Jump to content
Sign in to follow this  
cds1984

soldier(player) colliding with solid object damage

Recommended Posts

Hi,

Recently I created a map which plays at night, the AI don't have NVG and neither do the players.

They do all have torches, so it is pretty novel but the one thing that I would like to be able to create is damage to units from running head long into a building, rock face, vehicle or whatever else that would really knock the wind out of you if you did actually run into it (in real life i mean). If i ran into a rock face I'd probably end up in the hospital... I'm thinking. (in real life that is)

In a pitch dark map you find that if you fire or flip on your torch it gives away your position and thus the old, flip it on look and flip it off and walk, crawl or run in that direction and what you end up with is, walking or running into an object and in the pitch black there is absolutely no feedback visually or aurally to the player, so you just walk or run against whatever you ended up against with no idea until you flip the ole torch back on.

Have you ever been running along and popped on the map to check your location then turned the map off to see that you've been running against a tree? Having the map drop suddenly to the floor and you end up on your backside would make more sense.

So...

What I would like to do, like when you walk off a ledge or crash a vehicle into a solid object, is get some visual feedback on the screen, like the surrounding red pain fog or the audible yelp of the player... (OOOF sounds appropriate to me)

So far I've run into an issue that I can't resolve properly/simply the walls of a building or any direct class of a solid object that I might run into, so if I run into the side of a building that is around 5m to its centre, this will work (setting the condition to detect a distance of less than 10 from the building... which is very arbritary but a way to make this script work at this point!).

private ["_moving","_speed","_previous","_sample","_distance"];
_moving = false;
_previous = 0;
_sample = 0.1;
while {isPlayer player} do
{
 _speed = speed player;
 if (_speed != _previous) then
 {
   if (_moving) then
   {
     if ((_previous < 0 && _speed > 0) || (_previous > 0 && _speed < 0)) then
     {
       _distance = position player distance position (nearestBuilding position player);
       _moving = false;
       _previous = 0;
       if (_distance < 10) then
       { 
         addcamshake [10,0.5,5];
         playsound3D ["A3\Sounds_F\characters\human-sfx\Person0\P0_hit_03.wss", player,false,getPosASL player,0.8,1,0];
       };
     }
     else
     {
       _previous = _speed;
     };
   }
   else
   {
     _moving = true;
     _previous = _speed;
   };
 }
 else
 {
   if (_speed != 0) then
   {
     _previous = _speed;
     _moving = true;
   };
 };
 sleep _sample;
};

I wanted to just use classes as a condition egs. nearestObjects [player, ["House","Car","Fence","Tank"],0.5] but I think the same issue arises that the bits on the house aren't in the class "House", just the bit in the middle so I end up with needing to find the size of the House and see where the player is in comparison or have a function that gives me an array of objects attached to or makeup the house that I can cycle through to see if im splattered against one of them.

Maybe it's built in somewhere already? and I can't find the function? Vibration feedback on my desk would work a charm too of course but... maybe later.

Thanks for reading my ramblings, and for any suggestions about a function that is already implemented or how to detect the object that I've run into correctly would be GREAT!

Share this post


Link to post
Share on other sites

Hey guys. i know this isnt in the discussion of your thread, but i cannot find a thread to relate to this. so to get it out there. i just need some quick help, im using the high command module/subordinate command module to implement it into my game. however whenever i preveiw the mission it gives me command of every unit in the base, for example when the game starts i want to simply be the commander of three tasks forces. i linked it all up the right way, but when i drop a BLUFOR site (base) all of the spawned units are also under my command even though i never linked them to it. if you all could give me some help id greatly appreciate it!... if you want (may be against the rules. if so let me know it wont happen again) but email me a response at howardfish at live(dot)com ill be able to get the info faster! thanks!

Share this post


Link to post
Share on other sites
Hey guys. i know this isnt in the discussion of your thread, but i cannot find a thread to relate to this. so to get it out there. i just need some quick help, im using the high command module/subordinate command module to implement it into my game. however whenever i preveiw the mission it gives me command of every unit in the base, for example when the game starts i want to simply be the commander of three tasks forces. i linked it all up the right way, but when i drop a BLUFOR site (base) all of the spawned units are also under my command even though i never linked them to it. if you all could give me some help id greatly appreciate it!... if you want (may be against the rules. if so let me know it wont happen again) but email me a response at howardfish at live(dot)com ill be able to get the info faster! thanks!

Unspoken rule #1, never hijack a thread.

Stated BI Forum Rule #7, search before posting, I searched High Command as a thread title in the Mission Editing and Scripting Forum and came up with 11 threads.

I see you are new, and there is a period in which you cannot create a new thread, but being patient and posting where you need to post is your best bet to not get in trouble.

To help you out a bit:

There is a BIKI page you can reference to make sure your setting everything up properly.

Jester814 also has a

that may help you out as well.

Share this post


Link to post
Share on other sites

