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.
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
Please log in to shout.


Members Online: Roy, Moose, RIVE