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
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Wed Jan 02, 2002 11:33 pm   

trigger help with multiple IF
 
I'm having a problem with how to setup a trigger.

I'm using an alias along with the timer to run into a room, hit a monster, and run out. I have the ability to protect myself in two ways. Cast an invisibility or stoneskin spell, but sometimes I want to use either, both or none of the protections. I'd like to add these to an if statement or something similiar.

The if should check to see if I want stoneskin or an invis or both, then based on a variable cast that spell if it currently isn't on my person. Once it is cast it should go ahead and perform the i/o for combat.

Now obviously it can't cast both spells and start the combat in 1 round and there is a chance that the spell will fail.

Now that I've completely confused everyone does anyone have any ideas? I've tried a couple things but I'm running to a block at the point where I need to actually start the combat and I do/don't want both spells on.

I can post some of what I have if it would help anyone.

Thanks for any help.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jan 03, 2002 12:27 am   
 
I take you are using the tick timer so I will try to work with that.

#AL GoAndFight {
#IF (@ReadyToFight) {
@StepDirection
@KillCommand @MobName
AmFighting=1
ReadyToFight=0
} {
#IF (@AmFighting) {FLEE} {PrepToFight}
}

#AL PrepToFight {
#IF (%trigger(AwaitingSpellDisposition)=0) {
#IF ((@WantInvis)&(@AmInvis=0)) {
#T+ AwaitingSpellDisposition
Casting=invis
cast invis
}}
#IF (%trigger(AwaitingSpellDisposition)=0) {
#IF ((@WantStone)&(@AmStone=0)) {
#T+ AwaitingSpellDisposition
Casting=stone
cast stone
}}
#IF (%trigger(AwaitingSpellDisposition)=0) {
ReadyToFight=1
GoAndFight
}}

#CLASS AwaitingSpellDisposition
#TR {You blow your casting} {cast @Casting}
#TR {You succesfully cast} {#T- AwaitingSpellDispostion}
#CLASS 0

That should more or less do it. The less part is you have to put in whatever variable info and change the triggers appropiately. Then you just put GoAndFight as the tick command.
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Fri Jan 04, 2002 6:53 pm   
 
I took your suggestions, morphed them into my previous setup and after some more tweaking it seems to work well.

Thanks for the help! :)
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Fri Jan 04, 2002 9:22 pm   
 
I spoke too soon.

Zmud started crashing when certain criteria is met.. I've traced it down to this alias, anyone know what is wrong with it that it causes it to crash?

Alias "io" (used in place of GoAndFight in above info)

#IF (@ReadyToFight)&(@hp>@hpmin)& (@sp>@spmin) {
doio
ReadyToFight=0
} {PrepToFight}

It works fine as long as everything is true, when things are false (specifically hp is less than minhp) zmud closes completely w/o error message.
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Fri Jan 04, 2002 9:24 pm   
 
It also works fine if @ReadyToFight=0 and runs through the spell check w/o a problem.

It's only when my hp or sp get below min levels that it crashes.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jan 05, 2002 12:10 am   
 
Try replacing it with this:
#IF ((@ReadyToFight)&(@hp>@hpmin)&(@sp>@spmin)) {
It eliminates a space and encloses the whole thing a ()'s. It is proper syntax to have everything the if is checking on in one set. I make it my habit to put a set around each comparison to ensure proper order of operations. I believe the interior ()'s do nothing other then improve legibility.
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Sat Jan 05, 2002 4:46 am   
 
Thanks for the catch on the syntax.

Unfortunately it had no effect on the problem. Still crashes when @hp < @hpmin.

Odd because it seems like it would have teh same results as when ReadyToFight = 0, which does work and runs the PrepToFight alias correctly.

Am I using the IF statement incorrectly?

Any other ideas?
Reply with quote
iljhar
GURU


Joined: 10 Oct 2000
Posts: 1116
Location: USA

PostPosted: Sat Jan 05, 2002 6:41 am   
 
Try seeing if using the word 'and' does anything:

#IF ((@ReadyToFight) and (@hp>@hpmin) and (@sp>@spmin)) {

