Jump to content
Sign in to follow this  
twistking

How to discourage players from stealing enemy vehicles?

Recommended Posts

Hello,
how can i prevent or discourage players using enemy vehicles? When players have the ability to repair knocked out vehicles (engineer trait or repair vehicle), they can easily get aceess to strong vehicles that would more or less break the mission.
What are elegant ways to discourage usage of enemy vehicles?
"Locking" vehicles for players would of course work, but also feels a bit to restrictive and artificially forced. The best thing i could come up with was a trigger, that sets vehicle fuel close to empty when vehicle is damaged... Other ideas? Thanks!

Share this post


Link to post
Share on other sites

THIS MESSAGE HAS BEEN EDITED, and its more complete version can be found in next ones.


Probably the most efficient idea would be adding an eventHandler - GetIn to every vehicle you don't want to be used by players.
Please note that the code below will probably NOT WORK as it is. I haven't tested it, just somehow adapted from another one I use. But my bet is that this would be a nice approach:
 

_this addEventHandler ["getIn", {
    params ["_vehicle", "_role", "_unit", "_turret"];
    _vehicle = _this # 0;
    if ((_role == "driver") and (_unit isKindOf 'SoldierWB')) 
	then {
	_unit action ["eject", _vehicle];
	hint "You should not use enemy vehicles";
	}
}];


But there would be an even more efficient solution, which could be to add an array of forbidden vehicles AND an eventHandler to the init.sqs file as well, so it would act the same forced eject code upon every vehicle you chose, during the whole mission.

And this syntax might NOT prevent a player to enter as passenger or whatever and change seats for driver. So to avoid that there is another eventHandler, or you could just remove the "_role == "driver" parameter, so it would act upon everyone entering vehicle.

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 9/25/2023 at 10:39 PM, JCataclisma said:

Probably the most efficient idea would be adding an eventHandler - GetIn to every vehicle you don't want to be used by players.
Please note that the code below will probably NOT WORK as it is. I haven't tested it, just somehow adapted from another one I use. But my bet is that this would be a nice approach:
 


_this addEventHandler ["getIn", {
    params ["_vehicle", "_role", "_unit", "_turret"];
    _vehicle = _this # 0;
    if ((_role == "driver") ||		// in case is just for the driver;
	{_unit isKindOf 'SoldierWB'})	//or use SoldierGW for guerrilla, soldier Eb for OPFOR; 
	then {
	_unit action ["eject", _vehicle];
	hint "You should not use enemy vehicles";	// completely optional, of course;
	sleep 3;									// so to avoid 'hint' appearing for its whole 30 seconds on screen;
	hintSilent "";								// clear 'hint' after 3 seconds;
	}
}];


But there would be an even more efficient solution, which could be to add an array of forbidden vehicles AND an eventHandler to the init.sqs file as well, so it would act the same forced eject code upon every vehicle you chose, during the whole mission.

And this syntax might NOT prevent a player to enter as passenger or whatever and change seats for driver. So to avoid that there is another eventHandler, or you could just remove the "_role == "driver" parameter, so it would act upon everyone entering vehicle.

 

thanks!

Share this post


Link to post
Share on other sites

I have tested and so MODIFIED my previous post. Now the script acts upon entering as driver ONLY - I had used "||" which works as "or", instead of the "and" which is there now.
And I have also removed the "sleep", which is not allowed in such cases.
But it still does NOT avoid players entering in other seats and then changing to driver, whether the vehicle allowed to do so - that requires another kind of "switchSeat" eventHandler.

Whether you want it avoid access for every seat in the vehicle, just change the "if" line into this:

if (_unit isKindOf 'SoldierWB')



You also have the probably more simple option to just lock the driver seat at some point by using

_this lockDriver true;



So you can add all this into your "forbidden" vehicle's init field. The very first time the player enters the driver seat, they'll be ejected and driver locked permanently. And the lock will also work when vehicle's original driver exits - but I think it wonk work whether drivers got k1ll3d. For that case, there is a third part of code, that will permanently lock the driver seat once vehicle receives a specific amount of damage (providing "0" is full health, "0.5" is half damaged and "1" is completely destroyed).

 

_this addEventHandler ["getIn", {
    params ["_vehicle", "_role", "_unit", "_turret"];
    _vehicle = _this # 0;
    if (_unit isKindOf 'SoldierWB')
	then {
	_unit action ["eject", _vehicle];
	hint "You should not use enemy vehicles";
	}
}];

/*/======================/*/

_this addEventHandler ["getOut", {
    params ["_vehicle", "_role", "_unit", "_turret"];
    _vehicle = _this # 0;
    if (_role == "driver")
	then {
	_vehicle lockDriver true;
	}
}];

/*/======================/*/

_this addEventHandler ["Dammaged", {
	params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
	if (_damage > 0.7)
	then {
	_unit lockDriver true;}
}];


Remember to change both starting "_this" into "this" if you wan to test it on editor.

Edited by JCataclisma

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  

×