Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Some problems with Switches and Wait command
Some problems with Switches and Wait command
Dec 28 2008, 8:27 am
By: xhans2x  

Dec 28 2008, 8:27 am xhans2x Post #1



OK so I'm trying to add an new dynamic armor in my map thats based on shields. Basically, all units have a small amount of shields and under certain conditions you will have your shields set to a certain percent all the time, which serves the same purpose as armor except I can change the exact percent depending on the circumstance. Now I'm having trouble actually implementing this idea because I can't seem to use the wait command.

For example, here's a test trigger I used to simulate a scenario where shields will be full for a set period of time:

Conditions:
Switch 1 is cleared

Actions:
Set shield points for all men owned by Player 1 at anywhere to 100%
Wait for 5000 milliseconds
Set Switch 1
Preserve trigger

What I want to happen is have shields be at full for 5 seconds, and have shields go back down to some other percentage. I think what happens though is my trigger immediately sets switch 1 again and the wait command does nothing. Oh and I clear Switch 1 via another trigger, so it's not the conditions that's causing the problem.



None.

Dec 28 2008, 10:01 am FatalException Post #2



So, uh... What's it doing instead of what you want it to do? That's kind of an important part that you seem to have left out. :P

One thing that I noticed is that your trigger doesn't account for other triggers that may be running at the same time and trying to change the shield percentage to something else. Also, if you want their shields to be continuously replenished to 100% for that period of time (making them essentially invincible), you'll need to separate it into two triggers: One that sets shield points and preserves, and one that waits 5000 milliseconds, sets the switch, and preserves. Just giving general ideas since I don't really know what the problem is.



None.

Dec 28 2008, 1:27 pm NudeRaider Post #3

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

