mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 05:44:36 +01:00
Implement technique points
Currently all destructible props restore technique points
This commit is contained in:
@@ -16,6 +16,7 @@ public class GameConstants {
|
||||
public static final int MAX_STAMINA = 240;
|
||||
public static final int MAX_AVATARS_IN_TEAM = 4;
|
||||
public static final int DEFAULT_TEAMS = 6;
|
||||
public static final int MAX_MP = 5; // Client doesnt like more than 5
|
||||
|
||||
// Custom
|
||||
public static final int SERVER_CONSOLE_UID = 99;
|
||||
|
||||
@@ -34,6 +34,7 @@ public class BattleService extends BaseGameService {
|
||||
public void startBattle(Player player, int attackerId, RepeatedInt attackedList) {
|
||||
// Sanity check to make sure player isnt in a battle
|
||||
if (player.isInBattle()) {
|
||||
player.sendPacket(new PacketSceneCastSkillScRsp(1));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ public class BattleService extends BaseGameService {
|
||||
}
|
||||
}
|
||||
|
||||
// Give the client an error if not attacked entities detected
|
||||
// Give the client an error if no attacked entities detected
|
||||
if (entities.size() == 0) {
|
||||
player.sendPacket(new PacketSceneCastSkillScRsp(1));
|
||||
return;
|
||||
|
||||
@@ -17,6 +17,7 @@ public class LineupManager {
|
||||
private PlayerLineup[] lineups;
|
||||
private int currentIndex;
|
||||
private int currentLeader;
|
||||
private int mp;
|
||||
|
||||
// Extra lineups for challenges/simulated universe/etc
|
||||
private transient int currentExtraLineup;
|
||||
@@ -29,10 +30,19 @@ public class LineupManager {
|
||||
|
||||
public LineupManager(Player player) {
|
||||
this();
|
||||
|
||||
this.mp = 5;
|
||||
this.validate(player);
|
||||
}
|
||||
|
||||
public void addMp(int i) {
|
||||
this.mp = Math.min(this.mp + i, GameConstants.MAX_MP);
|
||||
this.getPlayer().sendPacket(new PacketSyncLineupNotify(player.getCurrentLineup()));
|
||||
}
|
||||
|
||||
public void removeMp(int i) {
|
||||
this.mp = Math.max(this.mp - i, 0);
|
||||
}
|
||||
|
||||
public PlayerLineup getLineupByIndex(int index, int extraLineup) {
|
||||
// Sanity
|
||||
if (extraLineup > 0) {
|
||||
|
||||
@@ -86,7 +86,8 @@ public class PlayerLineup {
|
||||
.setIndex(index)
|
||||
.setName(this.getName())
|
||||
.setLeaderSlot(this.getOwner().getLineupManager().getCurrentLeader())
|
||||
.setTechniquePoints(5)
|
||||
.setMp(this.getOwner().getLineupManager().getMp())
|
||||
.setMaxMp(GameConstants.MAX_MP)
|
||||
.setExtraLineupType(ExtraLineupType.LINEUP_NONE);
|
||||
|
||||
for (int slot = 0; slot < this.getAvatars().size(); slot++) {
|
||||
|
||||
@@ -224,6 +224,8 @@ public class Scene {
|
||||
// Set entity id and add monster to entity map
|
||||
entity.setEntityId(this.getNextEntityId());
|
||||
this.entities.put(entity.getEntityId(), entity);
|
||||
// Entity add callback
|
||||
entity.onAdd(this);
|
||||
}
|
||||
|
||||
public synchronized void removeEntity(GameEntity entity) {
|
||||
@@ -234,6 +236,9 @@ public class Scene {
|
||||
GameEntity entity = this.entities.remove(entityId);
|
||||
|
||||
if (entity != null) {
|
||||
// Entity remove callback
|
||||
entity.onRemove(this);
|
||||
// Send packet
|
||||
player.sendPacket(new PacketSceneGroupRefreshScNotify(null, entity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package emu.lunarcore.game.scene.entity;
|
||||
import emu.lunarcore.data.excel.NpcMonsterExcel;
|
||||
import emu.lunarcore.data.excel.StageExcel;
|
||||
import emu.lunarcore.game.enums.PropState;
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
|
||||
import emu.lunarcore.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||
import emu.lunarcore.proto.SceneNpcMonsterInfoOuterClass.SceneNpcMonsterInfo;
|
||||
@@ -29,6 +30,12 @@ public class EntityProp implements GameEntity {
|
||||
this.rot = new Position();
|
||||
this.state = PropState.Closed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(Scene scene) {
|
||||
// TODO Debug
|
||||
scene.getPlayer().getLineupManager().addMp(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneEntityInfo toSceneEntityProto() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package emu.lunarcore.game.scene.entity;
|
||||
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
import emu.lunarcore.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||
|
||||
public interface GameEntity {
|
||||
@@ -15,7 +16,14 @@ public interface GameEntity {
|
||||
public default int getInstId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public default void onAdd(Scene scene) {
|
||||
|
||||
}
|
||||
|
||||
public default void onRemove(Scene scene) {
|
||||
|
||||
}
|
||||
|
||||
public SceneEntityInfo toSceneEntityProto();
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,11 @@ public class HandlerSceneCastSkillCsReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] data) throws Exception {
|
||||
var req = SceneCastSkillCsReq.parseFrom(data);
|
||||
|
||||
|
||||
if (req.getSkillIndex() > 0 && session.getPlayer().getScene().getAvatarEntityIds().contains(req.getAttackerId())) {
|
||||
session.getPlayer().getLineupManager().removeMp(1);
|
||||
}
|
||||
|
||||
if (req.hasAttackedEntityIdList()) {
|
||||
session.getServer().getBattleService().startBattle(session.getPlayer(), req.getAttackerId(), req.getAttackedEntityIdList());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user