Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ DPS meter
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Green
(6 posts) Bio
|
Date
| Wed 15 Aug 2018 07:10 PM (UTC) Amended on Wed 15 Aug 2018 09:15 PM (UTC) by Nick Gammon
|
Message
| Looking for a little help making a simple dps meter.
my basic understanding is something like...
Start a timer on the first attack message only
** set a flag to zero
>You deal 10 damage!
** if flag == 0, set the flag to 1 and run timer
Add the damage amount to a variable
wait for a death message
> A stalker just died!
zero the Dmg variable and display the ttl damage divided by time
> DPS: 12
I can't figure out timers, etc and my Dmg variable is not
updating the display :(
Thanx for any help :)
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="DPSmeter"
keep_evaluating="y"
match="^You deal (.*?) damage\!$"
regexp="y"
send_to="12"
sequence="100"
>
<send>Note("curr hit: %1 ")
SetVariable("Dmg",(GetVariable("Dmg") + %1))
Note(" curr dmg: @Dmg ")</send>
</trigger>
</triggers>
this is from 2 consecutive swings...
You attack a hideous mud stalker!
You deal 15 damage!
curr hit: 15
curr dmg: 0
You attack a hideous mud stalker!
You deal 9 damage!
curr hit: 9
curr dmg: 15 | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 15 Aug 2018 09:18 PM (UTC) |
Message
|
Quote:
I can't figure out timers, etc and my Dmg variable is not updating the display
Variables like @Dmg are evaluated before the script runs, so it will show the old value. You could use:
Note(" curr dmg: ", GetVariable ('Dmg'))
You will notice that the correct value (after the first hit) is shown after the second hit. That is the result of this. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Wed 15 Aug 2018 09:32 PM (UTC) |
Message
| It is easier to use Lua variables for something which changes frequently, and you don't care about the amount of damage from one session to the next.
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="DPSmeter"
keep_evaluating="y"
match="^You deal ([0-9]+) damage\!$"
regexp="y"
send_to="12"
sequence="100"
>
<send>
Note("curr hit: %1 ")
if not tonumber ('%1') then
ColourNote ("Red", "", "Damage '%1' is not a number")
return
end -- if
-- reset damage and timer on new fight
if DamageTimer == nil then
DamageTimer = utils.timer () -- get current time
Dmg = 0
end -- if
Dmg = Dmg + %1
Note(" curr dmg: ", Dmg)
</send>
</trigger>
</triggers>
All you need for timing is to note when the fight starts and store that in a variable, like above.
Then at the end of the fight you calculate the elapsed time to give you the DPS:
<triggers>
<trigger
enabled="y"
group="DPSmeter"
match="* just died!"
send_to="12"
sequence="100"
>
<send>
if DamageTimer then
local TimeTaken = utils.timer () - DamageTimer
local DPS = Dmg / TimeTaken
ColourNote ("Orange", "", "Total damage: " .. Dmg)
ColourNote ("Orange", "", string.format ("Time taken: %%0.2f seconds", TimeTaken))
ColourNote ("Orange", "", string.format ("DPS: %%0.2f", DPS))
DamageTimer = nil
end -- if
</send>
</trigger>
</triggers>
This code sets DamageTimer to nil when it is done, so that the other trigger can detect that a new fight has started.
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Green
(6 posts) Bio
|
Date
| Reply #3 on Fri 17 Aug 2018 12:36 PM (UTC) |
Message
| |
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,697 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top