Jump to content
mcnools

Making units of a side within certain area surrender. Help

Recommended Posts

So, I was hoping to make some missions for my group where we can bring in prisoners for questioning to gain valuable intel. In order to do this however I need to have the enemy surrender sometimes.

I tried googling around but I haven't managed to find anything yet. If there is some proper surrendering script out there that takes in variables such as how outnumbered an enemy is, if he's wounded etc. that would be cool but if not I would be completely find with a more simple script that makes the remaining enemies of one side (within a specific area) surrender when there are say... less than three of them left in that area. I  found  this topic discussing how to make enemies surrender when there are less than 10 of them in the entire map (from what I've understood of that topic) but I couldn't even get that to work it seems. Unfortunately I'm completely at loss when it comes to scripting so I would need help.

 

In other words, I'm looking for a trigger/script with the condition "less than three OPFOR within this area" and the on activation "the last OPFOR within the area puts their hands on their backs and is set as captive".

 

Any ideas anyone?

If there are any other good surrender scripts/ideas I would like to hear them as well. We do use Alive though so anything that is relying on groups that are present when the mission starts etc. won't work I suppose. (My idea here was to have a minimum amount of enemies placed in these areas at start and then having more spawn by Alive, that way they won't just surrender right away or something)

Share this post


Link to post
Share on other sites

trigger condition(also make it not repeatable)

{alive _x AND (side _x) isEqualTo EAST} count allUnits isEqualTo 1

activation set opfor present then just execVM a .sqf file passing in the units like null = [thisList select 0] execVM "test.sqf"; for one of the opfor units

inside said .sqf file

params ["_unit"];

_unit setCaptive true;
_unit playmove "AmovPercMstpSsurWnonDnon";

 

  • Like 1

Share this post


Link to post
Share on other sites

Thank you! will try it ASAP!

 

EDIT: ok, tested it, it does make them surrender but seems to be depending on how many OPFOR there are in the ENTIRE map, I need the script to only care about the opfor in a small area (one village for instance). Since we use Alive there will always be some opfor roaming around the map somewhere, but when we storm a certain village and kill almost everyone the last guys should surrender.

 

Also, is there a way to:

1) make the enemy drop his weapon

and/or

2) make it possible to search the enemies inventory, not just backpacks but all of it, would be cool if we could find intel on people who have surrendered etc. Or just check them for bombs.

 

Thanks for helping out man!

 

 

 

 

Just to make sure I haven't messed anything up, this is how I set it up:

 

Small tigger, 50x50 metres, two opfor inside.

OPFOR - > present activation

Non repeatable.

 

Condition: 

Quote

  {alive _x AND (side _x) isEqualTo EAST} count allUnits isEqualTo 1

 

On Activation:  

Quote

null = [thisList select 0] execVM "test.sqf";


And then in the test.sqf I have:

Quote


params ["_unit"]; _unit setCaptive true; _unit playmove "AmovPercMstpSsurWnonDnon";


 

 

Share this post


Link to post
Share on other sites
57 minutes ago, mcnools said:

Thank you! will try it ASAP!

 

EDIT: ok, tested it, it does make them surrender but seems to be depending on how many OPFOR there are in the ENTIRE map, I need the script to only care about the opfor in a small area (one village for instance). Since we use Alive there will always be some opfor roaming around the map somewhere, but when we storm a certain village and kill almost everyone the last guys should surrender.

 

Also, is there a way to:

1) make the enemy drop his weapon

and/or

2) make it possible to search the enemies inventory, not just backpacks but all of it, would be cool if we could find intel on people who have surrendered etc. Or just check them for bombs.

 

Thanks for helping out man!

 

 

 

 

Just to make sure I haven't messed anything up, this is how I set it up:

 

Small tigger, 50x50 metres, two opfor inside.

OPFOR - > present activation

Non repeatable.

 

Condition: 

 

On Activation:  


And then in the test.sqf I have:

 

oops sorry thats because of using allUnits. change allUnits to thisList like

 {alive _x AND (side _x) isEqualTo EAST} count thisList isEqualTo 1

as for making the player drop the weapon do this.

params ["_unit"]; 
_unit action ["DropWeapon", _itemBox, currentWeapon _unit];
_unit setCaptive true; 
_unit playmove "AmovPercMstpSsurWnonDnon";

you can make the unit have a random chance of having intel by doing something similar to this in the same .sqf file as well

params ["_unit"]; 
_unit action ["DropWeapon", _itemBox, currentWeapon _unit];
_unit setCaptive true; 
_unit playmove "AmovPercMstpSsurWnonDnon";

_unit addAction ["Search",
{
	if (40 > random 100) then
	{
		hint "something found";
	} else
	{
		hint "nothing found";
	};
}, [], 6, false, true, "", "", 3];

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
18 hours ago, mcnools said:

In other words, I'm looking for a trigger/script with the condition "less than three OPFOR within this area" and the on activation "the last OPFOR within the area puts their hands on their backs and is set as captive".

Trigger activation: OPFOR, present.

Condition:

this and {(count thisList) < 3}

On act.:

[thisList select 0] spawn {
    _unit = _this select 0;

    _unit setCaptive true;

    _weaponHolder = "GroundWeaponHolder_Scripted" createVehicle (getPosASL _unit);

    _unit action ["DropWeapon", _weaponHolder, currentWeapon _unit];

    waitUntil {
        sleep 1;

        !(alive _unit) or {(currentWeapon _unit) == ""}
    };

    if (alive _unit) then {_unit playMove "AmovPercMstpSsurWnonDnon";};
};

Share this post


Link to post
Share on other sites

Thanks to both of you! I tried your method Schatten but it seems only one of the remaining soldiers drops his weapon and surrenders, the other one just shoots at me. (placed three units and shot one).

 

Also, just noticed that ace already has a "search inventory" option for captured units so that part is no longer necessary!

Share this post


Link to post
Share on other sites

Sorry if I'm thick, maybe I just need to get some sleep and try to understand things again, but where do I put that code?

Share this post


Link to post
Share on other sites

@mcnools, put this code into "On act." field of trigger:

{
	[_x] spawn {
		_unit = _this select 0;

		_unit setCaptive true;

		_weaponHolder = "GroundWeaponHolder_Scripted" createVehicle (getPosASL _unit);

		_unit action ["DropWeapon", _weaponHolder, currentWeapon _unit];

		waitUntil {
			sleep 1;

			!(alive _unit) or {(currentWeapon _unit) == ""}
		};

		if (alive _unit) then {_unit playMove "AmovPercMstpSsurWnonDnon";};
	};
} forEach thisList;
  • Thanks 1

Share this post


Link to post
Share on other sites

Ah! understood! thank you so much for your patience! The script seems to work like a charm now!

Share this post


Link to post
Share on other sites

@mcnools

Here are some links that should be helpful, as for the reasons why. They explain the game's scheduler.

https://community.bistudio.com/wiki/Scheduler#Scheduled_Environment

https://community.bistudio.com/wiki/Scheduler#Unscheduled_Environment

The spawn command opens a new thread which allows suspension.

https://community.bistudio.com/wiki/spawn

  • 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

×