Author Topic: Script for NPC equipping melee weapon in close-range?  (Read 364 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« on: December 08, 2012, 10:59:22 pm »


                I have an NPC that has both a crossbow and a set of a sword and a shield. If I attack him close range he takes out his melee "set" and it's alright. If I attack him long range, he takes out a crossbow and it's alright.

But how can I make him change his equipment to melee (or vice versa) depending on the range?

Thanks for help. '<img'>
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #1 on: December 09, 2012, 01:16:02 am »


               Use this in the NPC's OnSpawn Event:    ActionEquipMostDamagingRanged(OBJECT_SELF);

By default, this'll also equip a melee weapon when no ranged weapon w/ matching ammo exists.
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #2 on: December 09, 2012, 10:04:52 am »


               But it doesn't look like it will make the NPC change his weapon when the enemy comes into melee range, right?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #3 on: December 09, 2012, 10:54:00 am »


               This is fixed is my patch...
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #4 on: December 09, 2012, 11:03:20 am »


               

ShaDoOoW wrote...

This is fixed is my patch...


I'm using your patch. ^^
Though I know I should use the builder resources probably. ':?'
               
               

               


                     Modifié par Grani, 09 décembre 2012 - 11:06 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #5 on: December 09, 2012, 11:18:06 am »


               well which version? I dont recall when I fixed this, maybe around beta 6 or latest beta. Its definitely not in initial 1.70 release. And it might not work correctly, if you using old includes (this issue is fixed in x0_i0_equip) or old AI scripts (nw_c2_def*) which you haven't recompiled.

In clean module with 1.71b8 installed, the creature you specified will behave just as you wish. Except in easy difficulty or if she has point blank shot, she will not unequip ranged in close combat.
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #6 on: December 09, 2012, 12:37:38 pm »


               Well, I'm using original 1.70, so that's probably it.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #7 on: December 09, 2012, 01:57:46 pm »


               To clarify. This is an issue in default bioware AI. It probably was intented to work that way, unfortunately the script for this has an error - it works only for henchmans. It would be possible to fix it otherwise, such as extra code in heartbeat (if distance is long, try to equip ranged weapons) but in fact that would be simply workaround for real issue. I suppose that custom AIs such as Tony K's surely have this feature too.
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Script for NPC equipping melee weapon in close-range?
« Reply #8 on: December 09, 2012, 03:16:02 pm »


               Alright, thanks for help '<img'>