mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-09 03:42:57 +08:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
commit
73e181df9b
@ -4,10 +4,10 @@ import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.quest.enums.QuestContent;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -29,10 +29,10 @@ public class PlayerProgress {
|
||||
// keep track of EXEC_ADD_QUEST_PROGRESS count, will be used in CONTENT_ADD_QUEST_PROGRESS
|
||||
// not sure where to put this, this should be saved to DB but not to individual quest, since
|
||||
// it will be hard to loop and compare
|
||||
private Map<Integer, Integer> questProgressCountMap;
|
||||
private Map<String, Integer> questProgressCountMap;
|
||||
|
||||
public PlayerProgress() {
|
||||
this.questProgressCountMap = new Int2IntOpenHashMap();
|
||||
this.questProgressCountMap = new ConcurrentHashMap<>();
|
||||
this.completedDungeons = new IntArrayList();
|
||||
this.itemHistory = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
@ -70,15 +70,15 @@ public class PlayerProgress {
|
||||
return itemEntry.addToObtainedCount(count);
|
||||
}
|
||||
|
||||
public int getCurrentProgress(int progressId) {
|
||||
public int getCurrentProgress(String progressId) {
|
||||
return questProgressCountMap.getOrDefault(progressId, -1);
|
||||
}
|
||||
|
||||
public int addToCurrentProgress(int progressId, int count) {
|
||||
public int addToCurrentProgress(String progressId, int count) {
|
||||
return questProgressCountMap.merge(progressId, count, Integer::sum);
|
||||
}
|
||||
|
||||
public int resetCurrentProgress(int progressId) {
|
||||
public int resetCurrentProgress(String progressId) {
|
||||
return questProgressCountMap.merge(progressId, 0, Integer::min);
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ public final class PlayerProgressManager extends BasePlayerDataManager {
|
||||
|
||||
/** Quest progress */
|
||||
public void addQuestProgress(int id, int count) {
|
||||
var newCount = player.getPlayerProgress().addToCurrentProgress(id, count);
|
||||
var newCount = player.getPlayerProgress().addToCurrentProgress(String.valueOf(id), count);
|
||||
player.save();
|
||||
player
|
||||
.getQuestManager()
|
||||
|
@ -51,10 +51,12 @@ public class GameQuest {
|
||||
this.state = QuestState.QUEST_STATE_UNSTARTED;
|
||||
this.triggerData = new HashMap<>();
|
||||
this.triggers = new HashMap<>();
|
||||
this.finishProgressList = new int[questData.getFinishCond().size()];
|
||||
this.failProgressList = new int[questData.getFailCond().size()];
|
||||
this.finishTime = 0;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.clearProgress(false);
|
||||
this.acceptTime = Utils.getCurrentSeconds();
|
||||
this.startTime = this.acceptTime;
|
||||
this.startGameDay = getOwner().getWorld().getTotalGameTimeDays();
|
||||
@ -153,17 +155,30 @@ public class GameQuest {
|
||||
// TODO improve
|
||||
var oldState = state;
|
||||
if (questData.getFinishCond() != null && questData.getFinishCond().size() != 0) {
|
||||
for (var condition : questData.getFinishCond()) {
|
||||
if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) {
|
||||
this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr());
|
||||
}
|
||||
}
|
||||
this.finishProgressList = new int[questData.getFinishCond().size()];
|
||||
}
|
||||
|
||||
if (questData.getFailCond() != null && questData.getFailCond().size() != 0) {
|
||||
for (var condition : questData.getFailCond()) {
|
||||
if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) {
|
||||
this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr());
|
||||
}
|
||||
}
|
||||
this.failProgressList = new int[questData.getFailCond().size()];
|
||||
}
|
||||
|
||||
this.getOwner().getPlayerProgress().resetCurrentProgress(String.valueOf(this.subQuestId));
|
||||
|
||||
setState(QuestState.QUEST_STATE_UNSTARTED);
|
||||
finishTime = 0;
|
||||
acceptTime = 0;
|
||||
startTime = 0;
|
||||
this.getOwner().getPlayerProgress().resetCurrentProgress(this.subQuestId);
|
||||
|
||||
if (oldState == QuestState.QUEST_STATE_UNSTARTED) {
|
||||
return false;
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ public class ContentAddQuestProgress extends BaseContent {
|
||||
public boolean execute(
|
||||
GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
|
||||
val progressId = condition.getParam()[0];
|
||||
val currentCount = quest.getOwner().getPlayerProgress().getCurrentProgress(progressId);
|
||||
val currentCount =
|
||||
quest.getOwner().getPlayerProgress().getCurrentProgress(String.valueOf(progressId));
|
||||
|
||||
// if the condition count is 0 I think it is safe to assume that the
|
||||
// condition count from EXEC only needs to be 1
|
||||
|
@ -12,6 +12,8 @@ public class ContentLuaNotify extends BaseContent {
|
||||
@Override
|
||||
public boolean execute(
|
||||
GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
|
||||
return condition.getParamStr().equals(paramStr);
|
||||
return condition.getParamStr().equals(paramStr)
|
||||
&& condition.getCount()
|
||||
<= quest.getOwner().getPlayerProgress().getCurrentProgress(paramStr);
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ import emu.grasscutter.game.props.*;
|
||||
import emu.grasscutter.game.quest.QuestGroupSuite;
|
||||
import emu.grasscutter.game.world.data.TeleportProperties;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
|
||||
import emu.grasscutter.net.proto.*;
|
||||
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
||||
import emu.grasscutter.scripts.*;
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
@ -33,12 +33,11 @@ import emu.grasscutter.server.event.player.PlayerTeleportEvent;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.objects.KahnsSort;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import lombok.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.*;
|
||||
|
||||
public final class Scene {
|
||||
@Getter private final World world;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package emu.grasscutter.game.world;
|
||||
|
||||
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
||||
import emu.grasscutter.game.entity.*;
|
||||
@ -18,13 +20,10 @@ import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.ConversionUtils;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
||||
|
||||
public class World implements Iterable<Player> {
|
||||
@Getter private final GameServer server;
|
||||
@Getter private final Player host;
|
||||
@ -158,11 +157,8 @@ public class World implements Iterable<Player> {
|
||||
player.getTeamManager().setCurrentCharacterIndex(0);
|
||||
|
||||
if (player != this.getHost()) {
|
||||
this.broadcastPacket(new PacketPlayerChatNotify(
|
||||
player, 0,
|
||||
SystemHint.newBuilder()
|
||||
.setType(1).build()
|
||||
));
|
||||
this.broadcastPacket(
|
||||
new PacketPlayerChatNotify(player, 0, SystemHint.newBuilder().setType(1).build()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,11 +214,8 @@ public class World implements Iterable<Player> {
|
||||
victim.getPosition()));
|
||||
}
|
||||
} else {
|
||||
this.broadcastPacket(new PacketPlayerChatNotify(
|
||||
player, 0,
|
||||
SystemHint.newBuilder()
|
||||
.setType(2).build()
|
||||
));
|
||||
this.broadcastPacket(
|
||||
new PacketPlayerChatNotify(player, 0, SystemHint.newBuilder().setType(2).build()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -667,6 +667,7 @@ public class ScriptLib {
|
||||
var1);
|
||||
|
||||
for(var player : getSceneScriptManager().getScene().getPlayers()){
|
||||
player.getPlayerProgress().addToCurrentProgress(var1, 1);
|
||||
player.getQuestManager().queueEvent(QuestCond.QUEST_COND_LUA_NOTIFY, var1);
|
||||
player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_LUA_NOTIFY, var1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user