how do you make it so an NPC will cast defensively?
sarevok57
Member Posts: 6,002
*sigh* oh man is this toolset really starting to annoy me with its shenanigans
even with the script generator and with NWN lexicon for the life of me i can't wrap my head around why this defensive casting mode script won't compile
i go to lexicon and all it says is
int GetDefensiveCastingMode(
object oCreature
);
and then some oCreature jargon and what not
and then you can have it active or disabled, and thats it, no example on WHAT TO ACTUALLY TYPE in the script, so trying to do some detective work i tried;
int GetDefensiveCastingMode(object DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
int GetDefensiveCastingMode(object, DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
int GetDefensiveCastingMode(OBJECT_SELF, DEFENSIVE_CASTING_MODE_ACTIVATED );
(which i swear was going to be a winner.... )
and that failed
int GetDefensiveCastingMode(object, oCreature DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
int GetDefensiveCastingMode(OBJECT_SELF oCreature, DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
so it would be nice for someone who actually knows what the command is to type it out for me, because apparently i am not one of the chosen ones who actually understand this whacky alien language regardless on how much i try
even with the script generator and with NWN lexicon for the life of me i can't wrap my head around why this defensive casting mode script won't compile
i go to lexicon and all it says is
int GetDefensiveCastingMode(
object oCreature
);
and then some oCreature jargon and what not
and then you can have it active or disabled, and thats it, no example on WHAT TO ACTUALLY TYPE in the script, so trying to do some detective work i tried;
int GetDefensiveCastingMode(object DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
int GetDefensiveCastingMode(object, DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
int GetDefensiveCastingMode(OBJECT_SELF, DEFENSIVE_CASTING_MODE_ACTIVATED );
(which i swear was going to be a winner.... )
and that failed
int GetDefensiveCastingMode(object, oCreature DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
int GetDefensiveCastingMode(OBJECT_SELF oCreature, DEFENSIVE_CASTING_MODE_ACTIVATED );
that failed
so it would be nice for someone who actually knows what the command is to type it out for me, because apparently i am not one of the chosen ones who actually understand this whacky alien language regardless on how much i try
0
Comments
int GetDefensiveCastingMode(object oCreature);
This is the function declaration. It tells you the three components of the function so that you could use it yourself. I'll go through then out-of-order below.
1. GetDefensiveCastingMode
This is the name of the function. Very straightforward, if you want to ask, this is what you type - Note capitals matter. Good function names also hint at what it will do, in this case it's going to Get whether something is in Defensive Casting mode.
2. (object oCreature)
The Parameters, this tells you that the function expects to receive some 'thing' to work with. In particular, it's looking for a 'thing' which is an object. When it receives that object, it's going to name it oCreature. For using the function, this name doesn't really matter (only if you were writing the function yourself) but it again hints that the type of object it expects to receive is a Creature object, and it might not work correctly for any other type of object (like an item, which obviously can't be defensive casting).
3. int
This is the 'return type' for the function. When a function is run it either does something, returns something, or both. In this case, it returns an int (integer). Reading more of the lexicon article on the function, it explains that there are two possible return values. The article lists these as DEFENSIVE_CASTING_MODE_ACTIVATED and DEFENSIVE_CASTING_MODE_DISABLED. In the 'See Also' section you can see that these are defined as Constants with the integer values of 1 and 0 respectively
Therefore in order to actually use the above fucntion you'd need to do something like: Note that OBJECT_SELF refers to "this thing running the script", so this only works if the script-runner is the creature itself, maybe as part of an "OnDamaged" event
Like I said at the start though - It looks like the wrong function for what you want. That function only retrieves whether a creature is currently in defensive casting, where-as you asked for how to make it do defensive casting. Defensive casting is an Action Mode, so what you're really looking for is SetActionMode.
void SetActionMode(object oCreature, int nMode, int nStatus);
This function is a 'void', which means it doesn't return anything and therefore must be a function which 'does something'. The parameters expect an object (the creature) and two integers to represent the Mode and the Status for that mode. A little bit more reading of the lexicon suggests the appropriate function to be:
Now, the appropriate place to insert that function is another matter. Perhaps during the "OnSpawn" script of the creature? This depends on more specifics than you've provided.
I hope that helps. Always hard to judge someones skill-level from one post, so apologies if I've aimed too high or too low. Feel free to shoot me a PM for more help if you need it.
TR