| 03-03-2004, 12:57 AM | #1 |
Hi, I have a map where there are 12 players and things happen when player units die. Is is better to A) have a trigger for each player or is it better to B) have 1 trigger with many if/then/multiple functions in it. In senerio A there would be 12 small triggers that fire each time a unit dies. In senerio B there is only 1 very large trigger that fires each time a unit dies. Which is better and why? On my map BOTH ways WORK, but not everyone has a fast computer like me (2.6 Ghz). I want it to be set up the best way so people dont get lag. Thanks ahead of time. Peace |
| 03-03-2004, 03:09 AM | #2 |
Ummm... a combination of the two. It's stuff like this that arrays were made for, but I couldn't go into detail on what to do without knowing exactly what these triggers are supposed to be doing. But as an example... if you wanted to post the message "Haha" everytime someone lost a unit, you could say... Code:
Player1 Loses Unit
Events:
A unit dies
Actions:
Display to Force(Player 1) the message "Haha"
Player2 Loses Unit
Events:
A unit dies
Actions:
Display to Force(Player 2) the message "Haha"
....repeat for players 3-12...or... Code:
Player Loses Unit
Events:
A unit dies
Actions:
If (Owner of (Dying Unit)) Equal to Player 1 Then Display to Force(Player 1) the message "Haha"
If (Owner of (Dying Unit)) Equal to Player 2 Then Display to Force(Player 2) the message "Haha"
... repeat for players 3-12 ...or... Code:
Player Loses Unit
Events:
A unit dies
Actions:
Display to Force(Owner of(Dying Unit)) the message "Haha"So ummm... you tell me which way is best. |
| 03-03-2004, 03:09 AM | #3 |
I would say go with the 12 small triggers. The reason being is that blizzard compiles GUI if-thens into wierd things. Here is what the compiler converts a simple if-then statement into.(this is in JASS) Code:
func Some_Func_Name_001001001010 takes nothing returns boolean
if (not(udg_i == 24)) then
return false
else
return true
endfunciton
function My_Trig_Actions takes nothing returns nothing
if (Some_Func_Name_001001001010) then
blah, blah, acitons
else
call DoNothing() //not sure if that is the actual funciton, but who cares
endif
*rest of actions here*
endfunctionWhile it can be cleaned up if written directly in JASS, you probably don't want to do that. Let me explain a little about triggers that you may not know. If for some reason you create an infinte loop or such, warcraft has a timer, like a life, on every trigger. When triggers go over this alloted time warcraft decides they have done something wrong and kills them in order to not crash your computer. So that means if you are calling tons of functions using if-then's espically if you are using waits at all, your trigger may be killed. It would be better to go with just twelve small triggers. [edit] if you can make vanmorlok's third way work that would be the best answer. |
| 03-03-2004, 03:16 AM | #4 | |
Quote:
Ummm... okay.. we're talking about stuff being processed exponentially faster than you can blink here. There's no way that 12 IF statements would be mistaken for an infinite loop. And Blizzard would have to be ran by a bunch of brain-dead chimps to not realize that a wait statement will pause a trigger and extend its life-time. If that were the case then wait statements wouldn't even be usable. |
| 03-03-2004, 04:31 PM | #5 |
Thanks for your help guys, but I was kind of hopeing for some more practical feedback rather then theroretical. Has anyone had their map set up one way and had to change it to the other way because there was to much lag? ';.;' grrr... |
| 03-03-2004, 04:41 PM | #6 |
I fail to see how you can not compress such a trigger from 12 if statements into one. Please post said triggers goal and I can do it. |
| 03-03-2004, 04:49 PM | #7 | |
Quote:
How can we give you practical feedback without a practical problem? If you want more, you gotta give more--we can't read your mind to know what you're trying to do. |
| 03-03-2004, 11:24 PM | #8 | ||
Quote:
Well i dont need someone to combine triggers for me i have done that. I was just courious to see if seasoned mappers have had problems in this area and if so were able to over come them. Quote:
My situation is when a unit dies, the same unit is make back home and points are awarded to the owner of the killing unit. So, i first made 12 triggers like this: EVENT: unit dies CONDITION: owner of killing unit was Player 1 owner of dying unit was ally of other team ACTION: make 1 unit of type dying uint back home for owner of dying unit award points to owner of killing unit. Then i combined them into 1 tirgger EVENT: unit dies CONDITION: ACTION: if/then/multiple if: owner of dying unit was ally of other team then: if: owner of killing unit was Player 1 then: make 1 unit of type dying uint back home for owner of dying unit and award points to owner of killing unit. else: if: owner of killing unit was Player 2 then: make 1 unit of type dying uint back home for owner of dying unit and award points to owner of killing unit. else: if: owner of killing unit was Player 3 then: make 1 unit of type dying uint back home for owner of dying unit and award points to owner of killing unit. else: do nothing etc. So as you can see the later example is more bloated then the first, because they are DIFFERENT there inherently is one way that is better than the other. Since i was unsure, I thought i would post it to the formes to see if any seasoned mappers have delt with this situation already. Thanks. |
| 03-03-2004, 11:31 PM | #9 | |
Quote:
That is the best one, I would use it. |
| 03-04-2004, 03:31 AM | #10 | |
Quote:
When people ask me a question like he did I am liable to split hairs over the matter. I am not normally that picky, but he asked which way was better. I gave him the most practical answer as to why one was better. Whether it would work or not in his case, I don't care. It probably wouldn't kill a trigger unless he was actually using 1000's of if-thens, but the main point that I was getting at was the waits. Many waits + many if-then = cut trigger. But like all of us have said, if you can use things like (owner of dying unit) and such then you would be much better off. |
| 03-04-2004, 04:21 PM | #11 |
Thanks again for those of you who posted. I thought i would respond back and tell you what i finally decided on. Well, instead of doing 12 small triggers or 1 large trigger, i opted to make 2 medium size triggers. One for one each team. I think this solution makes the most sense. Hopefully no one will lag out cause of the map. If you have any further input on this topic I would still love to hear it. Peace. P.S. ^_^ <-- These horns never stop spinning. o_O <-- This guy jus got kicked in the nutz. :o <-- And this guy jus craped his pants. :D <-- GG |
| 03-04-2004, 04:37 PM | #12 |
E: Unit dies C: owner of (dying unit) is NOT an ally of owner of (killing unit) A: -give owner of (dying unit) unit of unit-type (dying unit) -give points to owner of (killing unit) Does that work for you? I've done pretty much the same thing in one of my campaings, and no lag whatsoever. It was for giving gold to heroes when they made a hero kill. |
| 03-04-2004, 06:55 PM | #13 | |
Quote:
Thanks Silver_Lynx, Cool suggestion. At first glance your solution looks like it would work well for all the players in just one small trigger. But there is a factor that it does not address. (No worries you didn't know because i didn't tell u) The factor that it does not account for is that there are also creeps on the map and i dont want people to get points for killing creeps OR have your units remade if you let them get killed by the creeps. So that is why i made multiple triggers to ensure if a unit died that it was on a certain team and the killing unit was on the other team and not just "not an ally of" because creeps are not your ally. Silver_Lynx, Can you think of a little tweak to your suggested solution that would account for creeps? Thanks, Peace. |
| 03-04-2004, 07:03 PM | #14 |
And why not just extrapolate some more: E: Unit dies C: owner of (dying unit) is NOT an ally of owner of (killing unit) owner of (dying unit) not equal to Nuetral Hostile owner of (dying unit) not equal to Nuetral Passive A: -give owner of (dying unit) unit of unit-type (dying unit) -give points to owner of (killing unit) |
| 03-05-2004, 09:57 PM | #15 | |
Quote:
Ahh i think i see where this is going now. There should be a way for me to have one small trigger that will work for all 12 players. Hmm. I'm gona have to scratch my head hard for this one. There were also some other things like player score integer varribles, that the above solution does not speciffically address. I think im gona have to set up an integer varriable aray, which i have never done before. Is it difficult? Anyone have any begnner tips for using a integer variable array? Nevertheless, I will post my current working triggers here when i get home so you guys can see exactly what im talking about. ~Dexll~ |
