gmzorz

sundirection/dvar animator for cod4

Dec 23rd, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.87 KB | None | 0 0
  1. @echo off
  2. setLocal enableDelayedExpansion
  3.  
  4. REM improved script generator
  5. REM unfortunately does not support decimals on input... but does smoothe out the path as much as possible
  6.  
  7. set bindKey=F11
  8. set vString=anim
  9. set output=out.cfg
  10. set steps=250
  11.     REM no more than 9999 steps
  12. set wait=2
  13. set looping=0
  14.     REM WARNING: LOOPING WILL PREVENT YOU FROM EXECUTING ANY OTHER COMMANDS, INCLUDING /QUIT
  15.    
  16. :: Dvars go here
  17.    
  18.     set dvar[0]=r_lightTweakSunDirection
  19.     set start[0]=-45 0 0
  20.     set end[0]=-45 360 0
  21.    
  22.     set dvar[1]=cg_fov
  23.     set start[1]=80
  24.     set end[1]=65
  25.    
  26.  
  27. set /a "numDvars=-1" & for /f "tokens=2 delims==" %%a in ('set dvar[') do ( set /a "numDvars+=1" )
  28. if !looping! == 0 (
  29.     set "lp=;"
  30. ) else ( set "lp=vstr !vString!1;" )
  31. for /l %%a in (0,1,!numDvars!) do (
  32.     set endLine=!endLine!!dvar[%%a]! !start[%%a]!;
  33. )
  34. set endLine=!endLine!
  35. set /a "prcnt=!steps!/50"
  36. set bar=^|
  37. set /a "l=0"
  38. set /a "numv=0"
  39. if exist !output! del !output! /s /q >nul
  40. echo bind !bindKey! ^"vstr !vString!1^" >> "!output!"
  41. if exist *.start del *.start /s /q >nul
  42. if exist *.end del *.end /s /q >nul
  43. if exist *.clc del *.clc /s /q >nul
  44. if exist *.flt del *.flt /s /q >nul
  45. if exist *.tmp del *.tmp /s /q >nul
  46. set /a "count=0" & echo >> "!count!.clc"
  47. for /f "tokens=2 delims==" %%a in ('set dvar[') do (
  48.     for %%b in (*.clc) do (
  49.         for %%c in (!start[%%~nb]!) do (
  50.             if not %%c == 0 ( set /a sn=%%c*10000 ) else ( set /a "sn=1" )
  51.             echo | set /p=!sn! >> start.txt
  52.         )
  53.         for %%c in (!end[%%~nb]!) do (
  54.             if not %%c == 0 ( set /a en=%%c*10000 ) else ( set /a "en=1" )
  55.             echo | set /p=!en! >> end.txt
  56.         )
  57.         if exist start.txt (
  58.             for /f "tokens=*" %%d in (start.txt) do set "start[%%~nb]=%%d" 2>nul
  59.             for /f "tokens=*" %%d in (end.txt) do set "end[%%~nb]=%%d" 2>nul
  60.             del *.txt /s /q >nul
  61.         )
  62.         set /a "floatVal=1"
  63.         for %%c in (!start[%%~nb]!) do (
  64.             echo | set /p=%%c >> "!floatVal!.start"
  65.             set /a "floatVal+=1"
  66.         )
  67.         set /a "floatVal=1"
  68.         for %%c in (!end[%%~nb]!) do (
  69.             echo | set /p=%%c >> "!floatVal!.end"
  70.             set /a "floatVal+=1"
  71.         )
  72.         set /a "floatVal-=1"
  73.         for /l %%c in (1,1,!floatVal!) do (
  74.             for /f "tokens=*" %%d in (%%c.start) do set /a "s_%%c=%%d"
  75.             for /f "tokens=*" %%d in (%%c.end) do set /a "e_%%c=%%d"
  76.             set /a "addTo_%%a_%%c=((!e_%%c!-!s_%%c!)/!steps!)"
  77.         )
  78.         del *.start
  79.         del *.end
  80.     )
  81.     del *.clc /s /q >nul
  82.     set /a "count+=1" & echo >> !count!.clc"
  83. )
  84. del *.clc /s /q >nul
  85.  
  86. REM         CURRENT             TYPE
  87. REM ----------------------------------
  88. REM %%a   = step                INT
  89. REM %%b   = dvar name           STRING
  90. REM %%c   = dvar count          INT
  91. REM %%d   = token in var        STRING
  92. REM %%e   = tokens in txt       STRING
  93. REM %%~nf = number of tokens    INT
  94. REM ----------------------------------
  95. set /a "vstr=1"
  96. set /a "vstrP=2"
  97. for /l %%a in (1,1,!steps!) do (
  98.     if exist *.tmp del *.tmp /s /q >nul
  99.     set /a "count=0" & echo >> "!count!.tmp"
  100.     set curStr=seta !vString!!vstr! ^"wait !wait!;
  101.     for /f "tokens=2 delims==" %%b in ('set dvar[') do (
  102.         if exist *.txt del *.txt /s /q >nul
  103.         for %%c in (*.tmp) do (
  104.         set /a "floatVal=1"
  105.         set /a "floatVal=1" & echo >> !floatVal!.flt
  106.             for %%d in (!start[%%~nc]!) do (
  107.                 for %%f in (*.flt) do (
  108.                     del *.flt /s /q >nul
  109.                     set /a "newValue=(%%d+!addTo_%%b_%%~nf!)" 2>nul
  110.                     set valOut=!newValue: =!
  111.                     set valOut_=!valOut:~0,-4!.!valOut:~-4!
  112.                     if !newValue! lss 10000 (
  113.                         if !newValue! gtr 999 ( set "valOut_=0.!valOut:~-5!" )
  114.                     )
  115.                     if !newValue! lss 1000 (
  116.                         if !newValue! gtr 99 ( set "valOut_=0.0!valOut:~-4!" )
  117.                     )
  118.                     if !newValue! lss 100 (
  119.                         if !newValue! gtr 9 ( set "valOut_=0.00!valOut:~-3!" )
  120.                     )
  121.                     if !newValue! lss 10 (
  122.                         if !newValue! gtr 0 ( set "valOut_=0.000!valOut:~-2!" )
  123.                         if !newValue! gtr -10000 ( set "valOut_=!valOut:~0,-4!0.!valOut:~-4!" )
  124.                         if !newValue! gtr -1000 ( set "valOut_=!valOut:~0,-3!0.0!valOut:~-3!" )
  125.                         if !newValue! gtr -100 ( set "valOut_=!valOut:~0,-2!0.00!valOut:~-2!" )
  126.                         if !newValue! gtr -10 ( set "valOut_=!valOut:~0,-1!0.00!valOut:~-1!" )
  127.                     )
  128.                     echo | set /p=!valOut_! >> d.txt
  129.                     echo | set /p=!valOut! >> d2.txt
  130.                 )
  131.                 set /a "floatVal+=1" & echo >> !floatVal!.flt
  132.             )
  133.             for /f "tokens=*" %%e in (d.txt) do set "start_[%%~nc]=%%e"
  134.            
  135.             for /f "tokens=*" %%e in (d2.txt) do set "start[%%~nc]=%%e"
  136.             if exist d.txt del d.txt /s /q >nul
  137.             if exist d2.txt del d2.txt /s /q >nul
  138.             set start_[%%~nc]=!start_[%%~nc]:  = !
  139.             set start_[%%~nc]=!start_[%%~nc]:~0,-1!
  140.             set curStr=!curStr!%%b !start_[%%~nc]!;
  141.         )
  142.         del *.flt /s /s >nul
  143.         if exist *.tmp del *.tmp /s /q >nul
  144.         set /a "count+=1" & echo >> "!count!.tmp"
  145.     )
  146.     set curStr=!curStr!vstr !vString!!vstrP!^"
  147.     echo !curStr! >> "!output!"
  148.     set /a "vstr+=1"
  149.     set /a "vstrP+=1"
  150.    
  151.     if !l! LEQ !prcnt! (
  152.         set /a l+=1
  153.     )
  154.     if !l! GTR !prcnt! (
  155.         set "bar=!bar!-"
  156.         set /a "numv+=2"
  157.         set /a l=1
  158.         cls
  159.         call :RM
  160.         echo                !bar!
  161.         echo                !numv!%%
  162.         echo.
  163.     )  
  164. )
  165. cls
  166. call :RM
  167. echo                !bar!^|
  168. echo                100%%
  169. echo.
  170. set endLine=seta !vString!!vstr! ^"wait !wait!;!endLine!!lp!^"
  171. echo !endLine! >> "!output!"
  172. echo    Finished writing to !output!
  173. pause >nul
  174. :RM
  175. echo.
  176. echo.
  177. echo                              .RrRrR.     .M_Mm mM_M.
  178. echo                             .Rr*R*rR.   .Mm~M*m*M~mM.
  179. echo                             R*R   R*R   M*m  M*M  M*M
  180. echo                             R*R   R*R   M*M  M*M  M*M
  181. echo                             R*R   R*R   M*M  M*M  M*M
  182. echo                             R*R   R*R   M*M  M*M  M*M
  183. echo                             R*R         M*M       M*M
  184. echo                             R*R         M*M       M*M
  185. echo                             R*R         M*M       M*M
  186. echo                             R*R         M*M       M*M
  187. echo                             R*R         M*M       M*M
  188. echo                             R*R         M*M       M*M
  189. echo.
  190. echo.
Advertisement
Add Comment
Please, Sign In to add comment