[Trigger] Hero pick trigger

Status
Not open for further replies.
Level 5
Joined
Apr 14, 2006
Messages
140
Hi all!

Excuse me if this had already been asked hundred times before, but I used the search tool and did not find anything... relevant.
I did a trigger related to a tavern. The user has a shadow to choose a hero. When done, the shadow is killed and the hero is instantly placed at the center of a region. The heroes in the tavern are self-made heroes, I removed the originals ones. I use the "A unit finishes training of a unit" to get the selected hero, but it seems that it doesn't reckognizes it, because the trigger does nothing...

I don't how to put GUI here, so sorry but here's the script :


function Trig_Pick_Human_Conditions takes nothing returns boolean
if ( not ( IsUnitType(GetTrainedUnit(), UNIT_TYPE_HERO) == true ) ) then
return false
endif
return true
endfunction

function Trig_Pick_Human_Func003Func001001 takes nothing returns boolean
return ( GetOwningPlayer(GetEnumUnit()) == GetOwningPlayer(GetTrainedUnit()) )
endfunction

function Trig_Pick_Human_Func003A takes nothing returns nothing
if ( Trig_Pick_Human_Func003Func001001() ) then
call KillUnit( GetEnumUnit() )
else
call DoNothing( )
endif
endfunction

function Trig_Pick_Human_Actions takes nothing returns nothing
call RemoveUnitFromAllStock( GetUnitTypeId(GetTrainedUnit()) )
call SetUnitPositionLocFacingLocBJ( GetTrainedUnit(), GetRectCenter(gg_rct_Attack_Center_Human), GetUnitLoc(gg_unit_ofrt_0013) )
call ForGroupBJ( GetUnitsInRectAll(gg_rct_Ombre), function Trig_Pick_Human_Func003A )
endfunction

//===========================================================================
function InitTrig_Pick_Human takes nothing returns nothing
set gg_trg_Pick_Human = CreateTrigger( )
call TriggerRegisterUnitEvent( gg_trg_Pick_Human, gg_unit_n000_0111, EVENT_UNIT_TRAIN_FINISH )
call TriggerAddCondition( gg_trg_Pick_Human, Condition( function Trig_Pick_Human_Conditions ) )
call TriggerAddAction( gg_trg_Pick_Human, function Trig_Pick_Human_Actions )
endfunction
 
Level 5
Joined
Apr 14, 2006
Messages
140
So, here's the copied code :

Event :
Unité - Taverne Humain 0111 <gen> Termine l'entrainement d'une unité
Conditions :
((Trained unit) is Un héros) Egal à* TRUE
Actions :
Bâtiment neutre - Remove (Unit-type of (Trained unit)) from all marketplaces
Unité - Move (Trained unit) instantly to (Center of Attack Center Human <gen>), facing (Position of Forteresse 0013 <gen>)
Groupe unité - Pick every unit in (Units in Ombre <gen>) and do (Actions)
Boucle - Actions
If ((Owner of (Picked unit)) Egal à* (Owner of (Trained unit))) then do (Unité - Kill (Picked unit)) else do (Do nothing)
 
Status
Not open for further replies.
Top