P
pure.b
Guest
okay i already have a topic going and i dont know if its against the rules to post another so if this is in a bad spot plz dont remove them straight away.
anyway i have a few codes which i try to use to make a random system to work
set udg_randomhero[1] = 'H002'
set udg_randomhero[2] = 'H000'
set udg_randomhero[3] = 'O000'
set udg_randomhero[4] = 'N000'
set udg_randomhero[5] = 'Hpal'
set udg_randomhero[6] = 'Hamg'
set udg_randomhero[7] = 'Hmkg'
set udg_randomhero[8] = 'Hblm'
that defines my players then i have
function Trig_random_Conditions takes nothing returns boolean
if ( not ( udg_usedrandom[GetConvertedPlayerId(GetTriggerPlayer())] == 0 ) ) then
return false
endif
return true
endfunction
function Trig_random_Func011C takes nothing returns boolean
if ( not ( GetOwningPlayer(GetLastCreatedUnit()) == ForcePickRandomPlayer(GetPlayersAllies(Player(0))) ) ) then
return false
endif
return true
endfunction
function Trig_random_Func012C takes nothing returns boolean
if ( not ( GetOwningPlayer(GetLastCreatedUnit()) == ForcePickRandomPlayer(GetPlayersAllies(Player(5))) ) ) then
return false
endif
return true
endfunction
function Trig_random_Func013002 takes nothing returns nothing
call SetPlayerUnitAvailableBJ( GetUnitTypeId(GetLastCreatedUnit()), false, GetEnumPlayer() )
endfunction
function Trig_random_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, udg_randomhero[GetRandomInt(1, 9)], GetTriggerPlayer(), GetRectCenter(gg_rct_South_hero_start), 90.00 )
if ( Trig_random_Func011C() ) then
call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_South_hero_start) )
else
call DoNothing( )
endif
if ( Trig_random_Func012C() ) then
call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_North_hero_start) )
else
call DoNothing( )
endif
call ForForce( GetPlayersAll(), function Trig_random_Func013002 )
call SetPlayerStateBJ( GetOwningPlayer(GetSoldUnit()), PLAYER_STATE_RESOURCE_FOOD_CAP, 0 )
call PanCameraToTimedLocForPlayer( GetEnumPlayer(), GetUnitLoc(GetLastCreatedUnit()), 0.00 )
set udg_usedrandom[GetConvertedPlayerId(GetTriggerPlayer())] = 1
set udg_haveunit[GetConvertedPlayerId(GetTriggerPlayer())] = 1
endfunction
//===========================================================================
function InitTrig_random takes nothing returns nothing
set gg_trg_random = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(0), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(1), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(2), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(3), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(5), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(6), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(7), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(8), "-random", true )
call TriggerAddCondition( gg_trg_random, Condition( function Trig_random_Conditions ) )
call TriggerAddAction( gg_trg_random, function Trig_random_Actions )
endfunction
thats my random system (if code isnt good tell me and ill post images)
anyway thing code works okay but problems that i encounter are that it dosent look to see if the unit is already used, i want it to buy a unit from the tavern instead of just creating it. So what i need it to do is like use a random number between 1 & 10 to make the unit, but then to like cancel out say number 6 cause it was already used... how do i do all this? should i post my triggers if it makes more sense???
anyway i have a few codes which i try to use to make a random system to work
set udg_randomhero[1] = 'H002'
set udg_randomhero[2] = 'H000'
set udg_randomhero[3] = 'O000'
set udg_randomhero[4] = 'N000'
set udg_randomhero[5] = 'Hpal'
set udg_randomhero[6] = 'Hamg'
set udg_randomhero[7] = 'Hmkg'
set udg_randomhero[8] = 'Hblm'
that defines my players then i have
function Trig_random_Conditions takes nothing returns boolean
if ( not ( udg_usedrandom[GetConvertedPlayerId(GetTriggerPlayer())] == 0 ) ) then
return false
endif
return true
endfunction
function Trig_random_Func011C takes nothing returns boolean
if ( not ( GetOwningPlayer(GetLastCreatedUnit()) == ForcePickRandomPlayer(GetPlayersAllies(Player(0))) ) ) then
return false
endif
return true
endfunction
function Trig_random_Func012C takes nothing returns boolean
if ( not ( GetOwningPlayer(GetLastCreatedUnit()) == ForcePickRandomPlayer(GetPlayersAllies(Player(5))) ) ) then
return false
endif
return true
endfunction
function Trig_random_Func013002 takes nothing returns nothing
call SetPlayerUnitAvailableBJ( GetUnitTypeId(GetLastCreatedUnit()), false, GetEnumPlayer() )
endfunction
function Trig_random_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, udg_randomhero[GetRandomInt(1, 9)], GetTriggerPlayer(), GetRectCenter(gg_rct_South_hero_start), 90.00 )
if ( Trig_random_Func011C() ) then
call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_South_hero_start) )
else
call DoNothing( )
endif
if ( Trig_random_Func012C() ) then
call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_North_hero_start) )
else
call DoNothing( )
endif
call ForForce( GetPlayersAll(), function Trig_random_Func013002 )
call SetPlayerStateBJ( GetOwningPlayer(GetSoldUnit()), PLAYER_STATE_RESOURCE_FOOD_CAP, 0 )
call PanCameraToTimedLocForPlayer( GetEnumPlayer(), GetUnitLoc(GetLastCreatedUnit()), 0.00 )
set udg_usedrandom[GetConvertedPlayerId(GetTriggerPlayer())] = 1
set udg_haveunit[GetConvertedPlayerId(GetTriggerPlayer())] = 1
endfunction
//===========================================================================
function InitTrig_random takes nothing returns nothing
set gg_trg_random = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(0), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(1), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(2), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(3), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(5), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(6), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(7), "-random", true )
call TriggerRegisterPlayerChatEvent( gg_trg_random, Player(8), "-random", true )
call TriggerAddCondition( gg_trg_random, Condition( function Trig_random_Conditions ) )
call TriggerAddAction( gg_trg_random, function Trig_random_Actions )
endfunction
thats my random system (if code isnt good tell me and ill post images)
anyway thing code works okay but problems that i encounter are that it dosent look to see if the unit is already used, i want it to buy a unit from the tavern instead of just creating it. So what i need it to do is like use a random number between 1 & 10 to make the unit, but then to like cancel out say number 6 cause it was already used... how do i do all this? should i post my triggers if it makes more sense???


