mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-23 18:54:37 +01:00
Basic implementation of challenge stories
This commit is contained in:
@@ -51,6 +51,7 @@ public class GameConstants {
|
||||
|
||||
// Challenge
|
||||
public static final int CHALLENGE_ENTRANCE = 100000103;
|
||||
public static final int CHALLENGE_STORY_ENTRANCE = 102020107;
|
||||
|
||||
// Rogue
|
||||
public static final boolean ENABLE_ROGUE = false;
|
||||
|
||||
@@ -7,7 +7,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = {"ChallengeMazeConfig.json"})
|
||||
@ResourceType(name = {"ChallengeMazeConfig.json", "ChallengeStoryMazeConfig.json"})
|
||||
public class ChallengeExcel extends GameResource {
|
||||
private int ID;
|
||||
private int GroupID;
|
||||
@@ -30,11 +30,22 @@ public class ChallengeExcel extends GameResource {
|
||||
|
||||
private transient Int2ObjectMap<ChallengeMonsterInfo> challengeMonsters1;
|
||||
private transient Int2ObjectMap<ChallengeMonsterInfo> challengeMonsters2;
|
||||
|
||||
private transient ChallengeStoryExtraExcel storyExcel;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public boolean isStory() {
|
||||
return this.storyExcel != null;
|
||||
}
|
||||
|
||||
public void setStoryExcel(ChallengeStoryExtraExcel storyExcel) {
|
||||
this.storyExcel = storyExcel;
|
||||
this.ChallengeCountDown = storyExcel.getTurnLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
@@ -54,7 +65,7 @@ public class ChallengeExcel extends GameResource {
|
||||
var monster = new ChallengeMonsterInfo(ConfigList2[i], NpcMonsterIDList2[i], EventIDList2[i]);
|
||||
this.challengeMonsters2.put(monster.getConfigId(), monster);
|
||||
}
|
||||
|
||||
|
||||
// Clear arrays to save memory
|
||||
this.ConfigList1 = null;
|
||||
this.NpcMonsterIDList1 = null;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package emu.lunarcore.data.excel;
|
||||
|
||||
import emu.lunarcore.data.GameData;
|
||||
import emu.lunarcore.data.GameResource;
|
||||
import emu.lunarcore.data.ResourceType;
|
||||
import emu.lunarcore.data.ResourceType.LoadPriority;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = {"ChallengeStoryMazeExtra.json"}, loadPriority = LoadPriority.LOW)
|
||||
public class ChallengeStoryExtraExcel extends GameResource {
|
||||
private int ID;
|
||||
private int TurnLimit;
|
||||
private int ClearScore;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
var challengeExcel = GameData.getChallengeExcelMap().get(this.getId());
|
||||
if (challengeExcel != null) {
|
||||
challengeExcel.setStoryExcel(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import emu.lunarcore.data.ResourceType.LoadPriority;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = {"ChallengeTargetConfig.json"}, loadPriority = LoadPriority.HIGH)
|
||||
@ResourceType(name = {"ChallengeTargetConfig.json", "ChallengeStoryTargetConfig.json"}, loadPriority = LoadPriority.HIGH)
|
||||
public class ChallengeTargetExcel extends GameResource {
|
||||
private int ID;
|
||||
private ChallengeType ChallengeTargetType;
|
||||
@@ -18,6 +18,6 @@ public class ChallengeTargetExcel extends GameResource {
|
||||
}
|
||||
|
||||
public enum ChallengeType {
|
||||
None, ROUNDS, DEAD_AVATAR, KILL_MONSTER, AVATAR_BASE_TYPE_MORE, AVATAR_BASE_TYPE_LESS, ROUNDS_LEFT;
|
||||
None, ROUNDS, DEAD_AVATAR, KILL_MONSTER, AVATAR_BASE_TYPE_MORE, AVATAR_BASE_TYPE_LESS, ROUNDS_LEFT, TOTAL_SCORE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,10 @@ public class Battle {
|
||||
|
||||
// Battle buffs
|
||||
|
||||
public MazeBuff addBuff(int buffId) {
|
||||
return addBuff(buffId, -1, 0xffffffff);
|
||||
}
|
||||
|
||||
public MazeBuff addBuff(int buffId, int ownerIndex) {
|
||||
return addBuff(buffId, ownerIndex, 0xffffffff);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ import emu.lunarcore.server.packet.send.PacketChallengeLineupNotify;
|
||||
import emu.lunarcore.server.packet.send.PacketChallengeSettleNotify;
|
||||
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
||||
import emu.lunarcore.util.Position;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -37,6 +38,8 @@ public class ChallengeInstance {
|
||||
@Setter private int roundsLeft;
|
||||
@Setter private int stars;
|
||||
|
||||
private IntList storyBuffs;
|
||||
|
||||
@Deprecated // Morphia only
|
||||
public ChallengeInstance() {}
|
||||
|
||||
@@ -47,7 +50,7 @@ public class ChallengeInstance {
|
||||
this.startPos = new Position();
|
||||
this.startRot = new Position();
|
||||
this.currentStage = 1;
|
||||
this.roundsLeft = excel.getChallengeCountDown();
|
||||
this.roundsLeft = getExcel().isStory() ? 5 : excel.getChallengeCountDown();
|
||||
this.setStatus(ChallengeStatus.CHALLENGE_DOING);
|
||||
this.setCurrentExtraLineup(ExtraLineupType.LINEUP_CHALLENGE);
|
||||
}
|
||||
@@ -76,8 +79,28 @@ public class ChallengeInstance {
|
||||
return status == ChallengeStatus.CHALLENGE_FINISH_VALUE;
|
||||
}
|
||||
|
||||
public void addStoryBuff(int storyBuff) {
|
||||
// Add story buffs
|
||||
if (storyBuffs == null) {
|
||||
storyBuffs = new IntArrayList();
|
||||
}
|
||||
|
||||
storyBuffs.add(storyBuff);
|
||||
}
|
||||
|
||||
public void onBattleStart(Battle battle) {
|
||||
// Set cycle limit
|
||||
battle.setRoundsLimit(player.getChallengeInstance().getRoundsLeft());
|
||||
|
||||
// Add story buffs
|
||||
if (this.getStoryBuffs() != null) {
|
||||
battle.addBuff(this.getExcel().getMazeBuffID());
|
||||
|
||||
int buffId = this.getStoryBuffs().getInt(this.getCurrentStage() - 1);
|
||||
if (buffId != 0) {
|
||||
battle.addBuff(buffId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBattleFinish(Battle battle, BattleEndStatus result, BattleStatistics stats) {
|
||||
@@ -190,6 +213,11 @@ public class ChallengeInstance {
|
||||
.setRoundCount(this.getRoundsElapsed())
|
||||
.setExtraLineupTypeValue(this.getCurrentExtraLineup());
|
||||
|
||||
if (this.getStoryBuffs() != null) {
|
||||
int buffId = this.getStoryBuffs().getInt(this.getCurrentStage() - 1);
|
||||
proto.getMutableStoryInfo().getMutableCurStoryBuffs().addBuffList(buffId);
|
||||
}
|
||||
|
||||
return proto;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import emu.lunarcore.game.player.BasePlayerManager;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
|
||||
import emu.lunarcore.proto.StartChallengeStoryBuffInfoOuterClass.StartChallengeStoryBuffInfo;
|
||||
import emu.lunarcore.server.packet.send.PacketStartChallengeScRsp;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
@@ -28,7 +29,7 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
this.takenRewards = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
public void startChallenge(int challengeId) {
|
||||
public void startChallenge(int challengeId, StartChallengeStoryBuffInfo storyBuffs) {
|
||||
// Get challenge excel
|
||||
ChallengeExcel excel = GameData.getChallengeExcelMap().get(challengeId);
|
||||
if (excel == null) {
|
||||
@@ -68,7 +69,7 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
// Set challenge data for player
|
||||
ChallengeInstance instance = new ChallengeInstance(getPlayer(), excel);
|
||||
getPlayer().setChallengeInstance(instance);
|
||||
|
||||
|
||||
// Set first lineup before we enter scenes
|
||||
getPlayer().getLineupManager().setCurrentExtraLineup(instance.getCurrentExtraLineup(), false);
|
||||
|
||||
@@ -87,6 +88,12 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
instance.getStartPos().set(getPlayer().getPos());
|
||||
instance.getStartRot().set(getPlayer().getRot());
|
||||
instance.setSavedMp(getPlayer().getCurrentLineup().getMp());
|
||||
|
||||
// Set story buffs
|
||||
if (excel.isStory() && storyBuffs != null) {
|
||||
instance.addStoryBuff(storyBuffs.getStoryBuffOne());
|
||||
instance.addStoryBuff(storyBuffs.getStoryBuffTwo());
|
||||
}
|
||||
|
||||
// Send packet
|
||||
getPlayer().sendPacket(new PacketStartChallengeScRsp(getPlayer(), challengeId));
|
||||
|
||||
@@ -17,9 +17,17 @@ public class HandlerLeaveChallengeCsReq extends PacketHandler {
|
||||
// As of 1.5.0, the server now has to handle the player leaving battle too
|
||||
session.getPlayer().forceQuitBattle();
|
||||
|
||||
// Get entry id
|
||||
int leaveEntryId = GameConstants.CHALLENGE_ENTRANCE;
|
||||
if (session.getPlayer().getChallengeInstance() != null) {
|
||||
if (session.getPlayer().getChallengeInstance().getExcel().isStory()) {
|
||||
leaveEntryId = GameConstants.CHALLENGE_STORY_ENTRANCE;
|
||||
}
|
||||
}
|
||||
|
||||
// Leave scene
|
||||
session.getPlayer().getLineupManager().setCurrentExtraLineup(0, false);
|
||||
session.getPlayer().enterScene(GameConstants.CHALLENGE_ENTRANCE, 0, true);
|
||||
session.getPlayer().enterScene(leaveEntryId, 0, true);
|
||||
}
|
||||
|
||||
// Send rsp packet to keep the client happy
|
||||
|
||||
@@ -12,8 +12,9 @@ public class HandlerStartChallengeCsReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] data) throws Exception {
|
||||
var req = StartChallengeCsReq.parseFrom(data);
|
||||
var storyBuffs = req.getMutableStoryInfo().getMutableStoryBuffInfo();
|
||||
|
||||
session.getPlayer().getChallengeManager().startChallenge(req.getChallengeId());
|
||||
session.getPlayer().getChallengeManager().startChallenge(req.getChallengeId(), storyBuffs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user