Fixed the display after switching back in NPC combat control mod

* player's active "sneak" notification box wasn't shown when switching
back after the combat.

Replaced numbers with defines in item highlighting mod.
This commit is contained in:
NovaRain
2023-06-24 14:17:38 +08:00
parent 3f8d322697
commit d7a974c50b
3 changed files with 30 additions and 22 deletions
+2 -2
View File
@@ -9,13 +9,13 @@ Containers=0
; Set to 1 to also highlight lootable corpses ; Set to 1 to also highlight lootable corpses
Corpses=0 Corpses=0
; Set to 1 to also highlight critters ; Set to 1 to also highlight critters, with the same rules as in combat
Critters=0 Critters=0
; Set to 1 to only highlight objects in the player's line-of-sight ; Set to 1 to only highlight objects in the player's line-of-sight
CheckLOS=1 CheckLOS=1
; Set the color of outlines for items, corpses and containers, available colors: ; Set the color of outlines for items, corpses, and containers; available colors:
; 1 - glowing red ; 1 - glowing red
; 2 - red ; 2 - red
; 4 - grey ; 4 - grey
+7 -7
View File
@@ -1,13 +1,13 @@
/** /**
Item Highlight mod. Item Highlight mod
Previously was part of sfall itself, now a separate mod. Previously was part of sfall itself, now a separate mod.
Features: Features:
- highlighting items, containers (optional) and lootable corpses (optional) on the ground - highlighting items, containers (optional) and lootable corpses (optional) on the ground
- highlighting of critters using the same rules as combat mode highlighting (optional) - highlighting critters using the same rules as combat mode highlighting (optional)
- configurable hotkey is used to trigger highlight - configurable hotkey is used to trigger highlight
- hotkey can be pressed and hold to continously update highlighted objects based on current position - 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) - only objects in direct line-of-sight of player are highlighted (optional)
- motion scanner is required to enable highlight (optional) - motion scanner is required to enable highlight (optional)
- motion scanner charges are decreased on each use (optional) - motion scanner charges are decreased on each use (optional)
@@ -55,12 +55,12 @@ end
procedure GetOutlineColor(variable obj, variable isCritter) begin procedure GetOutlineColor(variable obj, variable isCritter) begin
if isCritter then begin if isCritter then begin
if get_team(obj) == get_team(dude_obj) then return 8; if get_team(obj) == get_team(dude_obj) then return OUTLINE_GREEN_GLOW;
if not DudeCanSee(obj) then begin if not DudeCanSee(obj) then begin
if (DudeCanHear(obj)) then return 32; if (DudeCanHear(obj)) then return OUTLINE_DARK_YELLOW;
return 0; return 0;
end end
return 1; return OUTLINE_RED_GLOW;
end end
if checkLOS and not DudeCanSee(obj) then if checkLOS and not DudeCanSee(obj) then
return 0; return 0;
@@ -106,7 +106,7 @@ procedure KeyPressHandler begin
if scanCode == highlightKey and not(get_game_mode bwand (INTFACELOOT bwor BARTER)) then begin if scanCode == highlightKey and not(get_game_mode bwand (INTFACELOOT bwor BARTER)) then begin
if pressed then begin if pressed then begin
set_global_script_repeat(10); set_global_script_repeat(REPEAT_FRAMES);
if motionScanner then begin if motionScanner then begin
scanner := obj_carrying_pid_obj(dude_obj, PID_MOTION_SENSOR); scanner := obj_carrying_pid_obj(dude_obj, PID_MOTION_SENSOR);
if scanner then begin if scanner then begin
+21 -13
View File
@@ -15,6 +15,12 @@
#include "..\headers\critrpid.h" #include "..\headers\critrpid.h"
#include "main.h" #include "main.h"
#ifndef DEBUG
#define DEBUGMSG(x)
#else
#define DEBUGMSG(x) debug_msg(x);
#endif
procedure start; procedure start;
procedure AllowControl(variable pid); procedure AllowControl(variable pid);
procedure SetLight(variable critter, variable int, variable dist); procedure SetLight(variable critter, variable int, variable dist);
@@ -48,25 +54,29 @@ procedure CombatTurn_Handler begin
critter := get_sfall_arg, critter := get_sfall_arg,
pid, perkID, level; pid, perkID, level;
//display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + "/" + critter + ", arg3: " + get_sfall_arg); DEBUGMSG("Combat Turn: " + status + ", by " + obj_name(critter) + "/" + critter + ", arg3: " + get_sfall_arg)
pid := obj_pid(critter); pid := obj_pid(critter);
if (pid == PID_PLAYER and inControl == false) then return; if (pid == PID_PLAYER and inControl == false) then return;
if (pid != PID_PLAYER and controlMode != 1 and AllowControl(pid) == false) then begin if (pid != PID_PLAYER and controlMode != 1 and AllowControl(pid) == false) then begin
DEBUGMSG("Skip control.")
if (npcControl) then begin if (npcControl) then begin
npcControl := 0; npcControl := 0;
set_dude_obj(real_dude_obj);
call SetLight(dude_obj, dudeLightInt, dudeLightDist); // restore dude light call SetLight(dude_obj, dudeLightInt, dudeLightDist); // restore dude light
//move_to(dude_obj, dude_tile, dude_elevation); move_to(dude_obj, dude_tile, dude_elevation);
intface_redraw;
DEBUGMSG("Set dude after NPC control.")
end end
//display_msg("Skip control.");
return; return;
end end
if (status == 1) then begin if (status == 1) then begin
set_dude_obj(critter); set_dude_obj(critter);
//display_msg("Take control of: " + obj_name(critter));
DEBUGMSG("Take control of: " + obj_name(critter))
if (critter != real_dude_obj) then begin if (critter != real_dude_obj) then begin
if (npcControl == 0) then begin if (npcControl == 0) then begin
@@ -118,13 +128,11 @@ procedure CombatTurn_Handler begin
// remove perks before switching control (only work with 4.1.8+) // remove perks before switching control (only work with 4.1.8+)
if (dude_obj != real_dude_obj) then begin if (dude_obj != real_dude_obj) then begin
DEBUGMSG("Remove perks after NPC control.")
foreach (perkID in perksList) begin foreach (perkID in perksList) begin
level := has_trait(TRAIT_PERK, real_dude_obj, perkID); level := has_trait(TRAIT_PERK, real_dude_obj, perkID);
if (level) then critter_rm_trait(critter, TRAIT_PERK, perkID, level); if (level) then critter_rm_trait(critter, TRAIT_PERK, perkID, level);
end end
if (status == 0) then set_dude_obj(0); // w/o redraw interface bar (otherwise it flickers when switching from the player to NPCs)
//display_msg("Return control to real dude!");
end end
if (status < 0) then begin if (status < 0) then begin
@@ -175,11 +183,8 @@ procedure SetGlobalVar_Handler begin
end end
procedure start begin procedure start begin
if (game_loaded and sfall_ver_major >= 4) then begin if game_loaded then begin
//variable configSection := "CombatControl"; if (sfall_ver_major < 4) then return;
set_perk_ranks(PERK_gecko_skinning_perk, 1);
set_perk_level(PERK_gecko_skinning_perk, 999); // prevent it from appearing in the perk selection window
controlMode := GetConfig("CombatControl", "Mode", 0); controlMode := GetConfig("CombatControl", "Mode", 0);
if (controlMode >= 3) then begin if (controlMode >= 3) then begin
@@ -206,6 +211,9 @@ procedure start begin
displayNameColor := GetConfig("CombatControl", "DisplayNameColor", 0); displayNameColor := GetConfig("CombatControl", "DisplayNameColor", 0);
end end
set_perk_ranks(PERK_gecko_skinning_perk, 1);
set_perk_level(PERK_gecko_skinning_perk, 999); // prevent it from appearing in the perk selection window
pidList := GetConfigListInt("CombatControl", "PIDList"); pidList := GetConfigListInt("CombatControl", "PIDList");
if (len_array(pidList) > 0) then if (len_array(pidList) > 0) then
fix_array(pidList); fix_array(pidList);