Re: Events & Casting

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 01/22/02


On Tue, Jan 22, 2002 at 12:24:34AM -0600, David Cole wrote:
>I had a little bit of time today to look at do_cast in spell_parse.c, I
>haven't had much time really to ponder it, but at a glance, adding an event
>to do_cast looks a bit difficult? What I mean by an event is:
>
>c 'armor'
>You start casting a spell.
>casting: *****
>casting: ****
>casting: ***
>casting: **
>casting: *
>casting:
>You complete your spell.
>You feel someone protecting you.
>
I put something like that in mine (I assume you mean to have something
like casting speeds for different spells or just a general delay in it)
In a nutshell here's what you need to do, it's fairly simple really.
change do_cast so it handles a linked list, add an element to,
char_data->char_specials, like "struct spell_casting", then add a
function to step through the new linked list, decrement cast_time and
actually cast the spell then.

all do_cast would do would be to add to the linked list.
(not looking at my code right now

The structure needs to be something like:
struct spell_casting {
  int timer;
  struct char_data *victim;
  struct char_data *caster;
  int spell;
  struct spell_casting *prev_casting;
  struct spell_casting *next_casting;
}

Then in heartbeat you need something like
if(!(pulse % PULSE_SPELL))
  cast_list_update();


notes:
cast_list_update will need to reverify targets.

You probably will want to add in some code to prevent casting
another while casting a spell, cancel/remove a current spell when they
try to cast another at the same time, and/or to stop casting a spell.


It went fairly easy to me because I overhauled spells, removed the
spello information from the game to an external file to make things
easier to tweak.  So adding a new field "spell_speed" was fairly simple.


sounds like a lot, but it's only about 50 lines of code including
fluffy act() calls.
-mike

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT