Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;; Copyright 2023 Gleefre
- ;;;; File profs.lisp
- #|
- To use:
- Install sbcl:
- On ubuntu
- $ sudo apt install sbcl
- For other systems find out for yourself or download from sbcl's site:
- https://www.sbcl.org/platform-table.html
- Load the program:
- sbcl --load profs.lisp
- A prompt * will be given.
- Enter (init <prof> :exp <current-exp> :lvl <current-lvl>)
- For example:
- * (init 'armorsmith :exp 10 :lvl 3)
- DONE
- *
- If you (will) have exp bonus scroll activated add :exp-bonus T
- * (init 'leatherworking :exp 10 :lvl 3 :exp-bonus T)
- DONE
- *
- Then use (50-greed <target-level> <rep-base>) function:
- * (init 'armorsmith :exp 10 :lvl 3)
- DONE
- * (50-greed 12 10)
- (:TORN-STRAP 96 :BATTLETORN-BOOTS 4 :HELMET-OF-SACRIFICE 5 :LEGGUARDS-OF-COMRADES 5 :CRY-OF-BLIGHT 5 :SHOULDERS-OF-VALIANCE 6 :GUARD-CHESTPLATE 5 :TIN-PLATE 20 :STRAP 10 :COPPER-PLATE 94)
- (:COPPER-INGOT 94 :TORN-HIDE 96 :SIMPLE-BOLT 398 :AGATE 10 :MALACHITE 5 :TIGERSEYE 11 :TIN-PLATE -20 :TIN-INGOT 20 :STRAP -10 :HIDE 10)
- Then type (quit) to quit.
- To repeat calculations you need not to quit, but you need to call (init ...) again:
- * (init 'leatherworking :exp 10 :lvl 3 :exp-bonus T)
- DONE
- * (50-greed 12 50)
- (:DIRTY-YARN 70 :RUGGED-LEATHER-TREADS 4 :CAP-OF-SUFFERINGS 3 :LOYAL-PANTS-OF-THORNS 4 :REINFORCED-BOOTS 4 :EMBROIDED-SPAULDERS 5 :DEFILED-SCALED-ROBES 4 :LEATHER 50 :YARN 50 :TORN-LEATHER 78)
- (:TORN-HIDE 78 :DIRTY-FIBER 70 :SIMPLE-RIVET 318 :BEECH-BARK 8 :BEECHNUT 8 :EURHINUS-RESIN 4 :LEATHER -50 :HIDE 50 :YARN -50 :FIBER 50)
- The <rep-base> parameter means how much of 2 materials you need for the prof you will craft in batch.
- Good value is 50, but you may want to adjust it if you will craft much more mats / less mats.
- Good Luck!
- |#
- (defun init-params (&key (exp 0) (lvl 1) exp-bonus)
- (defparameter *levels* (list 0 100 222 350 485 626 774 930 1094 1266
- 1446 1635 1834 2043 2262 2492 2734 2988 3255 3535
- 3829 4138 4462 4802 5159 5534 5928 6342 6776 7232))
- (defparameter *cur-exp* exp)
- (defparameter *cur-lvl* lvl)
- (defparameter *resources* ())
- (defparameter *resources-types* ())
- (defparameter *exp-bonus* (if exp-bonus 5/4 1))
- (defparameter *recipes-applied* ())
- (defparameter *reps* ())
- (defparameter *base-reps* ()))
- (defun defrep (lvl exp name &rest resources)
- (let ((recipe `(:level ,lvl :exp ,exp :name ,name ,@resources)))
- ;; store resources types
- (loop for tp = resources then (cddr tp)
- until (null tp)
- do (pushnew (car tp) *resources-types*))
- ;; add recipe to "base recipes" if needed
- (when (member name *resources-types*)
- (push recipe *base-reps*))
- (setf *reps* (append *reps* (list recipe)))))
- (defun sort-reps ()
- (setf *reps* (sort (copy-tree *reps*) #'<
- :key (lambda (x) (getf x :level)))))
- (defun base-repp (recipe)
- (member (getf recipe :name) *base-reps*
- :key (lambda (x) (getf x :name))))
- (defun init-enchanter ()
- ;; level 1-10
- (defrep 1 20 :beech-rod :beech-rod -1 :beech-plank 1)
- (defrep 2 30 :vogria-powder :vogria-powder -1 :dried-vogria 1)
- (defrep 4 120 :sunshine :beech-rod 3 :vogria-powder 1 :simple-sandpaper 8 :beech-bark 1)
- (defrep 5 140 :impaler :beech-rod 1 :vogria-powder 1 :simple-sandpaper 10 :beech-leaf 1)
- (defrep 6 160 :staff-of-oblivion :beech-rod 3 :vogria-powder 3 :simple-sandpaper 12 :beech-bark 1)
- (defrep 7 180 :vile-scalpel :beech-rod 2 :vogria-powder 4 :simple-sandpaper 14 :vogria-bloom 1)
- (defrep 8 200 :hopes-reach :beech-rod 3 :vogria-powder 5 :simple-sandpaper 16 :vogria-essence 1)
- (defrep 9 220 :marrowstrike :beech-rod 4 :bogria-powder 4 :simple-sandpaper 18 :vogria-bloom 1)
- ;; level 10-20
- (defrep 10 140 :alder-rod :alder-rod -1 :alder-plank 1)
- (defrep 11 150 :irruvil-powder :irruvil-powder -1 :dried-irruvil 1)
- (defrep 13 380 :conclusion :alder-rod 2 :irruvil-powder 2 :sandpaper 6 :irruvil-essence 1)
- (defrep 14 400 :souldrinker :alder-rod 3 :irruvil-powder 1 :sandpaper 8 :alder-bark 1)
- (defrep 15 420 :spur :alder-rod 2 :irruvil-powder 4 :sandpaper 10 :irruvil-root 1)
- (defrep 16 440 :vengeful-striker :alder-rod 3 :irruvil-powder 3 :sandpaper 12 :alder-bark 1)
- (defrep 17 460 :dark-intent :alder-rod 4 :irruvil-powder 2 :sandpaper 14 :irruvil-root 1)
- (defrep 18 480 :blackheart :alder-rod 3 :irruvil-powder 5 :sandpaper 16 :alder-bark 1)
- ;; level 20-30
- (defrep 20 320 :spruce-rod :spruce-rod -1 :spruce-plank 1)
- (defrep 21 330 :lavekawa-powder :lavekawa-powder -1 :dried-lavekawa 1)
- (defrep 23 700 :twitch :spruce-rod 3 :lavekawa-powder 1 :quality-sandpaper 6 :spruce-cones 1)
- (defrep 24 720 :clemence :spruce-rod 2 :lavekawa-powder 4 :quality-sandpaper 8 :spruce-resin 1)
- (defrep 25 740 :warp-pole :spruce-rod 3 :lavekawa-powder 3 :quality-sandpaper 10 :spruce-cones 1)
- (defrep 26 760 :firesoul-war-staff :spruce-rod 4 :lavekawa-powder 4 :quality-sandpaper 12 :spruce-resin 1)
- (defrep 27 780 :gaze-of-corruption :spruce-rod 4 :lavekawa-powder 4 :quality-sandpaper 14 :spruce-cones 1)
- (defrep 28 800 :sunshard :spruce-rod 5 :lavekawa-powder 3 :quality-sandpaper 16 :spruce-bark 1))
- (defun init-weaponsmith ()
- ;; level 1-10
- (defrep 1 20 :copper-bar :copper-bar -1 :copper-ingot 1)
- (defrep 2 30 :beech-handle :beech-handle -1 :beech-plank 1)
- (defrep 4 120 :betrayer :copper-bar 1 :beech-handle 3 :simple-grindstone 8 :tigerseye 1)
- (defrep 5 140 :malice :copper-bar 3 :beech-handle 1 :simple-grindstone 10 :malachite 1)
- (defrep 6 160 :oathkeeper :copper-bar 3 :beech-handle 3 :simple-grindstone 12 :beech-leaf 1)
- (defrep 7 180 :silence :copper-bar 4 :beech-handle 2 :simple-grindstone 14 :agate 1)
- (defrep 8 200 :smite :copper-bar 5 :beech-handle 3 :simple-grindstone 16 :malachite 1)
- (defrep 9 220 :greataxe :copper-bar 4 :beech-handle 4 :simple-grindstone 18 :beech-leaf 1)
- ;; level 10-20
- (defrep 10 140 :tin-bar :tin-bar -1 :tin-ingot 1)
- (defrep 11 150 :alder-handle :alder-handle -1 :alder-plank 1)
- (defrep 13 380 :gladius :tin-bar 2 :alder-handle 2 :grindstone 6 :jasper 1)
- (defrep 14 400 :shadowrazor :tin-bar 2 :alder-handle 4 :grindstone 8 :quartz 1)
- (defrep 15 420 :despair :tin-bar 3 :alder-handle 3 :grindstone 10 :alder-cones 1)
- (defrep 16 440 :putrid-carver :tin-bar 4 :alder-handle 2 :grindstone 12 :alder-resin 1)
- (defrep 17 460 :phobia :tin-bar 3 :alder-handle 5 :grindstone 14 :obsidian 1)
- (defrep 18 480 :anduril :tin-bar 5 :alder-handle 3 :grindstone 16 :obsidian 1)
- ;; level 20-30
- (defrep 20 320 :iron-bar :iron-bar -1 :iron-ingot 1)
- (defrep 21 330 :spruce-handle :spruce-handle -1 :spruce-plank 1)
- (defrep 23 700 :furious-etcher :iron-bar 3 :spruce-handle 1 :quality-grindstone 6 :ruby 1)
- (defrep 24 720 :warbringer :iron-bar 2 :spruce-handle 4 :quality-grindstone 8 :spruce-cones 1)
- (defrep 25 740 :stormguard-claymore :iron-bar 3 :spruce-handle 3 :quality-grindstone 10 :spruce-cones 1)
- (defrep 26 760 :pride-of-ancient :iron-bar 4 :spruce-handle 4 :quality-grindstone 12 :lapis 1)
- (defrep 27 780 :barrage :iron-bar 5 :spruce-handle 3 :quality-grindstone 14 :lapis 1)
- (defrep 28 800 :remorseful-broadaxe :iron-bar 5 :spruce-handle 3 :quality-grindstone 16 :spruce-cones 1))
- (defun init-tailor ()
- ;; level 1-10
- (defrep 1 20 :dirty-cloth :dirty-cloth -1 :dirty-fiber 1)
- (defrep 2 30 :vogria-paste :vogria-paste -1 :dried-vogria 1)
- (defrep 4 120 :fiery-headguard :dirty-cloth 2 :vogria-paste 2 :simple-button 8 )
- (defrep 5 140 :legguards-of-the-sun :dirty-cloth 2 :vogria-paste 4 :simple-button 10 :vogria-root 1)
- (defrep 6 160 :touch-of-cursed-might :dirty-cloth 3 :vogria-paste 3 :simple-button 12 :red-blossom 1)
- (defrep 7 180 :boots-of-flames :dirty-cloth 4 :vogria-paste 2 :simple-button 14 :red-blossom 1)
- (defrep 8 200 :helmet-of-stars :dirty-cloth 3 :vogria-paste 5 :simple-button 16 :vogria-root 1)
- (defrep 9 220 :scaled-shoulderguards :dirty-cloth 5 :vogria-paste 3 :simple-button 18 :red-blossom 1)
- ;; level 10-20
- (defrep 10 140 :cloth :cloth -1 :fiber 1)
- (defrep 11 150 :irruvil-paste :irruvil-paste -1 :dried-irruvil 1)
- (defrep 13 380 :ruby-infused-visage :cloth 2 :irruvil-paste 2 :button 6 )
- (defrep 14 400 :shoulderguards-of-freedom :cloth 3 :irruvil-paste 1 :button 8 )
- (defrep 15 420 :leggings-of-the-phoenix :cloth 2 :irruvil-paste 4 :button 10 :irruvil-essence 1)
- (defrep 16 440 :stranglers-of-fire :cloth 4 :irruvil-paste 2 :button 12 :irruvil-essence 1)
- (defrep 17 460 :holy-world-walkers :cloth 4 :irruvil-paste 2 :button 14 :irruvil-essence 1)
- (defrep 18 480 :coif-of-hellish-whispers :cloth 3 :irruvil-paste 5 :button 16 :irruvil-bloom 1)
- ;; level 20-30
- (defrep 20 320 :quality-cloth :quality-cloth -1 :quality-fiber 1)
- (defrep 21 330 :lavekawa-paste :lavekawa-paste -1 :dried-lavekawa 1)
- (defrep 23 700 :quilted-facemask :quality-cloth 2 :lavekawa-paste 2 :big-button 6 )
- (defrep 24 720 :incinerated-shoulders :quality-cloth 3 :lavekawa-paste 1 :big-button 8 )
- (defrep 25 740 :legguards-of-fire :quality-cloth 2 :lavekawa-paste 4 :big-button 10 :lavekawa-essence 1)
- (defrep 26 760 :fall-of-broken-bones :quality-cloth 3 :lavekawa-paste 3 :big-button 12 :lavekawa-bloom 1)
- (defrep 27 780 :voice-of-the-champion :quality-cloth 4 :lavekawa-paste 2 :big-button 14 :lavekawa-bloom 1)
- (defrep 28 800 :thunder-hide-mask :quality-cloth 3 :lavekawa-paste 5 :big-button 16 :lavekawa-essence 1))
- (defun init-armorsmith ()
- ;; level 1-10
- (defrep 1 20 :copper-plate :copper-plate -1 :copper-ingot 1)
- (defrep 2 30 :torn-strap :torn-strap -1 :torn-hide 1)
- (defrep 4 120 :battletorn-boots :copper-plate 1 :torn-strap 3 :simple-bolt 8 )
- (defrep 5 140 :helmet-of-sacrifice :copper-plate 2 :torn-strap 2 :simple-bolt 10 :agate 1)
- (defrep 6 160 :legguards-of-comrades :copper-plate 2 :torn-strap 4 :simple-bolt 12 :malachite 1)
- (defrep 7 180 :cry-of-blight :copper-plate 4 :torn-strap 2 :simple-bolt 14 :tigerseye 1)
- (defrep 8 200 :shoulders-of-valiance :copper-plate 5 :torn-strap 4 :simple-bolt 16 :tigerseye 1)
- (defrep 9 220 :guard-chestplate :copper-plate 4 :torn-strap 4 :simple-bolt 18 :agate 1)
- ;; level 10-20
- (defrep 10 140 :tin-plate :tin-plate -1 :tin-ingot 1)
- (defrep 11 150 :strap :strap -1 :hide 1)
- (defrep 13 380 :bronzed-greaves :tin-plate 1 :strap 3 :bolt 4 )
- (defrep 14 400 :leggings-of-infinite-fortune :tin-plate 2 :strap 4 :bolt 8 )
- (defrep 15 420 :obsidian-chestplate :tin-plate 3 :strap 3 :bolt 10 :quartz 1)
- (defrep 16 440 :silk-gloves :tin-plate 4 :strap 2 :bolt 12 :jasper 1)
- (defrep 17 460 :headguard-of-holy-wars :tin-plate 3 :strap 5 :bolt 14 :quartz 1)
- (defrep 18 480 :shoulders-of-fortune :tin-plate 4 :strap 4 :bolt 16 :jasper 1)
- ;; level 20-30
- (defrep 20 320 :iron-plate :iron-plate -1 :iron-ingot 1)
- (defrep 21 330 :strong-strap :strong-strap -1 :strong-hide 1)
- (defrep 23 700 :wortheim-helmet :iron-plate 2 :strong-strap 2 :iron-bolt 6 )
- (defrep 24 720 :britches-of-silent-power :iron-plate 2 :strong-strap 4 :iron-bolt 8 )
- (defrep 25 740 :blessing-of-fortitude :iron-plate 3 :strong-strap 3 :iron-bolt 10 :amethyst 1)
- (defrep 26 760 :feral-gloves :iron-plate 4 :strong-strap 2 :iron-bolt 12 :ruby 1)
- (defrep 27 780 :death-of-eternal-glory :iron-plate 3 :strong-strap 5 :iron-bolt 14 :amethyst 1)
- (defrep 28 800 :iron-shoulderplates :iron-plate 4 :strong-strap 4 :iron-bolt 16 :ruby 1))
- (defun init-leatherworking ()
- ;; level 1-10
- (defrep 1 20 :torn-leather :torn-leather -1 :torn-hide 1)
- (defrep 2 30 :dirty-yarn :dirty-yarn -1 :dirty-fiber 1)
- (defrep 4 120 :rugged-leather-treads :torn-leather 1 :dirty-yarn 3 :simple-rivet 8 )
- (defrep 5 140 :cap-of-sufferings :torn-leather 3 :dirty-yarn 1 :simple-rivet 10 :beech-bark 1)
- (defrep 6 160 :loyal-pants-of-thorns :torn-leather 2 :dirty-yarn 4 :simple-rivet 12 :beechnut 1)
- (defrep 7 180 :reinforced-boots :torn-leather 4 :dirty-yarn 2 :simple-rivet 14 :beechnut 1)
- (defrep 8 200 :embroided-spaulders :torn-leather 5 :dirty-yarn 3 :simple-rivet 16 :beech-bark 1)
- (defrep 9 220 :defiled-scaled-robes :torn-leather 4 :dirty-yarn 4 :simple-rivet 18 :eurhinus-resin 1)
- ;; level 10-20
- (defrep 10 140 :leather :leather -1 :hide 1)
- (defrep 11 150 :yarn :yarn -1 :fiber 1)
- (defrep 13 380 :rugged-facemask-of-warlords :leather 2 :yarn 2 :rivet 6 )
- (defrep 14 400 :promise-of-horrors :leather 2 :yarn 4 :rivet 8 )
- (defrep 15 420 :chestpiece-of-the-forsaken :leather 3 :yarn 3 :rivet 10 :wisdom-bark 1)
- (defrep 16 440 :blood-hide-grasps :leather 4 :yarn 2 :rivet 12 :alder-resin 1)
- (defrep 17 460 :heirloom-of-the-forest :leather 3 :yarn 5 :rivet 14 :alder-cones 1)
- (defrep 18 480 :protector-of-guardians :leather 5 :yarn 3 :rivet 16 :alder-cones 1)
- ;; level 20-30
- (defrep 20 320 :strong-leather :strong-leather -1 :strong-hide 1)
- (defrep 21 330 :strong-yarn :strong-yarn -1 :quality-fiber 1)
- (defrep 23 700 :pact-of-silence :strong-leather 2 :strong-yarn 2 :iron-rivet 6 )
- (defrep 24 720 :legguards-of-vengeance :strong-leather 2 :strong-yarn 4 :iron-rivet 8 )
- (defrep 25 740 :bone-chestplate :strong-leather 3 :strong-yarn 3 :iron-rivet 10 :spruce-bark 1)
- (defrep 26 760 :promise-of-ruins :strong-leather 4 :strong-yarn 2 :iron-rivet 12 :spruce-resin 1)
- (defrep 27 780 :headguard-of-stealth :strong-leather 3 :strong-yarn 5 :iron-rivet 14 :spruce-bark 1)
- (defrep 28 800 :tribute-of-the-gladiator :strong-leather 4 :strong-yarn 4 :iron-rivet 16 :spruce-resin 1))
- (defun init (prof &rest args)
- (apply #'init-params args)
- (case prof
- (enchanter (init-enchanter))
- (weaponsmith (init-weaponsmith))
- (tailor (init-tailor))
- (armorsmith (init-armorsmith))
- (leatherworking (init-leatherworking))
- (t (error "unknown prof")))
- (sort-reps)
- 'done)
- (defun craft-recipe-base (recipe)
- ;; error if level is too low to craft recipe.
- (when (< *cur-lvl* (getf recipe :level))
- (error "ERROR: Crafting recipe [~a][~a], prof level [~a] is too low."
- (getf recipe :name) (getf recipe :level) *cur-lvl*))
- ;; take resources required
- (loop for res in *resources-types*
- do (decf (getf *resources* res 0)
- (getf recipe res 0)))
- ;; apply exp change
- (let* ((mul (max 0 (/ (+ (getf recipe :level) 4 (- *cur-lvl*)) 4))) ; get less exp when level is higher
- (gained-exp (ceiling (* mul *exp-bonus* (getf recipe :exp))))) ; also get bonus exp from scroll
- (incf *cur-exp* gained-exp)
- (loop while (and (< *cur-lvl* 30)
- (>= *cur-exp* (nth *cur-lvl* *levels*)))
- do (decf *cur-exp* (nth *cur-lvl* *levels*))
- do (incf *cur-lvl*)))
- ;; add recipe to 'done' recipes
- (incf (getf *recipes-applied* (getf recipe :name) 0)))
- (defun craft-recipe (recipe &optional (times 1))
- (loop repeat times do (craft-recipe-base recipe)))
- (defun highest-rep ()
- ;; works only if *reps* is sorted!
- (loop for (prev-rep next-rep) on *reps*
- if (or (null next-rep) (< *cur-lvl* (getf next-rep :level)))
- do (return (values prev-rep next-rep))))
- (defun present ()
- (values (loop for tp = (reverse *recipes-applied*) then (cddr tp) until (null tp)
- for (num rep) = tp
- collect rep collect num)
- (loop for tp = *resources* then (cddr tp) until (null tp)
- for (res num) = tp
- unless (zerop num)
- collect res and collect (- num))))
- (defun clear-base ()
- (loop for recipe in *base-reps*
- do (craft-recipe recipe (- (getf *resources* (getf recipe :name) 0)))))
- (defun greed (&optional (target-lvl 30))
- (loop while (< *cur-lvl* target-lvl)
- for rep = (highest-rep)
- do (craft-recipe rep))
- (clear-base)
- (present))
- (defun 50-greed (&optional (target-lvl 30) (repeat-base 50))
- (loop while (< *cur-lvl* target-lvl)
- for (rep next-rep) = (multiple-value-list (highest-rep))
- if (and (base-repp rep) (base-repp next-rep))
- do (craft-recipe rep repeat-base)
- (when (>= *cur-lvl* (getf next-rep :level))
- (craft-recipe next-rep repeat-base))
- else do (craft-recipe rep))
- (clear-base)
- (present))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement