PUI help again.

cleeezzz

The Undead Ranger.
Reaction score
268
SOLVED

JASS:
scope UTD initializer Init

globals
   private unit Caster = null
   private unit dummy = null
endglobals

private function Filter1 takes nothing returns boolean
    local real x = GetUnitX(GetFilterUnit())
    local real y = GetUnitY(GetFilterUnit())
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Caster)) and GetWidgetLife(GetFilterUnit())>0.405 and IsTerrainPathable( x, y, PATHING_TYPE_FLOATABILITY) == false
endfunction  

//=======================================================================
private struct Data
    //! runtextmacro PUI()
    unit u
    unit d
    real dmg
    timer t
    boolean critical
    
    private method onDestroy takes nothing returns nothing
        set .u = null
        set .d = null
        call ReleaseTimer(.t)
    endmethod
endstruct

private function showtxt takes nothing returns nothing
    local Data d = GetCSData(GetExpiredTimer())
    local texttag txt = CreateTextTag()
    local real x = GetUnitX(d.u)
    local real y = GetUnitY(d.u)
    local integer i = 0
    
    call SetTextTagText( txt,  "|c00FF0000" + "-" + I2S(R2I(d.dmg)) + "|r" , 0.023 )
    call SetTextTagPos ( txt, x, y, 150)
    call SetTextTagVelocity( txt, (64 * 0.071 / 128) * Cos(90 * 3.14/180 ) , (64 * 0.071 / 128) * Sin(90 * 3.14/180 ) )
    call SetTextTagPermanent( txt, false )
    call SetTextTagLifespan( txt, 1.70 )
    call SetTextTagFadepoint( txt, 1.00 )
    if (IsFoggedToPlayer( x, y, GetLocalPlayer()) or IsMaskedToPlayer( x, y, GetLocalPlayer())) and GetLocalPlayer() != GetOwningPlayer(d.d) then
        call SetTextTagVisibility( txt, false)
    endif


    set txt = null
    set d.dmg = 0
    call d.release()
