HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Some help with triggers

11-06-2003, 01:42 AM#1
Vallian88
Background: I'm making a game where you control a tower and at the start of the game you get a few units (eg. 5 footmen and 3 riflemen) then you go around and try to find the other players and kill their tower. You get points for killing units and towers, and when you get enough points you get reinforcement (eg. 3 knights). If your tower gets destroyed, all units you still have also die and you start out again with the original units in some random spot.

I need to make it so that when the players join the game they are randomly placed in one of the regions on the map, and when they die they are put randomly put into another spot. There are going to be around 10 regions to start out on, and when you die you get placed in one of those regions, if there is no player already there.
11-06-2003, 01:55 AM#2
XVoltaireX
Just go something like:

Event:
Whatever you want:

Condtions:
Whatever:

Actions:
Set X(1)= X(1)+1
If: X(1) greater than than equal to "Maxium # of Regions"
Then: Set X(1)=1
Else: Do Nothing
If: Number of "*Tower" in RebrithRegion(X) Equal to 0
Then: Create--all the recreation stuff.
Else: Run this trigger.

I think you should understand this.

Edited because: Of second though istend of all of this...
Set X(1)= X(1)+1
If: X(1) greater than than equal to "Maxium # of Regions"
Then: Set X(1)=1
Else: Do Nothing

