Compare commits
7 Commits
main
...
github/for
Author | SHA1 | Date | |
---|---|---|---|
|
04b3566261 | ||
|
89d2cc73f0 | ||
|
90c6290cea | ||
|
1d5d7c1f40 | ||
|
5c6ae768b8 | ||
|
e65a807f62 | ||
|
9f1d85b5c1 |
@ -1,50 +1,88 @@
|
||||
import Logger from "../util/Logger";
|
||||
import { ActorEntity } from "../game/entities/Actor";
|
||||
import Interface, { Command } from "./Interface";
|
||||
import { GetCurSceneInfoScRsp } from "../data/proto/StarRail";
|
||||
import MazePlaneExcel from "../util/excel/MazePlaneExcel";
|
||||
import MapEntryExcel from "../util/excel/MapEntryExcel";
|
||||
const c = new Logger("/scene", "blue");
|
||||
import Logger from '../util/Logger';
|
||||
import { ActorEntity } from '../game/entities/Actor';
|
||||
import Interface, { Command } from './Interface';
|
||||
import { GetCurSceneInfoScRsp } from '../data/proto/StarRail';
|
||||
import MazePlaneExcel from '../util/excel/MazePlaneExcel';
|
||||
import MapEntryExcel from '../util/excel/MapEntryExcel';
|
||||
const c = new Logger('/scene', 'blue');
|
||||
|
||||
export default async function handle(command: Command) {
|
||||
if (!Interface.target) {
|
||||
c.log("No target specified");
|
||||
return;
|
||||
if (!Interface.target) {
|
||||
c.log('No target specified');
|
||||
return;
|
||||
}
|
||||
|
||||
if (command.args.length == 0) {
|
||||
c.log('Usage: /scene <planeID|floorID>');
|
||||
return;
|
||||
}
|
||||
|
||||
const planeData =
|
||||
MazePlaneExcel.fromFloorId(parseInt(command.args[0])) ||
|
||||
MazePlaneExcel.fromPlaneId(parseInt(command.args[0])); //Get plane data
|
||||
let floorId = 10001001; // Default floor data
|
||||
|
||||
if (planeData!) {
|
||||
if (command.args[0].length === 5) {
|
||||
// If input is planeId
|
||||
floorId = planeData.StartFloorID;
|
||||
} else if (
|
||||
command.args[0].length === 8 &&
|
||||
planeData.FloorIDList.includes(parseInt(command.args[0]))
|
||||
) {
|
||||
// If input is floorId
|
||||
floorId = parseInt(command.args[0]);
|
||||
} else {
|
||||
c.error('cannot find Scene data!', false);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.error('cannot find Scene data!', false);
|
||||
return;
|
||||
}
|
||||
|
||||
const planeID = MazePlaneExcel.fromPlaneId(parseInt(command.args[0]));
|
||||
const entryId = MapEntryExcel.fromFloorId(planeID.StartFloorID).ID;
|
||||
const posData = Interface.target.player.db.posData;
|
||||
|
||||
const lineup2 = await Interface.target.player.getLineup();
|
||||
const curAvatarEntity = new ActorEntity(Interface.target.player.scene, lineup2.avatarList[0].id, posData.pos);
|
||||
const entryId = MapEntryExcel.fromFloorId(planeData.StartFloorID).ID;
|
||||
|
||||
if (!planeID) return c.log("Usage: /scene <planeID>");
|
||||
const posData = Interface.target.player.db.posData;
|
||||
const lineup = await Interface.target.player.getLineup();
|
||||
const curAvatarEntity = new ActorEntity(
|
||||
Interface.target.player.scene,
|
||||
lineup.leaderSlot,
|
||||
posData.pos
|
||||
);
|
||||
|
||||
// Update scene information on player.
|
||||
Interface.target.player.db.posData.planeID = planeID!.PlaneID;
|
||||
Interface.target.player.db.posData.floorID = planeID!.StartFloorID;
|
||||
await Interface.target.player.save()
|
||||
const allowedScenes = ['Train', 'Town', 'Maze']; //Scenes that won't break when you relog
|
||||
// Update scene information on player.
|
||||
if (allowedScenes.includes(planeData.PlaneType)) {
|
||||
Interface.target.player.db.posData.planeID = planeData.PlaneID;
|
||||
Interface.target.player.db.posData.floorID = floorId;
|
||||
await Interface.target.player.save();
|
||||
}
|
||||
|
||||
//ty for tamilpp25 scene
|
||||
Interface.target.send(GetCurSceneInfoScRsp, {
|
||||
retcode: 0,
|
||||
scene: {
|
||||
planeId: planeID.PlaneID,
|
||||
floorId: planeID.StartFloorID,
|
||||
entityList: [
|
||||
curAvatarEntity
|
||||
],
|
||||
entityBuffList: [],
|
||||
entryId: entryId,
|
||||
envBuffList: [],
|
||||
gameModeType: MazePlaneExcel.getGameModeForPlaneType(planeID.PlaneType),
|
||||
lightenSectionList: []
|
||||
},
|
||||
} as unknown as GetCurSceneInfoScRsp);
|
||||
Interface.target.player.scene.spawnEntity(curAvatarEntity, true);
|
||||
//change scene for player
|
||||
Interface.target.send(
|
||||
GetCurSceneInfoScRsp,
|
||||
GetCurSceneInfoScRsp.fromPartial({
|
||||
retcode: 0,
|
||||
scene: {
|
||||
planeId: planeData.PlaneID,
|
||||
floorId: floorId,
|
||||
entityList: [curAvatarEntity.getSceneEntityInfo()],
|
||||
leaderEntityId: curAvatarEntity.entityId,
|
||||
entityBuffList: [],
|
||||
entryId: entryId,
|
||||
envBuffList: [],
|
||||
gameModeType: MazePlaneExcel.getGameModeForPlaneType(
|
||||
planeData.PlaneType
|
||||
),
|
||||
lightenSectionList: [],
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
Interface.target.sync();
|
||||
Interface.target.player.scene.spawnEntity(curAvatarEntity, true);
|
||||
|
||||
c.log(`Scene set to PlaneID: ${planeID.PlaneID}`);
|
||||
Interface.target.sync();
|
||||
|
||||
c.log(`Scene set to floorId: ${floorId}`);
|
||||
}
|
||||
|
@ -25,6 +25,11 @@ export default class MazePlaneExcel {
|
||||
return MazePlaneExcelTable[planeId.toString()];
|
||||
}
|
||||
|
||||
|
||||
public static fromFloorId(floorId: number): MazePlaneExcelTableEntry {
|
||||
return MazePlaneExcelTable[floorId.toString().slice(0,5)];
|
||||
}
|
||||
|
||||
public static getGameModeForPlaneType(planeType: string): number {
|
||||
switch (planeType) {
|
||||
case "Town": return 1;
|
||||
@ -39,7 +44,6 @@ export default class MazePlaneExcel {
|
||||
case "Client": return 10;
|
||||
case "ChallengeActivity": return 11;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user