CAS Functions
--------------
For a quick listing of the functions in CAS for experienced users, see the reference:<LINK GOES HERE>
This section is for those who are new to CAS, and need to learn roughly what each function does and how it should be used.
All functions have an integer constant associated with them. That is, a number which represents them. These integers are arranged in groups corresponding loosely to what they do. Each group will be explained here one at a time.
1x Attacks
------------
In CAS, you can insert an attack command anywhere. What this actually does, is triggers the weapon's hit detection method. Either by sensor or projectile. The system will handle everything from there, triggering sounds and particle effects as appropriate.
The attack command is not actually needed to do damage in most combat systems. The majority of systems do damage between themselves, and the weapon is merely a fancy visual on top of that. Currently the only system that the attack command is needed for, is Linden Damage. It is primarily used for the hit sounds/effects.
Types:
Attacks come in different types. Currently, three types are supported. Each type of attack has a hit soundgroup and a hit particle effect associated with it. Currently, customisation of attack types is not supported, one of the very few areas of Custom Arms that cannot be customised. This will probably change in the future, as I will look towards making attack types more customiseable down the line.
There is one command for each type. Starting at 11 and working upwards:
11 Slash: A slash with a bladed weapon. eg, sword, knife, claw
12 unarmed: A strike with a nonmetallic blunt object, baseball bat, fist, foot, tentacle, etc
13 Blunt: A strike with a blunt metal object. eg, metal staff, mace, etc.
to specify an attack call, use a value between 11 and 13 in the second element of a command. Try to choose the most appropriate attack type.
Note that every attack type, in addition to it's normal hit sound, also has a critical hit sound. The critical sound will be triggered automatically instead of the normal one, if the attack has a Damage value of 6 or higher. See below for more info
Damage and Power:
in addition to a type, each attack also has a damage, and a power value.
The damage value determines how much damage the attack does. Currently, only Linden Damage respects this value. Other combat systems work out their attack damage on their own. An applicable value is between 0 and 9, with 0 being no damage, and 9 a massive hit. Note that trying to insert a value higher than 9 or lower than 0 will not work
The power value determines how much the attack pushes the target. A value of 0 means no push, and 9, the highest, will send someone flying 50m or so away. Using push is only recommended for a few select attacks, like big roundhouse kicks, and specials. It is not advised to use push on every attack, though there are no technical limitations on doing so. Abusing the push feature is likely to get you banned from roleplay sims. Magotek is not responsible for this.
Attack Direction:
The attack direction is a value which tells the system what way you are swinging the weapon. It orients damage projectiles accordingly, so that the effects are directional. For example, uyou can make blood spray in the direction you swing a sword.
The following chart lists the directions. Only one is useable per attack
Projectile Direction Constants
1 up
2 Up/Left
3 Left
4 Down/Left
5 Down
6 Down/Right
7 Right
8 Up/Right
9 Forward (away)
10 Back (towards self)
Using
All attacks take the following arguments
1: Damage and Power concatenated into one integer
2: Attack direction. a value from 1-10. See list above.
The function that you call determines the type.
To put this all together. If you want to create a command for a bladed slash to the right, with moderate damage, you would use something like
1.0,11,40,7
Those values are:
1.0: a random time picked for an example. Use the appropriate time for your command.
11: The function call for a bladed attack
40: 4 and 0 put together. That's 4 damage, 0 power (no push)
7: The attack direction of right. Will make the blood spray to the right from this attack.
2x Utility
------------
21 Hide Weapon: Turns the Held weapon invisible.
22 Show Weapon: Turns held weapon visible. No arguments
These two functions will make the weapon visible or invisible. What might you use this for? There are several possible uses. For example, you could make a thrown weapon, that disappears from your hand (by turning invisible) when you throw it. And returns to your hand by turning visible again.
Another good use for this is in weapon-specific sheath/draw commands. See the Weapon Settings thread for more info here: <LINK GOES HERE>
.................................
23 Sheath Weapon: Sets weapon status to 0, updates the sheath, and turns held weapon invisible (if weapon settings allow). no Arguments
24 Draw Weapon: Sets weapon status to 1, updates the sheath, and turns held weapon visible(if weapon settings allow). no arguments
These functions draw and sheath the weapon. More specifically, they:
1. Change the internal weapon status value between 1(drawn) and 0(sheathed)
2. Send a linkmessage out on the weapon status channel (weapon_status_channel = 457473663). This number has the weapon status (0 or 1) in the str field.
3. Turns the held weapon invisible (when sheathing) or visible (when drawing). Note that weapon settings can prevent this. See the Weapon Settings thread for more info.
4. Sends a chat message out on the weapon status chanel. Has weapon status as message. The sheath usually listens on this channel, and uses this to do it's own visual work.
These functions do not trigger any animations. All that they do, is the internal gruntwork to make the weapon switch between sheathed and drawn. It is adviseable to use them at the precise point in the draw/sheath anim that the weapon is released. For example with a sword, it would be after the sword is fully sheathed, and just before the user lets go and draws their hand away.
............................................
25 Trails Show weapon trails. Argument1 number of trail, or -1 to disable. -2 for color setting, in which case the argument2 is the color. <-1, -1, -1> sets it back to system color, and is auto reverted on event end.
The trails function gives an animset control over the weapon trails.
The first thing it can do, is turn a trail on. the trails are always there, but hidden, by default. This can be used to make a trail visible for one attack. To do this, use the number of the trail you want to activate as Argument1, and no argument2.
Second thing, is turning trails off. There is no function to turn off specific trails, only to turn them all off. To do this, use -1 as argument1, and no argument2
Note that trails will automatically be turned off at the end of each attack. This usage is only needed when you have need to turn a trail on, and then back off, within the same action. For example, a sword combo that slashes once, moves around, then slashes again. you'd want to turn off the trail for the moving around part.
The third and final use, is changing the trail color. There is no function to set the color of individual trails, only to change them all. To do this, use -2 as argument1, and a color vector as argument2. Using <-1, -1, -1> sets it back to system color, and it will automatically revert to system colour at the end of the action.
.............................................
26 Params
This function allows you to execute the native LSL function, llSetLinkPrimitiveParams, through CAS. This tutorial will only cover how this is implemented in CAS, not the entire workings of llSetLinkPrimitiveParams. For info on that, read the lsl wikis:
http://wiki.secondlife.com/wiki/LlSetPrimitiveParamshttp://lslwiki.net/lslwiki/wakka.php?wa ... tiveParamsThe first implementation detail is the targeting. You can either pass a linknumber as argument1 like primparams normally behaves, and all params will be applied to that prim. Or you can put in a name. The core will search the whole object for prims with that name, and apply all parameters to every one that matches. The latter method is more powerful in some cases, but requires the object to be properly setup.
Secondly, the list. You simply need to put down the entire params list you want to use, in the notecard, as the second argument. Remember that lists in CAS must be a CSV with <> around them. There are some important points to note:
-You can't use integer constants like PRIM_SIZE or LINK_SET in a string. Instead, use the integer that they represent. The integer for each param flag can be found on the wiki.
-Remember to trim unecessary extra zeroes from floats and vectors, to reduce the data size.
-Any strings used in this function cannot contain <>
-Prims named with numbers will not work, like "26". Only use numbers for targeting a specific link.
-This is the slowest function in CAS. It can take significant time to apply, and is slowed farther by delays.
The list of params has to be parsed and cast into the appropriate data types. How long this takes will depend on the size of your list. Expect an initial delay of 0.03 seconds per list element.
For each prim that is changing, add another 0.2 seconds, the delay on the primparams functions.
Searching the linkset for named prims will also add it's own overhead.
Argument1: Name or linknumber of target
Argument2: List of params. <> encapsulated CSV.
.............................
27 Message Sends an arbitrary linkmessage. Argument 1 is num, argument2 is <string>|<id> . The components of argument2 MUST be encapsulated in <> and seperated with |
This function sends a linkmessage to the LINK_SET, via llMessageLinked. For more info on that:
https://wiki.secondlife.com/wiki/LlMessageLinkedArgument1 is the Num field.
Argument2 <string>|<id> . The components of argument2 MUST be encapsulated in <> and seperated with |
.........................................................
3x Audio
------------
31 Sound: Plays a sound type. Takes a sound type as argument.
32 Voice: Plays a voice type. Takes a voice type as argument.
Sounds and voices in CAS are organised into types, with each type being assigned a number. For example, 0 is miss sounds, 1 is slashy sounds, and so on.
These commands interact with the random sound system, by taking a type to play as argument1, and playing a sound randomly of that type from all available. The only difference between the two is that 31 plays sounds from the soundset currently loaded, and 32 plays from the current voiceset.
Note that if a set of the appropriate type is not loaded, or if there are no sounds in the specified group, this call will silently fail and the action will continue without any error.
....................
33 Arbitrary: Plays any arbitrary sound. Takes a sound UUID as argument, or a sound name (asset must be in inventory
An alternative method of doing sounds, this one takes a sound UUID as argument1. Or alternatively, you can place the sound aseet inside the weapon system, and then call it by name.
4x Weapon Motion
------------------
41 Spin: Spins the weapon around using llTargetOmega. Argument is spin speed
42 Stop spin: Stops a spinning weapon.
These two functions control weapon spin. Spinning is on a preset axis, you simply specify the spin speed (float) as argument1. For reference, 20 is a good speed. 0 is no spinning. Negative numbers will spin the opposite direction
function 42 when called, will stop spin if the weapon is currently spinning. Spinning will automatically stop at the end of an action.
43 Direction
Calling this function will set the weapon's direction, either in normal, or reverse grip. Call with 0 for normal, 1 for reversed
Will automatically revert back to the animset default. If you want a weapon to always be held in reverse grip, specify it in the animset settings. This function is to be used to set the direction for a single attack only.
5x Misc
----------------
51 Stop:
Immediately ends the current action. If there are any farther commands after a stop command, they will not be executed. No input
It is recommended to use this command to delay the end of your action until the appropriate time, by having it as the last action. Use of this is not necessary to end an action, it will automatically end if it runs out of commands to process.
6x Animation
----------------
61 Play Anim
62 Play Anim (unoptimised)
Perhaps the most important CAS functions of all. A weapon is nothing without animations. This function is the main gateway through which you control them.
Function 61 takes two arguments. The first is the prefix-stripped name of the animation. That is, the name of an anim with the animset name removed from the top. For example, if you are using the animset hyper, and you want to call the animation 'hyper_1_1', you would use just '1_1' as the argument1 for this function. The animset name is automatically added to the start.
This means that animations are required to follow a specific naming convention. They must always be named in the format <animsetname>_<namehere>
The second argument is a boolean value, telling whether or not to record this animation. If 1 is supplied as argument2, the animation will be recorded in a list internally. This allows it to be stopped later, with the next function. The main usage of this is for looped animations, which once started, never stop on their own. Always use Argument2 of 1 with looped anims.
Function 62 is an unoptimised version. When playing an animation with this function, it takes the exact name of the anim. This means no naming convention is needed. Note that 61 is generally better for script memory and should be used where possible. 62 is provided for the occasional case where you want to use an animation which is no-modify and cannot be renamed.
..............................
63 Stop Anim: Stops animations. Argument 1 is a type to stop: 0 = single, 1 = list, 2 = all. Argument2 is an animation name, only relevant if A1 is 0.
This function stops animations. It is only occasionally useful.
It has three modes of operation, which can be used by passing an argument1 of 0, 1, or 2
0: Stop single animation mode. The second argument should be the name or UUID of the animation to stop.
1: Stop listed animation mode. No second argument is needed. This call will stop every animation in the internal anim list, and then clear it. This is only useful if you are making animations add themselves to the list (see function 61). Also note that the anim list is automatically stopped at the end of an action, so only use this if you need them to stop before the end.
2. All animation mode. This call will stop every single animation currently playing on your avatar, including animations from any other object or outside source, and the default linden animations.
-----------------------------------
64 Move Av to:
This CAS function calls the native LSL function, llMoveToTarget, with some supplied parameters. For those not aware, when called from the root prim of a worn attachment, this function will move the avatar. Therefore, this function is designed to move the avatar around to where you want them. This is especially useful for things like running forward during an animation, or leaping into the air.
The first parameter takes an offset vector of where to move to. That is, xyz. Note that the offset you enter will automatically be localised to the avatar's rotation. For reference, the X axis is backwards (negative) and forward (positive). The Y axis is Left (Negative) and right (positive). The Z axis is Down (negative) and Up (positive). So for example if you want the avatar to leap 2m forward, you would use a parameter1 of <2.0,0.,0.>
7x Effects
-----------------------
71 Rez Object: rezzes an object. Argument1 is a string containint "name,offset,rotation,start param". Argument 2 is a list of 2 values, specifing whether the position and rotation are global (or not)
All strings used such as animset names, must not contain any of the following characters:
\,_/|#!<>'"
The above are in use by the system for various parsing, seperating, and commenting purposes. Using them WILL break your animset.
For best results, use only alphanumeric characters a-z, A-Z, 0-9
All Lists such as primparams input should be in csv format and encapsulated with pointed brackets < >