First of all when you want to run a trigger action over and over, you need hyper triggers.
Otherwise sc would run the trigger, set the shield, and if conditions are still met set it again the next trigger loop 2 seconds later. During these 2 seconds no triggers are running, so shields wouldn't be modified.
So basically triggers just run ONCE, then the game goes on. The 'preserve trigger' does NOT preserve (run over and over) the actions, it simply states that the trigger will be run again, next trigger loop (instead of be deleted out of sc's memory).

Alright, so with hyper triggers triggers are checked 16 times faster, which is 8 timer per game second.
This is pretty close to executing an action over and over since only a few game frames will pass during each trigger loop.
But when using hyper triggers it is recommended to get rid of waits unless you know exactly what you're doing, or you run into wait blocks. Use a death count timer instead.

That being said the solution would look something like this:
Trigger 1: Shield state counter
Computer Player
Conditions:

Always
Actions:
Add 1 death to Cantina of Current Player
Preserve Trigger

Trigger 2: Set shield 1
Owner(s) of the unit
Conditions:

Computer Player (same as above) has suffered at most 39 deaths of Cantina
Actions:
Set shield of <unit type> of Current Player to 100%
Preserve Trigger

Trigger 3: Set shield 2
Owner(s) of the unit
Conditions:

Computer Player (same as above) has suffered at least 40 deaths of Cantina
Computer Player (same as above) has suffered at most 79 deaths of Cantina
Actions:
Set shield of <unit type> of Current Player to 50%
Preserve Trigger

...etc. as many set shield trigger as you need

Then you can use a some more triggers that control the death counter (Cantina) and thus control the shield percentage.

The only remaining problem (and there's no way around it) is if the unit is hit more than once in 1/8th of a second, then the shield isn't replenished in time, rendering the "shield-armor" useless for the follup up hits.

Post has been edited 1 time(s), last time on Dec 28 2008, 1:53 pm by NudeRaider.




Dec 28 2008, 1:45 pm Wormer Post #4



FatalException is right. Your trigger runs once the Switch 1 is cleared. Shields are once set to 100% and then it waits 5 seconds. After 5 seconds SC just sets the switch and the trigger wont run again till you clear the switch...

I'd recommended you to use Death Counters (with Hyper Triggers) as timers (and swithces) instead of waits, because waits may lead to wait blocks.

The solution may look like this:

Conditions:
Current Player has suffered Exactly 0 deaths of Timer
Actions:
Set Switch 1
Set deaths for Current Player: Set to 12*5+1 of Timer
Preserve trigger

Conditions:
Current Player has suffered At Least 2 deaths of Timer
Actions:
Set deaths for Current Player: Subtract 1 of Timer
Set shield points for All Men owned by Current Player at anywhere to 100%
Preserve trigger

When you need to run the system for particular player you just setting the Timer to 0 for that player with an external trigger.

ADDED: Ouch! I'm sorry Nude, but wtf, I've not seen your post, though it was written 30 mintes ago!

Post has been edited 1 time(s), last time on Dec 28 2008, 1:59 pm by Wormer.



Some.

Dec 28 2008, 7:47 pm xhans2x Post #5



The problem was that the trigger would not run AT ALL. The shields would NEVER be at full for even 1 second. I wanted to make switch 1 clearable everytime you cast a spell and last for 5 seconds, so that's why I had the switch set at the end of the trigger. The death counts you guys posted work so far, so I'll just get rid of wait time and switches altogether.

Also I read up on hyper triggers before I made this thread and tried the trigger out both WITH and WITHOUT hyper triggers. It seemed that if I got more than 5 or 6 units to attack the unit that one of them would breach the shields no matter what. It would take the same amount of units to breach the shields with and without the hyper trigs so it seemed like it didn't make a difference in this case, although I will still include them in my map.



None.

Dec 28 2008, 7:53 pm NudeRaider Post #6

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 xhans2x
Also I read up on hyper triggers before I made this thread and tried the trigger out both WITH and WITHOUT hyper triggers. It seemed that if I got more than 5 or 6 units to attack the unit that one of them would breach the shields no matter what. It would take the same amount of units to breach the shields with and without the hyper trigs so it seemed like it didn't make a difference in this case, although I will still include them in my map.
That can't be. As I said, the triggers run every 2 seconds without hypers, which means shields only get replenished in 2 second intervals.
As opposed to with hypers where they are replenished every 1/8 of a second.
If you could not confirm this you made some mistake while testing. Possibly your hypers being blocked by another wait.




Dec 28 2008, 9:10 pm FatalException Post #7



Quote from name:
Also I read up on hyper triggers before I made this thread and tried the trigger out both WITH and WITHOUT hyper triggers. It seemed that if I got more than 5 or 6 units to attack the unit that one of them would breach the shields no matter what. It would take the same amount of units to breach the shields with and without the hyper trigs so it seemed like it didn't make a difference in this case, although I will still include them in my map.
Could you post the trigger you used for replenishing the shield?
Quote from name:
As opposed to with hypers where they are replenished every 1/8 of a second.
Isn't it almost 1/12?



None.

Dec 28 2008, 9:13 pm NudeRaider Post #8

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 FatalException
Quote from name:
As opposed to with hypers where they are replenished every 1/8 of a second.
Isn't it almost 1/12?
11.8 times per real time second on fastest
8 times per game second
I prefer to measure times in game seconds as it's independend from speed, more relevant and more exact.




Dec 28 2008, 9:52 pm Falkoner Post #9



The math is pretty simple, what it really comes down to is that with hypertriggers on Fastest the game will check the triggers every 84 milliseconds, so you just divide 1000/84 and you get 11.904761904761904761904761904762 :)



None.

Dec 28 2008, 10:27 pm 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

Quote from Falkoner
The math is pretty simple, what it really comes down to is that with hypertriggers on Fastest the game will check the triggers every 84 milliseconds, so you just divide 1000/84 and you get 11.904761904761904761904761904762 :)
Just that it's not exactly 84ms




Dec 28 2008, 11:10 pm Biophysicist Post #11



Quote from NudeRaider
Quote from xhans2x
Also I read up on hyper triggers before I made this thread and tried the trigger out both WITH and WITHOUT hyper triggers. It seemed that if I got more than 5 or 6 units to attack the unit that one of them would breach the shields no matter what. It would take the same amount of units to breach the shields with and without the hyper trigs so it seemed like it didn't make a difference in this case, although I will still include them in my map.
That can't be. As I said, the triggers run every 2 seconds without hypers, which means shields only get replenished in 2 second intervals.
As opposed to with hypers where they are replenished every 1/8 of a second.
If you could not confirm this you made some mistake while testing. Possibly your hypers being blocked by another wait.

