Welcome to the Builder Academy

Question scripts checking for mud events?

More
12 Jun 2025 15:12 - 14 Jun 2025 04:43 #10757 by Salty
I've got an event that creates a healing aura which lasts one tick.  Currently the event is triggered by a dg_spell.  In my current  iteration I'm using the standard method of an incrementing trigger to count the number of casts and recast if charges are remaining.
Code:
Raphael's aura of healing~ 0 b 100 ~ eval max_aura 10 set actor %random.char% if %aura_num% < %max_aura%   dg_cast 'aura of healing'   eval aura_num %aura_num% + 1   global aura_num end ~
I've tried it in a combat trigger as well:
Code:
#1507 Raphael's aura of healing~ 0 k 100 ~ eval max_aura 10 eval tf ((%self.maxhitp% / 4) * 3) if %self.hitp% < %tf%   if %aura_num% < %max_aura%     dg_cast 'aura of healing'     eval aura_num %aura_num% + 1     global aura_num   end end ~

The problem I'm having is if the event is currently active and the trigger conditions are met, the trigger still fires, the spell is cast to no affect.  The counter is incremented and eventually maxes out without actually initiating the event the correct number of times.

I've looked through the existing triggers and from what I can see there are no triggers related to events.  There are no dg_queue triggers.  

I'm wondering how to implement a dg_queue trigger that works with an event.

Please advise.

Thanks.
Last edit: 14 Jun 2025 04:43 by Salty.

Please Log in or Create an account to join the conversation.

More
14 Jun 2025 01:09 #10758 by thomas
This is correct - I guess you need some kind of %self.event(eventname).active% check or similar. Unfortunately, events are extremely generic, and this is not an easy fix. Can the event set a script variable on the initiator? And unset on removal?
The following user(s) said Thank You: Salty

Please Log in or Create an account to join the conversation.

More
14 Jun 2025 04:47 - 14 Jun 2025 04:50 #10759 by Salty
Thomas, you said:

I guess you need some kind of %self.event(eventname).active% check or similar. Unfortunately, events are extremely generic, and this is not an easy fix.


I feel the same way.  The commented header portion of dg_event.c has the line:

* This system could easily be expanded by coders who wish to implement
* an event driven mud.

 I think this may be a timesink I'm not willing to invest in at this moment.


Thomas, you said:

Can the event set a script variable on the initiator? And unset on removal?


This is a very interesting idea that I'm going to explore.  It may be the path of least resistance.


Thanks for the advice.  I'll report back.

-Salty
Last edit: 14 Jun 2025 04:50 by Salty.

Please Log in or Create an account to join the conversation.

More
14 Jun 2025 08:15 - 14 Jun 2025 08:43 #10760 by Salty
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
Last edit: 14 Jun 2025 08:43 by Salty.

Please Log in or Create an account to join the conversation.

Time to create page: 0.432 seconds