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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ggoss
Apprentice


Joined: 01 Nov 2006
Posts: 114

PostPosted: Wed Jan 03, 2007 2:16 am   

help with a health script
 
i have this health script from zmud that i use (2 actually, one adds in for mana) and there was an error with it in zmud, but still worked correctly, I was wondering if theres a way i can streamline this for cmud. Script doesn't even seem to work in cmud, though it let me put it in

#CLASS {Health Checker}
#TRIGGER {{(}&gpos{)}%s&%nhit/&%dmaxhit%shit,%s&%nmov/&%dmaxmov%smove &name} {#MATH hitper {@hit * 100/ @maxhit}
#MATH hitdif {@hit-@maxhit}
#IF (@hitper >= 95) {
#SU "("@gpos ") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference"
#COL bold,green
#cap tells
}
#IF ((@hitper < 95) and (@hitper >= 91)) {
#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference"
#COL brown
#cap tells
}
#IF ((@hitper < 91) and (@hitper >= 81)) {
#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference"
#COL yellow
#cap tells
}
#IF ((@hitper < 80) and (@hitper >= 51)) {
#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference"
#COL bold,magenta
#cap tells
}
#IF ((@hitper < 51) and (@hitper >= 31)) {
#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference"
#COL magenta
#cap tells
}
#IF ((@hitper < 31) and (@hitper >= 1)) {
#SU "("@gpos") "@hit"/"@maxhit" hit, -"@mov"/"@maxmov" move, mana "@name" === "@hitdif" difference"
#COL bold,red
#cap tells
}
#IF (@hitper <= 1) {
#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference -= MORTED =-"
#COL blink,bold,red
#cap tells
}
}
#TRIGGER {{(}&gpos{)}%s&%nhit/&%dmaxhit%shit,%s&%nmov/&%dmaxmov%smove,%s&%nmanas/&%dmanab%smana &name} {#MATH hitper {@hit * 100/ @maxhit};#MATH hitdif {@hit-@maxhit};#IF ((@hitper < 91) and (@hitper >= 81)) {#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference";#COL yellow;#cap tells};#IF ((@hitper < 80) and (@hitper >= 51)) {#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference";#COL bold,magenta;#cap tells};#IF ((@hitper < 51) and (@hitper >= 31)) {#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference";#COL magenta;#cap tells};#IF ((@hitper < 31) and (@hitper >= 1)) {#SU "("@gpos") "@hit"/"@maxhit" hit, -"@mov"/"@maxmov" move, mana "@name" === "@hitdif" difference";#COL bold,red;#cap tells};#IF (@hitper <= 1) {#SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "@hitdif" difference -= MORTED =-";#COL blink,bold,red;#cap tells}}
#CLASS 0
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jan 03, 2007 3:10 am   
 
Well off hand I'd recommend a few things.

I'd change all the #IF to a #SWITCH statement. The second thing I'd is maximize the use of local variables... I'd recommend modifying so that @hitper, @gpos etc use them. My personal rule of thumb is two or three references to the variable to offset the overhead (which is neglible if any at all) of declaring a local variable versus directly accessing a variable.
_________________
Asati di tempari!
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Jan 03, 2007 1:21 pm   
 
This should tidy things a little, and introduces a local variables and #SWITCH as Tech suggested.
Code:
#CLASS {Health Checker}
#TRIGGER {{(}&gpos{)}%s&%nhit/&%dmaxhit%shit,%s&%nmov/&%dmaxmov%smove &name} {
$hitper = (@hit * 100 / @maxhit)
$hitdif = (@hit - @maxhit)

#SWITCH ($hitper >= 95) {
    #SU "("@gpos95
    #COL bold,green
  }
  ($hitper >= 91) {
    #SU "("@gpos")" @hit "/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"
    #COL brown
  }
  ($hitper >= 81) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"
    #COL yellow
  }
  ($hitper >= 51) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"
    #COL bold,magenta
  }
  ($hitper >= 31) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"
    #COL magenta
  }
  ($hitper >= 1) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, -"@mov"/"@maxmov" move, mana "@name" === "$hitdif" difference"
    #COL bold,red
  }
  ($hitper < 1) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference -= MORTED =-"
    #COL blink,bold,red
  }

#CAP tells
}
#TRIGGER {{(}&gpos{)}%s&%nhit/&%dmaxhit%shit,%s&%nmov/&%dmaxmov%smove,%s&%nmanas/&%dmanab%smana &name} {
$hitper = (@hit * 100 / @maxhit)
$hitdif = (@hit - @maxhit)

#SWITCH (($hitper < 91) and ($hitper >= 81)) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"
    #COL yellow
  }
  ($hitper >= 51) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"
    #COL bold,magenta
  }
  ($hitper >= 31) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"
    #COL magenta
  }
  ($hitper >= 1) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, -"@mov"/"@maxmov" move, mana "@name" === "$hitdif" difference"
    #COL bold,red
  }
  ($hitper < 1) {
    #SU "("@gpos") "@hit"/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference -= MORTED =-"
    #COL blink,bold,red
  }

#CAP tells
}
#CLASS 0

Note I moved the #CAP tells outside the #SWITCH statement, since you seemed to be capturing it in every event.

Whether it'll get the script working as it did in zMUD I'm not sure. If it's still not right then I'd suggest cutting down what it does at first to pinpoint the problem - try remove the formatting and just leaving in the variables, since
#SU "("@gpos")"91 "/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"

Contains a lot of quotes that might be causing a few parsing problems
#SU @gpos 91 @maxhit hit @mov @maxmov move @name $hitdif difference

Or place {} around what you're substituting
#SU {"("@gpos")"91 "/"@maxhit" hit, "@mov"/"@maxmov" move, "@name" === "$hitdif" difference"}

Hopefully that either fixes it or gets you on the way to finding the problem
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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