sauerCHAOS

DS Revisions

Mar 3rd, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.59 KB | None | 0 0
  1. // DuelScript by Chaos and srbs
  2. // (C) 2011 David "srbs" Forrest & Chaos, ZLIB license
  3. // somerandombystander (at) gmail (dot) com
  4. // sauerchaos (at) gmail (dot) com
  5. // http://www.opensource.org/licenses/zlib-license.php
  6.  
  7. // Key Bind:
  8. bind L [ showgui duel ]
  9.  
  10. // Defaults:
  11. createine = [ if (=s (getalias $arg1) "") [ $arg1 = $arg2 ] ]
  12. createine _ds_ifw "Winning by"
  13. createine _ds_ifl "Losing by"
  14. createine _ds_ift "Tied!"
  15. createine _ds_delay 3
  16. createine _ds_opts 30
  17. createine _ds_stats_gh 126
  18. createine _ds_stats_dgh 0
  19. createine _ds_col_w 0
  20. createine _ds_col_l 3
  21. createine _ds_col_t 1
  22. createine _ds_col_f 1
  23. createine _ds_col_c 7
  24. createine _ds_col_txt 1
  25. createine _ds_col_stats 3
  26. createine _ds_col_clock 7
  27. _ds_go = 0
  28. _ds_color = [ result (concatword "^f" $arg1) ]
  29.  
  30. // GUI:
  31. newgui duel [
  32.     guititle "^f2DuelScript Manager"
  33.     guibar
  34.     guilist [
  35.         guilist [
  36.             guitext (concatword (_ds_color $_ds_col_w) "Text if winning: ") 0
  37.             guitext (concatword (_ds_color $_ds_col_l) "Text if losing: ") 0
  38.             guitext (concatword (_ds_color $_ds_col_t) "Text if tied: ") 0
  39.  
  40.         ]
  41.         guilist [
  42.             guifield _ds_ifw 20 [ echo "^f7Text if winning set to:" (concatword (_ds_color $_ds_col_w) $_ds_ifw) ]
  43.             guifield _ds_ifl 20 [ echo "^f7Text if losing set to:" (concatword (_ds_color $_ds_col_l) $_ds_ifl) ]
  44.             guifield _ds_ift 20 [ echo "^f7Text if tied set to:" (concatword (_ds_color $_ds_col_t) $_ds_ift) ]
  45.         ]
  46.     ]
  47.     guibar
  48.     guilist [
  49.         guibitfield "Enable Auto-Start" _ds_opts 16
  50.         if (! (& $_ds_opts 16)) [
  51.             guibar
  52.             guistayopen [
  53.                 guibutton (concatword "Script is " (? $_ds_go "^f7On/^f~^f4Off" "^f4On^f~^f7/Off")) [ _ds_go = (! $_ds_go) ]
  54.             ]
  55.         ]
  56.     ]
  57.  
  58.     guitab "Options"
  59.     guilist [
  60.         guitext "^f2Continuous Echo: " 0
  61.         guibitfield "Enable" _ds_opts 1
  62.     ]
  63.     if (& $_ds_opts 1) [
  64.         guilist [
  65.             guitext "Interval (seconds): " 0
  66.             guifield _ds_delay 2 [ echo (concatword "^f7Interval between echos set to^f~ ^f1" $_ds_delay "^f~ ^f7seconds.^f~") ]
  67.     ]
  68.     ]
  69.     guibar
  70.     guilist [
  71.         guitext "^f2Echo on Keystroke: " 0
  72.         newbinds = (searchbinds "echo (_ds_getduelstatus)")
  73.         guikeyfield newbinds -8 [
  74.             looplist i (searchbinds "echo (_ds_getduelstatus)") [ bind $i "" ]
  75.             looplist i $newbinds [ bind $i "echo (_ds_getduelstatus)" ]
  76.         ]
  77.     ]
  78.     guibar
  79.     guilist [
  80.         guitext "^f2Duel Gamehud: " 0
  81.         guibitfield "Enable" _ds_opts 2
  82.         if (& $_ds_opts 2) [
  83.             guibar
  84.             guibutton "Configure" [ showgui dgconfig ]
  85.         ]
  86.     ]
  87.     if (! (& $_ds_opts 16)) [
  88.     guibar
  89.     guilist [
  90.         guitext "^f2Toggle On/Off: " 0
  91.         newerbinds = (searchbinds "_ds_go = (! $_ds_go)")
  92.         guikeyfield newerbinds -8 [
  93.             looplist i (searchbinds "_ds_go = (! $_ds_go)") [ bind $i "" ]
  94.             looplist i $newerbinds [ bind $i "_ds_go = (! $_ds_go)" ]
  95.         ]
  96.     ]
  97. ]
  98.    
  99.     guitab "Stats"
  100.     guitext "^f2Normal Gamehud Options: " 0
  101.     guibitfield "Show Time Left"    _ds_stats_gh    64
  102.     guibitfield "Show Name"     _ds_stats_gh    1
  103.     guibitfield "Show Frags"    _ds_stats_gh    2
  104.     guibitfield "Show Deaths"   _ds_stats_gh    4
  105.     guibitfield "Show Acc"      _ds_stats_gh    8
  106.     guibitfield "Show KpD"      _ds_stats_gh    16
  107.     guibitfield "Show Flags"    _ds_stats_gh    32
  108.     guibar
  109.     guibutton "_ds_color Configuration" [ showgui _ds_colgui_b ]
  110.    
  111.     guitab "About"
  112.     guitext "Created and Developed by ^f6Chaos^f~ and ^f6srbs^f~." 0
  113.     guibar
  114.     guialign 0 [
  115.         guitextbox "Questions or Comments? Visit us on IRC at ^f6#sauer-scripts^f~ on gamesurge.net, or post a comment online at ^f6http://quadropolis.us/node/2979^f~." 30
  116.     ]
  117. ] "Duel"
  118.  
  119. newgui dgconfig [
  120.     guitext "^f2Duel Gamehud Options: " 0
  121.     guibitfield "Show Time Left"    _ds_opts    8
  122.     guibitfield "Show Difference"   _ds_opts    4
  123.     guibitfield "Show Name"     _ds_stats_dgh   1
  124.     guibitfield "Show Frags"    _ds_stats_dgh   2
  125.     guibitfield "Show Deaths"   _ds_stats_dgh   4
  126.     guibitfield "Show Acc"      _ds_stats_dgh   8
  127.     guibitfield "Show KpD"      _ds_stats_dgh   16
  128.     guibitfield "Show Flags"    _ds_stats_dgh   32
  129.     guibar
  130.     guibutton "_ds_color Configuration" [ showgui _ds_colgui_a ]
  131. ] "Duelhud"
  132.  
  133.  
  134. _ds_colrad = [
  135.     guiradio "Green"    $arg1 0
  136.     guiradio "Blue"     $arg1 1
  137.     guiradio "Yellow"   $arg1 2
  138.     guiradio "Red"      $arg1 3
  139.     guiradio "Grey"     $arg1 4
  140.     guiradio "Purple"   $arg1 5
  141.     guiradio "Orange"   $arg1 6
  142.     guiradio "White"    $arg1 7
  143. ]
  144.  
  145. newgui _ds_colgui_a [
  146.     guitext (concatword (_ds_color $_ds_col_w) "Winning Text:") 0
  147.     _ds_colrad _ds_col_w
  148.     guitab "Losing"
  149.     guitext (concatword (_ds_color $_ds_col_l) "Losing Text:") 0
  150.     _ds_colrad _ds_col_l
  151.     guitab "Tied"
  152.     guitext (concatword (_ds_color $_ds_col_t) "Tied Text:") 0
  153.     _ds_colrad _ds_col_t
  154.     if (& $_ds_opts 4) [
  155.         guitab "Difference"
  156.         guitext (concatword (_ds_color $_ds_col_f) "Frag Difference:") 0
  157.         _ds_colrad _ds_col_f
  158.     ]
  159.     if (& $_ds_opts 8) [
  160.         guitab "Clock"
  161.         guitext (concatword (_ds_color $_ds_col_c) "Clock:") 0
  162.         _ds_colrad _ds_col_c
  163.     ]
  164. ] "Winning"  
  165.  
  166. newgui _ds_colgui_b [
  167.     guitext (concatword (_ds_color $_ds_col_txt) "Text:") 0
  168.     _ds_colrad _ds_col_txt
  169.     guitab "Numbers"
  170.     guitext (concatword (_ds_color $_ds_col_stats) "Numbers:") 0
  171.     _ds_colrad _ds_col_stats
  172.     guitab "Clock"
  173.     guitext (concatword (_ds_color $_ds_col_clock) "Clock:") 0
  174.     _ds_colrad _ds_col_clock
  175. ] "Text"
  176.  
  177.  
  178. // Helper Functions:
  179.  
  180. _ds_getduelstatus = [
  181.     if $_ds_go [
  182.         if (> (getfrags) (getdeaths)) [
  183.             result (concatword (_ds_color $_ds_col_w) $_ds_ifw " " (_ds_color $_ds_col_f) (? (& $_ds_opts 4) (- (getfrags) (getdeaths))))
  184.         ] [
  185.             if (= (getfrags) (getdeaths)) [
  186.                 result (concatword (_ds_color $_ds_col_t) $_ds_ift)
  187.             ] [
  188.                 result (concatword (_ds_color $_ds_col_l) $_ds_ifl " " (_ds_color $_ds_col_f) (? (& $_ds_opts 4) (- (getdeaths) (getfrags))))
  189.             ]
  190.         ]
  191.     ] [
  192.         _ds_echostats
  193.     ]
  194. ]
  195.  
  196. _ds_echostats = [ ? (& $_ds_stats_gh 64) (substr (_ds_getstats (- $_ds_stats_gh 64)) 1) (substr (_ds_getstats ($_ds_stats_gh)) 1) ]
  197.  
  198. _ds_addzero = [ ? (> $arg1 9) $arg1 (concatword "0" $arg1) ]
  199.  
  200. _ds_timeleft = [ format "%1:%2" (div (timeremaining) 60) (_ds_addzero (mod (timeremaining) 60)) ]
  201.  
  202. //Gamehud:
  203. gamehud = [
  204.     if (&& $_ds_go (& $_ds_opts 2)) [
  205.         concatword (
  206.             ? (& $_ds_opts 8) (
  207.                 concatword (
  208.                     _ds_color $_ds_col_c) (_ds_timeleft))) (
  209.                         concat (
  210.                             ? (& $_ds_opts 8)) (
  211.                                 _ds_getduelstatus) (
  212.                                     _ds_getstats $_ds_stats_dgh))
  213.     ] [
  214.         _ds_getstats $_ds_stats_gh
  215.     ]
  216. ]
  217.  
  218. // Forever Loops:
  219. _ds_duelloop = [ if (&& $_ds_go (& $_ds_opts 1)) [ echo (_ds_getduelstatus) ] ; sleep (* $_ds_delay 1000) [ _ds_duelloop ] ]
  220. _ds_duelloop
  221.  
  222. _ds_isduel = [
  223.     if (& $_ds_opts 16) [
  224.         if (>= (getmode)) [
  225.             count = 0
  226.             looplist i (listclients 1) [
  227.                 if (! (isspectator $i)) [ count = (+ $count 1) ]
  228.             ]
  229.             _ds_go = (= $count 2)
  230.         ] [ _ds_go = 0 ]
  231.     ]
  232.     sleep 5000 [ _ds_isduel ]
  233. ]
  234. _ds_isduel
  235.  
  236. // ------------------------------------
  237.  
  238. createine _ds_list [ name frags deaths acc kpd flags time ]
  239. looplist i $_ds_list [
  240.     do [
  241.         createine _ds_color_lbl_@i  7
  242.         createine _ds_color_num_@i  7
  243.         createine _ds_show_lbl_@i   1
  244.         createine _ds_show_num_@i   1
  245.     ]
  246. ]
  247. createine _ds_show_lbl 0
  248. createine _ds_show_num 0
  249.  
  250.  
  251. newgui duel [
  252.     guititle "GameHud"
  253.     guistayopen [
  254.         guibar
  255.         guialign 0 [
  256.             guialign 0 [
  257.                 guialign 0 [
  258.                     guitext "show/hide" 0
  259.                 ]
  260.                 guibar
  261.                 guialign 0 [
  262.                     guilist [
  263.                         guitext "label" 0
  264.                         looplist i $_ds_list [
  265.                             guialign 0 [
  266.                                 guibitfield "" _ds_show_lbl (+ (pow 2 (indexof $_ds_list @i))) [
  267.                                     if (! (getalias (concatword "_ds_show_num_" @@i))) [
  268.                                         (concatword "_ds_show_lbl_" @@@i) = 0  
  269.                                     ]
  270.                                 ]
  271.                             ]
  272.                         ]
  273.                     ]
  274.                     guibar
  275.                     guilist [
  276.                         guitext "number" 0
  277.                         looplist i $_ds_list [
  278.                             guialign 0 [
  279.                                 guibitfield "" _ds_show_num (+ (pow 2 (indexof $_ds_list @i))) [
  280.                                     if (! (getalias (concatword "_ds_show_num_" @@i))) [
  281.                                         (concatword "_ds_show_lbl_" @@@i) = 0
  282.                                     ]  
  283.                                 ]
  284.                             ]
  285.                         ]
  286.                     ]
  287.                 ]
  288.             ]
  289.             guibar
  290.             guialign 0 [
  291.                 guialign 0 [
  292.                     guitext "color" 0
  293.                 ]
  294.                 guibar
  295.                 guialign 0 [
  296.                     guilist [
  297.                         guitext "label" 0
  298.                         looplist i $_ds_list [
  299.                             guialign 0 [
  300.                                 guibutton "" [
  301.                                     (concatword "_ds_color_lbl_" @i) = (+ (mod (getalias (concatword "_ds_color_lbl_" @i)) 7) 1)
  302.                                 ]
  303.                             ]
  304.                         ]
  305.                     ]
  306.                     guibar
  307.                     guilist [
  308.                         guitext "number" 0
  309.                         looplist i $_ds_list [
  310.                             guialign 0 [
  311.                                 guibutton "" [
  312.                                     (concatword "_ds_color_num_" @i) = (+ (mod (getalias (concatword "_ds_color_num_" @i)) 7) 1)
  313.                                 ]
  314.                             ]
  315.                         ]
  316.                     ]
  317.                 ]
  318.             ]
  319.             guibar
  320.             guialign 0 [
  321.                 guialign 0 [
  322.                     guitext "label" 0
  323.                 ]
  324.                 guibar
  325.                 guibar
  326.                 //guistrut 1
  327.                 looplist i $_ds_list [
  328.                     cases $i "name" [
  329.                         guitext (concatword "^f" (getalias (concatword "_ds_color_lbl_" @i)) "Name:") 0
  330.                     ] "frags" [
  331.                         guitext (concatword "^f" (getalias (concatword "_ds_color_lbl_" @i)) "Frags:") 0
  332.                     ] "deaths" [
  333.                         guitext (concatword "^f" (getalias (concatword "_ds_color_lbl_" @i)) "Deaths:") 0
  334.                     ] "acc" [
  335.                         guitext (concatword "^f" (getalias (concatword "_ds_color_lbl_" @i)) "Acc:") 0
  336.                     ] "kpd" [
  337.                         guitext (concatword "^f" (getalias (concatword "_ds_color_lbl_" @i)) "KpD:") 0
  338.                     ] "flags" [
  339.                         guitext (concatword "^f" (getalias (concatword "_ds_color_lbl_" @i)) "Flags:") 0
  340.                     ] "time" [
  341.                         guitext (concatword "^f" (getalias (concatword "_ds_color_lbl_" @i)) "Time:") 0
  342.                     ]
  343.                 ]
  344.             ]
  345.             guibar
  346.             guialign 0 [
  347.                 guialign 0 [
  348.                     guitext "number" 0
  349.                 ]
  350.                 guibar
  351.                 //guistrut 1
  352.                 guibar
  353.                 looplist i $_ds_list [
  354.                     do [
  355.                         guitext (concatword "^f" $_ds_color_num_@i $i) 0
  356.                     ]
  357.                 ]
  358.             ]
  359.             guibar
  360.             guialign 0 [
  361.                 guialign 0 [
  362.                     guitext "location" 0
  363.                 ]
  364.                 guibar
  365.                 guibar
  366.                 //guistrut 1
  367.                 loop i (listlen $_ds_list) [
  368.                     guialign 0 [
  369.                         guibutton "" [
  370.                             _ds_list = (
  371.                                 strreplace $_ds_list (concat (at $_ds_list (- @@i 1)) (at $_ds_list @@i)) (concat (at $_ds_list @@i) (at $_ds_list (- @@i 1)))
  372.                             )
  373.                         ] "arrow_bw.jpg"
  374.                         guibutton "" [
  375.                             _ds_list = (
  376.                                 strreplace $_ds_list (concat (at $_ds_list @@i) (at $_ds_list (+ @@i 1))) (concat (at $_ds_list (+ @@i 1)) (at $_ds_list @@i))
  377.                             )
  378.                         ] "arrow_fw.jpg"
  379.                     ]
  380.                 ]
  381.             ]
  382.         ]
  383.         guibar
  384.         guibutton "Save" [] 0
  385.         guibutton "Reset" [] 0
  386.     ]
  387. ] "DuelScript"
  388.  
  389. _ds_name =  [ concatword "^f" $_ds_color_lbl_name (? (& $_ds_show_lbl (+ (pow 2 (indexof $_ds_list "name")))) "Name: ") "^f" $_ds_color_num_name (getname) ]
  390. _ds_frags =     [ concatword "^f" $_ds_color_lbl_frags (? (& $_ds_show_lbl (+ (pow 2 (indexof $_ds_list "frags")))) "Frags: ") "^f" $_ds_color_num_frags (getfrags) ]
  391. _ds_deaths =    [ concatword "^f" $_ds_color_lbl_deaths (? (& $_ds_show_lbl (+ (pow 2 (indexof $_ds_list "deaths")))) "Deaths: ") "^f" $_ds_color_num_deaths (getdeaths) ]
  392. _ds_acc =   [ concatword "^f" $_ds_color_lbl_acc (? (& $_ds_show_lbl (+ (pow 2 (indexof $_ds_list "acc")))) "Acc: ") "^f" $_ds_color_num_acc (getaccuracy) ]
  393. _ds_kpd =   [ concatword "^f" $_ds_color_lbl_kpd (? (& $_ds_show_lbl (+ (pow 2 (indexof $_ds_list "kpd")))) "KpD: ") "^f" $_ds_color_num_kpd (substr (divf (getfrags) (max (getdeaths) 1)) 0 4) ]
  394. _ds_flags =     [ concatword "^f" $_ds_color_lbl_flags (? (& $_ds_show_lbl (+ (pow 2 (indexof $_ds_list "flags")))) "Flags: ") "^f" $_ds_color_num_flags (getflags) ]
  395. _ds_time =  [ concatword "^f" $_ds_color_lbl_time (? (& $_ds_show_lbl (+ (pow 2 (indexof $_ds_list "time")))) "Time: ") "^f" $_ds_color_num_time (_ds_timeleft) ]
  396.  
  397. _ds_getstats = [
  398.     _ds_temp = ""
  399.     looplist i $_ds_list [
  400.             if (& $_ds_show_num (+ (pow 2 (indexof $_ds_list $i)))) [
  401.                 _ds_temp = (concat $_ds_temp (_ds_@i))
  402.             ]
  403.     ]
  404.     result (substr $_ds_temp 1)
  405. ]
Advertisement
Add Comment
Please, Sign In to add comment