Rewrite thrall rewards
This commit is contained in:
		| @@ -59,17 +59,19 @@ export class Floater { | ||||
|     let dist = playerPos.distance(this.xy); | ||||
|     let dir = Math.atan2(this.xy.y - playerPos.y, this.xy.x - playerPos.x); | ||||
|  | ||||
|     if (dist < 0.3) { | ||||
|       this.collect(); | ||||
|     } | ||||
|     let gravityAmt = (0.6 - dist) / 0.6; | ||||
|     gravityAmt = Math.pow(gravityAmt, 0.8); | ||||
|     if (gravityAmt > 0) { | ||||
|       let dx = -Math.cos(dir) * 0.005; | ||||
|       let dy = -Math.sin(dir) * 0.005; | ||||
|       this.velocity = this.velocity.offset( | ||||
|         new Point(gravityAmt * dx, gravityAmt * dy), | ||||
|       ); | ||||
|     if (this.frame >= 60) { | ||||
|       if (dist < 0.5) { | ||||
|         this.collect(); | ||||
|       } | ||||
|       let gravityAmt = (0.6 - dist) / 0.6; | ||||
|       gravityAmt = Math.pow(gravityAmt, 0.8); | ||||
|       if (gravityAmt > 0) { | ||||
|         let dx = -Math.cos(dir) * 0.005; | ||||
|         let dy = -Math.sin(dir) * 0.005; | ||||
|         this.velocity = this.velocity.offset( | ||||
|           new Point(gravityAmt * dx, gravityAmt * dy), | ||||
|         ); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   collect() { | ||||
|   | ||||
| @@ -600,7 +600,7 @@ export class ThrallCollectionPlatePickup { | ||||
|  | ||||
|   update() {} | ||||
|  | ||||
|   onClick(_cell: CellView): boolean { | ||||
|   onClick(cell: CellView): boolean { | ||||
|     let lifeStage = getPlayerProgress().getThrallLifeStage(this.thrall); | ||||
|     let itemStage = getPlayerProgress().getThrallItemStage(this.thrall); | ||||
|     let data = getThralls().get(this.thrall); | ||||
| @@ -650,7 +650,7 @@ export class ThrallCollectionPlatePickup { | ||||
|           }, | ||||
|           null, | ||||
|         ); | ||||
|         data.rewardCallback(); | ||||
|         data.rewardCallback((what) => this.spawn(cell.xy, what)); | ||||
|       } | ||||
|     } | ||||
|  | ||||
| @@ -658,6 +658,29 @@ export class ThrallCollectionPlatePickup { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   spawn(xy: Point, what: Stat | "EXP") { | ||||
|     let callbacks = null; | ||||
|     if (what == "EXP") { | ||||
|       callbacks = new ExperiencePickupCallbacks(); | ||||
|     } else { | ||||
|       callbacks = new StatPickupCallbacks(what); | ||||
|     } | ||||
|     if (callbacks == null) { return; } | ||||
|     let floater = new Floater( | ||||
|       xy.offset(new Point(0.5, 0.5)), | ||||
|       50, | ||||
|       callbacks, | ||||
|     ); | ||||
|     let speed = 0.015; | ||||
|     let direction = Math.random() * Math.PI * 2; | ||||
|     floater.velocity = new Point( | ||||
|       Math.cos(direction) * speed, | ||||
|       Math.sin(direction) * speed * 0.1, | ||||
|     ); | ||||
|     floater.velZ = 0.8; | ||||
|     getHuntMode().spawnFloater(floater); | ||||
|   } | ||||
|  | ||||
|   onSqueeze() {} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -22,7 +22,7 @@ import { | ||||
|   sprThrallStealth, | ||||
| } from "./sprites.ts"; | ||||
| import { Sprite } from "./engine/internal/sprite.ts"; | ||||
| import { getPlayerProgress } from "./playerprogress.ts"; | ||||
| import {Stat} from "./datatypes.ts"; | ||||
|  | ||||
| export type Thrall = { | ||||
|   id: number; | ||||
| @@ -62,7 +62,7 @@ export type ThrallData = { | ||||
|   itemPickupMessage: string; | ||||
|   deliveryMessage: string; | ||||
|   rewardMessage: string; | ||||
|   rewardCallback: () => void; | ||||
|   rewardCallback: (spawn: (what: Stat | "EXP") => void) => void; | ||||
|  | ||||
|   lifeStageText: Record<LifeStage, LifeStageText>; | ||||
| }; | ||||
| @@ -132,8 +132,8 @@ export let thrallParty = table.add({ | ||||
|   deliveryMessage: | ||||
|     '"Oh, that? Yeah, I won it." And then lost it, apparently.\n\nHe\'s elated. He will never leave.', | ||||
|   rewardMessage: "Garrett showers you with INT!", | ||||
|   rewardCallback: () => { | ||||
|     getPlayerProgress().add("INT", 10); | ||||
|   rewardCallback: (spawn) => { | ||||
|     for (let i = 0; i < 30; i++) { spawn("INT"); } | ||||
|   }, | ||||
|   lifeStageText: { | ||||
|     fresh: { | ||||
| @@ -204,8 +204,8 @@ export let thrallLore = table.add({ | ||||
|   deliveryMessage: | ||||
|     "Lupin looks at his own reflection -- with interest, confusion, dismissal, and then deep satisfaction. He loves it. He will never leave.", | ||||
|   rewardMessage: "Lupin showers you with AGI!", | ||||
|   rewardCallback: () => { | ||||
|     getPlayerProgress().add("AGI", 10); | ||||
|   rewardCallback: (spawn) => { | ||||
|     for (let i = 0; i < 30; i++) { spawn("AGI"); } | ||||
|   }, | ||||
|   lifeStageText: { | ||||
|     fresh: { | ||||
| @@ -273,9 +273,9 @@ export let thrallBat = table.add({ | ||||
|   deliveryMessage: | ||||
|     'Monica salivates. "This is... this is... simply exquisite!"\n\nShe is happy. She will never leave.', | ||||
|   rewardMessage: "Monica showers you with CHA and INT!", | ||||
|   rewardCallback: () => { | ||||
|     getPlayerProgress().add("CHA", 5); | ||||
|     getPlayerProgress().add("INT", 5); | ||||
|   rewardCallback: (spawn) => { | ||||
|     for (let i = 0; i < 15; i++) { spawn("CHA"); } | ||||
|     for (let i = 0; i < 15; i++) { spawn("INT"); } | ||||
|   }, | ||||
|   lifeStageText: { | ||||
|     fresh: { | ||||
| @@ -343,8 +343,8 @@ export let thrallCharm = table.add({ | ||||
|   deliveryMessage: | ||||
|     "Renfield inhales sharply and widens his stance, trying to hide his physical reaction to your face. He is elated and will never leave.", | ||||
|   rewardMessage: "Renfield showers you with PSI!", | ||||
|   rewardCallback: () => { | ||||
|     getPlayerProgress().add("PSI", 10); | ||||
|   rewardCallback: (spawn) => { | ||||
|     for (let i = 0; i < 24; i++) { spawn("PSI"); } | ||||
|   }, | ||||
|   lifeStageText: { | ||||
|     fresh: { | ||||
| @@ -410,9 +410,9 @@ export let thrallStealth = table.add({ | ||||
|   deliveryMessage: | ||||
|     "\"That? That's not mine.\" But she wants it. Now it's hers. She will never leave.", | ||||
|   rewardMessage: "Narthyss showers you with CHA and AGI!", | ||||
|   rewardCallback: () => { | ||||
|     getPlayerProgress().add("CHA", 5); | ||||
|     getPlayerProgress().add("AGI", 5); | ||||
|   rewardCallback: (spawn) => { | ||||
|     for (let i = 0; i < 15; i++) { spawn("CHA"); } | ||||
|     for (let i = 0; i < 15; i++) { spawn("AGI"); } | ||||
|   }, | ||||
|   lifeStageText: { | ||||
|     fresh: { | ||||
| @@ -479,8 +479,8 @@ export let thrallStare = table.add({ | ||||
|   deliveryMessage: | ||||
|     "Ridley admires the gear but -- to your surprise -- refuses to jam it into its brain.\n\nThe pup is elated and will never leave.", | ||||
|   rewardMessage: "Ridley showers you with EXP!", | ||||
|   rewardCallback: () => { | ||||
|     getPlayerProgress().addExperience(100); | ||||
|   rewardCallback: (spawn) => { | ||||
|     for (let i = 0; i < 6; i++) { spawn("EXP"); } | ||||
|   }, | ||||
|   lifeStageText: { | ||||
|     fresh: { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user