The Achievements Script - v1.0 stable
#1
[Image: achh.jpg]



UPDATE:

Version 1.0 stable has been publically released here: http://forum.cubers.net/thread-2277-post...l#pid46287
- The original script remains below for historical purposes.



For the past week or so I've been putting a lot of time into creating an achievements system in AssaultCube using only CubeScript. Therefore by nature it's slightly cludgy and has a few drawbacks ;), but I don't think that will stop anyone from having a bit of fun with it. I had a few ideals that I wanted to adhere to when making the script:
  • It should encourage the use of all the different weapons, as well as encourage the playing of multiple game modes.
  • It should be tough enough to provide a decent amount of gameplay time before being able to level up/complete the script.
  • It should be easy enough to be beaten by everyone, newbies and "pros" alike within a reasonable timeframe, to avoid drawing redundant gameplay out.
  • It should be simple, light and efficient (as far as CubeScript will allow).

I wasn't able to do everything I wanted to because of the last bit, therefore things like CTF/HTF/KTF/KTKF flags are all the same in the script's eyes. Adding that would add a rather large amount of lines to the script and there *is* a lot going on already! However, I do plan on continuing development of this script to add as much as feasibly possible, feature-wise - to it without breaking your client! But that'll only be in future versions assuming the tests go well.

As it sits, there are 15 achievements that you must unlock before you can move onto the next, higher, harder level. There is a 16th, "secret" achievement that is unlockable after a certain period of time. ;)

There are 3 levels, the first being the easiest (EASY), second being the norm (INTERMEDIATE), and the third being the hardest (HARD). In order to move onto the next difficulty EVERY achievement on that difficulty level must be unlocked. So you can't earn a higher level achievement without having gotten all of the lower ones first (encouraging gameplay). Once you have unlocked all of the achievements (15 total for each level) including the level 3's (HARD) achievements, you will see a message telling you that you beat the script, and a total number of enemies killed count since you first started working towards earning all the achievements. To replay the script (if you're trying to unlock/discover the secret achivement, replaying it *is* necessary) simply type:

/reset_achievements

...restarting AC will also do the trick. To view your progress there is the "My Achievements" menu. To bind this menu to a key you MUST edit line 346 of the script. Change "KEY" to a valid key from keymap.cfg. For instance:

bind RALT [showmenu "My Achievements"] // Binds the right ALT key to show the menu
...or....
bind M [showmenu "My Achievements"] // Binds the M key to show the menu

If you don't do this you'll see an 'unknown key "KEY"' error when starting AC. The only end user idents (commands) for the script are:
/reset_achievements - Resets your achievement progress.
/reset_all_achievements - Resets EVERYTHING, script completions counter, secret achievement progress, etc.
/show_killstreak_switch - Enables or disables the showing of killstreak messages upon every kill you get.

Questions, comments, feedback, etc. of any kind is very welcome! Please abide by the attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) license when modifying and/or redistributing.

Last but not least, the script:

// achievements.cfg by DES|Bukz - version 1.0 beta - Last Update: February 10th, 2011
// An attempt to add an achievements system in AssaultCube via strictly CubeScript. Requires,
// tools.cfg, and saved.cfg to be writable for progress to be stored/saved between sessions.
// Includes a simple leveling system to make the achievements harder to obtain over-time.

// This script is licensed under the attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) license:

// http://creativecommons.org/licenses/by-nc-sa/3.0/

if (checkalias cur_achievement_level) [] [alias cur_achievement_level 1]
if (checkalias show_killstreak_switch) [] [alias show_killstreak_switch 0]

// Create alias lists for various loops throughout the script.
alias achievement_aliases_2 [fragged_achievement_stat gibbed_achievement_stat slashed_achievement_stat headshot_achievement_stat splattered_achievement_stat killstreak_achievement_stat akimbo_achievement_stat]
alias achievement_aliases_3 [gave_fragged_ gave_gibbed_ gave_slashed_ gave_headshot_ gave_splattered_]
alias achievement_aliases_4 [gave_ratio_ gave_flag_ gave_killstreak_ gave_akimbo_ gave_assault_ gave_sub_ gave_sniper_ gave_carbine_ gave_shotgun_ gave_usp_]
alias achievement_aliases_5 [assault_achievement_stat sub_achievement_stat sniper_achievement_stat carbine_achievement_stat shotgun_achievement_stat usp_achievement_stat kills_achievement_stat]
alias achievement_acts [fragged gibbed slashed headshot splattered]
alias other_achievements_list [ratio flag killstreak akimbo assault sub sniper carbine shotgun usp]

// The various achievement goal lists/tables.

// Frags, gibs, knives, headshots, splatters.
//                              [f g k h s]
alias level_1_achievements_list [3 2 2 2 3]
alias level_2_achievements_list [5 4 4 4 5]
alias level_3_achievements_list [8 6 6 6 8]

