Jump to content
Sign in to follow this  
WurschtBanane

Delete dismounted vehicle crews

Recommended Posts

Now after the Tanks DLC, am making a pure OPFOR tank mission, meaning no hostile infantry. I made an infinite spawn of enemy tanks. The problem: The infantry that ejects from a disabled tank, often runs away and survives. And it stacks up. And stacks up. And stacks up. And crashes/lags the server.

 

My solution is to make all BLUFOR infantry get detected via an eventhandler, then get the "CARELESS" stat assigned so they dont run around, and then give them a waypoint into a hidden place where players cannot see them, for example the edge of the map. There will be a trigger, which loops and deletes every blufor unit that enters it.

 

 

My question: How do i create an eventhandler (has to work with JIPing players), that gives all Blufor infantry which isnt in a vehicle a waypoint and the CARELESS behaviour.

 

Also, how do i create a black hole trigger, that eats blufor and only blufor? Just putting in "BLUFOR present" and making it repeatable might not work, as it might get stuck due to blufor still being present and not reactivating the trigger.

Share this post


Link to post
Share on other sites
19 minutes ago, WurschtBanane said:

My solution is to make all BLUFOR infantry get detected via an eventhandler, then get the "CARELESS" stat assigned so they dont run around, and then give them a waypoint into a hidden place where players cannot see them, for example the edge of the map. There will be a trigger, which loops and deletes every blufor unit that enters it.

Why don't you delete them directly on GetOut? Honestly what you want is possible but depending on AI is a bad choice in my experience. It may be cheaper to just make them run somewhere (even better into the nearest forest/village) and check if anyone sees them along the way (I usually do it with line intersects to check if anyone can see them, e.g. for spawning enemies: !(lineIntersects [eyePos player, (AGLToASL spawn_point) vectorAdd [0,0,1], player])).

 

If they left the vehicle more than, say, 1m ago (so you still get some running away inf.) and no player can see them then delete them where they are.

 

Quote

My question: How do i create an eventhandler (has to work with JIPing players), that gives all Blufor infantry which isnt in a vehicle a waypoint and the CARELESS behaviour.

You don't. You create their waypoints on GetOut EH.

 

Quote

Also, how do i create a black hole trigger, that eats blufor and only blufor?

You can but why? Just delete them after they finish their WP with setWaypointStatements.

Share this post


Link to post
Share on other sites
Quote

You don't. You create their waypoints on GetOut EH.

 

Okay, i still need help with that. Do i put an Eventhandler into the init.sqf?

 

Quote

Why don't you delete them directly on GetOut?

I cant, that would be too unauthentic/unimmersive.

Share this post


Link to post
Share on other sites
8 hours ago, WurschtBanane said:

Now after the Tanks DLC, am making a pure OPFOR tank mission, meaning no hostile infantry. I made an infinite spawn of enemy tanks. The problem: The infantry that ejects from a disabled tank, often runs away and survives. And it stacks up. And stacks up. And stacks up. And crashes/lags the server.

 

My solution is to make all BLUFOR infantry get detected via an eventhandler, then get the "CARELESS" stat assigned so they dont run around, and then give them a waypoint into a hidden place where players cannot see them, for example the edge of the map. There will be a trigger, which loops and deletes every blufor unit that enters it.

 

 

My question: How do i create an eventhandler (has to work with JIPing players), that gives all Blufor infantry which isnt in a vehicle a waypoint and the CARELESS behaviour.

 

Also, how do i create a black hole trigger, that eats blufor and only blufor? Just putting in "BLUFOR present" and making it repeatable might not work, as it might get stuck due to blufor still being present and not reactivating the trigger.

 

How many units are we talking about?

You definitely don't want 100+ units moving to a single position.

Just spawn a simple line of sight check, once no player has line of sight delete the infantry:

 


