• 🏆 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!

Storm Bolt doesn't works for computer players

Status
Not open for further replies.
Level 1
Joined
Jan 16, 2006
Messages
5
Hello everybody.

I'm make a spell called INEPTITUD; when the unit with the buff attacks, it recieves some damage and is stunned (well i'm create a unit and order storm bolt it), there is my code:

JASS:
function Trig_Ineptitud_Attack_Conditions takes nothing returns boolean
    if ( not ( UnitHasBuffBJ(GetAttacker(), 'B00O') == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Ineptitud_Attack_Actions takes nothing returns nothing
local real x = GetUnitX(GetAttacker())
local real y = GetUnitY(GetAttacker())
    call CreateNUnitsAtLoc( 1, 'h00C', GetOwningPlayer(GetAttackedUnitBJ()), Location(x,y), bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'A08A', GetLastCreatedUnit() )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", GetAttacker() )
    call UnitApplyTimedLifeBJ( 1.00, 'BTLF', GetLastCreatedUnit() )
endfunction

//===========================================================================
function InitTrig_Ineptitud_Attack takes nothing returns nothing
    set gg_trg_Ineptitud_Attack = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ineptitud_Attack, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Ineptitud_Attack, Condition( function Trig_Ineptitud_Attack_Conditions ) )
    call TriggerAddAction( gg_trg_Ineptitud_Attack, function Trig_Ineptitud_Attack_Actions )
endfunction

When the unit with the buff attacks some unit controled by me, the spell works fine. But when the unit with the buff attacks some unit controled by the computed doesn't works... What happends???

Thanks in advance
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
wait a second while i laugh...

bwahahahahahaha

ok, sorry :cry:, its just that i've never seen someone who knows Locals and Unit X/Y commands without knowing not to use BJs, Swappeds, Swaps, CreateNUnitsAtLoc, and If/Then conditions before :D

anyways, are u using Test Map? in this case, its not a computer player, but just a (nothing) player that auto defaults to attack people that come near. try setting the player Player 2 - Blue to a computer instead of None.

replace your code with this xD

JASS:
function Trig_Ineptitud_Attack_Conditions takes nothing returns boolean 
return GetUnitAbilityLevel(GetAttacker(), 'B00O' ) > 0
endfunction 

function Trig_Ineptitud_Attack_Actions takes nothing returns nothing 
local real x = GetUnitX(GetAttacker()) 
local real y = GetUnitY(GetAttacker())
local unit u = CreateUnit( GetOwningPlayer( GetTriggerUnit() ), 'h00C', x, y, 0  )
call UnitAddAbility( u, 'A08A' ) 
call IssueTargetOrder( u, "thunderbolt", GetAttacker() ) 
call UnitApplyTimedLife( u, 'BTLF', 1 )
set u = null
endfunction 

//=========================================================================== 
function InitTrig_Ineptitud_Attack takes nothing returns nothing 
set gg_trg_Ineptitud_Attack = CreateTrigger( ) 
call TriggerRegisterAnyUnitEventBJ( gg_trg_Ineptitud_Attack, EVENT_PLAYER_UNIT_ATTACKED ) 
call TriggerAddCondition( gg_trg_Ineptitud_Attack, Condition( function Trig_Ineptitud_Attack_Conditions ) ) 
call TriggerAddAction( gg_trg_Ineptitud_Attack, function Trig_Ineptitud_Attack_Actions ) 
endfunction
 
Status
Not open for further replies.
Top