- Joined
- Aug 18, 2013
- Messages
- 71
I've had this problem before, UnitAddAbility doesn't work. I don't know why but it doesn't work.
The unit never gets the ability, the IDs are always correct. I have no clue why it doesn't work. Can heroes/units not be given abilities after they are created? Is there a special step I always miss? Anyone know?
Here's my code
For the debug. it shows up but the ability name or id does not display.
The unit never gets the ability, the IDs are always correct. I have no clue why it doesn't work. Can heroes/units not be given abilities after they are created? Is there a special step I always miss? Anyone know?
Here's my code
JASS:
//function Trig_GameDrawCardRed_OrCondition takes nothing returns boolean
// if((GetTriggerUnit() == gg_unit_n00C_0053)or(GetTriggerUnit() == gg_unit_n00C_0020)) then
// return true
// //else
// // if(GetTriggerUnit() == gg_unit_n00C_0020) then
// // return true
// // endif
// else
// return false
// endif
//endfunction
function Trig_GameDrawCardRed_Conditions2 takes nothing returns boolean
//return( ((GetTriggerUnit() == gg_unit_n00C_0053)or(GetTriggerUnit() == gg_unit_n00C_0020)) and ( GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER) > 0 ))
local unit a = GetTriggerUnit()
if (((GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER) > 0) and ((GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_FOOD_USED) < GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_FOOD_CAP)))) and ((a == gg_unit_n00V_0069)or(a == gg_unit_n00V_0066))) then
set a = null
//call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"true")
return true
else
set a = null
//call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"false")
return false
endif
endfunction
function Trig_GameDrawCardRed_Actions2 takes nothing returns nothing
local player p = GetTriggerPlayer()
local unit u
local integer max = 35
local integer rand = GetRandomInt(0,max)
//
local integer array spellCards
if(p == Player(0)) then
set u = udg_HeroBot
//call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"bot")
else
set u = udg_HeroTop
//call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"top")
endif
set spellCards[0] = 'A00K'
set spellCards[1] = 'A000'
set spellCards[2] = 'A00L'
set spellCards[3] = 'A00M'
set spellCards[4] = 'A01F'
set spellCards[5] = 'A00N'
set spellCards[6] = 'A00O'
set spellCards[7] = 'A00P'
set spellCards[8] = 'A00Q'
set spellCards[9] = 'A00R'
set spellCards[10] = 'A00S'
set spellCards[11] = 'A00T'
set spellCards[12] = 'A00U'
set spellCards[13] = 'A00W'
set spellCards[14] = 'A00V'
set spellCards[15] = 'A00X'
set spellCards[16] = 'A00Y'
set spellCards[17] = 'A00Z'
set spellCards[18] = 'A010'
set spellCards[19] = 'A011'
set spellCards[20] = 'A012'
set spellCards[21] = 'A013'
set spellCards[22] = 'A014'
set spellCards[23] = 'A015'
set spellCards[24] = 'A017'
set spellCards[25] = 'A018'
set spellCards[26] = 'A01A'
set spellCards[27] = 'A01B'
set spellCards[28] = 'A01C'
set spellCards[29] = 'A01D'
set spellCards[30] = 'A01E'
set spellCards[31] = 'A01G'
set spellCards[32] = 'A01H'
set spellCards[33] = 'A01J'
set spellCards[34] = 'A01I'
set spellCards[35] = 'A01K'
//spellcards end
call DisplayTextToPlayer(p,0,0,"Debug: "+AbilityId2String(spellCards[rand]))
call UnitAddAbility(u,spellCards[rand])
call SetUnitAbilityLevel(u,spellCards[rand],1)
set p = null
set u = null
//call DisplayTextToPlayer( p,0,0,"You've drawn a : " + I2S(rand) + " : " + GetUnitName(GetLastCreatedUnit()) )
endfunction
//===========================================================================
function InitTrig_GameDrawCardspell takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(0), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(1), true )
call TriggerAddCondition( t, Condition( function Trig_GameDrawCardRed_Conditions2 ) )
call TriggerAddAction( t, function Trig_GameDrawCardRed_Actions2 )
set t = null
endfunction
For the debug. it shows up but the ability name or id does not display.