[CODE][LONG]New spellcasting

From: Siber Wulf (sibrwulf@hotmail.com)
Date: 06/07/01

I felt creative last night, so I added a new type of spellcasting.  It works
_alright_ with a few kinks.

Here's what I did, using Circlemud 3.0 (very modified):

I wanted players to take time to cast a spell.  I also wanted to modify
their prompt to show how far along they are in the spellcasting.  I modified
the following lines:

inside comm.c in the heartbeat I added
if (!(pulse % (PASSES_PER_SEC)))                /* 1 second */


this is used to update the progress of each player's spellcasting every

Heres is the func update_spells
void update_spells(void)
  struct char_data *i, *next_char;
  for (i = character_list; i; i = next_char)
        if (IS_CASTING(i))
          if ((i)->player.casting_time_left > 1)
          else if ((i)->player.casting_time_left == 1)
                send_to_char(make_prompt(i), i);
                cast_spell(i, i->player.spell_vict,
i->player.spell_obj_vict, i->player.casting_spell);
                IS_CASTING(i) = 0;
(sorry about the long lines)

inside the spell_parser.c I modified the ACMD(do_cast) to look like this:
(near the end of it)
ch->player.spell_vict = tch;
ch->player.spell_obj_vict = tobj;
ch->player.casting_spell = spellnum;
ch->player.casting_time_left = SINFO.casting_time;
/* cast spell returns 1 on success; subtract mana & set waitstate */
//if (cast_spell(ch, tch, tobj, spellnum))
//      if (mana > 0)
//              GET_MANA(ch) = MAX(0, MIN(GET_MAX_MANA(ch), GET_MANA(ch) - mana));
This assigns the target data to the char struct, sets them to casting, and
sets up the casting time left.

I also added a line to the make_prompt func:
right before strcat(prompt, ">");
if (IS_CASTING(d->character))
spell_percent = 100 *
(spell_info[d->character->player.casting_spell].casting_time -
(d->character->player.casting_time_left)) /

sprintf(prompt + strlen(prompt), "%s(%s %d)", BCCCYN(d->character, NRM),
spells[d->character->player.casting_spell], spell_percent);
all the objects I created in this are working fine, cept I want to modify
the code in order to send a prompt to the char at certain keypoints in the
spellcasting (25%, 50%, 75%, 100%)  I have spells set to a generic 5 real
life seconds to cast(it works great) but that won't fall on 25%, 50%, etc.
I wanted to multiply the casting time (in seconds) by PULSES_PER_SECOND and
then remove the update_spells() from inside the if statement.  While I
realize that this will bog down the performance of the code, i might be able
to get away with 2 times every second.  How do I do this?

Thanks in advance. (sorry about the long lines)

Get your FREE download of MSN Explorer at http://explorer.msn.com

   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |

This archive was generated by hypermail 2b30 : 12/05/01 PST