-
Notifications
You must be signed in to change notification settings - Fork 1
1. DScripts
Sorry at the moment just a sloppy copied list from the original post on ttlg.com. Will fix this.
DBaseTrap - Standard Parameters
This script is the base framework for nearly every other script. By itself it has no use but will handle the generic parameters. Every Parameter explained here has to be put into the Editor->Design Note separated from the next via ;. They will work for every other script if nothing else is specified.
Normally scripts react to TurnOn and TurnOff messages. With [ScriptName][On/Off]="YourMessage" you can define other messages the script will react to. It is possible for a script to react to more than one TurnOn/Off message. In such a case each message (including the first!) needs a + before them like: DRelayTrapOn="+TurnOn+FrobWorldBegin+Damage"
Squirrel Note:It is possible for a script to have another On/Off default message. You can specify this with DefOn="CustomTurnOn" or DefOff="YourOff" anywhere in your script class but outside of functions. Messages specified in the Design Note have priority. For example DWatchMe is an exception which uses BeginScript instead of TurnOn
As a matter of fact this lets you simulate the three standard Trap Control Flags NoOn, NoOff, Invert - NOTE: The standard Trap Control Flags set with the object property have no effect on DScripts.
You can use [ScriptName]On="TurnOff";[ScriptName]Off="TurnOn" to simulate Invert; [ScriptName]On="Null" can be used to simulate NoOn and [ScriptName]Off="Null" can be used to simulate NoOff. Remember that if you specify [ScriptName]On="TurnOff" without specifying [ScriptName]Off, then TurnOff will perform the On as well as the Off action.
[ScriptName]Count Use this parameter to specify the maximum number of times that the script will work. You can use [ScriptName]Count=1 to emulate the Once Trap Control Flag. The default is 0 (infinite). Both TurnOn and TurnOff are counted by default. You can use [ScriptName]CountOnly=1 to count only TurnOn, and [ScriptName]CountOnly=2 to count only TurnOff - the respectively other message will still have their full effect even if the Count is full. Sending the trap a ResetCount message will reset the counter.
[ScriptName][On/Off]Capacitor This parameter specifies the number of times that a trap will need to receive its triggering message before it activates. For example: An NVRelayTrap with NVRelayTrapCapacitor=3 will only relay every third message, while one with _NVRelayTrapOnCapacitor=4; NVRelayTrapOffCapacitor=2 _will relay every second TurnOff message but only every fourth TurnOn message. The default is 1.
[ScriptName][On/Off]CapacitorFalloff can be used to specify the time, in seconds, that it takes for the trap to "lose charge", and the activation count to go back down by one activation.
Note 1: Count and Capacitor data are refreshed on script_reload and exiting game_mode. Therefore I suggest that you insert the script_reload command into your GameMode.cmd Note 2: All Capacitor parameters don't interfere with each other. For example setting Capacitor=3 and OnCapacitor=2 and then receiving TurnOff,TurnOff,TurnOn,TurnOn will relay both TurnOn messages as the first TurnOn is the 3rd message and the 2nd is the 2nd TurnOn. Same goes for CapacitorFalloff it won't decrease an OnCapacitor only OnCapacitorFalloff will do.
[ScriptName]Delay Setting this to a value greater 0 will postpone the action performed by this script by the specified number in seconds. [ScriptName]Delay=0.5 for example would delay the action by 500ms. By setting [ScriptName]ExlusiveDelay=1 the script will abort the still being delayed action and will start the Delay at 0 again. This is for example useful if you want a script to react to Water Arrows or entering a Room/OBB where due to the engine multiple On messages are sent in a very short time.
[ScriptName]Repeat If you want a script to repeat its actions multiple times you can set this parameter. By default it is 0 for none. The time between repeats is specified with [ScriptName]Delay. Infinite repeats are declared via [ScriptName]Repeat=-1 and will be stopped by the corresponding other message. A infinite repeating TurnOn will be stopped by a TurnOff. This single TurnOff will only stop the repeat and will not perform the DoOff action of the script. Only a second TurnOff will trigger it.
[ScriptName]FailChance A chance (from 1 to 100 or -100 to -1) that the specific script will not activate. If you define a negative value Capacitor and Counts will still be increased first and then tested if the script will fail or not.
Variable as Parameter $QVar can be used for all parameters as it represents a number for example DRelayTrapRepeat="$MyQVar"
Script Targeting If a script is looking for an object parameter for example [ScriptName]Target you can use the following expressions. Code: [me] the object itself [source] the object that sent the triggering message &LinkFlavor all linked objects with the specific link. *Archetype/MetaProp all concrete objects directly descending from the given Archetype @Archetype/MetaProp all concrete objects given Archetype and all of its descendants ^Archetype/MetaProp/Name finds the closest object. $QVar will sent to the object with the number stored in the Quest Variable QVar
+Everything Single objects and combinations of the other types. +-Everything Remove a previously added subset.
When using the + operator with a number like pure object/archetype numbers a # must be inserted before, also for example Target="+#42+#-17".
Example:
•Target="+[me]+&~ControlDevice+@M-DoesPatrol+coolguy+#42"
This will give back the object itself, all ~ControlDevice linked objects, every object with the MetaProperty M-DoesPatrol, the object named coolguy and the object with the number 42. IMPORTANT: Again if you want to address a pure object number you need # before it! (Only needed in combination with +)
•Target="+@guard+-@M-FrontGateGuard+-@M-TopFloorGuard"
This will target all guards which don't have the two specified metaproperties.
Note: Even if only one object is needed like for DCopyPropertySource="&LinkFlavour". You will only get the object with the highest LinkID (needs confirmation).
Design Note Examples DTeleportPlayerTrapOn="TurnOff" DTrapTeleporterOn="FireStimStimulus" DRelayTrapRepeat="$MyQVar"
Note/Tip From my testings Scripts from different .nut are shared, so you could also use extend DBaseTrap in your files without having to creating a new class yourself.
DStdButton (extends DRelayTrap) DStdButton has all the StdButton features - even TrapControlFlags work( Once will lock the object) - as well as the DRelayTrap features, so basically this can save some script markers which only wait for a Button TurnOn
Additional: If the button is locked the joint will not activate and the Schema specified by DStdButtonLockSound will be played, by default "noluck" the wrong lockpick sound.
DAddScript Squirrel Note: Can be used as Root -> D[Add/Remove]ScriptFunc
Adds the Script specified by DAddScriptScript to the objects specified by DAddScriptTarget, by default &ControlDevice. Additionally it sets the DesignNote via DAddScriptDN. If Script parameter is not set only the DesignNote is added/changed.
A TurnOff will clear the Script 4 slot.
NOTE: • It will try to add the Script in Slot 4. It will check if it is empty or in case if it is not if the Archetype has it, else you will get an error and should use a Metaproperty. • It is possible to only change the DesignNote with this script and so change the behavior of other scripts BUT this only works for non-squirrel scripts! • Using Capacitor or Count for will not work for newly added DScripts. As these are created and kept clean in the Editor.
DArmAttachment Attaches another object to the players arm.
So when using an empty hand model you can create your own custom weapons. It can be given to any weapon-ready object together with Inventory-> Limb Object: emptyhan or BJACHAND (Both models are included; made by Jason Otto and Soul Tear). OR you can also add it to normal weapons to attach a shield or light or whatever creative stuff you come up with
Parameters: DArmAttachmentUseObject: = 0 (Default): Will create a dummy object and give it the Shape->Model: DArmAttachmentModel = 1 Will create a copy of a real object/archetype specified in DArmAttachmentModel. If you want to attach special effects for example. = 2 (experimental and not really working): Same as 1 but the object will be really physical -> Real collision sounds based on the object. = 3 (experimental little working): Same as 2 but works even better. Disadvantage: Errors in DromED, Model will pass through walls/objects.
DArmAttachmentModel: model name(0) or object Archetype (1) depending on (DArmAttachmentUseObject) DArmAttachmentRot and DArmAttachmentPos: The model will most likely need some adjustments in position and Rotation. Both parameters take 3 arguments separated by , like : "90,0,0" or "0.1,-0.6,-0.43". They stand for HPB-Rotation respectively xyz translation. But most like don't behave like you expect it. Best method how to figure out the numbers is to use it in combination with set game_mode_backup 0 (NEVER SAVE AFTER!) and modify the DetailAttachment link. It's trial and error.
NOTE: You will(might) also need to do some hierarchy changes to adjust the sound and motions. Also I would say this script is not 100% finished please give feedback. TIP: Remember you can use multiple different melee weapons by using the cycle command. Or design them so that you can also use them from the normal inventory.
DHitScanTrap (extends DRelayTrap) (Has the DRelayTrap sending features: [On/Off]Target or [On/Off]TDest) When activated will scan if there is an object or a wall between two objects. Imagine it as an invisible scanning laser beam. The start and end object are specified by DHitScanTrapFrom and DHitScanTrapTo, the script object is used as default if none is specified. If the From object is the player the camera position is used, if the To object is the player as well then the ray will follow the center of the players view - for example to check if hes exactly facing something.
The Object that was hit will receive the message specified by DHitScanTrapHitMsg (default is "DHitScan"). By default when any object is hit a TurnOn will be sent to CD linked objects. Of course these can be changed via DHitScanTrapTOn and DHitScanTrapTDest Alternatively if just a special set of objects should trigger a TurnOn then these can be specified via DHitScanTrapTrigger. THIS WAS CHANGED in 0.28a from Target to Trigger!!!
NOTE: Unlike other scripts DHitScanTrapFrom and To only take single objects at the moment. I can add multiple object support as well but NOTE2: The scanning is described as an rather expensive progress. So don't use it like 100 times per second over long distances. Best to only activate it when you need it. (That's why this is no real Trigger) DRay Working with a template particle effect defined by DRaySFX, this script creates and scales particle effects between objects specified by DRayFrom and DRayTo. with the + or similar operator you can create multiple and different SFX between multiple objects at once. For all effects only the X values and Particle Launch Infos are used! Sending further TurnOn messages will not create additional SFX but update the already present ones.
Primarily two types are supported: DRayScaling: = 0 (Default): For even particle effects. This will scale up their spawn box and the particles used. A small effect with look exactly like a big one. = 1: For "shooting" Particle effects which start at the From location. Increases particle lifetime. (Min=Max)
TIPS: • A good template is the ParticleBeam(-3445) • You can use this script in the editor with an appropriate DRayOn message. For example "test" (use script_test objId) or Sim (objects will be created after leaving game mode) and then delete the script object. • By using Particles Start Launched you can create very different and more solid effects but they will be less accurate in hitting the To object. • You can either use an infinite repeating TurnOn from an outside Trap or DRayRepeat=-1 to constantly update your special effects in case the objects are changing positions. • If you don't want to turn off the special effect the second method is better else I recommend the first. (Else you would need +TurnOff+TurnOff+TurnOn sequence to deactivate the script completely.
• When using launched very fast particles (like the laser in the video) the effect degenerates after a few seconds, so sending a "+TurnOff+TurnOn" with DRayOffCapacitor=50 will update the effect 50 times and then create a new one. The capacitor doesn't have to be that high but without to much performance is used to calculate the launched particles!!! (and it's a more smoother as well) • My Demo effects are rather simple, be creative with the particle settings, share your stuff if you for example created a spiral or or or... All paricles are created with DRay and the damage detection with DHitScan
DDumpModels Included in the DDumpModel.nut read the instructions for more detailed information. Or in this post here
Basically it will create the models from your obj folder and place them in the editor. The parameters used are exactly as written here:
First= the model name of the first model you want to use; if it's a number it will start with for example the 100th model in your list. MaxModels = will stop after for example 2000 have been created. Screenshots=1 will automatically create screenshots in game mode while creating the models.
DHub (not a DBaseTrap script) will by default send a TurnOn at ControlDeviced linked objects when it receives a valid message. Valid messages are declared in the DesignNote like this: DHub[Message]="Parameter1=Value1;Parameter2=Value2". Even if you want to use the default options a minimal DHub[Message]="==" is necessary! The + operator does not work here. Multiple actions can be declared for the same Message via DHub[Message]2="Parameter1=Value1;.... The used numbers must be consecutive! If there is a gap all above numbers will be skipped. There is no maximum to different actions a Message can have.
Parameters are basically identically to the ones by DBaseTrap or DRelayTrap beside [T]On/Off. NOTE:!Parameters require no prefix. String values may not have " " around them!!! And I don't recommend blank spaces anywhere inside the "Parameter=Value;P2=V2" declaration, only if you want to address an object like Target=@false label
The valid parameters - all operators like +,@,$... will work here Code:
Relay What message(s) should be sent. Like for DRelayTrap there is stim support like [3.7]FireStim. Target To which object(s) Delay will delay the message and also defines the time between repeats. ExclusiveDelay When set to =1 will abort messages from this action which are still waiting to be sent. Repeat how often should the action be repeated. Repeat=-1 for infinitely. All Infinite repeats can be stop via a StopRepeat. A single action (repeat must not be infinite) via [Message+number]StopRepeat. Count The maximum number of times a action will be executed. Default =0 infinitely. All counts can be reset via a ResetCount message. Single action counts like above with via [Message+number]ResetCount. Capacitor The number of times this action will need to receive its triggering before executing. Default = 1 everytime. CapacitorFalloff The time in seconds after the Capacitor will go down by 1. Default =0 FailChance A chance (from 1 to 100 or -100 to -1) that this action be executed. If the number is negative Capacitor and Counts will still be increased first and then tested if the script will fail or not.
Default Parameter: By setting DHub[Parameter]="Value". This Parameter will be default for all actions if not specified otherwise. As an example and as script default DHubRelay="TurnOn";DHubTarget="&ControlDevice".
Design Note example DHudCompass Upon receiving FrobInvEnd will clone the current selected object and attach it slightly below the players camera and keep its facing always to north. By default there is no TurnOff as it is TurnedOff via toggling.
Engine Features -> Frob Info > Inv Action: Script must be set.
I suggest scaling down the object to 10-50%. DCompileTrap On TurnOn tries to compile the Editor Comments. This script lets you write your own squirrel commands inside the editor.
It uses Editor Comment because the Squirrel line/command end ; also indicates a new Parameter in the Design Note which do interfere, also you are able to use newlines much easier. But the newlines(made by enter) will be translated to \n and to not destroy your code you need to comment these \n out with a /* at the end of the line and */ at the start of the next
Editor Comment example: Code:
ActReact.Stimulate(Object.Named("player"),"BashStim",20);/* now comes a new line /DarkUI.TextMessage("String made by DCompileTrap");/ */DarkGame.KillPlayer()
Squirrel changes: (See also end of this post) --DGetParam removed the single parameter as now everything undergoes a string check handled by DCheckString and returns a single obj,string unless adv=1 is set, then an array is returned. --All DoOn,DoOff functions will now take the DesignNote as a parameter to save internal extra calls. --Removed most of the basic functions from the DBaseTrap so you can access them in other .nut files without using extend DBaseTrap.
DRelayTrap Can be used as Root -> DSendMessage; DRelayMessages A relay with all the DBaseTrap features. On TurnOn it will relay the message specified with DRelayTrapTOn. Respectively the on TurnOff to be sent messages can be specified with DRelayTrapTOff. By default these are TurnOn and TurnOff. With the + operator you can define multiple On, TOn, Off and TOff messages. With DRelayTrap[On/Off]Target (NEW: Also [On/Off]TDest works as an alternative) you can specify where to sent the message(s) to. Default are ControlDevice linked objects. If DRelayTrapOnTarget is specified then it will take priority over DRelayTrapTarget.
As a TOn, TOff message you can also send a Stim to do this, first enter the intensity surrounded by square brackets, followed by the stim name. For example: [ScriptName]TOn="[5.00]WaterStim".
Design Note example NVRelayTrapOn="+TurnOn+BashStimStimulus";NVRelayTrapTOn="+TurnOn+[5]FireStim";NVRelayTrapOnTarget="+player+^ZombieTypes"
What will happen: On TurnOn or when bashed it will send a TurnOn and a FireStim with intensity 5 to the player and the closest Zombie.(relative to the object with the script) As nothing else is specified on TurnOff will send a TurnOff to all ControlDevice linked objects. Code:
DDrunkPlayerTrap On TurnOn makes you drunk a TurnOff sober. Multiple Ons from the same source will reset the timer and will do a FadeIn again. Multiple sources do stack.
Optional parameters:
DDrunkPlayerTrapStrength regulates the strength basically every number can be used I would suggest something between 0 and 2 default=1
DDrunkPlayerTrapInterval a second regulator how often the effect is applied. With a lower interval higher strength becomes more acceptable. default[seconds]=0.2
DDrunkPlayerTrapLength How long the effect will last in seconds. Use 0 for until TurnOff is received default[seconds]=0
DDrunkPlayerTrapFadeIn Fades in the effect over the given time at the end the full strength is used. default[seconds]=0
DDrunkPlayerTrapFadeOut Only works if Length is set! Will gradually make the effect weaker over the last given seconds. default[seconds]=0
DDrunkPlayerTrapMode The effect is made up by 1) shaking the camera and 2) Pushing the player.(left/right/forward). default=3
By setting Mode to 1 or 2 you can use one effect only. Especially for Mode=2 higher Strength values can be used.
Check out the demo how this can be used as a potion. NOTE: v0.22: it's Savegame compatible now. I think you can also create some interesting effects with an early FadeOut and Repeats.
DCopyPropertyTrap
Target default: &ScriptParams Source default: [me]
Similar to S&R->SetProperty but can set multiple properties on multiple objects at the same time.
Upon receiving TurnOn copies the properties specified by DCopyPropertyTrapProperty form the object DCopyPropertyTrapSource(default is [me]) to the objects specified through DCopyPropertyTrapTarget if not setScriptParams linked objects will receive the propertie(s) by default. Multiple properties can be copied with the + operator.
You use the script object as a sender or receiver.
Design Note example: DCopyPropertyTrapProperty=""+PhysControl+RenderAlpha";DCopyPropertyTrapSource="&Owns";DCopyPropertyTrapTarget="[me]" This will copy the Physics->Controls and Renderer->Transparency(Alpha) property from the object linked with an Owns linked to the object itself.
DWatchMe By default when this object is created or at game start (BeginScript) creates AIWatchObj Links from all Human(-14) to this object. Alternatively an alternate DWatchMeOn message can be used, as well as DWatchMeTarget to specify another object, archetype or metaproperty.(see notes below)
•Further (if set) copies!! the AI->Utility->Watch links default property of the archetype (or the closest ancestors with this property) and sets the Step 1 - Argument 1 to the Object ID of this object. •Alternatively if no ancestor has this property the property of the script object will be used and NO arguments will be changed. (So it will behave like the normal T1/PublicScripts WatchMe or NVWatchMeTrap scripts).
On TurnOff will remove any(!) AIWatchObj links to this object. You maybe want to set DWatchMeOff="Null".
Usefullness: If you have multiple objects in your map and want that AIs perform simple(?) actions with each of them under certain conditions. For example: You can use it to let guards relight every extinguished torches on their patrol path -> see Demo. Initially it was designed to be used with DPortal do force an alerted AI to follow the player through portals. Still not optimal but the basics are there.
Tip: If you use a custom On command, multiple links could be created so you may want to set the Watch->"Kill like links" flag in that situation.
Design Note Examples: DWatchMeOn="WaterStimStimulus";DWatchMeTarget="@guard";DWatchMeFailChance=60 DWatchMeOn="TurnOn";DWatchMeTarget=42 DWatchMeTarget=ValidObjectName DWatchMeTarget=*swordsman
DTPBase Base script for the other 3 scripts. Has by itself no use. •If a patrolling AI is teleported it will reassume its patrol after teleportation from the now closest Patrol Point. •Contains the DTeleportation(who,where) function which teleports a given object to absolute world coordinates. DTeleportPlayerTrap •Upon receiving TurnOn moves the player by x,y,z values specified in the Design Note via DTpX=;DTpY=;DTpZ=. Use for 100% Seamless teleportation. •If no parameter is set or all are 0 then the player gets teleported to the location of this object instead.
Design Note Example: DTpX=-3.5;DTpZ=10 DTrapTeleporter
Target default: &Control Device
Upon receiving TurnOn teleports a ControlDevice linked object to this object and keeps the original rotation of the object. Further by default currently non-moving or non-AI objects will be static at the position of the TrapTeleporter and not affected by gravity until their physics are enabled again - for example by touching them. By setting DTeleportStatic=0 in the Editor->Design Note they will be affected by gravity after teleportation. Does nothing if Controls->Location is set.
Design Note Example: DTeleportStatic=0 DTrapTeleporterTarget=@Zombie types DPortal
DefOn ="PhysEnter" Default Target = Entering Object. (not [source]!)
Teleports any entering object (PhysEnter). Either by x,y,z values specified in the Design Note via DTpX=;DTpY=;DTpZ= or to object linked with ScriptParams. If a value in the Design Note is specified the first option takes priority! Unlike DTeleportPlayerTrap this script takes the little offset between the player and the portal center into account, which enables a 100% seamless transition - necessary if you want to trick the player.
Design Note Example: DTpX=-3.5;DTpZ=10 DPortalTarget="+player+#88+@M-MySpecialAIs" Tip If you use the ScriptParams link and want a seamless transition, place the destination object ~3 units above the ground