GOM_fnc_crewDelete = {

	params ["_unit"];
	systemchat format ["%1 disembarked!",_unit];

	waitUntil {sleep 1 + random 1;
		{lineIntersects [eyepos _unit,eyepos _x,_unit,_x]} count allPlayers isEqualTo count allPlayers
	};
	systemchat format ["Deleting %1",_unit];
	deletevehicle _unit;


};

vehicles apply {
	_x addEventHandler ["GetOut",{
		params ["_vehicle","_role","_unit"];
		_delete = _unit spawn GOM_fnc_crewDelete;
	}]}

Just adjust the lower part of the snippet to only apply to hostile tanks and you're set.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites
4 hours ago, Grumpy Old Man said:

 



GOM_fnc_crewDelete = {

	params ["_unit"];
	systemchat format ["%1 disembarked!",_unit];

	waitUntil {sleep 1 + random 1;
		{lineIntersects [eyepos _unit,eyepos _x,_unit,_x]} count allPlayers isEqualTo count allPlayers
	};
	systemchat format ["Deleting %1",_unit];
	deletevehicle _unit;


};

vehicles apply {
	_x addEventHandler ["GetOut",{
		params ["_vehicle","_role","_unit"];
		_delete = _unit spawn GOM_fnc_crewDelete;
	}]}

 

 

Does this work with AI spawned on a HC, if i spawn this loop on a Server?

Share this post


Link to post
Share on other sites
16 minutes ago, WurschtBanane said:

 

Does this work with AI spawned on a HC, if i spawn this loop on a Server?

Should work just fine since neither deletevehicle nor lineIntersects needs to be executed where the objects are local.

 

Cheers

Share this post


Link to post
Share on other sites

I used the JEBUS respawn script found here on the BI forums for my all tank mission two weeks ago.  It features an optional script that will delete the crew once the vehicle is considered immobile/unusable.  Works great for both tanks and jets.

Share this post


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

Thank you @Grumpy Old Man!

 

So if i execute your code on the server once, it will work for the rest of the mission?

 

You need to execute the addEventHandler part on every spawned hostile tank, should work fine.

Was just an example, since you didn't show how you're spawning your hostile tanks.

 

Cheers

Share this post


Link to post
Share on other sites

To spawn tanks (in this case its an APC) i do:

 

