| 12-09-2007, 12:40 AM | #1 |
What would be the best way to write a defeat/victory trigger for 3 different forces of 3 players (3v3v3).. Each player has 1 hero, and the defeat conditions are that all 3 heroes of the same team are dead (while there's at least 1 alive, there's a chance that the other players can revive their heroes). Victory conditions are that the other two teams' heroes are all dead. I can't figure out a way to write this in a single trigger...I definately don't want to have a BUNCH of triggers that all run anytime a player leaves/hero dies to check the conditions mentioned above.. And no, the heroes are not in any global unit variables. (so checking if udg_hero1 is dead and udg_hero2 is dead and udg_hero3 is dead, and so on, is out of the question.) |
| 12-09-2007, 01:43 AM | #2 |
Warning, Pseudo Code: Trigger 1: Event: Hero is created Actions: Store each hero into a global var //(if you havent done that already) Trigger 2: Event: Player Leaves Actions: Kill his hero Set CanReviveHeroOfPlayer[...] to false Trigger 3: Event: Every 10 Seconds Actions: Loop through every Player of Force 1 and check if his hero is still alive ____If every hero is dead defeat that team ________Set IsForce1Defeated to true Loop through every Player of Force 2 and check if his hero is still alive ____If every hero is dead defeat that team ________Set IsForce2Defeated to true Loop through every Player of Force 3 and check if his hero is still alive ____If every hero is dead defeat that team ________Set IsForce3Defeated to true If IsForce2Defeated equals true and IsForce3Defeated equals true then end game with victory for Force 1 If IsForce1Defeated equals true and IsForce3Defeated equals true then end game with victory for Force 2 If IsForce1Defeated equals true and IsForce2Defeated equals true then end game with victory for Force 3 End of Pseudo Code Hope I could help. Deaod |
| 12-09-2007, 03:46 AM | #3 | |
Thanks for the help, however: Quote:
I'm not using global variables, and periodically checking the defeat conditions is inefficient, although I appreciate the help..I'll probably just go through and write some mini-functions and condense it..oh well. Thanks for your help though. |
| 12-09-2007, 06:17 AM | #4 |
Periodically checking is the only way to be sure. Do you really want people to be stuck in the game because the victory trigger failed to fire? Checking if 12 heroes are alive every 10 seconds isn't going to lag. |
| 12-09-2007, 06:30 AM | #5 |
You're making it hard for yourself and others by not assigning the heroes to global variables. What is really wrong with that? If you think it's gonna lag, it won't; my map checks for 10 heroes every second with no lag at all. |
| 12-09-2007, 07:59 AM | #6 |
"I'm not using global variables" is like saying "I'm not using local variables" |
| 12-09-2007, 04:13 PM | #8 |
He doesn't want to use globals of any kind, which pretty much halts your method. If he'd use damn globals this could be done in an instant. |
| 12-09-2007, 04:52 PM | #9 |
Yea, the concept of globalizing the heroes into an array is simple and that code could be pretty easily written, although I appreciate your help. I'm just looking for a method to correctly evaluate the victory/defeat conditions without those globals. |
| 12-09-2007, 06:51 PM | #10 |
It's near impossible without overcomplicating it. Sorry. |
| 12-09-2007, 08:03 PM | #11 |
Guess I'll be doing a global array, then. :( |
| 12-09-2007, 11:00 PM | #12 |
Can you answer to us why making a global array for the heroes is such a big deal?? You could've had your problem solved ages ago if you'd just made the arrays. |
| 12-10-2007, 12:34 AM | #13 | |
Quote:
I think you somehow got the incorrect idea that using globals is a bad thing |
| 12-10-2007, 02:45 AM | #14 |
Its a bad programming concept, or habit..whatever you want to call it. I was hoping to avoid it. |
| 12-10-2007, 03:01 AM | #15 |
You mean the fact that you think using globals is bad is a bad concept? |
