• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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.
 
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
 
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
 
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