- Joined
- Feb 15, 2009
- Messages
- 463
Hero Modes
1.General Information
So this are several Scripts allowing your map to have the
Allrandom and Teamrandom(till yet) modes which are providing easy configurable , implementable and safe working code HERO MODES are designed for Maps containing 2 Teams fighting each other (like Aos stylerz)
2.What to do to implement?
The only things which need to be changed are the rawcodes of the heros
and the constant variables in the upper section of each trigger
(this is just a very little work taking about 5 seconds)
at beginning of each trigger you can also set the message which needs to be entered by the Choosing Player(the RequiredMessage variable)

To implement this little System or Script just copy the Modules(Allrandom , Teamrandom , etc...) you want to have in your map but if you dont want to have allrandom mode but others just copy the 2 globals GetChoosingPlayer and IsHeroModeAvailable to your module(just in one)
i know just 2 Modules in this 1st version but more will come
3.Basic Things






4.The Scripts
JASS:
//***********************************************************************************
// *
// Allrandom Mode by Saia_Djinn *
// *
//***********************************************************************************
//These globals are used by all modules dont erase them
globals
boolean IsHeroModeAvailable = true
constant player GetChoosingPlayer = Player(0)
endglobals
//###################################
scope Allrandom initializer Init
globals
private constant string RequiredMessage = "-ar" //change to whatever you want to be entered
private constant string ExcuseMessage = "|cffff2277Allrandom Mode was selected|r |cff42afefExcuse the following mini lags through hero set up|r" //we must say sorry to the players for the laaagg =D
private constant integer MaxHeros = 15 // this is the amount of all heros ,you must change this to your Heros array size to work(the real value needs to be added a 1 because we use the ZERO slot of the array)
private constant integer LastPlayerTeamA = 4 // if you have 5 players per team let this else change it to the half of amount -1(e.g. if u have 6 per team put a 5 in here)
private constant real CreateXTeamA = -800. // these 4 reals should contain the Coordinates where Units from Team A and B should be created
private constant real CreateYTeamA = -400.
private constant real CreateXTeamB = 900.
private constant real CreateYTeamB = -400.
//##################################################################################################################################################
private trigger Mode
private integer array Heros
private unitpool RandomPool
endglobals
private function SetUp takes nothing returns nothing
//make this list contain every hero you want to be randomed and change the used ones to the rawcodes of your heros
set Heros[0] = 'Hmkg'
set Heros[1] = 'Hblm'
set Heros[2] = 'Hamg'
set Heros[3] = 'Hpal'
set Heros[4] = 'Obla'
set Heros[5] = 'Ofar'
set Heros[6] = 'Oshd'
set Heros[7] = 'Otch'
set Heros[8] = 'Ucrl'
set Heros[9] = 'Ulic'
set Heros[10] = 'Udre'
set Heros[11] = 'Udea'
set Heros[12] = 'Edem'
set Heros[13] = 'Ekee'
set Heros[14] = 'Emoo'
set Heros[15] = 'Ewar'
//...
//...
endfunction
private function Actions takes nothing returns nothing
local integer a = -1
local unit t
if IsHeroModeAvailable then
set IsHeroModeAvailable = false
call SetUp()
set RandomPool = CreateUnitPool()
call DisplayTextToForce( bj_FORCE_ALL_PLAYERS , ExcuseMessage )
loop
set a = a+1
exitwhen a > MaxHeros
call UnitPoolAddUnitType( RandomPool , Heros[a] , 1. )
endloop
set a = -1
loop
set a = a+1
call TriggerSleepAction( 0.0 )
exitwhen a > 11
if GetPlayerSlotState( Player(a) ) == PLAYER_SLOT_STATE_PLAYING then
if a > LastPlayerTeamA then
set t = PlaceRandomUnit( RandomPool , Player(a) , CreateXTeamB , CreateYTeamB , 0. )
call UnitPoolRemoveUnitType( RandomPool , GetUnitTypeId( t ) )
else
set t = PlaceRandomUnit( RandomPool , Player(a) , CreateXTeamA , CreateYTeamA , 0. )
call UnitPoolRemoveUnitType( RandomPool , GetUnitTypeId( t ) )
endif
endif
endloop
call DestroyUnitPool(RandomPool)
call DestroyTrigger(Mode)
endif
endfunction
private function Init takes nothing returns nothing
set Mode = CreateTrigger()
call TriggerAddAction( Mode , function Actions )
call TriggerRegisterPlayerChatEvent( Mode , GetChoosingPlayer() , RequiredMessage , true )
endfunction
endscope
JASS:
//***********************************************************************************
// *
// Teamrandom Mode by Saia_Djinn *
// *
//***********************************************************************************
scope Teamrandom initializer Init
globals
private constant string RequiredMessage = "-tr" //change to whatever you want to be entered
private constant string ExcuseMessage = "|cffff2277Teamrandom Mode was selected|r |cff42afefExcuse the following mini lags through hero set up|r" //we must say sorry to the players for the laaagg =D
private constant integer MaxHeros = 7 // this is the amount of max heros per team you must change this to your Heros array size to work(the real value needs to be added a 1 because we use the ZERO slot of the array)
private constant integer LastPlayerTeamA = 4 // if you have 5 players per team let this else change it to the half of amount -1(e.g. if u have 6 per team put a 5 in here)
private constant real CreateXTeamA = -800. // these 4 reals should contain the Coordinates where Units from Team A and B should be created
private constant real CreateYTeamA = -400.
private constant real CreateXTeamB = 900.
private constant real CreateYTeamB = -400.
//##################################################################################################################################################
private trigger Mode
private integer array HerosA
private integer array HerosB
private unitpool RandomPoolA
private unitpool RandomPoolB
endglobals
private function SetUp takes nothing returns nothing
//make list HerosA contain all Heros to be randomed from TeamA and HerosB containing the rawcodes of TeamB
set HerosA[0] = 'Hmkg'
set HerosA[1] = 'Hblm'
set HerosA[2] = 'Hamg'
set HerosA[3] = 'Hpal'
set HerosA[4] = 'Edem'
set HerosA[5] = 'Ekee'
set HerosA[6] = 'Emoo'
set HerosA[7] = 'Ewar'
set HerosB[0] = 'Obla'
set HerosB[1] = 'Ofar'
set HerosB[2] = 'Oshd'
set HerosB[3] = 'Otch'
set HerosB[4] = 'Ucrl'
set HerosB[5] = 'Ulic'
set HerosB[6] = 'Udre'
set HerosB[7] = 'Udea'
//...
//...
endfunction
private function Actions takes nothing returns nothing
local integer a = -1
local unit t
if IsHeroModeAvailable then
set IsHeroModeAvailable = false
call SetUp()
set RandomPoolA = CreateUnitPool()
set RandomPoolB = CreateUnitPool()
call DisplayTextToForce( bj_FORCE_ALL_PLAYERS , ExcuseMessage )
loop
set a = a+1
exitwhen a > MaxHeros
call UnitPoolAddUnitType( RandomPoolA , HerosA[a] , 1. )
call UnitPoolAddUnitType( RandomPoolB , HerosB[a] , 1. )
endloop
set a = -1
loop
set a = a+1
call TriggerSleepAction( 0.0 )
exitwhen a > 11
if GetPlayerSlotState( Player(a) ) == PLAYER_SLOT_STATE_PLAYING then
if a > LastPlayerTeamA then
set t = PlaceRandomUnit( RandomPoolB , Player(a) , CreateXTeamB , CreateYTeamB , 0. )
call UnitPoolRemoveUnitType( RandomPoolB , GetUnitTypeId( t ) )
else
set t = PlaceRandomUnit( RandomPoolA , Player(a) , CreateXTeamA , CreateYTeamA , 0. )
call UnitPoolRemoveUnitType( RandomPoolA , GetUnitTypeId( t ) )
endif
endif
endloop
call DestroyUnitPool(RandomPoolA)
call DestroyUnitPool(RandomPoolB)
call DestroyTrigger(Mode)
endif
endfunction
private function Init takes nothing returns nothing
set Mode = CreateTrigger()
call TriggerAddAction( Mode , function Actions )
call TriggerRegisterPlayerChatEvent( Mode , GetChoosingPlayer() , RequiredMessage , true )
endfunction
endscope






Attachments
Last edited: