Stateful mobprogs

 
Post new topic   Reply to topic    mudlab.org Forum Index -> Code Vault
View previous topic :: View next topic  
Author Message
Tyche



Joined: 13 May 2005
Posts: 176
Location: Ohio, USA

PostPosted: Sat May 28, 2005 11:22 am    Post subject: Stateful mobprogs Reply with quote

== MPStatus command for Mobprogs ==

This snippet allows you to store and read state in Mobprogs.

In mob_prog.c add this define...
Code:

#define CHK_STATUS      (53)


In fn_keyword[] add this...
Code:

  "status",  /* if status $n == 1000  - checks status value on obj,room or mob */



In cmd_eval() near the end after case CHK_GRPSIZE: add...
Code:

  case CHK_STATUS:
    lval = lval_char->mprog_status;
    break;



Add the following to the CHAR_DATA structure in merc.h
Code:

  int   mprog_status;


Add an entry to mob_cmd_table[] in mob_cmds.c
Code:

  {"status", do_mpstatus},


Add this routine or similar to mob_cmds.c
Code:

void do_mpstatus (CHAR_DATA * ch, char *argument)
{
  char arg[MIL];
  char errbuf[MIL];

  if (ch == NULL)
    return;

  one_argument (argument, arg);
  if (!is_number (arg)) {
    sprintf (errbuf, "MpStatus: invalid arg from mob vnum %d.",
        ch->isNPC() ? ch->pIndexData->vnum : 0);
    wiznet (errbuf, NULL, NULL, WIZ_PROGS, 0, 0);
    return;
  }
  ch->mprog_status = atoi (arg);
}


Get it working and now your mprogs have the capability to save and query state.

The following fight trigger is an example of usage:

Code:

if status $i == 0
  poke $n
  say You look delicious, $n.
  mob status 1
  end
endif
if status $i == 1
  say I have a feeling your flesh will be rather tough.
  mob echo A bolt of energy flies from $I's hand!
  mob cast 'force bolt' $n
  chortle
  mob status 2
  End
endif
if status $i == 2
  if rand 25
    mob status 0
  endif
endif
end


Enjoy or die.

Article at QuickSnippets
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    mudlab.org Forum Index -> Code Vault All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
BBTech Template by © 2003-04 MDesign