Hyper triggers are always a good idea. Even if they don't seem important, they are always going to help at least somewhat.

Anyway, what's happening is that two or more of the units are able to hit in the time between two trigger cycles. If one unit is able to enough damage to drain the shields by more than half with one attack routine, it will only take two of them attacking between two trigger ycles to break the system, which could theoretically happen fairly often even with hyper triggers if there are enough units. Nothing you can really do about it, but hyper triggers will help a bit, even if it doesn't look like it.



None.

Dec 29 2008, 1:39 am xhans2x Post #12



Quote from FatalException
Quote from name:
Also I read up on hyper triggers before I made this thread and tried the trigger out both WITH and WITHOUT hyper triggers. It seemed that if I got more than 5 or 6 units to attack the unit that one of them would breach the shields no matter what. It would take the same amount of units to breach the shields with and without the hyper trigs so it seemed like it didn't make a difference in this case, although I will still include them in my map.
Could you post the trigger you used for replenishing the shield?

The trigger I used to test the shields was

Conditions:
Always

Actions:
Set shields to 100% for all units owned by Player 1 at anywhere.
Preserve Trigger

It was a blank map with no other triggers and the zealot stats were 20 dmg with 10 shields, so if the zealot ever took dmg to its HP it would mean that an attack got through the shields. Since zealots attack twice for 10 dmg, whenever a hit would go through it would only take 10 damage instead of 20. Also when I tested with and without the hyper triggers the map had no other wait command and there were no other triggers besides the replenish shields trigger and hyper triggers. I guess it's not really a problem since there needed to be 5-6 units attacking in order to get through the shields (I can just say that enemies have a 1 in 6 chance of getting a critical hit on you). It was only weird because even WITHOUT the hyper triggers the shields seemed to recharge really fast so much so that I needed multiple units hitting the zealot for it to take damage.



None.

Dec 29 2008, 1:47 am NudeRaider Post #13

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 xhans2x
It was only weird because even WITHOUT the hyper triggers the shields seemed to recharge really fast so much so that I needed multiple units hitting the zealot for it to take damage.
Yeah I too noticed inconsistencies in damage calculation with low shield values. I always figured it's because shield armor, shield hp and armor suck up the whole damage.
But that behavior hasn't anything to do with setting the shield.

Use 1 unit and test with it. You see much better whats happening.




Dec 29 2008, 2:15 am badcop Post #14



Quote from xhans2x
What I want to happen is have shields be at full for 5 seconds, and have shields go back down to some other percentage. I think what happens though is my trigger immediately sets switch 1 again and the wait command does nothing. Oh and I clear Switch 1 via another trigger, so it's not the conditions that's causing the problem.
So, you want the zealot to have 100% shield for 5 seconds, and then have the shield go down to some other percentage? Well, I think this is the solution.

Trigger 1
[Conditions]
Current Player has suffered exactly 1 death(s) of '2nd desired DC unit'
[Actions]
Modify death count(s) for Current Player add 1 for '1st desired DC unit'
Preserve Trigger

Trigger 2
[Conditions]
"Current player cast 'x' spell (Whatever conditions you're using to detect spells.)
[Actions]
Modify death count(s) for Current Player set to 1 for '2nd desired DC unit'
Preserve Trigger

Trigger 3
[Conditions]
Current Player has suffered exactly 1 death(s) of '2nd desired DC unit'
[Actions]
Set shield to 100% on [any unit] for Current Player at anywhere
Preserve Trigger

Trigger 4
[Conditions]
Current Player has suffered at least 69 death(s) of '1st desired DC unit'
[Actions]
Modify death count(s) for Current Player set to 0 for '1st desired DC unit'
Modify death count(s) for Current Player set to 0 for '2nd desired DC unit'
Preserve Trigger

For what you want if I'm not mistaken this method should work.



None.

Dec 29 2008, 2:47 am xhans2x Post #15



Quote from NudeRaider
Quote from xhans2x
It was only weird because even WITHOUT the hyper triggers the shields seemed to recharge really fast so much so that I needed multiple units hitting the zealot for it to take damage.
Yeah I too noticed inconsistencies in damage calculation with low shield values. I always figured it's because shield armor, shield hp and armor suck up the whole damage.
But that behavior hasn't anything to do with setting the shield.

Use 1 unit and test with it. You see much better whats happening.

The original test involved 2 of the above zealots with 1 just standing there and another one hitting it. I found that it was impossible for just 1 zealot to deal damage to the other even without hyper triggers that's why I included extra zealots in subsequent tests. Even with normal trigger speed it seems that the shields will always recharge BEFORE the second zealot attack (which seems to be half a second or so, not sure though).



None.

Dec 29 2008, 5:31 am NudeRaider Post #16

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 xhans2x
The original test involved 2 of the above zealots with 1 just standing there and another one hitting it. I found that it was impossible for just 1 zealot to deal damage to the other even without hyper triggers that's why I included extra zealots in subsequent tests. Even with normal trigger speed it seems that the shields will always recharge BEFORE the second zealot attack (which seems to be half a second or so, not sure though).
And I still insist that the shields are only modified every 2 seconds when not using hyper triggers. I'm not just guessing something, or making something up, THIS IS A PROVEN FACT!
If your tests suggest different behavior then this is because your tests are flawed.
Keep in mind that shield regeneration (adds 1 shield about every second) also takes away a bit of damage.
You should increase the shield value and damage to make your tests reliable. Hang on, I'll attach a testmap for you...
There. You will realize that sometimes the shield gets replenished in time, and sometimes the damage gets through. The zealot hits at about once every 1.5 seconds (triggers are checked every 2 seconds), so it takes him several hits to actually make damage.
When you step on the grey terrain and thus activate the hyper triggers, most of the time you won't even see the shield go down. It's regenerated practically instantly. If that doesn't convince you, then I don't know what will.

Post has been edited 2 time(s), last time on Dec 29 2008, 12:28 pm by NudeRaider.




Dec 29 2008, 12:12 pm Falkoner Post #17



Dude, I would just use Hyper Triggers, if you don't already have a ton of waits in your map, there's no reason not to put them in, they simply make things faster, such as selection systems and detection, it's annoying as a player having to wait on a beacon for a trigger to run, using Hyper Triggers makes that wait negligible.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:55 am]
Vrael -- Right I forgot, maybe something more like: output_yr = getinternalengine().timecooker.timemethod.bake().steam().casserole().lookattheclockonthewall.converttotimezone.souvide().current().subtractepoch()
[11:56 pm]
l)ark_ssj9kevin -- Vrael
Vrael shouted: I mean, if you just used output_yr = datetime.datetime.fromtimestamp(time.time()).strftime("%Y") then you wouldnt have to log in and log off for the year and you'd save yourself a whole bunch of trouble
SEN is written in PHP so it's probably even more arcane than that
[11:32 am]
NudeRaider -- No, it's Corbo
[2025-1-13. : 10:41 pm]
Vrael -- is evildesk still working in the copyright office is that why
[2025-1-13. : 9:14 pm]
Ultraviolet -- request denied
[2025-1-13. : 8:02 pm]
Roy -- We have to go down to the copyright office and renew our registration before we're allowed to change the date on the site.
[2025-1-13. : 2:44 am]
Ultraviolet -- But then how can you pretend and bullshit yourself that you're going to make big wonderful changes?? Nope, manual entry is the only way
[2025-1-12. : 11:56 pm]
Vrael -- I mean, if you just used output_yr = datetime.datetime.fromtimestamp(time.time()).strftime("%Y") then you wouldnt have to log in and log off for the year and you'd save yourself a whole bunch of trouble
[2025-1-11. : 2:16 pm]
Ultraviolet -- Sounds about right ;)
[2025-1-11. : 12:35 pm]
Moose -- > Log in January 1. > "This is the year I'm really going to overhaul this website." > Change date in copyright footer. > Log off for the year.
Please log in to shout.


Members Online: RIVE