Page 1 of 1

problem with SET CHAR OBJECTIVE

Posted: 26 Aug 2009, 10:00
by Shazdeh
I was trying to create a mission where you had to pick someone up and drive him around the city so he could kill his victims. So first you have to pick up a car, goto desired location and sound the horn so he know who you are and he will get in the car. Problem is that when I sound the horn, he scares and run away! I set the char objective to get in the car but it seems that the game changes it. (to FLEE_ON_FOOT_TILL_SAFE) he scares and run but when he goes out of the screen, if you dont sound the horn again will get in the car.
I tried set bravery of the char but it didn't work.
How can I force him to get in the car?

Re: problem with SET CHAR OBJECTIVE

Posted: 26 Aug 2009, 12:43
by Razor
Can you paste script?

Firstly you should set a good behavior to him
eg:

Code: Select all

army1 = CREATE_CHAR ( 197.5 , 153.8 , 2.0  )  2  180  [b]GUARD_AGAINST_PLAYER[/b] END
Read: http://projectcerbera.com/gta/2/tutorials/character-ai

And add line above:

Code: Select all

SET_CHAR_THREAT_REACTION ( army1 , [b]REACT_AS_NORMAL[/b] )

Re: problem with SET CHAR OBJECTIVE

Posted: 26 Aug 2009, 17:47
by Shazdeh
Thanks! i haven't tried it yet but I will.
In fact I lost my mission script file and that's why I didn't paste the code here.

Can I force all cars to drive crazy? You see, when green peds steal a car and drive it, if you are in their way they just keep going but normal peds don't. Can I make all cars to be like this?

Re: problem with SET CHAR OBJECTIVE

Posted: 27 Aug 2009, 00:11
by Gustavob
you can also try to make a group (see page 96 - Frequently Asked Questions - in GTA2 Scripting.doc) when player is sounding horn (IF (IS_CHAR_PRESSING_HORN_ONSCREEN (playername) or sthg like this) and set the char threat reaction (SET_CHAR_THREAT_REACTION (charname, REACT_AS_NORMAL) ), as Razor said.

try to remake the mission and post the code here then we can help more :)

About making drivers get crazy like car thieves, im sure its not possible

Re: problem with SET CHAR OBJECTIVE

Posted: 27 Aug 2009, 14:28
by Shazdeh
It worked! Thanks!

here's the code I used to test it:

Code: Select all

PLAYER_PED player = (44.0, 102.0, 2.0) 27 0

OBJ_DATA testphone = (46.0 , 102.0 , 2.0 ) 0 phone 
FORWARD answer_phone_1:
THREAD_TRIGGER thread_phone_1 = THREAD_WAIT_FOR_ANSWER_PHONE ( player , testphone , answer_phone_1: )

CHAR_DATA bastard1

answer_phone_1:

bastard1 = CREATE_CHAR ( 30.0 , 91.0 ) 10  160  GUARD_AGAINST_PLAYER  END
SET_CHAR_THREAT_REACTION ( bastard1 , REACT_AS_NORMAL )

RETURN


LEVELSTART 


LEVELEND
What is GUARD_AGAINST_PLAYER ? i found nothing in documents...

Re: problem with SET CHAR OBJECTIVE

Posted: 27 Aug 2009, 21:53
by Gustavob
http://en.wikigta.org/wiki/Code_lists_% ... ccupations

GUARD_AGAINST_PLAYER is the same as the simple GUARD, but attacks the player. but as you set the objective of the AI Char, it doesnt attack you

Re: problem with SET CHAR OBJECTIVE

Posted: 28 Aug 2009, 00:37
by Shazdeh
I was playing around with THREAT_SEARCH and THREAD_REACTION and they were awesome! These command works fine when character is on foot, but don't work when char has a car.

Code: Select all

tank1 = CREATE_CAR (28.0  , 122.0 )  -1 90 TANK END
bastard1  =  CREATE_CHAR_INSIDE_CAR  ( tank1  ) 4  GUARD  END
SET_CHAR_THREAT_SEARCH ( bastard1 , AREA)
SET_CHAR_THREAT_REACTION  (  bastard1  , REACT_AS_NORMAL ) 
The tank just move and ignores me!
Remember a mission in level 3 that there were some crazy tanks in the city and you should destroy them? Those tanks
drove in the city and when they spotted you, they fired. How can I have the same occupation?
One last thing! The tank in the code above drives really fast. Have any idea why?

Re: problem with SET CHAR OBJECTIVE

Posted: 28 Aug 2009, 01:07
by Gustavob
Shazdeh wrote: The tank just move and ignores me!
Remember a mission in level 3 that there were some crazy tanks in the city and you should destroy them? Those tanks
drove in the city and when they spotted you, they fired. How can I have the same occupation?
One last thing! The tank in the code above drives really fast. Have any idea why?
Take a look at bil.mis (uncompiled Industrial District script, look for it at http://gtamp.com/gta2 . I dont remember for what gang is this job, but look for the mission file bil_<firstgangletter><easy/medium/hard first letter><1/2/3>.mis ) and try to find this part, then find the chars commands

To fix the tank super speed, do:

Code: Select all

IF (IS_CHARACTER_IN_CAR (charname , tank1) )
SET_CHAR_MAX_DRIVESPEED (charname , 100)
ENDIF
then the char drives at the max speed of the tank when player drives it (100 blocks per minute)

Re: problem with SET CHAR OBJECTIVE

Posted: 28 Aug 2009, 11:02
by Shazdeh
You mean the bil.mis file that comes with "gta2script"? This file has problem: I can't compile it... Or is there another source code?

Thanks for max speed, I'll check it out.

Re: problem with SET CHAR OBJECTIVE

Posted: 28 Aug 2009, 13:05
by Sektor
You don't have to compile bil.mis and bil\*.mis to copy code from it. It won't compile with mispad but it compiles with the official compiler.

You might just have to put a tank_driver in a tank instead of some other type of ped. You also have to tell them to attack from vehicle.

Here's some old Tank Attack script I wrote. I haven't tested it.

Code: Select all

//Created by Sektor - GTAMP.com on 29/02/2008
//This script is public domain. You can use it freely.
//tested with bil.sty and bil.gmp

PLAYER_PED p1 = (90.0, 93.0, 255.0) 10 0
car_data tank1
car_data tank2
car_data tank3
car_data tank4
car_data tank5
CHAR_DATA dude1
CHAR_DATA dude2
CHAR_DATA dude3
CHAR_DATA dude4
CHAR_DATA dude5

COUNTER loop = 1
DECLARE_POLICELEVEL ( 5 )

LEVELSTART 

DISPLAY_MESSAGE ( 3852 )
//create tanks
tank1 = CREATE_CAR ( 90.0 , 91.0 ) -1 0 tank END
tank2 = CREATE_CAR ( 91.0 , 91.0 ) -1 0 tank END
tank3 = CREATE_CAR ( 92.0 , 91.0 ) -1 0 tank END
tank4 = CREATE_CAR ( 94.0 , 91.0 ) -1 0 tank END
tank5 = CREATE_CAR ( 95.0 , 91.0 ) -1 0 tank END

SET_CAR_ROCKETPROOF ( tank1 , ON ) // make tank1 rocket proof
SET_CAR_ROCKETPROOF ( tank2 , ON ) // make tank2 rocket proof
SET_CAR_ROCKETPROOF ( tank3 , ON ) // make tank3 rocket proof
SET_CAR_ROCKETPROOF ( tank4 , ON ) // make tank4 rocket proof
SET_CAR_ROCKETPROOF ( tank5 , ON ) // make tank5 rocket proof
CHANGE_CAR_LOCK ( tank1 , locked ) // lock tank1
CHANGE_CAR_LOCK ( tank2 , locked ) // lock tank2
CHANGE_CAR_LOCK ( tank3 , locked ) // lock tank3
CHANGE_CAR_LOCK ( tank4 , locked ) // lock tank4
CHANGE_CAR_LOCK ( tank5 , locked ) // lock tank5

//create dudes inside tanks
dude1 = CREATE_CHAR_INSIDE_CAR ( tank1 ) 8 tank_driver END
dude2 = CREATE_CHAR_INSIDE_CAR ( tank2 ) 8 tank_driver END
dude3 = CREATE_CHAR_INSIDE_CAR ( tank3 ) 8 tank_driver END
dude4 = CREATE_CHAR_INSIDE_CAR ( tank4 ) 8 tank_driver END
dude5 = CREATE_CHAR_INSIDE_CAR ( tank5 ) 8 tank_driver END

//set their skills and give them orders
SET_CHAR_SHOOTING_SKILL ( dude1 , crack_shot ) 
SET_CHAR_SHOOTING_SKILL ( dude2 , crack_shot ) 
SET_CHAR_SHOOTING_SKILL ( dude3 , crack_shot ) 
SET_CHAR_SHOOTING_SKILL ( dude4 , crack_shot ) 
SET_CHAR_SHOOTING_SKILL ( dude5 , crack_shot ) 
SET_CHAR_BRAVERY_LEVEL ( dude1 , loony ) 
SET_CHAR_BRAVERY_LEVEL ( dude2 , loony ) 
SET_CHAR_BRAVERY_LEVEL ( dude3 , loony ) 
SET_CHAR_BRAVERY_LEVEL ( dude4 , loony ) 
SET_CHAR_BRAVERY_LEVEL ( dude5 , loony ) 
SET_CHAR_THREAT_SEARCH ( dude1 , no_threats )
SET_CHAR_THREAT_SEARCH ( dude2 , no_threats )
SET_CHAR_THREAT_SEARCH ( dude3 , no_threats )
SET_CHAR_THREAT_SEARCH ( dude4 , no_threats )
SET_CHAR_THREAT_SEARCH ( dude5 , no_threats )
SET_CHAR_THREAT_REACTION ( dude1 , no_reaction )
SET_CHAR_THREAT_REACTION ( dude2 , no_reaction )
SET_CHAR_THREAT_REACTION ( dude3 , no_reaction )
SET_CHAR_THREAT_REACTION ( dude4 , no_reaction )
SET_CHAR_THREAT_REACTION ( dude5 , no_reaction )
SET_CHAR_DRIVE_AGGRESSION ( dude1 , on )
SET_CHAR_DRIVE_AGGRESSION ( dude2 , on )
SET_CHAR_DRIVE_AGGRESSION ( dude3 , on )
SET_CHAR_DRIVE_AGGRESSION ( dude4 , on )
SET_CHAR_DRIVE_AGGRESSION ( dude5 , on )
SET_CHAR_TO_USE_CAR_WEAPON ( dude1 , ON )
SET_CHAR_TO_USE_CAR_WEAPON ( dude2 , ON )
SET_CHAR_TO_USE_CAR_WEAPON ( dude3 , ON )
SET_CHAR_TO_USE_CAR_WEAPON ( dude4 , ON )
SET_CHAR_TO_USE_CAR_WEAPON ( dude5 , ON )
SET_CHAR_TO_STAY_IN_CAR ( dude1 , ON ) 
SET_CHAR_TO_STAY_IN_CAR ( dude2 , ON ) 
SET_CHAR_TO_STAY_IN_CAR ( dude3, ON ) 
SET_CHAR_TO_STAY_IN_CAR ( dude4 , ON ) 
SET_CHAR_TO_STAY_IN_CAR ( dude5 , ON ) 

WHILE_EXEC ( loop = 1 ) // the basic loop

GIVE_WEAPON ( p1, rocket_launcher ) // constantly give the player rockets

//constantly tell the dudes to kill the player
IF ( IS_CHARACTER_IN_ANY_CAR ( dude1 ) )
  SET_CHAR_OBJECTIVE ( dude1 , kill_char_any_means, p1 )
ENDIF
IF ( IS_CHARACTER_IN_ANY_CAR ( dude2 ) )
  SET_CHAR_OBJECTIVE ( dude2 , kill_char_any_means, p1 )
ENDIF
IF ( IS_CHARACTER_IN_ANY_CAR ( dude3 ) )
  SET_CHAR_OBJECTIVE ( dude3 , kill_char_any_means, p1 )
ENDIF
IF ( IS_CHARACTER_IN_ANY_CAR ( dude4 ) )
  SET_CHAR_OBJECTIVE ( dude4 , kill_char_any_means, p1 )
ENDIF
IF ( IS_CHARACTER_IN_ANY_CAR ( dude5 ) )
  SET_CHAR_OBJECTIVE ( dude5 , kill_char_any_means, p1 )
ENDIF

ENDWHILE

LEVELEND

Re: problem with SET CHAR OBJECTIVE

Posted: 29 Aug 2009, 11:57
by Shazdeh
Thanks! So, to actually attack the player they must have an objective. Problem solved.
I had a really fun time playing Sektor's script. Did you ever finished it and make a full map out of it?

Re: problem with SET CHAR OBJECTIVE

Posted: 29 Aug 2009, 12:09
by Sektor
I never finished it. It was made for a level based on Atari Battlezone (green wireframe buildings/obstacles on a black background). The author only sent a video of the map and not the actual map. The script didn't work on that map since it had no roads and the AI can't chase you in a vehicle without roads.