I have a portion of my map that is supposed to be a "forest". In reality it's just a randomized block of units that look like agria trees. I'm not concerned with pathable areas or any sort of aesthetics for this, so I suspect the trigger will be very simple.
Would it be a X/Y grid (in the form of an array), running a "for each" loop on each space, placing trees of random sizes?
If so, I can do that, but it sounds like it would be really heavy on startup resources.
It would depend on how many trees are being made. If you're looking at a thousand trees, yeah, probably. May even make the user believe that they crashed. If it's not something they'll be seeing for a while, you could always put it on a timer and have it be something like...
LostForest=reg_LostForest<Region>numOtree=0<integer>CreateForestEventsTimer-Every0.2secondsofGameTimeLocalVariablesi=0<Integer>rnd_point=(RandompointinLostForest)<Point[1]>
tree = Agria Tree <GameLink-Unit>
maxTreeSpawn = 10 <Integer>
Conditions
Actions
General - While (Conditions) are true, do (Actions)
Conditions
i <= maxTreeSpawn
Actions
Variable - Modify i: + 1
Unit - Create 1 tree for player {X} at rnd_point[0] facing rnd_point[1] (No Options)
Variable - Modify numOtree: + 1
General - If (Conditions) then do (Actions) else do (Actions)
If
numOtree >= 1000
Then
Trigger - Stop all instances of Create Lost Forest
Trigger - Turn Create Lost Forest Off
General - Break
Else
Variable - Set rnd_point[0] = (Random point in LostForest)
Variable - Set rnd_point[1] = (Random point in LostForest)
You can always experiment and play with the variables to get it right. I dunno if it will actually work or not, but it should! I wrote it up quickly in my mod file since I'm too lazy to change over to my actual map and try it out quick. Obviously, your tree, region, and other things may be different, but yeah. If I get bored a bit later I'll copy it over and give it a whirl, then come back here and edit this post. ;o
Not only did that work, it worked flawlessly. I'm currently running it at 3500 trees, and it handles it without lagging at all. If I end up with lag during online tests, I'll thin them out and scale the trees up to compensate.
As a bonus, I actually understand that trigger! I learned something!
out of the trigger and into the global area of the editor. At this point, you can either turn it into an array, or make another variable (I'm going to do it this way):
Note: If you named your tree or mineral global variable anything other than what I showed, your script value will be different than mine. As a general rule, from what I've found, your variable will be name gv_assignedNameExample if you assigned a global variable the name: Assigned Name Example. One way to find this value out for your variables is to click on it. In the Script Identifier text box will be the name of your variable. Then, if you assigned the variable in a trigger, function or structure, it will have lv_ before the name, but if you assigned it in the global box, it will have gv_ before the name.
Make another global variable now and have it call to the preset we just made. (A preset that's linking global variables apparently cannot be assigned a local variable.) I named mine Stupid Faith. ;P
Back inside the Create Forest trigger, add the following local variables:
Basically, it's saying that if the tree random variable we set earlier is below the value of 91, then the object that we are going to create will be the tree. If it isn't, then the object will be the mineral. Also, you cannot assign forest to be anything but Tree or Mineral. With this current set up, about 90% of your forest will be trees, and the other 10% will be minerals. Now, modify the previous Unit - Create action to be:
I have a portion of my map that is supposed to be a "forest". In reality it's just a randomized block of units that look like agria trees. I'm not concerned with pathable areas or any sort of aesthetics for this, so I suspect the trigger will be very simple.
Would it be a X/Y grid (in the form of an array), running a "for each" loop on each space, placing trees of random sizes?
If so, I can do that, but it sounds like it would be really heavy on startup resources.
Is there an easier way?
@nytemare3701: Go
It would depend on how many trees are being made. If you're looking at a thousand trees, yeah, probably. May even make the user believe that they crashed. If it's not something they'll be seeing for a while, you could always put it on a timer and have it be something like...
You can always experiment and play with the variables to get it right. I dunno if it will actually work or not, but it should! I wrote it up quickly in my mod file since I'm too lazy to change over to my actual map and try it out quick. Obviously, your tree, region, and other things may be different, but yeah. If I get bored a bit later I'll copy it over and give it a whirl, then come back here and edit this post. ;o
@FaithAnoe: Go
Not only did that work, it worked flawlessly. I'm currently running it at 3500 trees, and it handles it without lagging at all. If I end up with lag during online tests, I'll thin them out and scale the trees up to compensate.
As a bonus, I actually understand that trigger! I learned something!
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
@nytemare3701: Go
First, move
tree = Agria Tree <Game Link - Unit>
out of the trigger and into the global area of the editor. At this point, you can either turn it into an array, or make another variable (I'm going to do it this way):
mineral = mineral <Game Link - Unit>
Now, make a preset with the following:
Note: If you named your tree or mineral global variable anything other than what I showed, your script value will be different than mine. As a general rule, from what I've found, your variable will be name gv_assignedNameExample if you assigned a global variable the name: Assigned Name Example. One way to find this value out for your variables is to click on it. In the Script Identifier text box will be the name of your variable. Then, if you assigned the variable in a trigger, function or structure, it will have lv_ before the name, but if you assigned it in the global box, it will have gv_ before the name.
Make another global variable now and have it call to the preset we just made. (A preset that's linking global variables apparently cannot be assigned a local variable.) I named mine Stupid Faith. ;P
Back inside the Create Forest trigger, add the following local variables:
Followed by this if then statement inside the loop, just before you create the unit:
Basically, it's saying that if the tree random variable we set earlier is below the value of 91, then the object that we are going to create will be the tree. If it isn't, then the object will be the mineral. Also, you cannot assign forest to be anything but Tree or Mineral. With this current set up, about 90% of your forest will be trees, and the other 10% will be minerals. Now, modify the previous Unit - Create action to be:
After that, simple randomize the Mineral Or Tree integer again with the rest of the re-randomizing:
This is, of course, assuming you wanted to count the minerals as a part of the forest.
Edit: ... I like willuwontu's way more. I think I tend to create a lot of work for myself sometimes. ;o
Double Post >.>
@willuwontu: Go
Wow...That's really simple.