Jump to content
3l0ckad3

need help with distance2D from player to op4

Recommended Posts

In a nutshell, I have created,, a,,,,,, thing, where I can sneak up behind an enemy unit and snap his neck, it works, however, I rather more conditions pertain to distance to victim in distance2D, I also have other functions in place like dragging and hiding the body, and ai detecting dead bodies.
Where I think I need to go, is count enemies in < 20 radius on a loop for a condition to be meet, then the player must be going <4.2, and, the player must be crouching.

I'm well aware that the temporary trigger is already defining the radius, however, as I develop it further I'd like to remove the trigger so it is more versatile with bigger missions, where I do not want a million triggers running frame by frame, so, instead of defining each unit, and attaching a trigger to each unit, I can run it by side if that makes sense, and, when the victim dies he will no longer be counted, and the latter part of the script can temporarily terminate  the blocks needed to return back to a normal state.

 

I'm not afraid to do some reading, been doing it all day, so even if you just point me to some resources that would be great, or, if you think I'm headed in the wrong direction give me an earful,, I have no clue what I'm doing for the most part.


This is what I got so far...

 

silentAssailant.sqf



if (
   stance player == "CROUCH"
&&
   (
   speed player < 4.2)
) then {

   player setCaptive true;                     //only for testing, will be removed
   player setUnitTrait ["camouflageCoef",0.1];
   player setUnitTrait ["audibleCoef",0.1];
   Hint "script exit";
};


/*

while {true} do {                            //used this to get the speed I was after.
   speedvar = speed player;
   player sideChat str speedvar;
   sleep 0.001;
};

if (
  (side _x == east)                          //where I think I need to go with this, just unsure how to go about it.
   player distance objectOfInterest < 20
   ) then {

*/











initServer.sqf

 

if (isServer) then {


/* --- get stance, speed, (count op units) (distance) run block--- */

_vic1trg = createTrigger ["EmptyDetector", position vic1, true];   //spawns on victim
_vic1trg   setVariable ["victr", _this];                          
_vic1trg   attachTo [ vic1,[0,0,0]];                               // attaches Trigger to victim
_vic1trg   setTriggerArea [5, 5, 3, false];                        // temp radius
_vic1trg   setTriggerType "NONE";
_vic1trg   setTriggerActivation ["WEST", "PRESENT", true];
_vic1trg   setTriggerStatements [
"player in thisList", "0 = execVM 'silentAssailant.sqf';hint 'script exe'", ""];


};



------------------------ EDIT----------------------
Added more to it
 


sleep 33;

if (
     !alive vic1
) then {
     deleteVehicle vic1;
sleep 3;     
     Player setCaptive false;
     player setUnitTrait ["camouflageCoef",0.2];
     player setUnitTrait ["audibleCoef",0.3];
     hintC "back to normal"
};

And apparently, I just grew a brain, I could attach the trigger to myself, and set it to op4 present.. 

Share this post


Link to post
Share on other sites

I’m thinking and addAction added to the player checking the side of the cursorTarget of the player (along with all your other conditions, distance/speed/stance/etc) would be more efficient. I’m on my phone or else I would throw up an example, but it’s a concept.

  • Like 1

Share this post


Link to post
Share on other sites

Thnx J, I'll google, but if you could drop me a lil snip later from which to grasp, I'd be very appreciative.
I think I found a bit of a work around to this idea, but I'm not sure how taxing it will be.

Cheers.

 

Share this post


Link to post
Share on other sites


player addAction

[

     “Sneak Attack”,

     {

            params [“”, ””, ””, [“_unit”,objNull,[objNull]];

            if (isNull _unit) exitWith {};

            [_unit] execVM “myscript.sqf”;

     },

     [cursorTarget],

     1.5,

     true,

     true,

     “”,

     “cursorTarget isKindOf “Man” && alive cursorTarget && *sideCheck* && *distanceCheck* && *stancePlayerCheck* && *speedPlayerCheck*”

];

 

Something like this replace necessary conditions/script path/name etc. Rough outline at least.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you a ton J, couldn't ask for anything more, I was goofing around with a param array earlier, but you put that to shame lol
Cheers!

Share this post


Link to post
Share on other sites

Just realized a mistake on my part, param for _unit should be: [“_args”, [],[[]]]

 

and you would: _args params [“_unit”] under the original params line

  • Like 1

Share this post


Link to post
Share on other sites

I was just eating and trying to wrap my head around it lol 

Good thing you caught it, I would have tried to make sense of it for ever lol

Now, objnull, is that a placeholder for an object that is absent ? Like, a player that is offline, but could come back type deal ? 

 

1.5 I'm assuming is the distance the action will show, however, what are the two boolean placements ? 

Share this post


Link to post
Share on other sites

objNull (in the param array) is the default value that overrides in case an empty argument array is passed in, it’s a robustness thing, and yes can be a placeholder for an absent object, gives us something to check against. 

 

The 1.5 is the priority of the action. The higher that value, the higher in the list of actions it will be when you scroll wheel.

 

See addAction for all the details on what’s what.

  • Like 1

Share this post


Link to post
Share on other sites

params wiki entry:

Quote

[variableName, defaultValue, expectedDataTypes]

defaultValue: Anything - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).

expectedDataTypes (Optional):  Array of direct Data Types - checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted.

 

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

×