| 11-12-2005, 11:09 PM | #1 |
I have this trigger to remove an item from all units in map when it fires. The problem is that the hero could possibly have up to 3 of them, so here is how I did it. I make same action 3 times in loop. Would there be a better way I am posting the whole trigger for the hell of it in case you guys see anything else wrong with it. May as well have the whole thing criticised. Code:
Seiryuu Dies
Events
Unit - Seiryuu 0090 <gen> Dies
Conditions
Actions
Trigger - Turn on Deeplord Dies <gen>
Sound - Play monster_kill <gen>
Set AwardsDragons[(Player number of (Owner of (Killing unit)))] = (AwardsDragons[(Player number of (Owner of (Killing unit)))] + 1)
Set RecipeVis = (All allies of (Owner of (Killing unit)))
Player Group - Pick every player in RecipeVis and do (Actions)
Loop - Actions
Player - Add 1000 to (Picked player) Current gold
Player - Add 300 to (Picked player) Current lumber
Custom script: call DestroyForce( udg_RecipeVis )
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
Item - Remove (Item carried by (Picked unit) of type Summon Seiryuu)
Item - Remove (Item carried by (Picked unit) of type Summon Seiryuu)
Item - Remove (Item carried by (Picked unit) of type Summon Seiryuu)
Custom script: call DestroyGroup( GetLastCreatedGroup ())
Item - Pick every item in (Playable map area) and do (If ((Item-type of (Picked item)) Equal to Summon Seiryuu) then do (Item - Remove (Picked item)) else do (Do nothing))
Wait 2.00 game-time seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Killing unit)) Equal to Player 1 (Red)
(Owner of (Killing unit)) Equal to Player 2 (Blue)
(Owner of (Killing unit)) Equal to Player 3 (Teal)
Then - Actions
Game - Display to (All players) the text: |c007ebff1The Barba...
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Killing unit)) Equal to Player 4 (Purple)
(Owner of (Killing unit)) Equal to Player 5 (Yellow)
(Owner of (Killing unit)) Equal to Player 6 (Orange)
Then - Actions
Game - Display to (All players) the text: |c00106246The Knigh...
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Killing unit)) Equal to Player 7 (Green)
(Owner of (Killing unit)) Equal to Player 8 (Pink)
(Owner of (Killing unit)) Equal to Player 9 (Gray)
Then - Actions
Game - Display to (All players) the text: |c004e2a04 The Maur...
Else - Actions
Custom script: call DestroyTrigger( GetTriggeringTrigger() ) |
| 11-13-2005, 12:41 AM | #2 |
Why not loop until the item is not present? Then you only need to do it once and it will loop the amount of times needed. |
| 11-13-2005, 08:11 AM | #3 |
Remove this line: Custom script: call DestroyGroup( GetLastCreatedGroup ()) It shouldn't be working anyway because you put a space between GetLastCreatedGroup and (), and even if you fix that, it achieves nothing because GetLastCreatedGroup() duplicates that group (the last group is otherwise stored in bj_lastCreatedGroup, so if anything, destroy that). |
| 11-13-2005, 03:41 PM | #4 |
it works with a space before () , but GetLastCreatedUnit() returns a new group, and it does not return the last created group object but the last created group of units (If you used the GUI create N units at location trigger) It doesn't work for other functions |
| 11-13-2005, 05:23 PM | #5 | |
Quote:
|
| 11-13-2005, 05:51 PM | #6 |
Pretty sure it works since I never errored out when saving the map. I did change it like you said to call DestroyGroup( bj_lastCreatedGroup ) Thanks for the help. |
| 11-13-2005, 05:56 PM | #7 | |
Quote:
Well, as Vex pointed out, bj_lastCreatedGroup only holds the group created with "create N units at location" action, and not the last group created by any other function. |
