2017-05-23 22:28:42 +08:00
|
|
|
/*
|
2017-04-01 21:11:19 +07:00
|
|
|
|
|
|
|
|
NPC Combat Control
|
2017-05-23 22:28:42 +08:00
|
|
|
|
2017-04-01 21:11:19 +07:00
|
|
|
Allows to take control of your party member or other NPCs during combat
|
2017-05-23 22:28:42 +08:00
|
|
|
|
2017-04-01 21:11:19 +07:00
|
|
|
NOTE: this script requires compiler from sfall modderspack with -s option
|
|
|
|
|
(short circuit evaluation)
|
2017-05-23 22:28:42 +08:00
|
|
|
|
2017-04-01 21:11:19 +07:00
|
|
|
version 1.0
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2017-10-02 09:54:47 +08:00
|
|
|
#include "..\headers\define.h"
|
2018-07-10 12:05:15 +08:00
|
|
|
#include "..\headers\command.h"
|
2017-04-01 21:11:19 +07:00
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
variable
|
|
|
|
|
configSection := "CombatControl",
|
|
|
|
|
controlMode,
|
2017-10-02 09:54:47 +08:00
|
|
|
pidList,
|
2018-07-10 12:05:15 +08:00
|
|
|
displayName,
|
|
|
|
|
displayNameColor,
|
2018-07-13 11:25:42 +08:00
|
|
|
inControl := false,
|
2017-10-02 09:54:47 +08:00
|
|
|
hasGeckoSkinning := false;
|
2017-05-23 22:28:42 +08:00
|
|
|
|
2017-04-01 21:11:19 +07:00
|
|
|
|
|
|
|
|
procedure combatturn_handler begin
|
|
|
|
|
variable
|
|
|
|
|
status := get_sfall_arg,
|
2017-05-23 22:28:42 +08:00
|
|
|
critter := get_sfall_arg,
|
2017-04-01 21:11:19 +07:00
|
|
|
arg3 := get_sfall_arg,
|
|
|
|
|
pid;
|
2017-05-23 22:28:42 +08:00
|
|
|
|
2017-04-01 21:11:19 +07:00
|
|
|
// display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + ", arg3: " + arg3);
|
|
|
|
|
pid := obj_pid(critter);
|
2017-05-23 22:28:42 +08:00
|
|
|
if (status == 1
|
2017-04-01 21:11:19 +07:00
|
|
|
and (len_array(pidList) == 0 or scan_array(pidList, pid bwand 0xFFFFFF) != -1)
|
|
|
|
|
and (controlMode == 1 or party_member_obj(pid))) then begin
|
2018-07-11 10:03:03 +08:00
|
|
|
if not(critter == real_dude_obj) then begin
|
|
|
|
|
set_dude_obj(critter);
|
|
|
|
|
if hasGeckoSkinning then critter_add_trait(critter, TRAIT_PERK, PERK_gecko_skinning_perk, 1);
|
2018-07-13 11:25:42 +08:00
|
|
|
inControl := true;
|
2018-07-11 10:03:03 +08:00
|
|
|
end
|
2018-07-13 11:25:42 +08:00
|
|
|
if inControl then begin
|
|
|
|
|
// center the screen on the controlled critter and remove roof tiles
|
|
|
|
|
move_to(dude_obj, dude_tile, dude_elevation);
|
|
|
|
|
if displayName then begin
|
|
|
|
|
set_iface_tag_text(displayName, obj_name(critter), displayNameColor);
|
|
|
|
|
show_iface_tag(displayName);
|
|
|
|
|
end
|
2018-07-10 12:05:15 +08:00
|
|
|
end
|
2018-07-13 11:25:42 +08:00
|
|
|
end else if inControl then begin
|
2017-04-01 21:11:19 +07:00
|
|
|
set_dude_obj(real_dude_obj);
|
2018-07-13 11:25:42 +08:00
|
|
|
if displayName then hide_iface_tag(displayName);
|
2017-04-01 21:11:19 +07:00
|
|
|
end
|
2018-07-13 11:25:42 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
procedure gamemodechange_handler begin
|
|
|
|
|
if not(get_game_mode BWAND COMBAT) then inControl := false;
|
2017-04-01 21:11:19 +07:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
procedure start begin
|
2017-05-23 22:28:42 +08:00
|
|
|
if game_loaded and (sfall_ver_major >= 4) then begin
|
2018-01-02 09:58:30 +08:00
|
|
|
set_perk_ranks(PERK_gecko_skinning_perk, 1);
|
2018-03-28 21:29:22 +08:00
|
|
|
set_perk_level(PERK_gecko_skinning_perk, 999); // prevent it from appearing in the perk selection window
|
2017-04-01 21:11:19 +07:00
|
|
|
controlMode := GetConfig("CombatControl", "Mode", 0);
|
2018-07-10 12:05:15 +08:00
|
|
|
displayName := GetConfig("CombatControl", "DisplayName", 0);
|
|
|
|
|
displayNameColor := GetConfig("CombatControl", "DisplayNameColor", 0);
|
2017-04-01 21:11:19 +07:00
|
|
|
if (controlMode > 2) then controlMode := 0;
|
2018-07-10 12:05:15 +08:00
|
|
|
if (displayName < 5 or displayName > 9) then displayName := 0;
|
2017-04-01 21:11:19 +07:00
|
|
|
if (controlMode > 0) then begin
|
|
|
|
|
pidList := GetConfigListInt("CombatControl", "PIDList");
|
|
|
|
|
fix_array(pidList);
|
2017-10-02 09:54:47 +08:00
|
|
|
if has_trait(TRAIT_PERK, dude_obj, PERK_gecko_skinning_perk) then hasGeckoSkinning := true;
|
2017-05-23 22:28:42 +08:00
|
|
|
|
2017-04-01 21:11:19 +07:00
|
|
|
register_hook_proc(HOOK_COMBATTURN, combatturn_handler);
|
2018-07-13 11:25:42 +08:00
|
|
|
register_hook_proc(HOOK_GAMEMODECHANGE, gamemodechange_handler);
|
2017-04-01 21:11:19 +07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|