Added NPC combat control mod to example mods

Updated item highlighting mod and NPC armor mod.
This commit is contained in:
NovaRain
2023-07-03 15:35:03 +08:00
parent 2148650313
commit 2941157174
13 changed files with 405 additions and 37 deletions
@@ -1,11 +1,13 @@
/**
Item Highlight mod (Lite version)
Item Highlighting mod (Lite version)
A cut-down version of the mod included in sfall 4.x, offers a bit more features than the built-in function.
A cut-down version of the mod included in sfall 4.x, offering more features than the built-in function.
Features:
- highlighting items, containers (optional) and lootable corpses (optional) on the ground
- highlights items, containers (optional) and lootable corpses (optional) on the ground
- highlights critters using the same rules as combat mode highlighting (optional)
- configurable hotkey is used to trigger highlight
- hotkey can be pressed and held to continuously update highlighted objects based on current position
- only objects in direct line-of-sight of player are highlighted (optional)
- motion scanner is required to enable highlight (optional)
- motion scanner charges are decreased on each use (optional)
@@ -15,7 +17,7 @@
NOTE: this script requires compiler from sfall modderspack with -s option
(short circuit evaluation)
version 1.1
version 1.2
**/
@@ -24,6 +26,7 @@
#define CRITTER_IS_DEAD (1)
#define PID_MOTION_SENSOR (59)
#define REPEAT_FRAMES (10)
#define NO_HIGHLIGHT(obj) (get_flags(obj) bwand FLAG_NOHIGHLIGHT)
#define NO_STEAL(obj) (get_proto_data(obj_pid(obj), PROTO_CR_FLAGS) bwand CFLG_NOSTEAL)
@@ -32,36 +35,70 @@ variable highlightKey;
variable isHighlight;
variable alsoContainer;
variable alsoCorpse;
variable alsoCritter;
variable checkLOS;
variable outlineColor;
variable motionScanner;
variable highlightFailMsg1;
variable highlightFailMsg2;
procedure ToggleHighlightObject(variable obj, variable enable) begin
if obj and (not enable or not checkLOS or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT)) then begin
if (alsoContainer and obj_item_subtype(obj) == item_type_container) or (not NO_HIGHLIGHT(obj)) then begin
if (enable) then set_outline(obj, outlineColor);
else set_outline(obj, 0);
procedure DudeCanSee(variable obj) begin
variable block := obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT);
return not block or block == obj;
end
procedure DudeCanHear(variable obj) begin
variable hearDist := dude_perception * 5;
if (get_flags(obj) bwand FLAG_TRANSGLASS) then
hearDist /= 2;
return tile_distance_objs(dude_obj, obj) <= hearDist;
end
procedure GetOutlineColor(variable obj, variable isCritter) begin
if isCritter then begin
if get_team(obj) == get_team(dude_obj) then return OUTLINE_GREEN_GLOW;
if not DudeCanSee(obj) then begin
if (DudeCanHear(obj)) then return OUTLINE_DARK_YELLOW;
return 0;
end
return OUTLINE_RED_GLOW;
end
if checkLOS and not DudeCanSee(obj) then
return 0;
return outlineColor;
end
procedure ToggleHighlightObject(variable obj, variable enable, variable isCritter) begin
if (not alsoContainer or obj_item_subtype(obj) != item_type_container) and NO_HIGHLIGHT(obj) then return;
set_outline(obj, GetOutlineColor(obj, isCritter) if enable else 0);
end
procedure ToggleHighlight(variable enable) begin
variable obj;
variable obj, isCorpse;
foreach obj in list_as_array(LIST_GROUNDITEMS) begin
if obj != outlined_object then begin
call ToggleHighlightObject(obj, enable);
if obj and obj != outlined_object then begin
call ToggleHighlightObject(obj, enable, false);
end
end
if (alsoCorpse) then begin
if (alsoCorpse or alsoCritter) then begin
foreach obj in list_as_array(LIST_CRITTERS) begin
if critter_state(obj) == CRITTER_IS_DEAD and not NO_STEAL(obj) then begin
call ToggleHighlightObject(obj, enable);
if obj and obj != dude_obj then begin
isCorpse := critter_state(obj) == CRITTER_IS_DEAD;
if (alsoCritter and not isCorpse) or (isCorpse and not NO_STEAL(obj)) then begin
call ToggleHighlightObject(obj, enable, not isCorpse);
end
end
end
end
tile_refresh_display;
if (checkLOS or alsoCritter) and enable != isHighlight then begin
set_global_script_repeat(REPEAT_FRAMES if enable else 0);
end
isHighlight := enable;
end
procedure KeyPressHandler begin
@@ -71,7 +108,7 @@ procedure KeyPressHandler begin
if scanCode == highlightKey and not(get_game_mode bwand (INTFACELOOT bwor BARTER)) then begin
if pressed then begin
isHighlight := true;
set_global_script_repeat(REPEAT_FRAMES);
if motionScanner then begin
scanner := obj_carrying_pid_obj(dude_obj, PID_MOTION_SENSOR);
if scanner then begin
@@ -94,16 +131,21 @@ procedure KeyPressHandler begin
call ToggleHighlight(true);
end
end else begin
isHighlight := false;
call ToggleHighlight(false);
end
end
end
// visual glitch fix - for 3.8.29+
// visual glitch fix, turn off highlight when entering combat - for 3.8.40+
procedure CombatTurnHandler begin
if isHighlight then begin
call ToggleHighlight(false);
end
end
// visual glitch fix, turn off highlight when opening loot/barter screens - for 3.8.29+
procedure GameModeChangeHandler begin
if isHighlight and (get_game_mode bwand (INTFACELOOT bwor BARTER)) then begin
isHighlight := false;
call ToggleHighlight(false);
end
end
@@ -114,12 +156,15 @@ procedure InventoryMoveHandler begin
end
procedure start begin
if game_loaded and (sfall_ver_major < 4 and sfall_ver_build >= 12) then begin
if game_loaded then begin
if (sfall_ver_major >= 4 or sfall_ver_build < 12) then return;
call InitConfigs;
highlightKey := GetConfig(configSection, "Key", 0);
alsoContainer := GetConfig(configSection, "Containers", 0);
alsoCorpse := GetConfig(configSection, "Corpses", 0);
alsoCritter := GetConfig(configSection, "Critters", 0);
checkLOS := GetConfig(configSection, "CheckLOS", 0);
outlineColor := GetConfig(configSection, "OutlineColor", 16);
if (outlineColor < 1) then outlineColor := 64;
@@ -129,7 +174,13 @@ procedure start begin
highlightFailMsg2 := Translate("HighlightFail2", "Your motion sensor is out of charge.");
register_hook_proc(HOOK_KEYPRESS, KeyPressHandler);
register_hook_proc(HOOK_COMBATTURN, CombatTurnHandler);
register_hook_proc(HOOK_GAMEMODECHANGE, GameModeChangeHandler);
register_hook_proc(HOOK_INVENTORYMOVE, InventoryMoveHandler);
set_global_script_type(1);
end else begin
if isHighlight and not(get_game_mode bwand (INTFACELOOT bwor BARTER)) then begin
call ToggleHighlight(true);
end
end
end
@@ -12,7 +12,7 @@
#include "..\scripting\headers\lib.inven.h"
*/
variable ini := "sfall-mods.ini";
variable ini := "mods\\sfall-mods.ini";
variable translationIni;
// Gets the integer value from the specified ini
@@ -1,9 +1,9 @@
Item Highlight mod (Lite version) for sfall 3.8.x
-------------------------------------------------
Item Highlighting mod (Lite version) for sfall 3.8.x
----------------------------------------------------
A cut-down version of the mod included in sfall 4.x, offers a bit more features than the built-in function.
A cut-down version of the mod included in sfall 4.x, offers more features than the built-in function.
Features:
- highlighting items, containers (optional) and lootable corpses (optional) on the ground
- highlights items, containers (optional) and lootable corpses (optional) on the ground
- configurable hotkey is used to trigger highlight
- only objects in direct line-of-sight of player are highlighted (optional)
- motion scanner is required to enable highlight (optional)
@@ -12,10 +12,10 @@ Features:
Requires sfall 3.8.12 or higher.
To use, copy gl_highlighting_lite.int to your scripts folder, and copy sfall-mods.ini to the same directory as sfall.
Also, you should disable the built-in function in ddraw.ini (ToggleItemHighlightsKey=0).
To use, copy gl_highlighting_lite.int to your scripts folder and sfall-mods.ini to the mods folder in the same directory as sfall.
Create the mods folder if it does not exist. Also, you should disable the built-in function in ddraw.ini (ToggleItemHighlightsKey=0).
Note that due to the lack of newer game hooks in sfall 3.8.x, there are some minor visual glitches in the lite version:
- items will be kept highlighted when entering combat while holding the highlight key.
- when you pick up items while holding the highlight key, they will be kept highlighted if you drop them on the ground (fixed for 3.8.18+).
- items will be kept highlighted when entering combat while holding the highlight key (fixed in 3.8.40+).
- when you pick up items while holding the highlight key, they will be kept highlighted if you drop them on the ground (fixed in 3.8.18+).
Both glitches can bo solved by pressing and releasing the highlight key again.
@@ -9,10 +9,13 @@ Containers=0
; Set to 1 to also highlight lootable corpses
Corpses=0
; Set to 1 to only highlight objects in the player's line-of-sight
CheckLOS=0
; Set to 1 to also highlight critters, with the same rules as in combat
Critters=0
; Set the color of outlines, available colors:
; Set to 1 to only highlight objects in the player's line-of-sight
CheckLOS=1
; Set the color of outlines for items, corpses, and containers; available colors:
; 1 - glowing red
; 2 - red
; 4 - grey
@@ -20,7 +23,7 @@ CheckLOS=0
; 16 - bright yellow
; 32 - dark yellow
; 64 - purple
; You can set a custom color from the game palette by multiplying the color index value by 256 (available since sfall 4.2.7)
; You can set a custom color from the game palette by multiplying the color index value by 256 (in 3.8.27 or later)
OutlineColor=16
; Motion Scanner mode:
@@ -28,3 +31,37 @@ OutlineColor=16
; 1 - requires Motion Scanner present in player inventory to activate highlighting
; 2 - requires Motion Scanner and also requires 1 charge on every use (depleted scanner will not work anymore)
MotionScanner=0
[CombatControl]
;Allows you to control other critters directly in combat
;Set to 0 to disable
;Set to 1 to control all critters in combat (allowed only in sfall debugging mode)
;Set to 2 to control all party members
;Set to 3 to let you use the command cursor to specify targets for party members to attack in combat
Mode=0
;If you want to control only specific critters, uncomment the PIDList line and set a comma delimited list of PIDs
;PIDList=62,89,97,107,160,161
;Set a comma delimited list of perk IDs for perks to be inherited from the player during the combat control
PerksList=0,73
;Set to 1 to allow the player to gain a positive reputation when killing NPCs while controlling other critters
GainReputation=0
;Choose a notification box to display the name of the controlled critter above the interface bar
;Must be between 5 and (4 + the value of BoxBarCount in ddraw.ini)
;For sfall 4.1.6+ the number for the notification box is set automatically, so just use any value
;Set to 0 to disable
DisplayName=0
;Set the color of display name, available colors:
;0 - green
;1 - red
;2 - white
;3 - yellow
;4 - dark yellow
;5 - blue
;6 - purple
;7 - dull pink
DisplayNameColor=0