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
Rugbystyle
Wanderer


Joined: 07 Oct 2001
Posts: 71

PostPosted: Wed Aug 20, 2003 6:21 pm   

Processing speed
 
This is a little bit tedious of a question, but I would like to know which method would be faster for Zmud to process...
Example - my character can use two different types of weapons so when I hit an alias for a sword attack I made a little script to check what I'm wielding and change to sword if not using it. Same with my shield. I have two ways, and just want to know which is more effecient (granted it's probably nanoseconds). Would it be faster to have the alias set the weapon variable every time the alias is activated, or have an #IF statement in the alias to check if the variable is NOT what I want, to change it to what the alias needs, and if it is, do nothing.???

IE with 'weaponattack' being the attack alias that checks and switchs the weapons as needed and performs the attack.

#ALIAS ls {weaponreq1=longsword;weaponreq2=shield;attack=slash @enemy;weaponattack}

setting the weapon alias everytime I hit the ls alias

OR

#ALIAS ls {#IF (@weaponreq1!=longsword) {weaponreq1=longsword};{#IF (@weaponreq2!=shield) {weaponreq2=shield};attack=slash @enemy;weaponattack}

checking if the variable needs to be changed

Second part of the set, for my weaponattack check. If it's more effecient to have multiple nested #IF statements, or a series of individual #IF statements, seeing if the alias that called it up wants two swords, sword and shield, or two shields.

#ALIAS weaponattack {#IF (@weaponReq1=@weaponReq2) {#IF (@lefthand=@righthand) {#IF (@lefthand!=@weaponreq1) {#IF (@lefthand=shield) {swords} {shields}}} {#IF (@weaponReq1=shield) {
unwield right
wield shield
} {
unwield left
wield @LeftSword
}}} {#IF (@lefthand=@righthand) {#IF (@lefthand=shield) {
unwield right
wield @rightsword
} {
unwield left
wield shield
}}}
@attack

nested multiple #IF statements
OR

#IF (@weaponreq1!=@weaponreq2 and @lefthand=@righthand and @lefthand=blade) {
unwield left
wield shield
}
#IF (@weaponreq1!=@weaponreq2 and @lefthand=@righthand and @lefthand=shield) {
unwield right
wield @RightSword
}
#IF (@weaponreq1=@weaponreq2 and @lefthand=@righthand and @lefthand!=@weaponreq1 and @lefthand=blade) {shields}
#IF (@weaponreq1=@weaponreq2 and @lefthand=@righthand and @lefthand!=@weaponreq1 and @lefthand=shield) {swords}
#IF (@weaponreq1=@weaponreq2 and @lefthand!=@righthand @lefthand=shield) {swords}
#IF (@weaponreq1=@weaponreq2 and @lefthand!=@righthand and @righthand=blade) {shields}
@attack

multiple individual #IF statments


Just trying to keep my scripts as effecient as possible. Thanks
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Wed Aug 20, 2003 7:23 pm   
 
The Best answer you will probably get will be this:

Think of it as such, The shortest distance from A to C is through B, but #if you have to check to see #if B is there first that would just be one more thing to do.

Answer 1: #ALIAS ls {weaponreq1=longsword;weaponreq2=shield;attack=slash @enemy;weaponattack}


Answer 2: no difference but
#ALIAS weaponattack {#IF (@weaponReq1=@weaponReq2) {#IF (@lefthand=@righthand) {#IF (@lefthand!=@weaponreq1) {#IF (@lefthand=shield) {swords} {shields}}} {#IF (@weaponReq1=shield) {
unwield right
wield shield
} {
unwield left
wield @LeftSword
}}} {#IF (@lefthand=@righthand) {#IF (@lefthand=shield) {
unwield right
wield @rightsword
} {
unwield left
wield shield
}}}
@attack
Would be better for checking

but ofcoarse I have not tested this and yes it is a maner of nanoseconds!!!!!!!!
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