HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Create unit after wait function

01-09-2006, 08:02 PM#1
GosuSheep
ok. well, i have this game called sheep tag. and theres a mode called SWITCH. when a wolf kills a sheep, the wolf turns into the sheep, and after 10 seconds, the sheep turns into a wolf. the problem is, if multilpe sheep die, 10 seconds after the first sheep dies, both of the wolves create. even if the second sheep dies less than 10 seconds ago.

its something like this

sheep switch
Events
Unit - A unit owned by Player 1 (Red) Dies
Unit - A unit owned by Player 2 (Blue) Dies
Unit - A unit owned by Player 3 (Teal) Dies
Unit - A unit owned by Player 4 (Purple) Dies
Unit - A unit owned by Player 5 (Yellow) Dies
Unit - A unit owned by Player 6 (Orange) Dies
Unit - A unit owned by Player 7 (Green) Dies
Unit - A unit owned by Player 8 (Pink) Dies
Unit - A unit owned by Player 9 (Gray) Dies
Unit - A unit owned by Player 10 (Light Blue) Dies
Unit - A unit owned by Player 11 (Dark Green) Dies
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
((Unit-type of (Triggering unit)) Equal to Black Sheep) or ((Unit-type of (Triggering unit)) Equal to Sheep)
Actions

Set switch[(Player number of (Owner of (Triggering unit)))] = True
Trigger - Run Setup Leader <gen> (ignoring conditions)
Wait 10.00 seconds
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (Unit - Create 1 Shepard for (Player((Integer A))) at (Center of Shepard Respawn <gen>) facing Default building facing degrees) else do (Do nothing))
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 1) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Strong Blade and give it to (Picked unit))) else
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 2) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Claws of Attack +21 and give it to (Picked unit)
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 2) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Slow Poison and give it to (Picked unit))) else
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 3) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Slow Poison and give it to (Picked unit))) else
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (Set switch[(Integer A)] = False) else do (Do nothing))



im wondering if theres an easy way to seperate the wait times.
ive tried doing countdown timers, but its fairly difficult..

oh yeah, im doing this all on RoC. which is limited to most trigger functions

replies are greatly appreciated
01-09-2006, 08:27 PM#2
Jacek
trigger tags...

Trigger:
Collapse Events
Unit - A unit owned by Player 1 (Red) Dies
Unit - A unit owned by Player 2 (Blue) Dies
Unit - A unit owned by Player 3 (Teal) Dies
Unit - A unit owned by Player 4 (Purple) Dies
Unit - A unit owned by Player 5 (Yellow) Dies
Unit - A unit owned by Player 6 (Orange) Dies
Unit - A unit owned by Player 7 (Green) Dies
Unit - A unit owned by Player 8 (Pink) Dies
Unit - A unit owned by Player 9 (Gray) Dies
Unit - A unit owned by Player 10 (Light Blue) Dies
Unit - A unit owned by Player 11 (Dark Green) Dies
Unit - A unit owned by Player 12 (Brown) Dies
Collapse Conditions
((Unit-type of (Triggering unit)) Equal to Black Sheep) or ((Unit-type of (Triggering unit)) Equal to Sheep)
Collapse Actions
Set switch[(Player number of (Owner of (Triggering unit)))] = True
Trigger - Run Setup Leader <gen> (ignoring conditions)
Wait 10.00 seconds
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (Unit - Create 1 Shepard for (Player((Integer A))) at (Center of Shepard Respawn <gen>) facing Default building facing degrees) else do (Do nothing))
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 1) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Strong Blade and give it to (Picked unit))) else
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 2) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Claws of Attack +21 and give it to (Picked unit)
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 2) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Slow Poison and give it to (Picked unit))) else
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (If ((Number of players in Wolf) Equal to 3) then do (Unit Group - Pick every unit in (Units owned by (Player((Integer A))) of type Shepard) and do (Hero - Create Slow Poison and give it to (Picked unit))) else
For each (Integer A) from 1 to 12, do (If (switch[(Integer A)] Equal to True) then do (Set switch[(Integer A)] = False) else do (Do nothing))

Edited by Vexorian: Trigger tag needs spaces to work correctly
01-09-2006, 08:28 PM#3
Naakaloh
I'm not sure what you mean by seperate wait times, but you should be able to tell who is supposed to become the wolf by adding some more conditions that check to see if a player has switch set to true and not setting it for the other one if it is. That would prevent the wolf from spawning for a second player. Just make sure that after you create the wolf you set the switch back to false, so it doesn't prevent any wolf from spawning.
01-10-2006, 08:02 PM#4
johnfn
It's pretty simple actually. When the trigger runs it can run several times if a lot of sheep die, and then

Trigger:
Set switch[(Player number of (Owner of (Triggering unit)))] = True

will be set for all of those players that have dead sheep. Then when the 10 seconds is up, it'll just check through them all and every time it finds one that's true it'll give them the items. The easy way to fix this is to

Trigger:
Trigger - Turn off (This trigger)

at the beginning of the trigger (before the wait!) and

Trigger:
Trigger - Turn off (This trigger)

so the triggers don't overlap.

Hope that makes sense ^^


Edit: Those dumb big spaces under the trigger thing wont go away... >.>
01-10-2006, 08:21 PM#5
Vexorian
It would be worse without the spaces, horizontal scroll bars would tend to appear and make us unable to see the contents
01-10-2006, 08:57 PM#6
Anitarf
You don't need to use all those variables, unless you don't have any decay time, the dying unit should still be around after 10 seconds, and you can create the new unit for the (owner of (dying unit)) directly.
01-11-2006, 12:52 AM#7
johnfn
Quote:
Originally Posted by Anitarf
You don't need to use all those variables, unless you don't have any decay time, the dying unit should still be around after 10 seconds, and you can create the new unit for the (owner of (dying unit)) directly.
Wouldn't the dying unit change every time another unit died? (In which case you'd have to store the unit in a variable)
01-11-2006, 04:34 PM#8
GosuSheep
well. i appreciate u guys trying. but think ahead.

