Skip to content

Commit e4c3aa0

Browse files
committed
Added magic, beans, and update info
1 parent aabf272 commit e4c3aa0

File tree

9 files changed

+177
-39
lines changed

9 files changed

+177
-39
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheatmenu",
3-
"version": "0.1.0a",
3+
"version": "0.1.1",
44
"description": "A basic GUI for cheating in items. (Should be) OoTOnline safe",
55
"main": "cheatmenu.js",
66
"scripts": {

src/cheatmenu/cheatmenu.ts

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import Vector3 from 'modloader64_api/math/Vector3';
99
class cheatmenu_config{
1010
"hearts": number;
1111
"heartsLocked": boolean;
12+
"magic": number;
13+
"magicLocked": boolean;
1214
"rupees": number;
1315
"rupeesLocked": boolean;
1416
"time": number;
@@ -27,11 +29,13 @@ class cheatmenu_config{
2729
"bombsLocked": boolean;
2830
"bombchus": number;
2931
"bombchusLocked": boolean;
32+
"beans": number;
33+
"beansLocked": boolean;
3034
"arrows": number;
3135
"arrowsLocked": boolean;
32-
[key: string]: any;
3336
constructor(){
3437
this.heartsLocked = false;
38+
this.magicLocked = false;
3539
this.rupeesLocked = false;
3640
this.timeLocked = false;
3741
this.position = new Vector3(0, 0, 0);
@@ -43,6 +47,7 @@ class cheatmenu_config{
4347
this.seedsLocked = false;
4448
this.bombsLocked = false;
4549
this.bombchusLocked = false;
50+
this.beansLocked = false;
4651
this.arrowsLocked = false;
4752
}
4853
}
@@ -69,8 +74,11 @@ class cheatmenu implements IPlugin{
6974
if(this.config.heartsLocked){
7075
this.core.save.health = this.config.hearts;
7176
}
77+
if(this.config.magicLocked){
78+
this.core.save.magic_current = this.config.magic;
79+
}
7280
if(this.config.rupeesLocked){
73-
this.ModLoader.emulator.rdramWrite16(0x11A604, this.config.rupees);
81+
this.core.save.rupee_count = this.config.rupees;
7482
}
7583
if(this.config.timeLocked){
7684
this.core.save.world_time = this.config.time;
@@ -90,6 +98,9 @@ class cheatmenu implements IPlugin{
9098
if(this.config.bombchusLocked){
9199
this.core.save.inventory.bombchuCount = this.config.bombchus;
92100
}
101+
if(this.config.beansLocked){
102+
this.core.save.inventory.magicBeansCount = this.config.beans;
103+
}
93104
if(this.config.arrowsLocked){
94105
this.core.save.inventory.arrows = this.config.arrows;
95106
}
@@ -98,6 +109,51 @@ class cheatmenu implements IPlugin{
98109
// ... Set upwards velocity (?)
99110
this.ModLoader.emulator.rdramWrite16(0x1daa90, 0x40cb);
100111
}
112+
113+
if(this.config.hearts !== this.core.save.health){
114+
this.config.hearts = this.core.save.health;
115+
this.ModLoader.gui.tunnel.send("cheatmenu:HealthUpdate", this.config.hearts);
116+
}
117+
if(this.config.magic !== this.core.save.magic_current){
118+
this.config.magic = this.core.save.magic_current;
119+
this.ModLoader.gui.tunnel.send("cheatmenu:MagicUpdate", this.config.magic);
120+
}
121+
if(this.config.rupees !== this.core.save.rupee_count){
122+
this.config.rupees = this.core.save.rupee_count;
123+
this.ModLoader.gui.tunnel.send("cheatmenu:RupeeUpdate", this.config.rupees);
124+
}
125+
if(this.config.time !== this.core.save.world_time){
126+
this.config.time = this.core.save.world_time;
127+
this.ModLoader.gui.tunnel.send("cheatmenu:TimeUpdate", this.config.time);
128+
}
129+
if(this.config.dekuNuts !== this.core.save.inventory.dekuNutsCount){
130+
this.config.dekuNuts = this.core.save.inventory.dekuNutsCount;
131+
this.ModLoader.gui.tunnel.send("cheatmenu:DekuNutUpdate", this.config.dekuNuts);
132+
}
133+
if(this.config.dekuSticks !== this.core.save.inventory.dekuSticksCount){
134+
this.config.dekuSticks = this.core.save.inventory.dekuSticksCount;
135+
this.ModLoader.gui.tunnel.send("cheatmenu:DekuStickUpdate", this.config.dekuSticks);
136+
}
137+
if(this.config.seeds !== this.core.save.inventory.dekuSeeds){
138+
this.config.seeds = this.core.save.inventory.dekuSeeds;
139+
this.ModLoader.gui.tunnel.send("cheatmenu:SeedUpdate", this.config.seeds);
140+
}
141+
if(this.config.bombs !== this.core.save.inventory.bombsCount){
142+
this.config.bombs = this.core.save.inventory.bombsCount;
143+
this.ModLoader.gui.tunnel.send("cheatmenu:BombUpdate", this.config.bombs);
144+
}
145+
if(this.config.bombchus !== this.core.save.inventory.bombchuCount){
146+
this.config.bombchus = this.core.save.inventory.bombchuCount;
147+
this.ModLoader.gui.tunnel.send("cheatmenu:BombchuUpdate", this.config.bombchus);
148+
}
149+
if(this.config.beans !== this.core.save.inventory.magicBeansCount){
150+
this.config.beans = this.core.save.inventory.magicBeansCount;
151+
this.ModLoader.gui.tunnel.send("cheatmenu:BeanUpdate", this.config.bombchus);
152+
}
153+
if(this.config.arrows !== this.core.save.inventory.arrows){
154+
this.config.arrows = this.core.save.inventory.arrows;
155+
this.ModLoader.gui.tunnel.send("cheatmenu:ArrowUpdate", this.config.arrows);
156+
}
101157
if(this.config.position.x !== this.core.link.position.getRawPos().readFloatBE(0) || this.config.position.y !== this.core.link.position.getRawPos().readFloatBE(4) || this.config.position.z !== this.core.link.position.getRawPos().readFloatBE(8)){
102158
this.config.position.x = this.core.link.position.getRawPos().readFloatBE(0);
103159
this.config.position.y = this.core.link.position.getRawPos().readFloatBE(4);
@@ -122,38 +178,23 @@ class cheatmenu implements IPlugin{
122178

123179
update(){
124180
this.core.save.health = this.config.hearts;
181+
this.core.save.magic_current = this.config.magic;
125182
this.core.save.world_time = this.config.time
126-
this.ModLoader.emulator.rdramWrite16(0x11A604, this.config.rupees);
183+
this.core.save.rupee_count = this.config.rupees;
127184
this.core.save.inventory.dekuNutsCount = this.config.dekuNuts;
128185
this.core.save.inventory.dekuSticksCount = this.config.dekuSticks;
129186
this.core.save.inventory.dekuSeeds = this.config.seeds;
130187
this.core.save.inventory.bombsCount = this.config.bombs;
131188
this.core.save.inventory.bombchuCount = this.config.bombchus;
189+
this.core.save.inventory.magicBeansCount = this.config.beans;
132190
this.core.save.inventory.arrows = this.config.arrows;
133191
}
134192

135-
requestRefresh(){
136-
this.config.hearts = this.core.save.health;
137-
this.config.time = this.core.save.world_time;
138-
this.config.rupees = this.ModLoader.emulator.rdramRead16(0x11A604);
139-
this.config.dekuNuts = this.core.save.inventory.dekuNutsCount;
140-
this.config.dekuSticks = this.core.save.inventory.dekuSticksCount;
141-
this.config.seeds = this.core.save.inventory.dekuSeeds;
142-
this.config.bombs = this.core.save.inventory.bombsCount;
143-
this.config.bombchus = this.core.save.inventory.bombchuCount;
144-
this.config.arrows = this.core.save.inventory.arrows;
145-
this.ModLoader.gui.tunnel.send("cheatmenu:CheatUpdate", this.config);
146-
}
147193

148194
@EventHandler(OotEvents.ON_SAVE_LOADED)
149-
onSaveLoaded(){
195+
requestRefresh(){
150196
this.saveLoaded = true;
151-
this.requestRefresh();
152-
}
153-
154-
@TunnelMessageHandler("cheatmenu:RequestRefresh")
155-
onRequestRefresh(){
156-
this.requestRefresh();
197+
this.ModLoader.gui.tunnel.send("cheatmenu:SaveUpdate", this.config);
157198
}
158199
}
159200

src/cheatmenu/gui/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,34 @@
33
<head>
44
<title>Cheat Menu</title>
55
<style>
6+
html {
7+
padding: 0%;
8+
margin: 0%;
9+
border: 0%;
10+
min-width: 100%;
11+
min-height: 100%;
12+
}
613

14+
.bottom-right {
15+
position: fixed;
16+
bottom: 0;
17+
right: 0;
18+
}
719
</style>
820
</head>
921
<body>
22+
<div class="bottom-right">0.1.1</div>
1023
<table>
1124
<tr>
1225
<td><input id="heartsLocked" type="checkbox"></td>
1326
<td>Hearts: </td>
1427
<td><input id="hearts" type="number" min="0" max="20" step="1"> + <input id="qhearts" type="number" min="0" max="3" step="1">/4</td>
1528
</tr>
29+
<tr>
30+
<td><input id="magicLocked" type="checkbox"></td>
31+
<td>Magic: </td>
32+
<td><input id="magic" type="number" min="0" max="48">
33+
</tr>
1634
<tr>
1735
<td><input id="rupeesLocked" type="checkbox"></td>
1836
<td>Rupees: </td>
@@ -48,6 +66,11 @@
4866
<td>Bombchus: </td>
4967
<td><input id="bombchus" type="number" min="0" max="99" step="1"></td>
5068
</tr>
69+
<tr>
70+
<td><input id="beansLocked" type="checkbox"></td>
71+
<td>Magic Beans: </td>
72+
<td><input id="beans" type="number" min="0" max="99" step="1"></td>
73+
</tr>
5174
<tr>
5275
<td><input id="arrowsLocked" type="checkbox"></td>
5376
<td>Arrows: </td>

src/cheatmenu/gui/index.ts

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,40 @@ class MapMessageHandlers {
1717
this.tunnel.setupMessageProcessor(this);
1818
}
1919

20-
@TunnelMessageHandler("cheatmenu:CheatUpdate")
21-
onUpdate(evt: any){
20+
@TunnelMessageHandler("cheatmenu:SaveUpdate")
21+
onSaveUpdate(evt: any){
2222
config = evt;
2323
applyBtn.disabled = false;
24-
hearts.valueAsNumber = Math.floor(evt.hearts / 16) as number;
25-
qhearts.valueAsNumber = Math.floor((evt.hearts / 4) % 4) as number;
26-
rupees.valueAsNumber = evt.rupees as number;
27-
hour.valueAsNumber = Math.floor(evt.time / (65535 / 24)) as number;
28-
minute.valueAsNumber = Math.floor((evt.time % (65535 / 24)) / (65535 / (24 * 60))) as number;
29-
dekuNuts.valueAsNumber = evt.dekuNuts as number;
30-
dekuSticks.valueAsNumber = evt.dekuSticks as number;
31-
seeds.valueAsNumber = evt.seeds as number;
32-
bombs.valueAsNumber = evt.bombs as number;
33-
bombchus.valueAsNumber = evt.bombchus as number;
34-
arrows.valueAsNumber = evt.arrows as number;
24+
}
25+
26+
@TunnelMessageHandler("cheatmenu:HealthUpdate")
27+
onHealthUpdate(eHealth: number){
28+
if(!document.hasFocus()){
29+
hearts.valueAsNumber = Math.floor(eHealth / 16);
30+
qhearts.valueAsNumber = Math.floor((eHealth / 4) % 4);
31+
}
32+
}
33+
34+
@TunnelMessageHandler("cheatmenu:MagicUpdate")
35+
onMagicUpdate(eMagic: number){
36+
if(!document.hasFocus()){
37+
magic.valueAsNumber = eMagic / 2;
38+
}
39+
}
40+
41+
@TunnelMessageHandler("cheatmenu:RupeeUpdate")
42+
onRupeeUpdate(eRupees: number){
43+
if(!document.hasFocus()){
44+
rupees.valueAsNumber = eRupees;
45+
}
46+
}
47+
48+
@TunnelMessageHandler("cheatmenu:TimeUpdate")
49+
onTimeUpdate(evt: number){
50+
if(!document.hasFocus()){
51+
hour.valueAsNumber = Math.floor(evt / (65535 / 24));
52+
minute.valueAsNumber = Math.floor((evt % (65535 / 24)) / (65535 / (24 * 60)));
53+
}
3554
}
3655

3756
@TunnelMessageHandler("cheatmenu:PositionUpdate")
@@ -47,13 +66,62 @@ class MapMessageHandlers {
4766
// rotY.value = evt.y.toFixed(2);
4867
// rotZ.value = evt.z.toFixed(2);
4968
// }
69+
70+
@TunnelMessageHandler("cheatmenu:DekuNutUpdate")
71+
onDekuNutUpdate(eDekuNuts: number){
72+
dekuNuts.valueAsNumber = eDekuNuts;
73+
}
74+
75+
@TunnelMessageHandler("cheatmenu:DekuStickUpdate")
76+
onDekuStickUpdate(eDekuSticks: number){
77+
if(!document.hasFocus()){
78+
dekuSticks.valueAsNumber = eDekuSticks;
79+
}
80+
}
81+
82+
@TunnelMessageHandler("cheatmenu:SeedUpdate")
83+
onSeedUpdate(eSeeds: number){
84+
if(!document.hasFocus()){
85+
seeds.valueAsNumber = eSeeds;
86+
}
87+
}
88+
89+
@TunnelMessageHandler("cheatmenu:BombUpdate")
90+
onBombUpdate(eBombs: number){
91+
if(!document.hasFocus()){
92+
bombs.valueAsNumber = eBombs;
93+
}
94+
}
95+
96+
@TunnelMessageHandler("cheatmenu:BombchuUpdate")
97+
onBombchuUpdate(eBombchus: number){
98+
if(!document.hasFocus()){
99+
bombchus.valueAsNumber = eBombchus;
100+
}
101+
}
102+
103+
@TunnelMessageHandler("cheatmenu:BeanUpdate")
104+
onBeanUpdate(eBeans: number){
105+
if(!document.hasFocus()){
106+
beans.valueAsNumber = eBeans;
107+
}
108+
}
109+
110+
@TunnelMessageHandler("cheatmenu:ArrowUpdate")
111+
onArrowUpdate(eArrows: number){
112+
if(!document.hasFocus()){
113+
arrows.valueAsNumber = eArrows;
114+
}
115+
}
50116
}
51117

52118
const handlers = new MapMessageHandlers();
53119

54120
let hearts = document.getElementById("hearts") as HTMLInputElement;
55121
let qhearts = document.getElementById("qhearts") as HTMLInputElement;
56122
let heartsLocked = document.getElementById("heartsLocked") as HTMLInputElement;
123+
let magic = document.getElementById("magic") as HTMLInputElement;
124+
let magicLocked = document.getElementById("magicLocked") as HTMLInputElement;
57125
let rupees = document.getElementById("rupees") as HTMLInputElement;
58126
let rupeesLocked = document.getElementById("rupeesLocked") as HTMLInputElement;
59127
let hour = document.getElementById("hour") as HTMLInputElement;
@@ -81,6 +149,8 @@ let bombs = document.getElementById("bombs") as HTMLInputElement;
81149
let bombsLocked = document.getElementById("bombsLocked") as HTMLInputElement;
82150
let bombchus = document.getElementById("bombchus") as HTMLInputElement;
83151
let bombchusLocked = document.getElementById("bombchusLocked") as HTMLInputElement;
152+
let beans = document.getElementById("beans") as HTMLInputElement;
153+
let beansLocked = document.getElementById("beansLocked") as HTMLInputElement;
84154
let arrows = document.getElementById("arrows") as HTMLInputElement;
85155
let arrowsLocked = document.getElementById("arrowsLocked") as HTMLInputElement;
86156
let applyBtn = document.getElementById("apply") as HTMLButtonElement;
@@ -89,6 +159,8 @@ applyBtn.addEventListener("click", () => {
89159
if(!applyBtn.disabled){
90160
config.hearts = (hearts.valueAsNumber * 16) + (qhearts.valueAsNumber * 4);
91161
config.heartsLocked = heartsLocked.checked;
162+
config.magic = magic.valueAsNumber * 2;
163+
config.magicLocked = magicLocked.checked;
92164
config.rupees = rupees.valueAsNumber;
93165
config.rupeesLocked = rupeesLocked.checked;
94166
config.time = Math.ceil((hour.valueAsNumber * (65535 / 24)) + (minute.valueAsNumber * (65535 / (24 * 60))));
@@ -105,6 +177,8 @@ applyBtn.addEventListener("click", () => {
105177
config.bombsLocked = bombsLocked.checked;
106178
config.bombchus = bombchus.valueAsNumber;
107179
config.bombchusLocked = bombchusLocked.checked;
180+
config.beans = beans.valueAsNumber;
181+
config.beansLocked = beansLocked.checked;
108182
config.arrows = arrows.valueAsNumber;
109183
config.arrowsLocked = arrowsLocked.checked;
110184
handlers.tunnel.send("forwardToML", {id: "cheatmenu:DataUpdate", data: config});

src/cheatmenu/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheatmenu",
3-
"version": "0.1.0a",
3+
"version": "0.1.1",
44
"description": "A basic GUI for cheating in items. (Should be) OoTOnline safe",
55
"main": "cheatmenu.js",
66
"scripts": {

src/cheatmenu/payloads/E0/dummy.txt

Whitespace-only changes.

src/cheatmenu/payloads/E15/dummy.txt

Whitespace-only changes.

update.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "0.1.0a",
2+
"version": "0.1.1",
33
"url": "https://github.com/JerryWester/ML64OoTCheatMenu/releases/latest/download/cheatmenu.pak"
44
}

0 commit comments

Comments
 (0)