Scripts
Rather complicated one today...
// ifbind -- encase an already-existing keybind in a conditional statement -- by V-Man
alias ifbind [
bind $arg1 (concat [if] $arg2 (concatword "[" (if $arg4 [result (keybind $arg1)] [result $arg3]) "]") (concatword "[" (if $arg4 [result $arg3] [result (keybind $arg1)]) "]"))]
// ifbind (key) (condition) (command) (Use normal keybind if condition is 1 or 0?)
// ifbind C [$ctr] [domodifier 2] 1
// Takes the current bind in key "C" and makes it the "if yes" (1) argument in an encasing "if" statement depending on $ctr (thus, the provided command is executed when $ctr evaluates to 0).
// ifbind V [$connected] [showmenu voicecom] 0
// Takes the current bind in key "V" and makes it the "if not" (0) argument in an encasing "if" statement depending on $connected (thus, the provided command is executed when $connected evaluates to 1).

But it cleans up nicely when I apply it to a concept like this:
add2bind LCTRL [ctr = 1; onrelease [ctr = 0]]
add2bind RCTRL [ctr = 1; onrelease [ctr = 0]]
add2conloop [if (strcmp $conline [ ]) [] [cconline = $conline]]

alias hotkey [ifbind $arg1 [$ctr] $arg2 0]

hotkey C [if $editing [copy] [copyconline = $cconline]]
hotkey V [if $editing [paste] [saycommand (getalias copyconline)]]
hotkey A [if $editing [select 2 2 512 512] []]
hotkey S [if $editing [if (strcmp (curmap) []) [saycommand [/savemap ]] [savemap]] []]
hotkey Z [if $editing [undo] [suicide]]
hotkey F [saycommand [/docfind ]]
hotkey Q [quit]
hotkey P [screenshot]
hotkey O [if $connected [showmenu Gamemode] [showmenu maps]]
// Add more hotkeys as you wish! Any key pressed at the same time as a CTRL button will essentially have a different bind, practically doubling your keyboard space!
Now hotkeys just became a reality! :D
Thanks given by:
(26 Aug 10, 11:35AM)VallDiGna Wrote:
(20 Jun 10, 04:48PM)a_slow_old_man Wrote: 3. Zoom script by stef:
[...]


Above script doesn't work for me (AssaultCube v1.1.0.4),
but I want to write sth similar on my own (it will be my first script)
and I have 2 questions:

1. What is "altaction_4"? (role? why "altaction"? why "4"? :)
2. What is "domodifier 1"? (what is "domodifier" and why "1"? :)
Thanks given by:
I'd link you to the tutorial about it but it seems that site is down. :/

altaction_4 is what "altaction" does when your curweapon is 4 (SMG). By default it contains "quicknadethrow".

"domodifier" changes alias "modifier" to the supplied argument, which in turn causes your mouse wheel (again, by default) to modify "delta_" settings.
For your question, "domodifier 1" sets the modifier to 1, which causes the mouse wheel to modify delta_game_1, delta_spect_1, and delta_edit_1 (depending on whether you're alive, spectating, or editing) +1 or -1 at a time when scrolling. By default, this is activated by holding down 1 while scrolling.
I can't see any default definition for when you're alive or spectating with domodifier 1 (delta_game_1 and delta_spect_1)...
delta_edit_1 changes heightfield vdelta values.
Thanks given by:
(26 Aug 10, 08:33PM)Kirin Wrote: probably you enabled the old sniper script in scripts.cfg, that no longer works,

[...]

now sniper has got this options:

scopesensscale [x] (multiplier for sensitivity when zooming)
autoscopesens [0:1] (when set to 1 the sensitivity of the zoomed sniper will get adjusted to the zoom applied for a perfect sniper feeling, it bypasses scopesensscale, i personally recommend it ON)
setscope [0:1] (when using sniper, setting this to 1 enables the zoom)

there is no more aliases for sniper it's all hardcoded.
if you didnt get what i mean show me your script and i'll try to fix it for you.

EDIT. Remake of the zoom-script, no longer need to wait for bukz :P
//ZoomWheel-Script by Kirin
if (checkalias dscopefov) [] [
dscopefov = $scopefov;
echo (c 0) Zoom Script by (c X) Kirin (c 0) successfully injected!
]
autoscopesens 1
scopefov $dscopefov
alias delta_game_zoomwh [-= scopefov (* 10 $arg1)]
alias altaction_5 [ domodifier zoomwh; scopefov $dscopefov; setscope 1; onrelease [ setscope 0 ] ] // Sniper
works for AC 1.1.0.2 (/me doesnt want to make it for older patches)


Thanks, above script works in AC 1.1.0.4, but it has some disadvantages:

- zooming isn't smooth - scopefov delta should be bigger
for large scopefov values and getting smaller
near scopefov mininimum value

- "autoscopesens" is a little bit crappy - the sensitivity isn't constans
while zooming and generally I prefer to have control over it

So, I still want to write my own scope-zoom-script
and I have some questions about yours -
- ac scripts documentation is very poor.

What is it / what does it do:

delta_game_xxx
altaction_5
domodifier
checkalias xxx - check if there is "xxx" entry in saved.cfg?
[-= scopefov (..)] - is it just [scopefov = scopefov - (..)]?
Thanks given by:
I'll link you then.
altaction Other
Thanks given by:
To make the scoping smooth just make the zooming occur in smaller increments.
Thanks given by:
another way to use while,
//while_ by =SA=macm
//exmp: /while_ [= $x 1] [consoleline = $conline]

addcheck_msa while__
if (checkalias whl) [] [whl = []]

alias while_ [
if (= $numargs 2) [
(concatword "whl" (listlen $whl)) = (concat "(" $arg1 ")"); add2list whl (concatword "whl" (listlen $whl))
(concatword "whl" (listlen $whl)) = (concat "(" $arg2 ")"); add2list whl (concatword "whl" (listlen $whl))
] []
]

alias while__ [
whlp = 0;
loop whloop (listlen $whl) [
tmp_whl = (concat "if" (getalias (at $whl $whlp)) "[ (at $whl (+ $whlp 1))] []");
tmp_whl;
whlp = (+ $whlp 2)
];
sleep 0 [while__]
]

// just in case...
alias reset_while_ [loop a (listlen $whl) [delalias (concatword "whl" $a)]; whl = []]
Thanks given by:
ah! But can it return values in-frame like its sibling idents?
Thanks given by:
(26 Feb 11, 06:43PM)V-Man Wrote: ah! But can it return values in-frame like its sibling idents?

i dont understand, while_ adds a condition to a list, when this condition is true the second argument will be executed,
while_ checks every 0 miliseconds if the conditions in the list are true,
you can add as more as you want,

so if i do: /while_ [alive] [echo "spam"]
it will check every 0 milis, if you are alive spam the console, if not do nothing.

or if dead:
/while_ [!= (alive) 1] [if_conline_has "R.I.P." [] if_not [echo "R.I.P."]]
Thanks given by:
jakson, i dont agree with your "points".

1. just change the fixed delta with a dynamic one.
2. autoscopesens uses trigonometrics to find the exact parameter to scale sensitivity so that it's proportinal to the part of the scene viewed, so if u say that it's crappy it's like your saying that 2+2=22
after this i conclude by saying that when u dont like someone's work, in the OpenSource world you have 4 options:
1. leave it alone.
but if you need it:
2. use it anyway.
3. modify it.
4. make your own version.


""- ac scripts documentation is very poor.""
that is very offensive to the person's that spent hours making it...

jakson i suggest you to study Programming and Mathematics.
Thanks given by:
Gema Script

To use:
/gema (mapnamehere)
when you score your first flag it will say the seconds it took you to do that map.
In addition it will save the high score for that map (in seconds) under (mapname)_g. To view a highscore, you must type
/echo (mapname)_g

Anyways, here's the script itself:

//gema script v1.1 by sblargish
//thanks to bukz for helping saving of highscores
//thanks to v-man for the timer script below
delalias swst
alias stopwatch [
if (strcmp $arg1 "start") [alias swst (millis)] [
if (strcmp $arg1 "time") [if (checkalias swst) [echo (- (millis) $swst)] [stopwatch isn't running!]] [
  if (strcmp $arg1 "clear") [delalias swst] []]]]
//v-man's timer script above

alias gema-on 0
add2conloop [if_conline_has "you scored" [if (= $gema-on 1) [seconds (- (millis) $swst)]]]

alias ghiscore [
echo (c 2)That is a new HIGH SCORE!]

alias gemascores [
  if (checkalias (concatword (curmap 1) _g)) [if (<= $arg1 (getalias (concatword (curmap 1) _g))) [alias (concatword (curmap 1) _g) $arg1 ; ghiscore]] [alias (concatword (curmap 1) _g) $arg1; ghiscore]
]

alias seconds [
blarg = (divf $arg1 1000)
scoresys $blarg]

alias scoresys [
echo (c 2)You finished in (c 1)$arg1 (c 2)seconds on map (c 1)$gmap
stopwatch score
stopwatch clear
gema-on = 0
gemascores]

alias gema [
gema-on = 1
stopwatch clear
ctf $arg1
gmap = $arg1
stopwatch start]
Thanks given by:
Here's a handy little script to format numbers to a given number of decimal digits; for example /echo (format_precision 123.456 1) will output 123.4 - notice that there's no rounding, you can do that on the input yourself eg (+ 123.456 0.05) in this example.

It's subject to floating point accuracy issues so there may well be artifacts that integers don't suffer from: 32-bit floats are roughly enough for 6 digits total, so eg 0.12345 should be fine as well as 123.45, but 12345.67 will start showing error buildup.

Credits to Bukz for the idea and Gibstick \:D

// format input number (int/float) to a given precision
// no sanity checks on inputs, caller's responsibility
// note: format_precision -0.1 0 >>> -0
// arg1: number to convert
// arg2: precision (optional, default 0 == integer)

alias format_precision [

  if (listlen $arg1) [
    // if negative input, flag to prepend sign later if needed
    if (<f $arg1 0) [
      arg1 = (-f 0 ($arg1)); negative = 1
    ] [
      negative = 0
    ]

    divisor   = 1000000000 // max 32-bit int order of magnitude
    magnitude = 9          // 10^9 = divisor
    looping   = 1

    while [ ($looping) ] [
      if (div $arg1 $divisor) [
        // found first non-zero digit, break out
        looping = 0
      ] [
        // next order of magnitude (power of 10)
        divisor = (div $divisor 10)
        -= magnitude 1
        if (< $magnitude 0) [ looping = 0 ]
      ]
    ]

    output = ""
    while [ (>= ($magnitude) 0) ] [
      digit  = (div $arg1 $divisor)
      output = (concatword $output $digit)
      -=f arg1 (* $digit $divisor)

      divisor = (div $divisor 10)
      -= magnitude 1
    ]

    if (strcmp $output "") [ output = "0" ]
    if ($negative) [ output = (concatword - $output) ]

    decimals = ""
    while [ ($arg2) ] [
      *=f arg1 10
      digit    = (div $arg1 1)
      decimals = (concatword $decimals $digit)
      -=f arg1 $digit

      -= arg2 1
    ]

    if (listlen $decimals) [ decimals = (concatword . $decimals) ]
    output = (concatword $output $decimals)
    result $output
  ] [
    // no input, doh
    result ""
  ]
]
Thanks given by:
//made by Kirin (iterative pow algorithm, exponents are forced into integers)
alias pow [
alias pow_exp $arg2
alias pow_base $arg1
if (= $pow_exp 0) [result 1] [
if (< $pow_exp 0) [*= pow_exp -1] []
-= pow_exp 1
loop i $pow_exp [*=f pow_base $arg1]
if (> $arg2 0) [result $pow_base] [result (divf 1 $pow_base)]
]
]
//[Kirin] format float/int to a precision eg.  echo (formatprec 123,456 2)  :outputs:  123,45
alias formatprec [
fp_number = $arg1
fp_mag = (pow 10 $arg2)
*=f fp_number $fp_mag
-= fp_number 0
fp_number = (divf $fp_number $fp_mag)
result $fp_number
]

this is a much more compact solution, plus it gives a free pow function :D

(if u are using V-Man's tools u can remove the pow alias, cause V-Man has already integrated it)
Thanks given by:
* V-Man instates new tradition:
When you make a new script, bring it hither so that Kirin can test your humility!
Thanks given by:
i'm not sure i got the deeper meaning of that phrase xD (that's the inconvenience of not being english, or prepared in english)
hope it's something good
Thanks given by:
Updated my gema script for a bug that it took the slowest score instead of the fastest :|
also added color to the messages.
here it is: _gema_
Thanks given by:
Kirin's version doesn't enforce formatting on integers, eg /echo (formatprec 123 2) results in "123.0", not "123.00"
Thanks given by:
// bloop -- A backward loop -- by V-Man
alias bloop [loop $arg1 $arg2 [$arg1 = (- (+ (* (getalias $arg1) -1) $arg2) 1); arg3]]
// bloop i 11 [echo $i]
// 10 9 8 7 6 5 4 3 2 1 0
and
alias concatlist [
tmp_cnclist = []
loop cncl (listlen $arg1) [tmp_cnclist = (concatword $tmp_cnclist (at $arg1 $cncl))]
result $tmp_cnclist
]
// echo (concatlist [V - M a n])

as seen in this little thang:

alias convhex [
if (isnumber $arg1) [
if (|| (> $arg1 16777215) (< $arg1 0)) [echo (c 3)Valid range for convhex is 0..16777215] [
tmp_number = $arg1
tmp_number1 = $arg1
bloop hxd 7 [if (< $tmp_number (pow 16 $hxd)) [tmp_hxdgs = $hxd] []]
tmp_hex = [0x pl0 pl1 pl2 pl3 pl4 pl5]
loop hxd (- 6 $tmp_hxdgs) [tmp_hex = (replacestr $tmp_hex (concatword pl $hxd) 0)]
loop hx $tmp_hxdgs [
  tmp_hex = (replacestr $tmp_hex (concatword pl (+ $hx (- 6 $tmp_hxdgs))) (if (< (div $tmp_number (pow 16 (+ (* (+ $hx (- 6 $tmp_hxdgs)) -1) 5))) 10) [
   result (div $tmp_number (pow 16 (+ (* (+ $hx (- 6 $tmp_hxdgs)) -1) 5)))] [
   result (at [A B C D E F] (- (div $tmp_number (pow 16 (+ (* (+ $hx (- 6 $tmp_hxdgs)) -1) 5))) 10))]))
  tmphex = $tmp_hex
  loop rpl 6 [tmphex = (replacestr $tmphex (concatword pl $rpl) 0)]
  tmphex = (concatlist $tmphex)
  tmp_number = (- $tmp_number1 $tmphex)]
tmp_hex = (concatlist $tmp_hex)
result $tmp_hex]] [result (+ $arg1)]]
// echo (convhex 1337)
Thanks given by:
(03 Mar 11, 12:07AM)GeneralDisarray Wrote: Kirin's version doesn't enforce formatting on integers, eg /echo (formatprec 123 2) results in "123.0", not "123.00"
so i guess we just had different objectives, my objective was writing something shorter and faster and that brings the number to the precision wanted ;)
Thanks given by:
(26 Feb 11, 07:32PM)macm Wrote:
(26 Feb 11, 06:43PM)V-Man Wrote: ah! But can it return values in-frame like its sibling idents?

i dont understand, while_ adds a condition to a list, when this condition is true the second argument will be executed,
while_ checks every 0 miliseconds if the conditions in the list are true,
you can add as more as you want,

so if i do: /while_ [alive] [echo "spam"]
it will check every 0 milis, if you are alive spam the console, if not do nothing.

or if dead:
/while_ [!= (alive) 1] [if_conline_has "R.I.P." [] if_not [echo "R.I.P."]]
OK, finally got some time to illustrate:
Ideally, this
alias test [
whileresult = 0
tmp_while = 10
while_ [$tmp_while] [
+= whileresult 1
-= tmp_while 1]
result $whileresult]
would return the same result as this:
alias test [
whileresult = 0
tmp_while = 10
while [$tmp_while] [
+= whileresult 1
-= tmp_while 1]
result $whileresult]
But it doesn't.
When you can snatch this pebble from my hand figure out why and fix it, I'll be profoundly impressed.
Thanks given by:
nvm
Thanks given by:
Ok. Maybe i should have done more testing before postin while_,
the while command does not have sleep in it!
while_ has sleep 0, i think this was the only to do it,

i wrote this in so many ways that in the end i forgot to change a line,
this is the fixed one (no brackets for $arg2):

//while_ by =SA=macm
//exmp: /while_ [= $x 1] [consoleline = $conline]

addcheck_msa while__
if (checkalias whl) [] [whl = []]


alias while_ [
if (= $numargs 2) [
(concatword "whl" (listlen $whl)) = (concat "(" $arg1 ")"); add2list whl (concatword "whl" (listlen $whl))
(concatword "whl" (listlen $whl)) = (concat $arg2); add2list whl (concatword "whl" (listlen $whl))
] []
]

alias while__ [
whlp = 0;
loop whloop (listlen $whl) [
tmp_whl = (concat "if" (getalias (at $whl $whlp)) "[ (at $whl (+ $whlp 1))] []");
tmp_whl;
whlp = (+ $whlp 2)
];
sleep 0 [while__]
]



// just in case...
alias reset_while_ [loop a (listlen $whl) [delalias (concatword "whl" $a)]; whl = []]


so in "test", while_ will be executed atleast 0 millis after,
"test" will return immideatly!
this would only work in this way:
alias test [
whileresult = 0
tmp_while = 10
while_ [$tmp_while] [
+= whileresult 1
-= tmp_while 1]
sleep 200 [echo $whileresult]]

while_ is anything but perfect, sleep delays everything, it is a FAIL.
Anyways, i have some use for it, just thought it could be usefull to somebody and decided to share.
Thanks given by:
You're right, it will be useful for some things. I just wanted to be clear on which things. ;-)
Thanks given by:
My document wont save.... do i not have authority?
Thanks given by:
(01 Jul 10, 06:48PM)V-Man Wrote: Heck, I probably ought to list my Akimbo posts.

Christmas Skins - CLA Santas and RVSF elves!
SkinSwitch - A disgustingly bulky and ugly way to swap out weapon model mods.
Assault Your Ears - A makeshift music player for AssaultCube.
Assault Your Ears barebones - The music player, without the songs I included.
AssaultCube Parental Controls - Allows a Windows administrator to block the use of AssaultCube.
V-Time (Time Script) - Notifies you of the time and how long you've been playing.
Rewind - Allows you to go back a certain amount of time in a demo, or skip to a specific Minutes Remaining mark.
Quote generator - Randomly selects a quote to display at each intermission.
Friends - Searches for multiple names or tags in the Server Browser.
RapidFire - Script used to capture screenshots in bursts for animations!
Rave - Changes light levels and fog colors to simulate a rave atmosphere!
Smooth Zoom - Zooms your FOV over time for a smooth effect (based on work by Gibstick and Kirin)
Server Browser Wrapper - Uses menus to make alternate connection options easier
Animated XHair - Simulates an animated crosshair!
FPS Booster - A menu intended to optimize your FPS. No guarantees!
pauseconline - Skips a console line each time a new one comes up, "pausing" the text console
tools.cfg - A consolidation of all the metascripting tools I've made. Will be updated as new tools are made.
My Personal Ladder v1.0 - Keeps track of stats!
Flag Countdown - Detects when the flag is dropped or lost and begins a 30-second countdown!
Sendalias - Share a script over in-game chat
Remote Control - Share your command prompt with another player.
Random Terrain/Map Generator - Starts a new map and randomly edits the terrain!
Heightfield Randomizer - Randomly edits a specified heightfield range
Nade Timer - A countdown timer displays for nade-cooking!
Menu Maker - A menu that can make OTHER MENUS!

None of them work for me <:o
I really wanted to try them. . . but it comes up with some foreign language site. . .
Thanks given by:
(05 Mar 11, 04:25AM)Mikey Wrote: None of them work for me <:o
I really wanted to try them. . . but it comes up with some foreign language site. . .

The Akimbo host is demanding payment D:
Thanks given by:
What the hell with Akimbo?! This is like the 754th time this happens, someone fix it!
Thanks given by:
I think an accuracy script was one of the big ones on the list, I think this will do for now. :D

http://pastebin.com/pHJhQ8Lj

Suggestions on how to make it more efficient welcomed.

Edit: Running into some problems with this after some further testing, will provide more details soon.

Double edit: FIXED + link updated thanks to the help of B}Ronald_Reagan <333
Thanks given by:
<3333
Thanks given by:
// curaccuracy by Bukz (little mod of kirin)
// curaccuracy - Returns the given client's current accuracy for a given weapon. Does NOT work with bots or with nades. :(
//               /echo (curaccuracy (findcn $curname) 5) - Returns your current sniper rifle accuracy.
alias valid_weapons [0 1 2 3 4 5 6 9]
alias weapons_dmg [50 18 60 105 15 80 24 " " " " 18]
alias curaccuracy [
  if $connected [
    alias weap_atk 0
    alias weap_dmg 0
    alias landed 0
    if (! (strstr $valid_weapons $arg2)) [result -1] [
      if (strcmp (findpn $arg1) "") [result -1] [
        alias weap_atk (at (pstat_weap $arg1) (* $arg2 2))
        alias weap_dmg (at (pstat_weap $arg1) (+ (* $arg2 2) 1))
        alias landed (div $weap_dmg (at $weapons_dmg $arg2))
        result (*f (divf $landed $weap_atk) 100.00)
      ]
    ]
  ] [result -1]
]
docsection [Accuracy];
docident [curaccuracy] [Returns a given clients current accuracy with a given weapon.];
docargument [c] [A valid client number.];
docargument [w] [A valid weapon number.];
docargument [Does not work offline with bots or with grenades. Will return -1 if you try to use an invalid client or weapon number, or if executed while not connected to a server.];
i didnt try it but i'm positive it works ;)
Thanks given by: