| 11-04-2003, 01:12 AM | #1 |
This is going to be weird but don't worry about why i'm doing it. I like wasting my time. Actually, hopefully you'll see it if I actually get this going. I plan to make at least 100 triggers that I want to be totally random. For example Every 5 seconds Do trigger #1 or do trigger #2 or do trigger #3 or do trigger #4 Each trigger will be similar For example Make 5 Footmen or make 6 Footmen or make 7 Footmen or make 8 Footmen What is the best way to do this? The second important but not as important question is, how can I make it so that the random trigger does not repeat? Thank you. |
| 11-04-2003, 01:18 AM | #2 |
Youd have to turn off the trigger, and then remove it from an array so that it is not run again. |
| 11-04-2003, 01:18 AM | #3 |
Turn off (This Trigger) would do it...] Using math - Random Number between x and x would handle the random part... There you have it. |
| 11-04-2003, 01:26 AM | #4 |
Well... Turn Off (this trigger) would not work for the triggers being run, because they are being run by the Random trigger, and triggers that are turned off can still be run by another trigger... I suggest you make a Boolean Array called "HasRun" and name all your triggers that are run by your random trigger as numbers. Then in the begining of the triggers being run do a check. If HasRun[integer(string(this trigger name))] = True then Run trigger "run random trigger" Cancel other actions of this trigger else Set variable hasrun[integer(string(this trigger name))] = True ********** ********** is where you would put the actions of the trigger... I hope you understand what I mean... |
| 11-04-2003, 01:29 AM | #5 |
Thanks both. Guess I do have to do that. I was hoping there was an easier way. If there is, let me know! Another important question, I can do this by doing If/Then/Else all under one trigger or by making separate triggers. Does anyone know if doing it one way will lead to a bigger or smaller file size? |
| 11-04-2003, 01:31 AM | #6 |
I don't know about making it smaller... but yes it can be done in one trigger that is "if then else". Example to follow: Code:
event
Every 5 seconds of game
conditions
??????
actions
Set variable RandomNum = random integer from 1 to 10
If
Conditions
RandomNum = 1
Then
If HasRun[1] = True then Stop remaining actions else do nothing
Set variable HasRun[1] = True
**********
If
Conditions
RandomNum = 2
Then
If HasRun[2] = True then Stop remaining actions else do nothing
Set variable HasRun[2] = True
**********
If
Conditions
RandomNum = 3
Then
If HasRun[3] = True then Stop remaining actions else do nothing
Set variable HasRun[3] = True
**********
If
Conditions
RandomNum = 4
Then
If HasRun[4] = True then Stop remaining actions else do nothing
Set variable HasRun[4] = True
**********
If
Conditions
RandomNum = 5
Then
If HasRun[5] = True then Stop remaining actions else do nothing
Set variable HasRun[5] = True
**********
If
Conditions
RandomNum = 6
Then
If HasRun[6] = True then Stop remaining actions else do nothing
Set variable HasRun[6] = True
**********
If
Conditions
RandomNum = 7
Then
If HasRun[7] = True then Stop remaining actions else do nothing
Set variable HasRun[7] = True
**********
If
Conditions
RandomNum = 8
Then
If HasRun[8] = True then Stop remaining actions else do nothing
Set variable HasRun[8] = True
**********
If
Conditions
RandomNum = 9
Then
If HasRun[9] = True then Stop remaining actions else do nothing
Set variable HasRun[9] = True
**********
If
Conditions
RandomNum = 10
Then
If HasRun[10] = True then Stop remaining actions else do nothing
Set variable HasRun[10] = True
**********You would put your actions where the ** are for each random variable, and I set that particular trigger to stop running if the integer it chose had allready run. |
| 11-04-2003, 01:35 AM | #7 | |
You'll need one variable named mytriggervariable that is a trigger array size 100. Next, you'll need two triggers. Code:
Trigger Variables
Events
Map initialization
Conditions
Actions
Set mytriggervariable[1] = a1 <gen>
Set mytriggervariable[2] = a2 <gen>
Set mytriggervariable[3] = a3 <gen>
Set mytriggervariable[4] = a4 <gen>
Set mytriggervariable[5] = a5 <gen>
Set mytriggervariable[6] = a6 <gen>
Set mytriggervariable[7] = a7 <gen>
[i]etc...[/i]
Random Runnings
Events
Time - Every 5.00 seconds of game time
Conditions
Actions
Trigger - Run mytriggervariable[(Random integer number between 1 and 100)] (ignoring conditions)EDIT: Huh, missed the second problem. This was taken directly from the Map Making FAQ. Quote:
|
| 11-04-2003, 01:39 AM | #8 |
No need to make it that complicated, here is what u can do. It's easy. Actions Set Random = (Random integer number between 0 and 100) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions Random Equal to 0 Then - Actions Do this Else - Actions Do nothing If - Conditions Random Equal to 1 Then - Actions Do this Else - Actions Do nothing EDIT: Doh, Didn't see All Painfuls post :P hehe And so on, under each Then -Actions, u just put what you need it to do, if that number is set... Piece of cake |
| 11-04-2003, 01:41 AM | #9 |
Quell has the right run trigger if you devide all the actions into seperate triggers, but you would still need the "HasRun" boolean and the check, otherwise it could run the same trigger more than 1 time. EDIT: WOW! I actually be Zachary_Shadow to an answer? theres a first time for everything :ggani: |
| 11-04-2003, 01:46 AM | #10 |
Thanks all, you guys are the best :D. Now that I know how to do it, i'm just hoping it doesn't make the map 50 MB in size :ggani: When I do finish, i'm sure I will at least get a few laughs when I tell you what I did. Now is it worth it......Ah I guess so. We'll see what happens. Thanks again. |
| 11-04-2003, 01:50 AM | #11 |
The array method is more effecient and cleaner and makes it really easy to not repeat a trigger. Heres how I would do it. Trigger to fill the array. Code:
Init
Events
Map initialization
Conditions
Actions
Set NumberOfTriggers = (NumberOfTriggers + 1)
Set Triggers[NumberOfTriggers] = A1 <gen>
Set NumberOfTriggers = (NumberOfTriggers + 1)
Set Triggers[NumberOfTriggers] = A2 <gen>
Set NumberOfTriggers = (NumberOfTriggers + 1)
Set Triggers[NumberOfTriggers] = A3 <gen>
...Trigger to run a random trigger, then remove it from the array. Code:
RunAndRemove
Events
Time - Every 2.00 seconds of game time
Conditions
Actions
Set TempInt = (Random integer number between 1 and NumberOfTriggers)
Trigger - Run Triggers[TempInt] (checking conditions)
Set Triggers[TempInt] = Triggers[NumberOfTriggers]
Set NumberOfTriggers = (NumberOfTriggers - 1) |
| 11-04-2003, 01:55 AM | #12 |
Well I ain't a programmer, but I DO see the logic behind the Clean removal (your moving the trigger at the end of the array to where the trigger just run was, and then telling the main trigger, via a variable, that there is 1 less thing in the array therefore effectivly eliminating the items at the end of the array.) And I LOVE it, sounds like the most effeciant way to do that... I might just have to keep that for future reference. :D |
| 11-04-2003, 02:03 AM | #13 |
Guess that's how i'm gonnna do it! Thanks a lot Grater :D |
| 11-04-2003, 03:33 AM | #14 |
ICK! You guys are loco! Jebus this can be done easier Event Every 5 Seconds Action Create Math - Random 1 to 5 units of type Units[Math Random 1 to ... ] Where Units is a unit-type array you've made in the variable editor. Then at map init set Units[0], Units[1], and so on, to the different unit types you want. |
| 11-04-2003, 01:49 PM | #15 |
Code:
function addToList takes trigger t returns nothing set udg_ListBool[udg_count] = true set udg_List[udg_count] = t set udg_count = udg_count + 1 endfunction Code:
function resize takes nothing returns nothing
local integer i = 0
local integer x = 0
loop
exitwhen i > 100
if udg_ListBool[i] then
set udg_List[x] = udg_List[i]
set x = x + 1
endif
set i = i + 1
endloop
endfunctionThen every x ammount of time execute a random trigger from 0 to SZ. Then set udg_ListBool[rand] to false, decrement udg_SZ by one, and finally call the function resize. |
