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
Sutex-Kindred
Apprentice


Joined: 26 Aug 2009
Posts: 141

PostPosted: Tue May 10, 2011 6:53 pm   

Groups and healing.
 
I would like some help in getting this script to work please.
When I type Group "gr" alias, I get this below, This is a patched scripts taken form here and then converted , for my use, when and if can work.

Hit Points Mana Movement Align Exp needed Level
[ 5152/5152 ][ 2578/2578 ][ 1355/1355 ] [-1000] [ 7564084] [167 Th] Sutex
[ 5095/5095 ][ 3633/3633 ][ 945/945 ] [-1000] [ 15438043] [165 Wa] Halix
[ 3584/3584 ][ 4476/4476 ][ 1066/1066 ] [-1000] [ 15831605] [165 Mu] Zarlix

There can be as many as ten in a group. This is just my 3 characters , grouped

~[ (%d)/(%d) ~]~[ (%d)/(%d) ~]~[ (%d)/(%d) ~] ~[-(%d)~] ~[ (%d)~] ~[(%d) Th~] (%w) .. my new trigger not the original
Code:

#var current_hp %1
#var max_hp %2
#var currentmana %3
#var maxmana %4
#var currentmove %5
#var maxmove  %6
#var Align %7
#var expneed %8
#var level %9
#var name %10
#math hp_difference (@current_hp - @max_hp)
#math hp_percentage (@current_hp*100/@max_hp)
#if @hp_difference<@temp_hp {temp_hp=@hp_difference
#var healfirst @group_member}
#if @hp_percentage<@temp_percentage {temp_percentage=@hp_percentage
#var healmefirst @group_member}
#if @hp_percentage<21 {#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {13} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blink, red)dying %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blink, red)dying %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1}
#if @hp_percentage<41 {#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {12} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, red)hurting %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, red)hurting %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1}
#if @hp_percentage<61 {#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {14} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blue)wounded %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blue)wounded %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1}
#if @hp_percentage<81 {#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {10} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member has %ansi( bold, yellow)small wounds %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member has %ansi( bold, yellow)small wounds %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1}
#if @hp_percentage<96 {#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {2} {} {} {} "" {} {} {@group_member}
#say {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is scratched %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is scratched %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1}


Hope that's enough information
_________________
Entropy rules
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue May 10, 2011 8:17 pm   
 
One problem that I see right away is that your #IF statements are improperly formatted. You have, for instance:
Code:
#if @hp_difference<@temp_hp {...

The proper format would be:
Code:
#if (@hp_difference<@temp_hp) {...


Next, I strongly recommend against destroying and creating new buttons all the time in this code. You can change the values depicted in the button without destroying it.

Not really a problem, but something that could be greatly improved: use local variables whenever you can, instead of global variables. Also, don't use #MATH, use something like:
Code:
hp_difference = (@current_hp - @max_hp)

or:
Code:
#var hp_difference (@current_hp - @max_hp)


I would actually restructure your series of #IF statements into a #SWITCH. It would be much cleaner, and get rid of all those #ABORT commands. Also, I'm not entirely clear why it has "#math hp_difference (@max_hp-@current_hp)" is in every single #IF statement. If it needs to be done every time, it could be done outside of the #IF statements. You might be better off rewriting it from scratch, using the ideas in this code to see what to do. If I were doing it myself, I would probably have the code create the text string for the #SAY piecemeal, with each piece added to the string with a separate bit of code, and finally displayed with a #SAY.

This is just my off-the-cuff analysis from a quick look. I can't look at the code from with Cmud just now.
Reply with quote
Sutex-Kindred
Apprentice


Joined: 26 Aug 2009
Posts: 141

PostPosted: Wed May 11, 2011 4:40 am   
 
So much from using other peoples code,,,
Any chance that someone could just code this bit for me as my attempts have not worked , I can only get one line to work.

[ 5152/5152 ][ 2578/2578 ][ 1355/1355 ] [-1000] [ 7564084] [167 Th] Sutex
[ 5095/5095 ][ 3633/3633 ][ 945/945 ] [-1000] [ 15438043] [165 Wa] Halix
[ 3584/3584 ][ 4476/4476 ][ 1066/1066 ] [-1000] [ 15831605] [165 Mu] Zarlix

~[ (%d)/(%d) ~]~[ (%d)/(%d) ~]~[ (%d)/(%d) ~] ~[-(%d)~] ~[ (%d)~] ~[(%d) Th~] (%w) ... This is the one line I got working.
_________________
Entropy rules
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Wed May 11, 2011 8:16 pm   
 
change the 'Th' to '%w' and it should catch all
_________________
Discord: Shalimarwildcat
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