![]() |
![]() |
|||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
The Userdefined Event Is Your Friend Intended Audience: [Printer Friendly / Syntax Highlight] The great thing is: you don't have to. 98% of the creature scripting that was done in the NWN official campaign was done using UserDefinedEvents. I sat down with Preston (one of our scripters and one of the main guys behind the generic AI) and fired off a rapid series of things I would like to script... just about every one was do-able using the UserDefinedEvent. And it is easy to implement. Let's back up for a second here and discuss what an event is. Basically there are numerous scripts (sets of instructions) that exist on a creature... and each one is tied to events. When an event occurs, it tells the creature to fire off the proper script. No event = the script doesn't run. Basically, the UserDefinedEvent allows you to access the normal events a creature uses (OnPerception, OnDeath, etc.) without disturbing the normal AI routines or modifying the already-existing scripts. Using the UserDefinedEvent The generic OnSpawn script has a whole series of commands in it which are commented out... as a matter of fact, without the user changing anything in it, all that large script really does is three commands: it tells the creature to walk waypoints that refer specifically to its tag, set up its listening patterns (so it will respond to shouts from other NPC regarding combat) and generate a small amount of generic treasure in inventory (some gold, etc.) It is designed to allow the user to set states that access the generic AI, as they wish. All they do is go through the list and uncomment any state flags they wish to use (remove the '//' double slashes at the beginning of the command). Then save the OnSpawn script under a different name and use it in place of the regular one... voila, the generic behaviors have been altered. SetSpawnInCondition (NW_FLAG_PERCIEVE_EVENT); SetSpawnInCondition (NW_FLAG_ATTACK_EVENT); SetSpawnInCondition (NW_FLAG_DAMAGED_EVENT); SetSpawnInCondition (NW_FLAG_DISTURBED_EVENT); SetSpawnInCondition (NW_FLAG_END_COMBAT_ROUND_EVENT); SetSpawnInCondition (NW_FLAG_ON_DIALOGUE_EVENT); SetSpawnInCondition (NW_FLAG_DEATH_EVENT); What Next? Okay... you've uncommented the flags you want to script for and re-saved the OnSpawn script. That's taken you 2 minutes. Now how do you use it? Every creature has an OnUserDefined event section that you can put a script in. For any creature you make, it will be completely blank... this is where you do your actual scripting. Any script you put here will be 'checked' every time an event of the type you uncommented occurs. So if you uncomment the 'SetSpawnInCondition (NW_FLAG_DISTURBED_EVENT)', then every time the creature's inventory was disturbed (say someone pickpockets an item), the OnUserDefined script would also be run. The basic OnUserDefined script would look similar to this: Then I create a script for the OnUserDefined perhaps as so:
|
|||||||||||||||||||||||
|
|
||
|
Multiplayer Games at Neverwinter Connections
|
||
|
Download Modules
|
||
|
5,047,091 utilisateurs sur le site de BioWare:
|
||