endfunction
    
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit ds = GetEventDamageSource()
    local unit c = Hero[GetPlayerId(GetOwningPlayer(ds))]
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real x1
    local real y1
    local real x2
    local real y2
    local group g = CreateGroup()
    local integer i
    local integer n
    local Data d = Data<u>  //sets data of the unit
        if GetUnitTypeId(ds) != &#039;h00A&#039; then  //ignore this huge IF and scroll down to the next comment, this code just adds bonus dmg
            set Caster = ds
            set dummy = CreateUnit( GetOwningPlayer(c), &#039;h00A&#039;, x, y, 0 )       
            set n = ItemCheck( c, &#039;I00M&#039;)
            call UnitDamageTarget( dummy, u, 75.00 * I2R(n) , false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
            set n = ItemCheck( c, &#039;I005&#039;)
            set n = ItemCheck( c, &#039;I00G&#039;) + n
            set n = ItemCheck( c, &#039;I00J&#039;) + n
            set n = ItemCheck( c, &#039;I00F&#039;) + n
            call UnitDamageTarget( dummy, u, 25.00 * I2R(n) , false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
            set dummy = null
                if ItemCheck( ds, &#039;I00V&#039;) &gt;= 1 then
                    set dummy = CreateUnit( GetOwningPlayer(ds), &#039;h00A&#039;, x, y, 0 )
                    call UnitDamageTarget( dummy, u, 25.00 , false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                    call UnitAddAbility(dummy, &#039;A00I&#039;)
                    call UnitApplyTimedLife( dummy, &#039;BTLF&#039;, 2.00 )
                    call IssueTargetOrder( dummy, &quot;frostnova&quot;, u )
                        if IsTerrainPathable ( x, y,  PATHING_TYPE_FLOATABILITY) == false or UnitHasBuffBJ( u, &#039;B005&#039;) == true then
                            call UnitAddAbility(dummy, &#039;A01M&#039;)
                            call IssueTargetOrder( dummy, &quot;thunderbolt&quot;, u )
                        endif
                endif
            set dummy = null
                if ItemCheck( ds, &#039;I00X&#039;) &gt;= 1 then
                    call DestroyEffect( AddSpecialEffectTarget( &quot;Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl&quot;, GetTriggerUnit(),&quot;origin&quot;))
                    set dummy = CreateUnit( GetOwningPlayer(ds), &#039;h00A&#039;, x, y, 0 )
                    call UnitDamageTarget( dummy, u, 25.00, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                    call UnitApplyTimedLife( dummy, &#039;BTLF&#039;, 2.00 )
                    call UnitDamageTarget( dummy, u, 100.00, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                        if IsTerrainPathable ( x, y,  PATHING_TYPE_FLOATABILITY) == false then 
                            call GroupEnumUnitsInRect( g, bj_mapInitialPlayableArea, Condition( function Filter1))
                            call ForGroup( g, function CB)
                        endif   
                    call DestroyGroup(g)
                    set g = null
                endif
            set dummy = null
                if ItemCheck( ds, &#039;I00W&#039;) &gt;= 1 then
                    set dummy = CreateUnit ( GetOwningPlayer(ds), &#039;h009&#039;, x1, y1,  18.00 * I2R(i))
                    call UnitDamageTarget( dummy, u, 25.00, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null )
                    call UnitApplyTimedLife( dummy, &#039;BTLF&#039;, 4.00)
                        if IsTerrainPathable ( x, y,  PATHING_TYPE_FLOATABILITY) == true then 
                            set i = 1
                                loop
                                    exitwhen i &gt; 20
                                        set x1 = PolarProjectionX( x, 200.00, 18.00 * I2R(i))
                                        set y1 = PolarProjectionY( y, 200.00, 18.00 * I2R(i))
                                        set x2 = PolarProjectionX( x, 250.00, 18.00 * I2R(i))
                                        set y2 = PolarProjectionY( y, 250.00, 18.00 * I2R(i))
                                        set dummy = CreateUnit ( GetOwningPlayer(GetEventDamageSource()), &#039;h009&#039;, x1, y1,  18.00 * I2R(i))
                                        call UnitApplyTimedLife( dummy, &#039;BTLF&#039;, 4.00)
                                        call IssuePointOrder( dummy, &quot;breathoffire&quot;, x2, y2 )
                                        set i = i + 1
                                endloop
                        endif
                endif   
        endif
        if d == 0 then  // The important part starts here.
            call BJDebugMsg(&quot;HI&quot;)
            set d = Data.create()
            set d.u = u
            set d.d = GetEventDamageSource()
            set d.dmg = 0
            set d.t = NewTimer()
            set Data<u> = d
            call TimerStart(d.t, 0.10, false, function showtxt)
            call SetCSData(d.t,d)
        else
            call BJDebugMsg(&quot;HI2&quot;)
            call PauseTimer(d.t)
            call TimerStart(d.t, 0.10, false, function showtxt)
        endif
    set d.dmg = d.dmg + GetEventDamage()
    set u = null
    set ds = null
    set dummy = null
endfunction

private function Conditions takes nothing returns boolean
    if GetEventDamage() &gt; 0 then
        return true
    endif
    return false
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    set UTD = CreateTrigger(  )
    call TriggerAddCondition(UTD, Condition(function Conditions))
    call TriggerAddAction( UTD, function Actions )
endfunction

endscope</u></u>


you can skip the huge If/then/else statement but just take notice that it creates a dummy to damage the unit. using this one code, i was hoping, it would add the damage together using a struct (this has worked before in 2 separate triggers but now that its combined, it seems like the damage is too fast for the struct to be created). so when the unit takes damage from a unit with a certain item, and receives bonus damage, it happens so fast that it doesn't register that the struct has been created. do i have to keep it as 2 separate triggers? because it helps a lot to keep it in one.

EDIT: this might not even be a PUI problem, maybe its just the struct isnt' being created fast enough between the 2 damages.

EDIT2: OMFG. turns out the order was mixed up, i should have swapped the two if/then/else because damage was given to the unit before the struct was even created. alsdkldsfjk
 
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