Smaller Fallout projects. Latest Party Orders mod, Fallout: Nevada wiki. Modding questions also go here.
Post Reply
MarbledModulator
Posts: 3
Joined: Sat Oct 22, 2022 4:30 am

Fallout2 Party Orders: "npc_use_best_weapon"

Post by MarbledModulator » Sat Oct 22, 2022 5:10 am

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;
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;

User avatar
Magus
Site Admin
Posts: 397
Joined: Mon Nov 21, 2016 9:13 am
Contact:

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Post by Magus » Fri Nov 04, 2022 7:37 pm

Sorry, missed your message.
Why do you need this, though? NPCs will pull their weapons automatically when combat starts, anyway.
Please do not PM or email me about my mods and projects. Use forums. Also, see our talk channels.

MarbledModulator
Posts: 3
Joined: Sat Oct 22, 2022 4:30 am

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Post by MarbledModulator » Fri Nov 04, 2022 8:49 pm

Magnus,

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)

User avatar
Magus
Site Admin
Posts: 397
Joined: Mon Nov 21, 2016 9:13 am
Contact:

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Post by Magus » Fri Nov 04, 2022 11:10 pm

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.
Please do not PM or email me about my mods and projects. Use forums. Also, see our talk channels.

MarbledModulator
Posts: 3
Joined: Sat Oct 22, 2022 4:30 am

Re: Fallout2 Party Orders: "npc_use_best_weapon"

Post by MarbledModulator » Fri Nov 04, 2022 11:30 pm

Agreed, will do. Thanks.

Post Reply