Aww man! and here I was getting all excited about someone with all the answers getting back to me! *sigh*

Share this post


Link to post
Share on other sites

Hmm. Never tried, so don't know, how far this could take you, but closest to your need, that came to my mind are "Epe" event handlers. I can't recall anything else giving any real hope maybe except constant LOS checks ahead of you to determine how far unit is from the next object, that blocks LOS, thus an obstacle (but also "soft", like a bush). IIRC there was a mod in A2 for detection, if weapon held by a player is so close to the wall, so should be lowered.

Rest is about distance checks of boundingBoxes - all highly inaccurate.

Share this post


Link to post
Share on other sites

I don't think the Epe eventhandlers will be of much use in this case.

Like Rydygier said, your best bet is to do LOS checks.

Intersects, to be precise.

Combine that with a minimum speed and include the velocity vector into the check and you might be able to get it working.

Make sure you dont just check "ahead of you", use the velocity vetor.

Oh and don't rely on boundingboxes, they're too inaccurate.

Share this post


Link to post
Share on other sites

ahh for a simple answer!

Thanks for the help.

I will grind on, now that I've started I feel like it's necessary for the ARMA3 experience to be more complete.

if I come up with THE answer or AN answer I'll post it on the thread, of course.

Share this post


Link to post
Share on other sites

After realising that what I was looking for "an array of objects attached to the building" was something I was completely on the wrong track about and looking into the boundingBoxReal function (after the suggestion, Thanks!) I've ended up with this.

Testing distance to the building against the larger of the 2 dimensions (width or length) it kinda gets a closer approximation of 'yes you are against a wall of a building when you came to a sudden stop'.

Now... to tweak the 'you've come to a sudden stop' to take vector into consideration... since turning on the spot is starting and stopping also.

private ["_moving","_speed","_previous","_sample","_building","_dimensions","_width","_length","_distance"];
_moving = false;
_previous = 0;
_sample = 0.1;
while {isPlayer player} do
{
 _speed = speed player;
 if (_speed != _previous) then
 {
   if (_moving) then
   {
     if ((_previous < 0 && _speed > 0) || (_previous > 0 && _speed < 0)) then
     {
       _building = nearestBuilding position player;
       _dimensions = boundingBoxReal _building;
       _width = ((_dimensions select 1) select 0) - ((_dimensions select 0) select 0);
       _length = ((_dimensions select 1) select 1) - ((_dimensions select 0) select 1);
       _distance = position player distance position _building;
       _moving = false;
       _previous = 0;
       /*hint format ["%1 %2d %3w %4l",_building,_distance,_width,_length];*/
       if (_distance < (_width max _length)) then
       { 
         addcamshake [10,0.5,5];
         playsound3D ["A3\Sounds_F\characters\human-sfx\Person0\P0_hit_03.wss", player,false,getPosASL player,0.8,1,0];
       };
     }
     else
     {
       _previous = _speed;
     };
   }
   else
   {
     _moving = true;
     _previous = _speed;
   };
 }
 else
 {
   if (_speed != 0) then
   {
     _previous = _speed;
     _moving = true;
   };
 };
 sleep _sample;
};

---------- Post added at 05:14 ---------- Previous post was at 04:34 ----------

Optimised the script and added a delay after a true condition plus added the collision speed to the test condition. Hinky... but getting closer (when running into a building, not so much the rocks, vehicles and anything else hard but... onward!)

private ["_moving","_speed","_previous","_sample","_building","_dimensions","_width","_length","_distance","_delay","_damageSpeed"];
_moving = false;
_previous = 0;
_sample = 0.1;
_delay = 1;
_damageSpeed = 5;
while {isPlayer player} do
{
 _speed = speed player;
 if (_speed != _previous) then
 {
   if (_moving) then
   {
     if ((_previous < 0 && _speed > 0) || (_previous > 0 && _speed < 0)) then
     {
       _building = nearestBuilding position player;
       _dimensions = boundingBoxReal _building;
       _width = abs (((_dimensions select 1) select 0) - ((_dimensions select 0) select 0));
       _length = abs (((_dimensions select 1) select 1) - ((_dimensions select 0) select 1));
       _distance = position player distance position _building;
       _moving = false;
       /*hint format ["%1prev %2curr",_previous, _speed];*/
       /*hint format ["%1 %2d %3w %4l",_building,_distance,_width,_length];*/
       if (_distance < (_width max _length) && _previous >= _damageSpeed) then
       { 
         addcamshake [10,0.5,5];
         playsound3D ["A3\Sounds_F\characters\human-sfx\Person0\P0_hit_03.wss", player,false,getPosASL player,0.8,1,0];
         sleep _delay;
       };
     };
   }
   else
   {
     _moving = true;
   };
 }
 else
 {
   if (_speed != 0) then
   {
     _moving = true;
   };
 };
 sleep _sample;
 _previous = _speed;
};

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
Sign in to follow this  

×