Difference between revisions of "Decision Maker"

From GTAMods Wiki
Jump to navigation Jump to search
m (Example)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Decision Makers defines how peds reacts to certain events under certain circumstances. Default decision makers are located in the '''''data/decision/allowed''''' [[San Andreas]] directory. Decision makers can also be created by scripting to change how script peds deals with situations.
+
A '''decision maker''' defines how peds react to certain events under certain circumstances. Default decision makers are located in the <code>data/decision/allowed</code> [[San Andreas]] directory. Decision makers can also be created by [[#Scripting |scripting]] to change how script peds deals with situations.
  
 
== Format and Basics ==
 
== Format and Basics ==
  
The default decision maker files present in the [[San Andreas]] directory can be either in '''''.ped''''' or '''''.grp''''' extension. The first defines decisions for individual ped types and the later for a group of peds.
+
The default decision maker files present in the [[San Andreas]] directory can be either in <code>.ped</code> or <code>.grp</code> extension. The first defines decisions for individual ped types and the latter for a group of peds.
  
 
The files can be edited by using a text editor, but a spreadsheet software is heavily recommended due to the ''bad formating'' of the file.
 
The files can be edited by using a text editor, but a spreadsheet software is heavily recommended due to the ''bad formating'' of the file.
  
Each line is a event type and it's reaction to it. The line begins with:
+
The first line of the file is ignored, comments are not supported, and commas must be used.
{|{{Prettytable}}
+
 
 +
Each line is an event type and it's reaction to it. The line begins with:
 +
{|class="wikitable"
 
!Column
 
!Column
 
!Description
 
!Description
Line 20: Line 22:
  
 
Followed by the 6 possible responses to the event with the format:
 
Followed by the 6 possible responses to the event with the format:
{|{{Prettytable}}
+
{|class="wikitable"
 
!C1
 
!C1
 
!C2
 
!C2
Line 43: Line 45:
 
| BD
 
| BD
 
| BQ
 
| BQ
| Change of executing this response when the event trigger is a friendly ped (i.e. on it's respect/like list)
+
| Chance of executing this response when the event trigger is a friendly ped (i.e. on it's respect/like list)
 
|-
 
|-
 
| E
 
| E
Line 51: Line 53:
 
| BE
 
| BE
 
| BR
 
| BR
| Change of executing this response when the event trigger is a threat ped (i.e. on it's hate/dislike list)
+
| Chance of executing this response when the event trigger is a threat ped (i.e. on it's hate/dislike list)
 
|-
 
|-
 
| F
 
| F
Line 59: Line 61:
 
| BF
 
| BF
 
| BS
 
| BS
| Change of executing this response when the event trigger is the player ped
+
| Chance of executing this response when the event trigger is the player ped
 
|-
 
|-
 
| G
 
| G
Line 67: Line 69:
 
| BG
 
| BG
 
| BT
 
| BT
| Change of executing this response when the event trigger is not a ped, or a neutral ped (i.e. not on the relationship list).
+
| Chance of executing this response when the event trigger is not a ped, or a neutral ped (i.e. not on the relationship list).
 
|-
 
|-
 
| H
 
| H
Line 136: Line 138:
 
==== Rules ====
 
==== Rules ====
  
* The used event should be registered in [[#PedEvent.txt]] to work.
+
* The used event should be registered in [[#PedEvent.txt|PedEvent.txt]] to work.
 
* The chance should be in the range between 0 and 100. It's percentage of ''actual chance'' is calculated based on the sum of all the chances. For example, if we have 2 responses with a 100.0 chance when the trigger is friendly, each of those response will have a 50% of chance since 100.0 is 50% of the sum of the friendly responses (200.0).
 
* The chance should be in the range between 0 and 100. It's percentage of ''actual chance'' is calculated based on the sum of all the chances. For example, if we have 2 responses with a 100.0 chance when the trigger is friendly, each of those response will have a 50% of chance since 100.0 is 50% of the sum of the friendly responses (200.0).
 
* To ignore one response parameter all it's value shall be set to 0 except for task id that shall be set to -1.
 
* To ignore one response parameter all it's value shall be set to 0 except for task id that shall be set to -1.
Line 145: Line 147:
 
=== PedEvent.txt ===
 
=== PedEvent.txt ===
  
This file, in the directory ''data/decision'', is a enumeration file used to assign a internal index to a specific task id so it can be used as a event to be responded.
+
This file, in the directory <code>data/decision</code>, is a enumeration file used to assign a internal index to a specific task id so it can be used as a event to be responded.
 
There should be a maximum of 41 entries and modifying it isn't recommended.
 
There should be a maximum of 41 entries and modifying it isn't recommended.
 
Each line contains a string and a task id, the string is ignored, only the task id matters.
 
Each line contains a string and a task id, the string is ignored, only the task id matters.
Line 152: Line 154:
  
 
The following line can be found in R_Norm.ped in response to the event 15, EVENT_PED_ENTERED_MY_VEHICLE.
 
The following line can be found in R_Norm.ped in response to the event 15, EVENT_PED_ENTERED_MY_VEHICLE.
<code>17,4,706,50.000000,50.000000,50.000000,50.000000,1,1,0,0,0,0,0,0,708,50.000000,50.000000,50.000000,50.000000,1,1,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,</code>
+
<code style='overflow:auto;display:block;'>17,4,706,50.000000,50.000000,50.000000,50.000000,1,1,0,0,0,0,0,0,708,50.000000,50.000000,50.000000,50.000000,1,1,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,</code>
 
When formatted properly we get those possible responses:
 
When formatted properly we get those possible responses:
{|{{Prettytable}}
+
{|class="wikitable"
 
!Task
 
!Task
 
!Chance On Friend Trigger
 
!Chance On Friend Trigger
Line 180: Line 182:
 
|}
 
|}
  
What do we have here is, if you enter the vehicle the ped is occupying, he'll either leave the car and flee or scream and leave, as you may be aware that's exactly how the random peds react when you enter in their vehicles.
+
What do we have here is, if you enter the vehicle the ped is occupying, they will either leave the car and flee or scream and leave, as you may be aware that's exactly how the random peds react when you enter in their vehicles.
  
 
== Scripting ==
 
== Scripting ==
Line 186: Line 188:
 
Decision makers can be created and managed through scripts using the following commands:
 
Decision makers can be created and managed through scripts using the following commands:
  
* [[060A]] &ndash; Loads a pre-defined decision maker from a file
+
* [[060A|060A (LOAD_CHAR_DECISION_MAKER)]] &ndash; Loads a pre-defined decision maker from a file
* [[06AE]] &ndash; Loads a pre-defined group decision maker from a file
+
* [[060B|060B (SET_CHAR_DECISION_MAKER)]] &ndash; Sets the decision maker for a character
* [[065C]] &ndash; Frees the previously loaded decision maker
+
* [[065C|065C (CLEAR_ALL_DECISION_MAKERS)]] &ndash; Frees the previously loaded decision maker
* [[09F2]] &ndash; Checks if a decision maker exists
+
* [[06AD|06AD (SET_GROUP_DECISION_MAKER)]] &ndash; Sets the group decision maker for a group
* [[07E5]] &ndash; Clones a decision maker
+
* [[06AE|06AE (LOAD_GROUP_DECISION_MAKER)]] &ndash; Loads a pre-defined group decision maker from a file
* [[07E6]] &ndash; Clones a group decision maker
+
* [[0708|0708 (CLEAR_CHAR_DECISION_MAKER_EVENT_RESPONSE)]] &ndash; Clears the responses to a certain event in a decision maker
* [[0978]] &ndash; Clones a decision maker shared between characters, essentially cloning a reference not the entire maker
+
* [[0709|0709 (ADD_CHAR_DECISION_MAKER_EVENT_RESPONSE)]] &ndash; Adds a event response to a decision maker (max 6 responses per event)
* [[060B]] &ndash; Sets the decision maker for a character
+
* [[0749|0749 (CLEAR_GROUP_DECISION_MAKER_EVENT_RESPONSE)]] &ndash; Clears the responses to a certain event in a group decision maker
* [[06AD]] &ndash; Sets the group decision maker for a group
+
* [[074A|074A (ADD_GROUP_DECISION_MAKER_EVENT_RESPONSE)]] &ndash; Adds a event response to a group decision maker (max 6 responses per event)
* [[0709]] &ndash; Adds a event response to a decision maker (max 6 responses per event)
+
* [[07E5|07E5 (COPY_CHAR_DECISION_MAKER)]] &ndash; Clones a decision maker
* [[0708]] &ndash; Clears the responses to a certain event in a decision maker
+
* [[07E6|07E6 (COPY_GROUP_DECISION_MAKER)]] &ndash; Clones a group decision maker
* [[074A]] &ndash; Adds a event response to a group decision maker (max 6 responses per event)
+
* [[0978|0978 (COPY_SHARED_CHAR_DECISION_MAKER)]] &ndash; Clones a decision maker shared between characters, essentially cloning a reference not the entire maker
* [[0749]] &ndash; Clears the responses to a certain event in a group decision maker
+
* [[09F2|09F2 (DOES_DECISION_MAKER_EXIST)]] &ndash; Checks if a decision maker exists
  
 
== Default Decision Makers ==
 
== Default Decision Makers ==
Line 204: Line 206:
 
Here is a listing of the available default decision makers, their use and their id usable in [[pedstats.dat]].
 
Here is a listing of the available default decision makers, their use and their id usable in [[pedstats.dat]].
  
{|{{Prettytable}}
+
{|class="wikitable"
 
!Filename
 
!Filename
 
!Id
 
!Id
Line 211: Line 213:
 
| GangMbr.ped
 
| GangMbr.ped
 
| 0
 
| 0
| ...?
+
| ?
 
|-
 
|-
 
| Cop.ped
 
| Cop.ped
Line 288: Line 290:
 
{{N|SA}}
 
{{N|SA}}
 
[[Category:File Formats]][[Category:Pedestrian Formats]]
 
[[Category:File Formats]][[Category:Pedestrian Formats]]
[[Category:GTA SA]]
 

Latest revision as of 12:27, 15 May 2021

A decision maker defines how peds react to certain events under certain circumstances. Default decision makers are located in the data/decision/allowed San Andreas directory. Decision makers can also be created by scripting to change how script peds deals with situations.

Format and Basics

The default decision maker files present in the San Andreas directory can be either in .ped or .grp extension. The first defines decisions for individual ped types and the latter for a group of peds.

The files can be edited by using a text editor, but a spreadsheet software is heavily recommended due to the bad formating of the file.

The first line of the file is ignored, comments are not supported, and commas must be used.

Each line is an event type and it's reaction to it. The line begins with:

Column Description
A The event to react to.
B Unused. Always 4.

Followed by the 6 possible responses to the event with the format:

C1 C2 C3 C4 C5 C6 Description
C P AC AP BC BP Task to perform in response to the event.
D Q AD AQ BD BQ Chance of executing this response when the event trigger is a friendly ped (i.e. on it's respect/like list)
E R AE AR BE BR Chance of executing this response when the event trigger is a threat ped (i.e. on it's hate/dislike list)
F S AF AS BF BS Chance of executing this response when the event trigger is the player ped
G T AG AT BG BT Chance of executing this response when the event trigger is not a ped, or a neutral ped (i.e. not on the relationship list).
H U AH AU BH BU A boolean specifying whether the task should be performed when the ped is on a vehicle
I V AI AV BI BV A boolean specifying whether the task should be performed when the ped is on foot
J W AJ AW BJ BW Unused.
K X AK AX BK BX Unused.
L Y AL AY BL BY Unused.
M Z AM AZ BM BZ Unused.
N AA AN AA BN BA Unused.
O AB AO AB BO BB Unused.

Rules

  • The used event should be registered in PedEvent.txt to work.
  • The chance should be in the range between 0 and 100. It's percentage of actual chance is calculated based on the sum of all the chances. For example, if we have 2 responses with a 100.0 chance when the trigger is friendly, each of those response will have a 50% of chance since 100.0 is 50% of the sum of the friendly responses (200.0).
  • To ignore one response parameter all it's value shall be set to 0 except for task id that shall be set to -1.
  • Every token should be delimited by commas (',') unlike the other data files that commas are optional.

Although Rockstar ignored some of those rules in some lines, it's a mistake/bug, so be careful.

PedEvent.txt

This file, in the directory data/decision, is a enumeration file used to assign a internal index to a specific task id so it can be used as a event to be responded. There should be a maximum of 41 entries and modifying it isn't recommended. Each line contains a string and a task id, the string is ignored, only the task id matters.

Example

The following line can be found in R_Norm.ped in response to the event 15, EVENT_PED_ENTERED_MY_VEHICLE. 17,4,706,50.000000,50.000000,50.000000,50.000000,1,1,0,0,0,0,0,0,708,50.000000,50.000000,50.000000,50.000000,1,1,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0,-1,0.0,0.0,0.0,0.0,0,0,0,0,0,0,0,0, When formatted properly we get those possible responses:

Task Chance On Friend Trigger Chance On Threat Trigger Chance On Player Trigger Chance On Other Triggers In Car On Foot
TASK_COMPLEX_LEAVE_CAR_AND_FLEE 50% 50% 50% 50% true true
TASK_COMPLEX_SCREAM_IN_CAR_THEN_LEAVE 50% 50% 50% 50% true true

What do we have here is, if you enter the vehicle the ped is occupying, they will either leave the car and flee or scream and leave, as you may be aware that's exactly how the random peds react when you enter in their vehicles.

Scripting

Decision makers can be created and managed through scripts using the following commands:

Default Decision Makers

Here is a listing of the available default decision makers, their use and their id usable in pedstats.dat.

Filename Id Description
GangMbr.ped 0 ?
Cop.ped 1 Used for cop responses.
R_Norm.ped 2 Used for random normal peds responses.
R_Tough.ped 3 Used for random tough peds responses.
R_Weak.ped 4 Used for random coward peds responses.
Fireman.ped 5 Used for fireman responses.
m_empty.ped 6 Basic collision responses only. Seems like a template.
InDoors.ped 7 Used for peds spawned in interiors?
RANDOM.grp 8 ?
RANDOM2.grp 9 ?
RANDOM.ped N/A Fallback decision maker used when peds lost their decision makers?
m_plyr.ped N/A Used for the player?
m_empty.ped N/A Empty decision maker for scripting. Accessible by scripting by loading a decision maker of type 0.
m_norm.ped N/A Normal decision maker for scripting. Accessible by scripting by loading a decision maker of type 1.
m_tough.ped N/A Tough decision maker for scripting. Accessible by scripting by loading a decision maker of type 2.
m_weak.ped N/A Coward decision maker for scripting. Accessible by scripting by loading a decision maker of type 3.
m_steal.ped N/A Patrolling decision maker for scripting. Accessible by scripting by loading a decision maker of type 4.
MISSION.grp N/A Basic group used on mission scripts. Accessible by scripting by loading a group decision maker of type 0.

See also

  • ped.dat – Defines the relationship of friend/threat/neutral between ped types
  • pedstats.dat – Defines the decision maker for each kind of ped.