Jump to content
Freddywall

Damage player outside trigger

Recommended Posts

Hello,

 

place trigger, add Variable Name.

In Trigger: Activation

Type: None
Activation: Any Player
Activation Type: Not Present
Repeatable: Yes

In trigger Condition: this

In On activation: player setDammage 1

or use a value between 0.1-0.9 in the case you don't want to completely kill the player.

Share this post


Link to post
Share on other sites
2 minutes ago, Asmodeuz said:

Hello,

 

place trigger, add Variable Name.

In Trigger: Activation


Type: None
Activation: Any Player
Activation Type: Not Present
Repeatable: Yes

In trigger Condition: this

In On activation: player setDammage 1

or use a value between 0.1-0.9 in the case you don't want to completely kill the player.

How can i make gradual damage while player outside trigger

Share this post


Link to post
Share on other sites

Place a "empty" marker on your map. 

Name its variable name "tag_marker". 

 

In initplayerlocal.sqf, enter this code:

//start of code

//below 3 variables can be used to change the settings of this script :

 

Private _dmg = 0.01; // 0.01 = 1% damage of HP

 

Private _delay = 30; //delay in seconds  between damage

 

Private _dist = 100; //distance from marker where damage ticker starts

///

 

0= [] spawn {

while

{

sleep 3;

_mrkrpos= getmarkerpos "tag_marker" ;

player distance _mrkrpos > _dist

}

do

{

player setdamage (damage player) + _dmg;  

sleep _delay;

} ;

} ;

//end of code

 

Something like that for example. 

Written on handheld, please test and tell me if errors pop up. 

 

Cheers

Vd

  • Thanks 1

Share this post


Link to post
Share on other sites
8 minutes ago, Vandeanson said:

Place a "empty" marker on your map. 

Name its variable name "tag_marker". 

 

In initplayerlocal.sqf, enter this code:

//start of code

//below 3 variables can be used to change the settings of this script :

 

Private _dmg = 0.01; // 0.01 = 1% damage of HP

 

Private _delay = 30; //delay in seconds  between damage

 

Private _dist = 100; //distance from marker where damage ticker starts

///

 

0= [] spawn {

while

{

sleep 3;

_mrkrpos= getmarkerpos "tag_marker" ;

player distance _mrkrpos > _dist

}

do

{

player setdamage (damage player) + _dmg;  

sleep _delay;

} ;

} ;

//end of code

 

Something like that for example. 

Written on handheld, please test and tell me if errors pop up. 

 

Cheers

Vd

https://imgur.com/02T5AHg got this error

Share this post


Link to post
Share on other sites
43 minutes ago, Freddywall said:

How can i make gradual damage while player outside trigger


Continuing from my original suggestion use this in On Activation:
null = [] spawn {while {alive player} do {_dmg = 0.01; player setDamage (damage player) + _dmg; sleep 1;}; };

Change the values in _dmg and sleep to your liking to get the effect you want.

  • Like 1

Share this post


Link to post
Share on other sites
6 minutes ago, Asmodeuz said:


Continuing from my original suggestion use this in On Activation:
null = [] spawn {while {alive player} do {_dmg = 0.01; player setDamage (damage player) + _dmg; sleep 1;}; };

Change the values in _dmg and sleep to your liking to get the effect you want.

how to disable it when i am again goes inside the trigger?

Share this post


Link to post
Share on other sites
1 minute ago, Asmodeuz said:


Continuing from my original suggestion use this in On Activation:
null = [] spawn {while {alive player} do {_dmg = 0.01; player setDamage (damage player) + _dmg; sleep 1;}; };

Change the values in _dmg and sleep to your liking to get the effect you want.

just one thought, in my understanding, this loop will fire - and will the run endlessly until the player is dead. we would need to add a condition to exit the loop if the trigger condition is not met.

I am sure there is a way with triggers - but i am not that familiar with using triggers anymore.

 

 

My code was BS - never code on handheld XD

corrected code (my version)

 

initplayerlocal.sqf:

Spoiler

0= [] spawn {
  Private _dmg = 0.01; // 0.01 = 1% damage of HP
  Private _delay = 30; //delay in seconds  between damage
  Private _dist = 100; //distance from marker where damage ticker starts

  private _mrkrpos = getmarkerpos "tag_marker";
while {sleep 1; alive player}
do
{
waituntil {player distance _mrkrpos > _dist;};
player setdamage (damage player) + _dmg;
sleep _delay;
};
};

 

 

Of course - if you prefer triggers and editor only - asmodeuz version with a exit condition is better.

 

cheers

vd

  • Like 1

Share this post


Link to post
Share on other sites
15 minutes ago, Freddywall said:

how to disable it when i am again goes inside the trigger?


You can terminate the script that you spawn in the On Activation field. See terminate from the Biki

For this change the earlier script a bit, give it a "script handle" which you can then use to terminate the script. For this example we use killPlayer like so
killPlayer = [] spawn {while {alive player} do {_dmg = 0.01; player setDamage (damage player) + _dmg; sleep 1;}; };

 

Then in On Deactivation field use terminate killPlayer;

 

Now the "killPlayer" script will fire every time you step out of the trigger and stop (or "terminate") when you step back inside the trigger area.

  • Like 1

