Sorry I just realized I din't give my info on what I did. Sorry I'm super tired. Here is the script I've been working on. Sometimes two units die at the same time and it spawns my units twice. Anyone know of a way I could avoid this?
UnitDiesEventsUnit-AnyUnitdiesLocalVariablesConditionsActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Ownerof(Triggeringunit))==2ThenGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Emptyunitgroup)==SecondPlayerGroup(NumberofLivingunitsinSecondPlayerGroup)<=0ThenCinematics-TurncinematicmodeOfffor(Allplayers)over0.0secondsCamera-StopFollowingforplayer1SecondPlayerGroupwiththecameraandClearCurrentTargetCamera-Panthecameraforplayer1to(PlayerSpawnPointoffsetby(0.0,0.0))over0.0secondswith100%initialvelocity,4%deceleration,andDoNotusesmartpanningTrigger-RunPlayerSpawn(CheckConditions,Don't Wait until it finishes) Else ElseCinematic Unit Counter Options: Event Return Type: Real Parameters Boss Spawn Point = (Boss Spawn Point offset by (0.0, 0.0)) <Point> Grammar Text: CUC() Hint Text: (None) Custom Script Code Local Variables Actions Variable - Set Cinematic Units count = (Cinematic Units count + 1) Unit - Return (Real(Cinematic Units count))
Create a variable of type "unit" and, when the single unit you want to use is created, set the value of the variable equal to that specific unit (either explicitly in map startup, or by using the "last created unit" value).
Once you have that unit variable, you can use it as a condition for your trigger.
Yes but this would only trigger on that single unit. So if it dies. My cinematic ends and my units spawn before the cinematic force is dead. I was to condition the last dying unit. is that at all possible?
Oh, I misunderstood. In that case, you could add all your units you want to track to a "unit group" variable, then use the condition "number of living units in group = 0".
Actually both my technique and your technique doesn't work for what I want to do. Because both units can be in the same group and die at the same time thus triggering my trigger twice. Same thing applies to my interger calculation. I want a condition that would be like (Number of (triggering Unit) == 1.
Does that exist? Or how may I go about creating that?
Just add a turn off trigger action at the end of the trigger to stop it from Running again, that stops the trigger running again and again, but Unit groups is the best way that i know of.
@Trigger in second post:
This fails because you call a trigger to spawn another unit. You would like to have an action definition (function) instead because calling triggers isn't instant because it creates a new thread. So you will have a chance that there are multiple threads (= running triggers) created before the spawn code will be executed.
I'm assuming here that Starcraft will process new threads last. But since it doesn't work properly for you, it seems that this is the case here.
@your last post
Please don't consider checking that every 0.05 seconds. Since you have events that run a trigger, if a unit dies, you can solve this in a clear, efficient way.
You are already checking the unit group size to spawn only once. You only need to make sure that the code will be executed next to instantly falsify the condition. You can achieve that with transfering your spawn trigger code to an action definition and execute it afterwards (just don't make it another thread in the action definition options, then everything is ok).
You could use a boolean instead like you stated, but it should work without a boolean.
If you use a boolean, make sure to directly set it after you entered the "then".
"Number of (triggering Unit) == 1" Trigger always will fire once per each unit dying which means its always true (actually triggering unit is unit type, there's always 1 unit, otherwise it would be unit group
If (from what i understood) you want trigger to fire only once do
Can you explain in step by step how what should happen i can try to help you more accurate :)
<sub>Also try to avoid many 0.05 periodic timers, they are often unnecessary</sub>
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I've been looking around the editor for a condition to only count 1 unit dying as an event. Could anyone point me in the right direction?
@DarlD: Go
Sorry I just realized I din't give my info on what I did. Sorry I'm super tired. Here is the script I've been working on. Sometimes two units die at the same time and it spawns my units twice. Anyone know of a way I could avoid this?
@DarlD: Go
Create a variable of type "unit" and, when the single unit you want to use is created, set the value of the variable equal to that specific unit (either explicitly in map startup, or by using the "last created unit" value).
Once you have that unit variable, you can use it as a condition for your trigger.
@Chiquihuite: Go
Yes but this would only trigger on that single unit. So if it dies. My cinematic ends and my units spawn before the cinematic force is dead. I was to condition the last dying unit. is that at all possible?
@DarlD: Go
Nvm I got it. I made a unit Counter basically and I'm using that variables value to evaluate the number of units alive.
@DarlD: Go
Oh, I misunderstood. In that case, you could add all your units you want to track to a "unit group" variable, then use the condition "number of living units in group = 0".
In any case, I'm glad you got it working =)
@Chiquihuite: Go
Actually both my technique and your technique doesn't work for what I want to do. Because both units can be in the same group and die at the same time thus triggering my trigger twice. Same thing applies to my interger calculation. I want a condition that would be like (Number of (triggering Unit) == 1.
Does that exist? Or how may I go about creating that?
Just add a turn off trigger action at the end of the trigger to stop it from Running again, that stops the trigger running again and again, but Unit groups is the best way that i know of.
@Pshyched: Go
Did that. Also din't work. every .05 game time seconds i would have an If then else run.
(Basic version)
if number of living units in unitgroup <= 0 (or 1 I'm not sure which value. Sometimes it doesn't work when I set it at 0.)
then run player spawn.
else (nothing)
And In my player spawn I'd have my units created. 1 at a time with an off set on the point. and I'd have a turn off the current trigger.
I suppose I could create a bool. Have it set to true once my units have been spawned and inclue that as a condition for player unit spawn.
So if Units have Spawned == False
Spawn units
set variable to Units have Spawned == True
That would work right?
@Trigger in second post:
This fails because you call a trigger to spawn another unit. You would like to have an action definition (function) instead because calling triggers isn't instant because it creates a new thread. So you will have a chance that there are multiple threads (= running triggers) created before the spawn code will be executed.
I'm assuming here that Starcraft will process new threads last. But since it doesn't work properly for you, it seems that this is the case here.
@your last post
Please don't consider checking that every 0.05 seconds. Since you have events that run a trigger, if a unit dies, you can solve this in a clear, efficient way.
You are already checking the unit group size to spawn only once. You only need to make sure that the code will be executed next to instantly falsify the condition. You can achieve that with transfering your spawn trigger code to an action definition and execute it afterwards (just don't make it another thread in the action definition options, then everything is ok).
You could use a boolean instead like you stated, but it should work without a boolean.
If you use a boolean, make sure to directly set it after you entered the "then".
@Ahli634: Go
I'm really un-familiar with functions and action definitions. I tried them out and I could not make them work properly.
@DarlD: Go
Okay. I got it sorta working. I used the condition within bounds and I used 88% and 92% and the boss shot the barrage at my units! Yay! i died!
Unfortunately the scv's didn't spawn. How do I fix this?
"Number of (triggering Unit) == 1" Trigger always will fire once per each unit dying which means its always true (actually triggering unit is unit type, there's always 1 unit, otherwise it would be unit group
If (from what i understood) you want trigger to fire only once do
Can you explain in step by step how what should happen i can try to help you more accurate :)
<sub>Also try to avoid many 0.05 periodic timers, they are often unnecessary</sub>