Home   Help Search Login Register  

Author Topic: Cop patrol script in Crime City... Problems... AI DRIVES TOO SLOW!!!  (Read 2124 times)

0 Members and 1 Guest are viewing this topic.

Offline Acecool

  • Members
  • *
I have several problems..

THE AI follows when you get close enough, which is perfect... But, the AI follows extremely slow.. I want them to drive AGGRESSIVE... LIKE A COP trying to take down a perp.....

Also, the AI doesnt shoot at me if I am in a car, if I am out of the car they will open fire.... after a little bit...

Code: [Select]
_name = "Not Set"
_unit = _this select 0
{call format ["if (player == %1) then {_name = ""%1"";}", _x]} forEach allarray
hint "You are not wanted by the police!"


;;
;; They are not a criminal, wait until they are....
;;
#wait_until_criminal
_criminal = call format ["%1_criminal", _name]

if (_criminal > 0) then { goto "criminal_loop"; hint "You are now wanted by the police!" }

call format ["%1_criminal=1", _name]

if (!alive _unit) then { goto "exit" }
~2.0
goto "wait_until_criminal"


;;
;; They are a criminal, so lets let cops in the area chase them...
;;
#start_chase

#criminal_loop
_criminal = call format ["%1_criminal", _name]
if (_criminal < 1) then { goto "wait_until_criminal"; hint "You are no longer wanted by the police!" }


; If you are more than 25 meters and less than 250, let them chase you
{call format ["if (%1 distance _unit > 25 && %1 distance _unit < 250) then { %1 moveInDriver %1_car; %1 doFollow _unit}", _x]} forEach coparray
;; %1 Move getPos _unit
; Otherwise, get out... and shoot...
{call format ["if (%1 distance _unit <= 25 && speed _unit < 5) then { unassignvehicle %1 }", _x]} forEach coparray

{call format ["%1 Move getPos _unit; %1 doFire _unit", _x]} forEach coparray
{call format ["%1 setSpeedMode ""FULL""; %1_car setFuel 1; %1_car setDamage 0", _x]} forEach coparray


if (!alive _unit) then { goto "exit" }
~5.0
goto "criminal_loop"



#exit
Exit

Walter_E_Kurtz

  • Guest
I've never seen the AI drive aggressively; most often stupidly and, on rare occassions, competently.

Try using setVelocity and Velocity to hamper the perp, and give the cops a boost.
Code: [Select]
copcar setVelocity [(velocity copcar select 0) * 1.05, (velocity copcar select 1) * 1.05, (velocity copcar select 2)NB. Use a multiplication factor, to increase speed by a percentage, rather than adding to speed in any dimension.


Regarding targeting of the perp outside the car; I suspect it has to do with the doFire _unit command, which only loops around every five seconds. You might consider adding a command to fire on the vehicle, if the perp is still in it:
Code: [Select]
? (vehicle _unit != _unit): copman doFire vehicle _unit
However, first I'd try addRating -10000 to the perp once they become a criminal, and seeing if that doesn't help.


I think you should break down the #criminal_loop into two (or maybe three) phases:
1. initiate vehicular pursuit (if appropriate)
2. specifics of vehicular pursuit (speed boosts)
     I think %1 doFollow _unit may be conflicting with %1 Move getPos _unit otherwise
3. on foot and takedown
« Last Edit: 01 Dec 2008, 04:10:28 by Walter_E_Kurtz »

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
For the chase, take a look at Mando_Chaser in the scripts area.

With Mando_Chaser, the chaser vehicle will relentlessly chase the chased, until they smash into them.  You can modify it so that it reduces its speed when too close to chased to prevent the crash if you like.

Only problem with the script is you need to run it in open areas or on straight roads only.  If the chased vehicle turns a hard corner, mando_chaser will force the chasing vehicle to bee-line for the chased vehicle.  This means it will try to crash through any object in between (buildings, walls, trees, whatever).

Bottom line:  Mando_chaser is great if Mission Designer controls the chase sequence (i.e., a cutscene, or only occurs in certain areas).  If it needs to be dynamic, and the player is controls the chased vehicle, then the chaser will likely crash into objects (not a realistic outcome).
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Acecool

  • Members
  • *
Yeah, I attached my passive turbo script to the cops, but they still dont drive as fast.. I guess I can control it manually based on direction of the player...