• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Fixing a minor jass spell bug

Status
Not open for further replies.
Level 3
Joined
Jul 29, 2006
Messages
61
I had this script made for me in the spells section, however it has a minor bug. (it uses local handler vars)
JASS:
function Trig_Bloodwind_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Bloodwind_Timer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t, "KBunit")
    local real x = GetHandleReal(t, "X")
    local real y = GetHandleReal(t, "Y")
    local real angle = bj_RADTODEG * Atan2(GetUnitY(u) - y, GetUnitX(u) - x)
    local real ppx = GetUnitX(u) + 10 * Cos(angle * bj_DEGTORAD)
    local real ppy = GetUnitY(u) + 10 * Sin(angle * bj_DEGTORAD)
    call SetHandleInt(t, "Times", GetHandleInt(t, "Times") + 1)
    call SetUnitPosition(u, ppx, ppy)
    if GetHandleInt(t, "Times") == 50 then
        call PauseTimer(t)
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    endif
    set t = null
    set u = null
endfunction

function Trig_Bloodwind_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local location loc = GetUnitLoc(caster)
    local group g = GetUnitsInRangeOfLocAll(512, loc)
    local unit u = null
    local unit d = null
    local timer t = null
    call RemoveLocation(loc)
    loop
        set u = FirstOfGroup(g)
        call GroupRemoveUnit(g, u)
        exitwhen u == null
        if GetPlayerController(GetOwningPlayer(u)) == MAP_CONTROL_COMPUTER then
            set d = CreateUnit(Player(0), 'h001', GetUnitX(u), GetUnitY(u), 0)
            call UnitApplyTimedLife(d, 'BTLF', 1)
            call UnitDamageTargetBJ(d, u, 350.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_LIGHTNING )
            set d = null
            set t = CreateTimer()
            call SetHandleHandle(t, "KBunit", u)
            call SetHandleReal(t, "X", GetUnitX(caster))
            call SetHandleReal(t, "Y", GetUnitY(caster))
            call TimerStart(t, 0.02, true, function Bloodwind_Timer)
        endif
    endloop
    call DestroyGroup(g)
    set caster = null
    set u = null
    set g = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Bloodwind takes nothing returns nothing
    set gg_trg_Bloodwind = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bloodwind, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bloodwind, Condition( function Trig_Bloodwind_Conditions ) )
    call TriggerAddAction( gg_trg_Bloodwind, function Trig_Bloodwind_Actions )
endfunction

the problem is here:
JASS:
GetPlayerController(GetOwningPlayer(u)) == MAP_CONTROL_COMPUTER
I want it instead of detecting if it is computer controled to detecting it is an enemy of the owner of (caster)
 
Status
Not open for further replies.
Top