Baltazhar
Active Member
- Reaction score
- 55
As many people before me have probably realised, JASS is needed for some things. Being purely GUI myself until now (except for leak removal), I am struggling a bit with my first JASS function.
Usage: Each player gets a hero, and can repick once. When a hero is randomed, selected or repicked they must not be able to be picked/randomed again until next round.
Theory: The whole idea is to call the function and have it generate a random number for a global variable (with exceptions). So you would make a Custom Script in the GUI with "Call udg_HeroRandomRoll" and it would create a random integer for the HeroRandomRoll with the exceptions of not being one of the previous selected.
After reading what seems to be tons of tutorials I think I get the drift of JASS, but I end up with loads of errors.
The globals have been defined in the Trigger Editor's Variable box and are the following:
The entire code (with errors) looks like this:
I am unsure if I need an addition to the trigger posted above that states this:
The trigger doesn't need any events or conditions, just actions with randoming the integer when run.
Hope someone with more insight than me can help here.
Thanks in advance,
- Balt
Usage: Each player gets a hero, and can repick once. When a hero is randomed, selected or repicked they must not be able to be picked/randomed again until next round.
Theory: The whole idea is to call the function and have it generate a random number for a global variable (with exceptions). So you would make a Custom Script in the GUI with "Call udg_HeroRandomRoll" and it would create a random integer for the HeroRandomRoll with the exceptions of not being one of the previous selected.
After reading what seems to be tons of tutorials I think I get the drift of JASS, but I end up with loads of errors.
The globals have been defined in the Trigger Editor's Variable box and are the following:
JASS:
The entire code (with errors) looks like this:
JASS:
function RandomHeroRoll takes nothing returns nothing
local integer iRand=0
local boolean AddNew=True //Expected a name
local integer a=0 //Expected expression
local integer b=0 //Expected expression
loop
exitwhen a>20 //Expected name
set iRand=GetRandomInt(1, udg_TotalNumberOfHeroes)
set b=0 //Expected a variable name
set AddNew=True //Expected a variable name
loop
exitwhen b == a //Expected a name
if (udg_AvoidSameHeroes<b> == iRand) then //Expected a name
set AddNew=False //Expected a variable name
set b=a //Expected a variable name
endif //Expected 'endloop'
set b=b+1 //Expected a variable name
endloop
if (AddNew == True) then //Expected a name
set udg_AvoidSameHeroes[a]=iRand //Expected a name
set a=a+1 //Expected a variable name
set udg_HeroRandomRoll=iRand
endif //Expected 'endloop'
endloop //Expected 'endloop'
endfunction</b>
I am unsure if I need an addition to the trigger posted above that states this:
JASS:
//===========================================================================
function InitTrig_HeroRandomRoll takes nothing returns nothing
set gg_trg_HeroRandomRoll = CreateTrigger( )
call TriggerAddAction( gg_trg_HeroRandomRoll, function Trig_HeroRandomRoll_Actions )
endfunction
The trigger doesn't need any events or conditions, just actions with randoming the integer when run.
Hope someone with more insight than me can help here.
Thanks in advance,
- Balt