mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
* Fixed the game thinking you dropped an active explosive when the dropping is prevented with hs_inventorymove. * Added "inventory_redraw" script function (from Mr.Stalin) * NPC combat control mod now centers the screen on the controlled critter and has new options to display critter's name. * Removed obsoleted WIN2K preprocessor defines. Updated version number.
82 lines
2.6 KiB
Plaintext
82 lines
2.6 KiB
Plaintext
/*
|
|
|
|
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 "..\headers\define.h"
|
|
#include "..\headers\command.h"
|
|
#include "main.h"
|
|
|
|
variable
|
|
configSection := "CombatControl",
|
|
controlMode,
|
|
pidList,
|
|
displayName,
|
|
displayNameColor,
|
|
inControl := false,
|
|
hasGeckoSkinning := false;
|
|
|
|
|
|
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
|
|
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);
|
|
inControl := true;
|
|
end
|
|
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
|
|
end
|
|
end else if inControl then begin
|
|
set_dude_obj(real_dude_obj);
|
|
if displayName then hide_iface_tag(displayName);
|
|
end
|
|
end
|
|
|
|
procedure gamemodechange_handler begin
|
|
if not(get_game_mode BWAND COMBAT) then inControl := false;
|
|
end
|
|
|
|
procedure start begin
|
|
if game_loaded and (sfall_ver_major >= 4) then begin
|
|
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
|
|
controlMode := GetConfig("CombatControl", "Mode", 0);
|
|
displayName := GetConfig("CombatControl", "DisplayName", 0);
|
|
displayNameColor := GetConfig("CombatControl", "DisplayNameColor", 0);
|
|
if (controlMode > 2) then controlMode := 0;
|
|
if (displayName < 5 or displayName > 9) then displayName := 0;
|
|
if (controlMode > 0) then begin
|
|
pidList := GetConfigListInt("CombatControl", "PIDList");
|
|
fix_array(pidList);
|
|
if has_trait(TRAIT_PERK, dude_obj, PERK_gecko_skinning_perk) then hasGeckoSkinning := true;
|
|
|
|
register_hook_proc(HOOK_COMBATTURN, combatturn_handler);
|
|
register_hook_proc(HOOK_GAMEMODECHANGE, gamemodechange_handler);
|
|
end
|
|
end
|
|
end
|