Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Repeat Triggers... Possible?
Repeat Triggers... Possible?
Jan 22 2009, 10:30 pm
By: Nikronius  

Jan 22 2009, 10:30 pm Nikronius Post #1



Hi guys!

Well I am working on a modified version of python with an option that allows the user that controls the center get ally with a computer and get some advance...

I am using the following code:

Trigger("Player"){
Conditions:
Commands the Most At("Any unit", "000");
Bring("Current Player", "Any unit", "000", At least, 1);

Actions:
Run AI Script("ClrC");
Run AI Script("+Vi7");
Play WAV("sound\\Misc\\button.wav", 0);
}

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

Trigger("Player"){
Conditions:
Command the Least At("Any unit", "000");
Bring("Foes", "Any unit", "000", At least, 1);

Actions:
Run AI Script("ClrC");
Run AI Script("-Vi7");
Play WAV("sound\\Misc\\Buzz.wav", 0);
}


The point is that when current player sends units to 000 and has more units than his opponent he should get vision from P8, and viceversa, if enemy has more units than him in that area he should lose vision and enemy gets it...

The problem is that it seems to work only once, after i lose vision I cannot recover it... I suspect that is because triggers happen to work only once... any way to work around this? (I was poking the clear previous combat data option for that)

Note:

The original Idea was if Player BUILDS in that area... but I dont see any condition in which computer checks if there is NO building in certain area, so I had to work out with comparison of units which is still ok but if it is possible to do it with buildings please give me directions to do it!

**Using Scmdraft 2.080b

Thanks in advance guys!



None.

Jan 22 2009, 10:31 pm Falkoner Post #2



Preserve Trigger.

Look for that action :)

Note that if you add that, the trigger will run over and over while the unit is at that location, because the conditions remain true, you might want to set a switch in the actions and have that it has to be cleared in the conditions, or move the unit away from the location once they step on it.



None.

Jan 22 2009, 10:35 pm Nikronius Post #3



Thanks! I will try it later on, here is very late now. :lol:

hey! how do you set that switch, can you explain me little bit more? (Im new to this...) I was thinking about it but I have no idea how to do it!



None.

Jan 22 2009, 10:36 pm ForTheSwarm Post #4



Quote from Nikronius
The original Idea was if Player BUILDS in that area... but I dont see any condition in which computer checks if there is NO building in certain area, so I had to work out with comparison of units which is still ok but if it is possible to do it with buildings please give me directions to do it!

There is a command to check for buildings. It's next to Men, Factories, and Any Unit at the bottom of the unit list.

Post has been edited 1 time(s), last time on Jan 22 2009, 10:55 pm by ForTheSwarm.



None.

Jan 22 2009, 10:40 pm Falkoner Post #5



If you'd like to read up more on switches go ahead and check on this tutorial on my site: http://Falkoner.CoW.GooglePages.com/Switches.html Also, I'd read up on some stuff in the Wiki and the Tutorials.



None.

Jan 22 2009, 10:40 pm Nikronius Post #6



Quote from ForTheSwarm
Quote from Nikronius
The original Idea was if Player BUILDS in that area... but I dont see any condition in which computer checks if there is NO building in certain area, so I had to work out with comparison of units which is still ok but if it is possible to do it with buildings please give me directions to do it!

There is a command to check for buildings. It's next to Men and Any Unit.

Yeah but the conditions to check for that are not helpful... example:

Current player Brings exactly 1 [buildings] at "000"

obviously i can check if somebody builds there... but there is no condition to check if that building that he did is destroyed by enemies... and thats what Im refering to... as for saying:

Current player suffers exactly 1 death all buildings at "000"
action:
Run AI script "turn off vision for P8"

for example...

no way to do that....



None.

Jan 22 2009, 10:43 pm Falkoner Post #7



Actually, you could set a switch when a player brings a building there, then have a trigger like this:

If Switch "Building There" is Set
If Player X has suffered at least 1 death of building
If Player X brings exactly 0 building to "Location X"

Then:
Actions.

And that would work almost as well.



None.

Jan 22 2009, 10:56 pm ForTheSwarm Post #8



1. Brings 1 building to location.
Switch 1 is Cleared.

Actions.
Set Switch 1.


2. Brings 0 Buildings to location.
Switch 1 is Set.

Actions.
Clear Switch 1.



None.

Jan 24 2009, 12:46 am Nikronius Post #9



well the Preserve Trigger Worked just fine... but i want to fix something, I attached the map so you can see it.

The problem is that when i put 1 probe (or any unit) in middle of map, the trigger starts and i get ally, but when i go from the place it should turn off but it doesnt, the only way it turns off is when the other player comes in center of the map and I am not there anymore...

I would like that 1) if I have to zealots and he has 3 zealots I lose ally and enemy gets it and 2) if there is nobody in center except me when I leave i should lose vision...

