Added "get/set_object_data" and "get_object_ai_data" script functions (from Mr.Stalin)

Changed read_byte, read_short, read_int, and read_string functions to not require AllowUnsafeScripting.
This commit is contained in:
NovaRain
2018-12-05 10:14:10 +08:00
parent 65755911f4
commit 4249006ba9
10 changed files with 220 additions and 12 deletions
+92 -1
View File
@@ -267,7 +267,98 @@
#define WPN_ANIM_MINIGUN (0x09) // (L)
#define WPN_ANIM_ROCKET_LAUNCHER (0x0A) // (M)
// Compute attack result fields
// AI data parameters
#define AI_CAP_AGGRESSION (0)
#define AI_CAP_AREA_ATTACK_MODE (1)
#define AI_CAP_ATTACK_WHO (2)
#define AI_CAP_BEST_WEAPON (3)
#define AI_CAP_CHEM_USE (4)
#define AI_CAP_DISPOSITION (5)
#define AI_CAP_DISTANCE (6)
#define AI_CAP_MAX_DISTANCE (7)
#define AI_CAP_MIN_HP (8)
#define AI_CAP_MIN_TO_HIT (9)
#define AI_CAP_HURT_TOO_MUCH (10) // DAM_BLIND/DAM_CRIP_* flags
#define AI_CAP_RUN_AWAY_MODE (11)
#define AI_CAP_SECONDARY_FREQ (12)
#define AI_CAP_CALLED_FREQ (13)
#define AI_CAP_CHEM_PRIMARY_DESIRE (14) // array pid list
// AI attack area mode values
#define ai_area_always (0)
#define ai_area_sometimes (1)
#define ai_area_be_sure (2)
#define ai_area_be_careful (3)
#define ai_area_be_absolutely_sure (4)
// AI attack who mode values
#define ai_attack_no_pref (-1)
#define ai_attack_whomever_attacking_me (0)
#define ai_attack_strongest (1)
#define ai_attack_weakest (2)
#define ai_attack_whomever (3)
#define ai_attack_closest (4)
// AI run away mode values
#define ai_run_away_none (0)
#define ai_run_away_coward (1)
#define ai_run_away_finger_hurts (3)
#define ai_run_away_bleeding (4)
#define ai_run_away_not_feeling_good (5)
#define ai_run_away_tourniquet (6)
#define ai_run_away_never (7)
// AI disposition values
#define ai_disposition_none (0)
#define ai_disposition_custom (1)
#define ai_disposition_coward (2)
#define ai_disposition_defensive (3)
#define ai_disposition_aggressive (4)
#define ai_disposition_berserk (5)
// AI distance values
#define ai_distance_stay_close (0)
#define ai_distance_charge (1)
#define ai_distance_snipe (2)
#define ai_distance_on_your_own (3)
#define ai_distance_stay (4)
// AI best weapon pref values
#define ai_weapon_no_pref (0)
#define ai_weapon_melee (1)
#define ai_weapon_melee_over_ranged (2)
#define ai_weapon_ranged_over_melee (3)
#define ai_weapon_ranged (4)
#define ai_weapon_unarmed (5)
#define ai_weapon_unarmed_over_thrown (6)
#define ai_weapon_random (7)
// AI chem use mode values
#define ai_chem_clean (0)
#define ai_chem_stims_when_hurt_little (1) // use only stimpak/super stimpak/healing powder
#define ai_chem_stims_when_hurt_lots (2) // use only stimpak/super stimpak/healing powder
#define ai_chem_sometimes (3)
#define ai_chem_anytime (4)
#define ai_chem_always (5)
// common object data offsets
#define OBJ_DATA_TILENUM (0x04)
#define OBJ_DATA_CUR_FRM (0x18) // current frame number
#define OBJ_DATA_ROTATION (0x1C)
#define OBJ_DATA_FID (0x20)
#define OBJ_DATA_ELEVATION (0x28)
#define OBJ_DATA_PID (0x64)
#define OBJ_DATA_CID (0x68)
#define OBJ_DATA_SID (0x78)
// items
#define OBJ_DATA_CUR_CHARGES (0x3C)
// critters
#define OBJ_DATA_COMBAT_STATE (0x3C) // flags: 1 - combat, 2 - target is out of range, 4 - flee
#define OBJ_DATA_CUR_ACTION_POINT (0x40)
#define OBJ_DATA_DAMAGE_LAST_TURN (0x48)
#define OBJ_DATA_WHO_HIT_ME (0x54)
// compute attack result data offsets
#define C_ATTACK_SOURCE (0x00)
#define C_ATTACK_HIT_MODE (0x04)
#define C_ATTACK_WEAPON (0x08)
+3
View File
@@ -246,6 +246,8 @@
#define get_ini_section(file, sect) sfall_func2("get_ini_section", file, sect)
#define get_ini_sections(file) sfall_func1("get_ini_sections", file)
#define get_map_enter_position sfall_func0("get_map_enter_position")
#define get_object_ai_data(obj, aiParam) sfall_func2("get_object_ai_data", obj, aiParam)
#define get_object_data(obj, offset) sfall_func2("get_object_data", obj, offset)
#define get_outline(obj) sfall_func1("get_outline", obj)
#define get_string_pointer(text) sfall_func1("get_string_pointer", text)
#define intface_hide sfall_func0("intface_hide")
@@ -268,6 +270,7 @@
#define set_iface_tag_text(tag, text, color) sfall_func3("set_iface_tag_text", tag, text, color)
#define set_ini_setting(setting, value) sfall_func2("set_ini_setting", setting, value)
#define set_map_enter_position(tile, elev, rot) sfall_func3("set_map_enter_position", tile, elev, rot)
#define set_object_data(obj, offset, value) sfall_func3("set_object_data", obj, offset, value)
#define set_outline(obj, color) sfall_func2("set_outline", obj, color)
#define set_rest_heal_time(time) sfall_func1("set_rest_heal_time", time)
#define set_rest_mode(mode) sfall_func1("set_rest_mode", mode)
+1 -1
View File
@@ -598,7 +598,7 @@ int arg6 - Target's Damage Resistance (DR) value (affected by critical hit e
int arg7 - Target's Damage Threshold (DT) value (affected by critical hit effects, perks, traits, and special unarmed attacks)
int arg8 - Bonus ranged damage from the perk
int arg9 - Damage Multiplier (this is divided by 2, so a value of 3 does 1.5x damage, and 8 does 4x damage. Usually it's 2; for critical hits, the value is taken from the critical table; with Silent Death perk and the corresponding attack conditions, the value will be doubled)
int arg10 - Combat Difficulty multiplier (125 - rough, 100 - normal, 75 - wimpy)
int arg10 - Combat Difficulty multiplier (125 - rough, 100 - normal, 75 - wimpy; for player or party members it's always 100)
int arg11 - The calculated amount of damage (usually 0, required when using multiple hook scripts to calculate damage and using the set_sfall_arg function)
mixed arg12 - Computed attack results (see C_ATTACK_* for offsets and use read_int(arg12 + offset) to get the data)
@@ -550,6 +550,16 @@ Some utility/math functions are available:
> object sfall_func0("loot_obj")
- returns a pointer to the target object (container or critter) of the loot screen
> int sfall_func2("get_object_data", object, int offset)
- returns the data at the specified offset of an object (see OBJ_DATA_* constants in define_extra.h for offsets)
> void sfall_func3("set_object_data", object, int offset, int data)
- sets the data at the specified offset of an object
> int sfall_func2("get_object_ai_data", object, int aiParam)
- returns the setting value from the AI packet of an object (critter)
- use AI_CAP_* constants from define_extra.h for the aiParam argument to get AI value
------------------------
------ MORE INFO -------
------------------------
+4 -4
View File
@@ -1,8 +1,8 @@
*0x8156 - int read_byte(int address)
*0x8157 - int read_short(int address)
*0x8158 - int read_int(int address)
*0x8159 - string read_string(int address)
0x8156 - int read_byte(int address)
0x8157 - int read_short(int address)
0x8158 - int read_int(int address)
0x8159 - string read_string(int address)
*0x81cf - void write_byte(int address, int value)
*0x81d0 - void write_short(int address, int value)