Code edits to gl_npcarmor script

Added some line breaks in hookscripts.md.
This commit is contained in:
NovaRain
2021-09-03 10:36:33 +08:00
parent 569bde5fab
commit c047402dc9
3 changed files with 27 additions and 27 deletions
Binary file not shown.
+5 -5
View File
@@ -9,7 +9,7 @@
NOTE: this script requires compiler from sfall modderspack with -s option NOTE: this script requires compiler from sfall modderspack with -s option
(short circuit evaluation) (short circuit evaluation)
version 1.2 version 1.4
*/ */
@@ -65,7 +65,7 @@ procedure check_weapon_change(variable critter, variable weapon, variable isWiel
weaponAnimList := npc["WeaponAnims"]; weaponAnimList := npc["WeaponAnims"];
if (weaponAnimList != 0) then begin if (weaponAnimList != 0) then begin
foreach (i in string_split(weaponAnimList, ",")) begin foreach (i in string_split(weaponAnimList, ",")) begin
if (newWeaponAnim == atoi(i) and not(weapon_is_unusable(weapon))) then return -1; // can use (engine default) if (newWeaponAnim == atoi(i)) then return -1; // can use (engine default)
end end
end end
return 0; // can't use return 0; // can't use
@@ -78,13 +78,13 @@ procedure check_weapon_change(variable critter, variable weapon, variable isWiel
end end
/* /*
Finds the first weapon which can be used by the party member in the inventory Finds the first weapon that can be used by the party member in the inventory
*/ */
procedure search_alt_weapon(variable critter) begin procedure search_alt_weapon(variable critter) begin
variable obj, res, i := 0; variable obj, res, i := 0;
obj := inven_ptr(critter, 0); obj := inven_ptr(critter, 0);
while (obj) do begin while (obj) do begin
if (obj_item_subtype(obj) == item_type_weapon) then begin if (obj_item_subtype(obj) == item_type_weapon and weapon_is_unusable(obj) == false) then begin
if (unWieldWeapon == 0 or unWieldWeapon != obj_pid(obj)) then begin if (unWieldWeapon == 0 or unWieldWeapon != obj_pid(obj)) then begin
res := check_weapon_change(critter, obj, 1); res := check_weapon_change(critter, obj, 1);
if (res == -1) then begin if (res == -1) then begin
@@ -226,7 +226,7 @@ end
procedure canuseweapon_handler begin procedure canuseweapon_handler begin
variable critter, canWield; variable critter, canWield;
critter := get_sfall_arg; critter := get_sfall_arg;
if (critter != dude_obj) then begin if (critter != dude_obj and get_sfall_arg_at(3)) then begin
canWield := check_weapon_change(critter, get_sfall_arg, true); canWield := check_weapon_change(critter, get_sfall_arg, true);
// override result // override result
set_sfall_arg(3, canWield); set_sfall_arg(3, canWield);
+22 -22
View File
@@ -87,7 +87,7 @@ The defines to use for the hookID are in **sfall.h**.
#### `HOOK_TOHIT (hs_tohit.int)` #### `HOOK_TOHIT (hs_tohit.int)`
Runs when Fallout is calculating the chances of an attack striking a target. Runs when Fallout is calculating the chances of an attack striking a target.<br>
Runs after the hit chance is fully calculated normally, including applying the 95% cap. Runs after the hit chance is fully calculated normally, including applying the 95% cap.
``` ```
@@ -125,8 +125,8 @@ Critter ret2 - Override the target of the attack
#### `HOOK_CALCAPCOST (hs_calcapcost.int)` #### `HOOK_CALCAPCOST (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. 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.<br>
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 player's hands at the time the wrong AP cost will be shown. It will be fixed the next time the interface is redrawn. 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 player's hands at the time the wrong AP cost will be shown. It will be fixed the next time the interface is redrawn.<br>
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`. 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`.
``` ```
@@ -143,7 +143,7 @@ int ret0 - The new AP cost
#### `HOOK_DEATHANIM1 (hs_deathanim1.int)` #### `HOOK_DEATHANIM1 (hs_deathanim1.int)`
Runs before Fallout tries to calculate the death animation. Lets you switch out which weapon Fallout sees. Runs before Fallout tries to calculate the death animation. Lets you switch out which weapon Fallout sees.<br>
Does not run for critters in the knockdown/out state. Does not run for critters in the knockdown/out state.
``` ```
@@ -160,8 +160,8 @@ int ret0 - The pid of an object to override the attacking weapon with
#### `HOOK_DEATHANIM2 (hs_deathanim2.int)` #### `HOOK_DEATHANIM2 (hs_deathanim2.int)`
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. 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.<br>
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`. 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`.<br>
Does not run for critters in the knockdown/out state. Does not run for critters in the knockdown/out state.
``` ```
@@ -220,7 +220,7 @@ Critter arg0 - The critter that just died
#### `HOOK_FINDTARGET (hs_findtarget.int)` #### `HOOK_FINDTARGET (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. 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.<br>
This hook replaces that sorting function, allowing you to sort the targets in some arbitrary way. This hook replaces that sorting function, allowing you to sort the targets in some arbitrary way.
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, but this is fixed in sfall 4.2.3/3.8.23. 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, but this is fixed in sfall 4.2.3/3.8.23.
@@ -340,10 +340,10 @@ int ret0 - the new AP cost
------------------------------------------- -------------------------------------------
#### DEPRECATED HOOKS: #### DEPRECATED HOOKS:
* `HOOK_HEXMOVEBLOCKING (hs_hexmoveblocking.int)` ##### `HOOK_HEXMOVEBLOCKING (hs_hexmoveblocking.int)`
* `HOOK_HEXAIBLOCKING (hs_hexaiblocking.int)` ##### `HOOK_HEXAIBLOCKING (hs_hexaiblocking.int)`
* `HOOK_HEXSHOOTBLOCKING (hs_hexshootblocking.int)` ##### `HOOK_HEXSHOOTBLOCKING (hs_hexshootblocking.int)`
* `HOOK_HEXSIGHTBLOCKING (hs_hexsightblocking.int)` ##### `HOOK_HEXSIGHTBLOCKING (hs_hexsightblocking.int)`
Run when checking to see if a hex blocks movement or shooting. (or ai-ing, presumably...) Run when checking to see if a hex blocks movement or shooting. (or ai-ing, presumably...)
@@ -501,7 +501,7 @@ int ret0 - overrides the returned result of the function:
#### `HOOK_INVENTORYMOVE (hs_inventorymove.int)` #### `HOOK_INVENTORYMOVE (hs_inventorymove.int)`
Runs before moving items between inventory slots in dude interface. You can override the action. Runs before moving items between inventory slots in dude interface. You can override the action.<br>
What you can NOT do with this hook: What you can NOT do with this hook:
- force moving items to inappropriate slots (like gun in armor slot) - force moving items to inappropriate slots (like gun in armor slot)
@@ -531,7 +531,7 @@ int ret0 - Override setting (-1 - use engine handler, any other value - prev
#### `HOOK_INVENWIELD (hs_invenwield.int)` #### `HOOK_INVENWIELD (hs_invenwield.int)`
Runs before causing a critter or the player to wield/unwield an armor or a weapon (except when using the inventory by PC). Runs before causing a critter or the player to wield/unwield an armor or a weapon (except when using the inventory by PC).<br>
An example usage would be to change critter art depending on armor being used or to dynamically customize weapon animations. An example usage would be to change critter art depending on armor being used or to dynamically customize weapon animations.
__NOTE:__ When replacing a previously wielded armor or weapon, the unwielding hook will not be executed. __NOTE:__ When replacing a previously wielded armor or weapon, the unwielding hook will not be executed.
@@ -551,7 +551,7 @@ int ret0 - overrides hard-coded handler (-1 - use engine handler, any other
#### `HOOK_ADJUSTFID (hs_adjustfid.int)` #### `HOOK_ADJUSTFID (hs_adjustfid.int)`
Runs after calculating character figure FID on the inventory screen, whenever the game decides that character appearance might change. Runs after calculating character figure FID on the inventory screen, whenever the game decides that character appearance might change.<br>
Also happens on other screens, like barter. Also happens on other screens, like barter.
__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. __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.
@@ -699,7 +699,7 @@ int ret1 - pass 1 to allow the skill being used in combat (only for dude_obj
#### `HOOK_ONEXPLOSION (hs_onexplosion.int)` #### `HOOK_ONEXPLOSION (hs_onexplosion.int)`
Runs when Fallout is checking all the tiles within the explosion radius for targets before an explosion occurs. Runs when Fallout is checking all the tiles within the explosion radius for targets before an explosion occurs.<br>
The tile checking will be interrupted when 6 additional targets (critters) are received. The tile checking will be interrupted when 6 additional targets (critters) are received.
``` ```
@@ -762,7 +762,7 @@ int ret1 - overrides the light radius. Radius range is from 0 to 8 (works on
#### `HOOK_SNEAK (hs_sneak.int)` #### `HOOK_SNEAK (hs_sneak.int)`
Runs when the Sneak skill is activated, or when the game rolls another Sneak check after the duration for the current one is over. Runs when the Sneak skill is activated, or when the game rolls another Sneak check after the duration for the current one is over.<br>
You can override the result of a random Sneak check or the duration time for the current result. You can override the result of a random Sneak check or the duration time for the current result.
``` ```
@@ -795,7 +795,7 @@ int ret0 - pass -1 to cancel the execution of the handler (only for HOOK_STD
#### `HOOK_TARGETOBJECT (hs_targetobject.int)` #### `HOOK_TARGETOBJECT (hs_targetobject.int)`
Runs when the targeting cursor hovers over an object, or when the player tries to attack the target object. Runs when the targeting cursor hovers over an object, or when the player tries to attack the target object.<br>
You can override the target object or prevent the player from attacking the chosen target. You can override the target object or prevent the player from attacking the chosen target.
``` ```
@@ -810,7 +810,7 @@ mixed ret0 - overrides the target object, or pass -1 to prevent the player fro
#### `HOOK_ENCOUNTER (hs_encounter.int)` #### `HOOK_ENCOUNTER (hs_encounter.int)`
Runs whenever a random encounter occurs (except the Horrigan meeting and scripted encounters), or when the player enters a local map from the world map. Runs whenever a random encounter occurs (except the Horrigan meeting and scripted encounters), or when the player enters a local map from the world map.<br>
You can override the map for loading or the encounter. You can override the map for loading or the encounter.
``` ```
@@ -880,7 +880,7 @@ int ret0 - overrides the roll result
#### `HOOK_BESTWEAPON (hs_bestweapon.int)` #### `HOOK_BESTWEAPON (hs_bestweapon.int)`
Runs when the AI decides which weapon is the best while searching the inventory for a weapon to equip in combat. Runs when the AI decides which weapon is the best while searching the inventory for a weapon to equip in combat.<br>
This also runs when the player presses the "Use Best Weapon" button on the party member control panel. This also runs when the player presses the "Use Best Weapon" button on the party member control panel.
``` ```
@@ -897,9 +897,9 @@ Item ret0 - overrides the chosen best weapon
#### `HOOK_CANUSEWEAPON (hs_canuseweapon.int)` #### `HOOK_CANUSEWEAPON (hs_canuseweapon.int)`
Run when the AI checks whether it can use a weapon, or when the game checks whether the player can use a weapon. Run when the AI checks whether it can use a weapon, or when the game checks whether the player can use an item (weapon) in hand slot.<br>
For AI, this mostly happens when NPCs try to find weapons in their inventory or on the map. For AI, this mostly happens when NPCs try to find weapons in their inventory or on the map.<br>
For the player, this happens when the game redraws the interface bar. For the player, this happens when the game updates the item data for active item slots on the interface bar.
``` ```
Critter arg0 - the critter doing the check Critter arg0 - the critter doing the check