heres the issue

SHEEP1 Dies at 13:45 (minutes:seconds)
SHEEP2 Dies at 13:48

when sheep die, they get a wolf. but the trigger says
wait 10 seconds
if switch[interger a] = true make a wolf blah blah blah

its gonna make a wolf for BOTH of them at 13:55

i need a way around this. and its sooooo hard on my brain. hahah. i basically HAVE to result to countdown timers or even INTERGERS that countdown
01-11-2006, 05:43 PM#9
aaero
Anitarf is right on, actually. You don't need to use variables at all. Try something like this:

Trigger:
Collapse Events
Unit - A unit owned by Player 1 (Red) Dies
Unit - A unit owned by Player 2 (Blue) Dies
Unit - A unit owned by Player 3 (Teal) Dies
Unit - A unit owned by Player 4 (Purple) Dies
Unit - A unit owned by Player 5 (Yellow) Dies
Unit - A unit owned by Player 6 (Orange) Dies
Unit - A unit owned by Player 7 (Green) Dies
Unit - A unit owned by Player 8 (Pink) Dies
Unit - A unit owned by Player 9 (Gray) Dies
Unit - A unit owned by Player 10 (Light Blue) Dies
Unit - A unit owned by Player 11 (Dark Green) Dies
Unit - A unit owned by Player 12 (Brown) Dies
Collapse Conditions
((Unit-type of (Triggering unit)) Equal to Black Sheep) or ((Unit-type of (Triggering unit)) Equal to Sheep)
Collapse Actions
Trigger - Run Setup Leader <gen> (ignoring conditions)
Wait 10.00 seconds
Unit - Create 1 Shepard for (Owner of (Triggering Unit)) at (Center of Shepard Respawn <gen>) facing Default building facing degrees)
Hero - Create Strong Blade and give it to (LastCreatedUnit)
Hero - Create Claws of Attack +21 and give it to (LastCreatedUnit)
Hero - Create Slow Poison and give it to (LastCreatedUnit)

After ten seconds, this will create a new unit for whichever player's sheep died and give that unit all the items (you had slow poison listed twice btw).

Johnfn - Most event responses work properly in GUI triggers even if there is a wait. As far as I know, the only ones that don't work properly are the events regarding units casting a spell (ie Casting Unit, Target Unit of Ability, etc).