Author Topic: Can NPCs activate items?  (Read 418 times)

Legacy_LoA_Tristan

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0
Can NPCs activate items?
« on: January 31, 2013, 03:27:52 am »


               I've checked around but haven't really found a clear answer to this.

I note from experience in the OC that NPCs use potions as part of the AI scripted talent behavior; for instance

tUse = GetCreatureTalentRandom(TALENT_CATEGORY_BENEFICIAL_HEALING_POTION);
if(GetIsTalentValid(tUse))
{
    //MyPrintString("TalentHealingSelf Successful Exit");
    bkTalentFilter(tUse, OBJECT_SELF);
    return TRUE;
}
but this is about the only evidence I see that NPCs can activate any kind of item at all, and this bit of scripting is, eh... cryptic.  Seems like something is hardcoded from here out, and the whole process of activating an item cannot be scripted.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Can NPCs activate items?
« Reply #1 on: January 31, 2013, 05:16:47 am »


               That's correct, there is no action to activate a specific item.

Funky
               
               

               
            

Legacy_LoA_Tristan

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0
Can NPCs activate items?
« Reply #2 on: January 31, 2013, 12:36:01 pm »


               Kind of sad, I think, that all those wizards you see consider their staves baseball bats '<img'>
               
               

               
            

Legacy_Highv Priest

  • Full Member
  • ***
  • Posts: 170
  • Karma: +0/-0
Can NPCs activate items?
« Reply #3 on: February 01, 2013, 04:42:59 am »


               lol I just faked it. All the animations for activating an item are the same and using the bcheat/binstant for ActionCastSpell makes it LOOK like they just used a scroll/potion/etc. If you really want the code I'll be glad to give it to you. It's just apart of my "awesome_include" library(which is just things I created that fix MANY aspects of nwn) and it's called "ActionUseItem(string sName, int nItemType, object oUser=OBJECT_SELF)". The code checks if they have it, if they do it will decrease the amount of it, or decrease it's charges, or destroy it. It Sets them to be non-commandable for the duration of the animation and has them instant cast the spell on there target in the middle of the animation.
               
               

               
            

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
Can NPCs activate items?
« Reply #4 on: February 01, 2013, 12:46:49 pm »


               there's an nwnx plugin that allows you make creatures use items via scripting:

http://social.biowar...14258835-1.html

you could use this to force an NPC to use the staff.  if you wanted him to "decide" when to use it on his own, i imagine it would take some mucking about with the AI scripts.

or you seem quite happy with your solution '<img'>
               
               

               
            

Legacy_DM_Vecna

  • Hero Member
  • *****
  • Posts: 501
  • Karma: +0/-0
Can NPCs activate items?
« Reply #5 on: February 08, 2013, 03:56:16 am »


               Highv priest, I would love a copy of your awesome_include. I love home brew functions like this, they really get me thinking differently.

Vecna@nwnsmith.com