Trigger Trouble
Mar 26 2014, 9:07 pm
By: sigsaucy  

Mar 26 2014, 9:07 pm sigsaucy Post #1



Hi, I'm attempting to make a Total War style map with city taking over that goes like

-bring men to enemy city
-enemy spawns units
-once all enemy dead around city you get control of it

The issue i'm having is that cities are spawning units twice, once when you initially bring your units, and again when you take the city.

You can run the attached map to see what im talking about.

I think the error has something to do with switches.

Thanks, here are the triggers




CITY SPAWN TRIGGER

Trigger("Player 1","Player 2","Player 3","Player 4","Player 5","Player 6","Player 7","Player 8"){
Conditions:
Switch("Switch1", not set);
Bring("Current Player", "Terran Supply Depot", "1", Exactly, 1);
Bring("Foes", "Men", "1", At least, 1);

Actions:
Set Switch("Switch1", set);
Create Unit("Current Player", "Tassadar (Templar)", 3, "1");
Modify Unit Hit Points("Current Player", "Terran Supply Depot", 50, 0, "1");
Display Text Message(Always Display, "Under Attack");
Minimap Ping("1");
Minimap Ping("1");
Preserve Trigger();
Comment("1 spawn");
}



CITY CAPTURE TRIGGER
//-----------------------------------------------------------------//

Trigger("Player 1","Player 2","Player 3","Player 4","Player 5","Player 6","Player 7","Player 8"){
Conditions:
Bring("Foes", "Terran Supply Depot", "1", At least, 1);
Bring("Foes", "Men", "1", Exactly, 0);
Bring("Current Player", "Men", "1", At least, 1);
Switch("Switch1", set);

Actions:
Give Units to Player("Foes", "Current Player", "Terran Supply Depot", All, "1");
Modify Unit Hit Points("All players", "Terran Supply Depot", 100, 0, "1");
Display Text Message(Always Display, "We have taken this city");
Preserve Trigger();
Comment("1 capture");
Set Switch("Switch1", clear);
}




CITY DEFENDED TRIGGER
//-----------------------------------------------------------------//

Trigger("Player 1","Player 2","Player 3","Player 4","Player 5","Player 6","Player 7","Player 8"){
Conditions:
Bring("Foes", "Men", "1", Exactly, 0);
Bring("Current Player", "Terran Supply Depot", "1", At least, 1);
Switch("Switch1", set);

Actions:
Remove Unit At Location("Current Player", "Tassadar (Templar)", All, "1");
Modify Unit Hit Points("All players", "Terran Supply Depot", 100, 0, "1");
Set Switch("Switch1", clear);
Preserve Trigger();
Comment("1 defended");
}

//-----------------------------------------------------------------//

Attachments:
test.scm
Hits: 3 Size: 109.5kb




Mar 27 2014, 1:33 am death6373 Post #2



I found the bug. There was nothing wrong with your triggers but the thing that was causing the units to spawn twice was a bring condition bug. Starcraft sometimes does not update correctly between triggers and the "Bring" condition will return true when we know it to be false. http://www.staredit.net/starcraft/Bring_Condition_Bug. It thought that player 8 still had a depot there when it did not therefore it spawned the units twice. I put in a move location action to force starcraft to update correctly between the triggers.

Attachments:
TestZ.scm
Hits: 1 Size: 109.5kb



None.

Mar 27 2014, 7:07 pm sigsaucy Post #3



Thanks! that fixed it.

Although the link you sent said "Remove 1 Map Revealer for Player at Location" is the best trigger to use to refresh locations due to not doing anything.

Is there any reason I should use a move location trigger instead of this? Is one of these faster or more efficient to use?

There will be alot of triggers (around 200 cities) which is why i want the best one.




Mar 27 2014, 7:52 pm jjf28 Post #4

Cartography Artisan

Most people consider the 255 location limit to be very extreme should you use gridding systems but assuming this is not a concern we can do some comparison...

In both I assume the unit ID is not present.

Move location: src location, unit, player, dest location (note that this always moves the location regardless of whether the dest unit is found)
    1. Find unit at dest location (at best, binary tree search of pre-compiled data)
    2. Change location coordinates (4 values)
    3. Validate location coordinates (4 comparisons)
    4. Refresh location data

Remove unit at location: amount, unit, player, location
    1. Find unit at location (at best, binary tree search or pre-compiled data)
    2. (remove nothing)
    3. Refresh location data

Remove unit at location for a unit that does not exist should be slightly better.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Mar 28 2014, 12:25 pm Sacrieur Post #5

Still Napping

Quote from jjf28
Most people consider the 255 location limit to be very extreme should you use gridding systems but assuming this is not a concern we can do some comparison...

But not necessarily, since grid systems are very limited and aren't perfected. There is a system that would completely eliminate the need for locations in most applications, but it has not yet been documented (I'm working on it). The truth is that most sc1 documentation isn't very complete and thorough.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:53 pm]
Oh_Man -- https://youtu.be/MHOZptE-_-c are yall seeing this map? it's insane
[2024-5-04. : 1:05 am]
Vrael -- I won't stand for people going around saying things like im not a total madman
[2024-5-04. : 1:05 am]
Vrael -- that's better
[2024-5-04. : 12:39 am]
NudeRaider -- can confirm, Vrael is a total madman
[2024-5-03. : 10:18 pm]
Vrael -- who says I'm not a total madman?
[2024-5-03. : 2:26 pm]
UndeadStar -- Vrael, since the ad messages get removed, you look like a total madman for someone that come late
[2024-5-02. : 1:19 pm]
Vrael -- IM GONNA MANUFACTURE SOME SPORTBALL EQUIPMENT WHERE THE SUN DONT SHINE BOY
[2024-5-02. : 1:35 am]
Ultraviolet -- Vrael
Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
Gonna put deez sportballs in your mouth
[2024-5-01. : 1:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
Please log in to shout.


Members Online: Roy, Dem0n