Home   Help Search Login Register  

Author Topic: Get enemy to randomly surrender  (Read 2903 times)

0 Members and 1 Guest are viewing this topic.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Get enemy to randomly surrender
« on: 01 Apr 2003, 23:06:53 »
Hi!  To get an enemy to surrender after they have taken moderate damage do:

Add this to that units init:
this addEventHandler ["Hit", {_this select 0 exec "captive.sqs"}]

And then captive.sqs is:
Code: [Select]
;By Doolittle
?not alive _this : exit
?damage _this < 0.75 : exit
?vehicle _this != _this : exit
?random 1 < 0.3 : exit

_this removeAllEventHandlers "Hit"
_this setCaptive true
_this switchMove "FXStandSurDown"

_this addEventHandler ["Killed", {_this select 0 switchMove "FXStandSurDead"}]

Easy stuff! :)

Doolittle

unkie

  • Guest
Re:Get enemy to randomly surrender
« Reply #1 on: 04 Apr 2003, 03:52:41 »
this is cool, but how do you get AI to not kill them once they surrender?

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Get enemy to randomly surrender
« Reply #2 on: 04 Apr 2003, 08:14:26 »
Code: [Select]
_this setCaptive true
This makes them not shoot at someone who surrendered.

Doolittle

Loc-Dog

  • Guest
Re:Get enemy to randomly surrender
« Reply #3 on: 04 Apr 2003, 20:25:47 »
I didn't count but I put the script on atleast 60 or more enemy units and killed almost everyone and no one surrendered! I did this over and over again 5 times after I gave up. Hard arses! Maybe get me one of those flame throwers! I also had some friendly units on my side. If an AI unit is fiering on another AI unit, it takes a few secs for the first AI to disengage after the second AI has been set to captive, that could well be enaugh time for the first AI to shoot the second AI in the head....
« Last Edit: 04 Apr 2003, 20:33:01 by Loc-Dog »

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Get enemy to randomly surrender
« Reply #4 on: 04 Apr 2003, 22:53:26 »
That's the problem though with OFP...one shot one kill.  You need to just WOUND them.  Try shooting them in the legs, or use the Bizon or HK or any handgun...something where you can shoot them several times without killing them.

(Lemme know how it goes...)

Doolittle

Rappy

  • Guest
Re:Get enemy to randomly surrender
« Reply #5 on: 06 Apr 2003, 13:14:01 »
Did something similiar only based on the amount of enemies and allies, aswell as wounds.

Kinda never finished really cos I decided not to put it into my mp map:



_AI = _this select 0

;;Start normal AI behaviour check to see if enemy would like to surrender

#loopai
~1
enemies = _AI countenemy enemylist
allies = _AI countfriendly allylist
_d = 0

?(enemies >= 10) and (allies <= 5): goto "randomsurrender"
?(enemies >= 5) and (allies == 1): goto "surrender"
?(enemies >= 7) and (allies == 2): goto "surrender"
?(enemies >= 9) and (allies == 3): goto "randomsurrender"
?(getdammage _AI >= 0.5):goto "randomsurrender"
?(getdammage _AI >= 0.8):goto "randomsurrender2"
goto "loopai"

;;random surrender
#randomsurrender
~0.5
?(random 10 <= 1): goto "surrender"
goto "loopai"

#randomsurrender2
~0.5
?(random 10 <= 6): goto "surrender"
goto "loopai"

;; surrender
#surrender
~1
_AI sidechat "surrendering"
RemoveAllWeapons _AI
_AI removemagazines "handgrenade"
_AI removemagazines "handgrenade"
_AI switchmove "FXStandSurDown"
_AI setCaptive true

#surrendered
~2
?(Getdammage _AI >= 1):goto "end"
_d = _d + 1
?(_d == 10): goto "backtonormal"
goto "surrendered"

#backtonormal
;; Take back former weapon and get back to action state
goto "loopai"

#end
_AI switchmove "FXstandsurdead"
exit



As you see I didnt finish the backtonormal part of it which would mean giving the guy back the weapons he had before (wouldnt have been a problem really I guess) but I kinda had the problem of not getting off the surrender state (hands behind head) and I didnt need the script anyways anymore so I didnt bother anymore.

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Get enemy to randomly surrender
« Reply #6 on: 08 Apr 2003, 19:46:53 »
Doolittle ! That's great !

Could you plz post a (rough) script how i give a named player the action command to 'collect' the hostage ? This would be awesome for my mp nam mission.

I guess it's like:

- go thru all players
- check distance from this player to the nearest enemy that is a hostage
- add action command 'collet hostage' or something
- hostage disappears (give money or points to players)
- delete action command

but i dunno how to code it for OpF.  :-\

Johan_D

  • Guest
Re:Get enemy to randomly surrender
« Reply #7 on: 15 Apr 2003, 11:58:55 »
AI switchmove "null" or something is needed to get them back to normal.. can remember where I read it..

Johan

edit.. ah here: http://www.ofpec.com/editors/resource_view.php?id=471
« Last Edit: 15 Apr 2003, 11:59:43 by Johan_D »

jepo

  • Guest
Re:Get enemy to randomly surrender
« Reply #8 on: 24 Apr 2003, 09:43:46 »
to get them back to normal u do
this switchmove "combat"

gunnerman

  • Guest
Re:Get enemy to randomly surrender
« Reply #9 on: 27 Apr 2003, 02:22:30 »
I am quite stupid  :P can someone please post a demo  mission?