Page 1 of 1

Spawning creatures with buffs

Posted: Tue Jun 08, 2004 8:47 am
by Dirk Cutlass
In a test mod, I want to spawn in some creatures (actually they could be static spawns) with buffs already applied, e.g. Improved Invis, Stoneskin, etc. How do I do this? The AI seems too stupid to use these spells even though they are in their spell-books. Can I make them cast these spells when they spawn? Its only a test mod, anything quick and dirty will do.

Thanks.

Posted: Tue Jun 08, 2004 8:51 am
by Flakey
you can log on as a dm and cast the spells that way.

Posted: Tue Jun 08, 2004 8:58 am
by Pekarion
that's cheatz and haxx :p you have to have that golden opportunity when they don't have anything thrown on yet, and sneak them in the back =d

Posted: Tue Jun 08, 2004 9:14 am
by Deider
This is possible. Hopefully someone more qualified than I will answer, but in the meantime, I think it involves making a custom OnSpawn script.

My suggestion would be to search the Bioware forum, especially the one for builders. This may even be in their FAQ.

*remembers to heed his own advice, since Deider's been wanting to do this for the Wi- er, for no particular reason :twisted: *

Posted: Tue Jun 08, 2004 4:16 pm
by CPU
Rockhome has some (nasty and painful) NPC mages that you can hear the casting start as soon as they spawn in, further down the road. You might want to check with Ferus. It's his world. He (unfortunately) knows how this is done.

Posted: Tue Jun 08, 2004 5:52 pm
by dougnoel
There are two ways to do this. Both require editing the OnSpawn script and/or UserDefined script for the creature(s) in question. The first way is to add the effects directly to the creatures. For an example of this, take a look at the default OnSpawn script for HotU. At the bottom you'll find some commented out code for applying the ghost effect to creatures.
http://nwn.bioware.com/builders/sctutorial20.html
The above Bioware tutorial might help with that.

The second is just to queue up some actions for the creatures to cast spells on themselves. This does not necessarily require them to know the spells, and is how I would approach it. Also, you can add some AI in if you want the creatures to say, cast buffs on their non-wizard friends/cannon fodder as well. This just requires use of the AssignCommand() function.

For more information on how to use UserDefined events, take a look at the HotU OnSpawn script - it's actually pretty well commented. If you would like some actual coding help (you too Deider), send me a PM and let me know exactly what you're trying to accomplish and I'll send you some code.

Doug

Posted: Tue Jun 08, 2004 7:46 pm
by gentry
Actually, with HotU Bioware added "Post-spawn" and "Pre-Spawn" to the OnSpawn commands. You just need to set the proper variable on the creature, and then create a UDE script for it, spelling the creature in it's Prespawn event. At least, that's my understanding, I haven't actually done it yet.

Read this for a complete explanation of this (and a bunch of new HotU scripting features: http://nwn.bioware.com/forums/viewtopic ... 8&forum=47

Posted: Tue Jun 08, 2004 7:54 pm
by Mistcaller
Make a custom OnSpawn script like this:

Code: Select all

#include "x0_i0_anims" 
#include "x2_inc_switches" 

void main() 
{ 
    SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY); 
    ExecuteScript("nw_c2_default9", OBJECT_SELF); 
} 
This script will make the NPC start "casting" a certain order of spells when spawned. The mage will not change that order, even if attacked.
This wont automatically place the spell effects on the NPC, but rather it will force him cast them.
If you want to create the former you'll need a different and more complex custom script.

Posted: Wed Jun 09, 2004 1:25 pm
by dougnoel
Mistcaller wrote:Make a custom OnSpawn script like this:

Code: Select all

#include "x0_i0_anims" 
#include "x2_inc_switches" 

void main() 
{ 
    SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY); 
    ExecuteScript("nw_c2_default9", OBJECT_SELF); 
} 
Well neat! Yeah, definitely more than two ways. I realized you could also put calls into the OnEnter scripts for the area or module and send buff commands that way. But Mistcaller's way is much easier. :-) After reading Mistcaller's post, I looked up SetSpawnInCondition() on NWNLexicon and found a bunch of neat flags you can use: http://www.nwnlexicon.com/compiled/cons ... _FLAG.html You can also see a list of them in the script editor if you click on the Variable Tab and type in NW_FLAG in the search text box. Not sure why they are in the variables list instead of constants list, as the lexicon seems to indicate they're used as constants. Regardless, there's a number of fun things you can do when spawning in creatures now with HotU. Cool.