Jump to content
wyattwic

Detect if player is standing in smoke

Recommended Posts

Hello!

 

I have been having a hard time finding a way to detect if a player is standing within a particle effect, such as smoke.

 

I am trying to make a "Nerve gas" script where if a player steps into a specific color smoke grenade he begins to take damage and spaz out.

While I can easily detect if the player is standing near the smoke grenade, I am interested if they are standing within the smoke emitted.  Can anyone point me in the right direction?

Share this post


Link to post
Share on other sites
1 hour ago, killzone_kid said:

You can get position of a particle in onTimer script in particle array

 

 

Thanks @killzone_kid

 

Unfortunately I am somewhat dense in this subject.  The grenade being used is tossed by another player instead of being made via the drop command.  While I know how to create a particle, I am unsure how to do this with a thrown object.

 

EDIT:  I noticed I have not been very descriptive.

 

Player A tosses Yellow Smoke Grenade near Players B.

Player B is in contact with the particles and code is executed.

Share this post


Link to post
Share on other sites

so you want to use the default yellow grenade in the game and script the gas behavior?

 

or do you want to make a gas grenade addon?

 

this question is important because doing it via script only without an addon will limit the ways you can achieve this a lot.

Share this post


Link to post
Share on other sites

You could detect smoke grenade position, and then affect players who are near the grenade.  If you want to get real fancy, then you take wind direction into account.

 

For detecting gas grenade, put a fired eventhandler on the gas grenade thrower.  Code in the eventhandler would find smoke grenade object thrown, and call a script that lives as long as the smoke grenade is producing smoke (you could set this time as a number of seconds).  Loop to detect any players or ai near smoke grenade, and execute your spazzOut script on them.

 

BTW, I like the idea of the gas grenade and spazzOut script, so please post your solution when its done.

Share this post


Link to post
Share on other sites
4 hours ago, bad benson said:

so you want to use the default yellow grenade in the game and script the gas behavior?

 

or do you want to make a gas grenade addon?

 

this question is important because doing it via script only without an addon will limit the ways you can achieve this a lot.

 

BadBenson, I am trying to do this without an addon, using the generic YellowSmoke thrown by a player.

 

2 hours ago, johnnyboy said:

You could detect smoke grenade position, and then affect players who are near the grenade.  If you want to get real fancy, then you take wind direction into account.

 

For detecting gas grenade, put a fired eventhandler on the gas grenade thrower.  Code in the eventhandler would find smoke grenade object thrown, and call a script that lives as long as the smoke grenade is producing smoke (you could set this time as a number of seconds).  Loop to detect any players or ai near smoke grenade, and execute your spazzOut script on them.

 

BTW, I like the idea of the gas grenade and spazzOut script, so please post your solution when its done.

 

Johnnyboy,  I know how to do it based on the nades position but I was hoping to use the particles for detection, espically since I have noticed it moves differently in houses.  My number one complaint about my current implementation of the code is that a player was effected but not "in" the smoke.

 

When it comes to the code that does the damage, I have a draft of it.  As soon as I get it cleaned up and 100% working I will release it! :)

  • Like 1

Share this post


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

Johnnyboy,  I know how to do it based on the nades position but I was hoping to use the particles for detection, espically since I have noticed it moves differently in houses.  My number one complaint about my current implementation of the code is that a player was effected but not "in" the smoke.

Detecting particles sounds ideal.  But if that doesn't work out, I think you could approximate it based on:

  • smoke grenade position
  • Wind direction
  • Wind speed
  • Duration (small cone of smoke grows and drifts over time, then fades away)

You could then calculate a "cone" zone where smoke is likely to be.  To test you could create helper object spheres in your calculated cone zone to see if they line up visually with where the smoke is.

Share this post


Link to post
Share on other sites

i think it would be better to use a chemlight and spawn your own particle on it. then you can do what KK suggested.

  • Like 2

Share this post


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

i think it would be better to use a chemlight and spawn your own particle on it. then you can do what KK suggested.

That's a good idea.  You are then in control of the smoke particles, and can track their positions.  You could potentially still use a smoke grenade (if you like the look better than the chemlight), but replace it after it lands with a static one using a weaponHolder.  Then make your own smoke on that position.

  • Like 2

Share this post


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

That's a good idea.  You are then in control of the smoke particles, and can track their positions.  You could potentially still use a smoke grenade (if you like the look better than the chemlight), but replace it after it lands with a static one using a weaponHolder.  Then make your own smoke on that position.

 

Okay, sounds like a plan.

 

I'll look up a smoke grenade's config and see what settings it uses to create the effect, since the current particle spread is what I need.

 

Since this is the first time I am really messing with particles, I dont fully understand KK's suggestion.  Can someone elaborate for me?

Share this post


Link to post
Share on other sites

Now that I think about it, regarding " You are then in control of the smoke particles, and can track their positions. "...I don't know for sure if you can track the particle positions or not.  I've always had a weak understanding of particles and Drop command (although I have used it a few times).  Good luck.

Share this post


Link to post
Share on other sites

 getting the particles to behave exactly like in the config can sometimes be tricky because the config uses some engine stuff. but not always i think. i always wanted to make a tool that can convert particles back and forth between config and script format so one could make a particle editor that can basically export to config. but it's a lot of work and so far i didn't have a project where particles are a big part.

 

you can definately get close enoguh though.

 

 



https://community.bistudio.com/wiki/ParticleArray

 

look for the "onTimerScript" parameter in the example. i think you put an sqf file there similar to execVM.

 

on the bottom the parameter is described like this:

OnTimer - Name of the script to run every period determined by TimerPeriod property.

Position of the particle is stored in "this" variable. 

by the looks of it "drop" will take the same parameters almost

https://community.bistudio.com/wiki/drop

Share this post


Link to post
Share on other sites

I wish BI would give us a command to spawn a CE ( Complex particle Effect ). As Benson says you can get close by looking at the CE and then look at the setting of each PE ( Particle Effect ) it creates, but not a perfect match, as Benson says some use engine parameters that we dont have access to/ dont make sense from an outside perspective.

Share this post


Link to post
Share on other sites

Did anyone ever build a scripted solution for detecting if a unit is within a smoke cloud?  

 

I and others offered some ideas on this thread a long time ago, but they all require some work.  I wonder if anyone has made a clean solution for this since then, or has a fresh simple idea for it.  

Share this post


Link to post
Share on other sites
48 minutes ago, johnnyboy said:

Did anyone ever build a scripted solution for detecting if a unit is within a smoke cloud?  

 

I and others offered some ideas on this thread a long time ago, but they all require some work.  I wonder if anyone has made a clean solution for this since then, or has a fresh simple idea for it.  


Particle smoke is a flat texture that is always perpendicular to the viewer, i.e. you. So technically object is never "inside the smoke"

 

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

×