sezenspessa

[FORTH] Shaco Calculator

Sep 13th, 2020 (edited)
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. ( CALC I MADE LONG TIME AGO WHICH CALCULATES DIFFERENT ITEM BUILDS FOR SHACO )
  2. ( SUPER OUT OF DATE, WAS FOR OLD SHACO. )
  3. ( ENTER ITEM NAMES AT THE COMMAND LINE. )
  4. ( FOR USE IN GFORTH. )
  5.  
  6. : TEXT PAD 258 BL FILL WORD COUNT PAD SWAP MOVE ;
  7. CREATE STRUSPELLS 18 CHARS ALLOT
  8. CREATE STRSPELLS 4 CHARS ALLOT
  9.  
  10. VARIABLE .BONUSAD
  11. VARIABLE .ENEMYARMOR
  12. VARIABLE .LETHALITY
  13. VARIABLE .LEVEL
  14. VARIABLE .BONUSAD
  15. VARIABLE .CRIT
  16. VARIABLE .QLVL
  17. VARIABLE .WLVL
  18. VARIABLE .ELVL
  19. VARIABLE .RLVL
  20. VARIABLE .TOTALAD
  21. VARIABLE .STR
  22. VARIABLE .MAXHP
  23. VARIABLE .BASEAD
  24.  
  25. FVARIABLE FLETHALITY
  26. FVARIABLE FPEN
  27. FVARIABLE FCRIT
  28. FVARIABLE FTIAMAT
  29. FVARIABLE FCRITMULT
  30. FVARIABLE FCURRENTHP
  31.  
  32. 80 CONSTANT ,IE
  33. 25 CONSTANT ,TIAMAT
  34. 60 CONSTANT ,YOUMUU
  35. 55 CONSTANT ,DUSK
  36.  
  37. ( ABSTRACTION )
  38. : F+! ( ADDR F2 -- ) ( FLOAT ADD-BANG, ADDS THEN BINDS )
  39. DUP F@ F+ F! ;
  40. : CONF ( ADDR -- F ) ( GETS INT VALUE AT ADDR, CONVERTS TO FLOAT )
  41. @ S>F ;
  42. : ASK ( ACCEPTS TXT, PLACES TO TIB TO BE PLACED LATER )
  43. TIB 40 ACCEPT #TIB ! 0 >IN ! 1 TEXT ;
  44. : RNDNUM ( PSEUDO RNG BASED ON TIME, PROBABLY BAD )
  45. UTIME DROP ;
  46. : RND1 RNDNUM RNDNUM RNDNUM * * 20 UM* NIP ;
  47. : RND2 RNDNUM RND1 MS RNDNUM RND1 MS RNDNUM RND1 MS * * 100 UM* NIP ;
  48. ( ITEMS )
  49. : LETH .LEVEL @ S>F 0.4E F* 18E F/ 0.6E F+ .LETHALITY CONF F* FPEN F! CR ." ARMOR PEN IS: " FPEN F@ F. ;
  50. : IE CR ,IE .BONUSAD +! ." IE DETECTED... " 0.25E FCRIT F+! 0.25E FCRITMULT F+! ;
  51. : TIAMAT CR ,TIAMAT .BONUSAD +! ." TIAMAT DETECTED... " .BONUSAD CONF 0.80E F* FTIAMAT F+! ;
  52. : YOUMUU CR ,YOUMUU .BONUSAD +! ." YOUMUU DETECTED... " 18 .LETHALITY +! ;
  53. : DUSKBLADE CR ,DUSK .BONUSAD +! ." DUSKBLADE DETECTED... " 21 .LETHALITY +! ;
  54. ( COMBAT MATHS )
  55. : ARMR CR ." ENTER ENEMY ARMOR: " ASK 0. PAD 3 >NUMBER 2DROP DROP .ENEMYARMOR ! ;
  56. : CHKLV DUP DUP 18 > SWAP 1 < OR IF DROP ." WHAT? INVALID LVL, TRY AGAIN. " 0 ELSE .LEVEL ! 1 THEN ;
  57. : LVL RECURSIVE CR ." ENTER YOUR LEVEL: " ASK 0. PAD 2 >NUMBER 2DROP DROP CHKLV 0 = IF LVL THEN ;
  58. : RED 100E 100E .ENEMYARMOR CONF FPEN F@ F- F+ F/ ;
  59. : CRIT ( -- CRIT MULTI ) 100E FCRIT F@ F* F>S 1 - .CRIT ! 2 1 DO RND2 .CRIT @ < IF 2E FCRITMULT F@ F+
  60. ELSE 1E THEN LOOP ." CRIT " ;
  61. : DUSKDMG 22.941E .LEVEL CONF 7.059E F* F+ ;
  62. : QDMG 10 .QLVL @ * S>F .BONUSAD CONF 0.40E F* F+ ;
  63. : EDMG .BONUSAD @ 55 25 .ELVL @ DUP S>F * + SWAP S>F 0.6E 0.15E FROT F* F+ F* S>F F+ ( SPONGE )
  64. 1E FCURRENTHP F@ .MAXHP S>F F/ F- 0.5E F* FSWAP FDUP FOVER F* F+ F* ;
  65. : ENEMYHP 571 86 .LEVEL @ 1 - * + DUP .MAXHP ! S>F FCURRENTHP F! ;
  66. ( LEVEL STUFF )
  67. : USPELLS STRUSPELLS CHARS + C@ ; ( N -- CHAR# ) ( FINDS CHARACTER # AT N'TH POSITION )
  68. : DEFCHECK 0 USPELLS DUP DUP 68 = SWAP 100 = OR IF CR CR ." DEFAULT BUILD "
  69. S" WQEQQRQEQEREEWWRWW" STRUSPELLS PLACE DROP DROP DROP .LEVEL @ 1 + 1 THEN ;
  70. : INITLVL RECURSIVE CR CR ." ENTER YOUR SKILL ORDER, OR TYPE 'DEFAULT' FOR A STANDARD ORDER: "
  71. ASK PAD .STR 18 MOVE
  72. S" QWER" STRSPELLS PLACE .LEVEL @ 0
  73. .STR COUNT STRUSPELLS PLACE DEFCHECK ( UNPACKS AND PLACES 1ST LETTER TO STRUSPELLS )
  74. 17 USPELLS DUP 2DUP CR ( ALL HOPE ABANDON, YE WHO LOOK BELOW )
  75. 82 <> SWAP 69 <> AND SWAP ROT 87 <> SWAP 81 <> AND CR AND IF ( IF NOT Q,W,E,R THEN IT'S INVALID )
  76. ." TRY AGAIN. " INITLVL THEN ; ( AS OF NOW IT'S REDUNDANT BUT FUNNY LOOKING )
  77. : STATS 66E .LEVEL @ 1 - S>F 2.5E F* F+ FDUP F>S .BASEAD ! .BONUSAD @ S>F F+ F>S .TOTALAD +! ;
  78. : AUTO CRIT .TOTALAD @ S>F F* FDUP ." AUTO DMG: " F. ;
  79. : QSPELL STRSPELLS 1 CHARS + C@ ;
  80. : WSPELL STRSPELLS 2 CHARS + C@ ;
  81. : ESPELL STRSPELLS 3 CHARS + C@ ;
  82. : RSPELL STRSPELLS 4 CHARS + C@ ; ( MAY BE UNNECESSARY )
  83. : LEVELS RECURSIVE DO I USPELLS QSPELL = IF 1 .QLVL +! ELSE ( SETS OUR SPELL LEVELS )
  84. I USPELLS WSPELL = IF 1 .WLVL +! ELSE
  85. I USPELLS ESPELL = IF 1 .ELVL +! ELSE
  86. I USPELLS RSPELL = IF 1 .RLVL +! ELSE
  87. 0 .QLVL ! 0 .WLVL ! 0 .ELVL ! 0 .RLVL !
  88. CR ." you did something bad. " INITLVL LEVELS LEAVE THEN THEN THEN THEN LOOP
  89. CR ." Q LEVEL: " .QLVL @ .
  90. CR ." W LEVEL: " .WLVL @ .
  91. CR ." E LEVEL: " .ELVL @ .
  92. CR ." R LEVEL: " .RLVL @ . CR ;
  93.  
  94. : RUNES 18E 0.6E F* F>S .BONUSAD +! ;
  95. : TLORDS 21.176E 8.824E F+ .LEVEL @ S>F F* 0.40E .BONUSAD @ S>F F* F+ ;
  96.  
  97. : COMBAT 0.0E 5 0 DO
  98. 0.0E 5 1 DO
  99. I 1 = IF CRIT FDUP ." CRIT : " F. QDMG S>F F+ F* .TOTALAD @ F+
  100. DUSKDMG F+ ." FIRST AUTO DONE " THEN
  101. I 2 = IF FTIAMAT F@
  102. AUTO F+ CR ." SECOND AUTO DONE " THEN
  103. I 3 = IF EDMG CR ." E DONE " THEN
  104. TLORDS F+
  105. I 4 = IF AUTO CR ." THIRD AUTO DONE " THEN
  106. F+ LOOP
  107. F+ .MAXHP @ S>F FCURRENTHP F! LOOP
  108. 25 S>F F/ F. ." AVERAGE DAMAGE " ;
  109.  
  110. 18 .TOTALAD +!
  111. : GO CR CR LVL INITLVL RUNES LEVELS STATS ARMR LETH ENEMYHP ;
  112.  
  113.  
  114.  
  115.  
  116.  
  117. PAGE ." TYPE ANY OF THE FOLLOWING, THEN 'GO' ! " CR CR ." AVAILABLE ITEMS: TIAMAT DUSKBLADE IE YOUMUU " CR CR ." AWAITING INPUT... " CR
  118. ( TO-DO : FIX E )
Add Comment
Please, Sign In to add comment