RuneEd-Logo







 
Search/Browse Tutorials Click Here For Tutorial Search Instructions
Search For:

Major Additions to RuneEd - Scripting
 
Author: Dave Halsted
Last Updated: April 22, 2001 at 12:24:40 PM
 

Scripting
This is no small topic, and to the uninitiated, could use a tutorial or two. For now, I'll stick with this document's format and write up reference material for the different actors involved and their important properties.

The basic way it all works is via ScriptPoints and ScriptActions. ScriptPoints, which build into the Path network (see "Pathing" above), are the basic building block. When a creature is ordered to go to a specific ScriptPoint, he will:

1.Physically move to the ScriptPoint
2.Perform whatever animating/scripting is contained in the ScriptPoint's properties
3.Be released as a free-roaming Pawn or be order by that ScriptPoint to carry on to another ScriptPoint or ScriptAction. ScriptPoints are not one-shot deals. Creatures can be ordered to the same ScriptPoint multiple times and different creatures/creature classes can be ordered to the same ScriptPoint.

If a creature is too far from a ScriptPoint when he is ordered to it (e.g. maybe it's two rooms away with tunnels in between) he may not be able to get to it, even if a clean network of Pathing lines should lead him to it fine. When trying to script creatures to cover larger differences, it's best to daisy-chain ScriptPoints linked to each other to form the path. Here are the essential properties in a ScriptPoint:

ScriptAnim->ArriveAnim/ArrivePause: Here you can insert the name of an animation you would like a creature to play once it has arrived at the ScriptPoint. Whatever the ArrivePause is set to is how long the creature will loop that animation before proceeding to the next action. If ArrivePause is set to zero, the animation will loop once. As far as knowing what the animation names are, I don't know our current plan for releasing all that information. For starters you could look at ScriptActions and ScriptPoints within the included single-player maps to get some names...but that's not the most elegant solution. More on this in the future...

ScriptSync->LookTarget: The Pawn's head will be locked on to whatever target Tag you give here, and will be until it is later given a new look target. To have them look at Ragnar, type in "Player". LookTargets can be just about any other actor, as well.

ArriveEvent: This event will be fired when the creature arrives at the ScriptPoint.

bReleaseUponArrival: If set to TRUE, the creature will be released into its default free-roaming state once it has completed its ArriveAnim/ArrivePause/etc. There is an extra bit of control in here that is important to note. Let's say you set bReleaseUponArrival->FALSE, and the pawn is given a NextOrder of Scripting (see below) to some ScriptPoint across the room. After completing its actions at the current ScriptPoint, then, the creature will start trotting over to that next OrderTag location. However, the creature will do this like a robot -i.e. he will ignore the player and everything else. The player could whack on this creature as it's in transit and the creature would trudge along. This is invaluable when you want to make damn sure a creature follows a certain order of Scripting and can't be interfered with.

But on the other hand, if you set bReleaseUponArrival->TRUE and you are still giving the Pawn further scripting orders (i.e. telling it to head next to a ScriptPoint across the room, again), you'll have a smarter-interacting creature. What will happen is that the creature will still go and head over to that next ScriptPoint, but along the way as he heads over there he can be 'interrupted'. If he sees Ragnar or is otherwise alerted, he will break from scripting and come attack the player.


TurntoRotation: If set to TRUE, the creature will, upon arrival, rotate to align itself with the directional arrow of the ScriptPoint. Usually best left at FALSE.

bWalkToThisPoint: Self-explanatory.

NextOrder: if you would like the creature to head to another ScriptPoint next (or carry out a ScriptAction/ScriptDispatcher next), type "Scripting" into this slot.

NextOrderTag: This is where you type in the name of the next ScriptPoint you would like the Pawn to head to or the next ScriptAction/ScriptDispatcher you would like it to carry out.

ScriptActions are an invaluable addition to our scripting tools. In many ways they are like ScriptPoints, but the primary difference is that when a Pawn is ordered to a ScriptAction, he does not physically first walk over to wherever the ScriptAction is located, and he never will. The only way to get order a creature along specific map navigation is via ScriptPoints. ScriptActions are used for more complicated scripting than ScriptPoints allow for. Quite often in our maps you'll see a creature Ordered to head over to a ScriptPoint (and thus getting him into the desired position), at which point he is immediately next ordered to a ScriptAction. Since there is no physical walking involved, a creature will always carry out a ScriptAction immediately upon being ordered to do so. [However, you can affect a creature's rotation via ScriptActions just as you can with ScriptPoints.] Following are the significant settings for ScriptActions:

ScriptAnim: The same as for ScriptPoints

ScriptSound: The same as for ScriptPoints, except that with ScriptActions you can insert an independent sound playback delay.

LookTarget: Same as for ScriptPoints.


ControlHead/ControlMouth/ControlTorso/TimeGranularity: These give you the ability to 'animate' a Pawn a good deal at a ScriptPoint. You control these by typing in strings of letters into the blank text space. With ControlHead, the letter 'a' denotes that the head is turned all the way left, while the letter 'z' denotes that the head is turned all the way right. So if you wanted a creature to look left-right-left-right, you'd type in the text string "azaz". ControlTimeGranularity defines how much time each letter represents. If you set ControlTimeGranularity to '1' (one second), the left-right-left-right sequence will take a total of 4 seconds. 'a' is left and 'z' is right for ControlTorso, as well. For ControlMouth, 'a' means the mouth is fully closed and 'z' means it's open wide like a nutcracker. For more natural mouth movements I wouldn't go too far past the letter 'p'.

bFireEventImmediately: Under the Events property of a ScriptAction (just above "Tag"), you can type in the name of an Event you would like fired off as part of the ScriptAction. If bFireEventImmediately is set to TRUE, that Event will be fired the instant a Pawn is Ordered to the ScriptAction. If it is set to FALSE, that Event will not fire until the Pawn has finished all the animation/syncing defined in the ScriptAction.

bReleaseUponCompletion/bTurnToRotation: The same as with ScriptPoints (see above).

bWaitToBeTriggered: Now this one is a real save-all. If this is set to TRUE, the Pawn Ordered to this ScriptAction will 'hold' indefinitely. Once an Event has called the Tag of this ScriptAction, the creature will carry it out. If set to FALSE, the creature will carry out the ScriptAction immediately upon being Ordered to do so. Here's an example of a perfect use:

Let's say you want a creature in the distance to run over to a holding point, but not free up and attack the player until the player nears that holding point. What you do is put a ScriptPoint at that holding point, and Order the creature to that ScriptPoint. Make that ScriptPoint's NextOrderTag be a ScriptAction; within that ScriptAction, set bReleaseUponArrival->TRUE and bWaitToBeTriggered->TRUE. Then put a player proximity Trigger over by where you want the player's proximity to release the creature; make the Event of that Trigger be the name of the ScriptAction. When you play the level, the creature will run over to that ScriptPoint. When the player sets off the proximity Trigger, the ScriptAction will be called and will then carry out... because it had been set to bReleaseUponArrival->TRUE, the creature will then release at that point and come running at the player.


NextOrder/NextOrderTag: Same as with ScriptPoints (see above).

So how do you Order creatures to these ScriptPoints/ScriptActions/ScriptDispatchers in the first place? You can do it with an OrdersTrigger (it's a regular Trigger with a special property for typing in a creature name Tag and a ScriptPoint/etc. name Tag.) You can do it with a SpecialEventRune whose initial state is set to OrderObject [see the "Trigger" section above], and SpecialEventRune can in turn be called by a regular Trigger, a Dispatcher, an Event fired off a ScriptAction, a creature's death Event [Pawns' "Event"s are fired when they die], damn near anything. Or, you can place creatures in the map with Orders built-in or ActorGenerate [see "KeyPoint" above] a creature with built-in Orders. These built-in Orders are described here:

SpawnOrders/SpawnOrdersTag: The creature will carry out these orders the second he is actorgenerated in or the map begins. Type in "Scripting" for SpawnOrders and the name of a ScriptPoint/Action/Dispatcher for the SpawnOrdersTag.

SpawnAlertOrders: The creature will carry out these orders as soon as he sees the player or is otherwise alerted to the player's presence. Type "Scripting" for SpawnAlertOrders

SpawnTriggerOrders: When the specific Tag name of the creature is called by an Event, the creature will carry out these orders.

With SpawnTriggerOrders/SpawnAlertOrders/SpawnOrders, you simply leave those slots blank to disable them; this is the default.

You'll notice that you'll almost exclusively be typing in "Scripting" for the Orders themselves, and then the Tag of a ScriptPoint/Action/Dispatcher for the actual OrdersTag. There are some other orders other than "Scripting" that you can try. Actually, I don't know if the bulk are supported any more (I'd avoid the "Attack" order), but one that you can use is "Roaming". If a creature is given Orders of "Roaming" (with no subsequent OrdersTag), that creature will randomly roam around the geometry until he sees the player is alerted. The DarkVikings at the end of Thor1.run are all "Roaming", so they're not always in the same position whenever you play.

[ Click here for printable version ]

 

Current Comments on this article:

No User comments added.

Post New Thread
This comment system uses the official RuneGame.com Forum as its verification. To post a comment, please register on the main RuneGame.com Forum using the "Want to register?" link below.

Your UserName:    Want to register?
Your Password:   Forgotten your password?
Message:
 
Copyright ©2001 Ed.RuneGame.com