Skip to content

Commit

Permalink
Add store rooms detection
Browse files Browse the repository at this point in the history
  • Loading branch information
VityaSchel committed Jan 10, 2024
1 parent c6c4d1a commit f5dd344
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 3 deletions.
4 changes: 2 additions & 2 deletions remapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
</style>
</head>
<body style="margin: 0">
<img src="src/assets/map/floor-1.png" onClick="pointRoom(event)" />
<!-- <img src="src/assets/map/floor-1.png" onClick="pointRoom(event)" /> -->
<!-- <img src="src/assets/map/floor-1.png" onClick="pointPos(event)" /> -->
<!-- <img src="src/assets/map/floor-2.png" onClick="pointRoom(event)" /> -->
<!-- <img src="src/assets/map/floor-2.png" onClick="pointPos(event)" /> -->
<!-- <img src="src/assets/map/floor-3.png" onClick="pointRoom(event)" /> -->
<img src="src/assets/map/floor-3.png" onClick="pointRoom(event)" />
<!-- <img src="src/assets/map/floor-3.png" onClick="pointPos(event)" /> -->

<script>
Expand Down
1 change: 1 addition & 0 deletions src/assets/maya-friend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,31 @@ export const floors: { stairs: { x: number, y: number }, rooms: Room[], points:
'room': 114,
'x': 1080,
'y': 806
},
{
'room': 450,
'x': 935,
'y': 607
},
{
'room': 458,
'x': 1526,
'y': 402
},
{
'room': 462,
'x': 1144,
'y': 644
},
{
'room': 451,
'x': 836,
'y': 1127
},
{
'room': 461,
'x': 439,
'y': 779
}
],
points: [
Expand Down Expand Up @@ -475,6 +500,36 @@ export const floors: { stairs: { x: number, y: number }, rooms: Room[], points:
'room': 221,
'x': 1501,
'y': 292
},
{
'room': 463,
'x': 435,
'y': 769
},
{
'room': 460,
'x': 944,
'y': 610
},
{
'room': 465,
'x': 1529,
'y': 396
},
{
'room': 455,
'x': 1116,
'y': 651
},
{
'room': 453,
'x': 1232,
'y': 773
},
{
'room': 456,
'x': 815,
'y': 1165
}
],
points: [
Expand Down Expand Up @@ -755,6 +810,16 @@ export const floors: { stairs: { x: number, y: number }, rooms: Room[], points:
'room': 302,
'x': 322,
'y': 529
},
{
'room': 457,
'x': 524,
'y': 335
},
{
'room': 464,
'x': 365,
'y': 674
}
],
points: [
Expand Down
78 changes: 77 additions & 1 deletion src/radar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,43 @@ export function initRadar() {
jimmysFloor.append(jimmysFloorSpan)
radar.append(jimmysFloor)

const friends: HTMLDivElement[] = []
const createFriends = () => {
for (let i = 0; i < 5; i++) {
const friend = document.createElement('div')
const friendImg = document.createElement('img')
friendImg.src = 'cheats/assets/maya-friend.svg'
Object.assign(friendImg.style, {
opacity: '0.75',
width: '100%',
height: '100%'
})
Object.assign(friend.style, {
position: 'absolute',
top: '-999px',
left: '-999px',
zIndex: '1001',
transform: 'translate(-50%, -50%)'
})
friend.appendChild(friendImg)
radar.appendChild(friend)
friend.className = 'friend'
friends.push(friend)
}
}

createFriends()

const changeFloors = () => {
moveFriends()
if (window.floor >= 2) {
map.src = `cheats/assets/map/floor-${window.floor - 1}.png`
radar.style.display = 'block'

if (window.floor !== window.jhfloor) {
jimmy.style.display = 'none'
jimmysFloor.style.display = 'flex'
jimmysFloorSpan.innerText = window.jhfloor === 5 ? '--' : String(window.jhfloor - 1)
jimmysFloorSpan.innerText = (window.jhfloor === 5 || window.jhfloor === 0) ? '--' : String(window.jhfloor - 1)
} else {
jimmy.style.display = 'block'
jimmysFloor.style.display = 'none'
Expand Down Expand Up @@ -171,6 +199,32 @@ export function initRadar() {
}
}

const moveFriends = () => {
const floorMap = floors[window.floor - 2]
if (!floorMap) {
return
}

const guestRooms = window.guestrooms
.filter((_, index) => window.guestsin[index] === 1)
.filter(room => floorMap.rooms.some(r => r.room === room))
.map(room => floorMap.rooms.find(r => r.room === room)!)

friends.forEach(friend => {
Object.assign(friend.style, {
left: '-999px',
top: '-999px'
})
})

guestRooms.forEach((friendRoom, index) => {
const friendElement = friends[index]
const { x, y } = calculatePosition(friendRoom.x, friendRoom.y)
friendElement.style.left = `${x}px`
friendElement.style.top = `${y}px`
})
}

let currentRadarScale = 'mini'
const scaleRadar = (level: 'hide' | 'mini' | 'full') => {
if (window.floor < 2) return
Expand Down Expand Up @@ -215,8 +269,17 @@ export function initRadar() {

jimmy.style.width = 'auto'
jimmy.style.height = '5%'

friends.forEach(friend => {
Object.assign(friend.style, {
width: 'auto',
height: '5%'
})
})

moveMaya(true)
moveJimmy(true)
moveFriends()
} else if(level === 'mini') {
radar.style.display = 'block'
radar.style.width = '300px'
Expand Down Expand Up @@ -254,8 +317,17 @@ export function initRadar() {

jimmy.style.width = '5%'
jimmy.style.height = 'auto'

friends.forEach(friend => {
Object.assign(friend.style, {
width: '5%',
height: 'auto'
})
})

moveMaya(true)
moveJimmy(true)
moveFriends()
} else if(level === 'hide') {
radar.style.display = 'none'
}
Expand Down Expand Up @@ -316,6 +388,10 @@ export function initRadar() {
moveJimmy()
})

onPropertyChange('stairs', () => {
moveMaya()
})

changeFloors()

document.addEventListener('keydown', (event) => {
Expand Down
2 changes: 2 additions & 0 deletions src/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface Window {
jhinroom: number
menon: 0 | 1
stairs: number
guestrooms: [number, number, number, number, number]
guestsin: [(0 | 1), (0 | 1), (0 | 1), (0 | 1), (0 | 1)]
}

0 comments on commit f5dd344

Please sign in to comment.