Jump to content
Mynock

Super Simple Surrender script

Recommended Posts

Got bored and wrote a very basic surrender script system for my own needs and decided to share it. As usual with my stuff, I've only developed it for single player and I have not done extensive compatibility testing with mods like ACE, mods that change AI behavior, etc. If you test it as is or modify it slightly to work for a dedicated server or other multiplayer environment please let me know so I can update the script and credit you.

Ideally the user of the script will be someone looking to enhance the vanilla behavior of enemy units, not someone who is looking for a solution on top of AI behavior mods, realism or milsim mods, etc. If you already use those, this probably isn't going to work for you.

Basically what it does is allows you to set a minimum damage threshold and a percentage chance of surrender for an enemy unit. If the unit is wounded and damaged to a value above the minimum threshold, the unit will consider surrendering via the percentage chance.

If the unit does not surrender, then he will continue to fight you until killed.

If the unit does surrender, he will be set to captive mode (so AI friendlies won't keep trying to shoot him), play the surrender animation and sling his rifle over his shoulder and place his hands behind his head. Once in this position the player can approach the unit and use a "Restrain" action. The Restrain action will change the unit (relatively) smoothly to a sitting position with hands restrained behind the back. Once restrained the player can use the action menu to either search the unit's inventory, or "pick up" and move the unit to another location. For simplicity sake the unit remains in the sitting position when being moved as this script isn't designed for taking a hostage back to base or movement over long distances with a prisoner (I'd recommend Sushi's POW script for that). The idea behind being able to move the prisoner short distances is for those who want to imitate realistic procedures and not leave restrained people out in the open or who want to move all prisoners to an area to be guarded near the battlefield. From there you could use the inventory access to strip the unit of their weapon(s) and gear to continue the "realism" or you can just leave them as is on the ground, your choice.

All information pertaining to usage, license, and how to set it up is in the readme file. I'll copy everything into the spoiler below if you want to read about it before you download. Most critically you should know that you absolutely may not for any reason whatsoever use or distribute this script on a server, website, etc. that is monetized in any way without written consent from myself.

Super Simple Surrender Script

Author: Mynock

Contact: mynock.steam@gmail.com

Credits: BIS

WARNING: If you obtained this script from de-.pbo'ing a mission, and it has been modified from the

original in any way for that user's personal use, please contact the author of the mission

you obtained this script from in order to get their permission to use their modified version

of the original.

------------------------------------------------------------------------------------------------------------

What it Does: Allows you to assign a bit of code to any enemy AI unit you choose to give them a random

chance of surrendering if they are wounded in combat. If the unit surrenders, the player

can restrain the unit. Once the unit is restrained, the player can search the prisoner's

inventory or move the prisoner to another location. If the unit is killed at any point

after surrendering, the actions become useless and will be removed if the player attempts

to access the actions. If the unit is killed after surrendering and the player still wishes

to access the now dead unit's inventory, the default action in Arma 3 can be used instead.

Design: This script is designed to be used on enemy AI units. Use for any other purpose is not

recommended or supported by the author.

Modification: You may modify this script for personal use within your own mission as required to acheive

your desired effect.

Please do not redistribute a modified version without contacting me first.

Limitations: You may NOT use or distribute this script on any sort of monitized platform. No exceptions

without written consent from Mynock.

License: All stardard Bohemia Interactive and Arma licenses apply.

Distributed under the Creative Commons License BY + NC + SA.

Crediting: Crediting is not required, but is appreciated if you use this in your mission, as is or

modified for your own personal use.

Installation: Place entire MNK_SSS folder into your mission folder. All parts are required for proper use.

This is not a modular system. All five .sqf files must be present in the folder.

See Usage Example at the bottom for the line to execute the script.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Argument 0: Unit [Required] (If used in the unit's init field, "this" can be used, otherwise the variable name is required)

Argument 1: Minimum Damage Threshold | Number [Optional, default is 0.3] (Number 0.01 - 0.99. Minimum amount of damage the unit must sustain before considering surrender. Do not set to exactly 0 or exactly 1. Set to a number in between 0 and 1.)

Argument 2: Surrender Chance | Number [Optional, default is 0.5] (Number 0 - 1. Example: 0.5 is a 50% chance of surrender, 0.2 is a 20% chance, etc. Setting to 0 will cause the unit to never surrender, setting to 1 will cause the unit to always surrender)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Usage Examples: null = [this] execVM "MNK_SSS\mnk_surrender.sqf";

null = [this, 0.5] execVM "MNK_SSS\mnk_surrender.sqf";

null = [this, 0.5, 0.25] execVM "MNK_SSS\mnk_surrender.sqf";

Super Simple Surrender v1.0

  • Like 6

Share this post


Link to post
Share on other sites

I wrote something similar so I checked your script and I find using

while {alive _unit} do {

very inefficient. I could slow down missions with a large amount of AI.

I solve it with

_side = _this select 0;
{
	if (side _x == _side) then {
		call compile format["
			%1 addEventHandler ['Hit',{
				if (vehicle %1 == %1) then {
					_rand = random 100;
					if (_rand < 15) then {
						[%1] spawn fnc_surrender;
					};
				};
			}]
		",[_x] call BIS_fnc_objectVar];
	};
} forEach allUnits;
  • Like 1

Share this post


Link to post
Share on other sites

It sounds like this script probably isn't for you then. That's perfectly fine. As stated, I write stuff for single player, plus I don't make massive missions. Someone who has other needs like multiplayer or 100+ enemy AI are probably going to use something different. I find mine useful especially when I only want particular units to consider surrender, but not all of them. For example, I can put this script on a 4 man patrol who realistically might consider surrender if ambushed, but then later in the mission not run it on a bunch of units inside a base who have support nearby. Using side makes it so every single unit will consider surrendering, and in a lot of situations I don't want that. For what I do, I enjoy the flexibility of being able to set different minimum damage thresholds and surrender chances to different units vs all of them being identical. This would even work well for a situation where someone wants to make a mission where they have to wound an enemy officer to make him surrender and then restrain him; they could add a variable to the script that is created after he is restrained that then fires a trigger and completes an objective or the mission.

If the vast majority of the community thinks this is inefficient or useless then that's fine I can take down the file. No point in sharing something no one else is going to use.

Share this post


Link to post
Share on other sites

No, I also learned something from reading the code, so thanks. I just wanted to point out that there's an alternative solution that's worth considering, no need to get so defensive.

 

Also, the condition of course doesn't need to be side==..., it can be anything. I just like using event handlers whenever possible.

Share this post


Link to post
Share on other sites

Hardly being defense. I'm explaining my thought process behind the script. There are always multiple ways to do things in this game.

But you're right, if this is inefficient for the vast majority of the community then I see no point in leaving it up. I don't want to share things that are useless. I guess we will see what others think.

Share this post


Link to post
Share on other sites

I guess we will see what others think.

 

I think it's great....thanks for sharing your code.  ;)

Share this post


Link to post
Share on other sites

Whats is the point to being against code quality and performance?

If someone gives you advice take it and improve your code.

This is one of the methods gives you a possibility to make it perfect.

Share this post


Link to post
Share on other sites

I'm not against it. For my purposes my code works. If others want to do differently they are welcome to either modify mine to suit their personal needs or make their own. If no one is interested in using my method then it's rather pointless leaving it up, right? I don't have a problem with other people offering alternative solutions; I have a problem with this notion that if I explain my thought process and why I wrote my script the way I did, now I'm a defensive person who refuses to listen to anyone's advice. That's not the case, stop trying to turn it into that.

Perfect is a subjective term. For my purposes when I wrote this, it works. For others who have different ideas it probably won't be.

Share this post


Link to post
Share on other sites

Very neat, thanks for sharing!   Does it take into account how many other units are alive in the group when determining if the unit should surrender?  

Share this post


Link to post
Share on other sites

Very neat, thanks for sharing!   Does it take into account how many other units are alive in the group when determining if the unit should surrender?

Nope. Super simple means super simple haha. It only looks at if the unit has taken damage above the threshold and then the percentage chance of surrender. You're welcome to modify it for your personal use if you want to add in that feature for one of your missions. I actually built off of what you see here a little bit further for my needs, but I trimmed it down a few specific lines to share it so it was more flexible for other people to use.

Part of the reason I don't make really detailed and involved scripts is because I know everyone has a different idea for how they want to use it, so I like to keep it simple and then allow people to build on it for their specific project if they'd like (plus I'm not full of scripting talent to make crazy detailed ones anyway). I find it easier personally to take people's scripts and add to them (assuming their license allows for it) rather than trying to take things out because often times I end up breaking the script when I'm deleting sections instead of adding sections.

Share this post


Link to post
Share on other sites

I should also add since a few people have PM'd me about it: the reason the script deletes the first aid kits from surrendered units is because I found that about 50% of the time the unit that surrendered would try to heal itself after surrendering, which would lead to an endless animation loop of him applying the first aid kit and made the script useless. It was the simplest workaround I could come up with basically. If scavenging aid kits off of surrendered units is a requirement for your scenario, I'd recommend editing the script a bit to re-add the first aid kits after the entire surrender process is completed to (hopefully) avoid the never ending animation looping glitch.

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

×