Jump to content

Recommended Posts

This script allows mission maker to create Trees with sniper nests in them.

Sniper-Nest.jpg

 

Features:

  • Create tree with camouflaged platform in it.  Optionally create sniper on platform.
  • Platform accessible to AI and players.
  • AI and player can climb up tree, climb down tree, or fast rope down tree.
  • AI can climb/fastrope via calls in Waypoints
  • Player's AI team members can be commanded to climb up/down and use fast rope.

 

Download: Demo Mission

 

Usage Notes:  The init.sqf contains example calls for how to create trees, and what calls to put in waypoints so AI can climb or fastrope.

 

  • Like 14
  • Thanks 4

Share this post


Link to post
Share on other sites

Treemendous. 😎

  • Like 1
  • Haha 4

Share this post


Link to post
Share on other sites

I always joke about putting shooters in trees in my missions.


I have a "Fighting in Woods and Forests" mission queued up.

Time for a quick edit I think.

Afterwards - I'll send 30 angry dead people your way, @johnnyboy!

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites
4 hours ago, major-stiffy said:

Cool concept. This guy just came out with one too.

 

 

Hadn't seen that.  The list of features he has later in the video is far greater than mine, as it works on many different trees.  Mine is hardcoded for  one tree type.  I'm impressed with Rick's solution.  I tried attaching pallets directly to existing trees, but it went bonkers because trees move in the wind.  I'm guessing he just placed the pallet unattached near center of tree, so not affected by tree movement.  In my case I create a new tree simple object that does not sway in the wind.

 

The only advantage I can see with my script is that I hand picked a more realistic looking place for the pallet to rest on tree limbs, so it does not have a tree trunk clipping through it (and I added a fern to camouflage it).  Plus AI can use my tree.

  • Like 2

Share this post


Link to post
Share on other sites

The AI snipers, when they're in the tree, do they actually shoot with real effect?

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, Tankbuster said:

The AI snipers, when they're in the tree, do they actually shoot with real effect?

As long as they have LOS and know about the target, they will shoot like any other AI.  They just won't move, until commanded or scripted to exit tree.

  • Like 1

Share this post


Link to post
Share on other sites

Obviously this will become my go-to retreat from the ravaging hordes...

rbtjrD9.jpg

...awesome script man, thanks for sharing it.

  • Like 4

Share this post


Link to post
Share on other sites
7 minutes ago, EO said:

Obviously this will become my go-to retreat from the ravaging hordes...

Awesome shot dude.  I can hear the rustling and growling down below, and a faint raspy murmur of "I can smell your brains"...

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites

Just Wow! The king is back!

 

Such an amazing script @johnnyboy!

 

Not only it is good but also very very inspiring!

  • Thanks 1

Share this post


Link to post
Share on other sites

Could you make this a mod ,please? Some are no good with script.....Also,you could import and place trees?

Share this post


Link to post
Share on other sites
18 minutes ago, john111 said:

Could you make this a mod ,please? Some are no good with script.....Also,you could import and place trees?

Sorry man, I don't do mods.  But you can use the sample mission to see how to place trees in your own missions.

  • Like 1

Share this post


Link to post
Share on other sites

When did this come out?! You little bugger! The fact that AI can use it makes it supreme

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
21 minutes ago, froggyluv said:

When did this come out?! You little bugger! The fact that AI can use it makes it supreme

I just put it out a few days ago, but its been sitting on my hard drive for a year or two.  I make scripts for a particular mission, then never finish the mission and forget about them.  I have a few more oldies to package up and release also...anybody interested in Bang Sticks or Piranhas?  😈

  • Like 3
  • Haha 3

Share this post


Link to post
Share on other sites

Jboy I am trying to incorporate this on a dedicated sever mission with various playable units from different teams Blufor, Opfor, & Independent ....PVP. Everything shows up though when a player walks up to a tree they can't climb up it. The prompt to climb the tree shows but the player does not climb the tree. Any ideas....Please help I would love to add this to our server.

 

Great script bye the way.

Share this post


Link to post
Share on other sites
17 hours ago, Antman2o1o said:

Jboy I am trying to incorporate this on a dedicated sever mission with various playable units from different teams Blufor, Opfor, & Independent ....PVP. Everything shows up though when a player walks up to a tree they can't climb up it. The prompt to climb the tree shows but the player does not climb the tree. Any ideas....Please help I would love to add this to our server.

Hey Antman, thanks for your interest.  Unfortunately, I lack knowledge in solving MP issues, and its also hard for me to test for.

 

Are there any skilled MP scripters who could take look at this?  @LSValmont perhaps?  Or do you know someone Antman?

 

This is the while loop that creates the AddAction for a unit or player when they are a near a tree.  Antman says a player in MP will get the action, but when they execute it nothing happens, so I'm guessing the problem is not here in the Add Action code.

