• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Angles Bug

Status
Not open for further replies.
Locations aren't enough to crash a map, so I made this. Yet it bugs. I wanted to calculate if the facing angle of the hero/target is similar to the angle between x and targetx.
JASS:
    //Frontal Assault Off
    if GetUnitAbilityLevel(udg_DamageEventSource, 'B03M') > 0 then
        set udg_B = GetUnitAbilityLevel(udg_DamageEventSource, 'A09O')
        set udg_TempPoints[0] = GetUnitLoc(udg_DamageEventSource)
        set udg_TempPoints[1] = GetUnitLoc(udg_DamageEventTarget)
        //Caster Part
        set udg_TempReals[0] = GetUnitFacing(udg_DamageEventSource)
        //Compare target's facing to damage source point.
        //Once turned by AlwaysPos, check if the difference is less than 45 degrees.
        set udg_TempReals[2] = AlwaysPos(udg_TempReals[0] - AngleBetweenPoints(udg_TempPoints[0], udg_TempPoints[1]))
        call BJDebugMsg(R2S(udg_TempReals[2]))
        if udg_TempReals[2] < 46. then
            call BJDebugMsg("Works")
            set udg_DamageEventIncrease = udg_DamageEventIncrease + (0.05 + (0.05 * I2R(udg_B)))
        endif
        //Target Part
        set udg_TempReals[0] = GetUnitFacing(udg_DamageEventTarget)
        set udg_TempReals[2] = AlwaysPos(udg_TempReals[0] - AngleBetweenPoints(udg_TempPoints[1], udg_TempPoints[0]))
        call BJDebugMsg(R2S(udg_TempReals[2]))
        if udg_TempReals[2] < 46. then
            call BJDebugMsg("Works")
            set udg_DamageEventIncrease = udg_DamageEventIncrease + (0.05 + (0.05 * I2R(udg_B)))
        endif
        call RemoveLocation(udg_TempPoints[0])
        call RemoveLocation(udg_TempPoints[1])

AlwaysPos function:
JASS:
function AlwaysPos takes real posc returns real
    if posc < 0. then
        set posc = posc - (posc * 2.)
    endif
    return posc
endfunction

The problem: In-game, the debug message sometimes displays 300.00 + real values, which would be impossible, because the maximum value should be 90.

- Caster attacks unit (90 degrees)
- Caster faces the other direction(180 degrees)
180 - 90 = 90

Aside from that, even if the caster is facing the target head-on, sometimes, ''Works'' does not show up. And the second part rarely even works(target part).
Please help me.
 
Status
Not open for further replies.
Top