Urban Terror 4.1

Ultimate Guide to Configuration and Scripting

Round 6: Advanced Scripting & Toggles

Table of Contents:

 

 

Now that you have mastered the simple binding, lets look at the more advanced stuff: Scripting and Toggles. Before you start to drule, too much, Scripting and toggles are very limited in what they can do for you. They cannot make you a better player, they cannot make your Negev fire faster and be more accurate. They can help you in common tasks, to get them done better and sometimes faster than using multiple key commands. (Depending on your abilities I suppose)

How to "Set" Functions (thanks nexu)

You have the ability to create a variable with a given name and associate that with a series of instructions. You can use any of the set commands to do this:

set <name> "action; action; action;"

Every time you call the function <name> it will perform the series of action you define.  They can be game actions, variable declarations, or anything you can do from the console.  I loosely call this a "function" because in programming if you have a portion of code that you can call to perform an action or series of actions that is what it is called.  (Urban Terror might call it something else...)

set shoot_twice “+attack; - attack; +attack; -attack;”

This is a “function” (in a very loose sense) that when called will fire your weapon twice. (if flood protection is not turned on of course... ) then to call it you would use the following:

 

vstr

This command allows you to call a user defined variable to perform an action.  I do not know what it stands for, or why it is called vstr.  (Any Input?) To continue the example from above:

bind n “vstr shoot_twice”

Then you every time you pressed the “n” key you would “attack” twice.

 

Wait!

There is a command that tells the console to wait to execute commands to keep things from getting jammed up.  The "wait" command.  The syntax is:

wait #

This tell the console to wait # number of frames before performing the next command in sequence.  There is a drawback to this.  While the console is "waiting" you temporarily lose control of the character. Because your character is "waiting" like you told them too. Normally this is fractions of a second, however if you make the number too large you can be stuck for a while.

 

Toggle!


Why would you want to do this... well you can make some interesting toggles this way for example, I wrote a toggle that makes it so I don't have to hold the crouch key down to stay crouched... it goes like this:

//========== Crouch Toggle ============= by Matthew Craig <taggedzi>
set sit "+movedown;wait 15;ut_echo Crouch Stat: CROUCHED; set crouch vstr stand"
set stand "-movedown;wait 15;ut_echo Crouch Stat: STANDING;set crouch vstr sit"
set crouch "vstr sit"
bind v “vstr crouch”


Let's break this down:


1.When I press “v” it calls “crouch”.
2.“crouch” then calls the function “sit”.
3.“sit” makes my player crouch down (+movedown), and reports on my screen that I'm crouched. Then it says that “crouch” is now equal to “stand”.
4.So the next time I press “v” it calls “crouch”,
5.“crouch” calls “stand”,
6.“stand” tells my character to stand up (-movedown) and reports to the screen that I'm now standing, and sets “crouch” equal to “sit” again starting the process all over again.

It takes a minute to get the logic here for some people, but it works, and does well. This can be expanded to as many items as you want each one with multiple or single commands. Why would I set the value of the cvar if there is a toggle function available in UrT? Personal preference, you could toggle just as easy, I prefer to set the var so I can more easily echo what just happened. (it sucks when you press a random key on the keyboard while playing and have no idea why happened to your character.)

One Example of a longer script which might make more sense is a taunt script I wrote:

//========== Script =============== by <taggedzi>
set taunt_00 "say I taunt you once! ;set taunt vstr taunt_01"
set taunt_01 "say Twice!; set taunt vstr taunt_02"
set taunt_02 "say I taunt you again!; set taunt vstr taunt_03"
set taunt_03 "say You cannot stop my taunt!;set taunt vstr taunt_04"
set taunt_04 "say You silly English knights!; set taunt vstr taunt_05"
set taunt_05 "say Now go away or I shall taunt you again!;set taunt vstr taunt_00"
set taunt "vstr taunt_00"


With this script every time I call the “taunt” command it will call the next taunt and display it on the screen for all to see. When it gets to the end it starts over again. You can add more by following the sequence. One of they key points here... notice the last actual taunt sets “taunt” equal to “taunt_00”. This makes it start over again. Side note: You can use colors here, however... some servers disable this, so it they don't work it is probably a setting from the server you are playing on.

Here is a more complicated two way script. It allows you to turn the volume for the game up and down with keybinds.

//========== Volume Toggle ============= by <taggedzi>
set s_volumemute "s_volume 0.000; wait 15; ut_echo "audio volume: ^5[^9---------^5]";set set_volume_plus "vstr s_volumelowest"; set set_volume_minus “vstr s_volumemute”;"
set s_volumelowest "s_volume 0.100; wait 15; ut_echo "audio volume: ^5[^6|^9--------^5]";set set_volume_plus "vstr s_volumelow"; set set_volume_minus “vstr s_volumemute”;"
set s_volumelow "s_volume 0.350; wait 15; ut_echo "audio volume: ^5[^6|||^9------^5]";set set_volume_plus "vstr s_volumemed"; wait 15; set set_volume_minus “vstr s_volumelowest”;"
set s_volumemed "s_volume 0.620; wait 15; ut_echo "audio volume: ^5[^6||||||^9---^5]";set set_volume_plus "vstr s_volumehigh"; set set_volume_minus “vstr s_volumelow”;"
set s_volumehigh "s_volume 1.000; wait 15; ut_echo "audio volume: ^5[^6|||||||||^5]";set set_volume_plus "vstr s_volumehigh"; set set_volume_minus “vstr s_volumemed”;"
set set_volume_plus "vstr s_volumemute";
set set_volume_minus "vstr s_volumemute";
bind KP_MINUS "vstr set_volume_minus"
bind KP_PLUS "vstr set_volume_plus"


You will notice there are two vstr statements per entry. One for each bind I want set for my volume. You may also notice that my bind is to KP_MINUS (this is the plus key on the number pad), and the KP_MINUS (the minus sign on the number pad). For a complete list of keys “codes” please look in round 1.

You can make more or less complicated scripts depending on your needs or preferences. I have seen scripts that make the pistols automatic weapons (fire the gun faster than you can click).

Animations and Timing

Ok, so now you have the idea to get things done better and faster. Your character can only do one thing at a time, that time is very fast...but you must finish one thing before you do another. For example, I tried to write a script that zoomed in with the sniper scope, and when I clicked the attack button switched weapons to a pistol and shot... while yes you can do this... you have to wait for the animation to end for the switching weapons before you can fire. So if you did the following, it would not work:

bind x “+ut_weaponnext; +attack; -attack;”


The reason is the console runs through the commands too fast for your character animations. The console issues the attack command before you are holding the new weapon. So you need to add “wait” commands to properly time your commands. Remember it takes real time for you character to do something, make sure you give it to them because the console won't. This might work better:

bind x “+ut_weaponnext; wait 450; +attack; -attack;”

 

Really Advanced Stuff

After my first revision of this a player contacted me asking for a special script, allowing him to zoom in twice, pause for just a fraction of a second, then automatically fire the weapon, and unscope. I created just such a script, but discovered that the fire was “random” it never lined up with the scopes cross hairs. (behaving the same as a no-scope shot with a sniper riffle) I believe (I cannot prove this), that the game designers wanted to prevent this kind of scripting, because after 5 attempts I could not get it to am properly. Then I discovered the trick, it requires 2 key bindings. You cannot have a zoomin and a attack executed within a single bind execution. (I have just given you the key to solve this... as I did... but I won't tell this one out right.
Update, You can change bindings on the fly for example:

 

//========== Zoom_Drop Toggle ============= by <taggedzi>
set mouse2_zoom_in "bind MOUSE2 ut_zoomin; wait 15; ut_echo MOUSE2 Status: ^6Zoom IN; set mouse2 vstr mouse2_zoom_drop"
set mouse2_zoom_drop "bind MOUSE2 ut_weapdrop; wait 15; ut_echo MOUSE2 Status: ^6Drop Weapon;set mouse2 mouse2_zoom_in"
set mouse2 "vstr mouse2_zoom_in" //set default
bind KP_ENTER “vster mouse2”


Ok... seems a bit odd at first but here is how it works. I found this really useful in panic situations.
Normally MOUSE2 is zoomin for weapons with scope. I hardly ever use weapons with scopes unless I'm bored. So, I made a script to be able to use MOUSE2 as drop current weapon, or zoom depending on my preference. So when I have a weapon with zoom I still can, but If not I can drop my weapon quickly and move to the next one... (handy when you run out of ammo and need to switch fast...)

So: KP_ENTER toggles what MOUSE2 does. Try it and see.

 

Table of Contents:

 


This file was last updated: "November 15, 2009, 12:03 am"