Skip to content

Enemies equipping items in their inventory?

Is there a script or method to make enemies equip items in their inventory? (instead of attacking unarmed) but without having to put a weapon in the enemies hands during creature creation (my item spawn script puts some random weapons into an enemies inventory) and i just want the enemy to draw and use that item...

Comments

  • DerpCityDerpCity Member, Moderator Posts: 303
    edited July 2019
    Does your creature have the proper weapon proficiency feat to use the weapons you're giving them? I just made an orc with the creature wizard and gave him martial proficiency and put a longsword in his inventory, and he immediately pulled it out when he ran over to attack me.

    EDIT: Upon rereading, I just noticed you mentioned you were giving your creatures weapons through a spawn script, so I added a line in my orc's spawn script to give him a longsword and removed the original from his inventory. I was expecting him to not pull it out, but he actually did. However, I also didn't really answer your original question at all. For what you want, it should be as simple as adding a line at the end of their spawn script consisting of "ActionEquipMostDamagingMelee();" or "ActionEquipMostDamagingRanged();", depending on what you want them to do. If you only want them to do it once they spot a target, I would add this to your OnPerception script, replacing with the appropriate action if needed.
    object oTarget = GetLastPerceived();
    
        if (GetIsReactionTypeHostile(oTarget))
        {
            ActionEquipMostDamagingMelee();
        }
    

    Admittedly, I couldn't really test it well considering my creature automatically pulls out his weapon on his own, but when I had it check for a nonhostile and made him a commoner it worked, so it should work if they're hostile. That's the hope, anyway.
    Post edited by DerpCity on
  • GrymlordeGrymlorde Member Posts: 121
    The weapon also needs to be identified first. I know that sounds obvious but most magical weapons are not identified.
Sign In or Register to comment.