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
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Fri Oct 22, 2004 12:06 am   

case or if statements to organize attacks?
 
I have a skill that will allow me to view my opponents defences in order to find a weakness.
However, it is very hard to keep up with it in the heat of battle.
What I want to do is the following:
check defences: You look carefully at Someone.
I have about 8 attacks that I need to do quickly if my opponent has been so foolish as to not have the proper protection up when comming to face me.
The attacks have a priority though. #1 attack is better than #8 attack.
These are the attacks, and the things I need to look for to make my efforts successful.
#1 attack: freezing
You are surrounded by a protective pentacle. (defence)
You have limited immunity to cold attack. (defence)
You have limited immunity to fire attack. (makes you vulnerable if you have no cold resistance)
#2 attack: hypnotize
You are surrounded by a protective pentacle. (defence)
You are ignoring by reflex hostile runes and bedazzling. (defence)
#3 attack: sleep
You are surrounded by a protective pentacle. (defence)
You have enhanced the power of your adrenalin. (defence)
#4 attack: cursing
You are deaf and are immune to Songs and the Voice. (defence)
#5 attack: poisoining (general)
You are surrounded by an aura of divine light. (defence)
#6 attack: poisoning (fatal)
You are surrounded by a protective pentacle. (defence)
You are immune to most fatal poisons. (defence)
#7 attack: throwing daggers
You are surrounded by a protective pentacle. (defence)
You are dodgning incomming projectiles. (defence)
#8 attack: sword
You are surrounded by a protective pentacle. (defence)
Weapon attacks will be turned back upon the offender. (defence)
What I want to do is play a specific sound for the available attacks.
If there happens to be more that one available it could get very confusing. So I would like for the client to determine the top most priority attack and play its sound only, the others should remain silent. Im thinking a case statement may be the way but, Im open to suggestions if someone thinks there may be a simpler way to manage this.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Oct 22, 2004 1:00 am   
 
I would likely set this up with a list and a record variable. Roughly the trigger that starts receipt of the person's defenses would establish the list. I believe that would be "You look carefully at Someone." in your case. The list would be set to contain all the attack names in order of priority "freezing|hypnotize|sleep|cursing|poisoning general|poisoning fatal|throwing daggers|sword".

Next establish a record variable with all the different defense lines as keys and which attacks they defend against as values. For example:
#ADDKEY DefRec {You are surrounded by a protective pentacle.} {freezing|hypnotize|sleep|poisoning fatal|throwing daggers|sword}

Then by triggering directly off your record variable and removing from the list all those that are defended you have a short value to work with to select a sound:
#TR {({@DefRec})} {#FORALL {%db(@DefRec,"%1")} {#DELITEM ListVar {%i}}}

Finally whatever triggers the end of the person's defenses report would check the list using %item(@ListVar,1) and play the right sound or simply take the appropiate action. Since this could forseeably eliminate all your attacks I would suggest you build in a default action by checking %numitems(@ListVar) for 0.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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