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
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);