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
Gatsby
Novice


Joined: 19 Dec 2006
Posts: 30

PostPosted: Wed Dec 20, 2006 1:03 pm   

Would this trigger work?
 
Greetings,

What I want to achieve is to quaff a calculated number of potions each time my SP drops below a certain level. The important thing is that when I want to quaff 2 potions I quaff 2 potions and not 5, 8 or 16 ... Confused

Here we go:

the amount 1 potion heals:
#VAR Potheal 100

trigger to catch SP and SPMax from the mud:
#TRIG {SP: &SP/&SPMax } {}

PotNeeded calculates the amount of potions I want to quaff
#VAR PotNeeded %int( ( @SpMax-Sp ) / @PotHeal )

if PotNeeded >= 1 quaff the potions (not sure if #@Potneeded will work, but this is not important)
#TRIG ( @PotNeeded) {#@PotNeeded {quaff potion} }

OK, I quaffed what I want, now to make sure I dont quaff more I enter a second state where I stay until the mud sends the SP back and @PotNeeded becomes 0 :
#COND ( !@PotNeeded ) {}

I am aware this trigger wont work as I want because I could be losing some SP after the quaffing, but before the mud sends me SP again, pushing @PotNeeded back to non-zero so I'd never get out of the second state, but that is not important atm.

The big question is if @PotNeeded =2 will I quaff exactly 2 potions?

Thanks in advance

Gats

PS stopped searching this forum after 2 fruitless hours of search...
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Dec 20, 2006 1:48 pm   
 
Do you need to use an expression trigger off the @Potneeded variable? Since you're waiting to get updated by the prompt, couldn't you just quaff when you get the prompt if required?

#TRIG {SP: &SP/&SPMax} {#if ((@SpMax-@Sp) >= @PotHeal) {quaff potion}}

that way you quaff one, but it waits til the prompt to see what your new health is, then quaffs another if required.
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Gatsby
Novice


Joined: 19 Dec 2006
Posts: 30

PostPosted: Wed Dec 20, 2006 2:06 pm   
 
This sounds like a good idea, I'll certainly experiment with it. Most of my "ovequaffing" was generated indeed because of the expression-trigger....

Thanks,

Gats

I'd still like to know if what I posted originally would work, because I have other similar ideas...
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Dec 20, 2006 3:20 pm   
 
I've had similar problems with expression triggers when I've been using them for similar things to you. I tend to rely on them for things that don't send text back to the mud, so more for updating other variables, buttons, etc. I'll probably play about with them a bit more when converting my scripts to use in CMUD (new, shiny, better, etc. blatant plug there)

Didn't notice you could stack commands in your original post. Could send a few commands at once just by altering my trigger quite easily
#TRIG {SP: &SP/&SPMax} {#if ((@SpMax-@Sp) >= @PotHeal) {#REPEAT %int( ( @SpMax-@Sp)/@PotHeal) quaff potion}}

Which would send 'quaff potion' the correct number of times

The problem could be though that you see the prompt again before the mud has processed all the quaffs.

So you could get

SP: 100/500
quaff potion
quaff potion
quaff potion
quaff potion
You drink the potion.
You drink the potion.
You drink the potion.
SP: 400/500
quaff potion
quaff potion
You drink the potion.
You drink the potion.

Where the mud processes 3 of the 4 commands sent but returns the prompt before the last drink - causing you to think that you need to quaff once more, and drinking too many as a result.
If that does happen then it might be easier to rely on the first method, where you only quaff one at a time.
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Gatsby
Novice


Joined: 19 Dec 2006
Posts: 30

PostPosted: Wed Dec 20, 2006 3:39 pm   
 
I just noticed that when using the pattern trigger, I still could be quaffing too much...

The mud sends the HP/SP in formation every combatround (~0.8secs)
So the next SP received might still be unchanged if the potion quaffing hasnt been processed yet, resulting in another quaff.

Actually the trigger should be suspended until I get the message "you quaff a potion" back from the mud... Then I know that the next SP will be updated.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Dec 21, 2006 4:35 am   
 
To solve the multiple-firing problem, use a second trigger state or use #T- and #TEMP in the trigger to temporarily disable it until you get the "You quaff" message.

Also, does that #@var syntax actually work? I've always used #loop in that situation.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Thu Dec 21, 2006 10:26 am   
 
#@var doesn't work, it needs to be numeric. #repeat works
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Gatsby
Novice


Joined: 19 Dec 2006
Posts: 30

PostPosted: Wed Dec 27, 2006 4:01 pm   
 
Thanks all, it works nicely now; Quaffing 1 potion based upon the pattern matching of @SP, and it works fast enough to prevent quaffing multiple ones. Luckily those potions heal a sick amount of SP so 1 is enough.

Again, Thanks,

Gats
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