Some PUI trouble

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), 'H00I', 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, 'BTLF', 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;I00N&#039;) &gt;= 1 or ItemCheck(u,&#039;I00R&#039;) &gt;= 1 or ItemCheck(u,&#039;I00T&#039;) &gt;= 1 or ItemCheck(u,&#039;I00O&#039;) &gt;= 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 &gt;= 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;A011&#039; or GetSpellAbilityId() == &#039;A017&#039; or GetSpellAbilityId() == &#039;A006&#039; or GetSpellAbilityId() == &#039;A022&#039; or GetSpellAbilityId() == &#039;A027&#039; or GetSpellAbilityId() == &#039;A028&#039; or GetSpellAbilityId() == &#039;A003&#039; or GetSpellAbilityId() == &#039;A021&#039; or GetSpellAbilityId() == &#039;A01J&#039;) and GetUnitTypeId(GetTriggerUnit()) != &#039;H00I&#039;
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?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top