I put the triggers that way but seems not to work, can you guys check it out and tell me if there's anything wrong with the code?



None.

Jan 24 2009, 1:48 am NudeRaider Post #10

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

You forgot the map.

Can't give you elaborate answer right now because I'm dead tired. But you have to make a trigger that checks if you have middle, and If you have it, if you have no units there. When true, set ally/vision.




Jan 24 2009, 2:53 am poison_us Post #11

Back* from the grave

Just copy the trigger with the allied vision turning on, change the "bring" condition to 0 for [buildings] or whatever, and change the action from allied vision on to off.

Or, instead of the "bring" condition, you could have the "commands the most at" condition.




Jan 24 2009, 9:22 am Nikronius Post #12



lol sorry I forgot the map...
ok I will try to add "bring 0" cause the conditions to turn off are:

1) if Foes bring at least 1 [any unit] at "000"
2) if Player commands the least [any unit] at "000"

then turn off vision

EDIT: Well now that function works perfectly!, but can somebody explain me why it is not randomizing the starting locations for players?? i have the option turned on and i have 8 spawn places... but still they come up always in the same place! :hurr:

Thanks for all the help guys!

Attachments:
ICCup Python 1.3 RC.scx
Hits: 1 Size: 65.22kb

Post has been edited 2 time(s), last time on Jan 24 2009, 9:31 am by Nikronius.



None.

Jan 24 2009, 9:33 am Wormer Post #13



The solution is:
Quote

Player 1 triggers


Player 2 triggers


The solution might be little improoved (regarding to number of triggers) using some DeathCounter techniques and generalized (regarding to number of players and other things), but this is the starting point.

If I understand you right you're giveing vision when:
1. The player has not got vision.
2. The player have the most forces in the middle.
3. The player have built at least one building in the middle.

You're taking vision when:
1.1 The vision has already been set to the player before.
1.2 The player has not got the most units (buildings count too) in the middle
(when you have only 2 players this is equivalent to: the player has got the least units in the middle)
- OR -
2.1 The vision has already been set to the player before.
2.2 The player has got 0 buildings in the middle.

Switches sP1VisionOn and sP2VisionOn are used to store the infromation about whether the vision was given to the player.



Some.

Jan 24 2009, 9:41 am Wormer Post #14



Quote
Well now that function works perfectly!, but can somebody explain me why it is not randomizing the starting locations for players?? i have the option turned on and i have 8 spawn places... but still they come up always in the same place!
They are not randomized because you have predefined races for players 3 and 4, thus it randomizes only between player 1 and player 2.

EDIT: After you posted the map I realized that the system you're trying to make is a bit more complex because you should make it work for 4 players, not only 2.



Some.

Jan 24 2009, 9:52 am Wormer Post #15



Few comments to the posted map:

Quote
Trigger("Player"){
Conditions:
Bring("Current Player", "Any unit", "000", At most, 0);
Command the Least At("Men", "000");
Actions:
Run AI Script("-Vi7");
Preserve Trigger();
}
You should realize that this trigger will run only when both conditions are met altogether. The first condition implies the second, thus the trigger is equivalent to:
Quote
Trigger("Player"){
Conditions:
Bring("Current Player", "Any unit", "000", At most, 0);
Actions:
Run AI Script("-Vi7");
Preserve Trigger();
}

I wonder what is this trigger for:
Quote
Trigger("Player"){
Conditions:
Always();

Actions:
Run AI Script("PMCx");
}





Jan 24 2009, 10:20 am Nikronius Post #16



Quote from Wormer
Quote
Well now that function works perfectly!, but can somebody explain me why it is not randomizing the starting locations for players?? i have the option turned on and i have 8 spawn places... but still they come up always in the same place!
They are not randomized because you have predefined races for players 3 and 4, thus it randomizes only between player 1 and player 2.

EDIT: After you posted the map I realized that the system you're trying to make is a bit more complex because you should make it work for 4 players, not only 2.

why do you think I should do it for 4 pls? and actually the system that I have right now should work for the 4 players cause I put it as "Current Player" in force 1 so the 4 players should experience the same am I wrong?



None.

Jan 24 2009, 10:32 am Wormer Post #17



Quote from Nikronius
why do you think I should do it for 4 pls? and actually the system that I have right now should work for the 4 players cause I put it as "Current Player" in force 1 so the 4 players should experience the same am I wrong?
I've made the conclusion based on the fact you have 4 players in the Force 1. Or do you just left them to make proper locations randomization for every of 4 spots? Yes, it will work for all 4 players, but it dont takeing player allainces into account and what is the most important will take vision off only when the player leaves the location with all units. In other words player still will have vision when he hast not got the most units at location but controls at least 1 there.

EDIT: Actually this might not be as bad idea... I just dont know what do you want.

