Edits to gl_partycontrol and main.h

* it seems no need to "fix" Gecko Skinning perk anymore.
* use array to hold perk levels instead of calling has_trait twice.
This commit is contained in:
NovaRain
2024-03-27 11:18:53 +08:00
parent 9bd9837a7d
commit a66ff8d252
7 changed files with 22 additions and 19 deletions
Binary file not shown.
Binary file not shown.
+13 -9
View File
@@ -37,7 +37,7 @@ procedure SetGlobalVar_Handler;
variable variable
controlMode, controlMode,
pidList, perksList, pidList, perksList, addedPerkLevels,
lightInt, lightDist, npcControl, lightInt, lightDist, npcControl,
displayName, displayNameColor, isShowTag, displayName, displayNameColor, isShowTag,
inControl := false, inControl := false,
@@ -61,7 +61,7 @@ procedure CombatTurn_Handler begin
variable variable
status := get_sfall_arg, status := get_sfall_arg,
critter := get_sfall_arg, critter := get_sfall_arg,
pid, perkID, level; pid, i, perkID, level;
DEBUGMSG("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)
@@ -99,9 +99,14 @@ procedure CombatTurn_Handler begin
lightInt := get_object_data(critter, OBJ_DATA_LIGHT_INTENSITY); lightInt := get_object_data(critter, OBJ_DATA_LIGHT_INTENSITY);
// set perks (only work with 4.1.8+) // set perks (only work with 4.1.8+)
foreach (perkID in perksList) begin foreach (i: perkID in perksList) begin
addedPerkLevels[i] := 0;
level := has_trait(TRAIT_PERK, real_dude_obj, perkID); level := has_trait(TRAIT_PERK, real_dude_obj, perkID);
if (level) then critter_add_trait(critter, TRAIT_PERK, perkID, level); if (level) then begin
addedPerkLevels[i] := level;
critter_add_trait(critter, TRAIT_PERK, perkID, level);
end
end end
// special handling if dude has Jinxed trait/perk // special handling if dude has Jinxed trait/perk
if (has_trait(TRAIT_TRAIT, real_dude_obj, TRAIT_jinxed) or has_trait(TRAIT_PERK, real_dude_obj, PERK_jinxed_perk)) then begin if (has_trait(TRAIT_TRAIT, real_dude_obj, TRAIT_jinxed) or has_trait(TRAIT_PERK, real_dude_obj, PERK_jinxed_perk)) then begin
@@ -142,8 +147,8 @@ 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.") DEBUGMSG("Remove perks after NPC control.")
foreach (perkID in perksList) begin foreach (i: perkID in perksList) begin
level := has_trait(TRAIT_PERK, real_dude_obj, perkID); level := addedPerkLevels[i]; //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
// special handling for Jinxed // special handling for Jinxed
@@ -227,9 +232,6 @@ 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);
@@ -239,6 +241,8 @@ procedure start begin
perksList := GetConfigListInt("CombatControl", "PerksList"); perksList := GetConfigListInt("CombatControl", "PerksList");
fix_array(perksList); fix_array(perksList);
addedPerkLevels := create_array_list(len_array(perksList));
register_hook_proc(HOOK_COMBATTURN, CombatTurn_Handler); register_hook_proc(HOOK_COMBATTURN, CombatTurn_Handler);
register_hook_proc(HOOK_GAMEMODECHANGE, GameModeChange_Handler); register_hook_proc(HOOK_GAMEMODECHANGE, GameModeChange_Handler);
register_hook_proc(HOOK_INVENTORYMOVE, InventoryMove_Handler); register_hook_proc(HOOK_INVENTORYMOVE, InventoryMove_Handler);
+9 -10
View File
@@ -18,45 +18,46 @@ variable translationIni;
// Gets the integer value from the specified ini // Gets the integer value from the specified ini
procedure GetIniConfig(variable section, variable key, variable def, variable inifile) begin procedure GetIniConfig(variable section, variable key, variable def, variable inifile) begin
variable val := get_ini_setting(inifile + "|" + section + "|" + key); variable val := get_ini_setting(inifile + "|" + section + "|" + key);
if val == -1 then val := def; if (val == -1) then return def;
return val; return val;
end end
// Gets the string value from the specified ini // Gets the string value from the specified ini
procedure GetIniConfigStr(variable section, variable key, variable def, variable inifile) begin procedure GetIniConfigStr(variable section, variable key, variable def, variable inifile) begin
variable val := get_ini_string(inifile + "|" + section + "|" + key); variable val := get_ini_string(inifile + "|" + section + "|" + key);
if val == -1 orElse val == "" then val := def; if (val == -1 orElse val == "") then return def;
return val; return val;
end end
// Gets the integer value from sfall-mods.ini // Gets the integer value from sfall-mods.ini
procedure GetConfig(variable section, variable key, variable def) begin procedure GetConfig(variable section, variable key, variable def) begin
variable val := get_ini_setting(ini + "|" + section + "|" + key); variable val := get_ini_setting(ini + "|" + section + "|" + key);
if val == -1 then val := def; if (val == -1) then return def;
return val; return val;
end end
// Gets the string value from sfall-mods.ini // Gets the string value from sfall-mods.ini
procedure GetConfigStr(variable section, variable key, variable def) begin procedure GetConfigStr(variable section, variable key, variable def) begin
variable val := get_ini_string(ini + "|" + section + "|" + key); variable val := get_ini_string(ini + "|" + section + "|" + key);
if val == -1 orElse val == "" then val := def; if (val == -1 orElse val == "") then return def;
return val; return val;
end end
// Gets the value from sfall-mods.ini as a temp array of strings // Gets the value from sfall-mods.ini as a temp array of strings
procedure GetConfigList(variable section, variable key) begin procedure GetConfigList(variable section, variable key) begin
variable val := get_ini_string(ini + "|" + section + "|" + key); variable val := get_ini_string(ini + "|" + section + "|" + key);
if val == -1 orElse val == "" then return []; if (val == -1 orElse val == "") then return [];
return string_split(val, ","); return string_split(val, ",");
end end
// Gets the value from sfall-mods.ini as a temp array of ints // Gets the value from sfall-mods.ini as a temp array of ints
procedure GetConfigListInt(variable section, variable key) begin procedure GetConfigListInt(variable section, variable key) begin
variable arr, i, item; variable arr, len, i, item;
arr := GetConfigList(section, key); arr := GetConfigList(section, key);
for (i := 0; i < len_array(arr); i++) begin len = len_array(arr);
for (i := 0; i < len; i++) begin
arr[i] := atoi(arr[i]); arr[i] := atoi(arr[i]);
end end
return arr; return arr;
@@ -65,9 +66,7 @@ end
// Translates given string using Translations.ini // Translates given string using Translations.ini
procedure Translate(variable id, variable def) begin procedure Translate(variable id, variable def) begin
variable str := get_ini_string(translationIni + "|Sfall|" + id); variable str := get_ini_string(translationIni + "|Sfall|" + id);
if (str == 0 orElse (strlen(str) == 0)) then begin if (str == 0 orElse strlen(str) == 0) then return def;
str := def;
end
return str; return str;
end end
Binary file not shown.
Binary file not shown.
Binary file not shown.