Aller au contenu

Photo

How to change default attack?


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Zephyrys

Zephyrys
  • Members
  • 19 messages

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.



#2
Proleric

Proleric
  • Members
  • 2 356 messages
Might be easier to give her a rod with unlimited charges.
  • Shadooow aime ceci

#3
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

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



#4
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

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.



#5
Zephyrys

Zephyrys
  • Members
  • 19 messages

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.