// Ratio, flags, killstreak, duals (akimbo), assault rifle, sub machine gun, precision (sniper), carbine, noob cannon (shotgun), usp (pistol).
//                        [ r  f k d  a  s  p  c  n  u]
alias level_1_others_list [3.0 2 2 3 20 20 15 15 15 10]
alias level_2_others_list [5.0 4 4 6 50 50 30 30 30 20]
alias level_3_others_list [8.0 6 6 9 80 80 60 60 60 40]
//                                   OT OT OT OT OT OT

// make_achievement_aliases - Creates various aliases used by the script only if they do not already exist.
alias make_achievement_aliases [
  loop tmp_ach_loop 5 [
    loop tmp_ach_loop_2 3 [
      if (checkalias (format "%1%2" (at $achievement_aliases_3 $tmp_ach_loop) (+ $tmp_ach_loop_2 1))) [] [
        alias (format "%1%2" (at $achievement_aliases_3 $tmp_ach_loop) (+ $tmp_ach_loop_2 1)) 0
      ]
    ]
  ]
  loop tmp_ach_loop_3 (listlen $achievement_aliases_4) [
    loop tmp_ach_loop_4 3 [
      if (checkalias (format %1%2 (at $achievement_aliases_4 $tmp_ach_loop_3) (+ $tmp_ach_loop_4 1))) [] [
        alias (format "%1%2" (at $achievement_aliases_4 $tmp_ach_loop_3) (+ $tmp_ach_loop_4 1)) 0
      ]
    ]
  ]
  loop tmp_ach_loop_5 (listlen $achievement_aliases_5) [
    if (checkalias (at $achievement_aliases_5 $tmp_ach_loop_5)) [] [
      alias (at $achievement_aliases_5 $tmp_ach_loop_5) 0
    ]
  ]
  loop tmp_ach_loop_6 5 [
    if (checkalias (format "cur_%1_level" (at $achievement_acts $tmp_ach_loop_6)) (at (getalias (format "level_%1_achievements_list" $cur_achievement_level)) $tmp_ach_loop_6)) [] [
      alias (format "cur_%1_level" (at $achievement_acts $tmp_ach_loop_6)) (at (getalias (format "level_%1_achievements_list" $cur_achievement_level)) $tmp_ach_loop_6)
    ]
  ]
  loop tmp_ach_loop_7 (listlen $other_achievements_list) [
    if (checkalias (format "cur_%1_level" (at $other_achievements_list $tmp_ach_loop_7)) (at (getalias (format "level_%1_others_list" $cur_achievement_level)) $tmp_ach_loop_7)) [] [
    alias (format "cur_%1_level" (at $other_achievements_list $tmp_ach_loop_7)) (at (getalias (format "level_%1_others_list" $cur_achievement_level)) $tmp_ach_loop_7)
    ]
  ]
  if (checkalias achievements_counter) [] [alias achievements_counter 0]
  if (checkalias gave_achievements_comp) [] [alias gave_achievements_comp 0]
  if (checkalias gave_pwned_bukz) [] [alias gave_pwned_bukz 0]
]

// reset_achievement_stats - Reset conline stat holders.
alias reset_achievement_stats [
  loop tmp_ach_loop (listlen $achievement_aliases_2) [
    alias (at $achievement_aliases_2 $tmp_ach_loop) 0
  ]
]

// reset_achievements - Reset all achievements progress.
alias reset_achievements [
  reset_achievement_stats
  alias cur_achievement_level 1
  alias gave_achievements_comp 0
  loop tmp_ach_loop 5 [
    loop tmp_ach_loop_2 3 [
      alias (format "%1%2" (at $achievement_aliases_3 $tmp_ach_loop) (+ $tmp_ach_loop_2 1)) 0
    ]
  ]
  loop tmp_ach_loop_3 (listlen $achievement_aliases_4) [
    loop tmp_ach_loop_4 3 [
      alias (format "%1%2" (at $achievement_aliases_4 $tmp_ach_loop_3) (+ $tmp_ach_loop_4 1)) 0
    ]
  ]
  loop tmp_ach_loop_5 (listlen $achievement_aliases_5) [
    alias (at $achievement_aliases_5 $tmp_ach_loop_5) 0
  ]
  set_achievement_levels
]

// reset_all_achievements - Resets everything, including secret achievement progress and script completions counter.
alias reset_all_achievements [
  alias achievements_counter 0
  alias gave_pwned_bukz 0
  reset_achievement_stats
  reset_achievements
]

// set_achievement_levels - Checks all achievements and sets the proper current level's goals.
alias set_achievement_levels [
  loop tmp_ach_loop 5 [
    alias (format "cur_%1_level" (at $achievement_acts $tmp_ach_loop)) (at (getalias (format "level_%1_achievements_list" $cur_achievement_level)) $tmp_ach_loop)
  ]
  loop tmp_ach_loop_2 (listlen $other_achievements_list) [
    alias (format "cur_%1_level" (at $other_achievements_list $tmp_ach_loop_2)) (at (getalias (format "level_%1_others_list" $cur_achievement_level)) $tmp_ach_loop_2)
  ]
]

// Execute script core aliases on every run.
make_achievement_aliases
reset_achievement_stats
set_achievement_levels