Post has been edited 1 time(s), last time on Jan 24 2009, 10:48 am by Wormer.



Some.

Jan 24 2009, 10:51 am Nikronius Post #18



Quote
I wonder what is this trigger for:
Quote
Trigger("Player"){
Conditions:
Always();

Actions:
Run AI Script("PMCx");
}
Hahaha that trigger is for me to put a computer to play temporarely and be able to test the map. :D
Quote
and what is the most important will take vision off only when the player leaves the location with all units. In other words player still will have vision when he hast not got the most units at location but controls at least 1 there.
is true that right now if p1 has 1 unit and p2 has 3 both have vision until one of them has no unit in center... I was thinking that if i put only:

commands the least
commands the most

it would simply compare who has the most in middle and thus if p1 has 1 unit and p2 has 3 ONLY p2 would have vision but what happens is that at the beginning of the game both players get vision and it simply wont shut off... I have no idea why that happens and thats why I ended up with the current system that i have.
Quote
it dont takeing player allainces into account
I dont understand what you mean... that if p1 and p2 are ally and one of them goes to middle the other one doesnt get vision?? I think they do because they share vision... please explain.

the system with switches might be more accurate but until now I didnt understand it properly, I will try right now with switches to see how it works, but I have a question, you think is better to use EACH PLAYER their own triggers or for sake of less triggers is it better to use the "Current Player" option.


EDIT:
sorry... let me try to be clear with what i want:

i want people to fight for the center, I dont want people to be just macroing... so:

1) The person who has units in the center will get some advantage, in this case some % of vision of the center
2) If the opponent brings units to the center the vision turn off for the player with less units
3) If there is no unit in the middle both players should lose vision
-- Im thinking about adding other places in the map where you can control vision (corners) so people have to be going around the map (kind of training... specially for me :><: ) but I am not sure if I can give 100% vision of map to player 8 and then just share vision to players in some specific locations depending on switches or something so thats just a vague idea I have, not working on it right now because im trying to improve the system --

I had the problem that if i brought 1 unit to the middle and then went to my base again the vision was on all the time, but that is fixed.

What i have right now is the comparison, right now if both players have units in the middle both are getting vision regardless of who has more units... I want to fix that.

Everything else is working perfectly at least as I want, even though Im thinking about trying your code 1) to learn and 2) to see which works better.

:><:

Post has been edited 1 time(s), last time on Jan 24 2009, 11:33 am by NudeRaider. Reason: merged posts



None.

Jan 24 2009, 11:52 am NudeRaider Post #19

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote from Nikronius
Quote
it dont takeing player allainces into account

I dont understand what you mean... that if p1 and p2 are ally and one of them goes to middle the other one doesnt get vision?? I think they do because they share vision... please explain.
Shared vision is not passed on to the next player. The player who has allied vision from you sees everything YOU see, but he doesn't see the things you are shown by another player.

My recommendation on that problem is to use a death counter that signifies is you have vision or not.
Make 2 "blind" triggers (preserved of course) that set the vision based on the DC.
- If Current Player has suffered at least 1 death of 'Vision DC' then turn ON shared vision for <Computer>
- If Current Player has suffered at most 0 deaths of 'Vision DC' then turn OFF shared vision for <Computer>

The reset vision trigger:
C: Always
A: Set deaths for Current Player to 0 for 'Vision DC'
A: preserve

The activation trigger:
C: Current Player controls the most [men] at 'middle'
C: Current Player brings at least one [men] to 'middle'
A: Set deaths for All Players to 1 for 'Vision DC'
A: Set deaths for Foes to 0 for 'Vision DC'
A: preserve

Basically the first of those 2 last triggers always clears your vision DC (not the vision yet!) and you only get it back when you still control the most units (next trigger). Trigger order is obviously important here.

The last trigger sets the vision DC to all players that are not your enemies aka the players you allied. If you unally someone but he has still allied you, he still will not receive vision.

This is the most elegant way to do this. You need no switches, only 1 DC, just 4 triggers for as many players as you wish and gives freedom with alliances.


You asked about specific players vs current player:
Always use Current Player whenever possible. Using specific players can get you in trouble with leavers plus usually you need less triggers and it's easier to maintain the map should you want to add something.

Post has been edited 1 time(s), last time on Jan 24 2009, 1:59 pm by NudeRaider.




Jan 24 2009, 12:01 pm Wormer Post #20



Quote from Nikronius
I was thinking that if i put only:

commands the least
commands the most

it would simply compare who has the most in middle and thus if p1 has 1 unit and p2 has 3 ONLY p2 would have vision but what happens is that at the beginning of the game both players get vision and it simply wont shut off...
If you put only these conditions the problem is that at the beginning of the game all players remaining in the game (includeing observers) have got equal number of units in the middle. Every time all players remaining in the game have got equal number of units at location they all have the most and at the same time the least units at that location. This is the only case when both conditions are true. This could be the problem.

