I went to look at the source code of gl_p_party_orders.ssl to see how the "holster NPCs" code was written to see if I could use that as a base for possibly writing "arm NPCs" code. I was then surprised to see that "npc_use_best_weapon" code was fully written but unimplemented!
I see it was added to gl_ptyop.ssl in the "load EcCo version 0.6.2" commit in 2018 but has been untouched since then.
I imagine it was unimplemented because it didn't work or created new bugs. Does anyone know the story with this code and why it was not implemented??
Code: Select all
procedure npc_use_best_weapon(variable oC) begin
variable begin
weapon = 0;
bestdam = 0;
list; item;
end
inven_unwield(oC); // unwields without animation
reg_anim_clear(oC);
// search for suitable weapon
list = inven_as_array(oC);
foreach item in list begin
if (item) then if (is_weapon(item)) then begin
if (weapon == 0 or get_proto_data(obj_pid(item), PRODATA_IT_WP_DMG_MIN) > bestdam) then begin
// try to wield
wield_obj_critter(oC, item);
display_msg(obj_name(oC) + " try to use " + obj_name(item) + " " + (critter_inven_obj(oC, 1) != weapon));
if (critter_inven_obj(oC, 1) != weapon) then begin
bestdam = get_proto_data(obj_pid(item), PRODATA_IT_WP_DMG_MIN);
weapon = item;
end
end
end
end
if (weapon) then begin
end
iNum_npcs += 1;
oWho = oC;