[edit]. mkay so the old version, this time, worked when i added it in. So I'm gonna stick with that, I guess, until, 1.23b is accepted.
[edit2]
k so I'm looking at an example of dusks idds and I'm just confused about those 3 private values:
First of all, what are they used for?
Secondly, what does the 0x100000 mean?
Thirdly, what does the H2I function do?
I'm Trying to clean up my damage display system using his damage detection system, but I want to know why he did these things first.
- Code: Select all
scope CriticalStrike initializer Init
globals
private constant integer MAX_HANDLE_NO = 8190
private constant integer MIN_HANDLE_ID = 0x100000
private boolean array Flag[MAX_HANDLE_NO]
endglobals
private function H2I takes handle h returns integer
return h
return 0
endfunction
private function Conditions takes nothing returns boolean
return GetTriggerDamageType() == DAMAGE_TYPE_ATTACK and Flag[H2I(GetTriggerDamageSource())-MIN_HANDLE_ID] and GetUnitAbilityLevel(GetTriggerDamageSource(), 'AOcr') > 0 and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE)
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerDamageSource()
local unit t = GetTriggerDamageTarget()
local integer lvl = GetUnitAbilityLevel(u, 'AOcr')
local integer pr = GetTriggerPriority(GetTriggeringTrigger())
local texttag te = CreateTextTag()
local real d = GetTriggerDamage()
//Deals +100%/200%/300%/etc damage
debug call BJDebugMsg("Critical Strike has a |cff00ffff"+I2S(pr)+"|r priority which should fire a |cff00ffff5|r-PR trigger!")
call UnitDamageTargetEx(u, t, d*(lvl+1), ATTACK_TYPE_HERO, DAMAGE_TYPE_EXTRA, true)
call SetTextTagText(te, I2S(R2I(d*(lvl)))+"!", 0.024)
call SetTextTagPos(te, GetUnitX(u), GetUnitY(u), 0.00)
call SetTextTagColor(te, 255, 0, 0, 255)
call SetTextTagVelocity(te, 0, 0.04)
call SetTextTagVisibility(te, true)
call SetTextTagFadepoint(te, 2)
call SetTextTagLifespan(te, 5)
call SetTextTagPermanent(te, false)
set Flag[H2I(u)-MIN_HANDLE_ID] = false
set te = null
set u = null
set t = null
endfunction
private function Atk_Conditions takes nothing returns boolean
return GetUnitAbilityLevel(GetAttacker(), 'AOcr') > 0 and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE)
endfunction
private function Atk_Actions takes nothing returns nothing
local unit u = GetAttacker()
if GetRandomInt(1, 100) <= 30 then
call SetUnitAnimation(u, "attack slam")
call QueueUnitAnimation(u, "stand ready")
set Flag[H2I(u)-MIN_HANDLE_ID] = true
else
set Flag[H2I(u)-MIN_HANDLE_ID] = false
endif
set u = null
endfunction
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
call TriggerAddAction(trg, function Actions)
call TriggerAddCondition(trg, Condition(function Conditions))
call TriggerRegisterDamageEvent(trg, 1)
set trg = CreateTrigger()
call TriggerAddAction(trg, function Atk_Actions)
call TriggerAddCondition(trg, Condition(function Atk_Conditions))
call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_ATTACKED)
set trg = null
endfunction
endscope