Embrace_It
New Member
- Reaction score
- 9
I've made a very simple damage detection system for dealing with critical strikes in my map. A function called OnDamage checks if the damaging unit has the ability to do a critical strike, and if it does, the function calculates if it IS a critical strike and deals the damage and shows some floating text.
I set the critical strike chance to 90% and put a BJDebugMsg call for testing purposes, but when it procs, the are like 8 damage outputs. It seems it enters a loop and then multiplies the critical modifier (x2) each time. The result is that the damaged unit is instantly killed...I have no idea what is going on...Please help!
CODE:
Both the BJ, the normal UnitDamageTarget and NormalDamageTarget (which uses UnitDamageTarget) dont work.
Here an example of the output (the crit modifier is x2):
From 33.929, it instantly outputted the big values that follow it.
I set the critical strike chance to 90% and put a BJDebugMsg call for testing purposes, but when it procs, the are like 8 damage outputs. It seems it enters a loop and then multiplies the critical modifier (x2) each time. The result is that the damaged unit is instantly killed...I have no idea what is going on...Please help!
CODE:
JASS:
scope DamageDetection initializer InitDamageDetection
private function OnDamage takes nothing returns nothing
local unit source = GetTriggerUnit()
local unit damager = GetEventDamageSource()
local real damage = GetEventDamage()
call BJDebugMsg(R2S(damage * GetCritCritModifier(damager)))
if GetExpertise(damager) == 0. then
if CalcChance(90.) then
call UnitDamageTargetBJ(damager, source, damage * GetCritCritModifier(damager), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
//call NormalDamageTarget(damager, source, damage * 2., true, true)
call CreateFloatingTextTarget(damager, "Critical!", COMBAT_ABILITY)
call CreateFloatingRealTargetSize(source, damage, COMBAT_ABILITY, 15.)
endif
endif
endfunction
private function Conditions takes nothing returns boolean
return true
endfunction
//===========================================================================
private function InitDamageDetection takes nothing returns nothing
local trigger systrigger = CreateTrigger()
local group g = CreateGroup()
local rect r = GetWorldBounds()
local unit f
call GroupEnumUnitsInRect(g, r, Condition(function Conditions))
loop
set f = FirstOfGroup(g)
exitwhen f == null
call TriggerRegisterUnitEvent(systrigger, f, EVENT_UNIT_DAMAGED)
call GroupRemoveUnit(g, f)
endloop
call TriggerAddAction(systrigger, function OnDamage)
endfunction
endscope
Both the BJ, the normal UnitDamageTarget and NormalDamageTarget (which uses UnitDamageTarget) dont work.
Here an example of the output (the crit modifier is x2):
Code:
39.286
37.500
33.929
60.587
108.911
193.197
344.995
616.063
1100.113
1964.487
3508.013
6264.309
From 33.929, it instantly outputted the big values that follow it.