// get_achievement_stats - Collect stats from conline.
alias get_achievement_stats [
  if $connected [
    if (< $cur_achievement_level 4) [
      loop tmp_ach_loop 5 [
        if_conline_has (format "you %1" (at $achievement_acts $tmp_ach_loop)) but_not "teammate" [
          if (strcmp (at $achievement_acts $tmp_ach_loop) fragged) [
            if (= (curweapon) 1) [+= usp_achievement_stat 1] []
            if (= (curweapon) 2) [+= carbine_achievement_stat 1] []
            if (= (curweapon) 3) [+= shotgun_achievement_stat 1] []
            if (= (curweapon) 4) [+= sub_achievement_stat 1] []
            if (= (curweapon) 5) [+= sniper_achievement_stat 1] []
            if (= (curweapon) 6) [+= assault_achievement_stat 1] []
            if (= (curweapon) 9) [+= akimbo_achievement_stat 1] []
          ] []
          if (strcmp (at $achievement_acts $tmp_ach_loop) slashed) [] [alias slashed_achievement_stat 0]
          if (strcmp (at $achievement_acts $tmp_ach_loop) headshot) [+= sniper_achievement_stat 1] []
          if (strcmp (at $achievement_acts $tmp_ach_loop) splattered) [+= shotgun_achievement_stat 1] []
          += (format "%1_achievement_stat" (at $achievement_acts $tmp_ach_loop)) 1
          += killstreak_achievement_stat 1
          if $show_killstreak_switch [echo (c 3)Killstreak (c 0) $killstreak_achievement_stat] []
          += kills_achievement_stat 1
        ] []
      ]
      if (alive) [] [
        alias fragged_achievement_stat 0
        alias gibbed_achievement_stat 0
        alias headshot_achievement_stat 0
        alias splattered_achievement_stat 0
        alias killstreak_achievement_stat 0
        alias akimbo_achievement_stat 0
      ]
    ] []
  ] []
]

