(Only) Enter Forgotten Hall, Set Game Mode, Clean Up Map/Maze Excels (#56)
* Implement avatar levelup and promotion. * Clean up maz and map excels, set the correct game mode based on plane type, make forgotten hall enterable. * Remove non-working spawn command.
This commit is contained in:
parent
5e1209deba
commit
22cd1f6ba1
@ -3,6 +3,7 @@ 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) {
|
||||
@ -11,8 +12,8 @@ export default async function handle(command: Command) {
|
||||
return;
|
||||
}
|
||||
|
||||
const planeID = MazePlaneExcel.fromPlaneId(parseInt(command.args[0]))
|
||||
const uid = Interface.target.player.db._id;
|
||||
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();
|
||||
@ -35,9 +36,9 @@ export default async function handle(command: Command) {
|
||||
curAvatarEntity
|
||||
],
|
||||
entityBuffList: [],
|
||||
entryId: 10001,
|
||||
entryId: entryId,
|
||||
envBuffList: [],
|
||||
gameModeType: 1,
|
||||
gameModeType: MazePlaneExcel.getGameModeForPlaneType(planeID.PlaneType),
|
||||
lightenSectionList: []
|
||||
},
|
||||
} as unknown as GetCurSceneInfoScRsp);
|
||||
|
@ -13,9 +13,11 @@ export class Scene {
|
||||
public spawnEntity(entity: Entity, silent: boolean = false) {
|
||||
this.entities.set(entity.entityId, entity);
|
||||
if (!silent) {
|
||||
this.player.session.send(SceneEntityUpdateScNotify, {
|
||||
const dataObj : SceneEntityUpdateScNotify = {
|
||||
entityList: [entity.getSceneEntityInfo()]
|
||||
} as SceneEntityUpdateScNotify);
|
||||
};
|
||||
|
||||
this.player.session.send(SceneEntityUpdateScNotify, dataObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,15 +10,16 @@ export class ActorEntity extends Entity
|
||||
super(scene, pos, rot);
|
||||
}
|
||||
|
||||
public getSceneEntityInfo(): SceneEntityInfo {
|
||||
const sceneEntityInfo = super.getSceneEntityInfo();
|
||||
sceneEntityInfo.actor = {
|
||||
public getSceneActorInfo(): SceneEntityInfo {
|
||||
return {
|
||||
...super.getSceneEntityInfo(),
|
||||
actor: {
|
||||
avatarType: AvatarType.AVATAR_FORMAL_TYPE,
|
||||
baseAvatarId: this.avatarId,
|
||||
uid: this.scene.player.db._id,
|
||||
mapLayer: 0 //?
|
||||
}
|
||||
};
|
||||
return sceneEntityInfo;
|
||||
}
|
||||
|
||||
public getEntityType(): EntityType {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { EnterMazeCsReq, EnterMazeScRsp } from "../../data/proto/StarRail";
|
||||
import MapEntryExcel from "../../util/excel/MapEntryExcel";
|
||||
import MazePlaneExcel from "../../util/excel/MazePlaneExcel";
|
||||
import Packet from "../kcp/Packet";
|
||||
import Session from "../kcp/Session";
|
||||
@ -6,7 +7,8 @@ import Session from "../kcp/Session";
|
||||
export default async function handle(session: Session, packet: Packet) {
|
||||
const body = packet.body as EnterMazeCsReq;
|
||||
|
||||
const mazeEntry = MazePlaneExcel.getEntry(body.entryId);
|
||||
const mazeEntry = MapEntryExcel.fromId(body.entryId);
|
||||
const mazePlane = MazePlaneExcel.fromPlaneId(mazeEntry.PlaneID);
|
||||
|
||||
let curLineup = await session.player.getLineup();
|
||||
curLineup.planeId = mazeEntry.PlaneID;
|
||||
@ -23,7 +25,7 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
scene: {
|
||||
planeId: mazeEntry.PlaneID,
|
||||
floorId: mazeEntry.FloorID,
|
||||
gameModeType: 1,
|
||||
gameModeType: MazePlaneExcel.getGameModeForPlaneType(mazePlane.PlaneType),
|
||||
}
|
||||
},
|
||||
id: mazeEntry.PlaneID,
|
||||
|
@ -1,28 +1,38 @@
|
||||
import { GetCurSceneInfoScRsp, Vector } from "../../data/proto/StarRail";
|
||||
import { GetCurSceneInfoScRsp, MotionInfo, SceneEntityInfo, SceneNpcMonsterInfo, Vector } from "../../data/proto/StarRail";
|
||||
import { ActorEntity } from "../../game/entities/Actor";
|
||||
import MapEntryExcel from "../../util/excel/MapEntryExcel";
|
||||
import MazePlaneExcel from "../../util/excel/MazePlaneExcel";
|
||||
import Packet from "../kcp/Packet";
|
||||
import Session from "../kcp/Session";
|
||||
|
||||
export default async function handle(session: Session, packet: Packet) {
|
||||
// Get data.
|
||||
const posData = session.player.db.posData;
|
||||
const _lineup = session.player.db.lineup;
|
||||
const lineup = _lineup.lineups[_lineup.curIndex];
|
||||
const curAvatarEntity = new ActorEntity(session.player.scene, lineup.avatarList[0], posData.pos);
|
||||
const curAvatarEntity = new ActorEntity(session.player.scene, lineup.avatarList[lineup.leaderSlot], posData.pos);
|
||||
const entryId = MapEntryExcel.fromFloorId(posData.floorID).ID;
|
||||
const mazePlane = MazePlaneExcel.fromPlaneId(posData.planeID);
|
||||
|
||||
// Scene management.
|
||||
session.player.scene.spawnEntity(curAvatarEntity, true);
|
||||
session.player.scene.entryId = entryId;
|
||||
|
||||
// Send response.
|
||||
session.send(GetCurSceneInfoScRsp, {
|
||||
retcode: 0,
|
||||
scene: {
|
||||
planeId: posData.planeID,
|
||||
floorId: posData.floorID,
|
||||
entityList: [
|
||||
curAvatarEntity
|
||||
curAvatarEntity.getSceneEntityInfo()
|
||||
],
|
||||
lightenSectionList: [],
|
||||
leaderEntityId: curAvatarEntity.entityId,
|
||||
entityBuffList: [],
|
||||
entryId: 10001,
|
||||
entryId: entryId,
|
||||
envBuffList: [],
|
||||
gameModeType: 1,
|
||||
lightenSectionList: []
|
||||
gameModeType: MazePlaneExcel.getGameModeForPlaneType(mazePlane.PlaneType),
|
||||
},
|
||||
} as unknown as GetCurSceneInfoScRsp);
|
||||
session.player.scene.spawnEntity(curAvatarEntity, true);
|
||||
session.player.scene.entryId = 10001;
|
||||
} as GetCurSceneInfoScRsp);
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { GetMazeMapInfoCsReq, GetMazeMapInfoScRsp } from "../../data/proto/StarRail";
|
||||
import MapEntryExcel from "../../util/excel/MapEntryExcel";
|
||||
import MappingInfoExcel from "../../util/excel/MappingInfoExcel";
|
||||
import MazePlaneExcel from "../../util/excel/MazePlaneExcel";
|
||||
import Packet from "../kcp/Packet";
|
||||
@ -24,7 +25,7 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
dataObj.lightenSectionList.push(i)
|
||||
}
|
||||
|
||||
dataObj.unlockTeleportList = MazePlaneExcel.getAllEntries().map(x => x.ID);
|
||||
dataObj.unlockTeleportList = MapEntryExcel.all().map(x => x.ID);
|
||||
|
||||
session.send(GetMazeMapInfoScRsp, dataObj);
|
||||
}
|
@ -5,6 +5,7 @@ import Session from "../kcp/Session";
|
||||
|
||||
export default async function handle(session: Session, packet: Packet) {
|
||||
const body = packet.body as SceneEntityMoveCsReq;
|
||||
|
||||
if (session.player.scene.entryId !== body.entryId) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,49 +1,49 @@
|
||||
import { ChallengeStatus, ExtraLineupType, StartChallengeCsReq, StartChallengeScRsp } from "../../data/proto/StarRail";
|
||||
import { ChallengeStatus, CurChallenge, ExtraLineupType, Maze, SceneActorInfo, SceneEntityInfo, SceneInfo, SceneNpcInfo, SceneNpcMonsterInfo, ScenePropInfo, StartChallengeCsReq, StartChallengeScRsp } from "../../data/proto/StarRail";
|
||||
import { ActorEntity } from "../../game/entities/Actor";
|
||||
import Packet from "../kcp/Packet";
|
||||
import Session from "../kcp/Session";
|
||||
|
||||
// StartChallengeCsReq { challengeId: 101 }
|
||||
export default async function handle(session: Session, packet: Packet) {
|
||||
const body = packet.body as StartChallengeCsReq;
|
||||
console.log(JSON.stringify(body, undefined, 4));
|
||||
|
||||
// TODO: This packet is just a base
|
||||
const _lineup = session.player.db.lineup;
|
||||
const lineup = _lineup.lineups[_lineup.curIndex];
|
||||
const curAvatarEntity = new ActorEntity(session.player.scene, lineup.avatarList[lineup.leaderSlot], { x: 0, y: 0, z: 0 });
|
||||
|
||||
session.send(StartChallengeScRsp, {
|
||||
retcode: 0,
|
||||
curChallenge: {
|
||||
challengeId: body.challengeId,
|
||||
deadAvatarNum: 0,
|
||||
extraLineupType: ExtraLineupType.LINEUP_CHALLENGE,
|
||||
rounds: 1,
|
||||
status: ChallengeStatus.CHALLENGE_DOING,
|
||||
killMonsterList: [{
|
||||
monsterId: 8013010,
|
||||
killNum: 1,
|
||||
}]
|
||||
},
|
||||
extraLineupType: ExtraLineupType.LINEUP_NONE,
|
||||
killMonsterList: [],
|
||||
deadAvatarNum: 0,
|
||||
} as CurChallenge,
|
||||
maze: {
|
||||
// ? Data from MappingInfoExcelTable
|
||||
id: 30101,
|
||||
mapEntryId: 10001,
|
||||
id: 30104,
|
||||
mapEntryId: 3000401,
|
||||
floor: {
|
||||
floorId: 20121001,
|
||||
scene: {
|
||||
planeId: 20121,
|
||||
entryId: 1000,
|
||||
floorId: 20121001,
|
||||
gameModeType: 1,
|
||||
entityList: [{
|
||||
entityId: 10010101,
|
||||
npcMonster: {
|
||||
monsterId: 8013010,
|
||||
worldLevel: 1,
|
||||
},
|
||||
groupId: 11,
|
||||
planeId: 30104,
|
||||
entryId: 3000401,
|
||||
floorId: 30104001,
|
||||
lightenSectionList: [],
|
||||
gameModeType: 4,
|
||||
entityList: [
|
||||
curAvatarEntity.getSceneEntityInfo(),
|
||||
{
|
||||
entityId: 10000,
|
||||
motion: {
|
||||
pos: {
|
||||
x: 0,
|
||||
y: 100,
|
||||
z: 0,
|
||||
x: 74719,
|
||||
y: 2014,
|
||||
z: -94205,
|
||||
},
|
||||
rot: {
|
||||
x: 0,
|
||||
@ -51,9 +51,26 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
z: 0
|
||||
}
|
||||
},
|
||||
}]
|
||||
}
|
||||
}
|
||||
groupId: 3,
|
||||
instId: 1,
|
||||
actor: {} as SceneActorInfo,
|
||||
npc: {} as SceneNpcInfo,
|
||||
prop: {} as ScenePropInfo,
|
||||
npcMonster: {
|
||||
monsterId: 1003020,
|
||||
isGenMonster: false,
|
||||
eventId: 0,
|
||||
isSetWorldLevel: false,
|
||||
worldLevel: 6
|
||||
} as SceneNpcMonsterInfo
|
||||
} as SceneEntityInfo,
|
||||
],
|
||||
leaderEntityId: curAvatarEntity.entityId,
|
||||
entityBuffList: [],
|
||||
envBuffList: [],
|
||||
snar: ""
|
||||
} as SceneInfo
|
||||
}
|
||||
} as Maze
|
||||
} as StartChallengeScRsp);
|
||||
}
|
24
src/util/excel/MapEntryExcel.ts
Normal file
24
src/util/excel/MapEntryExcel.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import _MapEntryExcelTable from "../../data/excel/MapEntryExcelTable.json";
|
||||
type MapEntryExcelTableEntry = typeof _MapEntryExcelTable[keyof typeof _MapEntryExcelTable]
|
||||
const MapEntryExcelTable = _MapEntryExcelTable as { [key: string]: MapEntryExcelTableEntry };
|
||||
|
||||
export default class MapEntryExcel {
|
||||
private constructor() {
|
||||
}
|
||||
|
||||
public static all() : MapEntryExcelTableEntry[] {
|
||||
return Object.values(MapEntryExcelTable);
|
||||
}
|
||||
|
||||
public static fromId(id: number) : MapEntryExcelTableEntry {
|
||||
return MapEntryExcelTable[id];
|
||||
}
|
||||
|
||||
public static fromIds(ids: number[]): MapEntryExcelTableEntry[] {
|
||||
return ids.map(id => MapEntryExcel.fromId(id));
|
||||
}
|
||||
|
||||
public static fromFloorId(id: number) : MapEntryExcelTableEntry {
|
||||
return Object.values(MapEntryExcelTable).filter(e => e.FloorID == id)?.[0];
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import _MapEntryExcelTable from "../../data/excel/MapEntryExcelTable.json";
|
||||
import _MazePlaneExcelTable from "../../data/excel/MazePlaneExcelTable.json";
|
||||
import MapEntryExcel from "./MapEntryExcel";
|
||||
|
||||
interface MazePlaneExcelTableEntry {
|
||||
PlaneID: number;
|
||||
@ -11,44 +11,13 @@ interface MazePlaneExcelTableEntry {
|
||||
FloorIDList: number[];
|
||||
}
|
||||
|
||||
interface TextMap {
|
||||
hash: number;
|
||||
}
|
||||
|
||||
type EntranceType = "Town" | "Mission" | "Explore";
|
||||
|
||||
interface MapEntryExcelTableEntry {
|
||||
ID: number;
|
||||
IsShowInMapMenu: boolean;
|
||||
MapMenuSortID: number;
|
||||
EntranceType: EntranceType | number; // Actually an enum. Town | Mission | Explore
|
||||
EntranceGroupID: number;
|
||||
Name: TextMap;
|
||||
Desc: TextMap;
|
||||
EntranceListIcon: string;
|
||||
ImagePath: string;
|
||||
MiniMapIconHintList: any[];
|
||||
ShowReward: number;
|
||||
PlaneID: number;
|
||||
FloorID: number;
|
||||
StartGroupID: number;
|
||||
StartAnchorID: number;
|
||||
TargetMission: number;
|
||||
TargetMainMissionList: number[];
|
||||
BeginMainMissionList: number[];
|
||||
FinishMainMissionList: number[];
|
||||
FinishQuestList: number[];
|
||||
UnlockQuest: number;
|
||||
}
|
||||
|
||||
const MazePlaneExcelTable = _MazePlaneExcelTable as { [key: string]: MazePlaneExcelTableEntry };
|
||||
const MapEntryExcelTable = _MapEntryExcelTable as { [key: string]: MapEntryExcelTableEntry };
|
||||
|
||||
export default class MazePlaneExcel {
|
||||
private constructor() { }
|
||||
|
||||
public static fromEntryId(entryId: number): MazePlaneExcelTableEntry {
|
||||
const mapEntry = MapEntryExcelTable[entryId.toString()];
|
||||
const mapEntry = MapEntryExcel.fromId(entryId);
|
||||
return MazePlaneExcelTable[mapEntry.PlaneID.toString()];
|
||||
}
|
||||
|
||||
@ -56,11 +25,21 @@ export default class MazePlaneExcel {
|
||||
return MazePlaneExcelTable[planeId.toString()];
|
||||
}
|
||||
|
||||
public static getEntry(entryId: number): MapEntryExcelTableEntry {
|
||||
return MapEntryExcelTable[entryId.toString()];
|
||||
public static getGameModeForPlaneType(planeType: string): number {
|
||||
switch (planeType) {
|
||||
case "Town": return 1;
|
||||
case "Maze": return 2;
|
||||
case "Train": return 3;
|
||||
case "Challenge": return 4;
|
||||
case "RogueExplore": return 5;
|
||||
case "RogueChallenge": return 6;
|
||||
case "TownRoom": return 7;
|
||||
case "Raid": return 8;
|
||||
case "FarmRelic": return 9;
|
||||
case "Client": return 10;
|
||||
case "ChallengeActivity": return 11;
|
||||
}
|
||||
|
||||
public static getAllEntries(): MapEntryExcelTableEntry[] {
|
||||
return Object.values(MapEntryExcelTable);
|
||||
return 0;
|
||||
}
|
||||
}
|
20
src/util/excel/MonsterExcel.ts
Normal file
20
src/util/excel/MonsterExcel.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import _MonsterExcelTable from "../../data/excel/MonsterExcelTable.json";
|
||||
type MonsterExcelTableEntry = typeof _MonsterExcelTable[keyof typeof _MonsterExcelTable]
|
||||
const MonsterExcelTable = _MonsterExcelTable as { [key: string]: MonsterExcelTableEntry };
|
||||
|
||||
export default class MonsterExcel {
|
||||
private constructor() {
|
||||
}
|
||||
|
||||
public static all() : MonsterExcelTableEntry[] {
|
||||
return Object.values(MonsterExcelTable);
|
||||
}
|
||||
|
||||
public static fromId(id: number) : MonsterExcelTableEntry {
|
||||
return MonsterExcelTable[id];
|
||||
}
|
||||
|
||||
public static fromIds(ids: number[]): MonsterExcelTableEntry[] {
|
||||
return ids.map(id => MonsterExcel.fromId(id));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user