Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
eupher
Apprentice


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Wed Nov 14, 2001 5:34 am   

trigger timing problem?
 
I have a healing script that is giving me problems. First off, I have a db style variable that tracks the name and max hp of my group members:

#show @group_hp
Booga1327Hobbes3025

My healing trigger matches on a prompt I receive during combat, which shows the % hp of the group member that is most injured:

Hobbes:[ 54%][ Booga]:[1540h][2141m/b]

I have configuration variables that store the mana cost and healing power of a few healing spells. I also have a @healing variable that tracks whether I am currently in the process of throwing a healing spell (I sent the spell to the mud but it hasn't fired yet).

When I receive a combat prompt, I check to see if I'm already in the process of casting a healing spell (@healing = 1). If not I check to see if I should throw a spell. If so, I set @healing = 1 and then throw the spell.

The idea is that I should never try to cast a healing spell until the last one completed. This seems to work about 95% of the time. However, occassionally I will send a second healing spell before the first one fired (as if @healing wasn't set to 1 as it should be).

The only pattern to this behavior that I can find is that it usually accompanies a period of rapid output from the mud (usually from a spot of lag). This makes me wonder if zmud isn't finishing the commands associated with the trigger before it starts processing the commands for the next trigger.

If this is the case.. is it a bug or is there a way to work around it? If this is not the case then apparently I have a bug in my script. So, I'm including that, too. :)

Pattern -> (%w):~[(&03)~%~]~[(&08)~]:~[(&04)h~]~[(&04)m/b~]$



#if (@auto_heal > 0) {
patient = %trim( %1)
#if (@patient = "someone") {#abort 1}
#if (@{group_hp.@patient} = "") {
#if (@checking_group > 0) {#abort 1} {
checking_group = 1
group
#abort 1
}
}
patient_max = @{group_hp.%trim( %1)}
patient_current = %eval( @{group_hp.%trim( %1)} * %2 / 100)
patient_low = %eval( @patient_max - @patient_current)
patient_heal = %eval( @patient_max - @heal_power)
patient_critical = %eval( @patient_heal * @critical_percent / 100)
me_current = %4
me_max = @{group_hp.%trim( %3)}
me_low = %eval( @me_max - @me_current)
me_heal = %eval( @me_max - @heal_power)
me_critical = %eval( @me_heal * @critical_percent / 100)
#show @patient has @patient_current / @patient_max hp
#if ((%eval( @patient_current <= @patient_critical)) AND (@healing = 0)) {
healing=1
cast '@fast_heal_spell' @patient
}
#if ((@me_current <= @me_critical) AND (@healing = 0)) {
healing=1
cast '@fast_heal_spell'
}
#if ((@patient_low >= @group_heal_power) AND (@me_low >= @group_heal_power) AND (@healing = 0)) {
healing=1
cast '@group_heal_spell'
}
#if ((@patient_current < @patient_heal) AND (@healing = 0)) {
healing=1
cast '@heal_spell' @patient
}
#if ((@me_current < @me_heal) AND (@healing = 0)) {
healing=1
cast '@heal_spell'
}
}


Thanks for any help.

Eupher
Reply with quote
eupher
Apprentice


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Wed Nov 14, 2001 5:41 am   
 
I ran out of room so I'm including a log of the problem in action here:

quote:

Hobbes:[ 54%][ Booga]:[1540h][2141m/b]
Hobbes has 1633 / 3025 hp
cast 'reinvigorate' Hobbes

Joie raises their arms in the air and begin to weave an intricate pattern of magic.

Hobbes:[ 54%][ Booga]:[1540h][2141m/b]
Hobbes has 1633 / 3025 hp

a grey wolf misses Vensi Boda Boda of the Academy.
Niritti's shockwave bruises Vensi Boda Boda of the Academy!
Vensi Boda Boda of the Academy wounds Hobbes!
Vensi Boda Boda of the Academy pulls a prism from his satchel and thrusts it at Hobbes!
Vensi Boda Boda of the Academy utters the words, 'tapaen korno ha'.
Vensi Boda Boda of the Academy's colour spray bruises Hobbes!
Hobbes's slash bruises Vensi Boda Boda of the Academy!
Vensi Boda Boda of the Academy parries your attack.

Hobbes:[ 47%][ Booga]:[1541h][2143m/b]
Hobbes has 1421 / 3025 hp

Niritti utters the words, 'fpullonv'.
Niritti's blizzard hits Vensi Boda Boda of the Academy!

Hobbes:[ 47%][ Booga]:[1541h][2143m/b]
Hobbes has 1421 / 3025 hp
You raise your arms into the air and begin to recite a prayer to your god.

Hobbes:[ 47%][ Booga]:[1541h][2143m/b]
Hobbes has 1421 / 3025 hp

Hobbes tells the group 'this mob smokes crack'.

Hobbes:[ 47%][ Booga]:[1541h][2143m/b]
Hobbes has 1421 / 3025 hp

Hobbes utters the words, 'apuri arvoten'.
Hobbes's vision is restored.

Hobbes:[ 47%][ Booga]:[1541h][2143m/b]

Joie utters the words, 'gu'on da'an rpokid'.
Joie's pillar of flames injures Vensi Boda Boda of the Academy!
Vensi Boda Boda of the Academy mauls Hobbes!
Vensi Boda Boda of the Academy beats Hobbes over the head with a watering can!
Vensi Boda Boda of the Academy's bash bruises Hobbes!
Vensi Boda Boda of the Academy bashes Hobbes over the head knocking them to the ground.
Hobbes's slash misses Vensi Boda Boda of the Academy.
You concentrate all the energy into a burst of mystical words!
You cast the spell for 140 mana.
You gain 770 experience.
You heal your target for 385 points.
Hobbes has many nasty wounds.
Ok.
Vensi Boda Boda of the Academy parries your attack.

Hobbes:[ 53%][ Booga]:[1542h][2005m/b]
Hobbes has 1421 / 3025 hp
cast 'reinvigorate' Hobbes

Niritti utters the words, 'yino'.

Hobbes:[ 59%][ Booga]:[1542h][2005m/b]
Hobbes has 1784 / 3025 hp
cast 'reinvigorate' Hobbes
You raise your arms into the air and begin to recite a prayer to your god.

Hobbes:[ 59%][ Booga]:[1542h][2005m/b]
Hobbes has 1784 / 3025 hp
You stop chanting...
You raise your arms into the air and begin to recite a prayer to your god.



The script behaved as intended up until the end of that log... when a second healing spell was sent before the first one completed.

If you've read this far then you truly are dedicated... and I appreciate your time. :)

Eupher
Reply with quote
decantor
Apprentice


Joined: 14 Nov 2001
Posts: 100

PostPosted: Wed Nov 14, 2001 6:50 am   
 
Although I *just* downloaded 6.22, it seems to me that what you should try doing is using the new trigger types to do all this coding for you. I don't know the new syntax yet, but basically what you would do is:

set your autoheal triggers on.
set a trigger to evaluate your group's health and assign the @patient variables.
Use one of the new state-type triggers(probably loop pattern) to cast the heal spell.
Set the next state of this trigger to execute when your heal spell is cast.

As far as I can tell, this should work without a hitch, for your auto-casting trigger will be disabled until you have actually casted the spell.

Sorry I can't be more help with the syntax, but I haven't had a chance to play around with it yet! Maybe if you're still having problems someone with more 6.2 finesse will help ;)
Reply with quote
eupher
Apprentice


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Wed Nov 14, 2001 2:26 pm   
 
I'd like to get this working without the new state triggers for a few reasons, most importantly being that I'd like to share the script with people that may not be running 6.22. Also, I'm not sure a state trigger would work for this. I could easily be wrong... I read the help file on them once but I haven't used them at all yet. The problem I see is that after I send the heal spell to the mud, I have a number of triggers that determine the spell was cast (or attempted). For example:

^They aren't here.$ // maybe I was blinded, or they already died or fled the room
^You lost your concentration.$
^The round was too hectic.$

I have triggers matching patterns similar to those, all of which set @healing = 0 so I am ready to throw another spell.

If the new state triggers can handle this (cool) and nobody is able to help me with why my script doesn't work as is, then I guess I'll take your suggestion and rewrite it with state triggers. I'm really curious to know why the script doesn't work though.

Any other ideas?

Thanks again,
Eupher
Reply with quote
decantor
Apprentice


Joined: 14 Nov 2001
Posts: 100

PostPosted: Wed Nov 14, 2001 3:46 pm   
 
Well, I still can't be much help with the syntax the way you have written it, simply because your coding style is far different than mine. If there are different outcomes of the same event, I generally use && syntax instead of using a whole bunch of IFs. For instance, I would use something like:

Hobbes:[ 47%][ Booga]:[1541h][2143m/b]

#TR {(%w):[ (%d)][(%d):[(%d)h][(%d)m/b]} {[patient = %1];[current_patient_percentage = %2];[etcetera];[@autocast];[#t- auto_heal_trigger]} {auto_heal_trigger}

#ALIAS autocast: (much easier to set up in the settings editor than on command line)

#IF [(@patient!="Someone")&&(@auto_heal=1)&&(100>current_patient_percentage>60)] {[cast whatever_spell_you_would_under_such_circumstances] abort}
#IF [(@patient!="Someone")&&(@auto_heal=1)&&(60>current_patient_percentage>20)] {[cast whatever_spell_you_would_under_such_circumstances] abort}

I would then add triggers for all the outcomes of these event, success and failures, to do one command:

#t+ auto_heal_trigger

On the preview, the plus sign is parsed, so in case it is when I post it, that last command would be #t(plus sign) auto_heal_trigger.

I'm not entirely sure that this is actually any different than the way you did it, for they do seem to have a lot of similarites. I'm also not entirely certain that the syntax as I have written it is perfect, for it is very early in the morning and I'm still waiting for the coffee to finish brewwing.
Reply with quote
Kru
Beginner


Joined: 14 Nov 2001
Posts: 28

PostPosted: Wed Nov 14, 2001 11:07 pm   
 
Where do I find out about these state triggers?

:)
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Wed Nov 14, 2001 11:45 pm   
 
Trigger States are reserved for users of Bay-Tuh. Without access to Bay-Tuh, they don't help you.

Bay-Tuh is not for everyone - it can be lethal to your computer, so you might just want to wait for free admission to Puh Blick when it becomes available.




Who has noticed that when users see beta they often think that means Download me! I work fine, and will be your new best friend!
zMUD 6 Online Help: All the power you'll ever need.
Reply with quote
eupher
Apprentice


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Thu Nov 15, 2001 1:41 am   
 
While I sincerely appreciate the time decantor took to provide input, is there nobody out there that can tell me why my script does not work? Surely there's some guru out there that would have an idea. Should I email it in as a zmud bug?

Eupher
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Nov 15, 2001 7:32 pm   
 
One possibility appears to be that (@patient_current <= @patient_critical) at the same time that (@patient_current <= @patient_heal). Given (@healing = 0), both of these might fire since zMUD usually evaluates the entire trigger before updating variables. If both @fast_heal_spell and @heal_spell were "reinvigorate" you'd have trouble distinguishing between the trigger firing twice or merely executing multiple, non-nested #IF statements.

I'm not saying this is the case, but it's the only thing I could come up with.

LightBulb
Reply with quote
eupher
Apprentice


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Thu Nov 15, 2001 8:46 pm   
 
As it is, @fast_heal_spell = 'reinvigorate' and @heal_spell = 'greater heal'. If zmud evaluated all of the conditions before it executed any code, then that certainly seems like it could cause problems. However, I'm not convinced that's the case. In every situation where (@patient_current <= @patient_critical) evaluates to true, (@patient_current <= @patient_heal) would certainly also evaluate to true. However, I have never experienced this trigger sending 2 seperate healing commands at once (triggered by a single combat prompt). The problem is that it triggers a healing command and should set @healing = 1, but then it triggers another healing command the next time a prompt is matched even though @healing should still be 1.

Eupher
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 16, 2001 6:44 pm   
 
Since your log shows that zMUD sent the first healing command before the second prompt arrived you can reasonably assume that it had time to set @healing to 1 before the second prompt was processed, especially since you change the variable before you cast. That means there's probably something in your script that's causing the problem. Be sure to check all your settings, the problem could be in what seems like a totally unrelated class.

How do you set @healing to zero?

The most likely culprits are another trigger that also casts the reinvigorate (or a variable) spell or a trigger that changes @healing.

LightBulb
Reply with quote
eupher
Apprentice


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Fri Nov 16, 2001 8:00 pm   
 
That was the first thought I had... and the first thing I looked for. However, the only trigger I have that casts any healing spell is the one I listed here. I do have several triggers that set @healing = 0, but none of them should have fired here. In the example I gave, there are 4 possible lines that could have caused another trigger to fire that might set @healing = 0:

quote:

Niritti utters the words, 'yino'.
<blank line>
Hobbes:[ 59%][ Booga]:[1542h][2005m/b]
Hobbes has 1784 / 3025 hp



The triggers I have to set @healing = 0 match on patterns like:

^You cast the spell for {55|75|140} mana.$
^You lost your concentration.$
^You get a mental block and are unable to complete the casting.$

None of those should match on the line "Niritti utters the words, 'yino'."

If I had a trigger that set @healing = 0 on a blank line then I'd be throwing spells at ever single prompt, so that's not it either.

The combat prompt is what I match to possibly throw a spell and set @healing = 1. As you can see, at no point in that trigger does it set @healing = 0.

The last line is just output from my trigger. That's another case where if I were matching that and setting @healing = 0 then I would end up throwing a healing spell at every combat prompt.

You have a good idea here, but it's something I already thought of and checked carefully. For instance, the trigger originally set @healing = 1 AFTER I sent the spell. I reversed the order just in case that was the problem... but that didn't fix it.

I'm out of ideas that exclude it being a zmud bug. Like somehow the next prompt is getting processed before @healing is truly changed to 1 by the first prompt. I'm leaning in this direction especially since the problem only happens when I get a bunch of output from the mud quickly. If I'm in a small group and am not experiencing any lag then I hardly (if ever) see the bug. However, when I'm in a big group with lots of fighting spam... especially if there's any lag... then I see the bug frequently.

Thanks again for the input. I'm going to file a bug report tonight and see what Zugg thinks.

Eupher
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net