// check_achievement_stats - Analyzes the stats that get_achievement_stats collects and awards the client with the
//                           proper achievement if it has been unlocked.
alias check_achievement_stats [
  if $connected [
    if (< $cur_achievement_level 4) [
      loop tmp_ach_loop 5 [
        if (&& (>= (getalias (format "%1_achievement_stat" (at $achievement_acts $tmp_ach_loop))) (getalias (format "cur_%1_level" (at $achievement_acts $tmp_ach_loop)))) (= (getalias (format "gave_%1_%2" (at $achievement_acts $tmp_ach_loop) $cur_achievement_level)) 0)) [
          alias (format "gave_%1_%2" (at $achievement_acts $tmp_ach_loop) $cur_achievement_level) 1
          give_achievement (at $achievement_acts $tmp_ach_loop)
        ] []
      ]
      if (&& (>= (curratio (findcn $curname)) $cur_ratio_level) (= (getalias (format "gave_ratio_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_ratio_%1" $cur_achievement_level) 1
        give_achievement ratio
      ] []
      if (&& (>= (at (pstat_score (findcn $curname)) 0) $cur_flag_level) (= (getalias (format "gave_flag_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_flag_%1" $cur_achievement_level) 1
        give_achievement flag
      ] []
      if (&& (>= $killstreak_achievement_stat $cur_killstreak_level) (= (getalias (format "gave_killstreak_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_killstreak_%1" $cur_achievement_level) 1
        give_achievement killstreak
      ] []
      if (&& (>= $akimbo_achievement_stat $cur_akimbo_level) (= (getalias (format "gave_akimbo_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_akimbo_%1" $cur_achievement_level) 1
        give_achievement akimbo
      ] []
      if (&& (>= $assault_achievement_stat $cur_assault_level) (= (getalias (format "gave_assault_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_assault_%1" $cur_achievement_level) 1
        give_achievement assault
        alias assault_achievement_stat 0
      ] []
      if (&& (>= $sub_achievement_stat $cur_sub_level) (= (getalias (format "gave_sub_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_sub_%1" $cur_achievement_level) 1
        give_achievement sub
        alias sub_achievement_stat 0
      ] []
      if (&& (>= $sniper_achievement_stat $cur_sniper_level) (= (getalias (format "gave_sniper_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_sniper_%1" $cur_achievement_level) 1
        give_achievement sniper
        alias sniper_achievement_stat 0
      ] []
      if (&& (>= $carbine_achievement_stat $cur_carbine_level) (= (getalias (format "gave_carbine_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_carbine_%1" $cur_achievement_level) 1
        give_achievement carbine
        alias carbine_achievement_stat 0
      ] []
      if (&& (>= $shotgun_achievement_stat $cur_shotgun_level) (= (getalias (format "gave_shotgun_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_shotgun_%1" $cur_achievement_level) 1
        give_achievement shotgun
        alias shotgun_achievement_stat 0
      ] []
      if (&& (>= $usp_achievement_stat $cur_usp_level) (= (getalias (format "gave_usp_%1" $cur_achievement_level)) 0)) [
        alias (format "gave_usp_%1" $cur_achievement_level) 1
        give_achievement usp
        alias usp_achievement_stat 0
      ] []
    ] []
  ] []
]

// check_achievement_levels - Checks all achievements to see if all the current level's achievments have been
//                            been unlocked, if so, bumps the client up to the next level and updates the goals.
//                            Also serves as end script message for when the client finishes all the achievements.
alias check_achievement_levels [
  if $connected [
    if (< $cur_achievement_level 5) [
      alias have_achievement_counter 0
      loop tmp_ach_loop 5 [
        if (= (getalias (format "gave_%1_%2" (at $achievement_acts $tmp_ach_loop) $cur_achievement_level)) 1) [+= have_achievement_counter 1] []
      ]
      loop tmp_ach_loop_2 (listlen $other_achievements_list) [
        if (= (getalias (format "gave_%1_%2" (at $other_achievements_list $tmp_ach_loop_2) $cur_achievement_level)) 1) [+= have_achievement_counter 1] []
      ]
      if (= $have_achievement_counter 15) [
        += cur_achievement_level 1
        if (&& (= $cur_achievement_level 4) (= $gave_achievements_comp 0)) [
          alias gave_achievements_comp 1
          += achievements_counter 1
          if (&& (>= $achievements_counter 3) (= $gave_pwned_bukz 0)) [
            alias gave_pwned_bukz 1
            echo (c 3)You unlocked secret achievement (c 1)Pwn Bukz! (c 2)Beat the achievements script (c 5)3 (c 2)or more times! (c 0)GG!
          ] []
          echo (c 3) $kills_achievement_stat (c 2)noobs were killed during the making of this film. (c 5)";)"
          echo (c 0)You completed the achievements script! (c 2)Use (c 5)/reset_achievements (c 2)to start over!
        ] [
          if (< $cur_achievement_level 4) [
            echo "   " (c 0)*** (c 1)LEVEL UP (c 0)***
            if (= $cur_achievement_level 2) [echo New difficulty: (c 2)INTERMEDIATE] [if (= $cur_achievement_level 3) [echo New difficulty: (c 3)HARD] []]
            set_achievement_levels
          ] []
        ]
      ] []
    ] []
  ] []
]

// give_achievement - Prints pretty stuff on the console for the client when an achievement is unlocked.
alias give_achievement [
  if (< $cur_achievement_level 4) [
    if (strcmp $arg1 fragged) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Unstoppable! (c 2)Get (c 5) $cur_fragged_level (c 2)frags without dying!] []
    if (strcmp $arg1 gibbed) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Grenadier! (c 2)Get (c 5) $cur_gibbed_level (c 2)grenade gibs without dying!] []
    if (strcmp $arg1 slashed) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Knife Specialist! (c 2)Get (c 5) $cur_slashed_level (c 2)consecutive knife gibs!] []
    if (strcmp $arg1 headshot) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Sharp Shooter! (c 2)Get (c 5) $cur_headshot_level (c 2)headshots without dying!] []
    if (strcmp $arg1 splattered) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Noob Cannon! (c 2)Get (c 5) $cur_splattered_level (c 2)shotgun splatters without dying!] []
    if (strcmp $arg1 ratio) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Ratio Whore! (c 2)Get a (c 5) $cur_ratio_level (c 2)or higher ratio!] []
    if (strcmp $arg1 flag) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Flag Runner! (c 2)Get (c 5) $cur_flag_level (c 2)or more flags in a single round!] []
    if (strcmp $arg1 killstreak) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Rampage! (c 2)Get a (c 5) $cur_killstreak_level (c 2)or higher kill streak without dying!] []
    if (strcmp $arg1 akimbo) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Akimbo Madman! (c 2)Get (c 5) $cur_akimbo_level (c 2)or more kills with the akimbo without dying!] []
    if (strcmp $arg1 assault) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)AR Marksman! (c 2)Get (c 5) $cur_assault_level (c 2)or more kills with the assault rifle overtime!] []
    if (strcmp $arg1 sub) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)SMG Massacre! (c 2)Get (c 5) $cur_sub_level (c 2)or more kills with the sub machine gun overtime!] []
    if (strcmp $arg1 sniper) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Pro Sniper! (c 2)Get (c 5) $cur_sniper_level (c 2)or more kills with the sniper rifle overtime!] []
    if (strcmp $arg1 carbine) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Carbine Rage! (c 2)Get (c 5) $cur_carbine_level (c 2)or more kills with the carbine overtime!] []
    if (strcmp $arg1 shotgun) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Shotgun Lunatic! (c 2)Get (c 5) $cur_shotgun_level (c 2)or more kills with the shotgun overtime!] []
    if (strcmp $arg1 usp) [echo (c 3)You unlocked level (c 5) $cur_achievement_level (c 1)Pistol Whipper! (c 2)Get (c 5) $cur_usp_level (c 2)or more kills with the pistol overtime!] []
  ] []
]

// Various plugins to native aliases/conloop to ensure automation.
add2conloop [get_achievement_stats]
add2conloop [check_achievement_stats]
add2conloop [check_achievement_levels]

addcheck_msa [reset_achievement_stats]

// gen_achievement_alias_list - Returns a list of ALL aliases used by the script, except for saved.cfg session
//                              dependant aliases.
alias gen_achievement_alias_list [
  alias achievement_aliases []
  add2list achievement_aliases "achievement_acts achievement_aliases achievement_aliases_2 achievement_aliases_3 achievement_aliases_4 achievement_aliases_5 check_achievement_levels check_achievement_stats gen_achievement_alias_list get_achievement_stats give_achievement other_achievements_list have_achievement_counter make_achievement_aliases reset_achievements reset_achievement_stats set_achievement_levels"
  loop tmp_ach_loop (listlen $achievement_aliases_2) [
    add2list achievement_aliases (at $achievement_aliases_2 $tmp_ach_loop)
  ]
  loop tmp_ach_loop_2 3 [
    add2list achievement_aliases (format "level_%1_achievements_list" (+ $tmp_ach_loop_2 1))
    add2list achievement_aliases (format "level_%1_others_list" (+ $tmp_ach_loop_2 1))
  ]
  loop tmp_ach_loop_3 (listlen $achievement_acts) [
    add2list achievement_aliases (format "cur_%1_level" (at $achievement_acts $tmp_ach_loop_3))
  ]
  loop tmp_ach_loop_4 (listlen $other_achievements_list) [
    add2list achievement_aliases (format "cur_%1_level" (at $other_achievements_list $tmp_ach_loop_4))
  ]
  result $achievement_aliases
]

// Clear all the script's aliases on quit.
addlistonquit (gen_achievement_alias_list)

// A menu to keep track of progress.
newmenu [My Achievements]
menuitemvar [if (= $cur_achievement_level 1) [concat Current difficulty: (c 0)EASY] [if (= $cur_achievement_level 2) [concat Current difficulty: (c 2)INTERMEDIATE] [concat Current difficulty: (c 3)HARD]]]
menuitem [] -1
menuitemvar [if (|| (= (getalias (format "gave_fragged_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Unstoppable (c 5)- (c 2)Get (c 5) $cur_fragged_level (c 2)frags without dying!] [concat (c 1)Unstoppable (c 5)- (c 2)Get (c 5) $cur_fragged_level (c 2)frags without dying! (c 4) (concatword $fragged_achievement_stat / $cur_fragged_level)]]
menuitemvar [if (|| (= (getalias (format "gave_gibbed_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Grenadier (c 5)- (c 2)Get (c 5) $cur_gibbed_level (c 2)grenade gibs without dying!] [concat (c 1)Grenadier (c 5)- (c 2)Get (c 5) $cur_gibbed_level (c 2)grenade gibs without dying! (c 4) (concatword $gibbed_achievement_stat / $cur_gibbed_level)]]
menuitemvar [if (|| (= (getalias (format "gave_slashed_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Knife Specialist (c 5)- (c 2)Get (c 5) $cur_slashed_level (c 2)consecutive knife gibs!] [concat (c 1)Knife Specialist (c 5)- (c 2)Get (c 5) $cur_slashed_level (c 2)consecutive knife gibs! (c 4) (concatword $slashed_achievement_stat / $cur_slashed_level)]]
menuitemvar [if (|| (= (getalias (format "gave_headshot_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Sharp Shooter (c 5)- (c 2)Get (c 5) $cur_headshot_level (c 2)headshots without dying!] [concat (c 1)Sharp Shooter (c 5)- (c 2)Get (c 5) $cur_headshot_level (c 2)headshots without dying! (c 4) (concatword $headshot_achievement_stat / $cur_headshot_level)]]
menuitemvar [if (|| (= (getalias (format "gave_splattered_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Noob Cannon (c 5)- (c 2)Get (c 5) $cur_splattered_level (c 2)shotgun splatters without dying!] [concat (c 1)Noob Cannon (c 5)- (c 2)Get (c 5) $cur_splattered_level (c 2)shotgun splatters without dying! (c 4) (concatword $splattered_achievement_stat / $cur_splattered_level)]]
menuitemvar [if (|| (= (getalias (format "gave_ratio_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Ratio Whore (c 5)- (c 2)Get a (c 5) $cur_ratio_level (c 2)or higher ratio!] [concat (c 1)Ratio Whore (c 5)- (c 2)Get a (c 5) $cur_ratio_level (c 2)or higher ratio! (c 4) (concatword (curratio (findcn $curname)) / $cur_ratio_level)]]
menuitemvar [if (|| (= (getalias (format "gave_flag_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Flag Runner (c 5)- (c 2)Get (c 5) $cur_flag_level (c 2)or more flags in a single round!] [concat (c 1)Flag Runner (c 5)- (c 2)Get (c 5) $cur_flag_level (c 2)or more flags in a single round! (c 4) (concatword (at (pstat_score (findcn $curname)) 0) / $cur_flag_level)]]
menuitemvar [if (|| (= (getalias (format "gave_killstreak_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Rampage (c 5)- (c 2)Get a (c 5) $cur_killstreak_level (c 2)or higher kill streak without dying!] [concat (c 1)Rampage (c 5)- (c 2)Get a (c 5) $cur_killstreak_level (c 2)or higher kill streak without dying! (c 4) (concatword $killstreak_achievement_stat / $cur_killstreak_level)]]
menuitemvar [if (|| (= (getalias (format "gave_akimbo_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Akimbo Madman (c 5)- (c 2)Get (c 5) $cur_akimbo_level (c 2)or more kills with the akimbo without dying!] [concat (c 1)Akimbo Madman (c 5)- (c 2)Get (c 5) $cur_akimbo_level (c 2)or more kills with the akimbo without dying! (c 4) (concatword $akimbo_achievement_stat / $cur_akimbo_level)]]
menuitemvar [if (|| (= (getalias (format "gave_assault_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)AR Marksman (c 5)- (c 2)Get (c 5) $cur_assault_level (c 2)or more kills with the assault rifle overtime!] [concat (c 1)AR Marksman (c 5)- (c 2)Get (c 5) $cur_assault_level (c 2)or more kills with the assault rifle overtime! (c 4) (concatword $assault_achievement_stat / $cur_assault_level)]]
menuitemvar [if (|| (= (getalias (format "gave_sub_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)SMG Massacre (c 5)- (c 2)Get (c 5) $cur_sub_level (c 2)or more kills with the sub machine gun overtime!] [concat (c 1)SMG Massacre (c 5)- (c 2)Get (c 5) $cur_sub_level (c 2)or more kills with the sub machine gun overtime! (c 4) (concatword $sub_achievement_stat / $cur_sub_level)]]
menuitemvar [if (|| (= (getalias (format "gave_sniper_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Pro Sniper (c 5)- (c 2)Get (c 5) $cur_sniper_level (c 2)or more kills with the sniper rifle overtime!] [concat (c 1)Pro Sniper (c 5)- (c 2)Get (c 5) $cur_sniper_level (c 2)or more kills with the sniper rifle overtime! (c 4) (concatword $sniper_achievement_stat / $cur_sniper_level)]]
menuitemvar [if (|| (= (getalias (format "gave_carbine_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Carbine Rage (c 5)- (c 2)Get (c 5) $cur_carbine_level (c 2)or more kills with the carbine overtime!] [concat (c 1)Carbine Rage (c 5)- (c 2)Get (c 5) $cur_carbine_level (c 2)or more kills with the carbine overtime! (c 4) (concatword $carbine_achievement_stat / $cur_carbine_level)]]
menuitemvar [if (|| (= (getalias (format "gave_shotgun_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Shotgun Lunatic (c 5)- (c 2)Get (c 5) $cur_shotgun_level (c 2)or more kills with the shotgun overtime!] [concat (c 1)Shotgun Lunatic (c 5)- (c 2)Get (c 5) $cur_shotgun_level (c 2)or more kills with the shotgun overtime! (c 4) (concatword $shotgun_achievement_stat / $cur_shotgun_level)]]
menuitemvar [if (|| (= (getalias (format "gave_usp_%1" $cur_achievement_level)) 1) (>= $cur_achievement_level 4)) [concat (c 0)UNLOCKED (c 5)- (c 1)Pistol Whipper (c 5)- (c 2)Get (c 5) $cur_usp_level (c 2)or more kills with the pistol overtime!] [concat (c 1)Pistol Whipper (c 5)- (c 2)Get (c 5) $cur_usp_level (c 2)or more kills with the pistol overtime! (c 4) (concatword $usp_achievement_stat / $cur_usp_level)]]
menuitemvar [if (= $gave_pwned_bukz 1) [concat (c 0)UNLOCKED (c 5)- (c 1)Pwn Bukz (c 5)- (c 2)Beat the achievements script (c 5)3 (c 2)or more times!] []]
menuitem [] -1
menuitemvar [if (= $achievements_counter 0) [concat (c 4)You beat the achievements script (c 3) $achievements_counter (c 4)times.] [if (= $achievements_counter 1) [concat (c 4)You beat the achievements script (c 5) $achievements_counter (c 4)times.] [if (= $achievements_counter 2) [concat (c 4)You beat the achievements script (c 2) $achievements_counter (c 4)times.] [concat (c 4)You beat the achievements script (c 0) $achievements_counter (c 4)times.]]]]
menuitem [] -1
menuitemvar [concat (c 2)Killstreak settings] [showmenu "Achievements Killstreak Settings"]
menuitemvar [concat (c 3)Reset achievement progress] [showmenu "Confirm Achievements Reset"]

newmenu [Achievements Killstreak Settings]
menuitemslider [Show killstreak messages: ] 0 1 [$show_killstreak_switch] 1 ["no" "yes"] [show_killstreak_switch = $arg1]
menuitem [] -1
menuitemvar [concat (c 4)OK] [closemenu "Achievements Killstreak Settings"; sleep 0 [closemenu "My Achievements"]]

newmenu [Confirm Achievements Reset]
menuitemvar [concat (c 2)Are you sure you want to reset (c 3)ALL (c 2)of your achievements progress?]
menuitem [] -1
menuitemvar [concat (c 0)Yes] [reset_achievements; closemenu "Confirm Achievements Reset"; sleep 0 [showmenu "My Achievements"]]
menuitemvar [concat (c 3)No] [closemenu "Confirm Achievements Reset"; sleep 0 [closemenu "My Achievements"]]

// Achievements menu bind.
bind KEY [showmenu "My Achievements"]

docsection [Achievements];

docident [reset_achievements] [Resets ALL of your achievements progress!];

docident [show_killstreak_switch] [Enables or disables the showing of killstreak messages on the console.];
docexample [/show_killstreak_switch = 1] [Enables the messages.];
docexample [/show_killstreak_switch = 0] [Disables the messages.];
docremark [If enabled, a message showing your current killstreak will show up on the console everytime you get a kill.];

Copy and paste the above code into a text file and save it as "achievements.cfg".

1) Move this file to your "/config/" folder in the root installation dir for AC. Add "exec config\achievements.cfg" to your autoexec.cfg file. Save and start AC, the script should be installed.
...OR...
2) Create a "scripts" folder in the root installation dir for AC. Move this file to the folder. Add "execdir scripts" to your autoexec.cfg file. Save and start AC, the script should be installed.

Note: If using method #2 during installation, you can put any .cfg files containing valid cubescript into the "scripts" folder you created to install future scripts quickly and easily. Any .cfg files in this folder will be automatically executed on startup. Also, the values used in the achievement goals lists/tables are entirely experimental! If they turn out to be too easy I will crank them up for the next release and vice-versa. Suggestions on better values are extremely welcomed! Please report any problems you may have or bugs you may find! This script requires the latest tools.cfg to function!

The script doesn't work during bot rounds, that would be too easy to get achievements IMO. If anyone really wants it to work in bot rounds I'll paste a revision to the script that allows it.

Also don't forget to change the bind so you can easily see your progress! Enjoy. :)

[Image: achf.jpg]
Thanks given by:
#2
hmm this could be fun ! i like it.

what about 2 people going into a server and just shooting each other to get the achievements?

unless i misread something above, but having it start when a certain amount of people are in a server would help that. say at least 8
Thanks given by:
#3
EPIC!!

put it in for 1.1.0.5!
looks really good.

EDIT:
<noob script attempt>
/bind 0 [if $showmenu "My Achievements" [closemenu "My Achievements" 0; echo closed achievements] [showmenu "My Achievements" 1; echo Viewing Achievements]]
</noob script attempt>

hhmm...would that work?
to open and close it with the same button?
Thanks given by:
#4
@ Joe Smith: Since it is a client side script written in cubescript it'll be faked rather easily by most experienced scripters. Really if someone is gonna go to the extent of cheating a client-side script that no one else sees anyway, let em. Although some simple checks like you mentioned could be implemented rather easily, I'll tinker around with some ideas for the next version to prevent the minor stuff anyways.

@ MykeGregory: I know of no easy way to make a "toggle-like" bind for menus with AC. While a menu is showing it doesn't seem that most keybinds work, therefore trying to use a simple switch + if statement to determine whether to attempt to close or open the menu won't work. The next best thing I can come up with off the top of my head is to use onrelease to simulate a toggle bind (like the scoreboard - hold to view, release to close), try something like this if you'd like:

/bind 0 [showmenu "My Achievements"; onrelease [closemenu "My Achievements"]]
Thanks given by:
#5
Hmm... for some reason it doesnt work for me :/

Maybe I have made something wrong ._.

"autoexec.cfg": exec bla bla

"blabla.cfg": your code

shouldnt that work?
Thanks given by:
#6
@ a_slow_old_man: Putting the script into a file named "blabla.cfg" and placing it into your config folder, and then adding:

exec config\blabla.cfg

...to your autoexec.cfg should install the script. Worse comes to worst you could always try just pasting the entire script into your autoexec.cfg

Do you have tools.cfg installed? It is required for the script to function, are there any errors or is the thing just flat out not working at all? :/

HTH anyways, with a bit more info I might be able to pinpoint the problem, good luck!
Thanks given by:
#7
Will this kill my FPS, like MPL? Or is there going to be less in my "saved.cfg"?
Thanks given by:
#8
@ Orynge: Since it relies on lots of aliases being modified, executed, and written just like the MPL script, it will have a chance of FPS drops on some machines. I'm still not 100% sure of the cause of these drops yet (if anyone has an idea I'm all ears), other than maybe just scripter abuse of cubescript. :p

The weird thing is, I don't have a very good rig and both this script and the MPL never effected my FPS much. I suppose this could be a system dependant problem. The only way to find out if it will run smoothy on your machine is to try it, I can't guarantee any results beforehand. I will say though that this script has a LOT less lines/data than the MPL script and is also not manipulating nearly as many aliases at the same time. Therefore you might not notice the FPS drop with this one as much as you did with MPL. There will be less spam in your saved.cfg no doubt.

Good luck hopefully this one will run smoothy for you! :)
Thanks given by:
#9
Well I see the menu, but I had a 13 killstreak and not a thing happend :/
Thanks given by:
#10
Okay, I've tried it, and it's working well. No FPS drops or anything like it. :D
But I get:
unknown command: curratio
whenever I bring up the Achievements menu. D:

I have tools.cfg and I have tried restarting AC and have used /reset_achievements and /reset_all_achievements.

Thanks. :)
Thanks given by:
#11
Now its working :D
Thanks given by:
#12
@ a_slow_old_man: And you do have tools.cfg installed? If so you should of been awarded the killstreak achievement at the very least and it sounds like something horribly wrong happened on first run or something. D: Try to give me as many specifics as you can about whats going on and I'll see what I can do.

Edit: nvm, yay, ftw, happy fragging! :>

@ Orynge: Verify that you do in fact have the latest version of tools.cfg, the last update to it added the "curratio" command that the script uses. If you do have the latest version and you're getting that error then it's something I'll have to look into, and most probably the script won't work correctly for you for the time being because that achievement will be unobtainable. I'll get to the bottom of it ASAP. Glad to hear it's not suffering from the FPS drop though. :)
Thanks given by:
#13
Omg, i love this so much ;D THANKS BUKZ
Thanks given by:
#14
(11 Feb 11, 12:13PM)Bukz Wrote: @ Orynge: Verify that you do in fact have the latest version of tools.cfg, the last update to it added the "curratio" command that the script uses. If you do have the latest version and you're getting that error then it's something I'll have to look into, and most probably the script won't work correctly for you for the time being because that achievement will be unobtainable. I'll get to the bottom of it ASAP. Glad to hear it's not suffering from the FPS drop though. :)

Whoops, forgot that that was updated. Thanks Bukz :)
Thanks given by:
#15
EPIC.

Translation in progress!
Thanks given by:
#16
omg this too good
Thanks given by:
#17
who thinks it should be implemented to 1.1.0.5?!
Thanks given by:
#18
nice! <3
Thanks given by:
#19
maaaaaan! this is cool :D
Thanks given by:
#20
Hey, nice job. Cubescript, being a decently simple script, is perfect for use as such!

I haven't tried this yet, but, does this show killstreaks? For instance when I kill 5 people, it will like pop-up saying "5 killstreak" ?

Is client side, without distribution and non-commercial editing aloud?

Thanks and good work :)
Thanks given by:
#21
For now it will only pop up achievements, but some of them are killstreaks. Just check the menu.
Thanks given by:
#22
Happy to hear that everyone is liking it! :D

@ SiL3nT: There is an optional killstreak counter that you can enable from the menu that'll pop up whatever your current killstreak is after getting a kill. :)

About the client side non-distribution/non-commercial editing, checkout the license, that's completely legal in it's terms. Modifying and redistribution is okay too, as long as attribution is given, the same or a similar license is used, and it is for non-commercial purposes. I pick this license because it protects me well enough as well as gives others the freedom to modify and share it (like Andrez who's prolly working on the Italian translation. :D).

It probably is not the easiest script to modify I will admit, loop/getalias/format were used extensively to make it as lightweight and dynamic as possible. Therefore a thorough understanding of those commands will probably be required before you go in and mess with anything other than translations or tweaking the goal tables and/or menu.
Thanks given by:
#23
Thanks for the replies!

I am still a started in the CubeScripting, so my attempt failed.

But, to Bukz, couldn't you add a function which would disable this when mastermode is match and private?

Also, disable it if there are less than 6 people in the server.

Thanks!
Thanks given by:
#24
It's awesome, thanks Bukz <3
Thanks given by:
#25
Excellent work Bukz, F1.
Thanks given by:
#26
You may have issues if the script is executed in autoexec before tools.cfg... XD
Tools was meant to be executed first -- if it is installed properly, it should be the first "exec" command in the whole autoexec file. Any other script using it can be executed afterward. I prefer to have
exec config\tools.cfg
execdir scripts
and just put all my scripts in the "scripts" folder.
Maybe future AC releases should have a scripts folder and "execdir scripts" by default.
Thanks given by:
#27
I need to put the exec config/achievements line first in my
autoconfig file? Cuz the script ain't working.
Thanks given by:
#28
The script is working flawlessly for me. Infact, I almost done with the easy level. I would double check what you have.
Thanks given by:
#29
DES|V-Man: do you know of the run alias?
// full format: exec config/something.cfg
// shorthand:
run something
The idea of a scripts directory isn't a bad one, but in the past nearly nobody was using, let alone writing, CubeScript apart from the stuff provided by default. It's only DES that has lately (well, sort of) been pumping out all these awesome scripts.
There might be some problem with calling the directory scripts though - I bet it'd lead to immense confusion with newbies; especially if their scripts aren't meant to run on each launch .. I'll think about it some - maybe we can arrange some sort of compromise that'll fit the CubeScript-afficionado just as well as those that just want to use provided material.
Thanks given by:
#30
I can't think of any name better than "scripts," nor can I see the problem with calling it that. Newbies will merely ignore it altogether, and nearly-newbies will generally have to read instructions in order to use scripts (i.e., "put this in your 'scripts' folder" or "put this in your 'config' folder").
At any rate, the name of the folder is hardly a concern to me. If you decide to make an automatically-executed folder by default, I'll be grateful enough to let it be called anything (well, probably not "catpoop").

@Sil3nT: You need to execute tools.cfg first, and achievements later in autoexec.
Thanks given by: