Author Topic: NPC Weapon Change Problem  (Read 370 times)

Legacy_Devling99

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
NPC Weapon Change Problem
« on: April 23, 2011, 08:21:25 pm »


               Hey, i have some guards which i need to wear some special weapons, they need to have more than one weapon in their inventory at once.

I need a script that can ensure that my npc wont change their weapon out with the most damaging weapon, but just keep the weapon i gave them in hand, until i give them another.

How can this be done?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NPC Weapon Change Problem
« Reply #1 on: April 23, 2011, 09:03:24 pm »


               

Devling99 wrote...

I need a script that can ensure that my npc wont change their weapon out with the most damaging weapon, but just keep the weapon i gave them in hand, until i give them another.

How can this be done?


Well in order to do it the way you are asking, you would have to modify the AI to where they do not select the most damaging weapon.  This rout just does not sound like the simplest option to me.  But I do not really know what is triggering the weapons change on your guards, so I may be wrong.  

The Simplest option is to allow your guards to have only one weapon.   This will not give them the option to change it via the Combat AI.   Instead of Changing an Int on the guard to select the weapon they equip, as you sugested in the other post, just write that script to change the weapon that they posses.  This can be done either by destroying the old weapon and creating a new one or modifing the one that they have.

The Route taken is really dependent on what is triggering the change and when it is happening.  If it is happening in the middle of combat  writing a custom AI for the guards with the Int set may be the option.   I myself right now do not have the time, at the moment, to digg back through the AI to figure it out again.
               
               

               
            

Legacy_Devling99

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
NPC Weapon Change Problem
« Reply #2 on: April 23, 2011, 10:18:16 pm »


               Well, the thing is that i am building a module where it is possible to gather some kinds of materials and then get a blacksmith to upgrade the milita's Equipment, so i wont need to change there weapon while they are in combat.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NPC Weapon Change Problem
« Reply #3 on: April 28, 2011, 03:11:26 am »


               Sorry for the delay,
I think if I was doing sonething like this.  I would give all my guards 1 weapon and have them share a common tag,   It would not matter  what types of weapon it was.   So you could have some guards with long swords, sone with short swords and other with axes or what ever you wanted them carrying as long as they all had the same tag.  

So lets say you 5 guards three of them with long swords and two with short swords.   You would place the weapons on the guards and change there tags to something like "Guards_weapon" .  For this example I will also assume all the guards have a common tag. (assumed  a Tag of "guard")

When Your PC returns with the Craft Item to upgarde the guards weapons you could do something like this from the action taken script.


 #include "x2_inc_itemprop"

void main()
{
  int i;
  object oItem;
  object oGuard = GetObjectByTag("guard",i);
 
while (GetIsObjectValid( oGuard))
 {
   oItem = GetItemPossessedBy(oGuard,"Guards_weapon");
   if(GetIsObjectValid(oItem))
      IPSafeAddItemProperty(oItem,ItemPropertyEnhancementBonus(1));
   oItem = GetObjectByTag("guard",i++);
 }


               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
NPC Weapon Change Problem
« Reply #4 on: April 29, 2011, 02:46:57 am »


               I think a better way to handle it, is just give them 1 weapon, and use scripting to switch weapons when you want to switch, e.g. take one and hand them another, rather than going through the hooplah of AI...  Just my 2 cents..