Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task system #4

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ out/jak2/fr3.rar

*.diff
goalc-report.html
.vscode/PythonImportHelper-v2-Completion.json
6 changes: 2 additions & 4 deletions goal_src/jak1/engine/anim/joint.gc
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,8 @@
(when (or (not s5-1) (= (-> s5-1 name) 'default))
(login this) ;; not part of level load, just normal login.
(when (needs-link? this)
(format 0 "bonus link~%")
(link-art! this)
)
)
(format 0 "bonus link~%")
(link-art! this)))
(if s5-1
(set-loaded-art (-> s5-1 art-group) this) ;; part of level load, add to level's ag, but don't log in yet.
))
Expand Down
133 changes: 60 additions & 73 deletions goal_src/jak1/engine/game/game-info.gc
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,68 @@
;; The "perm" data is saved to the memory card.

;; orb count for purposes of the shop
(define *shop-count* 0)

(defenum shop-item-idx
:type uint8
(jump)
(double-jump)
(punch)
(spin-kick)
(crouch)
(roll-jump)
(jump-dive))

(define *shop-length* 7)

;; item names
(define *shop-item* (new 'static 'array string 1
"JUMP"
"DOUBLE JUMP"
"PUNCH"
"SPIN KICK"
"CROUCH"
"ROLL JUMP"
"JUMP DIVE"
))

;; has the item been purchased? (1=N 0=Y, idk ask himham)
(define *shop-first-purchase* (new 'static 'array int 1
1
1
1
1
1
1
1
))

;; how much does an item cost
(define *shop-price* (new 'static 'array int 1
6 ;; min 0 max 6
40 ;; min 40 max 44
100 ;; max 452
100 ;;
100
100
100))

;; how much does an item cost
(define *shop-price-hard* (new 'static 'array int 1
6 ;; min 0 max 6
9999 ;; min 40 max 44
9999 ;; max 452
1462 ;;
9999
9999
9999))

(defun get-shop-price ((idx int))
(if (-> *pc-settings* shop-hard?)
(-> *shop-price-hard* idx)
(-> *shop-price* idx)))

(defun buy ((idx int))
;;(-> *game-info* money-per-level 25)

(defconstant NUM_UNLOCKS 7)

(deftype microtransaction-item (structure)
((idx int)
(name string)
(task game-task)
(price uint32)
(hard-price uint32)))

(deftype microtransaction-info (structure)
((num-items int32)
(items microtransaction-item NUM_UNLOCKS :inline)))

(define-perm *microtransaction-info* microtransaction-info (new 'global 'microtransaction-info))

(defun get-microtransaction-item-by-name ((name string))
(set! (-> *microtransaction-info* num-items) NUM_UNLOCKS)
(dotimes (i (-> *microtransaction-info* num-items))
(format #t "Checking item ~d: name is ~a~%" i (-> *microtransaction-info* items i name))
(if (string= name (-> *microtransaction-info* items i name)) (return (-> *microtransaction-info* items i))))
(the-as microtransaction-item #f))

(defun set-item-param ((self microtransaction-item) (name string) (task game-task) (price int) (hard-price int) (idx int))
(if (> idx NUM_UNLOCKS) (return #f))
(set! (-> self name) (new 'global 'string 15 (the-as string #f))) ;; now you can have at most 128 characters of a string, but you are eating away at global memory
(format (clear (-> self name)) name)
(set! (-> self task) task)
(set! (-> self price) price)
(set! (-> self hard-price) hard-price)
(set! (-> self idx) idx)
;;set active to false as everything will be false on boot
(none))

(defun set-up-microtransaction-info ()
;;(set-item-param (-> *microtransaction-info* items 1) "Jump" (game-task training-buzzer) 3 10 1)
(set-item-param (-> *microtransaction-info* items 0) "JUMP" (game-task jump-unlocked?) 6 6 0)
(set-item-param (-> *microtransaction-info* items 1) "DOUBLE JUMP" (game-task double-jump-unlocked?) 40 9999 1)
(set-item-param (-> *microtransaction-info* items 2) "PUNCH" (game-task punch-unlocked?) 100 9999 2)
(set-item-param (-> *microtransaction-info* items 3) "SPIN KICK" (game-task spin-kick-unlocked?) 100 1462 3)
(set-item-param (-> *microtransaction-info* items 4) "CROUCH" (game-task crouch-unlocked?) 100 9999 4)
(set-item-param (-> *microtransaction-info* items 5) "ROLL JUMP" (game-task roll-jump-unlocked?) 100 9999 5)
(set-item-param (-> *microtransaction-info* items 6) "JUMP DIVE" (game-task jump-dive-unlocked?) 100 9999 6))

(defun get-shop-price ((item microtransaction-item))
(if (-> *pc-settings* shop-hard?) (-> item hard-price) (-> item price)))

(defun buy ((item microtransaction-item))
"purchase the item"
(cond
((!= (-> *shop-first-purchase* idx) 1)
;; already purchased
(sound-play "cursor-options"))
((>= *shop-count* (get-shop-price idx))
;; have the orbs
(sound-play "money-pickup")
(-! *shop-count* (get-shop-price idx))
(set! (-> *shop-first-purchase* idx) 0))
((task-closed? (-> item task) (task-status need-hint))
;; already purchased
(sound-play "cursor-options"))
((>= (-> *game-info* money-per-level 25) (get-shop-price item))
;; have the orbs
(sound-play "money-pickup")
(-! (-> *game-info* money-per-level 25) (get-shop-price item))
(close-specific-task! (-> item task) (task-status need-hint)))
(else
;; you broke MFer
(sound-play "caught-eel"))))
;; you broke MFer
(sound-play "caught-eel"))))

;; DECOMP BEGINS

Expand Down Expand Up @@ -369,7 +356,7 @@
;; if we have all the money in our level, display the all orbs graphic
(if (= (-> this money-per-level level-idx) (-> (get-game-count level-idx) money-count)) (activate-orb-all level-idx)))))))
;; increment our current money count
(+! *shop-count* amount)
(+! (-> *game-info* money-per-level 25) amount)
(+! (-> this money) amount))
(('fuel-cell)
;; got a power cell!
Expand Down
9 changes: 8 additions & 1 deletion goal_src/jak1/engine/game/task/game-task-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,11 @@
(plunger-lurker-hit 113)
(leaving-misty 114)
(assistant-village3 115)
(max 116))
(jump-unlocked? 116)
(double-jump-unlocked? 117)
(punch-unlocked? 118)
(spin-kick-unlocked? 119)
(crouch-unlocked? 120)
(roll-jump-unlocked? 121)
(jump-dive-unlocked? 122)
(max 123))
Loading