Aller au contenu

Photo

Can the spellhook script work for an NPC?


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

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I need some spellhook code to work on an NPC.  It currently works fine with the PC, but when the NPC tries it out, it does not work.  The NPC is not in the party, but is in the Defender faction. 

#2
The Fred

The Fred
  • Members
  • 2 516 messages
Yes, it works, BUT the scripters in their wisdom didn't think people would want it to, by and large (because it was used originally for crafting). So, it will only worked in areas flagged as wild magic areas i.e. with the "X2_L_WILDMAGIC" flag (I think) set to TRUE. Luckily, you can just set this variable on all the areas - I was doing this by hand in my old NWN1 module but I'm pretty sure you can just loop through all areas OnModuleLoad, it's what I'm doing now.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks for the response Fred. Unfortunately I already re-worked my entire script and AI for doing it under the assumption that spellhook doesn't work with NPCs. It would have saved me a lot of time, ah well. If my current system turns out to be unstable, now I know I have a fall back system.

Question:

If you give an NPC the command ActionCastSpellAtObject() and the NPC is too far away to target the creature, does the engine automatically move the NPC closer, or do you have to script this as well?

#4
The Fred

The Fred
  • Members
  • 2 516 messages
Yes, the action includes moving into the correct range for that action (this is I believe in general true for all actions).

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Man! I could have saved *tons* of time that I used setting up a system to make the NPC move close enough before casting a spell. I still may switch over since I would only have to change a few lines of code.

#6
kevL

kevL
  • Members
  • 4 078 messages
if you already have that code, Matt, you might want to keep it; i've noticed a creature can get 'distracted' between moving and casting ...

#7
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Okay, I'll keep it. Right now things work fairly well.