Spoiler

 


    while {damage _tree < 1} do
    {
        sleep 1;
        private _nearDudes = [];
        _nearDudes = nearestObjects [getposatl _tree, ["Man"],15];
        {
            _dude = _x;
            _hasClimbAction = _dude getVariable "hasClimbAction";
            
            if (isNil "_hasClimbAction") then
            {
                _hasClimbAction = "no";
                _dude setVariable ["hasClimbAction", "no", true];
            };
            if (alive _dude and getposatl _dude select 2 < .3 and (_hasClimbAction == "no" or _hasClimbAction == "") and (_dude distance2d _tree) < 8) then 
            {
                _treeProxy setVariable ["climbers",(_treeProxy getVariable "climbers")+[_dude],true];
                _dude setVariable ["hasClimbAction","yes",true];
                _dude setVariable ["nearTreeProxy",_treeProxy,true];
 
                _actionTitle = 'Climb up tree';
                if (!isPlayer _dude) then 
                {
                    _actionTitle = (name _dude)+'('+ str(_dude call getUnitPositionId) + '): Climb up tree';
                };   

                _climbUpActionID = _dude addAction 
                   [_actionTitle, 
                    {
                        _dude = _this select 0;
                        _id = _this select 2;
                        _tree = _this select 3 select 0;
                        _pallet = _this select 3 select 1;
                        _dude removeAction (_dude getVariable "ClimbUpActionID");
                        private _pos = getPosASLVisual _tree;
                        _d = [_dude,_pallet,_tree] execvm "JBOY\JBOY_climbUp.sqf";
                    }, 
                    [_tree,_pallet], 10, true, true, '', '',
                    5, false
                ];   
                _dude setVariable["ClimbUpActionID",_climbUpActionID,true];                
            } else
            {
                if ( !alive _dude or
                    (_dude in (_treeProxy getVariable "climbers") 
                    and _hasClimbAction == "yes" 
                    and ((_dude distance2d _tree) > 8 or getposatl _dude select 2 > .3))) then
                {
                    _dude removeAction (_dude getVariable "ClimbUpActionID");
                    if ( !alive _dude) then {removeAllActions _dude;};
                     _dude setVariable ["hasClimbAction", "no", true];
                    _treeProxy setVariable ["climbers",(_treeProxy getVariable "climbers")-[_dude],true];
                };
            };
        } foreach _nearDudes;
    };

 

Here is the JBOY_climbUp.sqf script called by the action added above.  Antman says nothing happens when a player executes this action in MP.  But it works for a player and AI in SP.

Spoiler

// JBOY_climbUp.sqf
/*
 _treeProxy = _dude getVariable "nearTreeProxy";
 _tree = _treeProxy getVariable "tree";
 _pallet = _treeProxy getVariable "pallet";
 _d = [player,_pallet,_tree] execvm "JBOY\JBOY_climbUp.sqf";
 */
if (!isServer)  exitwith {};
params["_dude","_pallet","_tree"];
//systemchat format ["%1",_this];
_dude setVariable ["hasClimbAction","",true]; // 
_treeProxy = (missionNameSpace getVariable "jboySniperTreeProxies") select ((missionNameSpace getVariable "jboySniperTrees") find _tree);
_treeProxy setVariable["climber",_dude,true];
sleep 1;
_dude enableCollisionWith _tree;
_dude enableCollisionWith _tree;

_ropeBottomObj = _treeProxy getVariable "ropeBottomObj";
_pos = ([_ropeBottomObj, 1.5, ([_ropeBottomObj,_tree] call BIS_fnc_dirTo)+30] call BIS_fnc_relPos);
_pos = [_pos select 0, _pos select 1, 0];
_dude setpos _pos;

//_dude switchMove (selectRandom ["ladderciviluploop","ladderrifleuploop"]);
[_dude, (selectRandom ["ladderciviluploop","ladderrifleuploop"])] remoteExec ["switchMove", 0];

_dude setdir (([_ropeBottomObj, _tree] call BIS_fnc_dirTo));

_pos1 = getPosASL _dude;
_pos2 = _pos1 vectorAdd [0,0,0.75];
_dude setVariable ["jboyTreeProxy", _treeProxy, true];
_dude setVariable ["jboyClimbPos1", _pos1, true];
_dude setVariable ["jboyClimbPos2", _pos2, true];
_dude setVariable ["jboyClimbVectorDir", vectorDir _dude, true];
_dude addEventHandler ["AnimDone", 
{
    _dude = _this select 0;
    _pos2 = _dude getVariable "jboyClimbPos2";
	_pos1 = _pos2; 
	_pos2 = _pos2 vectorAdd [0,0,0.75];
    _dude setVariable ["jboyClimbPos1", _pos1, true];
    _dude setVariable ["jboyClimbPos2", _pos2, true];
}];
_dude setVariable ["jboyDismountObj", _pallet, true];

fnc_jboyAddMissionEventHandler = {
    params ["_args","_fnc"];
    private _thisEventHandler = addMissionEventHandler [
        'EachFrame',
        format [
            '_thisEventHandler call %1',
            _fnc
        ]
    ];
    missionNamespace setVariable ["ncb_gv_ehIdArgs_" + (_thisEventHandler toFixed 0),_args];
    _thisEventHandler
};