if isHC then 
{
[] spawn { 
while {true} do { 
sleep 1000;
_grp1 = [getMarkerPos "tankspawn_2", BLUFOR, ["rhsusf_M113_D_usarmy_MK19"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp1 setBehaviour "SAFE";
_grp1 setFormation "COLUMN";

_wpt1 = _grp1 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt1 setWaypointType "MOVE";

_wpt2 = _grp1 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt2 setWaypointType "MOVE";

_wpt3 = _grp1 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt3 setWaypointType "SAD";

};

 

Its an infinite spawn, basically. I did this with different vehicles, that way about 20 vehicles are spawned per hour. I got performance issues sorted already, i just need to know how to wedge the eventhandler in there.

Share this post


Link to post
Share on other sites
32 minutes ago, Grumpy Old Man said:

 

You need to execute the addEventHandler part on every spawned hostile tank, should work fine.

Was just an example, since you didn't show how you're spawning your hostile tanks.

 

Cheers

 

 

So, looking at the eventhandler, i see that _x stands for the vehicle. But i only defined the group, so if i put in

_grp1 addeventhandler

it will assign the EH to the group, not the tank. How do i solve this?

Share this post


Link to post
Share on other sites
9 minutes ago, WurschtBanane said:

 

 

So, looking at the eventhandler, i see that _x stands for the vehicle. But i only defined the group, so if i put in


_grp1 addeventhandler

it will assign the EH to the group, not the tank. How do i solve this?

I see, since you're using BIS_fnc_spawnGroup which returns a group you can get the vehicle like this:

 

_veh = assignedVehicle leader _grp1;

Assuming the BIS function properly assigns the vehicle to the group.

 

Cheers

Share this post


Link to post
Share on other sites

So now after testing, i encountered 2 problems.

 

Number one: I put this (without the lower vehicles apply part) in the InitServer.sqf. I removed the two "systemchat format" lines (i hope they are not important, by my understanding its just for testing). It works on local and local hosted MP, but not on a dedicated server.

On 24.4.2018 at 8:49 AM, Grumpy Old Man said:


GOM_fnc_crewDelete = {

	params ["_unit"];
	systemchat format ["%1 disembarked!",_unit];

	waitUntil {sleep 1 + random 1;
		{lineIntersects [eyepos _unit,eyepos _x,_unit,_x]} count allPlayers isEqualTo count allPlayers
	};
	systemchat format ["Deleting %1",_unit];
	deletevehicle _unit;


};

vehicles apply {
	_x addEventHandler ["GetOut",{
		params ["_vehicle","_role","_unit"];
		_delete = _unit spawn GOM_fnc_crewDelete;
	}]}

 

 

Problem number two:

if isServer then 
{
[] spawn { 
while {true} do { 
sleep 600;
_grp1 = [getMarkerPos "tankspawn_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp1 setBehaviour "SAFE";
_grp1 setFormation "COLUMN";

_wpt1 = _grp1 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt1 setWaypointType "MOVE";

_wpt2 = _grp1 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt2 setWaypointType "MOVE";

_wpt3 = _grp1 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt3 setWaypointType "SAD";

_veh = assignedVehicle leader _grp1;

vehicles apply {
	_veh addEventHandler ["GetOut",{
		params ["_vehicle","_role","_unit"];
		_delete = _unit spawn GOM_fnc_crewDelete;
	}]};

sleep 5;

_grp2 = [getMarkerPos "tankspawn_2_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp2 setBehaviour "SAFE";
_grp2 setFormation "COLUMN";

_wpt4 = _grp2 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt4 setWaypointType "MOVE";

_wpt5 = _grp2 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt5 setWaypointType "MOVE";

_wpt6 = _grp2 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt6 setWaypointType "SAD";

_veh = assignedVehicle leader _grp2;

vehicles apply {
	_veh addEventHandler ["GetOut",{
		params ["_vehicle","_role","_unit"];
		_delete = _unit spawn GOM_fnc_crewDelete;
	}]};

                }; 
};

I tried to put this APC spawn on a loop, wedging the eventhandler in there. But the script does not work, and i dont know what i am doing wrong.

Share this post


Link to post
Share on other sites
11 hours ago, WurschtBanane said:

So now after testing, i encountered 2 problems.

 

Number one: I put this (without the lower vehicles apply part) in the InitServer.sqf. I removed the two "systemchat format" lines (i hope they are not important, by my understanding its just for testing). It works on local and local hosted MP, but not on a dedicated server.

 

 

Problem number two:


if isServer then 
{
[] spawn { 
while {true} do { 
sleep 600;
_grp1 = [getMarkerPos "tankspawn_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp1 setBehaviour "SAFE";
_grp1 setFormation "COLUMN";

_wpt1 = _grp1 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt1 setWaypointType "MOVE";

_wpt2 = _grp1 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt2 setWaypointType "MOVE";

_wpt3 = _grp1 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt3 setWaypointType "SAD";

_veh = assignedVehicle leader _grp1;

vehicles apply {
	_veh addEventHandler ["GetOut",{
		params ["_vehicle","_role","_unit"];
		_delete = _unit spawn GOM_fnc_crewDelete;
	}]};

sleep 5;

_grp2 = [getMarkerPos "tankspawn_2_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp2 setBehaviour "SAFE";
_grp2 setFormation "COLUMN";

_wpt4 = _grp2 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt4 setWaypointType "MOVE";

_wpt5 = _grp2 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt5 setWaypointType "MOVE";

_wpt6 = _grp2 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt6 setWaypointType "SAD";

_veh = assignedVehicle leader _grp2;

vehicles apply {
	_veh addEventHandler ["GetOut",{
		params ["_vehicle","_role","_unit"];
		_delete = _unit spawn GOM_fnc_crewDelete;
	}]};

                }; 
};

I tried to put this APC spawn on a loop, wedging the eventhandler in there. But the script does not work, and i dont know what i am doing wrong.

 

When you're using initServer.sqf, the function only exists on the server machine.

Try putting it into init.sqf, so it exists everywhere.

Just note that in MP, init.sqf is the last file called in the initialization order, so you can't call the function before that from an objects init field or similar.

 

To your number two:

You apply the function multiple times to _veh, using "vehicles apply". As stated earlier this was just an example, to use  it on a single vehicle simply use:

if isServer then 
{
[] spawn { 
while {true} do { 
sleep 600;
_grp1 = [getMarkerPos "tankspawn_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp1 setBehaviour "SAFE";
_grp1 setFormation "COLUMN";

_wpt1 = _grp1 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt1 setWaypointType "MOVE";

_wpt2 = _grp1 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt2 setWaypointType "MOVE";

_wpt3 = _grp1 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt3 setWaypointType "SAD";

_veh1 = assignedVehicle leader _grp1;

_veh1 addEventHandler ["GetOut",{
	params ["_vehicle","_role","_unit"];
	_delete = _unit spawn GOM_fnc_crewDelete;
}];

sleep 5;

_grp2 = [getMarkerPos "tankspawn_2_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp2 setBehaviour "SAFE";
_grp2 setFormation "COLUMN";

_wpt4 = _grp2 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt4 setWaypointType "MOVE";

_wpt5 = _grp2 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt5 setWaypointType "MOVE";

_wpt6 = _grp2 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt6 setWaypointType "SAD";

_veh2 = assignedVehicle leader _grp2;

_veh2 addEventHandler ["GetOut",{
	params ["_vehicle","_role","_unit"];
	_delete = _unit spawn GOM_fnc_crewDelete;
}];

                }; 
};

Cheers

Cheers

Share this post


Link to post
Share on other sites

Alright @Grumpy Old Man thank you very much, i got it to work!

 

What i found out is, that for some reason the EH is triggered upon spawn. So what i did was to add the EH one minute after each spawn. This is what the spawn script using GOMs despawn eventhandler looks like now:

if isServer then 
{
while {true} do { 
sleep 5;
_grp1 = [getMarkerPos "tankspawn_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp1 setBehaviour "SAFE";
_grp1 setFormation "COLUMN";

_wpt1 = _grp1 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt1 setWaypointType "MOVE";

_wpt2 = _grp1 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt2 setWaypointType "MOVE";

_wpt3 = _grp1 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt3 setWaypointType "SAD";

sleep 60;

_veh1 = assignedVehicle leader _grp1;

_veh1 addEventHandler ["GetOut",{
    params ["_vehicle","_role","_unit"];
    _delete = _unit spawn GOM_fnc_crewDelete;
}];

sleep 5;

_grp2 = [getMarkerPos "tankspawn_2_2", BLUFOR, ["rhs_m6"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
_grp2 setBehaviour "SAFE";
_grp2 setFormation "COLUMN";

_wpt4 = _grp2 addWaypoint [getmarkerPos "waypointspawn_1",0];
_wpt4 setWaypointType "MOVE";

_wpt5 = _grp2 addWaypoint [getmarkerPos "waypointspawn_2",0];
_wpt5 setWaypointType "MOVE";

_wpt6 = _grp2 addWaypoint [getmarkerPos "waypointspawn_3",0];
_wpt6 setWaypointType "SAD";

sleep 60;

_veh2 = assignedVehicle leader _grp2;

_veh2 addEventHandler ["GetOut",{
    params ["_vehicle","_role","_unit"];
    _delete = _unit spawn GOM_fnc_crewDelete;
}];

                }; 
};

Obviously, you need to make the sleeps longer, i shortened them to be able to test properly. 10 tanks per minute is a bit much :D

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  

×