Thomas, using your suggestion I found a solution that works:
First, I have a trigger on NPC load that defines the global variables used:
Code:
#1511
Load raphael global variables~
0 gn 100
~
*
* Set the variables on load because aura needs to be defined before
* checked in trigger #1507
*
* Set the variables on greet because aoh needs to be redefined if
* the value has been incremented in a previous fight.
*
eval aura 0
global aura
eval aoh 0
global aoh
~
Second, there is the combat trigger.
Code:
#1507
Raphael's aura of healing~
0 k 100
~
*
* aoh and aura are defined on load and on greet in trigger #1511
*
* the 'aura of healing' spell is an event and the spell sets the
* value of aura to 1. The event cooldown sets the value of
* aura to 0.
*
* Aura of Healing may only be cast when the aura variable is 0 and
* fora maximum of 5 times.
*
eval max_aoh 5
if %aoh% < %max_aoh%
if !%self.aura%
dg_cast 'aura of healing'
eval aoh %aoh% + 1
global aoh
end
end
~
Third, and the most important, is managing the %aura% variable via the perform_set_dg_var() function from dg_scripts.c
In the EVENTFUNC(event_cooldown) of mud_event.c
Code:
case eSPL_AURA_OF_HEALING:
REMOVE_BIT_AR(ROOM_FLAGS(rnum), ROOM_AURA_HEALING);
for (tch = world[rnum].people; tch; tch = tch->next_in_room)
if (IS_NPC(tch))
perform_set_dg_var(tch, tch, "aura 0");
and in the mag_rooms() function of magic.c
Code:
case SPELL_AURA_OF_HEALING:
IdNum = eSPL_AURA_OF_HEALING;
if (ROOM_FLAGGED(rnum, ROOM_AURA_HEALING))
{
send_to_char(ch, "There is already an aura of healing in this room.\r\n");
return;
}
if (!ROOM_FLAGGED(rnum, ROOM_AURA_HEALING))
{
perform_set_dg_var(ch, ch, "aura 1");
duration = GET_LEVEL(ch);
SET_BIT_AR(ROOM_FLAGS(rnum), ROOM_AURA_HEALING);
msg = "You cast an shield the room in an aura of healing.";
room = "$n shields the room in an aura of healing.";
}
break;
The load trigger defines the global variables. The perform_set_dg_var() function call sets the global variable on the NPC/caster when the event activates and/or cools down. The combat trigger manages the global variables.
This works as intended, but the implementation is a bit cumbersome because we're getting close to just writing a spec_fun instead.
Thanks for the help.
-Salty