yea so, im not really any good with triggers, I sort of know the data editor pretty good, but triggers are my weak point. I would like to set up Random heroes for my map, but im not sure how to,
anybody got any test map or can explain a little on what to do exactly? I know it has something to do with storing all all heroes in an array variable, but thats pretty much all i know about it. Help anyone?
Not sure if this is exactly what you need but this guy helped me out with spawning a random number of units. I used the first method he explains, so yours would end up looking something like: (I named my random real to randomization)
Event: (Your event)
Condition:
Action: General - If (Conditions) then do (Actions) else do (Actions)
If
Randomization < 25.0
Then
Unit - Create Your Hero 1 blah blah
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
Randomization >= 25.0
And
Conditions
Randomization < 100.0
Then
Unit - Create Your hero 2 blah blah
Else
And just adjust the random (real) to your needs if you have 10 heros set it to 1000 and your first IF would be Random < 100 and so on like stated above. Well i hope you get my drift, and i hope it works out for you.
yes you can do that.... you just have to set up a boolean with an array of 10 (assuming you have 10 heroes)
when a hero is picked set that hero number to true. when picking a random hero pick a random number 1-10 then check if the random number boolean is set to true already if so then you need to tell it to repick a random number and try again.... if not then set the boolean to true so the next random hero wont pick the same one.... if you need more help I can walk you thur it on skype..... Skype: SyCoAttack
yes you can do that.... you just have to set up a boolean with an array of 10 (assuming you have 10 heroes) when a hero is picked set that hero number to true. when picking a random hero pick a random number 1-10 then check if the random number boolean is set to true already if so then you need to tell it to repick a random number and try again.... if not then set the boolean to true so the next random hero wont pick the same one.... if you need more help I can walk you thur it on skype..... Skype: SyCoAttack
That is the wrong way to do it. Due to the nature of random numbers that would leave a small chance for an infinite loop (where it keeps repacking the same hero which it cannot choose!). All it needs is a sequence long enough for the thread to hit the oplimit and your map will bug!
The correct way is you use a list of all the heroes that have not been picked and simply pick a random index from that. Removal from the list is done by taking the last element and placing it over the removed element then decreasing length by 1.
Ok, heres my random trigger, as u see its working not really random
its just checks booleans, and if character are not picked, it picks it and set boolean true, but i don't really understand how to make this states random, its just picks unpicked characters step by step.
if i could randomly start one of trigger's states, or run one of random triggers, it will be done, but i didn't find a trigger function for that.
maybe u can post a sample of right way to do it?
and btw one more question, is it right to use different booleans for each character? as u see theres 2 teams, and each of teams can pick 1 of each characters, so i actually can create 2 booleans with 7 arrays (7 is number of heroes thats up atm) 1 that check if green team heroes are picked, and second checks for red team, but its more easy to me to use unique variable for each character, but by somerason time to time i get an error, error that couldn't set variable's value, its like 1 of 10 games, and i just wonder is it becuz i use too many variables? or this error cause by my triggering mistakes?
as u see iv created a trigger variable with 7 arrays, its 7 triggers that checks if boolean tru and if its not it choices character and set boolean as true, but when i try to do a trigger that runs variable with random integer between 1 and 7 it says trying to access an element past array, what im doing wrong
looks like its not working becuz system doesn't know who is triggering player, cuz trigger runner by other trigger not by event started by player, what to do?
as u see on last screenshot if i link array of variable directly to player 1, my random system just works perfect... only if i could link a player that activated trigger
yea so, im not really any good with triggers, I sort of know the data editor pretty good, but triggers are my weak point. I would like to set up Random heroes for my map, but im not sure how to,
anybody got any test map or can explain a little on what to do exactly? I know it has something to do with storing all all heroes in an array variable, but thats pretty much all i know about it. Help anyone?
@Jinxxx123: Go
http://forums.sc2mapster.com/development/triggers/13847-how-to-spawn-a-random-number-of-units-at-a-location/#p3
Not sure if this is exactly what you need but this guy helped me out with spawning a random number of units. I used the first method he explains, so yours would end up looking something like: (I named my random real to randomization)
Event: (Your event)
Condition:
Action: General - If (Conditions) then do (Actions) else do (Actions)
If Randomization < 25.0
Then Unit - Create Your Hero 1 blah blah
Else General - If (Conditions) then do (Actions) else do (Actions)
If Randomization >= 25.0
And
Conditions Randomization < 100.0
Then Unit - Create Your hero 2 blah blah Else
And just adjust the random (real) to your needs if you have 10 heros set it to 1000 and your first IF would be Random < 100 and so on like stated above. Well i hope you get my drift, and i hope it works out for you.
Might be easier if you do it like this:
Ex. you have 10 heroes
you store them in an array from 1-10 so
set Hero[1] = first hero
set Hero[2] = second hero
etc..
then in the random trigger
Event: put something like dialog button clicked or whateverway triggers your random hero
Conditions: nothing
Actions:
Create 1 unit of type Hero[random integer between 1 and 10 (as we have 10 heroes max)] rest of the action
and this will create a random unit of your Hero array
the Hero variable is a unit type variable
This should be easier to work with then the above and also when you increase the amount of heroes easier to adjust.
thanks guys, i just needed a basic idea of what to do .. giving the 2nd post a try right now :)
got it work, it was as easy as you posted it dudeim.. thanks bud
what if i don't want random function to pick heroes that already picked by other players? i can do it somehow?
@uroboros1987: Go
yes you can do that.... you just have to set up a boolean with an array of 10 (assuming you have 10 heroes) when a hero is picked set that hero number to true. when picking a random hero pick a random number 1-10 then check if the random number boolean is set to true already if so then you need to tell it to repick a random number and try again.... if not then set the boolean to true so the next random hero wont pick the same one.... if you need more help I can walk you thur it on skype..... Skype: SyCoAttack
That is the wrong way to do it. Due to the nature of random numbers that would leave a small chance for an infinite loop (where it keeps repacking the same hero which it cannot choose!). All it needs is a sequence long enough for the thread to hit the oplimit and your map will bug!
The correct way is you use a list of all the heroes that have not been picked and simply pick a random index from that. Removal from the list is done by taking the last element and placing it over the removed element then decreasing length by 1.
Ok, heres my random trigger, as u see its working not really random its just checks booleans, and if character are not picked, it picks it and set boolean true, but i don't really understand how to make this states random, its just picks unpicked characters step by step. if i could randomly start one of trigger's states, or run one of random triggers, it will be done, but i didn't find a trigger function for that.
maybe u can post a sample of right way to do it?
and btw one more question, is it right to use different booleans for each character? as u see theres 2 teams, and each of teams can pick 1 of each characters, so i actually can create 2 booleans with 7 arrays (7 is number of heroes thats up atm) 1 that check if green team heroes are picked, and second checks for red team, but its more easy to me to use unique variable for each character, but by somerason time to time i get an error, error that couldn't set variable's value, its like 1 of 10 games, and i just wonder is it becuz i use too many variables? or this error cause by my triggering mistakes?
as u see iv created a trigger variable with 7 arrays, its 7 triggers that checks if boolean tru and if its not it choices character and set boolean as true, but when i try to do a trigger that runs variable with random integer between 1 and 7 it says trying to access an element past array, what im doing wrong
looks like its not working becuz system doesn't know who is triggering player, cuz trigger runner by other trigger not by event started by player, what to do?
as u see on last screenshot if i link array of variable directly to player 1, my random system just works perfect... only if i could link a player that activated trigger
http://www.sc2mapster.com/forums/resources/project-workplace/76627-12-big-game-hunters-tactics/?page=2
ill post my solution in project thread, not sure if its working multiplayer, but it works single, i used real variable called TRIGGERING PLAYER, that changes be4 each execution of trigger, who knows mb it works need to test it mp