cleeezzz
The Undead Ranger.
- Reaction score
- 268
JASS:
scope DS initializer Init
struct DS
//! runtextmacro PUI()
unit u
integer shotnum
real x
real y
integer id
integer lvl
timer t
endstruct
private function shoot takes nothing returns nothing
local DS d = GetCSData(GetExpiredTimer())
local unit dummy
local real x = GetUnitX(d.u)
local real y = GetUnitY(d.u)
local real angle = AngleXY(x,y,d.x,d.y)
set dummy = CreateUnit ( GetOwningPlayer(d.u), 039;H00I039;, x, y, Rad2Deg(angle))
set DS[dummy] = d
call SetUnitPathing(dummy, false)
call SetUnitX(dummy, x)
call SetUnitY(dummy, y)
call UnitAddAbility(dummy, d.id)
call SetUnitAbilityLevel(dummy,d.id,d.lvl)
call UnitApplyTimedLife( dummy, 039;BTLF039;, 4.00)
call IssuePointOrder(dummy,"carrionswarm",d.x,d.y)
call IssuePointOrder(dummy,"breathoffire",d.x,d.y)
call IssuePointOrder(dummy,"breathoffrost",d.x,d.y)
call SetUnitAnimation(d.u, "stand")
call SetUnitAnimation(d.u, "attack")
set dummy = null
endfunction
//=======================================================================
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local real x = GetLocationX(GetSpellTargetLoc())
local real y = GetLocationY(GetSpellTargetLoc())
local DS d = DS<u>
if ItemCheck(u,039;I00N039;) >= 1 or ItemCheck(u,039;I00R039;) >= 1 or ItemCheck(u,039;I00T039;) >= 1 or ItemCheck(u,039;I00O039;) >= 1 then
if d == 0 then
set d = DS.create()
set DS<u> = d
set d.u = u
set d.shotnum = 1
set d.t = NewTimer()
call SetCSData(d.t,d)
else
set d.shotnum = d.shotnum + 1
endif
if d.shotnum >= 5 then
set d.shotnum = 0
set d.x = x
set d.y = y
set d.id = GetSpellAbilityId()
set d.lvl = GetUnitAbilityLevel(u,d.id)
call TimerStart(d.t,0.15,false,function shoot)
endif
endif
set u = null
endfunction
//=======================================================================
private function Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 039;A011039; or GetSpellAbilityId() == 039;A017039; or GetSpellAbilityId() == 039;A006039; or GetSpellAbilityId() == 039;A022039; or GetSpellAbilityId() == 039;A027039; or GetSpellAbilityId() == 039;A028039; or GetSpellAbilityId() == 039;A003039; or GetSpellAbilityId() == 039;A021039; or GetSpellAbilityId() == 039;A01J039;) and GetUnitTypeId(GetTriggerUnit()) != 039;H00I039;
endfunction
//=======================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trig,Condition(function Conditions))
call TriggerAddAction(trig,function Actions)
endfunction
endscope
</u></u>
this basically runs whenever a certain list of spells are casted, if the hero has a certain item in its inventory, then its casted twice, but only once every 5 spells. the pui counts every shot and doubles the 5th spell however theres a bug, it kinda stops working. (some times it doubles every 3 spells and some times it doesn't double at all)
EDIT:FOUND the problem but its still not solved, it seems PUI is destroying the struct even though no where in the code do i destroy it. Does anyone know the conditions of when PUI recycles the structs? is it automatic?