mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Updated NPC armor appearance mod script
Added command_lite.h header file (from EcCo mod). Added alternative npcarmor.ini for vanilla Fallout 2.
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
;NPC armor appearance configuration for vanilla Fallout 2. Does not require any new graphics
|
||||||
|
;Party members will use player's armor appearance just like old B-Team mod
|
||||||
|
|
||||||
|
;WeaponAnims codes
|
||||||
|
; 1 - Knife (D)
|
||||||
|
; 2 - Club (E)
|
||||||
|
; 3 - Sledgehammer (F)
|
||||||
|
; 4 - Spear (G)
|
||||||
|
; 5 - Pistol (H)
|
||||||
|
; 6 - SMG (I)
|
||||||
|
; 7 - Rifle (J)
|
||||||
|
; 8 - Big Gun (K)
|
||||||
|
; 9 - Minigun (L)
|
||||||
|
; 10 - Rocket Launcher (M)
|
||||||
|
; 11-15 - sfall additional weapon animation codes
|
||||||
|
|
||||||
|
; This section maps 7 armor types to corresponding armor item PIDs
|
||||||
|
[ArmorTypes]
|
||||||
|
Jacket = 74,265
|
||||||
|
Leather = 1,379
|
||||||
|
Metal = 2,240,380
|
||||||
|
Power = 3,232
|
||||||
|
AdvPower = 348,349
|
||||||
|
Combat = 17,239,381
|
||||||
|
Robe = 113,524
|
||||||
|
|
||||||
|
; Default armor FIDs (the same for all NPCs)
|
||||||
|
[Default]
|
||||||
|
Jacket = 16777229
|
||||||
|
Leather = 16777228
|
||||||
|
Metal = 16777230
|
||||||
|
Combat = 16777226
|
||||||
|
Power = 16777217
|
||||||
|
AdvPower = 16777287
|
||||||
|
Robe = 16777218
|
||||||
|
|
||||||
|
; Sulik
|
||||||
|
[1]
|
||||||
|
PID=16777313
|
||||||
|
WeaponAnims=1,3,4,6
|
||||||
|
Default=16777280
|
||||||
|
|
||||||
|
; Vic
|
||||||
|
[2]
|
||||||
|
PID=16777278
|
||||||
|
WeaponAnims=1,5,7
|
||||||
|
Default=16777307
|
||||||
|
|
||||||
|
; Cassidy
|
||||||
|
[3]
|
||||||
|
PID=16777305
|
||||||
|
WeaponAnims=4,5,7
|
||||||
|
Default=16777260
|
||||||
|
Leather=16777260
|
||||||
|
|
||||||
|
; Myron
|
||||||
|
[4]
|
||||||
|
PID=16777376
|
||||||
|
WeaponAnims=1,5
|
||||||
|
Default=16777304
|
||||||
|
|
||||||
|
; Lenny
|
||||||
|
[5]
|
||||||
|
PID=16777323
|
||||||
|
WeaponAnims=1,5,6
|
||||||
|
Default=16777295
|
||||||
|
|
||||||
|
; Davin
|
||||||
|
[6]
|
||||||
|
PID=16777379
|
||||||
|
WeaponAnims=1,2,5
|
||||||
|
Default=16777264
|
||||||
|
|
||||||
|
; Miria
|
||||||
|
[7]
|
||||||
|
PID=16777380
|
||||||
|
WeaponAnims=1,6
|
||||||
|
Default=16777252
|
||||||
|
Jacket=16777222
|
||||||
|
Leather=16777221
|
||||||
|
Metal=16777223
|
||||||
|
Combat=16777219
|
||||||
@@ -23,21 +23,20 @@ Robe = 113,524
|
|||||||
|
|
||||||
; Default armor FIDs (the same for all NPCs)
|
; Default armor FIDs (the same for all NPCs)
|
||||||
[Default]
|
[Default]
|
||||||
Power=16777217
|
Power = 16777217
|
||||||
AdvPower=16777287
|
AdvPower = 16777287
|
||||||
Robe=16777218
|
Robe = 16777218
|
||||||
|
|
||||||
|
|
||||||
; Sulik
|
; Sulik
|
||||||
[1]
|
[1]
|
||||||
PID=16777313
|
PID=16777313
|
||||||
WeaponAnims=1,3,4,6,14
|
WeaponAnims=1,3,4,6,14
|
||||||
Default=16777280
|
Default=16777280
|
||||||
Leather=16777325
|
|
||||||
Power=16777324
|
|
||||||
Metal=16777323
|
|
||||||
Jacket=16777321
|
Jacket=16777321
|
||||||
|
Leather=16777325
|
||||||
|
Metal=16777323
|
||||||
Combat=16777322
|
Combat=16777322
|
||||||
|
Power=16777324
|
||||||
|
|
||||||
; Vic
|
; Vic
|
||||||
[2]
|
[2]
|
||||||
@@ -45,47 +44,46 @@ PID=16777278
|
|||||||
WeaponAnims=1,5,7,13,14
|
WeaponAnims=1,5,7,13,14
|
||||||
Default=16777307
|
Default=16777307
|
||||||
Jacket=16777329
|
Jacket=16777329
|
||||||
Combat=16777330
|
|
||||||
Metal=16777331
|
|
||||||
Power=16777332
|
|
||||||
Leather=16777333
|
Leather=16777333
|
||||||
|
Metal=16777331
|
||||||
|
Combat=16777330
|
||||||
|
Power=16777332
|
||||||
|
|
||||||
; Cassidy
|
; Cassidy
|
||||||
[3]
|
[3]
|
||||||
PID=16777305
|
PID=16777305
|
||||||
WeaponAnims=4,5,7,13
|
WeaponAnims=4,5,7,13
|
||||||
Default=16777354
|
Default=16777354
|
||||||
Leather=16777260
|
|
||||||
Power=16777328
|
|
||||||
Metal=16777327
|
|
||||||
Jacket=16777351
|
Jacket=16777351
|
||||||
|
Leather=16777260
|
||||||
|
Metal=16777327
|
||||||
Combat=16777326
|
Combat=16777326
|
||||||
|
Power=16777328
|
||||||
|
|
||||||
; Myron
|
; Myron
|
||||||
[4]
|
[4]
|
||||||
PID=16777376
|
PID=16777376
|
||||||
WeaponAnims=1,5,14
|
WeaponAnims=1,5,14
|
||||||
Default=16777304
|
Default=16777304
|
||||||
Leather=
|
|
||||||
Power=16777349
|
|
||||||
Combat=16777350
|
Combat=16777350
|
||||||
|
Power=16777349
|
||||||
|
|
||||||
; Cat Jules
|
; Cat Jules (RP)
|
||||||
[5]
|
[5]
|
||||||
PID=16777720
|
PID=16777720
|
||||||
WeaponAnims=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
WeaponAnims=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
||||||
Default=16777353
|
Default=16777353
|
||||||
|
Jacket=16777346
|
||||||
Leather=16777347
|
Leather=16777347
|
||||||
Metal=16777348
|
Metal=16777348
|
||||||
Jacket=16777346
|
|
||||||
Combat=16777226
|
Combat=16777226
|
||||||
|
|
||||||
; Kitsune
|
; Kitsune (RP)
|
||||||
[6]
|
[6]
|
||||||
PID=16777718
|
PID=16777718
|
||||||
WeaponAnims=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
WeaponAnims=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
||||||
Default=16777222
|
Default=16777222
|
||||||
|
Jacket=16777222
|
||||||
Leather=16777221
|
Leather=16777221
|
||||||
Metal=16777223
|
Metal=16777223
|
||||||
Jacket=16777222
|
|
||||||
Combat=16777219
|
Combat=16777219
|
||||||
|
|||||||
Binary file not shown.
@@ -15,9 +15,13 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#define IS_ARMOR(item) (obj_type(item) == OBJ_TYPE_ITEM and obj_item_subtype(item) == item_type_armor)
|
#define IS_ARMOR(item) (obj_type(item) == OBJ_TYPE_ITEM and obj_item_subtype(item) == item_type_armor)
|
||||||
#define IS_WEAPON(item) (obj_type(item) == OBJ_TYPE_ITEM and obj_item_subtype(item) == item_type_weapon)
|
#define IS_WEAPON(item) (obj_type(item) == OBJ_TYPE_ITEM and obj_item_subtype(item) == item_type_weapon)
|
||||||
|
|
||||||
|
#define FID_OBJ_CRITTER (0x01000000)
|
||||||
|
|
||||||
|
procedure update_armor_apperance;
|
||||||
|
|
||||||
variable
|
variable
|
||||||
modIni := "npcarmor.ini",
|
modIni := "npcarmor.ini",
|
||||||
defaultFids,
|
defaultFids,
|
||||||
@@ -26,44 +30,55 @@ variable
|
|||||||
altWeapon,
|
altWeapon,
|
||||||
unWieldWeapon;
|
unWieldWeapon;
|
||||||
|
|
||||||
procedure check_armor_change(variable critter, variable item, variable isWorn) begin
|
/*
|
||||||
|
Returns the FID value set in the config settings for party member armor: Jacket, Leather, etc.
|
||||||
|
*/
|
||||||
|
procedure check_armor_change(variable critter, variable armor, variable isWield) begin
|
||||||
variable npc, armorType, fid;
|
variable npc, armorType, fid;
|
||||||
if (npcMap[obj_pid(critter)]) then begin
|
npc := npcMap[obj_pid(critter)];
|
||||||
npc := npcMap[obj_pid(critter)];
|
if (npc) then begin
|
||||||
if (not isWorn) then begin
|
if (isWield == false) then begin
|
||||||
// display_msg("No armor fid: " + npc["Default"]);
|
// display_msg("No armor fid: " + npc["Default"]);
|
||||||
return npc["Default"];
|
return npc["Default"];
|
||||||
end else if (item) then begin
|
end else if (armor) then begin
|
||||||
armorType := armorPidMap[obj_pid(item)];
|
armorType := armorPidMap[obj_pid(armor)];
|
||||||
fid := npc[armorType] or defaultFids[armorType];
|
fid := npc[armorType] or defaultFids[armorType];
|
||||||
if (fid == 0 or fid == -1) then fid := npc["Default"];
|
if (fid == 0 or fid == -1) then fid := npc["Default"];
|
||||||
// display_msg("Change fid: " + fid + ", npc: " + npc[armorType] + ", default:" + defaultFids[armorType]);
|
// display_msg("Change fid: " + fid + ", npc: " + npc[armorType] + ", default:" + defaultFids[armorType]);
|
||||||
return fid;
|
return fid;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return -1;
|
return -1; // engine default
|
||||||
end
|
end
|
||||||
|
|
||||||
procedure check_weapon_change(variable critter, variable item, variable isWield) begin
|
/*
|
||||||
|
Checks if a party member can use the offered weapon
|
||||||
|
*/
|
||||||
|
procedure check_weapon_change(variable critter, variable weapon, variable isWield) begin
|
||||||
variable npc, newWeaponAnim, weaponAnimList, i;
|
variable npc, newWeaponAnim, weaponAnimList, i;
|
||||||
if (npcMap[obj_pid(critter)]) then begin
|
npc := npcMap[obj_pid(critter)];
|
||||||
npc := npcMap[obj_pid(critter)];
|
if (npc) then begin
|
||||||
if isWield then begin
|
if (isWield) then begin
|
||||||
newWeaponAnim := get_proto_data(obj_pid(item), PROTO_WP_ANIM);
|
newWeaponAnim := get_proto_data(obj_pid(weapon), PROTO_WP_ANIM);
|
||||||
weaponAnimList := string_split(npc["WeaponAnims"], ",");
|
|
||||||
if newWeaponAnim then begin // anim code 0 - none/unarmed
|
if newWeaponAnim then begin // anim code 0 - none/unarmed
|
||||||
foreach (i in weaponAnimList) begin
|
weaponAnimList := npc["WeaponAnims"];
|
||||||
if (newWeaponAnim == atoi(i)) then return -1;
|
if (weaponAnimList != 0) then begin
|
||||||
|
foreach (i in string_split(weaponAnimList, ",")) begin
|
||||||
|
if (newWeaponAnim == atoi(i)) then return -1; // can use (engine default)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return 0;
|
return 0; // can't use
|
||||||
end
|
end
|
||||||
end else begin
|
end else begin
|
||||||
unWieldWeapon := obj_pid(item);
|
unWieldWeapon := obj_pid(weapon);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return -1;
|
return -1; // engine default
|
||||||
end
|
end
|
||||||
|
|
||||||
|
/*
|
||||||
|
Finds the first weapon which can be used by the party member in the inventory
|
||||||
|
*/
|
||||||
procedure search_alt_weapon(variable critter) begin
|
procedure search_alt_weapon(variable critter) begin
|
||||||
variable obj, res, i := 0;
|
variable obj, res, i := 0;
|
||||||
obj := inven_ptr(critter, 0);
|
obj := inven_ptr(critter, 0);
|
||||||
@@ -87,48 +102,47 @@ end
|
|||||||
|
|
||||||
// for NPCs when they change armor/weapon themselves
|
// for NPCs when they change armor/weapon themselves
|
||||||
procedure invenwield_handler begin
|
procedure invenwield_handler begin
|
||||||
variable critter, item, fid, slot, isWorn, canWield;
|
variable critter, item, fid, slot, isWield, canWield;
|
||||||
critter := get_sfall_arg;
|
critter := get_sfall_arg;
|
||||||
item := get_sfall_arg;
|
item := get_sfall_arg;
|
||||||
slot := get_sfall_arg;
|
slot := get_sfall_arg;
|
||||||
isWorn := get_sfall_arg;
|
isWield := get_sfall_arg;
|
||||||
|
|
||||||
if (critter and item and slot == INVEN_TYPE_WORN) then begin
|
if (/*critter and*/ item and slot == INVEN_TYPE_WORN) then begin
|
||||||
fid := check_armor_change(critter, item, isWorn);
|
fid := check_armor_change(critter, item, isWield);
|
||||||
if (fid != -1) then begin
|
if (fid != -1) then begin
|
||||||
if art_exists(fid) then begin
|
if art_exists(fid) then begin
|
||||||
art_change_fid_num(critter, fid);
|
art_change_fid_num(critter, fid);
|
||||||
end else begin
|
end else begin
|
||||||
debug_msg("Error: NPC Armor mod: missing FID.");
|
debug_msg("[Error] NPC armor mod: Invenwield missing FID: " + fid);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return;
|
end else if (/*critter and*/ item and slot == INVEN_TYPE_RIGHT_HAND) then begin
|
||||||
end
|
|
||||||
|
|
||||||
if (critter and item and slot == INVEN_TYPE_RIGHT_HAND) then begin
|
|
||||||
if (altWeapon == item) then return;
|
if (altWeapon == item) then return;
|
||||||
canWield := check_weapon_change(critter, item, isWorn);
|
canWield := check_weapon_change(critter, item, isWield);
|
||||||
set_sfall_return(canWield);
|
set_sfall_return(canWield);
|
||||||
if (canWield != -1) then begin
|
if (canWield != -1) then begin
|
||||||
call search_alt_weapon(critter);
|
call search_alt_weapon(critter); // wield weapon by script
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
// when changing armor from inventory while controlling other NPCs
|
// when changing armor from inventory while controlling other NPCs
|
||||||
procedure adjustfid_handler begin
|
procedure adjustfid_handler begin
|
||||||
variable fid, armor;
|
variable fid, armor, weapAnim, currFid, newFid;
|
||||||
if (dude_obj != real_dude_obj) then begin
|
if (dude_obj != real_dude_obj) then begin
|
||||||
|
currFid := get_sfall_arg;
|
||||||
|
if ((currFid bwand 0x0F000000) != FID_OBJ_CRITTER) then return;
|
||||||
armor := critter_inven_obj(dude_obj, INVEN_TYPE_WORN);
|
armor := critter_inven_obj(dude_obj, INVEN_TYPE_WORN);
|
||||||
fid := check_armor_change(dude_obj, armor, armor != 0);
|
fid := check_armor_change(dude_obj, armor, armor != 0);
|
||||||
if (fid != -1) then begin
|
if (fid != -1) then begin
|
||||||
variable weapAnim := get_sfall_arg bwand 0xF000;
|
weapAnim := currFid bwand 0xF000;
|
||||||
variable newFid := fid bwand 0xFFFF0FFF bwor weapAnim;
|
newFid := fid bwand 0xFFFF0FFF bwor weapAnim;
|
||||||
if art_exists(newFid) then begin
|
if art_exists(newFid) then begin
|
||||||
set_sfall_arg(0, newFid);
|
set_sfall_arg(0, newFid);
|
||||||
set_sfall_return(newFid);
|
set_sfall_return(newFid);
|
||||||
end else begin
|
end else begin
|
||||||
debug_msg("Error: NPC Armor mod: missing FID.");
|
debug_msg("[Error] NPC armor mod: Adjust FID missing: " + newFid);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -140,29 +154,18 @@ procedure inventorymove_handler begin
|
|||||||
slot := get_sfall_arg;
|
slot := get_sfall_arg;
|
||||||
item := get_sfall_arg;
|
item := get_sfall_arg;
|
||||||
if (dude_obj != real_dude_obj) then begin
|
if (dude_obj != real_dude_obj) then begin
|
||||||
if (IS_WEAPON(item) and (slot == INVEN_TYPE_RIGHT_HAND or slot == INVEN_TYPE_LEFT_HAND)) then begin
|
if ((slot == INVEN_TYPE_RIGHT_HAND or slot == INVEN_TYPE_LEFT_HAND) and IS_WEAPON(item)) then begin
|
||||||
canWield := check_weapon_change(dude_obj, item, item != 0);
|
canWield := check_weapon_change(dude_obj, item, item != 0);
|
||||||
set_sfall_return(canWield);
|
set_sfall_return(canWield);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
procedure start begin
|
procedure start begin
|
||||||
variable sect, sects, armorTypes, armorType, npc, pid, pids, i;
|
variable sect, sects, armorTypes, armorType, npc, pid, pids, i;
|
||||||
if game_loaded and (sfall_ver_major >= 4) then begin
|
if game_loaded and (sfall_ver_major >= 4) then begin
|
||||||
register_hook_proc(HOOK_INVENWIELD, invenwield_handler);
|
|
||||||
register_hook_proc(HOOK_ADJUSTFID, adjustfid_handler);
|
|
||||||
register_hook_proc(HOOK_INVENTORYMOVE, inventorymove_handler);
|
|
||||||
|
|
||||||
defaultFids := get_ini_section(modIni, "Default");
|
|
||||||
fix_array(defaultFids);
|
|
||||||
foreach (armorType: i in defaultFids) begin
|
|
||||||
defaultFids[armorType] := atoi(i);
|
|
||||||
end
|
|
||||||
|
|
||||||
armorPidMap := create_array_map;
|
|
||||||
armorTypes := get_ini_section(modIni, "ArmorTypes");
|
armorTypes := get_ini_section(modIni, "ArmorTypes");
|
||||||
|
armorPidMap := create_array_map;
|
||||||
foreach (armorType: pids in armorTypes) begin
|
foreach (armorType: pids in armorTypes) begin
|
||||||
pids := string_split(pids, ",");
|
pids := string_split(pids, ",");
|
||||||
foreach (pid in pids) begin
|
foreach (pid in pids) begin
|
||||||
@@ -170,6 +173,12 @@ procedure start begin
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defaultFids := get_ini_section(modIni, "Default");
|
||||||
|
fix_array(defaultFids);
|
||||||
|
foreach (armorType: i in defaultFids) begin
|
||||||
|
defaultFids[armorType] := atoi(i);
|
||||||
|
end
|
||||||
|
|
||||||
npcMap := create_array_map;
|
npcMap := create_array_map;
|
||||||
|
|
||||||
i := 1;
|
i := 1;
|
||||||
@@ -188,7 +197,26 @@ procedure start begin
|
|||||||
i += 1;
|
i += 1;
|
||||||
sect := get_ini_section(modIni, ""+i);
|
sect := get_ini_section(modIni, ""+i);
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
call update_armor_apperance;
|
||||||
|
|
||||||
|
register_hook_proc(HOOK_INVENWIELD, invenwield_handler);
|
||||||
|
register_hook_proc(HOOK_ADJUSTFID, adjustfid_handler);
|
||||||
|
register_hook_proc(HOOK_INVENTORYMOVE, inventorymove_handler);
|
||||||
|
|
||||||
|
debug_msg("NPC armor appearance mod: Done.");
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
procedure update_armor_apperance begin
|
||||||
|
variable npc, arItem, fid;
|
||||||
|
foreach (npc in party_member_list_critters) begin
|
||||||
|
if (npc == dude_obj) then continue;
|
||||||
|
arItem := critter_inven_obj(npc, INVEN_TYPE_WORN);
|
||||||
|
if (arItem) then begin
|
||||||
|
fid := check_armor_change(npc, arItem, true);
|
||||||
|
if (fid == -1 or art_exists(fid) == false) then continue;
|
||||||
|
art_change_fid_num(npc, fid);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -997,7 +997,8 @@ void Graphics::init() {
|
|||||||
#define _DLL_NAME "d3dx9_43.dll"
|
#define _DLL_NAME "d3dx9_43.dll"
|
||||||
HMODULE h = LoadLibraryEx(_DLL_NAME, 0, LOAD_LIBRARY_AS_DATAFILE);
|
HMODULE h = LoadLibraryEx(_DLL_NAME, 0, LOAD_LIBRARY_AS_DATAFILE);
|
||||||
if (!h) {
|
if (!h) {
|
||||||
MessageBoxA(0, "You have selected graphics mode 4 or 5, but " _DLL_NAME " is missing\nSwitch back to mode 0, or install an up to date version of DirectX", "Error", 0);
|
MessageBoxA(0, "You have selected graphics mode 4 or 5, but " _DLL_NAME " is missing.\n"
|
||||||
|
"Switch back to mode 0, or install an up to date version of DirectX.", "Error", 0);
|
||||||
ExitProcess(-1);
|
ExitProcess(-1);
|
||||||
} else {
|
} else {
|
||||||
FreeLibrary(h);
|
FreeLibrary(h);
|
||||||
|
|||||||
Reference in New Issue
Block a user