Moved hard-coded "ControlCombat" mod from sfall into a global script #87

- Exactly the same functionality and settings
- Mod settings are now in sfall-mods.ini
This commit is contained in:
phobos2077
2017-04-01 21:11:19 +07:00
parent 9531fcbebd
commit 116c522bdc
7 changed files with 83 additions and 93 deletions
+10
View File
@@ -22,3 +22,13 @@ OutlineColor=32
; 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=2
[CombatControl]
;Allows you to directly control other critters in combat
;Set to 0 to disable
;Set to 1 to control all critters in combat
;Set to 2 to control all party members
;If you want to control only specific critters, uncomment the PIDList line and set a comma delimited list of PIDs
Mode=0
;PIDList=62,89,97,107,160,161
-8
View File
@@ -515,14 +515,6 @@ DialogPanelAnimDelay=33
;Controls the speed of pipboy alarm clock animations (lower - faster; valid range: 0..127)
PipboyTimeAnimDelay=50
;Allows you to directly control other critters in combat
;Set to 0 to disable
;Set to 1 to control all critters in combat
;Set to 2 to control all party members
;If you want to control only specific critters, uncomment the ControlCombatPIDList line and set a comma delimited list of PIDs
ControlCombat=0
;ControlCombatPIDList=62,89,97,107,160,161
;Set to 1 to stack empty identical weapons, no matter what type of ammo was loaded before
StackEmptyWeapons=0
Binary file not shown.
+51
View File
@@ -0,0 +1,51 @@
/*
NPC Combat Control
Allows to take control of your party member or other NPCs during combat
NOTE: this script requires compiler from sfall modderspack with -s option
(short circuit evaluation)
version 1.0
*/
#include "main.h"
variable
configSection := "CombatControl",
controlMode,
pidList;
procedure combatturn_handler begin
variable
status := get_sfall_arg,
critter := get_sfall_arg,
arg3 := get_sfall_arg,
pid;
// display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + ", arg3: " + arg3);
pid := obj_pid(critter);
if (status == 1
and (len_array(pidList) == 0 or scan_array(pidList, pid bwand 0xFFFFFF) != -1)
and (controlMode == 1 or party_member_obj(pid))) then begin
set_dude_obj(critter);
end else begin
set_dude_obj(real_dude_obj);
end
end
procedure start begin
if game_loaded then begin
controlMode := GetConfig("CombatControl", "Mode", 0);
if (controlMode > 2) then controlMode := 0;
if (controlMode > 0) then begin
pidList := GetConfigListInt("CombatControl", "PIDList");
fix_array(pidList);
register_hook_proc(HOOK_COMBATTURN, combatturn_handler);
end
end
end
+19
View File
@@ -24,6 +24,25 @@ procedure GetConfigStr(variable section, variable key, variable def) begin
return val;
end
// Gets the value from ddraw.ini as a temp array of strings
procedure GetConfigList(variable section, variable key) begin
variable val := get_ini_string(ini + "|" + section + "|" + key);
if val == -1 or val == "" then return [];
return string_split(val, ",");
end
// Gets the value from ddraw.ini as a temp array of ints
procedure GetConfigListInt(variable section, variable key) begin
variable arr, i, item;
arr := GetConfigList(section, key);
for (i := 0; i < len_array(arr); i++) begin
arr[i] := atoi(arr[i]);
end
return arr;
end
// Translates given string using Translations.ini
procedure Translate(variable id, variable def) begin
variable str := get_ini_string(translationIni + "|Sfall|" + id);
-41
View File
@@ -604,46 +604,5 @@ procedure _PURGE_all_saved_arrays begin
free_array(load_array(key));
end
// temp_list* functions are deprecated since we have array expressions
#define _LIST_ELEMENT_SIZE 128
procedure temp_list2(variable x1, variable x2) begin
variable a;
a := temp_array(2, _LIST_ELEMENT_SIZE);
a[0] := x1; a[1] := x2;
return a;
end
procedure temp_list3(variable x1, variable x2, variable x3) begin
variable a;
a := temp_array(3, _LIST_ELEMENT_SIZE);
a[0] := x1; a[1] := x2; a[2] := x3;
return a;
end
procedure temp_list4(variable x1, variable x2, variable x3, variable x4) begin
variable a;
a := temp_array(4, _LIST_ELEMENT_SIZE);
a[0] := x1; a[1] := x2; a[2] := x3; a[3] := x4;
return a;
end
procedure temp_list6(variable x1, variable x2, variable x3, variable x4, variable x5, variable x6) begin
variable a;
a := temp_array(6, _LIST_ELEMENT_SIZE);
a[0] := x1; a[1] := x2; a[2] := x3; a[3] := x4; a[4] := x5; a[5] := x6;
return a;
end
procedure temp_list8(variable x1, variable x2, variable x3, variable x4, variable x5, variable x6, variable x7, variable x8) begin
variable a;
a := temp_array(8, _LIST_ELEMENT_SIZE);
a[0] := x1; a[1] := x2; a[2] := x3; a[3] := x4; a[4] := x5; a[5] := x6; a[6] := x7; a[7] := x8;
return a;
end
#undef _LIST_ELEMENT_SIZE
#endif