From 118df5656d0dcaad9680d263145d568aa3f5c3b6 Mon Sep 17 00:00:00 2001 From: tamilpp25 Date: Fri, 5 Aug 2022 08:49:27 +0530 Subject: [PATCH] improve scene command (#42) Co-authored-by: TheLostTree <65834918+TheLostTree@users.noreply.github.com> --- src/commands/scene.ts | 42 +++++++++++++++++++++++++------- src/util/excel/MazePlaneExcel.ts | 4 +++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/commands/scene.ts b/src/commands/scene.ts index 8f95087..a869542 100644 --- a/src/commands/scene.ts +++ b/src/commands/scene.ts @@ -11,26 +11,50 @@ export default async function handle(command: Command) { return; } - const planeID = MazePlaneExcel.fromPlaneId(parseInt(command.args[0])) - const uid = Interface.target.player.db._id; + if(command.args.length == 0){ + c.log("Usage: /scene "); + return; + } + + const plane = MazePlaneExcel.fromFloorId(parseInt(command.args[0])) || MazePlaneExcel.fromPlaneId(parseInt(command.args[0])) //Get plane data + let floorId = 10001001 // Default floor data + + if(plane!){ + if(command.args[0].length === 5){//PLANE ID LOGIC + floorId = plane.StartFloorID; + }else if(command.args[0].length === 8){//FLOOR ID LOGIC + if(plane! && plane.FloorIDList.includes(parseInt(command.args[0]))){ + floorId = parseInt(command.args[0]); + }else{ + c.error("cannot find Scene data!"); + return; + } + }else{ + c.error("Invalid FloorID / PlaneID length!"); + return; + } + }else{ + c.error("cannot find Scene data!"); + return; + } + 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 lineup = await Interface.target.player.getLineup(); + const curAvatarEntity = new ActorEntity(Interface.target.player.scene, lineup.leaderSlot, posData.pos); - if (!planeID) return c.log("Usage: /scene "); + const planeId = parseInt(floorId.toString().slice(0,5)); // 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() - //ty for tamilpp25 scene Interface.target.send(GetCurSceneInfoScRsp, { retcode: 0, scene: { - planeId: planeID.PlaneID, - floorId: planeID.StartFloorID, + planeId: planeId, + floorId: floorId, entityList: [ curAvatarEntity ], @@ -45,5 +69,5 @@ export default async function handle(command: Command) { Interface.target.sync(); - c.log(`Scene set to PlaneID: ${planeID.PlaneID}`); + c.log(`Scene set to floorId: ${floorId}`); } diff --git a/src/util/excel/MazePlaneExcel.ts b/src/util/excel/MazePlaneExcel.ts index 03d3bd6..be8ecaf 100644 --- a/src/util/excel/MazePlaneExcel.ts +++ b/src/util/excel/MazePlaneExcel.ts @@ -55,6 +55,10 @@ export default class MazePlaneExcel { public static fromPlaneId(planeId: number): MazePlaneExcelTableEntry { return MazePlaneExcelTable[planeId.toString()]; } + + public static fromFloorId(floorId: number): MazePlaneExcelTableEntry { + return MazePlaneExcelTable[floorId.toString().slice(0,5)]; + } public static getEntry(entryId: number): MapEntryExcelTableEntry { return MapEntryExcelTable[entryId.toString()];