• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Dps Meter System

Status
Not open for further replies.
Level 10
Joined
Mar 19, 2010
Messages
622
I'm working on a boss-fight map and needed to have a dps meter for players to check their damage output but I really can't find one in hive's database. Can anyone create one, or teach me how to do it?

Details are as below:
-Shows it in multiboard
-Needed to have a total timer which used to calculate the total duration
-MUI
-A place to show the total damage dealt
-Damage dealt is only enumerated if it's dealt to a set boss
-Only one boss at a time can stay active
-So basically it is a dps meter showing all hero's dps to a boss

Thanks in advance.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
post this to your script...
JASS:
function Trig_DamageDealt_Copy_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real life = GetWidgetLife(u)
    local real life2
    local real damage = 100
    local real actualdamage
    //as you can see the damage is constant 100
    call UnitDamageTarget(u, u, damage, false, false, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL, null)
    set life2 = GetWidgetLife(u)
    //but the actual is different, depends on the ATTACK_TYPE_???
    set actualdamage = life - life2
    call BJDebugMsg("damage = "+R2S(damage))
    call BJDebugMsg("actual damage/damage dealt "+R2S(actualdamage))
endfunction

function InitTrig_DamageDealt takes nothing returns nothing
    set gg_trg_DamageDealt = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_DamageDealt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_DamageDealt, function Trig_DamageDealt_Copy_Actions )
endfunction
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
you can change via hashtable...just dont mind the 0x654 coz its a large integer number just to avoid conflicts...

e.g.
JASS:
set actualdamage = life - life2
call SaveReal(H, GetHandleId(u), 0x654, LoadReal(H, GetHandleId(u), 0x654) + actualdamage)
call BJDebugMsg("damage = "+R2S(damage))
call BJDebugMsg("actual damage/damage dealt "+R2S(LoadReal(H, GetHandleId(u), 0x654)))
I have a multiboard system with timers on it but its written in jass, sample is Here
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
take note that Im only telling how to get the actual damage and not doing the code you requested on post#1...

It requires JNGP and the Demo is like this...
This will trigger once a unit is attacked...

JASS:
library DamageDealt

globals
    private hashtable H = InitHashtable()
endglobals

function SimTTUnit takes string s, unit u, real heightoffset, real size returns nothing
    local texttag tag = CreateTextTag()
    call SetTextTagPosUnit(tag, u, heightoffset) //heightoffset is 0 OK
    call SetTextTagText(tag, s, size) //size is 0.025 OK
    call SetTextTagPermanent(tag, false)
    call SetTextTagVelocity(tag, 0.03, 0.03)
    call SetTextTagLifespan(tag, 3)
    call SetTextTagFadepoint(tag, 0.01) 
    set tag = null
endfunction

function DisplayDamage takes unit caster, unit target, real damage, attacktype atk, damagetype dmg returns nothing
    local real life = GetWidgetLife(target)
    local real life2
    local real actualdamage
    call UnitDamageTarget(caster, target, damage, false, false, atk, dmg, null)
    set life2 = GetWidgetLife(target)    
    set actualdamage = life - life2
    call SaveReal(H, GetHandleId(target), 0, LoadReal(H, GetHandleId(target), 0) + actualdamage)  
    call SimTTUnit("Total Damage: "+I2S(R2I(LoadReal(H, GetHandleId(target), 0))), target, 0, 0.025)
endfunction

endlibrary
JASS:
scope DemoD initializer onInit

private function Cast takes nothing returns boolean
    call DisplayDamage(GetAttacker(), GetTriggerUnit(), 50, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
    return false
endfunction

function onInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(t, function Cast)  
endfunction

endscope


 
Status
Not open for further replies.
Top