Skip to content

Commit fab99d9

Browse files
committed
Fixed party control script. Release v4.1.9.
1 parent d07b7bd commit fab99d9

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

artifacts/config_files/sfall-mods.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ DisplayNameColor=2
8282
;Messages
8383
MsgControlOn=NPC combat control: ON
8484
MsgControlOff=NPC combat control: OFF
85-
MsgControl=It is not possible to enable/disable control while controlling NPC.
85+
MsgControl=It is not possible to disable control while controlling NPC.
8686

8787
[Misc]
8888
;Set to 1 to enable mod keys for combat mode

artifacts/ddraw.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;sfall configuration settings
2-
;v4.1.8 - Extended version
2+
;v4.1.9 - Extended version
33

44
[Main]
55
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
@@ -628,7 +628,7 @@ StackEmptyWeapons=0
628628
;If the amount of ammo boxes in the inventory is less than or equal to the reserve, only one box will be used
629629
ReloadReserve=-1
630630

631-
;Set to 1 to change the counter in the 'Move Items' window to start at the maximum number of items
631+
;Set to 1 to change the counter in the 'Move Items' window to start at the maximum number of items, except in the barter screen
632632
ItemCounterDefaultMax=0
633633

634634
;Set to 1 to leave the music playing in dialogue with talking heads

artifacts/mods/gl_partycontrol.ssl

+34-24
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
*/
1313

1414
#define SFALL_SC_EVALUATION (true) // ScriptEditor 4.0: Automatic script compilation with -s option
15+
#define DEBUG (false)
1516

1617
#include "..\headers\define.h"
1718
#include "..\headers\command.h"
1819
#include "main.h"
1920

2021
#define OBJ_DATA_LIGHT_DISTANCE (0x6C)
2122
#define OBJ_DATA_LIGHT_INTENSITY (0x70)
23+
#define PID_PLAYER (16777216)
2224

2325
procedure start;
2426
procedure AllowControl(variable pid);
@@ -35,14 +37,13 @@ variable
3537
noCheckArray,
3638
pidList,
3739
lightInt, lightDist, npcControl,
38-
displayName, displayNameColor, //isOutline := false,
40+
displayName, displayNameColor, isShowTag, //isOutline := false,
3941
inControl := false,
4042
hasAwareness := false,
4143
hasGeckoSkinning := false;
4244

4345

4446
procedure AllowControl(variable pid) begin
45-
4647
if (noCheckArray or scan_array(pidList, pid bwand 0xFFFFFF) != -1) and (party_member_obj(pid)) then return true;
4748
return false;
4849
end
@@ -51,20 +52,25 @@ procedure CombaTurn_Handler begin
5152
variable
5253
status := get_sfall_arg,
5354
critter := get_sfall_arg,
54-
//arg3 := get_sfall_arg,
5555
pid;
56-
//display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + ", arg3: " + arg3);
5756

5857
if (not(toggleControl)) then return;
5958

59+
if DEBUG then begin
60+
display_msg("Combat Turn: " + status + ", by " + obj_name(critter)+ "/" + critter + ", arg3: " + get_sfall_arg);
61+
end
62+
6063
if (npcControl) then begin
6164
if (lightInt) then lightInt := round((lightInt / 65536.0) * 100); // calc percent of intensity
62-
obj_set_light_level(npcControl, lightInt, lightDist); // restore/off light for npc
65+
obj_set_light_level(npcControl, lightInt, lightDist); // restore light for prev. controlled npc
6366
end
6467

