• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Fixing a minor jass spell bug

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

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)
    set t = null
    set u = null

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)
        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)
    call DestroyGroup(g)
    set caster = null
    set u = null
    set g = null
    set t = null

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 )

the problem is here:
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)
Not open for further replies.