Home   Help Search Login Register  

Author Topic: Simple enemy AI surrender and capture script  (Read 2703 times)

0 Members and 1 Guest are viewing this topic.

Offline norrin

  • Tutorial Writer
  • **
Simple enemy AI surrender and capture script
« on: 08 Nov 2009, 12:09:44 »
Enemy AI surrender and capture script

Version 0.1

Description
A script that allows you to set an enemy group so that it surrenders after a certain number of group members are dead.  Once the conditions are met the surrendering units drop their weapons on the ground, put their hands behind their heads and are set as captives. You can then move up to them and get them to join your group and move them to a friendly prison or drop-off point.  The captured units can at no time carry weapons, drive vehicles or operate on-board weapon systems.

This is an updated version of my simple capture script for ArmA1.

Instructions for test mission

Shoot an OPFOR unit from each of the two enemy groups in front of you. The remaining units will drop there weapons and then put hands behind their heads and will be made setCaptive true (ie. turn blue on the map). Move next to one and an action to "take prisoner" should appear. Capture and then wait a few seconds the prisoner will join your group. Then take him or send him to just between the barbed wire in front of the guard house . He should resume the hands behind head animation and then after a couple of seconds he will disappear. You will get a message POW returned for interrogation. If you shoot units that have surrended you will get a message. If you order a POW to take a weapon he will immediately put it down again so he cannot be used as a BLUFOR unit.

You can change the number of OPFOR units that need to be shot before the group surrenders in the init.sqf in the line:

{[_x, 2, _allies] execVM "NORRN_capture\group_surrender.sqf"} forEach _enemy_groups_high_morale;

You'll need a player in the leader's slot (or you'll have to shoot the AI leader so leadership passes down the group) or have the AI disabled.

To implement
* Copy across the text from the init.sqf and NORRN_capture folder to your mission file.

*In the editor name the enemy AI groups that can surrender and be captured eg east_1 = group this.

*Update the code in the init.sqf - you have to put allies and enemys generic unit types and also the names of the enemy groups that you want to surrender in _enemy_groups_high_morale and _enemy_groups_low_morale lines. There's two lines as you may want different groups to surrender when different numbers of troops die.

*You'll need a marker on the map called "prison". This is where the enemy units will leave your group.

*Make sure that the rank of the group leader of friendly units is higher than the rank of the captured units

*If you don't want captured units boarding a vehicle or chopper in the gunner or driver slots you'll need to put this code in the int line of the vehicle.
Code: [Select]
this addEventHandler ["GETIN", {if ((_this select 1) == "driver" && (_this select 2) isKindOf "soldierEB" || (_this select 1) == "gunner" && (_this select 2) isKindOf "soldierEB") then {(_this select 2) action ["GETOUT", (_this select 0)] }}];
- you may need to adapt this if the surrendering units are not OPFOR

Tested
ArmA2 1.04 on a dedicated server
« Last Edit: 08 Nov 2009, 12:11:26 by norrin »

Offline ZapBrannigan

  • Members
  • *
Re: Simple enemy AI surrender and capture script
« Reply #1 on: 10 Nov 2009, 09:36:08 »
It seems to work fine though i personaly wouldnt want the captured prisioners to be in my group if i was the mission maker. you could change take prisoner to, secure prisoner and let the player use the action to set his hands behind his back and kneel like tied with flexcuffs like in rainbow 6 3..

also, if the player isnt around such as he left the area without taking the prisoner, you should have him get his gun back and start fighting again.  that said make sure the enemy doesnt surrender in the first place if the friendly units are nowhere nearby (IE the enemy group was hit by artillery.)

lastly, dropping ammo is not realistic, the enemy only needs to drop his weapon, you can remove the enemies ammo when the player uses the secure prisoner action.  in real life if youre trying to surrender are you going to take the time to empty each pocket of ammo? nah you just will throw your gun on the ground and let them see your hands.  because when i took prisoners it was strange there was many pouches on the ground around the enemies gun.

also, make sure the players squad is bigger than the enemies squad because under normal circumstances, a whole squad isnt going to surrender to 1 guy.

good work

Offline norrin

  • Tutorial Writer
  • **
Re: Simple enemy AI surrender and capture script
« Reply #2 on: 11 Nov 2009, 02:40:30 »
Hi Zap,

Thanks for your comments - they are very helpful and may find there way into an upgrade of a more sophisticated surrender system that I wrote for ArmA1, which already includes some of the things you're talking about such as surrendered units grabbing weapons and attacking if capturing players move too far away etc.  This complex system looks at a wide range of variables before a unit surrenders such as the numbers of enemies known about, their distance from the unit, the number of injuries and casualities in a group as well as the strength of the group and unit skill (there's probably a couple of other things as well that have slipped my mind).

The simple system presented here is essentially designed with specific game objectives in mind - such as being forced to capture units for transportation and/or interrogation.  Interrogated units would then provide significant intel for the next task in a mission or a piece of essential equipment.  So in a sense they are canned scripts and are not meant to accurately model the surrender/capturing process as its essential that at least some of the units survive so the next task in the mission can be completed.

norrin