Re: Delay skills

From: Allan Grant (pheonix@iq-corp.com)
Date: 05/24/00


First of all you don't just want to delay it.  If you delay it then
during
the time of the delay the person will just sit there not being able to
do
anything, not even seeing a promp in between.
Second of all, the reason it gives you the error is because the delay
function doesn't exist in CircleMUD (I don't believe so anything).
WAIT_STATE is defined in utils.h and is used and is used in the code
fore
delays but this won't work for you because WAIT_STATE is used to put a
delay on player commands, not on the messages he receives.

What you need is a bit harder to do.  The best way if you want to put
this kind of delay on skills and spells would be to probably add a
variable in char_special_data in structs.h.
For example you could add:
int casting_spell;
sh_int casting_ticks;

Then in spells.h, in spell_info_type add at the bottom just below
int targets:
sh_int ticks;

Then in spell_parser.c in void spello add at the bottom, just below
spell_info[spl].routines = routines; :
spell_info[spl].ticks = ticks;

Then go down below to where it says:
#define skillo(skill) spello(skill, 0, 0, 0, 0, 0, 0, 0);
and change it
#define skillo(skill) spello(skill, 0, 0, 0, 0, 0, 0, 0, 0);

Then a little further down where all the spello calls are
and add the ticks it takes to cast each spell.  For example if you want
armor to take 3 ticks to cast change:
  spello(SPELL_ARMOR, 30, 15, 3, POS_FIGHTING,
        TAR_CHAR_ROOM, FALSE, MAG_AFFECTS);
to:
  spello(SPELL_ARMOR, 30, 15, 3, POS_FIGHTING,
        TAR_CHAR_ROOM, FALSE, MAG_AFFECTS, 3);

Now you have all your spells defined in how many ticks each one takes.
Then you have to make it do something.  Still in spell_parser.c go to
ACMD(do_cast) and at the bottom, just below
      if (mana > 0)
        GET_MANA(ch) = MAX(0, MIN(GET_MAX_MANA(ch), GET_MANA(ch) - mana));
add:
      if (SINFO.ticks) {
        ch->char_special_data->casting_ticks = SINFO.ticks;
        ch->char_special_data->casting_spell = spellnum;
      }

Now what that does is it sets the ticks and the spell variable up.
Now you have to make it where each tick it decreases the spell ticks
by 1 and if the ticks are == 0 it gives a message that you set up
in constants.c for that spell.
So go into limits.c, and at the top add:
extern char *spell_finish_cast_msg[];

Now go to void point_update(void) and add just after the three
gain_condition statements :
    /* Spell message count down */
    if (i->char_special_data->casting_ticks) {
      i->char_special_data->casting_ticks--;
      if (!i->char_special_data->casting_ticks) {
        if
(*spell_finish_cast_msg[ch->char_special_data->casting_spell]) {

send_to_char(spell_finish_cast_msg[ch->char_special_data->casting_spell],
i);
          send_to_char("\r\n", i);
          ch->char_special_data->casting_spell = NULL;
        }
      }
    }
    else
      ch->char_special_data->casting_spell = NULL;

Almost done now.  All you have to do is set up the char
*spell_finish_cast_msg[].
So go to constants.c and somewhere in there (maybe above the
spell_wear_off_msg[]) add:
const char *spell_finish_cast_msg[] = {
  "RESERVED"  /* 0, not casting a spell */
  "You feel your armor spell solidify."
  ...
And define the finish casting message for all the spells that you set
up as spells which aren't cast instantly (the spello definitions).

There is one other thing though that I just remembered that you'd have
to do, make it where someone who is already casting a spell can't start
to cast another until that one is finished.  In spell_parser.c in
do_cast just below the if (IS_NPC(ch)) return; (near the very top) add:
  if (ch->char_special_data->casting_ticks) {
    send_to_char("You are already casting a spell.\r\n", ch);
    return;
  }

Now here are some problems with the above, not hard to fix:
* The spell will still go off right after you type cast, you just get
another message later.  This is to simulate something like:
You feel an armor begin to form around you.
1 tick passes
You feel your armor spell solidify.
* Second problem is it would take at least a tick to cast all the
spells that you want to put these messages on.  Tick is around 45
seconds.  So it definately wouldn't work for violent spells except
for maybe some special violent spells because the person won't be
able to cast one each round.  They'll be able to still do skills and
stuff while casting but they just won't be able to cast another spell.
If you want it to take less time make it check every violence pulse
instead of every tick.
* If after someone starts to cast they quit and re-enter it will get rid
of that whole casting delay since it doesn't save.  You could add a
check in the save command that you can't quit until you finish casting.
* Probably a bunch of other problems :)

This is just a pretty quick, rough hack so you'll probably have to fix
some errors or typos I may have made but this gives you kind of an idea.
If you wanted to make it really well where it takes out the mana over
the casting period and you have a chance of failing concentrating
all while casting and have it where the spell only finally goes off
after some ticks (or pulses) go off what you'd have to do is add a
whole bunch more variables in char_special_data (or some other struct)
and do that.

Hope it helps,


Allan | Pheonix


Alex Mann wrote:
>
> Hi I wanted to add
>
> send_to_char("blah")
> delay(100);
> send_to_char("blah")
>
> To make my skills and spells more interesting by giving the cast stages
> which are time delayed.
>
> However i put it into the code, and I get an implicite declaration error,
> any one know, what the problem is, I'm not sure if i need to spcify a
> specific .h file to make it work.
>
> Any help Mucho Appriciated
> Alex mann
> (high-lord)
> www.naryan.co.uk
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
>      +------------------------------------------------------------+


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT