Jump to content
TeTeT

Trigger area damaging player continuously?

Recommended Posts

Hello,

 

my trigger foo is probably very weak: Yesterday I tried to create a trigger area and continuously damage a player that enters the trigger area. The trigger fired exactly once, though the 'repeatedly' flag was set. What did I miss?

 

So far I've used waitUntil most often for such tasks, but I guess triggers are much more resource friendly than a check on any given frame.

 

Cheers,

TeTeT

Share this post


Link to post
Share on other sites

You have to leave the Trigger Area, then go back in. It needs to reset.

To have it repeat while inside a trigger you'll have to run a script or turn On/Off a variable so the trigger resets via script.

Share this post


Link to post
Share on other sites

A trigger with the repeated flag set can activate when the condition is true, then deactivate again when the condition is false and keep doing that as the world state changes, in your case that means as the player enters then exits the area then enters it again.

 

TL DR: What @Von Quest said. 

 

To create what you want I would go for a loop. WaitUntil could do it but I'm a sucker for a good ol' while-loop. 

 

Put this in your trigger's activation:

Sorry for no code format, I'm on mobile

0 = [thisTrigger, player] spawn {

Params ["_trg", "_obj"];

private _dDamage = 0.1;

private _interval = 1;

while {triggerActivated _trg} do {

_obj setDamage (damage _obj + _dDamage);

sleep _interval;

} ;

} ;

  • Like 1

Share this post


Link to post
Share on other sites

You should precise if you are scripting for MP (I'd rather script a pure local trigger, without links with other PCs, see alternate syntax of createTrigger).

Say if AIs are concerned

Say if you want to regain health in case of exit from the area. (thisTrigger doesn't work on deact. field).

Share this post


Link to post
Share on other sites

Hello,

 

I found this topic while searching for a script that would work for my mission. I'm trying to create an area which would make any infantry unit take 0.1 damage every second if the unit stays inside the area. If the unit leaves the area they should stop taking damage. This should apply to ALL infantry units (including but not limited to players) in my MP mission.

 

I think I managed to make mrcurry's script posted above work for player controlled units using a trigger with my specified area size and "Any Player" activation, and setting the trigger as repeatable. However, I cannot seem to be able to make this work for AI units. I'm just not good enough at scripting. Any idea how I might do that? And to make it even more complex, how can I make the trigger activate for only units that are on foot (i.e., not in any vehicle)?

 

p.s. Sorry for the necro.

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×