If not, try using 2 ampersands:

#IF ((@ReadyToFight) && (@hp>@hpmin) && (@sp>@spmin)) {


Iljhar
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Mon Jan 07, 2002 6:01 pm   
 
After further testing it seems the problem is not directly in this alias but somewhere in the PrepToFight alias that causes the crash.

I think my problem is I am attempting to add in two more things to the original code. Originally I want to pause the i/o if I want a stoneskin or invis. What I also need to do is to pause the i/o if my hps are too low or my sps are too low, and devour food, or guzzle wine. Both can be done at the same time.

Right now if ReadyToFight = 1, and my hp<hpmin, it calls PrepToFight and crashes. I think this is because PrepToFight is currently only handling my spells and doesn't know what to do about my hp/sp levels. So it's causing a loop.

What do I need to do to modify this?

Currently PrepToFight is:

#IF (%trigger( magebot|AwaitingSpellDisposition)=0) {
#IF ((@WantInvis)&(@AmInvis=0)) {
#T+ magebot|AwaitingSpellDisposition
Casting=invis
invis
}}
#IF (%trigger( magebot|AwaitingSpellDisposition)=0) {
#IF ((@WantStone)&(@AmStone=0)) {
#T+ magebot|AwaitingSpellDisposition
Casting=stoneskin
stoneskin
}}
#IF (%trigger( magebot|AwaitingSpellDisposition)=0) {
ReadyToFight=1
io
}

I need to add in a devour side when hp<hpmin and a guzzle wine when sp<spmin. Both can be done at the same time and can be done independently of the spell casting.

I'm still using the following "io" to call this alias:

#IF ((@ReadyToFight)&(@hp>@hpmin)&(@sp>@spmin)) {
doio
ReadyToFight=0
} {PrepToFight}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jan 07, 2002 6:31 pm   
 
You need to check hp and sp as part of PrepToFight and take the appropriate action when they are low. I'd just add a couple of new #IF statements AFTER the one that casts spells and BEFORE the one that calls "io". You'll still have looping problems if you run out of "side" or "wine", but otherwise this should work.

#IF (@hp <= @hpmin) {eat side}
#IF {@sp <= @spmin) {guzzle wine}

LightBulb
All scripts untested unless otherwise noted
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Mon Jan 07, 2002 6:58 pm   
 
Now that was a neat endless loop. :)

Using this setup:


#IF (%trigger( magebot|AwaitingSpellDisposition)=0) {
#IF ((@WantInvis)&(@AmInvis=0)) {
#T+ magebot|AwaitingSpellDisposition
Casting=invis
invis
}}
#IF (%trigger( magebot|AwaitingSpellDisposition)=0) {
#IF ((@WantStone)&(@AmStone=0)) {
#T+ magebot|AwaitingSpellDisposition
Casting=stoneskin
stoneskin
}}
#IF (@hp<=@hpmin) {devour side} {#noop}
#IF (@sp<=@spmin) {guzzle wine} {#noop}
#IF (%trigger( magebot|AwaitingSpellDisposition)=0) {
ReadyToFight=1
io
}

caused zmud to send "devour side" to the mud more times than I could count and then closed itself. This is starting to be a tad frustrating....
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Mon Jan 07, 2002 7:51 pm   
 
Instead of handling the hp/sp part in another alias, could I just adjust the basic alias/IF to handle it?

I'm thinking something along these lines:

#IF (@ReadyToFight)&(@hp>@hpmin)& (@sp>@spmin) {
doio
ReadyToFight=0
} {#IF (@hp<=@hpmin) {devour side} {#IF (@sp<=@spmin) {guzzle wine} {PrepToFight}}}


If I follow this correctly it shouldn't call PrepToFight unless I need a spell (ReadyToFight=0) and it should devour a side or guzzle wine if needed...

Anyone's thoughts on this? Think I'll go test it and see what happens.
Reply with quote
Altan
Beginner


Joined: 09 Mar 2001
Posts: 12

PostPosted: Mon Jan 07, 2002 7:57 pm   
 
That did it.

Seems to work well, thanks everyone for the assistance and dealing with me rambling....

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