Implement character ascension material bosses

This commit is contained in:
Melledy
2023-09-29 17:47:10 -07:00
parent 0b0313bf29
commit b476fc73f2
3 changed files with 62 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import emu.lunarcore.game.scene.entity.*;
import emu.lunarcore.game.player.Player; import emu.lunarcore.game.player.Player;
import emu.lunarcore.proto.SceneEntityGroupInfoOuterClass.SceneEntityGroupInfo; import emu.lunarcore.proto.SceneEntityGroupInfoOuterClass.SceneEntityGroupInfo;
import emu.lunarcore.proto.SceneInfoOuterClass.SceneInfo; import emu.lunarcore.proto.SceneInfoOuterClass.SceneInfo;
import emu.lunarcore.server.packet.send.PacketActivateFarmElementScRsp;
import emu.lunarcore.server.packet.send.PacketSceneGroupRefreshScNotify; import emu.lunarcore.server.packet.send.PacketSceneGroupRefreshScNotify;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@@ -156,6 +157,10 @@ public class Scene {
private int getNextEntityId() { private int getNextEntityId() {
return ++lastEntityId; return ++lastEntityId;
} }
public GameEntity getEntityById(int id) {
return this.entities.get(id);
}
public void syncLineup() { public void syncLineup() {
// Get current lineup // Get current lineup
@@ -197,6 +202,17 @@ public class Scene {
// Sync packet // Sync packet
getPlayer().sendPacket(new PacketSceneGroupRefreshScNotify(toAdd, toRemove)); getPlayer().sendPacket(new PacketSceneGroupRefreshScNotify(toAdd, toRemove));
} }
public boolean activateFarmElement(int entityId, int worldLevel) {
GameEntity entity = this.getEntityById(entityId);
if (entity == null) {
player.sendPacket(new PacketActivateFarmElementScRsp());
return false;
}
player.sendPacket(new PacketActivateFarmElementScRsp(entityId, worldLevel));
return true;
}
public synchronized void addEntity(GameEntity entity) { public synchronized void addEntity(GameEntity entity) {
// Dont add if monster id already exists // Dont add if monster id already exists

View File

@@ -0,0 +1,19 @@
package emu.lunarcore.server.packet.recv;
import emu.lunarcore.proto.ActivateFarmElementCsReqOuterClass.ActivateFarmElementCsReq;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler;
@Opcodes(CmdId.ActivateFarmElementCsReq)
public class HandlerActivateFarmElementCsReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] data) throws Exception {
var req = ActivateFarmElementCsReq.parseFrom(data);
session.getPlayer().getScene().activateFarmElement(req.getEntityId(), req.getWorldLevel());
}
}

View File

@@ -0,0 +1,27 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.proto.ActivateFarmElementScRspOuterClass.ActivateFarmElementScRsp;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
public class PacketActivateFarmElementScRsp extends BasePacket {
public PacketActivateFarmElementScRsp() {
super(CmdId.ActivateFarmElementScRsp);
var data = ActivateFarmElementScRsp.newInstance()
.setRetcode(1);
this.setData(data);
}
public PacketActivateFarmElementScRsp(int entityId, int worldLevel) {
super(CmdId.ActivateFarmElementScRsp);
var data = ActivateFarmElementScRsp.newInstance()
.setEntityId(entityId)
.setWorldLevel(worldLevel);
this.setData(data);
}
}