Is there a reason why you need to have a constant variable on event? I need to put a different time to fire a periodic event trigger and I cannot change the time between 2 period. I did a workaround, but it could work best with a variable...
The events are registered/created at game startup, before any other trigger code has run. So if you were to use a variable, it is safely set to a known value (0, false, null, etc., depending on type), and that is what will be used by the event.
It is possible to register events at runtime, but you have to create the GUI versions of the Events as Actions.
You could do a repeating timer instead. I'm pretty sure you can use a variable to specify their duration and use the the event for when a timer finishes.
I tried setting with a variable, but I can't change the value once it's created, as arcanes said. So if you use a random number between 0 and 2, it will randomly pick a number and this number will be the same for the rest of the game.
Yeah, I also tried this, but I need to put the create thread option on or else it will make wait the entire script. So when I put this on it kills my computer performance, because my script is relatively heavy.
My worm exploding action is actually a script of like 930 lines, which checks footprint of buildings depending on the type of the unit. So if I put this script in a normal trigger, it becomes too heavy and the editor crashes, as I need to create 25 triggers of that kind (with deferent periodic event time, depending on the frequency that I want). You can see at the very last line that I choosed a random number between 20 and 40 seconds, so the value will be fix for the rest of the game.
Yeah, you're true, it's always better with actions and loops than trigger, but as I said below, it becames too heavy to handle for the editor (I checked with the overview manager and the 25 actions takes 4,5 MB once compressed).
Hi guys,
Is there a reason why you need to have a constant variable on event? I need to put a different time to fire a periodic event trigger and I cannot change the time between 2 period. I did a workaround, but it could work best with a variable...
@tatatatate: Go
The events are registered/created at game startup, before any other trigger code has run. So if you were to use a variable, it is safely set to a known value (0, false, null, etc., depending on type), and that is what will be used by the event.
It is possible to register events at runtime, but you have to create the GUI versions of the Events as Actions.
You could do a repeating timer instead. I'm pretty sure you can use a variable to specify their duration and use the the event for when a timer finishes.
@ArcaneDurandel: Go
Thanks, it's what I wanted to know.
@MaskedImposter: Go
I needed 5 levels of frequency, so I just made 5 triggers that are initially off. I tried with action définition with create thread and while loops and it's horrible in term of performance. So I just put most of my script in an action with no create thread and it works fine.
I tried setting with a variable, but I can't change the value once it's created, as arcanes said. So if you use a random number between 0 and 2, it will randomly pick a number and this number will be the same for the rest of the game.
those 5 triggers are always doing the same thing?
put this in a seperate action and check the thread flag.
you can change the variable everywhere anytime and it runs smoother than triggers.
@FunkyUserName: Go
Yeah, I also tried this, but I need to put the create thread option on or else it will make wait the entire script. So when I put this on it kills my computer performance, because my script is relatively heavy.
I think that if the triggers are not firing, they don't use space, instead of action définition.
@tatatatate: Go
i made the opposite experience, anything but a trigger runs smoother and better. can you post your script how you did it?
Yeah, it's a pleasure! I made it in 3 ways:
-Full action, the least possible of trigger.
-Mostly done with action, but keeping main actions via triggers.
-Fully with triggers and loops.
The second choice was the best for me. I ran the action that takes 5 seconds (with waits) every 30 seconds (approximatively).
bool lib3_gt_WormMediumCreation1_Func (bool testConds, bool runActions) { Variable Declarations
unit lv_u;
actor lv_a;
region[3] lv_reg;
point[21] lv_p;
int lv_i;
fixed lv_r;
Variable Initialization
Actions if (!runActions) {
return true;
}
while ((lv_p[0] == null)) {
lv_p[0] = RegionRandomPoint(RegionPlayableMap());
if ((CreepIsPresent(lv_p[0]) == true)) {
lv_p[0] = null;
} else {
} } libNtve_gf_CreateUnitsWithDefaultFacing(1, "WormM", 0, 15, lv_p[0]);
UnitIssueOrder(UnitLastCreated(), OrderTargetingPoint(AbilityCommand("attack", 0),
RegionRandomPoint(RegionPlayableMap())), c_orderQueueReplace);
lv_u = UnitLastCreated();
Wait(RandomFixed(15.0, 30.0), c_timeGame);
libNtve_gf_CreateUnitsWithDefaultFacing(1, "WormEM", c_unitCreateIgnorePlacement, 15,
UnitGetPosition(lv_u));
lib3_gf_WormExploding(1.0, lv_u);
UnitRemove(lv_u);
libNtve_gf_PlayAnimation(libNtve_gf_MainActorofUnit(UnitLastCreated()), c_animNameDefault, "Birth", 0, c_animTimeDefault);
libNtve_gf_CreateExplosionAtPoint(libNtve_ge_ExplosionSize_Large, libNtve_ge_ExplosionType_Zerg, UnitGetPosition(lv_u));
libNtve_gf_CreateActorAtPoint("LightOmniOrangeLarge", UnitGetPosition(lv_u)); lv_a = libNtve_gf_ActorLastCreated();
Wait(4.5, c_timeGame);
libNtve_gf_PlayAnimation(libNtve_gf_MainActorofUnit(UnitLastCreated()), c_animNameDefault, "Unburrow", 0, c_animTimeDefault);
Wait(2.0, c_timeGame);
UnitRemove(UnitLastCreated());
ActorSend(lv_a, "Destroy Immediate");
return true; }
void lib3_gt_WormMediumCreation1_Init () {
lib3_gt_WormMediumCreation1 = TriggerCreate("lib3_gt_WormMediumCreation1_Func");
TriggerEnable(lib3_gt_WormMediumCreation1, false);
TriggerAddEventTimePeriodic(lib3_gt_WormMediumCreation1, RandomFixed(20.0, 40.0), c_timeGame); }
My worm exploding action is actually a script of like 930 lines, which checks footprint of buildings depending on the type of the unit. So if I put this script in a normal trigger, it becomes too heavy and the editor crashes, as I need to create 25 triggers of that kind (with deferent periodic event time, depending on the frequency that I want). You can see at the very last line that I choosed a random number between 20 and 40 seconds, so the value will be fix for the rest of the game.
Yeah, you're true, it's always better with actions and loops than trigger, but as I said below, it becames too heavy to handle for the editor (I checked with the overview manager and the 25 actions takes 4,5 MB once compressed).