6568
pid := obj_pid(critter);
6669
if (status == 1 and (AllowControl(pid) or controlMode == 1)) then begin
6770
set_dude_obj(critter);
71+
if DEBUG then begin
72+
display_msg("Set control to: " + obj_name(critter));
73+
end
6874
if (critter != real_dude_obj) then begin
6975
if not(npcControl) then obj_set_light_level(real_dude_obj, 0, 0); // dude off light
7076
npcControl := critter;
@@ -75,44 +81,48 @@ procedure CombaTurn_Handler begin
7581
if hasGeckoSkinning then critter_add_trait(critter, TRAIT_PERK, PERK_gecko_skinning_perk, 1);
7682
if hasAwareness then critter_add_trait(critter, TRAIT_PERK, PERK_bonus_awareness, 1);
7783
inControl := true;
78-
end else if (npcControl) then begin
79-
obj_set_light_level(dude_obj, 100, 4); // set default light
80-
npcControl := 0;
84+
end
85+
else if (npcControl) then begin
86+
obj_set_light_level(dude_obj, 100, 4); // set dude default light
87+
npcControl := 0; // dude control
8188
end
8289
if inControl then begin
8390
/*if (isOutline) then*/ set_outline(critter, OUTLINE_GREY);
84-
// center the screen on the controlled critter and remove roof tiles
91+
// center the screen on the controlled critter/dude and remove roof tiles
8592
move_to(dude_obj, dude_tile, dude_elevation);
8693
if (displayName and critter != real_dude_obj) then begin
8794
set_iface_tag_text(displayName, obj_name(critter), displayNameColor);
8895
show_iface_tag(displayName);
96+
isShowTag := true;
8997
end
9098
end
91-
end else if (inControl) then begin
92-
if (displayName) then hide_iface_tag(displayName);
93-
if (status == -1 or AllowControl(pid) == false) then begin
94-
set_dude_obj(real_dude_obj);
95-
obj_set_light_level(dude_obj, 100, 4);
96-
npcControl := 0;
99+
end
100+
else if (inControl) then begin
101+
if (isShowTag) then begin
102+
hide_iface_tag(displayName);
103+
isShowTag := false;
104+
end
105+
if (status < 0 or AllowControl(pid) == false) then begin
106+
if (dude_obj != real_dude_obj) then begin
107+
set_dude_obj(real_dude_obj);
108+
obj_set_light_level(dude_obj, 100, 4);
109+
npcControl := 0;
110+
end
97111
end
98112
end
113+
99114
end
100115

101116
procedure GameModeChange_Handler begin
102117

103-
if (not(inControl) and toggleControl and get_game_mode == COMBAT) then begin
118+
if (inControl == false and toggleControl and get_game_mode == COMBAT) then begin
104119
hasGeckoSkinning := has_trait(TRAIT_PERK, dude_obj, PERK_gecko_skinning_perk);
105120
hasAwareness := has_trait(TRAIT_PERK, dude_obj, PERK_bonus_awareness);
106121
//isOutline := (get_light_level > 32768);
107122
end
108-
109123
if (inControl and not(get_game_mode BWAND COMBAT)) then begin
110124
inControl := false;
111-
if (dude_obj != real_dude_obj) then begin
112-
set_dude_obj(real_dude_obj);
113-
obj_set_light_level(dude_obj, 100, 4);
114-
npcControl := 0;
115-
end
125+
npcControl := 0;
116126
move_to(dude_obj, dude_tile, dude_elevation);
117127
end
118128
end
@@ -125,7 +135,7 @@ procedure InventoryMove_Handler begin
125135

126136
int ret1 - Override setting (-1 - use engine handler, any other value - prevent relocation of item/reloading weapon)
127137
*/
128-
if (inControl and get_sfall_arg == 3) then begin // armor slot
138+
if (npcControl and get_sfall_arg == 3) then begin // armor slot
129139
if (obj_pid(dude_obj) == PID_MARCUS or proto_data(obj_pid(dude_obj), cr_body_type) != CR_BODY_BIPED) then begin
130140
display_msg(message_str_game(GAME_MSG_PROTO, 675));
131141
set_sfall_return(true);
@@ -208,7 +218,7 @@ procedure InvenWield_Handler begin
208218
end
209219

210220
procedure SetGlobalVar_Handler begin
211-
if (inControl and get_sfall_arg == GVAR_PLAYER_REPUTATION) then begin
221+
if (npcControl and get_sfall_arg == GVAR_PLAYER_REPUTATION and obj_pid(dude_obj) != PID_PLAYER) then begin
212222
variable value := global_var(GVAR_PLAYER_REPUTATION);
213223
if (get_sfall_arg > value) then begin
214224
set_sfall_return(value);

sfall/Modules/Interface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void ActionPointsBarPatch() {
6565
dlog("Applying expanded action points bar patch.", DL_INIT);
6666
if (hrpIsEnabled) {
6767
// check valid data
68-
if (!stricmp((const char*)0x10039358, "HR_IFACE_%i.frm")) {
68+
if (!_stricmp((const char*)0x10039358, "HR_IFACE_%i.frm")) {
6969
SafeWriteStr(0x10039363, "E.frm"); // patching HRP
7070
} else {
7171
dlog(" Incorrect HRP version!", DL_INIT);

0 commit comments

Comments
 (0)