HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit spawning and Selectable destinations.

03-30-2008, 11:21 PM#1
Axzarious
I am working on a map project that fuses elements from hero arenas, dota, footman frenzy. I have the unit spawning down, and then I got another idea to make the map even more insane. Instead of two sides, have 4. Now, the only problem with this, is that I don't know how to make the spawn point destinations selectable. I want it to be configurable so that people can configure thier spawns so that they will attack one of the 3 other peoples bases. I am not sure how to do this, but I will post an example of how my nits are spawned.

Trigger:
Events

Time - Every 20 seconds of game time
Conditions
Collapse Actions
Collapse Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
Loop - Actions
Collapse If (All conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Region Centered at ((Picked player) start location) with size (384.00, 384.00)) contains (Random unit from (Units owned by (Picked player) of type Barracks))) Equal to True
Then - Actions
Unit - Create 1 Swordsman for (Picked Player) at Center of (Region centered at (Player 1 (Red) start location) with size (384.00, 384.00) facing default building facing degrees.
Unit - Order (Last Created unit) to attack-move to (Center of (Region centered at (Player 8 (pink) start location) with size (3840.00, 384.00)
Unit - Create 1 Swordsman for (Picked Player) at Center of (Region centered at (Player 1 (Red) start location) with size (384.00, 384.00) facing default building facing degrees.
Unit - Order (Last Created unit) to attack-move to (Center of (Region centered at (Player 8 (pink) start location) with size (3840.00, 384.00)
Collapse Else - Actions
Do Nothing
Collapse
Collapse If (All conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Region Centered at ((Picked player) start location) with size (384.00, 384.00)) contains (Random unit from (Units owned by (Picked player) of type Firing Range))) Equal to True
Then - Actions
Unit - Create 1 Gunsman for (Picked Player) at Center of (Region centered at (Player 1 (Red) start location) with size (384.00, 384.00) facing default building facing degrees.
Unit - Order (Last Created unit) to attack-move to (Center of (Region centered at (Player 8 (pink) start location) with size (3840.00, 384.00)
Unit - Create 1 Gunsman for (Picked Player) at Center of (Region centered at (Player 1 (Red) start location) with size (384.00, 384.00) facing default building facing degrees.
Unit - Order (Last Created unit) to attack-move to (Center of (Region centered at (Player 8 (pink) start location) with size (3840.00, 384.00)
Collapse Else - Actions
Do Nothing



Thats a small segment of the code for player 1, and only for the units created at his base (It does the same thing for 5 other players as well, with the same amount of units exept for the 'flank' people which spawn only 1 unit. Note that it is the same for the second force as well) The triggers for reds team mates are the same as well, so if player 2 also had a barracks, they would both have 4 footman at each base, for a total of 8 down the center lane. There are 5 paths in total, and so far, I have 13 repetitions for different units in the coding, as I shortened the coding for the example, and took out the other 11 units. Now, As stated, and a reminder, I want the essential same thing, but for 4 players, and the option to make the spawns run to one of the other 3 enemy bases. Also, If there is any more efficient code to reduce possible lag that others may experiance (I have a rather high end computer, so it is non existant for me in war 3, unless somebody hosting another game that I am in lags.)

Also, if possible, I would like the unit to carry on its previous action if it is issued a new one for right clicking (Like in castle fight, note that I already have all spawns classified as wards so that MIGHT be enough of a deterent, but they can still be commanded)

Once I can get this thing up, I am planning on posting a rough beta, and plan on recruiting people if possible.
03-31-2008, 01:36 AM#2
Anitarf
Uhhh... ok, a couple of things first:

"(Center of (Region centered at (Player 8 (pink) start location)" is effectively the same as "Player 8 (pink) start location", except that the latter leaks less memory.

"(Region Centered at ((Picked player) start location) with size (384.00, 384.00)) contains (Random unit from (Units owned by (Picked player) of type Firing Range))) Equal to True" could be replaced with the unit comparison "(Random unit from (Units owned by (Picked player) of type Firing Range)) not equal to (no unit)", again, there's less leaking involved this way.

Now, in order to allow players to choose which other player to attack, you first need a way to store this information. Go to the variable editor and create a player variable array. For each player, we will store the player he is attacking under a corresponding index into that array. Then, instead of telling the units to attack Player 8's start location, you would use the player array instead of "player 8". Of course, you still need a way for players to choose which opponent to attack, but there's so many ways to do this that I won't explain them all. You could use dialogues, dummy buildings or heroes with dummy abilities, a spellbook on your main hero with dummy abilities etc.
03-31-2008, 05:39 AM#3
Axzarious
I think I know what you mean for the array, but I am not sure what you mean for the rest. I would probably use Dialogues. "Attack North, East, West, South". But you would not be able to 'attack' the location of your own base. (E.g. Attack north would not work if you are the north base) I am not too good with triggers, so If you could post an example of the array implemented, I would appreciate it, and give credit in the map if you want.
03-31-2008, 07:25 PM#4
Axzarious
Okay, So I have the efficiancy changes, but As clarification, there would be 4 teams- North, East, South, and West. I would want players to be able to select which location to attack (Excluding thier own) by Typing -north, -east, -south, and -west. So I would create a player array, from 0-11, and assign players 1-12 to each array? Then how would I make them attack the player? Currently I would like them to attack a 'location', as It might mess up the spawn routes. (The ones to the sides, and not across from them)
Currently the Array is
Name............................Type................Initial Value
PlayerAttackTargets.....player array (12)....... None

Is this correct or do I need another Array? How would the setup trigger look? I may be able to figure out how to change the functions for the chat strings, but I am the kind of learner that needs an example, and please pardon my newbishness.
04-01-2008, 12:06 AM#5
Anitarf
First, you need the chat message triggers, here's a sample:
Trigger:
ChatMessage1
Collapse Events
Player - Player 1 (Red) types a chat message containing -north as An exact match
Player - Player 2 (Blue) types a chat message containing -north as An exact match
Player - Player 3 (Teal) types a chat message containing -north as An exact match
-------- ...add all other players who can attack North. --------
Conditions
Collapse Actions
Set PlayerAttackTargets[(Player number of (Triggering player))] = Player 4 (Purple)
-------- (replace player 4 with whoever is the main Norh player) --------
Then, you need to tweak your spawn trigger to use this variable, I just rewrote it in such a way that there's one trigger that handles the spawns for all players, no need for senseless copy-pasting:
Trigger:
Spawn
Collapse Events
Time - Every 20.00 seconds of game time
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Random unit from (Units owned by (Player((Integer A))) of type Barracks)) is alive) Equal to True
Collapse Then - Actions
Unit - Create 1 Footman for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees
Unit - Order (Last created unit) to Attack-Move To (PlayerAttackTargets[(Integer A)] start location)
Unit - Create 1 Footman for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees
Unit - Order (Last created unit) to Attack-Move To (PlayerAttackTargets[(Integer A)] start location)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Random unit from (Units owned by (Player((Integer A))) of type Blacksmith)) is alive) Equal to True
Collapse Then - Actions
Unit - Create 1 Rifleman for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees
Unit - Order (Last created unit) to Attack-Move To (PlayerAttackTargets[(Integer A)] start location)
Unit - Create 1 Rifleman for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees
Unit - Order (Last created unit) to Attack-Move To (PlayerAttackTargets[(Integer A)] start location)
Else - Actions
04-01-2008, 11:27 PM#6
Axzarious
Thanks a million.