You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: artifacts/scripting/HookScripts.md
+36-36Lines changed: 36 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,8 +109,8 @@ Critter arg1 - The attacker
109
109
Critter arg2 - The target of the attack
110
110
int arg3 - The targeted bodypart
111
111
int arg4 - Source tile (may differ from attacker's tile, when AI is considering potential fire position)
112
-
int arg5 - Attack Type (one of ATKTYPE_*)
113
-
int arg6 - Ranged flag. 1 means the hit chance is calculated by taking into account the bonuses/penalties of the distance to the target
112
+
int arg5 - Attack Type (see ATKTYPE_* constants)
113
+
int arg6 - Ranged flag. 1 if the hit chance calculation takes into account the distance to the target. This does not mean the attack is a ranged attack
114
114
int arg7 - The raw hit chance before applying the cap
115
115
116
116
int ret0 - the new hit chance
@@ -119,7 +119,7 @@ int ret0 - the new hit chance
119
119
120
120
#### `HOOK_AFTERHITROLL (hs_afterhitroll.int)`
121
121
122
-
Runs after Fallout has decided if an attack will hit or miss
122
+
Runs after Fallout has decided if an attack will hit or miss.
123
123
124
124
```
125
125
int arg0 - If the attack will hit: 0 - critical miss, 1 - miss, 2 - hit, 3 - critical hit
@@ -169,8 +169,8 @@ int ret0 - The pid of an object to override the attacking weapon with
169
169
170
170
#### `HOOK_DEATHANIM2 (hs_deathanim2.int)`
171
171
172
-
Runs after Fallout has calculated the death animation. Lets you set your own custom frame id, so more powerful than `HOOK_DEATHANIM2`, but performs no validation.
173
-
When using critter_dmg function, this script will also run. In that case weapon pid will be -1 and attacker will point to an object with `obj_art_fid == 0x20001F5`.
172
+
Runs after Fallout has calculated the death animation. Lets you set your own custom frame id, so more powerful than `HOOK_DEATHANIM1`, but performs no validation.
173
+
When using `critter_dmg` function, this script will also run. In that case weapon pid will be -1 and attacker will point to an object with `obj_art_fid == 0x20001F5`.
174
174
Does not run for critters in the knockdown/out state.
Runs when checking to see if a hex blocks movement or shooting. (or ai-ing, presumably...)
347
+
Run when checking to see if a hex blocks movement or shooting. (or ai-ing, presumably...)
348
348
349
349
__NOTE:__ These hook scripts can become very CPU-intensive and you should avoid using them.
350
-
For this reason, these hooks are not properly supported in sfall, and may be removed in future versions.
350
+
For this reason, these hooks are not thoroughly supported in sfall, and may be removed in future versions.
351
351
If you want to check if some tile or path is blocked, use functions: `obj_blocking_tile`, `obj_blocking_line`, `path_find_to`.
352
352
If you want script to be called every time NPC moves by hex in combat, use `HOOK_MOVECOST` hook.
353
353
@@ -368,7 +368,7 @@ Runs when retrieving the damage rating of the player's used weapon. (Which may b
368
368
```
369
369
int arg0 - The default min damage
370
370
int arg1 - The default max damage
371
-
Item arg2 - The weapon used. (0 if unarmed)
371
+
Item arg2 - The weapon used (0 if unarmed)
372
372
Critter arg3 - The critter doing the attacking
373
373
int arg4 - The type of attack
374
374
int arg5 - non-zero if this is an attack using a melee weapon
@@ -387,22 +387,22 @@ To add proper check for ammo before attacking and proper calculation of the numb
387
387
```
388
388
Item arg0 - The weapon
389
389
int arg1 - Number of bullets in burst or 1 for single shots
390
-
int arg2 - The amount of ammo that will be consumed, calculated by cost of the original function (this is basically 2 for Super Cattle Prod and Mega Power Fist)
391
-
Note: for hook type 2, this value is the cost of ammo (default is always 1)
390
+
int arg2 - The amount of ammo that will be consumed, calculated by the original ammo cost function (this is basically 2 for Super Cattle Prod and Mega Power Fist)
391
+
NOTE: for hook type 2, this value is the ammo cost per round (default is always 1)
392
392
int arg3 - Type of hook:
393
393
0 - when subtracting ammo after single shot attack
394
394
1 - when checking for "out of ammo" before attack
395
395
2 - when calculating number of burst rounds
396
-
3 - when subtracting ammo after burst attack)
396
+
3 - when subtracting ammo after burst attack
397
397
398
-
int ret0 - The new amount of ammo, or ammo cost value for hook type 2 (set to 0 for unlimited ammo)
398
+
int ret0 - The new amount of ammo to be consumed, or ammo cost per round for hook type 2 (set to 0 for unlimited ammo)
399
399
```
400
400
-------------------------------------------
401
401
402
402
#### `HOOK_KEYPRESS (hs_keypress.int)`
403
403
404
404
Runs once every time when any key was pressed or released.
405
-
- DX codes: see __dik.h__ header or https://kippykip.com/b3ddocs/commands/scancodes.htm
405
+
- DX codes: see **dik.h** header or https://kippykip.com/b3ddocs/commands/scancodes.htm
__NOTE:__ If you want to override a key, the new key DX scancode should be the same for both pressed and released events.
@@ -418,7 +418,7 @@ int ret0 - overrides the pressed key (a new key DX scancode or 0 for no over
418
418
419
419
#### `HOOK_MOUSECLICK (hs_mouseclick.int)`
420
420
421
-
Runs once every time when a mouse button was pressed or release.
421
+
Runs once every time when a mouse button was pressed or released.
422
422
423
423
```
424
424
int arg0 - event type: 1 - pressed, 0 - released
@@ -430,7 +430,7 @@ int arg1 - button number (0 - left, 1 - right, up to 7)
430
430
431
431
Runs when using any skill on any object.
432
432
433
-
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()`).
433
+
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`).
434
434
Suggested use - override first aid/doctor skills to buff/nerf them, override steal skill to disallow observing NPCs inventories in some cases.
435
435
Doesn't seem to run when lock picking.
436
436
@@ -488,7 +488,7 @@ int arg3 - Type of hook:
488
488
int ret0 - overrides the returned result of the function:
489
489
0 - not in range (can't see)
490
490
1 - in range (will see if not blocked)
491
-
2 - forced detection (will see regardless, only used in "obj_can_see_obj" scripting function which is called by every critter in the game)
491
+
2 - forced detection (will see regardless, only used in "obj_can_see_obj" script function which is called by every critter in the game)
492
492
```
493
493
-------------------------------------------
494
494
@@ -545,7 +545,7 @@ int ret0 - overrides hard-coded handler (-1 - use engine handler, any other
545
545
Runs after calculating character figure FID on the inventory screen, whenever the game decides that character appearance might change.
546
546
Also happens on other screens, like barter.
547
547
548
-
__NOTE:__ FID has following format: `0x0ABBCDDD`, where: `A` - is object type, `BB` - animation code (always 0 in this case), `C` - weapon code, `DDD` - FRM index in LST file.
548
+
__NOTE:__ FID has following format: `0x0ABBCDDD`, where: `A` - object type, `BB` - animation code (always 0 in this case), `C` - weapon code, `DDD` - FRM index in LST file.
549
549
550
550
```
551
551
int arg0 - the vanilla FID calculated by the engine according to critter base FID and armor/weapon being used
@@ -650,10 +650,10 @@ int ret1 - overrides the result of engine calculation: 0/1 - failure, 2/3 -
Copy file name to clipboardExpand all lines: artifacts/scripting/arrays.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,8 +245,8 @@ For those who used arrays in their mods before sfall 3.4:
245
245
246
246
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.
247
247
248
+
__NOTE:__ Starting from sfall 4.3.3/3.8.33, the **ArraysBehavior** option is removed, and arrays always work in **ArraysBehavior=1** mode. Make sure to review your scripts if you need to save arrays into savegames.
249
+
248
250
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.
249
251
250
252
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.
251
-
252
-
The **ArraysBehavior** option has been removed from sfall 4.3.3/3.8.33, now arrays always work in **ArraysBehavior=1** mode.
0 commit comments