• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Reverse Distance-based Damage

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
            set l = GetUnitLoc(udum)
            set l2 = GetUnitLoc(t)
            set i4 = DistanceBetweenPoints(l,l2)
            call print(R2S(I2R(GetHeroInt(s, true)) * ( 1.5 * (1-(i4 / 800)))))

Basically i want this to do int-based damage depending on how far the unit is from the caster, except reversed (closest unit takes the most damage and farthest unit takes the least damage. My problem is that the print line always returns something like -17xx.xx

JASS:
function Trig_Set_Damage_Copy_Actions takes nothing returns nothing
    local unit s = udg_DamageEventSource
    local unit t = udg_DamageEventTarget
    local unit udum = null
    local unit caster
    local group g = CreateGroup()
    local location l
    local location l2
    local integer i = GetPlayerId(GetOwningPlayer(s))
    local integer i2
    local integer i3
    local real i4
    set udg_DamageEventAmountDummy = udg_DamageEventAmount
    set udg_Temp_Integer = GetConvertedPlayerId(GetOwningPlayer(s))
  
    if ( GetUnitAbilityLevel(t, 'B003')  != 0 and GetUnitAbilityLevel( s,'A00N') != 0 ) then
        call print("Begin Lightning")
        set udg_DamageEventAmount = ( udg_DamageEventAmount + ( I2R(GetHeroInt(udg_DamageEventSource, true)) * ( 3.00 ) ) )
        call UnitRemoveAbility(udg_DamageEventTarget , 'B003' )
        call print(R2S(udg_DamageEventAmount)) 
        set l = GetUnitLoc(t)       
        call GroupEnumUnitsInRangeOfLoc(g, l, 600, null) 
        set bj_wantDestroyGroup = true
        set i2 = CountUnitsInGroup(g)
        set i3 = i2
        call print(I2S(i2))
        loop
            set bj_wantDestroyGroup = true
            set udum = GetClosestUnitInGroup(GetLocationX(l), GetLocationY(l), g)
            call print(I2S(GetHandleId(udum)))
            set l2 = GetUnitLoc(udum)
            set l = GetUnitLoc(t)
            set caster = CreateUnitAtLoc(Player(i), 'h004', l2, 0)
            call UnitAddAbility(caster, 'A00L')
            call IssueTargetOrderById(caster, 'A00L', udum)
            set i4 = DistanceBetweenPoints(l2,l)
            call DisableTrigger(udg_DamageEventTrigger) 
            call UnitDamageTarget(s, udum, (udg_DamageEventAmount + ( I2R(GetHeroInt(s, true)) * ( 1.5 * (1-(i4 / 800))))), false, false, null, null, null)
            call print(R2S(I2R(GetHeroInt(s, true)) * ( 1.5 * (1-(i4 / 800)))))
            call EnableTrigger(udg_DamageEventTrigger)
            call GroupRemoveUnit(g, udum)
            set i2 = i2 - 1
           // call print(I2S(i2))
            exitwhen i2 == 0 or i3 - i2 >= 1.5 + (GetUnitAbilityLevel(s, 'A00N') * 0.5)
        endloop
    endif
    if ( udg_ShowCriticalText == true ) then
        set udg_ShowCriticalText = false
        call CreateTextTagUnitBJ( ( I2S(R2I(udg_DamageEventAmount)) + "!" ), udg_DamageEventTarget, 50.00, 13.00, 100, 5.00, 10.00, 0 )
        call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 75.00, 90.00 )
        call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
        call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 3.50 )
        call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 1.40 )
    endif
    call DestroyGroup(g)
    set s = null
    set t = null
    set udum = null
    set caster = null
    set l = null
    set l2 = null
    set g = null
    //ll TimerStart(time, 0.01, false,function timerEnd)
endfunction



E/ after a few more tests, it seems that the group is filtering correctly (it will contain units when ran) but when i try to do something like I2S(GetHandleId(FirstOfGroup, GroupRandomUnit or GetClosestUnitInGroup)) returns 0
 
Last edited:
Status
Not open for further replies.
Top