Guest User

Untitled

a guest
Feb 24th, 2020
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. debug 0
  2. #works to improve the sigil
  3. #quits with parse IMPROVE SIGIL FINISHED
  4.  
  5. ############## PLAYER DEFINED VARIABLES #####################
  6.  
  7.  
  8.  
  9. ###### accepts any sigil at or greater than the target.
  10. ## Quality = "workability" value for the sigil 1-99
  11. ## Precision = "hardness" value for the sigil 1-99
  12. ## WO sigils will have high quality, lowish precision. Product sigils will have super high precision above all else.
  13. ## Danger threshold will need to be very high for product sigils. WO sigils can be low
  14. var qualityTarget 55
  15. var precisionTarget 95
  16.  
  17. ###### Abandon sigil improves when beneath this threshold
  18. ## set 0 to turn it off
  19. ## Range of possible sigils is 1-15
  20. var abandonLimit 11
  21.  
  22. ###### risk = 1-3
  23. ## Primarily used for testing
  24. ## modifier for sanity/resolve/focus bucket only used if guaranteed to the sigil doesn't blow due to overused stars.
  25. ## 0 = assume maximum resource pulls only. Slightly lower chance of high-precision sigils, but lower chance of failure.
  26. ## 1 = average
  27. ## 2 = assume minimum pulls only. Higher chance of high-precision sigils, but very high chance of failure.
  28. var acceptableRisk 2
  29.  
  30. ###### Skip Options
  31. ## Primarily used for testing
  32. ## Disable trivial, maybe straightforward for high-value sigils.
  33. ## Set to NULL to do all actions
  34. ## This will skip everything, but I don't know why you would: var skipmoves trivial|straightforward|challenging|formidable|difficult
  35. var skipMoves NULL
  36. if ("$guild" = "Trader") then var skipMoves trivial|difficult
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. #######################################################################
  51. #######################################################################
  52. ################## DO NOT EDIT BELOW THIS LINE ######################
  53. #######################################################################
  54.  
  55. goto Improve.Sigil.Main.Start
  56.  
  57.  
  58.  
  59. ############################## CONTROLLER ##########################
  60. Improve.Sigil.Main.Start:
  61. gosub Improve.Sigil.GuildPrework
  62. gosub Improve.Sigil.Init.Vars
  63. gosub Improve.Sigil.Stats.Init
  64. gosub Improve.Sigil.Init.Actions
  65.  
  66. Improve.Sigil.Loop:
  67. ### reset the moves, mostly redundant, executes an improve to trigger actions
  68. gosub Improve.Sigil.ResetMoves
  69.  
  70. ### check if quality can be improved
  71. if (%qualityLevel <= %qualityTarget) then gosub Improve.Sigil.TestVar quality
  72.  
  73. ### check if precision can be improved
  74. if (%precisionLevel <= %precisionTarget) then gosub Improve.Sigil.TestVar precision
  75.  
  76. ### check if win conditions are still possible
  77. gosub Improve.Sigil.CheckWinPossible
  78.  
  79. goto Improve.Sigil.Loop
  80.  
  81.  
  82.  
  83.  
  84.  
  85. #######################################################################
  86. #######################################################################
  87.  
  88. ##########################
  89. #### Generic Functions ###
  90. ##########################
  91. Improve.Sigil.Put:
  92. put $0
  93. waitforre ^You|^Stow|^But|^What|^The
  94. return
  95.  
  96.  
  97. ##########################
  98. #### Setup Functions #####
  99. ##########################
  100.  
  101. Improve.Sigil.GuildPrework:
  102. if ("$guild" = "Trader" || "$guild" = "Bard") then {
  103. gosub Improve.Sigil.Put stow left
  104. gosub Improve.Sigil.Put get alm
  105. gosub Improve.Sigil.Put study alm
  106. if ($roundtime > 0) then {
  107. pause $roundtime
  108. pause 1
  109. }
  110. gosub Improve.Sigil.Put stow alm
  111.  
  112. if ($Arcana.LearningRate > 30) then gosub Improve.Sigil.Put turn taran to arcana
  113. if ($Outdoorsmanship.LearningRate > 30) then gosub Improve.Sigil.Put turn taran to outdoorsmanship
  114. if ($Scholarship.LearningRate > 30) then gosub Improve.Sigil.Put turn taran to schol
  115. gosub Improve.Sigil.Put rub taran
  116. gosub Improve.Sigil.Put gaze cry
  117. }
  118.  
  119. if ("$guild" = "Trader") then {
  120. gosub Improve.Sigil.Put spec luck
  121. }
  122. if ("$guild" = "Bard") then {
  123. if ($Bardic_Lore.LearningRate < 30) then gosub Improve.Sigil.Put put whist pier
  124. }
  125. return
  126.  
  127.  
  128. ##########################
  129. ##### Init Functions #####
  130. ##########################
  131.  
  132. Improve.Sigil.Init.Vars:
  133. put #echo blue Initializing script
  134. var dangerLevel 0
  135. var sanityLevel 0
  136. var resolveLevel 0
  137. var focusLevel 0
  138.  
  139. #Global variable set to 0 if you don't want the calling script to scribe it
  140. put #var scribeSigil 0
  141.  
  142. var precisionLevel NULL
  143. var qualityLevel NULL
  144.  
  145. var possibleBuckets ACTION|APPROACH|EFFORT|FORM|METHOD|PROCESS|RITUAL|TASK|TECHNIQUE
  146. eval Improve.Sigil.possibleBuckets.count count("%possibleBuckets","|")
  147.  
  148. ## Assign numeric values to difficulties - minimum number of stars required to complete the action ##
  149. #trivial = 1-3 (2)
  150. #straightforward = 2-5 (3)
  151. #formidable = 3-6 (4)
  152. #challenging = 4-8 (6)
  153. #difficult = 6-8 (8)
  154. var Improve.Sigil.static.trivial 1|2|3
  155. var Improve.Sigil.static.straightforward 2|3|5
  156. var Improve.Sigil.static.challenging 3|4|6
  157. var Improve.Sigil.static.formidable 4|6|8
  158. var Improve.Sigil.static.difficult 6|8|9
  159.  
  160. pause .05
  161. return
  162.  
  163. Improve.Sigil.Init.Actions:
  164.  
  165. #Main buckets
  166. #capture the sigil - not necessary due to being fed the sigil from the improve script, but it could find errors.
  167. action var sigilName $1 when \) (\w+) sigil [comprised|formed]
  168.  
  169. #out of 1-100, anything below 20 removes visibility
  170. action var STATS.previousQuality %qualityLevel;var qualityLevel $1 when Clarity:(\d+)
  171. action var STATS.previousPrecision %precisionLevel;var precisionLevel $1 when Precision:(\d+)
  172.  
  173. #0-20
  174. action var STATS.previoussanityLevel %sanityLevel; eval sanityLevel count("$1","*") when Sanity: (\**)
  175. action var STATS.previousresolveLevel %resolveLevel;eval resolveLevel count("$1","*") when Resolve: (\**)
  176. action var STATS.previousfocusLevel %focusLevel;eval focusLevel count("$1","*") when Focus: (\**)
  177. action var STATS.previousDangerLevel %dangerLevel; eval dangerLevel count("$1","*") when Danger: (\**)
  178.  
  179. #early exit actions
  180. action goto Improve.Sigil.EMPTY when You are unaware of any completely identified sigils in the area|You are unaware of any sigil
  181. action goto Improve.Sigil.BLEWIT when You lose track of your surroundings
  182. action goto Improve.Sigil.TIMEOUT when You are unaware of any sigils in the area. First identify one before attempting to improve its detail.
  183. action goto Improve.Sigil.BLEWIT when the sigil is nowhere to be found now|With dismay you ponder|removing all traces of the sigil|No traces of the sigil remain|you find yourself unable to locate the sigil anywhere
  184.  
  185. ##bucket assignment
  186. #$1 = difficulty (stars from pool) - trivial|straightforward|challenging|formidable|difficult
  187. #$2 = bucket (pool name) - focus|resolve|sanity
  188. #$3 = move name - ACTION|APPROACH|EFFORT|FORM|METHOD|PROCESS|RITUAL|TASK|TECHNIQUE
  189. #$4 = improvement - (precision|quality)... ignoring bucket to bucket moves right now as the danger level makes it impossible to use.
  190. action var Improve.Sigil.Move.$3 $4|$2|$1 when ^\.\.\.a (trivial|straightforward|challenging|formidable|difficult), (sanity|resolve|focus) [taxing|destroying|disrupting]* (%possibleBuckets) [for|to]* [elevate|improving|enhancing]* the sigil (precision|quality)\.$
  191.  
  192. pause .05
  193. return
  194.  
  195. Improve.Sigil.ResetMoves:
  196. var possibleBuckets ACTION|APPROACH|EFFORT|FORM|METHOD|PROCESS|RITUAL|TASK|TECHNIQUE
  197. ## Setup difficulty, action variables ##
  198. ## presetting to flags which will not trigger an improve attempt
  199. ## quality/precision|bucketname|Difficulty
  200. var moveMadeThisPass 0
  201.  
  202. eval Improve.Sigil.ResetMoves.count count("%possibleBuckets","|")
  203. var Improve.Sigil.ResetMoves.i 0
  204. Improve.Sigil.ResetMoves.While:
  205. var Improve.Sigil.ResetMoves.tmp %possibleBuckets(%Improve.Sigil.ResetMoves.i)
  206. var Improve.Sigil.Move.%Improve.Sigil.ResetMoves.tmp NULL|NULL|NULL
  207. math Improve.Sigil.ResetMoves.i ADD 1
  208. if %Improve.Sigil.ResetMoves.i <= %Improve.Sigil.possibleBuckets.count then goto Improve.Sigil.ResetMoves.While
  209. gosub Improve.Sigil.find.MakeMove improve na
  210. if (%precisionLevel < %abandonLimit) then goto Improve.Sigil.ABANDON
  211. return
  212.  
  213.  
  214.  
  215. ##########################
  216. ### IMPROVE FUNCTIONS ####
  217. ##########################
  218.  
  219. #$1 = bucket to test, quality or precision
  220. Improve.Sigil.TestVar:
  221. var Improve.Sigil.TestVar.testingBucket $1
  222.  
  223. var Improve.Sigil.TestVar.i 0
  224. #iterate through all possible moves and determine if it's a good move to make
  225. Improve.Sigil.TestVar.While:
  226. #only choose moves with the right bucket
  227. if ("%Improve.Sigil.TestVar.testingBucket" = "%Improve.Sigil.Move.%possibleBuckets(%Improve.Sigil.TestVar.i)(0)") then {
  228. #test if there's enough stars in the bucket
  229. gosub Improve.Sigil.find.TestVar.TestMove %possibleBuckets(%Improve.Sigil.TestVar.i) %Improve.Sigil.Move.%possibleBuckets(%Improve.Sigil.TestVar.i)(1) %Improve.Sigil.Move.%possibleBuckets(%Improve.Sigil.TestVar.i)(2)
  230. }
  231. math Improve.Sigil.TestVar.i ADD 1
  232. if %Improve.Sigil.TestVar.i <= %Improve.Sigil.possibleBuckets.count then goto Improve.Sigil.TestVar.While
  233. return
  234.  
  235.  
  236. #$1 = move to make if valid
  237. #$2 = array of bucket to test (improvement[ignore]|bucket|difficulty)
  238. #you're in this function if and only if the improvement is deemend necessary
  239. Improve.Sigil.find.TestVar.TestMove:
  240. #redefining variables as $ global references are lost in regex matches.
  241. var Improve.Sigil.find.TestVar.TestMove.action $1
  242. eval Improve.Sigil.find.TestVar.TestMove.bucket $2
  243. eval Improve.Sigil.find.TestVar.TestMove.difficulty $3
  244.  
  245. # test if in the skip list
  246. if matchre("%Improve.Sigil.find.TestVar.TestMove.difficulty","(%skipMoves)") then {
  247. put #echo blue skipping a trivial move (%Improve.Sigil.find.TestVar.TestMove.action)
  248. return
  249. }
  250.  
  251. #test if the bucket has enough resources and make the move if so.
  252. # I hate genie arrays. It falls apart at 2 levels deep.
  253. var riskModifiedMin %Improve.Sigil.static.%Improve.Sigil.find.TestVar.TestMove.difficulty
  254. if (%%Improve.Sigil.find.TestVar.TestMove.bucketLevel >= %riskModifiedMin(%acceptableRisk)) then gosub Improve.Sigil.find.MakeMove %Improve.Sigil.find.TestVar.TestMove.action %Improve.Sigil.find.TestVar.TestMove.difficulty
  255.  
  256. return
  257.  
  258. #$1 - action to take
  259. #$2 - difficulty (impove = na)
  260. Improve.Sigil.find.MakeMove:
  261. var moveMadeThisPass 1
  262. COUNTER ADD 1
  263. put per sigil $1
  264. waitfor Roundtime
  265.  
  266. if ("$1" <> "improve") then {
  267. MATH Improve.Sigil.STATS.$1 ADD 1
  268. put #echo blue $1 improve number %Improve.Sigil.STATS.$1
  269. MATH Improve.Sigil.Stats.Init.NonImproveSteps ADD 1
  270. }
  271.  
  272. if ("$1" = "ACTION") then {
  273. put per sigil action
  274. waitfor Roundtime
  275. }
  276.  
  277. if (%c = 1) then {
  278. ## Stats for metrics - capturing only on first improve
  279. var Improve.Sigil.Stats.Init.startingPrecision %precisionLevel
  280. var Improve.Sigil.Stats.Init.startingQuality %qualityLevel
  281. } else {
  282. gosub Improve.Sigil.Stats.PS.Report $2 $1
  283. }
  284. # gosub Improve.Sigil.Stats.PS.Save
  285. #check to see if minimums are met.
  286. gosub Improve.Sigil.CheckWin return
  287. return
  288.  
  289. Improve.Sigil.CheckWin:
  290. if ((%qualityTarget <= %qualityLevel) && (%precisionTarget <= %precisionLevel) && ("%precisionTarget" != "NULL")) then goto Improve.Sigil.SUCCESS
  291. if ("$1" = "return") then return
  292. goto Improve.Sigil.BLEWIT
  293.  
  294. Improve.Sigil.CheckWinPossible:
  295. var minStars -1
  296.  
  297. # I hate genie. It screws up multiple if/else statements so I have to do something stupid like this.
  298.  
  299. if !matchre("trivial","(%skipMoves)") then {
  300. var minStars %Improve.Sigil.static.trivial(%acceptableRisk)
  301. }
  302. if ((minStars = -1) && (!(matchre("straightforward","(%skipMoves)")))) then {
  303. var minStars %Improve.Sigil.static.straightforward(%acceptableRisk)
  304. }
  305. if ((minStars = -1) && (!(matchre("challenging","(%skipMoves)")))) then {
  306. var minStars %Improve.Sigil.static.challenging(%acceptableRisk)
  307. }
  308. if ((minStars = -1) && (!(matchre("formidable","(%skipMoves)")))) then {
  309. var minStars %Improve.Sigil.static.formidable(%acceptableRisk)
  310. }
  311. if ((minStars = -1) && (!(matchre("difficult","(%skipMoves)")))) then {
  312. var minStars %Improve.Sigil.static.difficult(%acceptableRisk)
  313. }
  314. if (minStars = -1) then {
  315. #you're an idiot message
  316. put #echo red *** You're running the sigil improvement script with all difficulties filtered out.
  317. put #echo red *** Exiting the game to prevent unexpected errors. Goodbye.
  318. put quit
  319. exit
  320. }
  321. if ((%sanityLevel < %minStars) && (%resolveLevel < %minStars) && (%focusLevel < %minStars)) then goto Improve.Sigil.CheckWin
  322. return
  323.  
  324. ################################
  325. ### ERROR AND EXIT FUNCTIONS ###
  326. ################################
  327.  
  328. Improve.Sigil.TIMEOUT:
  329. gosub Improve.Sigil.STATS.SetHeader red ERROR
  330. put #echo red >Log Script hung. Exiting
  331. goto Improve.Sigil.END
  332.  
  333. Improve.Sigil.BLEWIT:
  334. gosub Improve.Sigil.STATS.SetHeader red FAIL
  335. goto Improve.Sigil.END
  336.  
  337. Improve.Sigil.EMPTY:
  338. gosub Improve.Sigil.STATS.SetHeader red ERROR
  339. put #echo >SigilLog room empty, shorting out of sigil improve early.
  340. goto Improve.Sigil.END
  341.  
  342. Improve.Sigil.ABANDON:
  343. gosub Improve.Sigil.STATS.SetHeader white ABANDON
  344. goto Improve.Sigil.END
  345.  
  346. Improve.Sigil.END:
  347. gosub Improve.Sigil.STATS.Report
  348. put #parse IMPROVE SIGIL FINISHED
  349. exit
  350.  
  351.  
  352. #####################
  353. ### STATS PACKAGE ###
  354. #####################
  355.  
  356.  
  357. Improve.Sigil.SUCCESS:
  358. gosub Improve.Sigil.STATS.SetHeader green SUCCESS
  359. put #var scribeSigil 1
  360. goto Improve.Sigil.END
  361.  
  362. Improve.Sigil.STATS.Report:
  363. ## Report Stats ##
  364. if ("%Improve.Sigil.Stats.Init.BodyString" = "") then var Improve.Sigil.Stats.Init.BodyString (%sigilName)
  365.  
  366. ## Use this to capture the total number of steps
  367. var Improve.Sigil.Stats.Init.BodyString %Improve.Sigil.Stats.Init.BodyString, Steps:%c
  368.  
  369. ## Report the number of times each step was called
  370. ## gosub Improve.Sigil.STATS.Report.Steps
  371.  
  372. ## Use this to capture the number of non-improve steps
  373. var Improve.Sigil.Stats.Init.BodyString %Improve.Sigil.Stats.Init.BodyString, NI_Steps:%Improve.Sigil.Stats.Init.NonImproveSteps
  374.  
  375. ## Use this to capture the starting quality
  376. var Improve.Sigil.Stats.Init.BodyString %Improve.Sigil.Stats.Init.BodyString, startingP:%Improve.Sigil.Stats.Init.startingPrecision
  377.  
  378. ## Use this to capture the starting precision
  379. var Improve.Sigil.Stats.Init.BodyString %Improve.Sigil.Stats.Init.BodyString, startingQ:%Improve.Sigil.Stats.Init.startingQuality
  380.  
  381. ## Use this to capture the ending quality
  382. var Improve.Sigil.Stats.Init.BodyString %Improve.Sigil.Stats.Init.BodyString, Q:%qualityLevel
  383.  
  384. ## Use this to capture the ending precision
  385. var Improve.Sigil.Stats.Init.BodyString %Improve.Sigil.Stats.Init.BodyString, P:%precisionLevel
  386.  
  387. #use this to report the stats
  388. put #echo %Improve.Sigil.Stats.Init.color >Log Sigil %Improve.Sigil.Stats.Init.result %Improve.Sigil.Stats.Init.BodyString
  389. return
  390.  
  391. Improve.Sigil.STATS.Report.Steps:
  392. eval Improve.Sigil.STATS.Report.count count("%possibleBuckets","|")
  393. var Improve.Sigil.STATS.Report.i 0
  394. Improve.Sigil.STATS.Report.While:
  395. var Improve.Sigil.STATS.Report.key %possibleBuckets(%Improve.Sigil.STATS.Report.i)
  396. var Improve.Sigil.STATS.Report.value %Improve.Sigil.STATS.%Improve.Sigil.STATS.Report.key
  397. var Improve.Sigil.Stats.Init.BodyString %Improve.Sigil.Stats.Init.BodyString, %Improve.Sigil.STATS.Report.key:%Improve.Sigil.STATS.Report.value
  398. math Improve.Sigil.STATS.Report.i ADD 1
  399. if %Improve.Sigil.STATS.Report.i <= %Improve.Sigil.possibleBuckets.count then goto Improve.Sigil.STATS.Report.While
  400. return
  401.  
  402. Improve.Sigil.STATS.SetHeader:
  403. var Improve.Sigil.Stats.Init.color $1
  404. var Improve.Sigil.Stats.Init.result $2
  405. return
  406.  
  407. Improve.Sigil.Stats.Init:
  408. COUNTER set 0
  409.  
  410. # Prefix
  411. var Improve.Sigil.Stats.Init.initString
  412. var Improve.Sigil.Stats.Init.color red
  413. var Improve.Sigil.Stats.Init.logWindow sigillog
  414. var Improve.Sigil.Stats.Init.BodyString
  415. var Improve.Sigil.Stats.Init.NonImproveSteps 0
  416.  
  417. # to help determine the abandon threshhold
  418. var Improve.Sigil.Stats.Init.startingPrecision -1
  419. var Improve.Sigil.Stats.Init.startingQuality -1
  420.  
  421. eval Improve.Sigil.Stats.Init.count count("%possibleBuckets","|")
  422. var Improve.Sigil.Stats.Init.i 0
  423. Improve.Sigil.Stats.Init.While:
  424. var Improve.Sigil.Stats.Init.tmp %possibleBuckets(%Improve.Sigil.Stats.Init.i)
  425. var Improve.Sigil.STATS.%Improve.Sigil.Stats.Init.tmp 0
  426. math Improve.Sigil.Stats.Init.i ADD 1
  427. if %Improve.Sigil.Stats.Init.i <= %Improve.Sigil.possibleBuckets.count then goto Improve.Sigil.Stats.Init.While
  428.  
  429. ## for P/S reporting (precision per star)
  430. ## adding a hook for quality, but it's not used right now.
  431. var STATS.previousPrecision NULL
  432. var STATS.previousQuality NULL
  433.  
  434. var STATS.count.trivial 0
  435. var STATS.count.standard 0
  436. var STATS.count.formidable 0
  437. var STATS.count.challening 0
  438. var STATS.count.difficult 0
  439. put #echo >sigil_ps -----------------------------
  440. return
  441.  
  442. Improve.Sigil.Stats.PS.Save:
  443. put #echo green - why is this being called still?
  444. var STATS.previousPrecision %precisionLevel
  445. var STATS.previousQuality %qualityLevel
  446.  
  447. var STATS.previoussanityLevel %sanityLevel
  448. var STATS.previousresolveLevel %resolveLevel
  449. var STATS.previousfocusLevel %focusLevel
  450. var STATS.previousDangerLevel %dangerLevel
  451. return
  452.  
  453. Improve.Sigil.Stats.PS.Report:
  454.  
  455. math STATS.count.$1 add 1
  456. var STATS.previousDifficultyLevel $1
  457.  
  458. ## for P/S reporting (precision per star)
  459. var tmp_bucket sanity
  460. if (%STATS.previousresolveLevel > %resolveLevel) then var tmp_bucket resolve
  461. if (%STATS.previousfocusLevel > %focusLevel) then var tmp_bucket focus
  462. var tmp_val %STATS.previous%tmp_bucketLevel
  463.  
  464. evalmath tmp.starChange %tmp_val - %%tmp_bucketLevel
  465. evalmath tmp.percisionChange %precisionLevel - %STATS.previousPrecision
  466. evalmath tmp.qualityChange %qualityLevel - %STATS.previousQuality
  467. evalmath tmp.dangerChange %dangerLevel - %STATS.previousDangerLevel
  468.  
  469. if ("$1" = "na") then var tmp_bucket na
  470.  
  471. put #echo >sigil_ps %tmp_bucket, $1, Action:$2, SChng:%tmp.starChange, PChng:%tmp.percisionChange, QChng:%tmp.qualityChange, DChng:%tmp.dangerChange, PDL:%STATS.previousDangerLevel
  472. return
  473.  
  474.  
  475.  
  476. ###################################### _________________________________________________ #############
  477. ###################################### _________________________________________________ #############
  478. ###################################### _________________________________________________ #############
  479. ###################################### _________________________________________________ #############
  480. ###################################### _________________________________________________ #############
  481. ###################################### _________________________________________________ #############
RAW Paste Data