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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top