Home   Help Search Login Register  

Author Topic: how can i get enemies to surrender after a number of them have been killed?  (Read 1529 times)

0 Members and 1 Guest are viewing this topic.

Offline filth

  • Members
  • *
  • Who's the bad man?
hello all you helpful ofpec people.

i need a script.

what i want to happen is this:

i assault an enemy position, let's say two enemy squads of ten men each (twenty enemies in total).

when i kill a certain amount (let's say 6 men - i would prefer it if they were from either group),

i want the rest of them to lay down their weapons and surrender. (presumably using a switchmove animation - ideally staggered so that they don't all do it exactly at the same time)

any thoughts?

cheers,

filth.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Many.

One simple way is to give each of the groups of enemies a groupname eg by putting
GrpNameX = group this
in the init field of the leader of each group, and where X = 1 for group 1; 2 for group 2 etc.

Then create a trigger that has the following in the condition field:

12 > (count units GrpName1) + (count units GrpName1) + ...for all the groups

This will cause the trigger to fire when the number of remaining enemies is down to 12

In the Action field (or whatever it is called) put

[units GrpName1 + units GrpName2 ...] exec "surrender.sqs"

Surrender.sqs could look something like:

Code: [Select]
_enemyloons = _this select 0
{unassignVehicle _x} forEach _enemyloons
_enemyloons allowGetIn false
{[_x] join grpNull} forEach _enemyloons
{_x setCaptive true} forEach _enemyloons
{_x setCombatMode "BLUE"} forEach _enemyloons
{_x setBehaviour "CARELESS"} forEach _enemyloons
{_x setSpeedMode "LIMITED"} forEach _enemyloons
{_x doMove [8000 - 10 + random 5,9960 - 10 + random 5]} forEach _enemyloons
{_x doWatch Alexi} forEach _enemyloons
{_x setMimic "Angry"} forEach _enemyloons
[_enemyloons] exec "DropWeapons.sqs"

{_x addEventHandler ["Killed",{_this select 0 switchMove "FXStandSurDead"}]} foreach _enemyloons
{_x setUnitPos "UP"} forEach _enemyloons

_i = 0
#loopSurrender1
_loon = _enemyloons select _i

~0.25 + random 0.75

if ((alive _loon) and (vehicle _loon == _loon) and (abs(8000 - (getPos _loon select 0)) <50) and (abs(9960 - (getPos _loon select 1)) <50)) then {_loon doWatch Alexi;if (50 > random 100) then {_loon switchMove "FXStandSur"} else {_loon switchMove "FXWomanSur"}}

_i = _i + 1
if (_i < count _enemyloons) then {goto"loopSurrender1"}

_start = _time
#longLoop

_i = 0
#loopSurrender2
_loon = _enemyloons select _i

~random 1

if ((alive _loon) and (vehicle _loon == _loon) and (abs(8000 - (getPos _loon select 0)) <50) and (abs(9960 - (getPos _loon select 1)) <50)) then {_loon doWatch Alexi;if (50 > random 100) then {_loon switchMove "FXStandSur"} else {_loon switchMove "FXWomanSur"}}

_i = _i + 1
if (_i < count _enemyloons) then {goto"loopSurrender2"}

if ({(alive _x) and ((abs(8000 - (getPos _x select 0)) >=50) or (abs(9960 - (getPos _x select 1)) >=50))} count _enemyloons < 1) then {goto"end"}
if ({(speed _x) > 1} count _enemyloons < 1) then {goto"end"}
if (_time > (_start + 600)) then {goto"end"}

~2 + random 2
goto"longLoop"

#end


{if (alive _x) then {_x doWatch Alexi;if (50 > random 100) then {_x switchMove "FXStandSur"} else {_x switchMove "FXWomanSur"}}} forEach _enemyloons


exit
and DropWeapons.sqs looks like:
Code: [Select]
;DropWeapons.sqs
;called by:  [units] exec "DropWeapons.sqs"
; Where units is an array of the units that should drop their weapons

_units = _this select 0

if (count _units < 1) then {exit}

#again
_repeat = false

_i = 0
#loop
~0.5 + random 0.5
_unit = _units select _i
if (Vehicle _unit != _unit) then {_repeat = true}
{_unit action ["Drop Weapon",_unit,0,0,_x]} forEach weapons _unit
_i = _i + 1
if (_i < count _units) then {goto"loop"}

{unassignVehicle _x} forEach _units
_units allowGetIn false
~2
if _repeat then {goto"again"}
exit

Note that in the above example:
1. Alex is the name of the unit they are surrendering to.  You could delete all references to this if you like.
2. There are several absolute locations on the island.  They work for the airbase in the north of Malden.  You would need to change them for use elsewhere - or you might use the actual location of the unit they are surrendering to - that might look quite neat

Not guaranteed.  The script code I have just cut and pasted from a mission of mine but it may need to be played about with a bit in case I cut and pasted it incorrectly.
« Last Edit: 11 May 2007, 19:14:00 by THobson »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Gen Barron's surrender script is also attached to a thread here.
urp!

Offline filth

  • Members
  • *
  • Who's the bad man?
cheers for this guys.

i'm giving them both a go...

filth.