Author Topic: How to change default attack?  (Read 354 times)

Legacy_Zephyrys

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
How to change default attack?
« on: May 09, 2014, 04:29:06 am »


               

Hello,


 


Basically I want to create an NPC that casts an endless stream of Rays of Frost as her 'all out of spells' behavior instead of a melee attack.  I'm pretty sure I know what line to use:


 


ActionCastSpellAtObject(int nSpell=Ray_of_Frost, object oTarget, int nMetaMagic=METAMAGIC_ANY, int bCheat=TRUE, int nDomainLevel=0, int nProjectilePathType=PROJECTILE_PATH_TYPE_DEFAULT, int bInstantSpell=TRUE)


 


I just don't know where I should put it in the AI's combat script to give me the desired behavior.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
How to change default attack?
« Reply #1 on: May 09, 2014, 04:41:49 pm »


               Might be easier to give her a rod with unlimited charges.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
How to change default attack?
« Reply #2 on: May 10, 2014, 01:59:44 am »


               

We do a lot of stuff like this from endcombatround. It's our default go-to, but it does come with a downside: it allows them to do other actions that round as well. Proleric's solution isn't bad, though the ai may not use it as you would like.


 


Also, you could just give her the spell, and restore uses of it from endcombatround, though that requires a little more code, and possibly a nwnx plugin - I just can't remember at the moment, and I can't open the toolset to check.


 


Funky



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
How to change default attack?
« Reply #3 on: May 10, 2014, 05:42:01 am »


               

Looking at default functions, I only see


 


IncrementRemainingFeatUses


DecrementRemainingFeatUses


 


DecrementRemainingSpellUses


 


So I'm pretty sure you need a plug-in or something -- though if you made it a feat and could get her to use it via scripting that could solve your problem.  Could possibly do it with PlayerTool1 or something -- basically adjust the spellcasting AI to make it choose that feat over a spell if no other spell remains.  PlayerTool1 has no cast time or anything so that might lead to odd results, though.


 


If you wind up making a custom feat, then making a "generic" spell would be useful -- make it medium range, requiring a specific target, and no projectile visual.  Then you could use that for a bunch of different monsters using your own spell visual and effect based on the casting creature.



               
               

               
            

Legacy_Zephyrys

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
How to change default attack?
« Reply #4 on: May 10, 2014, 10:09:54 am »


               

The code I used above has the Cheat flag activated, which essentially means the character will cast the spell regardless as to whether he or she has the spell capable of being cast or not.  I just wish there was some way of plunking it into the part of the AI that determines what action you do if you can't do anything else.