fnc_jboyClimbUpEH = {
    // the var is an array that is passed immediately to params
    missionNamespace getVariable ("ncb_gv_ehIdArgs_" + (_thisEventHandler toFixed 0)) params ["_dude","_pallet"];
    _vectorDir =  _dude getVariable "jboyClimbVectorDir";
	if (!alive _dude) then 
	{
		_dude switchMove "";
        detach _dude;
		_dude removeAllEventHandlers "AnimDone";
        removeMissionEventHandler ["EachFrame",_this];
	};
	_treeProxy = _dude getVariable "jboyTreeProxy";
	_pallet = _treeProxy getVariable "pallet";
	_climbHeight = getposatl _pallet select 2; // 23.5
    if (( getposatl _dude select 2)< _climbHeight) then
    {
        _pos1 = _dude getVariable "jboyClimbPos1";
        _pos2 = _dude getVariable "jboyClimbPos2";
        
        //_tree = _treeProxy getVariable "tree";

        _dude setVelocityTransformation 
        [
            _pos1, 
            _pos2, 
            [0,0,5], // current velocity
            [0,0,5], // next velocity
            _vectorDir, //[0,1,0], 
            _vectorDir, //[0,1,0], 
            [0,0,1], 
            [0,0,1],
            moveTime _dude
        ];
    } else
    {
        _dude removeAllEventHandlers "AnimDone";
        removeMissionEventHandler ["EachFrame",_this];
        missionNamespace setVariable ["ncb_gv_ehIdArgs_" + (_thisEventHandler toFixed 0),nil];
        _dude switchMove "";
        _man = (nearestObjects [_pallet, ["Man"], 5]) select 0; 
        _man enableCollisionWith _dude;
        _dude setpos [getpos _pallet select 0, getpos _pallet select 1, (getpos _pallet select 2) +.1];
        _dude attachTo [_pallet,[0,.2,.1]];
		_dude forceSpeed 0;
        detach _dude;
        _d = [_dude] execvm "JBOY\JBOY_climbDownAddAction.sqf";
        _d = [_dude] execvm "JBOY\JBOY_ropeDownAddAction.sqf";
     };
};
_id = [[_dude,_pallet],"fnc_jboyClimbUpEH"] call fnc_jboyAddMissionEventHandler;

 

 

Share this post


Link to post
Share on other sites
On 6/10/2020 at 7:36 AM, Antman2o1o said:

Jboy I am trying to incorporate this on a dedicated sever mission with various playable units from different teams Blufor, Opfor, & Independent ....PVP. Everything shows up though when a player walks up to a tree they can't climb up it. The prompt to climb the tree shows but the player does not climb the tree. Any ideas....Please help I would love to add this to our server.

 

Great script bye the way.

Have you looked at the trees using Zeus? What I notice on dedicated server sometimes the platform spawns at 0,0,0 instead of on top of the tree.

Share this post


Link to post
Share on other sites
3 hours ago, MK84 said:

Have you looked at the trees using Zeus? What I notice on dedicated server sometimes the platform spawns at 0,0,0 instead of on top of the tree.

thx, that could explain Antman's experience:  Player chooses climb action, script runs, but completes immediately because player already at same height as platform (which is not on tree).  Will investigate (can't promise how soon though).

  • Like 1

Share this post


Link to post
Share on other sites

I looked at the script and it is too complex for remoteExec.

Should be moved to a fnc compiled on both client and server and only then it is feasible to make it 100% MP compatible.

  • Like 1

Share this post


Link to post
Share on other sites

Guys thanks for the response I am just not skilled enough to convert it into a function.

Its a great script maybe someone can take lead here.

Share this post


Link to post
Share on other sites
5 hours ago, LSValmont said:

I looked at the script and it is too complex for remoteExec.

Should be moved to a fnc compiled on both client and server and only then it is feasible to make it 100% MP compatible.

Thanks for advice.  Is it just the Climb function that needs compiling?

 

And how do I compile it both on client and server?

 

And where should the function be executed...both client and server?

Share this post


Link to post
Share on other sites
7 hours ago, johnnyboy said:

Thanks for advice.  Is it just the Climb function that needs compiling?

 

And how do I compile it both on client and server?

 

And where should the function be executed...both client and server?

 

Everything related to Ai should probably be compiled and executed via remote or whatnot on the server only while anything related to the player should be run locally.

 

It is a good habit to do fnc for the players and for the Ai separately. For example I have a fnc called: "vAiRearm" and another "vRearm" for players.

 

For single player you can just compile everything in the init.sqf file.

 

But for MP optimization you want to compile server fnc in the initServer.sqf file and the client stuff on the initPlayerLocal.sqf.

 

While MP optimization takes a little more work once you get used to it you only need to do things once and get compatibility for any scenario.

 

You started scripting for SP and I started scripting for MP so don't worry, we will meet each other halfway 😉 

  • Like 3
  • Thanks 1

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

×