Page 1 of 1

Fallout2 Party Orders: "npc_use_best_weapon"

Posted: Sat Oct 22, 2022 5:10 am
by MarbledModulator
I really enjoyed Fallout2 Party Orders mod on my last playthrough but wished there was an "arm NPCs" function just like there was a "holster NPCs" function.

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;
  inven_unwield(oC);    // unwields without animation
  // 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;
  if (weapon) then begin

  iNum_npcs += 1;
  oWho = oC;

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Posted: Fri Nov 04, 2022 7:37 pm
by Magus
Sorry, missed your message.
Why do you need this, though? NPCs will pull their weapons automatically when combat starts, anyway.

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Posted: Fri Nov 04, 2022 8:49 pm
by MarbledModulator

I actually wrote this from a playthrough I did a year ago so I could be mistaken (and I don't currently have Fallout 2 installed to test my assumptions) but I think it was because
  1. I think some NPCs won't autoequip a weapon if their unarmed was high enough (like Sulik)
  2. If the NPC had several weapons in their inventory I would want to check before combat if they equip the weapon I wanted them to use
  3. I assumed equipping a weapon/ loading an empty weapon used up some of the NPCs action points (but now realize I never checked to see if this is actually true)

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Posted: Fri Nov 04, 2022 11:10 pm
by Magus
1. Maybe.
2. I'm not sure if the script follows engine logic in choosing the weapon. Could cause them to re-equip another weapon, too.
3. Loading probably does. Not sure about equipping.

So, some testing and research will be needed for this pretty minor thing. I'll probably won't spend time on this, but if you figure all this out, feel free to send a pull.

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Posted: Fri Nov 04, 2022 11:30 pm
by MarbledModulator
Agreed, will do. Thanks.