Share this post


Link to post
Share on other sites
14 minutes ago, Vandeanson said:

just one thought, in my understanding, this loop will fire - and will the run endlessly until the player is dead. we would need to add a condition to exit the loop if the trigger condition is not met.

I am sure there is a way with triggers - but i am not that familiar with using triggers anymore.

 

 

My code was BS - never code on handheld XD

corrected code (my version)

 

initplayerlocal.sqf:

  Hide contents


0= [] spawn {
  Private _dmg = 0.01; // 0.01 = 1% damage of HP
  Private _delay = 30; //delay in seconds  between damage
  Private _dist = 100; //distance from marker where damage ticker starts

  private _mrkrpos = getmarkerpos "tag_marker";
while {sleep 1; alive player}
do
{
waituntil {player distance _mrkrpos > _dist;};
player setdamage (damage player) + _dmg;
sleep _delay;
};
};

 

 

Of course - if you prefer triggers and editor only - asmodeuz version with a exit condition is better.

 

cheers

vd

I continue get damage when i am inside the trigger

Share this post


Link to post
Share on other sites

my version must be used with a simple empty marker: F6 -> icons -> system -> empty and name it tag_marker

Share this post


Link to post
Share on other sites
16 hours ago, Vandeanson said:

my version must be used with a simple empty marker: F6 -> icons -> system -> empty and name it tag_marker

How can i make it with ellips? 

Share this post


Link to post
Share on other sites
27 minutes ago, Freddywall said:

How can i make it with ellips? 

We need to change the condition check for that:

 

Name your area marker TAG_marker. 

 

In the code:

Replace 

waituntil {player distance _mrkrpos > _dist ; };

 

With

 

waituntil {!(player inArea "TAG_marker");};

 

Again on handheld and not tested, please send me any errors:) 

 

Not 100% sure if the negation of the condition is correct this way or if its:

 

!inArea

 

Will be able to properly test later this evening. 

Cheers

Vd

Share this post


Link to post
Share on other sites

honestly imo this is one of the better ways of doing it to also allow you more control over what you want. this will add 0.1 damage to each unit that is not inside the trigger every 5 seconds, simply change how much damage you want them to take and the time you want them to take damage. this isnt tested as its just off the head, if its something you want to use and isnt working just respond and ill fix it or walk you through fixing it if your willing to learn.

while {true} do
{
	//get all units that are not in the trigger area
	_outSideUnits = (allUnits select {!(_x inAreaArray triggerName)});
	//loop through the units gathered and increase their damage by 0.1
	{
		_curDamage = damage _x;
		_newDamage = _curDamage + 0.1;
		_x setDamage _newDamage;
	} forEach _outSideUnits;
	Sleep 5;
};

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 9/19/2019 at 9:35 PM, gokitty1199 said:

honestly imo this is one of the better ways of doing it to also allow you more control over what you want. this will add 0.1 damage to each unit that is not inside the trigger every 5 seconds, simply change how much damage you want them to take and the time you want them to take damage. this isnt tested as its just off the head, if its something you want to use and isnt working just respond and ill fix it or walk you through fixing it if your willing to learn.


while {true} do
{
	//get all units that are not in the trigger area
	_outSideUnits = (allUnits select {!(_x inAreaArray triggerName)});
	//loop through the units gathered and increase their damage by 0.1
	{
		_curDamage = damage _x;
		_newDamage = _curDamage + 0.1;
		_x setDamage _newDamage;
	} forEach _outSideUnits;
	Sleep 5;
};

 

seems it's doesn't work. Error in "_outSideUnits = (allUnits select {!(_x inAreaArray triggerName)});"

Share this post


Link to post
Share on other sites
20 minutes ago, Freddywall said:

seems it's doesn't work. I paste it in initlocalplayer.sqf

why would you put it there? this isnt something that should run on every client as it will cause issues, this should only run on the server. it would also help to post what issue you had, i just tested and noticed an issue, i meant to use inArea not inAreaArray. this is tested and working

while {true} do
{
	//get all units that are not in the trigger area
	_outSideUnits = (allUnits select {!(_x inArea triggerName)});
	hint str count _outSideUnits;
	//loop through the units gathered and increase their damage by 0.1
	{
		_curDamage = damage _x;
		hint str _curDamage;
		_newDamage = _curDamage + 0.1;
		_x setDamage _newDamage;
	} forEach _outSideUnits;
	Sleep 5;
};

 

Share this post


Link to post
Share on other sites
25 minutes ago, gokitty1199 said:

why would you put it there? this isnt something that should run on every client as it will cause issues, this should only run on the server. it would also help to post what issue you had, i just tested and noticed an issue, i meant to use inArea not inAreaArray. this is tested and working


while {true} do
{
	//get all units that are not in the trigger area
	_outSideUnits = (allUnits select {!(_x inArea triggerName)});
	hint str count _outSideUnits;
	//loop through the units gathered and increase their damage by 0.1
	{
		_curDamage = damage _x;
		hint str _curDamage;
		_newDamage = _curDamage + 0.1;
		_x setDamage _newDamage;
	} forEach _outSideUnits;
	Sleep 5;
};

 

It works well, thank you

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

×