You better imagine when you have to to give vision and to take it instead of thinking when the vision should be on. Thinking the first way is closer to the triggers implementation.

Quote from Nikronius
Quote
[quote]it dont takeing player allainces into account

I dont understand what you mean... that if p1 and p2 are ally and one of them goes to middle the other one doesnt get vision?? I think they do because they share vision... please explain.
Oh well, I was thinking of 4 players playing the game and have alliances between each other. The question is what you should do in that case.

Your current system is not taking alliances into account. Everything will work the same way whether they are allied or not. With your current system (and mine too) this does not matter at all.

Quote from Nikronius
I have a question, you think is better to use EACH PLAYER their own triggers or for sake of less triggers is it better to use the "Current Player" option.
It is better to use the Current Player option. Generally it is bad when you have many triggers makeing the same thing, because if you want to change something you have to change it in every copy of the trigger.

But I break this rule and gave you an example for the sake of being more simple to understand... To use the current player in my example you should use Death Counters (switches section) instead of the Switches sP1VisionOn and sP2VisionOn:

Quote
// give vision
TRIGGER
OWNERS: Force 1
CONDITIONS:
Current player has suffered exactly 0 deaths of dcVisionOn
Current player commands the most Any Unit at lMiddle
Current Player brings at least 1 Buildings at lMiddle
ACTIONS:
Modify deaths counts for Current Player: set to 1 for dcVisionOn
Execute AI script +Vi7
Preserve trigger

// take vision
TRIGGER
OWNERS: Force 1
CONDITIONS:
Current player has suffered exactly 1 deaths of dcVisionOn
Current player commands the least Any Unit at lMiddle
ACTIONS:
Set sTakeVision
Preserve trigger

TRIGGER
OWNERS: Force 1
CONDITIONS:
Current player has suffered exactly 1 deaths of dcVisionOn
Current Player brings exactly 0 Buildings at lMiddle
ACTIONS:
Set sTakeVision
Preserve trigger

TRIGGER
OWNERS: Player 1
CONDITIONS:
Switch sTakeVision is Set
ACTIONS:
Clear sTakeVision
Modify deaths counts for Current Player: set to 0 for dcVisionOn
Execute AI script -Vi7
Preserve trigger

You change every
"Set sP1VisionOn" and "Set sP2VisionOn" actions to "Modify deaths counts for Current Player: set to 1 for dcVisionOn"
"Clear sP1VisionOn" and "Clear sP2VisionOn" actions to "Modify deaths counts for Current Player: set to 0 for dcVisionOn"
"sP1VisionOn is Set" and "sP2VisionOn is Set" conditions to "Current player has suffered exactly 1 deaths of dcVisionOn"
"sP1VisionOn is Cleared" and "sP2VisionOn is Cleared" conditions to "Current player has suffered exactly 0 deaths of dcVisionOn"

dcVisionOn is an unused unit which players cant kill in the game. For example a hero unit or whatever.

After this you could generalize triggers for Force 1.

Quote from Nikronius
-- Im thinking about adding other places in the map where you can control vision (corners) so people have to be going around the map (kind of training... specially for me :><: ) but I am not sure if I can give 100% vision of map to player 8 and then just share vision to players in some specific locations depending on switches or something so thats just a vague idea I have, not working on it right now because im trying to improve the system --
What you want could be done. But you cant give vision to players in some specific locations. For this purpose you'll need 3 computer players: the one has vision only for Player 1, the other has vision only for Player 2 and the last has vision to both players. You give Neutral units at certain areas depending on the presence of players' forces in the area. That is more complicated. You should first clearly decide what do you want to see with one area.

Quote from Nikronius
What i have right now is the comparison, right now if both players have units in the middle both are getting vision regardless of who has more units... I want to fix that.
Right now you have not clearly this. The player will get vision only when he has got the most units. But once he got the vision he will loose it only when he totally leave the area.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:29 pm]
Oh_Man -- homeworld 3 = massive disappointment
[10:05 am]
Moose -- ya
[05:23 am]
zsnakezz -- yes
[2024-5-12. : 8:51 pm]
l)ark_ssj9kevin -- Are you excited for Homeworld 3?
[2024-5-12. : 8:44 pm]
l)ark_ssj9kevin -- Hi Brusilov
[2024-5-12. : 4:35 pm]
O)FaRTy1billion[MM] -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
my server that was hosting it died
[2024-5-10. : 8:46 pm]
NudeRaider -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
https://armoha.github.io/eud-book/
[2024-5-10. : 8:36 am]
Brusilov -- Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
[2024-5-09. : 11:31 pm]
Vrael -- :wob:
[2024-5-09. : 8:42 pm]
Ultraviolet -- :wob:
Please log in to shout.


Members Online: Roy