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
Gargath
Newbie


Joined: 09 Apr 2021
Posts: 3

PostPosted: Fri Apr 09, 2021 5:05 pm   

Help with a script
 
Hello all,

I'd like to know if someone can help me with this script ? I try to store damage output into a variable. The probleme I have is the following. The damage output from Fist of Fury get store into a variable (string list), but when i try to get the sum of all the damage, it simply paste every data without calculating anything... any help ?

Code:

#TRIGGER {Your hands glow with an ethereal light as you hit *, who dies instantly! ~[%1~HP]} {#additem etherealdamage %1;#add etherealhit 1}
#TRIGGER {Your hands glow with an ethereal light as you hit *! ~[%1~HP]} {#additem etherealdamage %1;#add etherealhit 1}
#TRIGGER {with your deadly hit!!} {#add totalhit 1}
#TRIGGER {You hit} {#add totalhit 1}
#TRIGGER {You miss} {#add totalhit 1}
#VARIABLE etherealdamage {131 |231 |160 |148 |244 }
#VARIABLE etherealhit{0}
#VARIABLE totalhit {0}
#ALIAS totalhand {clansay Fist of Fury - Total Damage Deal: @etherealdamage - Proc Chance: %eval(@etherealhit*100/@totalhit)~% - Average Damage: %eval(@etherealdamage/@etherealhit)}


Thks in advance
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Fri Apr 09, 2021 5:55 pm   
 
* = mob name?
~[%1~HP] should be ~[(%d)~HP~]


alias needs to include something like...
Code:
#ALIAS {totalhand} {
#LOOP %numitems(@etherialdamage) {$totalDmg=($totalDmg+%pop(@etherealdamage))}
clansay Fist of Fury - Total Damage Deal: $totalDmg - Proc Chance: %eval(@etherealhit*100/@totalhit)~% - Average Damage: %eval($totalDmg/@etherealhit)}
}


Wasn't really seeing how you was getting the damage value to the 'etherealdamage' variable without using (%d), and to get a total damage value from a string list you needed to add each item, which the #Loop will do.
Reply with quote
Gargath
Newbie


Joined: 09 Apr 2021
Posts: 3

PostPosted: Fri Apr 09, 2021 6:57 pm   
 
FIGHT SAMPLE

Quote:
The Small Pond

? ? ? ? ?
? ? ? - ?
- - @ - ?
? - % ? ?
? ~ ~ ~ ?

[ e s w ]
A huge bengal tiger is eating his meal here. [ 0 ]
......the Bengal Tiger glows with a bright light!
An Elephant is eating contentedly here. [ 0 ]
An Elephant is eating contentedly here. [ 0 ]

<700H 864M 376V 1X 19:10:27 401E> kil bengal
The Bengal Tiger is hit full force with your lightning breath. [93 HP]
You OBLITERATE the Bengal Tiger with your deadly hit!! [26 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [31 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [29 HP]
You OBLITERATE the Bengal Tiger with your deadly hit!! [27 HP]
You OBLITERATE the Bengal Tiger with your deadly hit!! [27 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [28 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]

<700H 867M 380V 1X 24%D 19:10:30 401E> TICK IN 5 SECONDS.

the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [29 HP]
You OBLITERATE the Bengal Tiger with your deadly hit!! [26 HP]
The Bengal Tiger is hit full force with your lightning breath. [120 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [28 HP]
You miss the Bengal Tiger with your hit. [0 HP]
You TOTALLY DEMOLISH the Bengal Tiger with your deadly hit!! [32 HP]

<700H 869M 382V 1X 45%D 19:10:32 401E>
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
Your hands glow with an ethereal light as you hit the Bengal Tiger! [213 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [29 HP]
You OBLITERATE the Bengal Tiger with your deadly hit!! [25 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [29 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [29 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [28 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [29 HP]

<700H 871M 384V 1X 79%D 19:10:34 401E>
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
the Bengal Tiger misses you with his hit. [0 HP]
Even the air fears brushing against your Lords Light. [0 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [28 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [30 HP]
The Bengal Tiger is hit full force with your lightning breath. [138 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [28 HP]
You ANNIHILATE the Bengal Tiger with your deadly hit!! [28 HP]
The Bengal Tiger is dead! R.I.P.
You receive 32897 experience points.
Your blood freezes as you hear the Bengal Tiger's death cry.


DISPLAY RESULT
Quote:
You clan-say 'Fist of Fury - Total Damage Deal: 163 243 213 - Proc Chance: 8% - Average Damage: 0'


The data from "ethereal damage" is store correctly, but CMUD won't let me do the sum..
I've try with (%d) wich won't store the data, i'm cluless
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Fri Apr 09, 2021 7:43 pm   
 
Like I said it's showing the entire variable @etherealdamage as a 'stringlist' you need to set up a tempVar to add each item from that list to one another. the way I used the #Loop and %pop it checks the total number of items in the list to loop that many times, and each iteration of the loop it will add the first item to $totalDmg (a temp var) remove first item from stringlist, and continue til the loop is done. Should get you the total damage value of all items in the list.

etherealdamage = "163|243|213"

#Loop %numitems(@etherealdamage) **this is 3** {$totalDmg = ($totalDmg+%pop(@etherealdamage)} ** tempVar is empty or 0 at base, will add 0 + 163, loop, 163+243, loop, 406+213 = 619 **
alias then shows Total Damage Dealt : $totalDmg - Proc Chance: 8% - Average Damage: etc etc

If your trigs was capturing with %1 then that's fine.
Reply with quote
Gargath
Newbie


Joined: 09 Apr 2021
Posts: 3

PostPosted: Mon Apr 12, 2021 12:27 pm   
 
Have done everything you said.... strange thing.. it work on ZMUD... sad thing.. don't work CMUD... thks for help thought !!
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Tue Apr 13, 2021 6:42 pm   
 
I would offer some suggestions:

#TRIG {* ~[%d~]$} {@fightdamage=fightdamage+%1}

or, to tighten the usage to combat only, you can name it and enable it on a command input trigger

#ONINPUT {kill %w} {#VAR fightDamage;T+ calcDamage}
#TRIG calcDamage {* ~[%d~]$} {fightdamage=@fightdamage+%1;#T- calcDamage}

and even further:

#ONINPUT {kill %w} {#VAR fightDamage;#T+ calcDamage;#VAR hitCounter;#T+ calcAveDam}
#TRIG calcDamage {* ~[%d~]$} {fightdamage=@fightdamage+%1;hitCounter=@hitCounter+1}
#TRIG calcAveDam {<your fight is over/you get blah xp>} {#VAR aveDam=@fightDamage/@hitCounter;#T- calcDamage;#T- calcAveDam}
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