Advertisement
IcarusLives

Sheep Dog Game Engine UNCOMMENTED

Jul 28th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.59 KB | None | 0 0
  1. @echo off & setlocal enableDelayedExpansion
  2.  
  3. %multithread_dispatcher%
  4.     set numDistances=7
  5.     set /a "d0=1, d1=5, d2=200, d3=500, d4=400, d5=150, d6=50, d7=5, far=1"
  6.     if not exist %temp%\Canvas_3.txt call :map
  7.     call :updateCanvas /f 3
  8.     call :mathMacros
  9.     set /a "dx=18", "dy=14"
  10.     set /a "totalSheep=6", "sheepMoveSpeed=0", "maxSheepRadarDistance=8"
  11.     set "frame=-1"
  12.     for /l %%a in (0,1,%totalSheep%) do set /a "sheep_x[%%a]=18 - (%%a + 2)", "sheep_y[%%a]=19 - %%a"
  13. call :multiThread GAME_ENGINE "wasdp"
  14. goto :eof
  15.  
  16. :GAME_ENGINE
  17.  
  18.     (   for /l %%# in () do (       set /a "frame+=1", "sheepMoveChance=frame %% (sheepMoveSpeed + 1)", "currentSheep=frame %% (totalSheep + 1)"
  19.            
  20.  
  21.             %controller% & %move% w a s d . . . . dx dy
  22.  
  23.             for /l %%a in (0,1,%totalSheep%) do %plot% sheep_x[%%a] sheep_y[%%a] %%a
  24.  
  25.             for /f "tokens=1,2" %%0 in ("!currentSheep! !random!") do ( set "com=nul" & set "totalRaffles=0"
  26.                
  27.                 if !sheepMoveChance! equ 0 (
  28.                
  29.                     set "dirID=0"
  30.                     for %%b in ("-1 -1","0 -1","1 -1","1 0","1 1","0 1","-1 1","-1 0") do (
  31.                         for /f "tokens=1,2" %%c in (%%b) do set /a "sheep[%%0][!dirID!]X=%%c + sheep_x[%%0]", "sheep[%%0][!dirID!]Y=%%d + sheep_y[%%0]"
  32.                         set /a "dirID+=1"
  33.                     )
  34.                    
  35.                     for /l %%b in (0,1,7) do ( for /l %%c in (0,1,!totalSheep!) do (
  36.                            
  37.                             if "%%c" neq "%%0" (
  38.                                 set /A "x1=sheep[%%0][%%b]X, x2=sheep_x[%%c], y1=sheep[%%0][%%b]Y, y2=sheep_y[%%c], sheepDistance=%getDistance(x2,x1,y2,y1)%"
  39.                                
  40.                                 set "forCatch=false"
  41.                                 for /l %%d in (0,1,!numDistances!) do (
  42.                                     if "!forCatch!" neq "true" if !sheepDistance! == %%d (
  43.                                         set /a "sheep[%%0][%%b]+=!buyRaffles(x):x=d%%d!"
  44.                                         set "forCatch=true"
  45.                                         if !debug! == 1 (
  46.                                             set /a "r=!buyRaffles(x):x=d%%d!"
  47.                                             echo sheepDistance: !sheepDistance!  +!d%%d! [!r!] raffles >>debug.txt
  48.                                         )
  49.                                     )
  50.                                 )
  51.                                 if !sheepDistance! GTR !numDistances! (
  52.                                     set /a "sheep[%%0][%%b]+=!buyRaffles(x):x=far!"
  53.                                         if !debug! == 1 (
  54.                                             set /a "r=!buyRaffles(x):x=far!"
  55.                                             echo sheepDistance: !sheepDistance!  +!far! [!r!] raffles >>debug.txt
  56.                                         )
  57.                                 )
  58.                             )
  59.                            
  60.                             set /A "x1=dx, x2=sheep_x[%%0], y1=dy, y2=sheep_y[%%0], distance_D=%getDistance(x2,x1,y2,y1)%"
  61.                             if !distance_D! geq %maxSheepRadarDistance% (
  62.                                 set "c[%%0]=0"
  63.                                            REM if !distance_D! leq 2 ( set /a "sheep[%%0][%%b]+=(9362 * 2)"
  64.                                     REM ) else if !distance_D! equ 3 ( set /a "sheep[%%0][%%b]+=(1560 * 2)"
  65.                                     REM ) else if !distance_D! equ 4 ( set /a "sheep[%%0][%%b]+=(312 * 2)"
  66.                                     REM ) else if !distance_D! equ 5 ( set /a "sheep[%%0][%%b]+=(78 * 2)"
  67.                                     REM ) else if !distance_D! equ 6 ( set /a "sheep[%%0][%%b]+=(26 * 2)"
  68.                                     REM ) else if !distance_D! equ 7 ( set /a "sheep[%%0][%%b]+=(13 * 2)"
  69.                                     REM ) else if !distance_D! geq 8 ( set /a "sheep[%%0][%%b]+=(13 * 2)"
  70.                                 REM )
  71.                             ) else ( set "c[%%0]=1" )
  72.  
  73.                         )
  74.                         set /a "totalRaffles+=!sheep[%%0][%%b]!"
  75.                     )
  76.                    
  77.                     if !totalRaffles! gtr %%1 (
  78.                         if !debug! == 1 echo Picking a raffle winner, since totalRaffles [!totalRaffles!] is GTR than random [%%1] >>debug.txt
  79.                         set /a "selectedRaffle=%%1 %% totalRaffles"
  80.                         for /l %%b in (0,1,7) do (
  81.                             set /a "selectedRaffle-=!sheep[%%0][%%b]!", "sheep[%%0][%%b]=0"
  82.  
  83.                             if !selectedRaffle! LEQ 0 if "!com!" equ "nul" ( set "com=%%b" )
  84.                         )
  85.                     )
  86.                    
  87.                 )
  88.                
  89.                 %move% 1 7 5 3 4 6 2 0 sheep_x[%%0] sheep_y[%%0]
  90.             )
  91.            
  92.             %adjustCamera% dx dy
  93.             call:showCanvas !dx! !dy! D
  94.             call:updateCanvas /v 3
  95.     )   )
  96. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement