Added full ddraw.ini + other config files and all relevant artifacts from latest modderspack.

This commit is contained in:
VladislavKolosovsky
2015-07-07 00:44:58 +07:00
parent cafa0158a7
commit b82348ed33
65 changed files with 5078 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
This folder contains documentation about sfall scripting extensions.
headers\ - folder contains sfall headers that you should #include in your scripts
sfall.h - main sfall header, always include it
define_extra.h - some additional preprocessor constants for vanilla engine stuff (proto offsets, etc.)
dik.h - DX scancodes constants for use with key_pressed function and HOOK_KEYPRESS
sfall function notes.txt - incomplete reference for new opcodes
sfall function list.txt - list of all sfall opcodes (w/o descriptions)
hookscripts.txt - detailed manual for using hook scripts to modify engine behavior
arrays.txt - manual for sfall arrays
If you are/will be using sfall Script Editor, don't forget to check out new compiler documentation in ScriptEditor\docs\sslc_readme.txt,
there are numerious new syntax features and extensions to SSL (Star-Trek Scripting language).
+229
View File
@@ -0,0 +1,229 @@
>>> ARRAYS CONCEPT <<<
Sfall introduces new method of storing variables - arrays.
Array is basically a container which can store variable number of values (elements). Each element in array can be of any type.
Arrays can be extremely useful for some more advanced scripting, in conjunction with loops.
Array elements are accessed by index or key. For example:
// this code puts some string in array "list" at index 5:
list[5] := "Value";
There are 2 different types of arrays currently available:
1) Lists - a set of values with specific size (number of elements), where all elements have numeric indexes starting from zero (0) up to array length minus one.
For example:
// this creates list with 3 elements. Element "A" has index 0, element "B" has index 1, element "C" - 2
list := ["A", "B", "C"];
Limitations:
- all indexes are numeric, starting from 0;
- to assign value to a specific index, you must first resize array to contain this index
(for example, if list is of size 3 (indexes from 0 to 2), you can't assign value to index 4 unless you change list size to 5 first).
2) Maps (or associative arrays) - a set of key=>value pairs, where all elements (values) are accessed by corresponding keys.
Differences from list:
- maps don't have specific size (to assign values, you don't need to resize array first);
- keys, just like values, can be of any type (but avoid using -1 as array keys or you won't be able to use some functions reliably).
Both array types have their pros and cons and are suited for different tasks.
>>> ARRAYS SYNTAX <<<
Basically arrays are implemented using number of new operators (scripting functions). But for ease of use, there are some new syntax elements:
1) Accessing elements. Use square brackets:
display_msg(arr[5]);
mymap["price"] := 515.23;
2) Alternative accessing for maps. Use dot:
display_msg(mymap.name);
mymap.price := 232.23;
3) Array expressions. Create and fill arrays with just one expression:
// create list with 5 values
[5, 777, 0, 3.14, "Cool Value"]
// create map:
{5: "Five", "health": 50, "speed": 0.252}
NOTES:
- make sure to call "fix_array" if you want new array to be available in the next frame or "save_array" if you want to use it for a longer period
(see next section for details)
4) Iterating in loop. Use "foreach" key word like this:
foreach (item in myarray) begin
// this block is executed for each array element, where "item" contains current value on each step
end
// alternative syntax:
foreach (key: item in myarray) begin
// "key" will contain current key (or numeric index, for lists)
end
See "Script editor\docs\sslc readme.txt" file for full information on new SSL syntax features.
>>> STORING ARRAYS <<<
Apart from lists/maps arrays are divided by how they are stored.
There a 3 types of arrays:
1) Temporary. They are created using temp_array function or when using array expressions.
Arrays of this type are auto-deleted at the end of the frame. So, for example, if you have a global script which runs at regular intervals,
where you create temp_array, it will not be available next time your global script is executed.
2) Permanent. They are created using "create_array" function or "fix_array" (from pre-existing temporary array).
This type of arrays are always available (by their ID) until you start a new game or load a saved game (at which point they are deleted).
3) Saved. If you want your array to really stay for a while, use function "save_array" to make any array "saved". However, they are, like permanent arrays,
"deleted" from memory when loading game. In order to use them properly, you must load them from the savegame using "load_array" whenever you want to use them.
Example:
variable savedArray;
procedure start begin
if game_loaded then begin
savedArray := load_array("traps");
end else begin
foreach trap in traps begin
....
end
end
end
>>> PRACTICAL EXAMPLES <<<
> Use arrays to implement variable-argument procedures:
// define it
procedure give_item(variable critter, variable pidList) begin
foreach (pid: qty in pidList) begin
give_pid_qty(critter, pid, qty);
end
end
// call it:
call give_item(dude_obj, {PID_SHOTGUN: 1, PID_SHOTGUN_SHELLS: 4, PID_STIMPAK: 3});
> Create arrays of objects (maps) for advanced scripting:
variable traps;
procedure init_traps begin
// just a quick example, there is a better way of doing it...
traps := load_array("traps");
if (traps == 0) then begin
traps := [];
save_array("traps", traps);
end
foreach k: v in traps begin
traps[k] := load_array("trap_"+k); // each object is stored separately
end
end
procedure add_trap(variable trapArray) begin
variable index;
index := len_array(traps);
save_array("trap_"+k, trapArray);
array_push(traps, trapArray);
end
// use them:
foreach trap in traps begin
if (self_elevation == trap["elev"] and tile_distance(self_tile, trap["tile"]) < trap["radius"]) then
// kaboom!!!
end
end
>>> ARRAY OPERATORS REFERENCE <<<
*mixed means any type
> int create_array(int size, int nothing):
- creates permanent array (but not "saved")
- if size is >= 0, creates list with given size
- if size == -1, creates map (associative array)
- second argument is not used yet, just use 0
- returns arrayID (valid until array is deleted)
> int temp_array(int size, int nothing):
- works exactly like "create_array", only created array becomes "temporary"
> void fix_array(int arrayID):
- changes "temporary" array into "permanent" ("permanent" arrays are not automatically saved into savegames)
> void set_array(int arrayID, mixed key, mixed value):
- sets array value
- if used on list, "key" must be numeric and within valid index range (0..size-1)
- if used on map, key can be of any type
- to "unset" a value from map, just set it to zero (0)
- this works exactly like statement:
arrayID[key] := value;
> mixed get_array(int arrayID, mixed key):
- returns array value by key or index
- if key doesn't exist or index is not in valid range, returns 0
- works exactly like expression:
(arrayID[key])
> void resize_array(int arrayID, int size):
- changes array size
- applicable to maps too, but only to reduce elements
- there are number of special negative values of "size" which perform various operations on the array,
use macros sort_array, sort_array_reverse, reverse_array, shuffle_array from sfall.h header
> void free_array(int arrayID):
- deletes any array
- if array was "saved", it will be removed from a savegame
> mixed scan_array(int arrayID, mixed value):
- searches for a first occurence of given value inside given array
- if value is found, returns it's index (for lists) or key (for maps)
- if value is not found, returns -1 (be careful, as -1 can be a valid key for a map)
> int len_array(int arrayID):
- returns number of elements or key=>value pairs in a given array
- if array is not found, returns -1 (can be used to check if given array exist)
> mixed array_key(int arrayID, int index):
- don't use it directly; it is generated by the compiler in foreach loops
- for lists, returns index back (no change)
- for maps, returns a key at the specified numeric index (don't rely on the order in which keys are stored though)
- can be checked if given array is associative or not, by using index (-1): 0 - array is list, 1 - array is map
> int arrayexpr(mixed key, mixed value):
- don't use it directly; it is used by compiler to create array expressions
- assigns value to a given key in an array, created by last "create_array" or "temp_array" call
- always returns 0
> void save_array(mixed key, int arrayID):
- arrayID is associated with given "key"
- array becomes permanent (if it was temporary) and "saved"
- key can be of any type (int, float or string)
> int load_array(mixed key):
- load array from savegame data by the same key provided in "save_array"
- arrayID is returned or zero (0) if none found
>>> BACKWARD COMPATIBILITY NOTES <<<
For those who used arrays in their mods before sfall 3.4:
1) There is an INI parameter "arraysBehavior" in "Misc" section of ddraw.ini. If set to 0, all scripts which used sfall arrays before should work. This basically changes that "create_array" will create permanent arrays which are "saved" by default and their ID is also permanent. It is 1 by default.
2) How savegame compatibility is handled?
Saved arrays are stored in sfallgv.sav file (in savegame) in new (more flexible) format, just after the old arrays. So basically, when you load older savegame, sfall will load arrays from old format and save them to new format on next game save. If you load savegame made with sfall 3.4 using sfall 3.3 (for example), game shouldn't crash, but all arrays will be lost.
3) Previously you had to specify size in bytes for array elements. This parameter is now ignored and you can store strings of arbitrary length in arrays.
+210
View File
@@ -0,0 +1,210 @@
#ifndef DEFINE_EXTRA_H
#define DEFINE_EXTRA_H
#define ATTACK_MODE_NONE 0
#define ATTACK_MODE_PUNCH 1
#define ATTACK_MODE_KICK 2
#define ATTACK_MODE_SWING 3
#define ATTACK_MODE_THRUST 4
#define ATTACK_MODE_THROW 5
#define ATTACK_MODE_SINGLE 6
#define ATTACK_MODE_BURST 7
#define ATTACK_MODE_FLAME 8
#define OBJ_TYPE_ITEM (0)
#define OBJ_TYPE_CRITTER (1)
#define OBJ_TYPE_SCENERY (2)
#define OBJ_TYPE_WALL (3)
#define OBJ_TYPE_TILE (4)
#define OBJ_TYPE_MISC (5)
#define OBJ_TYPE_SPATIAL (6)
/* Critter Flags */
#define CFLG_BARTER 2 //0x00000002 - Barter (can trade with)
#define CFLG_NOSTEAL 32 //0x00000020 - Steal (cannot steal from)
#define CFLG_NODROP 64 //0x00000040 - Drop (doesn't drop items)
#define CFLG_NOLIMBS 128 //0x00000080 - Limbs (can not lose limbs)
#define CFLG_NOAGES 256 //0x00000100 - Ages (dead body does not disappear)
#define CFLG_NOHEAL 512 //0x00000200 - Heal (damage is not cured with time)
#define CFLG_INVULN 1024 //0x00000400 - Invulnerable (cannot be hurt)
#define CFLG_FLATTN 2048 //0x00000800 - Flatten (leaves no dead body)
#define CFLG_SPECIAL 4096 //0x00001000 - Special (there is a special type of death)
#define CFLG_RANGED 8192 //0x00002000 - Range (melee attack is possible at a distance)
#define CFLG_NOKNOCKDOWN 16384 //0x00004000 - Knock (cannot be knocked down)
//remove inven obj defines
#define RMOBJ_CONSUME_DRUG 4666772
#define RMOBJ_CONTAINER 4683293 // same as RMOBJ_TRADE
#define RMOBJ_USE_OBJ 4666865
#define RMOBJ_EQUIP_ARMOR 4658121
#define RMOBJ_EQUIP_WEAPON 4658675
#define RMOBJ_UNLOAD_WEAPON 4667030
//#definE RMOBJ_LOAD_WEAPON 4831349 // same as RMOBJ_DROP
#define RMOBJ_USE_DRUG_ON 4834866
#define RMOBJ_STEAL_VIEW 4668206
//#define RMOBJ_DROP_DYNAMITE 4666865 // same as USE_OBJ
#define RMOBJ_ITEM_DESTROYED 4543215
#define RMOBJ_ITEM_REMOVED 4548572
#define RMOBJ_ARMOR_EQUIPED 4651961
#define RMOBJ_LEFT_HAND_EQUIPED 4651899
#define RMOBJ_RIGHT_HAND_EQUIPED 4651934
#define RMOBJ_RM_MULT_OBJS 4563866
#define RMOBJ_REPLACE_WEAPON 4658526
#define RMOBJ_THROW 4266040
// offsets for get_proto_data
#define PROTO_PID (1)
#define PROTO_TEXTID (4)
// items
#define PROTO_IT_FLAGS (24)
#define PROTO_IT_TYPE (32)
#define PROTO_IT_MATERIAL (108)
#define PROTO_IT_SIZE (112)
#define PROTO_IT_WEIGHT (116)
#define PROTO_IT_COST (120)
// weapons
#define PROTO_WP_ANIM (36)
#define PROTO_WP_DMG_MIN (40)
#define PROTO_WP_DMG_MAX (44)
#define PROTO_WP_RANGE_1 (52)
#define PROTO_WP_RANGE_2 (56)
#define PROTO_WP_PROJ_PID (60)
#define PROTO_WP_MIN_ST (64)
#define PROTO_WP_APCOST_1 (68)
#define PROTO_WP_APCOST_2 (72)
#define PROTO_WP_CRIT_FAIL (76)
#define PROTO_WP_PERK (80)
#define PROTO_WP_BURST (84)
#define PROTO_WP_CALIBER (88)
#define PROTO_WP_AMMO_PID (92)
#define PROTO_WP_MAG_SIZE (96)
#define PROTO_WP_SOUND (100)
// armor
#define PROTO_AR_AC (36)
#define PROTO_AR_DR_NORMAL (40)
#define PROTO_AR_DR_LASER (44)
#define PROTO_AR_DR_FIRE (48)
#define PROTO_AR_DR_PLASMA (52)
#define PROTO_AR_DR_ELECTRICAL (56)
#define PROTO_AR_DR_EMP (60)
#define PROTO_AR_DR_EXPLOSION (64)
#define PROTO_AR_DT_NORMAL (68)
#define PROTO_AR_DT_LASER (72)
#define PROTO_AR_DT_FIRE (76)
#define PROTO_AR_DT_PLASMA (80)
#define PROTO_AR_DT_ELECTRICAL (84)
#define PROTO_AR_DT_EMP (88)
#define PROTO_AR_DT_EXPLOSION (92)
#define PROTO_AR_PERK (96)
#define PROTO_AR_FID_MALE (100)
#define PROTO_AR_FID_FEMALE (104)
// containers
#define PROTO_CN_MAX_SIZE (36)
#define PROTO_CN_FLAGS (40)
// ammo
#define PROTO_AM_CALIBER (36)
#define PROTO_AM_PACK_SIZE (40)
#define PROTO_AM_AC_MOD (44)
#define PROTO_AM_DR_MOD (48)
#define PROTO_AM_DMG_MULT (52)
#define PROTO_AM_DMG_DIV (56)
// misc items
#define PROTO_MI_POWER_PID (36)
#define PROTO_MI_CALIBER (40)
#define PROTO_MI_CHARGES (44)
// drugs
#define PROTO_DR_STAT_A (36)
#define PROTO_DR_STAT_B (40)
#define PROTO_DR_STAT_C (44)
#define PROTO_DR_AMOUNT_1_A (48)
#define PROTO_DR_AMOUNT_1_B (52)
#define PROTO_DR_AMOUNT_1_C (56)
#define PROTO_DR_DURATION_1 (60)
#define PROTO_DR_AMOUNT_2_A (64)
#define PROTO_DR_AMOUNT_2_B (68)
#define PROTO_DR_AMOUNT_2_C (72)
#define PROTO_DR_DURATION_2 (76)
#define PROTO_DR_AMOUNT_3_A (80)
#define PROTO_DR_AMOUNT_3_B (84)
#define PROTO_DR_AMOUNT_3_C (88)
#define PROTO_DR_ADDICT_CHANCE (92)
#define PROTO_DR_ADDICT_PERK (96)
#define PROTO_DR_ADDICT_DELAY (100)
// critters
#define PROTO_CR_ACTION_FLAGS (32)
#define PROTO_CR_HEAD_FID (40)
#define PROTO_CR_AI_PACKET (44)
#define PROTO_CR_TEAM_NUM (48)
#define PROTO_CR_FLAGS (52)
#define PROTO_CR_BODY_TYPE (388)
#define PROTO_CR_KILL_EXP (392)
#define PROTO_CR_KILL_TYPE (396)
#define PROTO_CR_DMG_TYPE (400)
// weapon calibers
#define CALIBER_NONE (0)
#define CALIBER_ROCKET (1)
#define CALIBER_FLAMER_FUEL (2)
#define CALIBER_SMALL_ENERGY_CELL (3)
#define CALIBER_MICRO_FUSION_CELL (4)
#define CALIBER_223 (5)
#define CALIBER_5MM (6)
#define CALIBER_40 (7)
#define CALIBER_10MM (8)
#define CALIBER_44 (9)
#define CALIBER_14MM (10)
#define CALIBER_12_GAUGE (11)
#define CALIBER_9MM (12)
#define CALIBER_BB (13)
#define CALIBER_45 (14)
#define CALIBER_2MM (15)
#define CALIBER_4_7MM_CASELESS (16)
#define CALIBER_HN_NEEDLER (17)
#define CALIBER_7_62MM (18)
// hidden perks
#define PERK_add_nuka (53)
#define PERK_add_buffout (54)
#define PERK_add_mentats (55)
#define PERK_add_psycho (56)
#define PERK_add_radaway (57)
#define PERK_weapon_long_range (58)
#define PERK_weapon_accurate (59)
#define PERK_weapon_penetrate (60)
#define PERK_weapon_knockback (61)
#define PERK_armor_powered (62)
#define PERK_armor_combat (63)
#define PERK_weapon_scope_range (64)
#define PERK_weapon_fast_reload (65)
#define PERK_weapon_night_sight (66)
#define PERK_weapon_flameboy (67)
#define PERK_armor_advanced_1 (68)
#define PERK_armor_advanced_2 (69)
#define PERK_add_jet (70)
#define PERK_add_tragic (71)
#define PERK_armor_charisma (72)
#define WPN_ANIM_NONE (0x00) // (A)
#define WPN_ANIM_KNIFE (0x01) // (D)
#define WPN_ANIM_CLUB (0x02) // (E)
#define WPN_ANIM_SLEDGEHAMMER (0x03) // (F)
#define WPN_ANIM_SPEAR (0x04) // (G)
#define WPN_ANIM_PISTOL (0x05) // (H)
#define WPN_ANIM_SMG (0x06) // (I)
#define WPN_ANIM_RIFLE (0x07) // (J)
#define WPN_ANIM_BIG_GUN (0x08) // (K)
#define WPN_ANIM_MINIGUN (0x09) // (L)
#define WPN_ANIM_ROCKET_LAUNCHER (0x0A) // (M)
#endif // DEFINE_EXTRA_H
+135
View File
@@ -0,0 +1,135 @@
#ifndef H_DIK
#define H_DIK
// Listed are keyboard scan code constants (in decimal), taken from dinput.h
#define DIK_ESCAPE 1
#define DIK_1 2
#define DIK_2 3
#define DIK_3 4
#define DIK_4 5
#define DIK_5 6
#define DIK_6 7
#define DIK_7 8
#define DIK_8 9
#define DIK_9 10
#define DIK_0 11
#define DIK_MINUS 12 /* - on main keyboard */
#define DIK_EQUALS 13
#define DIK_BACK 14 /* backspace */
#define DIK_TAB 15
#define DIK_Q 16
#define DIK_W 17
#define DIK_E 18
#define DIK_R 19
#define DIK_T 20
#define DIK_Y 21
#define DIK_U 22
#define DIK_I 23
#define DIK_O 24
#define DIK_P 25
#define DIK_LBRACKET 26
#define DIK_RBRACKET 27
#define DIK_RETURN 28 /* Enter on main keyboard */
#define DIK_LCONTROL 29
#define DIK_A 30
#define DIK_S 31
#define DIK_D 32
#define DIK_F 33
#define DIK_G 34
#define DIK_H 35
#define DIK_J 36
#define DIK_K 37
#define DIK_L 38
#define DIK_SEMICOLON 39
#define DIK_APOSTROPHE 40
#define DIK_GRAVE 41 /* accent grave */
#define DIK_LSHIFT 42
#define DIK_BACKSLASH 43
#define DIK_Z 44
#define DIK_X 45
#define DIK_C 46
#define DIK_V 47
#define DIK_B 48
#define DIK_N 49
#define DIK_M 50
#define DIK_COMMA 51
#define DIK_PERIOD 52 /* . on main keyboard */
#define DIK_SLASH 53 /* / on main keyboard */
#define DIK_RSHIFT 54
#define DIK_MULTIPLY 55 /* * on numeric keypad */
#define DIK_LMENU 56 /* left Alt */
#define DIK_SPACE 57
#define DIK_CAPITAL 58
#define DIK_F1 59
#define DIK_F2 60
#define DIK_F3 61
#define DIK_F4 62
#define DIK_F5 63
#define DIK_F6 64
#define DIK_F7 65
#define DIK_F8 66
#define DIK_F9 67
#define DIK_F10 68
#define DIK_NUMLOCK 69
#define DIK_SCROLL 70 /* Scroll Lock */
#define DIK_NUMPAD7 71
#define DIK_NUMPAD8 72
#define DIK_NUMPAD9 73
#define DIK_SUBTRACT 74 /* - on numeric keypad */
#define DIK_NUMPAD4 75
#define DIK_NUMPAD5 76
#define DIK_NUMPAD6 77
#define DIK_ADD 78 /* + on numeric keypad */
#define DIK_NUMPAD1 79
#define DIK_NUMPAD2 80
#define DIK_NUMPAD3 81
#define DIK_NUMPAD0 82
#define DIK_DECIMAL 83 /* . on numeric keypad */
#define DIK_F11 87
#define DIK_F12 88
#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */
#define DIK_AT 0x91 /* (NEC PC98) */
#define DIK_COLON 0x92 /* (NEC PC98) */
#define DIK_UNDERLINE 0x93 /* (NEC PC98) */
#define DIK_STOP 0x95 /* (NEC PC98) */
#define DIK_AX 0x96 /* (Japan AX) */
#define DIK_UNLABELED 0x97 /* (J3100) */
#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */
#define DIK_RCONTROL 0x9D
#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */
#define DIK_DIVIDE 0xB5 /* / on numeric keypad */
#define DIK_SYSRQ 0xB7
#define DIK_RMENU 0xB8 /* right Alt */
#define DIK_HOME 0xC7 /* Home on arrow keypad */
#define DIK_UP 0xC8 /* UpArrow on arrow keypad */
#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */
#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */
#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */
#define DIK_END 0xCF /* End on arrow keypad */
#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */
#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */
#define DIK_INSERT 0xD2 /* Insert on arrow keypad */
#define DIK_DELETE 0xD3 /* Delete on arrow keypad */
#define DIK_LWIN 0xDB /* Left Windows key */
#define DIK_RWIN 0xDC /* Right Windows key */
#define DIK_APPS 0xDD /* AppMenu key */
#define DIK_BACKSPACE DIK_BACK /* backspace */
#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */
#define DIK_LALT DIK_LMENU /* left Alt */
#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */
#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */
#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */
#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */
#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */
#define DIK_RALT DIK_RMENU /* right Alt */
#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */
#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */
#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */
#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */
#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */
#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */
#endif
+189
View File
@@ -0,0 +1,189 @@
//Recognised modes for set_shader_mode and get_game_mode
#define WORLDMAP (0x1)
#define LOCALMAP (0x2) //No point hooking this: would always be 1 at any point at which scripts are running
#define DIALOG (0x4)
#define ESCMENU (0x8)
#define SAVEGAME (0x10)
#define LOADGAME (0x20)
#define COMBAT (0x40)
#define OPTIONS (0x80)
#define HELP (0x100)
#define CHARSCREEN (0x200)
#define PIPBOY (0x400)
#define PCOMBAT (0x800)
#define INVENTORY (0x1000)
#define AUTOMAP (0x2000)
#define SKILLDEX (0x4000)
//Valid arguments to register_hook
#define HOOK_TOHIT (0)
#define HOOK_AFTERHITROLL (1)
#define HOOK_CALCAPCOST (2)
#define HOOK_DEATHANIM1 (3)
#define HOOK_DEATHANIM2 (4)
#define HOOK_COMBATDAMAGE (5)
#define HOOK_ONDEATH (6)
#define HOOK_FINDTARGET (7)
#define HOOK_USEOBJON (8)
#define HOOK_REMOVEINVENOBJ (9)
#define HOOK_BARTERPRICE (10)
#define HOOK_MOVECOST (11)
#define HOOK_HEXMOVEBLOCKING (12)
#define HOOK_HEXAIBLOCKING (13)
#define HOOK_HEXSHOOTBLOCKING (14)
#define HOOK_HEXSIGHTBLOCKING (15)
#define HOOK_ITEMDAMAGE (16)
#define HOOK_AMMOCOST (17)
#define HOOK_USEOBJ (18)
#define HOOK_KEYPRESS (19)
#define HOOK_MOUSECLICK (20)
#define HOOK_USESKILL (21)
#define HOOK_STEAL (22)
#define HOOK_WITHINPERCEPTION (23)
#define HOOK_INVENTORYMOVE (24)
//Valid arguments to list_begin
#define LIST_CRITTERS (0)
#define LIST_GROUNDITEMS (1)
#define LIST_SCENERY (2)
#define LIST_WALLS (3)
//#define LIST_TILES (4) //Not listable via sfall list functions
#define LIST_MISC (5)
#define LIST_SPATIAL (6)
#define LIST_ALL (9)
//Valid flags for force_encounter_with_flags
#define ENCOUNTER_FLAG_NO_CAR (1)
//The attack types returned by get_attack_type
#define ATKTYPE_LWEP1 (0)
#define ATKTYPE_LWEP2 (1)
#define ATKTYPE_RWEP1 (2)
#define ATKTYPE_RWEP2 (3)
#define ATKTYPE_PUNCH (4)
#define ATKTYPE_KICK (5)
#define ATKTYPE_LWEP_RELOAD (6)
#define ATKTYPE_RWEP_RELOAD (7)
#define ATKTYPE_STRONGPUNCH (8)
#define ATKTYPE_HAMMERPUNCH (9)
#define ATKTYPE_HAYMAKER (10)
#define ATKTYPE_JAB (11)
#define ATKTYPE_PALMSTRIKE (12)
#define ATKTYPE_PIERCINGSTRIKE (13)
#define ATKTYPE_STRONGKICK (14)
#define ATKTYPE_SNAPKICK (15)
#define ATKTYPE_POWERKICK (16)
#define ATKTYPE_HIPKICK (17)
#define ATKTYPE_HOOKKICK (18)
#define ATKTYPE_PIERCINGKICK (19)
//Some possible values for the 4th argument to hs_removeinvobj
#define RMOBJ_DROP (0x49B875) //If the object is dropped manually by the player from the inventory screen
#define RMOBJ_TRADE (0x47761D) //If the object is offered up as a trade
#define RMOBJ_DROPMULTI (0x45C1CF) //When dropping a part of a stack (RMOBJ_DROP occures first)
//Return values for "typeof"
#define VALTYPE_NONE (0) // not used yet
#define VALTYPE_INT (1)
#define VALTYPE_FLOAT (2)
#define VALTYPE_STR (3)
// Arrays defines
// create persistent list
#define create_array_list(size) (create_array(size, 0))
// create temporary list
#define temp_array_list(size) (temp_array(size, 0))
// create persistent map
#define create_array_map (create_array(-1, 0))
// create temporary map
#define temp_array_map (temp_array(-1, 0))
// true if array is map, false otherwise
#define array_is_map(x) (array_key(x, -1) == 1)
// returns temp list with names of all arrays saved with save_array() in alphabetical order
#define list_saved_arrays (load_array("...all_arrays..."))
// removes array from savegame
#define unsave_array(x) save_array(0, x)
// true if given item exists in given array, false otherwise
#define is_in_array(item, array) (scan_array(array, item) != -1)
// true if given array exists, false otherwise
#define array_exists(array) (len_array(array) != -1)
// remove all elements from array
#define clear_array(array) resize_array(array, 0)
// sort array in ascending order
#define sort_array(array) resize_array(array, -2)
// sort array in descending order
#define sort_array_reverse(array) resize_array(array, -3)
// reverse elements in list
#define reverse_array(array) resize_array(array, -4)
// randomly shuffle elements in list
#define shuffle_array(array) resize_array(array, -5)
// remove element from map or just replace value with 0 for list
#define unset_array(array, item) set_array(array, item, 0)
// same as "key_pressed" but checks VK codes instead of DX codes
#define key_pressed_vk(key) (key_pressed(key bwor 0x80000000))
#define set_attack_explosion_pattern(x, y) metarule2_explosions(1, x, y)
#define set_attack_explosion_art(x, y) metarule2_explosions(2, x, y)
#define set_attack_explosion_radius(x) metarule2_explosions(3, x, 0)
#define set_attack_is_explosion(x) metarule2_explosions(4, x, 0)
#define set_attack_is_explosion_fire set_attack_is_explosion(DMG_fire)
#define GAME_MSG_COMBAT (0)
#define GAME_MSG_AI (1)
#define GAME_MSG_SCRNAME (2)
#define GAME_MSG_MISC (3)
#define GAME_MSG_CUSTOM (4)
#define GAME_MSG_INVENTRY (5)
#define GAME_MSG_ITEM (6)
#define GAME_MSG_LSGAME (7)
#define GAME_MSG_MAP (8)
#define GAME_MSG_OPTIONS (9)
#define GAME_MSG_PERK (10)
#define GAME_MSG_PIPBOY (11)
#define GAME_MSG_QUESTS (12)
#define GAME_MSG_PROTO (13)
#define GAME_MSG_SCRIPT (14)
#define GAME_MSG_SKILL (15)
#define GAME_MSG_SKILLDEX (16)
#define GAME_MSG_STAT (17)
#define GAME_MSG_TRAIT (18)
#define GAME_MSG_WORLDMAP (19)
#define GAME_MSG_PRO_ITEM (0x1000)
#define GAME_MSG_PRO_CRIT (0x1001)
#define GAME_MSG_PRO_SCEN (0x1002)
#define GAME_MSG_PRO_WALL (0x1003)
#define GAME_MSG_PRO_TILE (0x1004)
#define GAME_MSG_PRO_MISC (0x1005)
#define mstr_combat(x) (message_str_game(GAME_MSG_COMBAT, x))
#define mstr_ai(x) (message_str_game(GAME_MSG_AI, x))
#define mstr_scrname(x) (message_str_game(GAME_MSG_SCRNAME, x))
#define mstr_misc(x) (message_str_game(GAME_MSG_MISC, x))
#define mstr_custom(x) (message_str_game(GAME_MSG_CUSTOM, x))
#define mstr_inventry(x) (message_str_game(GAME_MSG_INVENTRY, x))
#define mstr_item(x) (message_str_game(GAME_MSG_ITEM, x))
#define mstr_lsgame(x) (message_str_game(GAME_MSG_LSGAME, x))
#define mstr_map(x) (message_str_game(GAME_MSG_MAP, x))
#define mstr_options(x) (message_str_game(GAME_MSG_OPTIONS, x))
#define mstr_perk(x) (message_str_game(GAME_MSG_PERK, x))
#define mstr_pipboy(x) (message_str_game(GAME_MSG_PIPBOY, x))
#define mstr_quests(x) (message_str_game(GAME_MSG_QUESTS, x))
#define mstr_proto(x) (message_str_game(GAME_MSG_PROTO, x))
#define mstr_script(x) (message_str_game(GAME_MSG_SCRIPT, x))
#define mstr_skill(x) (message_str_game(GAME_MSG_SKILL, x))
#define mstr_skilldex(x) (message_str_game(GAME_MSG_SKILLDEX, x))
#define mstr_stat(x) (message_str_game(GAME_MSG_STAT, x))
#define mstr_trait(x) (message_str_game(GAME_MSG_TRAIT, x))
#define mstr_worldmap(x) (message_str_game(GAME_MSG_WORLDMAP, x))
#define BLOCKING_TYPE_BLOCK (0)
#define BLOCKING_TYPE_SHOOT (1) // use this for more realistic line-of-sight checks
#define BLOCKING_TYPE_AI (2)
#define BLOCKING_TYPE_SIGHT (3) // not really useful (works not as you would expect), game uses this only when checking if you can talk to a person
#define party_member_list_critters party_member_list(0)
#define party_member_list_all party_member_list(1)
+390
View File
@@ -0,0 +1,390 @@
-------------------------------------
----------- WHAT IS THIS? -----------
-------------------------------------
Hook scripts are specially named scripts that are run by sfall at specific points to allow mods to override normally hardcoded behaviour in a more flexible way than sfall's normal ini configuration.
In addition to the bit of code it overrides, the script will be run once when first loaded and again at each player reload to allow for setup. Hook scripts have access to a set of arguments supplied to sfall, but aren't required to use them all. They also return one or more values, but again they're optional, and you only need to return a value if you want to override the default.
As good practise to aid in mod compatibility, only use the hs_xxx .int script if you are setting return values. For any other scripts, use a normal global script combined with register_hook or register_hook_proc.
There are script functions specific to hook scripts:
int init_hook()
The hook script equivilent of game_loaded; it returns 2 when the script is first loaded, 1 when the player reloads and 0 otherwise.
mixed get_sfall_arg()
Gets the next argument from sfall. Each time it's called it returns the next argument, or otherwise it returns 0 if there are no more arguments left.
int get_sfall_args()
Returns all hook arguments as a new temp array.
void set_sfall_return(int value)
Used to return the new values from the script. Each time it's called it sets the next value, or if you've already set all return values it does nothing.
void set_sfall_arg(int argnum, int value)
Changes argument value. This is usefull if you have several hook scripts attached to one hook point (see below).
void register_hook(int hooktype)
Used from a normal global script if you want to run it at the same point a full hook script would normally run. In case of this function, "start" proc will be execuded in a current global script. You can use all above functions like normal.
void register_hook_proc(int hooktype, proc procedure)
The same as register_hook, except that you specifically define which procedure in the current script should be called as a hook (instead of "start"). Pass procedure the same as how you use dialog option functions. This IS the recommended way to use hook scripts, as it gives both modularity (each mod logic in a separate global script, no conflicts if you don't use "hs_*.int" scripts) and flexibility (you can place all related hook scripts for specific mod in a single script!).
NOTE: you can hook several scripts to a single hook point, for example if it's different mods from different authors or just some different aspects of one larger mod. In this case scripts are executed in reverse order of how they were registered. When one of the scripts in a chain returns value with "set_sfall_return", the next script may override this value if calls "set_sfall_return" again. Sometimes you need to multiply certain value in a chain of hook scripts.
Example: let's say we have a Mod A which reduces all "to hit" chances by 50%. The code might look like this:
original_chance = get_sfall_arg;
set_sfall_return(original_chance / 2);
Mod B also want to affect hit chances globally, by increasing them by 50%. Now in order for both mods to work well together, we need to add this line to Mod A hook script:
set_sfall_arg(original_chance / 2);
This basically changes hook argument for the next script. Mod B code:
original_chance = get_sfall_arg;
set_sfall_return(original_chance * 1.5);
set_sfall_arg(original_chance * 1.5);
So if you combine both mods together, they will run in chain and the end result will be a 75% from original hit chance (hook register order doesn't matter in this case, if you use "set_sfall_arg" in both hooks).
The defines to use for the hooktype are in sfall.h.
-------------------------------------------
----------- HOOK SCRIPT TYPES -------------
-------------------------------------------
hs_tohit.int
Runs when fallout is calculating the chances of an attack striking a target
Runs after the hit chance is fully calculated normally, including applying the 95% cap
int arg1 - The unmodified hit chance
critter arg2 - The attacker
critter arg3 - The target of the attack
int arg4 - The targeted bodypart
int ret1 - the new hit chance
-------------------------------------------
hs_afterhitroll.int
Runs after fallout has decided if an attack will hit or miss
int arg1 - If the attack will hit. (0 - critical miss, 1 - miss, 2 - hit, 3 - critical hit)
critter arg2 - The attacker
critter arg3 - The target of the attack
int arg4 - The bodypart
int arg5 - The hit chance
int ret1 - Override the hit/miss
int ret2 - Override the targeted bodypart
critter ret3 - Override the target of the attack
-------------------------------------------
hs_calcapcost.int
Runs whenever fallout is calculating the ap cost of using the weapon (or unarmed attack). Doesn't run for using other item types or moving.
Note that the first time a game is loaded, this script doesn't run before the initial interface is drawn, so if the script effects the ap cost of whatever is in the players hands at the time the wrong ap cost will be shown. It will be fixed the next time the interface is redrawn.
You can get the weapon object by checking item slot based on attack type (ATKTYPE_LWEP1, ATKTYPE_LWEP2, etc) and then calling critter_inven_obj().
critter arg1 - The critter performing the action
int arg2 - Attack Type (see ATKTYPE_* constants)
int arg3 - Is aimed attack (1 or 0)
int arg4 - The normal ap cost
int ret1 - The new ap cost
-------------------------------------------
hs_deathanim1.int
Runs before fallout tries to calculate the death animation. Lets you switch out which weapon fallout sees
int arg1 - The pid of the weapon performing the attack. (May be -1 if the attack is unarmed)
critter arg2 - The attacker
critter arg3 - The target
int arg4 - The amount of damage
int ret1 - The pid of an object to override the attacking weapon with
-------------------------------------------
hs_deathanim2.int
Runs after fallout has calculated the death animation. Lets you set your own custom frame id, so more powerful than hs_deathanim1, but performs no validation.
When using critter_dmg function, this script will also run. In that case weapon pid will be -1 and target will point to an object with obj_art_fid == 0x20001F5.
item arg1 - The pid of the weapon performing the attack. (May be -1 if the attack is unarmed)
critter arg2 - The attacker
critter arg3 - The target
int arg4 - The amount of damage
int arg5 - The death anim id calculated by fallout
int ret1 - The death anim id to override with
-------------------------------------------
hs_combatdamage.int
Runs when:
1) Game calculates how much damage each target will get. This includes primary target as well as all extras (explosions and bursts). This happens BEFORE the actual attack animation.
2) AI decides whether it is safe to use area attack (burst, grenades), if he might hit friendlies.
Does not run for misses, or non-combat damage like dynamite explosions.
critter arg1 - The target
critter arg2 - The attacker
int arg3 - The amount of damage to the target
int arg4 - The amount of damage to the attacker
int arg5 - The special effect flags for the target
int arg6 - The special effect flags for the attacker
int arg7 - The weapon used in the attack
int arg8 - The bodypart that was struck
int arg9 - Roll result of the attack (check with is_success, etc functions; basically: 0-crit. fail, 1-fail, 2-success, 3-crit. success)
int arg10 - Number of bullets actually hit the target (1 for melee attacks)
int arg11 - The amount of knockback to the target
int ret1 - The damage to the target
int ret2 - The damage to the attacker
int ret3 - The special effect flags for the target
int ret4 - The special effect flags for the attacker
int ret5 - The amount of knockback to the target
-------------------------------------------
hs_ondeath.int
Runs immediately after a critter dies for any reason. No return values; this is just a convinence for when you need to do something after death for a large number of different critters and don't want to have to script each and every one of them.
Critter arg1 - The critter that just died
-------------------------------------------
hs_findtarget.int
Runs when the ai is trying to pick a target in combat. Fallout first chooses a list of 4 likely suspects, then normally sorts them in order of weakness/distance/etc depending on the ai caps of the attacker. This hook replaces that sorting function, allowing you to sort the targets in some arbitrary way. Use sfall_return to give the 4 targets, in order of preference. All 4 must be given if you want to override normal sorting; if you want to specify less than 4 targets fill in the extra spaces with 0's. If you do not give 4 targets, the npcs normal sorting mechanism will be used.
The return values can include critters that weren't in the list of possible targets, but the additional targets may still be discarded later on in the combat turn if they are out of the attackers perception or the chance of a successful hit is too low. The list of possible targets often includes duplicated entries.
critter arg1 - The attacker
critter arg2 - A possible target
critter arg3 - A possible target
critter arg4 - A possible target
critter arg5 - A possible target
critter ret1 - The first choice of target
critter ret2 - The second choice of target
critter ret3 - The third choice of target
critter ret4 - The fourth choice of target
-------------------------------------------
hs_useobjon.int
Runs when:
1) a critter uses an object on another critter. (Or themselves)
2) a critter uses an object from inventory screen AND this object does not have "Use" action flag set and it's not active flare or explosive.
3) player or AI uses any drug
This is fired before the object is used, and the relevent use_obj_on script procedures are run. You can disable default item behavior.
NOTE: you can't remove and/or destroy this object during the hookscript (game will crash otherwise). To remove it, return 1.
Critter arg1 - The target
Critter arg2 - The user
int arg3 - The object used
int ret1 - overrides hard-coded handler and selects what should happen with the item (0 - place it back, 1 - remove it, -1 - use engine handler)
-------------------------------------------
hs_useobj.int
Runs when:
1) a critter uses an object from inventory which have "Use" action flag set or it's an active flare or dynamite.
2) player uses an object from main interface
This is fired before the object is used, and the relevent use_obj script procedures are run. You can disable default item behavior.
NOTE: you can't remove and/or destroy this object during the hookscript (game will crash otherwise). To remove it, return 1.
Critter arg1 - The user
int arg2 - The object used
int ret1 - overrides hard-coded handler and selects what should happen with the item (0 - place it back, 1 - remove it, -1 - use engine handler)
-------------------------------------------
hs_removeinvenobj.int
Runs when an object is removed from a critters inventory for any reason
critter arg1 - the critter the object is being removed from
item arg2 - the item that is being removed
int arg3 - a flag, or possibly the number of items to remove
int arg4 - The reason the object is being removed. (Actually, the site from which _item_remove_mult was called)
-------------------------------------------
hs_barterprice.int
Runs whenever the value of goods being purchased is calculated
critter arg1 - the critter doing the bartering (either dude_obj or inven_dude)
critter arg2 - the critter being bartered with
int arg3 - the default value of the goods
critter arg4 - the barter critter (has all of the goods being traded in its inventory)
int arg5 - the amount of actual caps in the barter stack (as opposed to goods)
int arg6 - the value of all goods being traded before skill modifications
int ret1 - the modified value of all of the goods
-------------------------------------------
hs_movecost.int
Runs when calculating the ap cost of movement
Critter arg1 - the critter doing the moving
int arg2 - the number of hexes being moved
int arg3 - the original ap cost
int ret1 - the new ap cost
-------------------------------------------
hs_hexmoveblocking.int
hs_hexshootblocking.int
hs_hexaiblocking.int
Runs when checking to see if a hex blocks movement or shooting. (or ai-ing, presumably...)
Critter arg1 - the critter doing the moving
int arg2 - the tile number being checked
int arg3 - the elevation being checked
int arg4 - 1 if the hex would normally be blocking
object* ret1 - 0 if the hex doesn't block, or any sort of object pointer if it does
-------------------------------------------
hs_itemdamage.int
Runs when retriving the damage rating of the players used weapon. (Which may be their fists.)
int arg1 - The default min damage
int arg2 - The default max damage
Item arg3 - The weapin used. (0 if unarmed)
Critter arg4 - The critter doing the attacking
int arg5 - The type of attack
int arg6 - non zero if this is an attack using a melee weapon
int ret1 - Either the damage to be used, if ret2 isn't given, or the new minimum damage if it is
int ret2 - The new maximum damage
-------------------------------------------
hs_ammocost.int
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.
By default, weapon will shoot when at least 1 round is left, regardless of ammo cost calculations.
To add proper check for ammo before shooting and proper calculation of number of burst rounds, set Misc.CheckWeaponAmmoCost=1 in ddraw.ini
Item arg1 - weapon
int arg2 - Number of bullets in burst (1 for single shots)
int arg3 - Ammo cost calculated by original function (this is basically 2 for Super Cattle Prod and Mega Power Fist)
int arg4 - Type of hook (0 - when substracting ammo after attack, 1 - when checking for "out of ammo" before attack)
int ret1 - new ammo cost value (set to 0 for unlimited ammo)
-------------------------------------------
hs_keypress.int
Runs once every time when any key was pressed or released.
DX codes: (see dik.h header)
VK codes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
int arg1 - event type: 1 - pressed, 0 - released
int arg2 - key DX scancode
int arg3 - key VK code (very similar to ASCII codes)
-------------------------------------------
hs_mouseclick.int
Runs once every time when a mouse button was pressed or release.
int arg1 - event type: 1 - pressed, 0 - released
int arg2 - button number (0 - left, 1 - right, up to 7)
-------------------------------------------
hs_useskill.int
Runs when using any skill on any object.
This is fired before the default handlers are called, which you can override. In this case you should write your own skill use handler entirely, or otherwise nothing will happen (this includes fade in/fade out, time lapsing and messages - all of this can be scripted; to get vanilla text messages - use message_str_game() along with sprintf()).
Suggested use - override first aid/doctor skills to buff/nerf them, override steal skill to disallow observing NPCs inventories in some cases.
Doesn't seem to run when lock picking.
Critter arg1 - The user critter
Obj arg2 - The target object
int arg3 - skill being used
int arg4 - skill bonus from items such as first aid kits
int ret1 - overrides hard-coded handler (-1 - use engine handler, any other value - override)
-------------------------------------------
hs_steal.int
Runs when checking an attempt to steal or plant an item in other inventory using Steal skill.
This is fired before the default handlers are called, which you can override. In this case you MUST provide message of the result to player ("You steal the %s", "You are caught planting the %s", etc.).
Example message (vanilla behavior): display_msg(sprintf(mstr_skill(570 + (isSuccess != false) + arg4*2), obj_name(arg3)));
Critter arg1 - Thief
Obj arg2 - The target
Item arg3 - Item being stolen/planted
int arg4 - 0 when stealing, 1 when planting
int ret1 - overrides hard-coded handler (1 - force success, 0 - force fail, -1 - use engine handler)
-------------------------------------------
hs_withinperception.int
Runs when checking if one critter sees another critter. This is used in different situations like combat AI. You can override the result.
NOTE: obj_can_see_obj calls this first when deciding if critter can possibly see another critter with regard to perception, lighting, sneak factors. If check fails, the end result is false. If check succeeds (eg. critter is within perception range), another check is made if there is any blocking tile between two critters (which includes stuff like windows, large bushes, barrels, etc.) and if there is - check still fails. You can override "within perception" check by returning 0 or 1, OR, as a convenience, you can also override blocking check after the perception check by returning 2 instead. In this case you should add "line of sight" check inside your hook script, otherwise critters will detect you through walls.
This is fired after the default calculation is made.
Critter arg1 - Watcher object
Obj arg2 - Target objet
int arg3 - Result of vanilla function: 1 - within perception range, 0 - otherwise
int ret1 - overrides the returned result of the function: 0 - not in range (can't see), 1 - in range (will see if not blocked), 2 - forced detection (will see regardless, only used in obj_can_see_obj scripting function which is called by every critter in the game)
-------------------------------------------
hs_inventorymove.int
Runs before moving items between inventory slots in dude interface. You can override the action.
What you can NOT do with this hook:
- force moving items to inapropriate slots (like gun in armor slot)
- block picking up items
What you can do:
- restrict player from using specific weapons or armors
- add AP costs for all inventory movement including reloading
- apply or remove some special scripted effects depending on PC's armor
int arg1 - Target slot (0 - main backback, 1 - left hand, 2 - right hand, 3 - armor slot, 4 - weapon, when reloading it by dropping ammo)
Item arg2 - Item being moved
Item arg3 - Item being replaced or weapon being reloaded (can be 0)
int ret1 - Override setting (-1 - use engine handler, any other value - prevent relocation of item/reloading weapon)
+352
View File
@@ -0,0 +1,352 @@
*0x8156 - int read_byte(int address)
*0x8157 - int read_short(int address)
*0x8158 - int read_int(int address)
*0x8159 - char* read_string(int address)
*0x81cf - void write_byte(int address, int value)
*0x81d0 - void write_short(int address, int value)
*0x81d1 - void write_int(int address, int value)
*0x821b - void write_string(int address, char* value)
*0x81d2 - void call_offset_v0(int address)
*0x81d3 - void call_offset_v1(int address, int arg1)
*0x81d4 - void call_offset_v2(int address, int arg1, int arg2)
*0x81d5 - void call_offset_v3(int address, int arg1, int arg2, int arg3)
*0x81d6 - void call_offset_v4(int address, int arg1, int arg2, int arg3, int arg4)
*0x81d7 - int call_offset_r0(int address)
*0x81d8 - int call_offset_r1(int address, int arg1)
*0x81d9 - int call_offset_r2(int address, int arg1, int arg2)
*0x81da - int call_offset_r3(int address, int arg1, int arg2, int arg3)
*0x81db - int call_offset_r4(int address, int arg1, int arg2, int arg3, int arg4)
0x815a - void set_pc_base_stat(int StatID, int value)
0x815b - void set_pc_extra_stat(int StatID, int value)
0x815c - int get_pc_base_stat(int StatID)
0x815d - int get_pc_extra_stat(int StatID)
0x815e - void set_critter_base_stat(CritterPtr, int StatID, int value)
0x815f - void set_critter_extra_stat(CritterPtr, int StatID, int value)
0x8160 - int get_critter_base_stat(CritterPtr, int StatID)
0x8161 - int get_critter_extra_stat(CritterPtr, int StatID)
0x8242 - void set_critter_skill_points(int critter, int skill, int value)
0x8243 - int get_critter_skill_points(int critter, int skill)
0x8244 - void set_available_skill_points(int value)
0x8245 - int get_available_skill_points()
0x8246 - void mod_skill_points_per_level(int value)
0x81b4 - void set_stat_max(int stat, int value)
0x81b5 - void set_stat_min(int stat, int value)
0x81b7 - void set_pc_stat_max(int stat, int value)
0x81b8 - void set_pc_stat_min(int stat, int value)
0x81b9 - void set_npc_stat_max(int stat, int value)
0x81ba - void set_npc_stat_min(int stat, int value)
0x816b - int input_funcs_available()
ox816c - int key_pressed(int dxScancode)
0x8162 - void tap_key(int dxScancode)
0x821c - int get_mouse_x()
0x821d - int get_mouse_y()
0x821e - int get_mouse_buttons()
0x821f - int get_window_under_mouse()
0x8163 - int get_year()
0x8164 - bool game_loaded()
0x8165 - bool graphics_funcs_available()
0x8166 - int load_shader(char* path)
0x8167 - void free_shader(int ID)
0x8168 - void activate_shader(int ID)
0x8169 - void deactivate_shader(int ID)
0x816d - void set_shader_int(int ID, char* param, int value)
0x816e - void set_shader_float(int ID, char* param, float value)
0x816f - void set_shader_vector(int ID, char* param, float f1, float f2, float f3, float f4)
0x81ad - int get_shader_version()
0x81ae - void set_shader_mode(int mode)
0x81b0 - void force_graphics_refresh(bool enabled)
0x81b1 - int get_shader_texture(int ID, int texture)
0x81b2 - void set_shader_texture(int ID, char* param, int texID)
0x816a - void set_global_script_repeat(int frames)
0x819b - void set_global_script_type(int type)
0x819c - int available_global_script_types()
0x8170 - bool in_world_map()
0x8171 - void force_encounter(int map)
0x8229 - void force_encounter_with_flags(int map, int flags)
0x822a - void set_map_time_multi(float multi)
0x8172 - void set_world_map_pos(int x, int y)
0x8173 - int get_world_map_x_pos()
0x8174 - int get_world_map_y_pos()
0x8175 - void set_dm_model(char* name)
0x8176 - void set_df_model(char* name)
0x8177 - void set_movie_path(char* filename, int movieid)
0x8178 - void set_perk_image(int perkID, int value)
0x8179 - void set_perk_ranks(int perkID, int value)
0x817a - void set_perk_level(int perkID, int value)
0x817b - void set_perk_stat(int perkID, int value)
0x817c - void set_perk_stat_mag(int perkID, int value)
0x817d - void set_perk_skill1(int perkID, int value)
0x817e - void set_perk_skill1_mag(int perkID, int value)
0x817f - void set_perk_type(int perkID, int value)
0x8180 - void set_perk_skill2(int perkID, int value)
0x8181 - void set_perk_skill2_mag(int perkID, int value)
0x8182 - void set_perk_str(int perkID, int value)
0x8183 - void set_perk_per(int perkID, int value)
0x8184 - void set_perk_end(int perkID, int value)
0x8185 - void set_perk_chr(int perkID, int value)
0x8196 - void set_perk_int(int perkID, int value)
0x8187 - void set_perk_agl(int perkID, int value)
0x8188 - void set_perk_lck(int perkID, int value)
0x8189 - void set_perk_name(int perkID, char* value)
0x818a - void set_perk_desc(int perkID, char* value)
0x8247 - void set_perk_freq(int value)
0x818b - void set_pipboy_available(int available)
0x818c - int get_kill_counter(int critterType)
0x818d - void mod_kill_counter(int critterType, int amount)
0x818e - int get_perk_owed()
0x818f - void set_perk_owed(int value)
0x8190 - int get_perk_available(int perk)
0x8191 - int get_critter_current_ap(CritterPtr)
0x8192 - void set_critter_current_ap(CritterPtr, int ap)
0x8193 - int active_hand()
0x8194 - void toggle_active_hand()
0x8195 - void set_weapon_knockback(WeaponPtr, int type, float value)
0x8196 - void set_target_knockback(CritterPtr, int type, float value)
0x8197 - void set_attacker_knockback(CritterPtr, int type, float value)
0x8198 - void remove_weapon_knockback(WeaponPtr)
0x8199 - void remove_target_knockback(CritterPtr)
0x819a - void remove_attacker_knockback(CritterPtr)
0x819d - void set_sfall_global(string/int varname, int/float value)
0x819e - int get_sfall_global_int(string/int varname)
0x819f - float get_sfall_global_float(string/int varname)
0x822d - int create_array(int elementcount, int elementsize)
0x822e - void set_array(int array, any element, any value)
0x822f - any get_array(int array, any element)
0x8230 - void free_array(int array)
0x8231 - int len_array(int array)
0x8232 - void resize_array(int array, int newelementcount)
0x8233 - int temp_array(int elementcount, int elementsize)
0x8234 - void fix_array(int array)
0x8239 - int scan_array(int array, int/float var)
0x8256 - int array_key(int array, int index)
0x8257 - int arrayexpr(any key, any value)
0x8254 - void save_array(any key, int array)
0x8255 - int load_array(any key)
0x81a0 - void set_pickpocket_max(int percentage)
0x81a1 - void set_hit_chance_max(int percentage)
0x81a2 - void set_skill_max(int value)
0x81aa - void set_xp_mod(int percentage)
0x81ab - void set_perk_level_mod(int levels)
0x81c5 - void set_critter_hit_chance_mod(CritterPtr, int max, int mod)
0x81c6 - void set_base_hit_chance_mod(int max, int mod)
0x81c7 - void set_critter_skill_mod(CritterPtr, int max)
0x81c8 - void set_base_skill_mod(int max)
0x81c9 - void set_critter_pickpocket_mod(CritterPtr, int max, int mod)
0x81ca - void set_base_pickpocket_mod(int max, int mod)
0x81a3 - int eax_available()
0x81a4 - void set_eax_environment(int environment)
0x81a5 - void inc_npc_level(char* npc)
0x8241 - int get_npc_level(char* npc)
0x81a6 - int get_viewport_x()
0x81a7 - int get_viewport_y()
0x81a8 - void set_viewport_x(int view_x)
0x81a9 - void set_viewport_y(int view_y)
0x81ac - int get_ini_setting(char* setting)
0x81eb - char* get_ini_string(char* setting)
0x81af - int get_game_mode()
0x81b3 - int get_uptime()
0x81b6 - void set_car_current_town(int town)
0x81bb - void set_fake_perk(char* name, int level, int image, char* desc)
0x81bc - void set_fake_trait(char* name, int active, int image, char* desc)
0x81bd - void set_selectable_perk(char* name, int active, int image, char* desc)
0x81be - void set_perkbox_title(char* title)
0x81bf - void hide_real_perks()
0x81c0 - void show_real_perks()
0x81c1 - int has_fake_perk(char* name)
0x81c2 - int has_fake_trait(char* name)
0x81c3 - void perk_add_mode(int type)
0x81c4 - void clear_selectable_perks()
0x8225 - void remove_trait(int traitID)
0x81cb - void set_pyromaniac_mod(int bonus)
0x81cc - void apply_heaveho_fix
0x81cd - void set_swiftlearner_mod(int bonus)
0x81ce - void set_hp_per_level_mod(int mod)
0x81dc - void show_iface_tag(int tag)
0x81dd - void hide_iface_tag(int tag)
0x81de - int is_iface_tag_active(int tag)
0x81df - int get_bodypart_hit_modifier(int bodypart)
0x81e0 - void set_bodypart_hit_modifier(int bodypart, int value)
0x81e1 - void set_critical_table(int crittertype, int bodypart, int level, int valuetype, int value)
0x81e2 - int get_critical_table(int crittertype, int bodypart, int level, int valuetype)
0x81e3 - void reset_critical_table(int crittertype, int bodypart, int level, int valuetype)
0x81e4 - int get_sfall_arg()
0x823d - void set_sfall_arg(int arg, int value)
0x823c - array get_sfall_args()
0x823d - void set_sfall_arg(int arg, int value)
0x81e5 - void set_sfall_return(int value)
0x81ea - int init_hook()
0x81e6 - void set_unspent_ap_bonus(int multiplier)
0x81e7 - int get_unspent_ap_bonus()
0x81e8 - void set_unspent_ap_perk_bonus(int multiplier)
0x81e9 - int get_unspent_ap_perk_bonus()
0x81ec - float sqrt(float)
0x81ed - float abs(float)
0x81ee - float sin(float)
0x81ef - float cos(float)
0x81f0 - float tan(float)
0x81f1 - float arctan(float x, float y)
0x8263 - ^ operator (exponentiation)
0x8264 - float log(float)
0x8265 - float exponent(float)
0x8266 - int ceil(float)
0x8267 - int round(float)
0x81f2 - void set_palette(char* path)
0x81f3 - void remove_script(objptr)
0x81f4 - void set_script(objptr, int scriptid)
0x81f5 - int get_script(objptr)
0x81f6 - int nb_create_char()
0x81f7 - int fs_create(string path, int size)
0x81f8 - int fs_copy(string path, string source)
0x81f9 - int fs_find(string path)
0x81fa - void fs_write_byte(int id, int data)
0x81fb - void fs_write_short(int id, int data)
0x81fc - void fs_write_int(int id, int data)
0x81fd - void fs_write_float(int id, int data)
0x81fe - void fs_write_string(int id, string data)
0x8208 - void fs_write_bstring(int id, string data)
0x8209 - int fs_read_byte(int id)
0x820a - int fs_read_short(int id)
0x820b - int fs_read_int(int id)
0x820c - float fs_read_float(int id)
0x81ff - void fs_delete(int id)
0x8200 - int fs_size(int id)
0x8201 - int fs_pos(int id)
0x8202 - void fs_seek(int id, int pos)
0x8203 - void fs_resize(int id, int size)
0x8204 - int get_proto_data(objptr, int offset)
0x8205 - void set_proto_data(objptr, int offset, int value)
0x8206 - void set_self(objptr)
0x8207 - void register_hook(int hook)
0x820d - int list_begin(int type)
0x820e - int list_next(int listid)
0x820f - void list_end(int listid)
0x8236 - array list_as_array(int type)
0x8210 - int sfall_ver_major()
0x8211 - int sfall_ver_minor()
0x8212 - int sfall_ver_build()
0x8213 - void hero_select_win(int)
0x8214 - void set_hero_race(int style)
0x8215 - void set_hero_style(int style)
0x8216 - void set_critter_burst_disable(int critter, int disable)
0x8217 - int get_weapon_ammo_pid(objptr weapon)
0x8218 - void set_weapon_ammo_pid(objptr weapon, int pid)
0x8219 - int get_weapon_ammo_count(objptr weapon)
0x821a - void set_weapon_ammo_count(objptr weapon, int count)
0x8220 - int get_screen_width()
0x8221 - int get_screen_height()
0x8222 - void stop_game()
0x8223 - void resume_game()
0x8224 - void create_message_window(char* message)
0x8226 - int get_light_level()
0x8227 - void refresh_pc_art
0x8228 - int get_attack_type
0x822b - int play_sfall_sound(char* file, int loop)
0x822c - void stop_sfall_sound(int ptr)
0x8235 - array string_split(char* string, char* split)
0x8237 - int atoi(char* string)
0x8238 - float atof(char* string)
0x824e - char* substr(char* string, int start, int length)
0x824f - int strlen(char* string)
0x8250 - char* sprintf(char* format, any value)
0x8251 - int charcode(char* string)
0x8253 - int typeof(any value)
0x823a - int get_tile_fid(int tile)
0x823b - int modified_ini
0x823e - void force_aimed_shots(int pid)
0x823f - void disable_aimed_shots(int pid)
0x8240 - void mark_movie_played(int id)
0x8248 - objptr get_last_target(objptr critter)
0x8249 - objptr get_last_attacker(objptr critter)
0x824b - int tile_under_cursor
0x824c - int gdialog_get_barter_mod
0x824d - void set_inven_ap_cost
0x825c - void reg_anim_combat_check(int enable)
0x825a - void reg_anim_destroy(objptr object)
0x825b - void reg_anim_animate_and_hide(objptr object, int animID, int delay)
0x825d - void reg_anim_light(objptr object, int radius, int delay)
0x825e - void reg_anim_change_fid(objptr object, int FID, int delay)
0x825f - void reg_anim_take_out(objptr object, int holdFrameID, int delay)
0x8260 - void reg_anim_turn_towards(objptr object, int tile/targetObj, int delay)
0x8261 - int metarule2_explosions(objptr object)
0x8262 - void register_hook_proc(int hook, procedure proc)
0x8266 - char* message_str_game(int fileId, int messageId)
0x8267 - int sneak_success
0x8268 - int tile_light(int elevation, int tileNum)
0x8269 - ObjectPtr obj_blocking_line(ObjectPtr objFrom, int tileTo, int blockingType)
0x826a - ObjectPtr obj_blocking_tile(int tileNum, int elevation, int blockingType)
0x826b - array tile_get_objs(int tileNum, int elevation)
0x826c - array party_member_list(int includeHidden)
0x826d - array path_find_to(ObjectPtr objFrom, int tileTo, int blockingType)
0x826e - ObjectPtr create_spatial(int scriptID, int tile, int elevation, int radius)
0x826f - int art_exists(int artFID)
0x8270 - int obj_is_carrying_obj(ObjectPtr invenObj, ObjectPtr itemObj)
* These functions require AllowUnsafeScripting to be enabled in ddraw.ini
@@ -0,0 +1,324 @@
-------------------------------------
---------- GLOBAL SCRIPTS -----------
-------------------------------------
As well as the new functions, sfall also adds global scripts. These run independent of any loaded maps, but do not have an attached object. (i.e. using self_obj without using set_self first will crash the script.) To use a global script, the script must have a name which begins with 'gl' and contains a procedure called 'start'. This procedure will be executed once when the player loads a saved game or starts a new game. If you wish the script to be executed repeatedly, call set_global_script_repeat on this first run using the number of frames between each run as the argument. (0 disables the script, 1 runs it every frame, 2 runs it every other frame etc.)
Global scripts have multiple modes, which can be set using the set_global_script_type function. In the default mode (i.e. mode 0) their execution is linked to the local map game loop, so the script will not run in dialogs or on the world map. In mode 1 their execution is linked to the player input, and so they will run whenever the mouse cursor is visible on screen, including the world map, character dialogs etc. In mode 2, execution is linked to the world map loop, so the script will only be executed on the world map and not on the local map or in any dialog windows. Mode 3 is a combination of modes 0 and 2, so scripts will be executed on both local maps and the world map, but not in dialog windows. Using mode 1 requires the input wrapper to be enabled. Use available_global_script_types to check what is available.
-------------------------------------
------ NOTES ON NEW FUNCTIONS -------
-------------------------------------
Both set_global_script_repeat and set_global_script_type only have an effect on the script they were called from. Every global script needs its own game_loaded block to correctly set up the script type and repeat rate. set_global_script_repeat will have no effect if called on a non-global script.
The read_xxx functions take a memory address as the parameter and can read arbitrary pieces of fallouts address space. The write functions are equivilent except that they write to arbitrary memory addresses. The call_offset_xx functions can be used to call arbitrary functions inside fallout. Different versions are used to call functions with different numbers of arguments. None of these functions will work unless AllowUnsafeScripting is enabled in ddraw.ini
The get/set_pc_base/extra_stat functions are equivelent to calling get/set_critter_base/extra_stat with dude_obj as the critter pointer. None of these stat functions take perks into account, and neither do they do range clamping to make sure the stats are valid. Use the normal get_critter_stat function to get a correctly perk adjusted and range clamped value for a stat.
The set_stat_max/min functions can be used to set the valid ranges on on stats. Values returned by get_current_stat will be clamped to this range. The set_pc_ function only effect the player, the set_npc_ functions only effect other critters, and the set_ functions effect both.
The input functions are only available if the user has the input hook turned on in ddraw.ini. Use input_funcs_available to check.
The graphics functions are only available if the user is using graphics mode 4 or 5. Use graphics_funcs_available to check; it returns 1 if you can use them or 0 if you can't. Calling graphics functions when graphics_funcs_available returns 0 will do nothing.
load_shader takes a path relative to the data\shaders\ directory as an argument and returns a shader ID. That ID should be passed as the first argument to all other shader functions, and is valid until free_shader is called on the ID, the player loads a saved game or the player quits to the main menu.
get_shader_version gives you the higest shader version supported by the players graphics cards. Possible return values are 11, 12, 13, 14, 20, 21 and 30.
set_shader_mode tells sfall when to use a shader. The parameter is a set of 32 flags which specify the screens on which the shader will be disabled, unless bit 32 is set, in which case the shader will only be active on those screens. Remember that screens are displayed on top of each other; if the player opens the character menu which in combat, the game still considers the player to be in combat. See sfall.h for a list of defines.
force_graphics_refresh forces the screen to redraw at times when it normally wouldn't. If you're using animated shader, turning this option on is recommended.
The mapper manual lists the functions 'world_map_x_pos' and 'world_map_y_pos', which supposedly return the players x and y positions on the world map. get_world_map_x/y_pos are included here anyway, because I was unable to get those original functions to work, or even to find any evidence that they existed in game.
set_pipboy_available will only accept 0 or 1 as an argument. Using any other value will cause the function to have no effect. Use 0 to disable the pipboy, and 1 to enable it.
get/set_critter_current_ap functions should only be used during the target critters turn while in combat. Calling them outside of combat typically returns the critters max ap, but don't rely on that behaviour. (Specifically, if the critter has never before entered combat, it will probably return the critters base ap ignoring any extra bonuses from perks etc.) Using set_critter_current_ap on the player will not automatically redraw the screen, so the ap bar will be incorrect until the player next clicks.
The 'type' value in the weapon knockback functions can be 0 or 1. If 0, the value becomes an absolute distance that targets will be knocked back. If 1, the value is multiplied by the distance they would normally have been knocked back. Weapon knockback modifiers are applied in the order weapon -> attacker -> target, so a x2 weapon weilded by an abs 6 attacker hitting a /2 target will knock the target back 3 squares. The knockback functions will not override the stonewall perk or knockdowns resulting from criticals. knockback values set on weapons or critters are not saved, and must be reset each time the player reloads.
The get/set_sfall_global functions require an 8 character long case sensitive string for the variable name. The variables behave the same as normal fallout globals, except that they don't have to be declared beforehand in vault13.gam. Trying to get a variable which hasn't been set will always return 0. These functions are intended for use when a patch to a mod requires the addition of a new global variable, a case which would otherwise require the player to start a new game.
set_pickpocket_max and set_hit_chance_max effect all critters rather than just the player. set_skill_max can't be used to increase the skill cap above 300. set_perk_level_mod sets a modifier between +25 and -25 that is added/subtracted from the players level for the purposes of deciding which perks can be chosen.
set_fake_trait and set_fake_perk can be used to add additional traits and perks to the character screen. They will be saved correctly when the player saves and reloads games, but by themselves they will have no further effect on the character. For perks, the allowed range for levels is between 0 and 100; setting the level to 0 removes that perk. For traits, the level must be 0 or 1. The image is a numeric id that corrisponds to an entry in skilldex.lst. The name is limited to 64 characters and the description to 1024 characters by sfall, but internal fallout limits may be lower.
has_fake_trait and has_fake_perk return the number of levels the player has of the perks/traits with the given name.
perk_add_mode, set_selectable_perk, set_perkbox_title, hide_real_perks, show_real_perks and clear_selectable_perks control the behaviour of the select a perk box. set_selectable_perk can be used to add additional items by setting the 'active' parameter to 1, and to remove them again by setting it to 0. set_perkbox_title can be used to change the title of the box, or by using "" it will be set back to the default. hide and show_real_perks can be used to prevent the dialog from displaying any of the original 119 perks. perk_add_mode modifies what happens when a fake perk is selected from the perks dialog. It is treated as a set of flags - if bit 1 is set then it is added to the players traits, if bit 2 is set it is added to the players perks, and if bit 3 is set it is removed from the list of selectable perks. The default is 0x2. clear_selectable_perks restores the dialog to it's default state.
show_iface_tag, hide_iface_tag and is_iface_tag_active relate to the boxes that appear above the interface such as SNEAK and LEVEL. You can use 3 for LEVEL and 4 for ADDICT, or the range from 5 to 9 for custom boxes. Remember to add your messages to intrface.msg and setup the font colours in ddraw.ini if you're going to use custom boxes.
get/set_bodypart_hit_modifier alter the hit percentage modifiers for aiming at specific bodyparts. Valid bodypart id's are from 0 to 8. Changes are not saved, and will reset to the defaults (or to the values specified in ddraw.ini if they exist) at each reload.
(re)set/get_critical_table are used for modifing the critical table. For details see 'http://falloutmods.wikia.com/wiki/Critical_hit_tables'. Changes are not saved, and will reset to the defaults, (or to the contents of CriticalOverrides.ini, if it exists,) at each game reload. These function also require OverrideCriticalTable to be set to 1 in ddraw.ini. (Disabled by default, because it noticably increases loading times.)
get/set_unspent_ap_bonus alter the AC bonus you recieve per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.) get/set_unspent_ap_perk_bonus are similar, but effect the extra AC granted by the h2h evade perk. (The default value of this is also 4, equivilent to doubling the original bonus.)
nb_* functions are reserved for the brotherhood tactical training mod, and should be avoided.
The fs_* functions are used to manipulate a virtual file system. Files saved here should have paths relative to the data folder, and use backslashes as the directory seperator. They will take precedence over files stored in the normal data folder. They will also be saved into save games, so be avoid creating large files. Using fs_copy followed by fs_read_xxx, you can read the contents of existing files.
get/set_proto_data are used to manipulate the in memory copies of the .pro files fallout makes when they are loaded. The offset refers to the offset in memory from the start of the proto to the element you are reading, and is equal to the file offset minus 12. Changes are not stored on disc, and are not permenent. If you modify the protos, and then fallout subsequently reloads the file your changes will be lost.
the list_xxx functions can be used to loop over all items on a map. list_begin takes an argument telling sfall what you want to list. (Defined in sfall.h) It returns a list pointer, which you iterate through with list_next. Finally, when you've finished with the list use list_end on it. Not calling list_end will result in a memory leak. Alternatively, use list_as_array to get the whole list at once as a temp array variable, which can be looped over using len_array and which you don't need to remember to free afterwards.
play_sfall_sound and stop_sfall_sound are used to play mp3/wav/wma files. The path given is relative to the fallout folder. Specify loop as 1 to loop the file continuously, or 0 otherwise. If you don't wish to loop, play_sfall_sound returns 0. If you do loop, it returns an id which can be passed back to stop_sfall_sound when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. These functions do not require 'AllowDShowSound' to be set to 1 in ddraw.ini.
arrays are created and manipulated with the xxx_array functions. An array must first be created with create_array or temp_array, specifying how many data elements the array can hold. You can store any of ints, floats and strings in an array, and can mix all 3 in a single array. The id returned by create/temp_array can then be used with the other array functions. Arrays are shared between all scripts. (i.e. you can call create_array from one script, and then use the returned id from another script.) They are also saved across savegames. You must remember to free any arrays you create with create_array when you are done with them, or you will leak memory. arrays created with temp_array will be automatically freed at the end of the frame. These functions are safe, in that supplying a bad id or trying to access out of range elements will not crash the script. create_array is the only function that returns a permenent array, all other functions which return arrays (string_split, list_as_array etc,) all return temp arrays. You can use fix_array to make a temp array permenent.
NOTE: the above description only applies when "arraysBehavior" is set to 0 in ddraw.ini. Refer to "arrays.txt" for detailed description of new arrays behavior.
force_aimed_shots and disable_aimed_shots allow overriding the normal rules regarding which weapons are allowed to make aimed attacks. (e.g. weapons that cause explosive damage normally cannot normally make aimed shots.) force_aimed_shots will allow a weapon to make aimed shots even if it normally couldn't, and disable_aimed_shots stops a weapon from making aimed shots even if it normally could. Both of these functions affect player and npcs alike. force_aimed_shots does not override the effects of the fast shot trait. The list of edited weapons is not saved over game loads, so you need to call the functions once at each reload. Use a pid of 0 to represent unarmed.
get/set_critter_skill_points will get/set the number of additional points a critter has in a skill, on top of whatever they have from their stats and other bonuses. Note that skill points are part of the proto, so calling set_skill_points on a critter will affect all critters that share the same proto.
----------------------------------------------
------ FUNCTION REFERENCE (incomplete) -------
----------------------------------------------
> int game_loaded()
- returns 1 the first time it is called after a new game or game load, and 0 any time after. It works on an individual basis for each script, so one script wont interfere with others. It's primary use is for global scripts, so that they know when to call set_global_script_repeat, but it can be called from normal scripts too.
> void inc_npc_level(string npc)
- takes an npc name as an argument. The npc must be in your party. This function ignores player level requirements and the minimum 3 player level delay between npc level gains. It also ignores the random element, regardless of sfall's NPCAutoLevel setting.
> int get_npc_level(string npc)
- also takes the npc name as an argument, and returns the npc's current level. Again, the npc needs to be in your party.
> int get_ini_setting(string setting)
- reads an integer value from an ini file in the fallout directory.
- It only takes a single argument; seperate the file name, section and key with a '|' character; e.g. 'myvar:=get_ini_setting("myini.ini|mysec|var1")' If the file or key cannot be found, -1 is returned.
- The file name is limited to 16 chars, including the extension.
- The section name is limited to 8 characters.
- It can also be used to get sfalls settings, by using ddraw.ini as the file name.
> string get_ini_string(string setting)
- reads a string value from an ini file in the fallout directory.
> int get_game_mode()
- is a more flexible version of in_world_map. It will return a set of flags indicating which mode the game is currently in.
- These flags are the same as those used in the set_shader_mode function.
> int get_uptime()
- is just a wrapper around the windows GetTickCount() function. It's useful for making time fade effects in shaders, since they already have access to the current tick count.
> boolean in_world_map()
- returns 1 if the player is looking at the world map, or 0 at any other time.
- Obviously this is only useful in global scripts, since normal scripts will never get the chance to run on the world map.
> void force_encounter(int map)
- can be called either from a global script while traveling on the world map, or from a normal script while on a local map.
- In either case the encounter occurs shortly after the next time the player moves on the world map.
- The player will not get an outdoorsman skill check.
> void force_encounter_with_flags(int map, int flags)
- does the same thing as force_encounter, but allows the specification of some extra options.
- Forcing a random encounter on a map that is not normally used for random encounters may cause the player to lose the car, if they have it.
- In this case use force_encounter_with_flags with the ENCOUNTER_FLAG_NO_CAR flag set.
> int get_light_level()
- ambient light level in range 0..65535
- The value returned by get_light_level may not exactly match that set by set_light_level, as set_light_level applies modifiers from the night vision perk.
> void set_map_time_multi(float multi)
- adjusts how fast time passes while you're on the world map. It takes a single float as an argument, where 1 is the normal speed.
- This function works in addition to the WorldMapTimeMod setting in ddraw.ini and the pathfinder perk, rather than overriding it, so calling set_map_time_multi(0.5) when the player has 2 levels of pathfinder would result in time passing at 25% the normal speed on the world map.
> void remove_script(objptr)
- accepts a pointer to an object and will remove the script from that object.
> void set_script(objptr, int scriptid)
- accepts a pointer to an object and scriptID, and applies the given script to an object (scriptID accept the same values as create_object_sid from sfall 3.6)
- If used on an object that is already scripted, it will remove the existing script first; you cannot have multiple scripts attached to a single object. Calling set_script on self_obj will have all sorts of wacky side effects, and should be avoided.
- if you add 0x80000000 to the sid when calling set_script, map_enter_p_proc will be SKIPPED. The start proc will always be run.
> int get_script(objptr)
- accepts a pointer to an object and returns it's scriptID (line number in scripts.lst), or -1 if the object is unscripted.
> void set_self(int obj)
- overrides the scripts self_obj for the next function call.
- It is primarily used to allow the calling of functions which take an implicit self_obj parameter (e.g. drop_obj) from global scripts, but it can also be used from normal scripts;
- self_obj will revert back to its original value after the next function call.
- calling self_obj(0) will also revert self_obj to original value
- source_obj, target_obj, and similar functions will not work if preceeded by "set_self"
> void mod_skill_points_per_level(int x)
- accepts a value of between -100 and 100, and modifies the number of skill points the player recieves when they level up.
- This is a modification of what would otherwise happen, rather than a replacement.
- The value is not saved into the save game, so should be reset in the game_loaded section of a script.
> void seq_perk_freq(int x)
- sets the number of levels between each perk.
- Setting 0 will reset it back to the default.
- This overrides the effects of the skilled trait.
- It is not saved into the save game, so needs to be called once per reload.
- Be careful not to let the player obtain a perk when no perks are available to pick, or the game may crash.
> ObjectPtr get_last_target(objptr)
- will return the last critter to be deliberately attacked
> ObjectPtr get_last_attacker(objptr)
- will return the last critter to deliberately launch an attack against the argument critter.
- If a critter has not launched/recieved an attack, it will return 0. This is only stored for the duration of combat, and outside of combat both functions will always return 0.
> void set_base_pickpocket_mod(int max, int mod)
- changes maximum chance of success and chance mod for each steal attempt
- "max" will replace 95% success chance cap (so you can set 100% maximum chance, for instance)
- "mod" will add this much percent to each success chance. for example if your chance is 50% and "mod" is 20, you will get 70% actual success rate
> void set_critter_pickpocket_mod(CritterPtr, int max, int mod)
- the same as above, but applies only to specific critter
> void reg_anim_combat_check
- allows to enable all reg_anim_* functions in combat (including vanilla functions) if set to 0. It is automatically reset at the end of each frame, so you need to call it before "reg_anim_begin" - "reg_anim_end" block.
Some additional reg_anim_* functions were introduced. They all work in the same convention as vanilla functions and use the same underlying code.
> void reg_anim_destroy(object)
- given object is destroyed at the end of current animation set
> void reg_anim_animate_and_hide(object, animID, delay)
- exactly like "reg_anim_animate" but the object will automatically disappear after the last animation frame (but not destroyed)
> void reg_anim_light(object, light, delay)
- change light of any object. light argument is a light radius (0-8), but you can use highest 2 bytes to pass light intensity as well (example: 0xFFFF0008 - intensity 65535 and radius 8). If highest 2 bytes are 0, intensity will not be changed. Intensity range is from 0 to 65535 (0xFFFF).
> void reg_anim_change_fid(object, fid, delay)
- should work like art_change_fid_num but in reg_anim sequence
> void reg_anim_take_out(object, holdFrameID, delay)
- plays "take out weapon" animation for given holdFrameID. It is not required to have such weapon in critter's inventory.
> void reg_anim_turn_towards(object, tile/target, delay)
- makes object change it's direction to face given tile num or target object.
> int metarule2_explosions(int arg1, int arg2)
was made as a dirty easy hack to allow dynamically change some explosion parameters (ranged attack). All changed parameters are reset to vanilla state automatically after each attack action. Following macros are available in sfall.h:
> void set_attack_explosion_pattern(x, y)
- currently y is not used and x means: 1 - reduced explosion pattern (3 effects are spawned instead of 7), 0 - full pattern
> void set_attack_explosion_art(x, y)
- y not used and x is a misc frame ID (last 3 bytes, without object type) to use for the next explosion.
> void set_attack_explosion_radius(x)
- changes radius at which explosion will hit secondary targets for the next attack (from the experiments it is limited to something around 8 by the engine)
> void set_attack_is_explosion_fire
- if you call this right before using a weapon with fire damage type, it will produce explosion effects (and radius damage) just like "explosion" type, but all targets will still recieve fire damage.
Some utility/math functions are available:
> array string_split(string, split)
- takes a string and a seperator, searches the string for all instances of the seperator, and returns a temp array filled with the pieces of the string split at each instance. If you give an empty string as the seperator, the string is split into individual characters.
- you can use this to search for a substring in a string like this: strlen(get_array(string_split(haystack, needle), 0))
> string substr(string, start, length)
- cuts a substring from a string starting at "start" up to "length" characters. If start is negative - it indicates starting position from the end of the string (for example substr("test", -2, 2) will return last 2 charactes: "st"). If length is negative - it means so many characters will be omitted from the end of string (example: substr("test", 0, -2) will return string without last 2 characters: "te")
> int strlen(char* string)
- returns string length
> string sprintf(char* format, any value)
- formats given value using standart syntax of C printf function (google "printf" for format details). However it is limited to formatting only 1 value.
- can be used to get character by ASCII code ("%c")
> int typeof(any value)
- returns type of the given value: VALTYPE_INT, VALTYPE_FLOAT or VALTYPE_STR.
> int charcode(char* string)
- returns ASCII code for the first character in given string
> ^ operator (exponentiation)
- use as any other arithmetic operator, like 5^(1/3)
- if exponent is integer, you can use negative base, otherwise you will get "nan" with negative base
- if both arguments are integers, result will be integer
> float log(float x)
- natural logarithm of x
> float exponent(float x)
- e^x
> int round(float x)
- round x to the nearest integer
> float sqrt(float x)
- square root of x
> float abs(float x)
- absolute (positive) value of x
> float sin(float x)
> float cos(float x)
> float tan(float x)
- tangent of x
> float arctan(float x, float y)
- arctangent of x
- just pass 1 as y (don't ask...)
> void register_hook_proc(int hook, procedure proc)
- works just like "register_hook", but allows to specify which procedure to use for given hook script (instead of "start")
- use zero (0) as second argument to unregister hook script from current global script
- only use in global scripts
- second argument should be passed just like you pass procedures to functions like gsay_option, giq_option, etc (name without quotes)
- see "hookscripts.txt" for more details
> string message_str_game(int fileId, int messageId)
- works exactly the same as message_str, except you get messages from files in "text/english/game" folder
- use GAME_MSG_* defines or mstr_* macros from sfall.h to use specific msg file
> int sneak_success
- returns 1 if last sneak attempt (roll against skill) was successful, 0 otherwise
- this is an internal engine variable wich is used to determine the perception range of critters (which you can override using HOOK_WITHINPERCEPTION)
> int tile_light(int elevation, int tileNum)
- returns light intensity at the given tile in range from 0 to 65535
> ObjectPtr obj_blocking_line(ObjectPtr objFrom, int tileTo, int blockingType)
- returns first object which blocks direct linear path from objFrom to tileTo using selected blocking function (see BLOCKING_TYPE_* constants in sfall.h)
- if path is clear (no blocker was encountered by selected function) - returns 0
- objFrom is always excluded from calculations, but is required to be a valid object
> ObjectPtr obj_blocking_tile(int tileNum, int elevation, int blockingType)
- returns first object blocking given tile using given blocking function or 0 if tile is clear
> array tile_get_objs(int tileNum, int elevation)
- returns array of all objects at given tile
- it will include any hidden, dead or system objects (like cursor), so make sure to check properly when iterating
> array party_member_list(int includeHidden)
- returns array of all current party members (0 - only critter-type, alive and visible will be returned, 1 - all object, including Trunk, etc.)
> array path_find_to(ObjectPtr objFrom, int tileTo, int blockingType)
- returns the shortest path to a given tile using given blocking function as an array of tile directions (0..5) to move on each step
- array length equals to a number of steps
- empty array means that specified target cannot be reached
> ObjectPtr create_spatial(int scriptID, int tile, int elevation, int radius)
- creates new spatial script with given SID, at given tile, and radius
> int art_exists(int artFID)
- checks if given artFID exists in the game
- useful when you want to check if critter can use specific weapon: art_exists((artFid bwand 0xffff0fff) bwor (weaponAnim * 0x1000))
> int obj_is_carrying_obj(ObjectPtr invenObj, ObjectPtr itemObj)
- returns number of itemObj inside invenObj's inventory, note that both arguments are object pointers
- useful when dealing with different stacks of same item (obj_is_carrying_obj_pid just returns total for all stacks of the same PID)
------------------------
------ MORE INFO -------
------------------------
See other documentation files (arrays.txt, hookscripts.txt) for related functions reference.