Just go Set X(1)=Random Number(1-Max # of Regions)

Hope that helps..
11-06-2003, 03:28 AM#3
Vallian88
Uhh, I have no experience with variables so I don't know what I need to make for the triggers.
11-06-2003, 03:44 AM#4
ULTIMA_WEAPON_
is this game your making similar to sumthing like "Bunker Wars"? If so, then I can understand your disire amd help u.:D
11-06-2003, 03:53 AM#5
Vallian88
YES this is the WC3 version of Bunker Command (wars)!!!! Finally someone who played SC. Any help with how to make the triggers would be greatly appriciated.
11-06-2003, 02:22 PM#6
Zechnophobe
Okay, to start off, open the trigger editor (It's the button that looks like an 'a').
At the top of the trigger Editor is another button that looks like a big ol' X. Click on it to bring up the variable editor. The variable editor, if you haven't done anything yet, will be empty. At the top of THIS window, is a button that says +X. Click on this button to make a new variable.
Enter the name of your variable, lets call it 'spawnregions' for now. Where it says 'variable type' select 'region'. There is a little check box below that, that says 'array'. Check that box. This will unlock a 'size' field.

This is where you need to know how many Regions you are going to be using to spawn in. If it's 10, put in 10, if more, put however many regions you are going to have. Remember this number, it'll be important in a bit. Don't worry about the initial value line, since this is an Array, it won't matter.

A quick explanation of Arrays, if you don't know: An array is just a number of variables. So, if you put in '10' as the size of the array, it's like having '10' REGION variables. The reason this is useful, is in how they are stored, since you can access them all with the same bit of code, which we'll do in a minute.

We'll need one more Variable here, its going to be named RandomInt, will NOT be an array, and will be of type Integer. Don't worry about the default value.

Okay, now lets go back to the Trigger Editor. (Make sure you hit OK when leaving the variable editor, so that your variable is saved). Create a new Category (CTRL + G, or find it under the 'new' menu), and name that Category: "Spawn Handler."

Select your new Category and make a new Trigger (CTRL + T, or find it under the 'new' menu). I have no idea if you have experience with triggers, so I"ll be as thorough as I can here.

Name the trigger "Init-spawn." Create a new EVENT in that trigger(Double click on the where it says Init-spawn, in the Trigger Function window, then hit CTRL + E, or find it in the new menu).
The event you are looking for is 'MAP INITIALIZATION.' which should be the default trigger. This means we want this trigger to go off while the map is loading.

We don't need any conditions for this one, so just skip on down to 'Actions'. We need to set up a For Loop. Make a new Action, and this time make it: For Integer A, do Multiple Actions. Before you 'OK' your choice of Action, you'll notice below it that it says something like: For each Integer A from 1 to 10, do(Multiple). That second number, the 10, needs to be equal to the size of that array you made. After you've set it to that, hit OK, to get back to the trigger editor.

Your new for Loop will have a + sign next to it. Click on that + to expand it. It'll show you the Loop-Actions area. Click on that, and make a new Actoin: Create Units (any type of unit Creation). In this, create whatever units you want the person to start with. You will need one "Create units" for each type of unit you want them to start with. The 'location' for where you want them created involves your array of Regions. Click on where it says "Center of Playable Map area". The window it brings up will say "Center of Region" And below that "Playable map area." Select "Playable map area". This will bring up a window trying to find what location you want to use. Go to the 'variable' field, and look for spawnregions, the array we made and select it. When you do so, it'll appear where 'playable map area' was, and will have a red 'index' next to it. This index is a Number we give it, telling which of the many Regions in spawnregions we are referring to. Click on it, and from the 'function' box, find 'for loop integer A'. Hit Okay until you get back to the trigger editor (Assuming you inputed the quantity, and type of units to make).

What we just did: The For Loop does each of the 'loop' actions once, for each number that it goes through (1-2-3-4-5-6-7-8-9-10). When it does so, you can use the current 'loop number' as a variable. So, the first time it loops, all of these actions will be performed with "For loop integer A" equalling 1, the second time, with it equalling 2, and so on. This means it will go through every index in that array you made.. with only basically 2 lines of code.

This is pretty much all you need to have everyone spawn in their own region when the game starts.. but it's not randomized. I realized that half way through writing this, and didn't wanna go back and change stuff.

Since my fingers are now a bit sore from this, I hope you can figure out the rest. If not, I may stop by again, or you can PM me.
11-06-2003, 04:42 PM#7
XVoltaireX
You should learn some things about varibles they make your life a whole lot easier. Anyways I tried to help.

Edited because: I believe there is no way you can do this trigger without aribles anyway. .
11-07-2003, 02:03 AM#8
Vallian88
Ok I got my trigger to work, but now I need to make it work for everyone(I know theres a way around making triggers for each player) and I need to make it choose a random region that doesn't already have someone's tower in it. I already made it random, I just need to take the region's that already have a tower in them out of the trigger. I also need to make it so when a tower dies the region is put back into the trigger. I think I'm gonna have to do something like this
Set spwanregions[randomint] = nothing
But it needs to actually take that part of the array out of the variable. Like if regions 1,2,3,4,5,6,7, and 8 were taken I need to remove the array index's 1-8 out of the variable so that only 9 and 10 are an option, and when someone's tower dies, it puts their index back into the variable.
Here's my current trigger:

Intspawn

Events:
Map instalization

Conditions:
[none]

Actions:
Set spwanregions[1] = Region 1 <gen>
Set spwanregions[2] = Region 2 <gen>
Set spwanregions[3] = Region 3 <gen>
Set spwanregions[4] = Region 4 <gen>
Set spwanregions[5] = Region 5 <gen>
Set spwanregions[6] = Region 6 <gen>
Set spwanregions[7] = Region 7 <gen>
Set spwanregions[8] = Region 8 <gen>
Set spwanregions[9] = Region 9 <gen>
Set spwanregions[10] = Region 10 <gen>

Set randomint = (Random integer number between 1 and 10)

Camera - Pan camera for Player 1 (Red) to (Center of spwanregions[randomint]) over 0.00 seconds

Unit - Create 1 Guard Tower for Player 1 (Red) at (Random point in spwanregions[randomint]) facing Default building facing degrees

Unit - Create 5 Footman for Player 1 (Red) at (Random point in spwanregions[randomint]) facing Default building facing degrees

Unit - Create 5 Rifleman for Player 1 (Red) at (Random point in spwanregions[randomint]) facing Default building facing degrees

Unit - Create 2 Priest for Player 1 (Red) at (Random point in spwanregions[randomint]) facing Default building facing degrees