12
12
*/
13
13
14
14
#define SFALL_SC_EVALUATION (true) // ScriptEditor 4.0: Automatic script compilation with -s option
15
+ #define DEBUG (false)
15
16
16
17
#include "..\headers\define.h"
17
18
#include "..\headers\command.h"
18
19
#include "main.h"
19
20
20
21
#define OBJ_DATA_LIGHT_DISTANCE (0x6C)
21
22
#define OBJ_DATA_LIGHT_INTENSITY (0x70)
23
+ #define PID_PLAYER (16777216)
22
24
23
25
procedure start;
24
26
procedure AllowControl(variable pid);
@@ -35,14 +37,13 @@ variable
35
37
noCheckArray,
36
38
pidList,
37
39
lightInt, lightDist, npcControl,
38
- displayName, displayNameColor, //isOutline := false,
40
+ displayName, displayNameColor, isShowTag, //isOutline := false,
39
41
inControl := false,
40
42
hasAwareness := false,
41
43
hasGeckoSkinning := false;
42
44
43
45
44
46
procedure AllowControl(variable pid) begin
45
-
46
47
if (noCheckArray or scan_array(pidList, pid bwand 0xFFFFFF) != -1) and (party_member_obj(pid)) then return true;
47
48
return false;
48
49
end
@@ -51,20 +52,25 @@ procedure CombaTurn_Handler begin
51
52
variable
52
53
status := get_sfall_arg,
53
54
critter := get_sfall_arg,
54
- //arg3 := get_sfall_arg,
55
55
pid;
56
- //display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + ", arg3: " + arg3);
57
56
58
57
if (not(toggleControl)) then return;
59
58
59
+ if DEBUG then begin
60
+ display_msg("Combat Turn: " + status + ", by " + obj_name(critter)+ "/" + critter + ", arg3: " + get_sfall_arg);
61
+ end
62
+
60
63
if (npcControl) then begin
61
64
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
63
66
end
64
67
65
68
pid := obj_pid(critter);
66
69
if (status == 1 and (AllowControl(pid) or controlMode == 1)) then begin
67
70
set_dude_obj(critter);
71
+ if DEBUG then begin
72
+ display_msg("Set control to: " + obj_name(critter));
73
+ end
68
74
if (critter != real_dude_obj) then begin
69
75
if not(npcControl) then obj_set_light_level(real_dude_obj, 0, 0); // dude off light
70
76
npcControl := critter;
@@ -75,44 +81,48 @@ procedure CombaTurn_Handler begin
75
81
if hasGeckoSkinning then critter_add_trait(critter, TRAIT_PERK, PERK_gecko_skinning_perk, 1);
76
82
if hasAwareness then critter_add_trait(critter, TRAIT_PERK, PERK_bonus_awareness, 1);
77
83
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
81
88
end
82
89
if inControl then begin
83
90
/*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
85
92
move_to(dude_obj, dude_tile, dude_elevation);
86
93
if (displayName and critter != real_dude_obj) then begin
87
94
set_iface_tag_text(displayName, obj_name(critter), displayNameColor);
88
95
show_iface_tag(displayName);
96
+ isShowTag := true;
89
97
end
90
98
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
97
111
end
98
112
end
113
+
99
114
end
100
115
101
116
procedure GameModeChange_Handler begin
102
117
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
104
119
hasGeckoSkinning := has_trait(TRAIT_PERK, dude_obj, PERK_gecko_skinning_perk);
105
120
hasAwareness := has_trait(TRAIT_PERK, dude_obj, PERK_bonus_awareness);
106
121
//isOutline := (get_light_level > 32768);
107
122
end
108
-
109
123
if (inControl and not(get_game_mode BWAND COMBAT)) then begin
110
124
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;
116
126
move_to(dude_obj, dude_tile, dude_elevation);
117
127
end
118
128
end
@@ -125,7 +135,7 @@ procedure InventoryMove_Handler begin
125
135
126
136
int ret1 - Override setting (-1 - use engine handler, any other value - prevent relocation of item/reloading weapon)
127
137
*/
128
- if (inControl and get_sfall_arg == 3) then begin // armor slot
138
+ if (npcControl and get_sfall_arg == 3) then begin // armor slot
129
139
if (obj_pid(dude_obj) == PID_MARCUS or proto_data(obj_pid(dude_obj), cr_body_type) != CR_BODY_BIPED) then begin
130
140
display_msg(message_str_game(GAME_MSG_PROTO, 675));
131
141
set_sfall_return(true);
@@ -208,7 +218,7 @@ procedure InvenWield_Handler begin
208
218
end
209
219
210
220
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
212
222
variable value := global_var(GVAR_PLAYER_REPUTATION);
213
223
if (get_sfall_arg > value) then begin
214
224
set_sfall_return(value);
0 commit comments