Advertisement
Guest User

Mining

a guest
Sep 2nd, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.17 KB | None | 0 0
  1. ## Modified by Azarael
  2. ## Modified by Hervean
  3. ## Orginal by Bluerider.
  4.  
  5. #debug 10
  6.  
  7. ### User Defined Settings (0 = no, 1 = yes)
  8. # Keeping stone?
  9. var mine.stone $MINING_MINE.STONE
  10.  
  11. # Keeping metal?
  12. var mine.metal $MINING_MINE.METAL
  13.  
  14. # Tracking volume?
  15. var volume.track $MINING_VOLUME.TRACK
  16.  
  17. # Where to stow material when not deeded.
  18. var mat.stow $MINING_MAT.STOW
  19.  
  20. # Which sizes of stone to deed
  21. var StoneDeed $MINING_STONE.DEED
  22.  
  23. # List of metal to keep.
  24. var MaterialKeepList.metal $MINING_METAL.KEEP
  25. ## var MaterialKeepList.metal (nickel|tin|covellite|silver|iron|zinc|copper|lead|oravir)
  26.  
  27. ## List of stone to keep.
  28. var MaterialKeepList.stone $MINING_STONE.KEEP
  29. ## var MaterialKeepList.stone (alabaster|andesite|basalt|breccia|dolomite|gabbro|granite|jade|limestone|marble|obsidian|onyx|pumice|quartzite|sandstone|schist|serpentine|soapstone|travertine)
  30.  
  31. # How long to wait after mining before mining again.
  32. # Too small a value may cause dangers to happen before they can be corrected.
  33. var SafetyPause 12
  34.  
  35. ############################################################################
  36. ###Variable declaration.
  37.  
  38. var FoundStone 0
  39. var FoundMetal 0
  40. var MineFailure 0
  41. var MaterialLevel 0
  42. var TotalStone 0
  43. var TotalMetal 0
  44. var TotalDeed 0
  45. var rare.found 0
  46. var volume.found.stone 0
  47. var volume.found.metal 0
  48. var volume.found.rare 0
  49. var total.volume 0
  50. var have.pick 0
  51. var have.shovel 0
  52. var have.deeds 0
  53. var miners.present 0
  54. var need.coins 0
  55. var warn.once 0
  56. var analyzed.pick 0
  57. var regular.metal.type None
  58. var position |second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth
  59. var sizes.metal (tiny|small|medium|large|huge|massive|enormous)
  60. var volumes.metal (1|2|3|4|5|10|20)
  61. var sizes.rare (tiny|small|medium|large|huge|massive|enormous)
  62. var volumes.rare (1|2|3|4|5|10|20)
  63. var sizes.stone (pebble|stone|small rock|large rock|boulder)
  64. var volumes.stone (1|2|3|4|5)
  65. var metal.materiallist (nickel|tin|covellite|silver|iron|zinc|copper|lead|oravir|coal) (\w+)
  66. var stone.materiallist (alabaster|andesite|basalt|breccia|dolomite|gabbro|granite|jade|limestone|marble|obsidian|onyx|pumice|quartzite|sandstone|schist|serpentine|soapstone|travertine) (\w+)
  67. var Rare.MetalList (animite|audrualm|damite|darkstone|electrum|glaes|gold|haralun|kertig|lumium|niniam|muracite|platinum) (\w+)
  68. ## Metal Keeplist with rares added.
  69. eval MaterialKeepList.metal replacere("%MaterialKeepList.metal", "\)", "|animite|audrualm|damite|darkstone|electrum|glaes|gold|haralun|kertig|lumium|niniam|muracite|platinum)")
  70.  
  71. ############################################################################
  72. ##Miner script overrides.
  73.  
  74. if_1 then
  75. {
  76. var this.mat 0
  77. var override.mats %1
  78. var mine.stone 0
  79. var mine.metal 0
  80. var MaterialKeepList.metal
  81. var MaterialKeepList.stone
  82. eval override.count count("%override.mats","|")
  83. goto Parse.Override
  84. }
  85. goto Triggers
  86.  
  87. Parse.Override:
  88. if matchre("%override.mats(%this.mat)","alabaster|andesite|basalt|breccia|dolomite|gabbro|granite|jade|limestone|marble|obsidian|onyx|pumice|quartzite|sandstone|schist|serpentine|soapstone|travertine") then
  89. {
  90. var mine.stone 1
  91. var MaterialKeepList.stone %MaterialKeepList.stone|%override.mats(%this.mat)
  92. }
  93. if matchre("%override.mats(%this.mat)","nickel|tin|covellite|silver|iron|zinc|copper|lead|oravir|coal") then
  94. {
  95. var mine.metal 1
  96. var MaterialKeepList.metal %MaterialKeepList.metal|%override.mats(%this.mat)
  97. }
  98. if %this.mat < %override.count then
  99. {
  100. math this.mat add 1
  101. goto Parse.Override
  102. }
  103. eval MaterialKeepList.stone replacere("%MaterialKeepList.stone","^\|","")
  104. eval MaterialKeepList.metal replacere("%MaterialKeepList.metal","^\|","")
  105. var MaterialKeepList.stone (%MaterialKeepList.stone)
  106. var MaterialKeepList.metal (%MaterialKeepList.metal|animite|audrualm|damite|darkstone|electrum|glaes|gold|haralun|kertig|lumium|niniam|muracite|platinum)
  107.  
  108. ############################################################################
  109. ###Trigger setup
  110. Triggers:
  111. # If roundtime wasn't up try sending the last command again.
  112. action (Retry) pause, put $lastcommand when ...wait
  113. action put #queue clear;put #send 1 $lastcommand when ^Sorry,|^\.\.\.wait|that while entangled in a web\.$
  114.  
  115. # Check if we find anything when mining
  116. action (Mining) var FoundStone 1 when topples free\.
  117. action (Mining) var FoundStone 1;var FoundMetal 1 when are visible on the ground\.
  118. action (Mining) var FoundMetal 1 when falls to the ground\!
  119.  
  120. # Catch what we have mined and update totals.
  121. action var stone.type $1;var result.type.stone $2;math TotalStone add 1;math minesuccess add 1 when %stone.materiallist (and|topples)
  122. action var regular.metal.type $1;var result.type.metal $2;math TotalMetal add 1;math minesuccess add 1 when %metal.materiallist (falls|are)
  123. action var rare.metal.type $1;math rare.found add 1 when %Rare.MetalList (falls|are)
  124.  
  125. # Update the amount of material left in the room when prospecting.
  126. action (Prospect) var MaterialLevel 6 when enormous quantity remains to be found
  127. action (Prospect) var MaterialLevel 5 when substantial quantity remains to be found
  128. action (Prospect) var MaterialLevel 4 when good quantity remains to be found
  129. action (Prospect) var MaterialLevel 3 when decent quantity remains to be found
  130. action (Prospect) var MaterialLevel 2 when small quantity remains to be found
  131. action (Prospect) var MaterialLevel 1 when scattering of resources remains to be found
  132. action (Prospect) var MaterialLevel 0 when not suitable for mining
  133.  
  134. # Prospecting checks.
  135. action (Prospect) var CarefulDone 1 when (shows the location of additional resources|pocket of hidden resources|no additional resources)
  136.  
  137. # Tool checks.
  138. action (toolcheck) var have.pick 1;var stow.pickaxe $1 when tap a .* pickaxe .*inside your (\S+|\S+\s+\w+)\.$
  139. action (toolcheck) var have.shovel 1;var stow.shovel $1 when tap a .* shovel .*inside your (\S+|\S+\s+\w+)\.$
  140. action (toolcheck) var have.shovel 1;var is.tied 1 when tap a .* shovel .*atop your .* belt\.$
  141.  
  142. action (analyze) var tool $1 when analyze .* of the \S+ (\w+)
  143. action (analyze) var condition.%tool $1 $2 when (pristine|mint|good|scuffed|minor|unsightly|badly|practically) (condition|up|scratches|notches|damaged|destroyed)
  144. action (analyze) var condition.%tool $1 and $2 when (dents|scratched) and (dings|notched)
  145.  
  146. # Checks for deeds, miners and coins.
  147. action (Prospect) var miners.present 1 when ^Miners stand ready
  148. action (deedcheck) var have.deeds 1 when ^You tap a .* packet
  149. action (deedcheck) var have.deeds 0;send tap my deed pack when deed packet appears out of deeds
  150. action (coincheck) var need.coins 1 when you lack the money
  151.  
  152. # Collected volume counting.
  153. action (volume) var this.size.stone $2 when %stone.materiallist (topples|and)
  154. action (volume) var this.size.metal $1 when (\w+) %metal.materiallist (falls|are)
  155. action (volume) var this.size.rare $1 when (\w+) %Rare.MetalList (falls|are)
  156.  
  157. ############################################################################
  158.  
  159. Main:
  160. action (toolcheck) on
  161. action (deedcheck) on
  162. pause 1
  163. send tap my pick
  164. pause 1
  165. send tap my shovel
  166. pause 1
  167. if %mine.stone then send tap my deed pack
  168. pause 1
  169. if !%have.pick then
  170. {
  171. if !%have.shovel then
  172. {
  173. echo You need a pick or a shovel to mine with.
  174. echo Exiting script.
  175. exit
  176. }
  177. }
  178. action (deedcheck) off
  179. action (toolcheck) off
  180. action (Retry) off
  181. var CarefulDone 0
  182. pause 1
  183. if %mine.stone then
  184. {
  185. if %have.shovel then
  186. {
  187. if %is.tied = 1 then
  188. {
  189. send untie my shovel
  190. gosub Prospect
  191. } else{
  192. send get my shovel
  193. gosub Prospect
  194. }
  195. }
  196. }
  197. if !%have.pick then
  198. {
  199. if %is.tied = 1 then send untie my shovel
  200. else send get my shovel
  201. gosub Prospect
  202. }
  203. send get my pick
  204. gosub Prospect
  205.  
  206. MainLoop:
  207. if %MaterialLevel > 0 then
  208. {
  209. gosub Mine
  210. }
  211. else
  212. {
  213. if ( %MineFailure > 3 ) then
  214. {
  215. gosub Prospect
  216. }
  217. else
  218. {
  219. gosub Mine
  220. }
  221. }
  222. goto MainLoop
  223.  
  224.  
  225. Prospect:
  226. var MineFailure 0
  227. action (Prospect) on
  228. action (Retry) on
  229. matchre ProspectContinue Studying the geology
  230. matchre Prospect this area contains mineable resources
  231. matchre RoomEmpty Roundtime\:|not suitable
  232. send prospect
  233. matchwait
  234.  
  235. ProspectContinue:
  236. pause
  237. pause 1
  238. action (Prospect) off
  239. action (Retry) off
  240. goto mine
  241.  
  242. # Perform mine action
  243. Mine:
  244. action (Mining) on
  245. action (Retry) on
  246. if %volume.track then action (volume) on
  247. var FoundStone 0
  248. var FoundMetal 0
  249. pause 1
  250. put mine
  251. waitforre Roundtime
  252. action (Mining) off
  253. action (Retry) off
  254. if %volume.track then action (volume) off
  255. gosub Danger
  256. if %FoundStone = 1 then
  257. {
  258. var MineFailure 0
  259. if %volume.track then gosub volume.add stone
  260. if %mine.stone then gosub Mine.Found stone
  261. }
  262. if %FoundMetal = 1 then
  263. {
  264. var MineFailure 0
  265. pause .5
  266. if matchre("$roomobjs", "%Rare.MetalList") then
  267. {
  268. if %volume.track then gosub volume.add rare
  269. }
  270. else
  271. {
  272. if %volume.track then gosub volume.add metal
  273. }
  274. if %mine.metal then gosub Mine.Found metal
  275. }
  276. else
  277. {
  278. math MineFailure add 1
  279. }
  280. if %MineFailure > 4 then gosub prospect
  281. goto mine
  282.  
  283. Mine.Found:
  284. var type $1
  285. if $righthandnoun = pickaxe then
  286. {
  287. if !%analyzed.pick then
  288. {
  289. action (analyze) on
  290. pause 1
  291. send analyze pick
  292. waitforre Roundtime
  293. var analyzed.pick 1
  294. action (analyze) off
  295. if %have.shovel then
  296. {
  297. send stow pick in my %stow.pickaxe
  298. pause 1
  299. if %is.tied = 1 then send untie my shovel
  300. else send get my shovel
  301. pause 1
  302. }
  303. }
  304. }
  305. gosub Collect
  306. return
  307.  
  308. ## Collect items.
  309. Collect:
  310. if matchre("$roomobjs", "%MaterialKeepList.%type (\w+)") then
  311. {
  312. if matchre("$roomobjs", "%Rare.MetalList") then
  313. {
  314. var rare.form $2
  315. send get %rare.form
  316. waitforre ^You pick up
  317. send stow %rare.form in my %mat.stow
  318. waitforre ^You put
  319. if matchre("$roomobjs", "%MaterialKeepList.%type (\w+)") then
  320. {
  321. goto Collect
  322. }
  323. return
  324. }
  325. if %mine.%type then
  326. {
  327. if %type = stone then
  328. {
  329. if matchre("%result.type.%type", "%StoneDeed") then
  330. {
  331. if %have.deeds then
  332. {
  333. action (deedcheck) on
  334. send get my deed pack
  335. send push %result.type.%type with pack
  336. pause 1
  337. action (deedcheck) off
  338. if %have.deeds then
  339. {
  340. send stow pack in my %mat.stow
  341. pause 1
  342. send get deed
  343. waitforre ^You pick up
  344. send stow deed in my %mat.stow
  345. }
  346. else
  347. {
  348. send stow deed in my %mat.stow
  349. }
  350. waitforre ^You put
  351. math deeds add 1
  352. if matchre("$roomobjs", "%MaterialKeepList.%type (\w+)") then
  353. {
  354. var result.type.%type $2
  355. goto Collect
  356. }
  357. return
  358. }
  359. if %miners.present then
  360. {
  361. if !%need.coins then
  362. {
  363. action (coincheck) on
  364. send push %result.type.%type
  365. pause 1
  366. action (coincheck) off
  367. if !%need.coins then
  368. {
  369. math deeds add 1
  370. send stow deed in my %mat.stow
  371. waitforre ^You put
  372. if matchre("$roomobjs", "%MaterialKeepList.%type (\w+)") then
  373. {
  374. var result.type.%type $2
  375. goto Collect
  376. }
  377. return
  378. }
  379. }
  380. if !%warn.once then
  381. {
  382. echo No coins and no deeds. Can't collect the %stone.type %result.type.%type.
  383. var warn.once 1
  384. }
  385. }
  386. if !%warn.once then
  387. {
  388. echo No deeds and no miners. Can't collect the %stone.type %result.type.%type.
  389. var warn.once 1
  390. }
  391. return
  392. }
  393. }
  394. action (Retry) on
  395. action (volume) on
  396. send take %result.type.%type
  397. waitforre ^You pick up
  398. send stow %result.type.%type in my %mat.stow
  399. waitforre ^You put
  400. action (Retry) off
  401. pause 1
  402. if matchre("$roomobjs", "%MaterialKeepList.%type (\w+)") then
  403. {
  404. var result.type.%type $2
  405. goto Collect
  406. }
  407. return
  408. }
  409. }
  410. return
  411.  
  412. Volume.Add:
  413. var type $1
  414. if %this.size.%type = rock then
  415. {
  416. action (taprock) on
  417. action (taprock) var this.size.%type $1 rock when ^You tap a (\w+)
  418. pause 1
  419. send tap %stone.type rock
  420. pause 1
  421. action (taprock) off
  422. }
  423. gosub parse.array "%sizes.%type" "%this.size.%type"
  424. eval this.volume element("%volumes.%type", "%array.index")
  425. math volume.found.%type add %this.volume
  426. return
  427.  
  428. Danger:
  429. action (Prospect) on
  430. matchre Danger Unfortunately\, you are unable to find any way around the instability in the geology\.
  431. matchre dangerclean adjusting the angle of mining
  432. matchre RETURN You scan the area for danger and find nothing of concern lurking within the nearby geology\.
  433. put prospect danger
  434. matchwait
  435.  
  436. DangerClean:
  437. put #queue clear
  438. pause
  439. if %FoundStone = 1 then
  440. {
  441. if %volume.track then gosub volume.add stone
  442. gosub Collect stone
  443. }
  444. if %FoundMetal = 1 then
  445. {
  446. if matchre("$roomobjs", "%Rare.MetalList") then if %volume.track then gosub volume.add rare
  447. else
  448. {
  449. if %volume.track then gosub volume.add metal
  450. }
  451. gosub Collect metal
  452. }
  453. goto prospect
  454.  
  455. RoomEmpty:
  456. if %MaterialLevel = 0 then
  457. {
  458. Echo Room not minable.
  459. } else {
  460. if !%CarefulDone then
  461. {
  462. action (prospect) on
  463. send prospect careful
  464. pause
  465. pause 1
  466. action (prospect) off
  467. goto prospect
  468. }
  469. }
  470. if %minesuccess > 0 then
  471. {
  472. evalmath total.volume %volume.found.stone + %volume.found.metal + %volume.found.rare
  473. action (analyze) on
  474. pause 1
  475. send analyze shovel
  476. waitforre Roundtime
  477. if %is.tied = 1 then send tie shovel to my forger's belt
  478. else send stow shovel in my %stow.shovel
  479. action (analyze) off
  480. pause 1
  481. if %mine.stone then
  482. {
  483. echo ===Stone type: %stone.type
  484. echo ===Total stone mined: %TotalStone
  485. if %volume.track then echo ===Total stone volume: %volume.found.stone
  486. if %deeds > 0 then echo ===Total stone deeded: %deeds
  487. }
  488. if %mine.metal then
  489. {
  490. echo ===Metal type: %regular.metal.type
  491. echo ===Total metal mined: %TotalMetal
  492. if %volume.track then echo ===Total metal volume: %volume.found.metal
  493. }
  494. echo ===Total material mined (inclusive): %minesuccess
  495. if %volume.track then echo ===Total volume mined (inclusive): %total.volume
  496. if %mine.stone then
  497. {
  498. if !%have.shovel then echo ===Pick condition: %condition.pickaxe
  499. }
  500. else
  501. {
  502. if %have.pick then echo ===Pick condition: %condition.pickaxe
  503. }
  504. if %have.shovel then echo ===Shovel condition: %condition.shovel
  505. if %rare.found > 0 then
  506. {
  507. echo ===Rare type: %rare.metal.type
  508. echo ===Total rare: %rare.found
  509. echo ===Total rare volume: %volume.found.rare
  510. }
  511. }
  512. if !($righthand = Empty) then
  513. {
  514. if %is.tied = 1 then send tie my shov to my forger's belt
  515. else send stow $righthandnoun in %stow.$righthandnoun
  516. }
  517. put #parse MINING FINISHED
  518. exit
  519.  
  520. RETURN:
  521. return
  522.  
  523. exit
  524. var array.index
  525.  
  526. parse.array:
  527. var this.array $1
  528. var search.str $2
  529. eval this.array tolower("%this.array")
  530. eval this.array replacere("%this.array", "\(|\)", "")
  531. eval search.str tolower("%search.str")
  532. if !matchre("%this.array", "(.*(?:\||^)%search.str)(?:\||$)") then
  533. {
  534. var array.index Null
  535. echo String %search.str does not exist in array.
  536. }
  537. else
  538. {
  539. var substring_element $1
  540. eval array.index count("%substring_element","|")
  541. }
  542. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement