mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-09 14:23:26 +08:00
Fixed dungeon challenge scoreboard and implement dungeon drops
Also fixed a few dungeon script handlers
This commit is contained in:
parent
ae31e4fd98
commit
1b97b4afa0
@ -66,6 +66,7 @@ public class GameData {
|
|||||||
private static final Int2ObjectMap<DailyDungeonData> dailyDungeonDataMap = new Int2ObjectOpenHashMap<>();
|
private static final Int2ObjectMap<DailyDungeonData> dailyDungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||||
private static final Int2ObjectMap<DungeonData> dungeonDataMap = new Int2ObjectOpenHashMap<>();
|
private static final Int2ObjectMap<DungeonData> dungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||||
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();
|
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();
|
||||||
|
private static final Int2ObjectMap<RewardPreviewData> rewardPreviewDataMap = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
||||||
@ -300,6 +301,13 @@ public class GameData {
|
|||||||
return shopGoods;
|
return shopGoods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the rewardpreviewdatamap
|
||||||
|
*/
|
||||||
|
public static Int2ObjectMap<RewardPreviewData> getRewardPreviewDataMap() {
|
||||||
|
return rewardPreviewDataMap;
|
||||||
|
}
|
||||||
|
|
||||||
public static IntList getScenePointIdList() {
|
public static IntList getScenePointIdList() {
|
||||||
return scenePointIdList;
|
return scenePointIdList;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package emu.grasscutter.data.common;
|
||||||
|
|
||||||
|
public class ItemParamStringData {
|
||||||
|
private int Id;
|
||||||
|
private String Count;
|
||||||
|
|
||||||
|
public ItemParamStringData() {}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCount() {
|
||||||
|
return Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemParamData toItemParamData() {
|
||||||
|
if (Count.contains(";")) {
|
||||||
|
String[] split = Count.split(";");
|
||||||
|
Count = Count.split(";")[split.length - 1];
|
||||||
|
} else if (Count.contains(".")) {
|
||||||
|
return new ItemParamData(Id, (int) Math.ceil(Double.parseDouble(Count)));
|
||||||
|
}
|
||||||
|
return new ItemParamData(Id, Integer.parseInt(Count));
|
||||||
|
}
|
||||||
|
}
|
@ -11,8 +11,11 @@ public class DungeonData extends GameResource {
|
|||||||
private int Id;
|
private int Id;
|
||||||
private int SceneId;
|
private int SceneId;
|
||||||
private int ShowLevel;
|
private int ShowLevel;
|
||||||
|
private int PassRewardPreviewID;
|
||||||
private String InvolveType; // TODO enum
|
private String InvolveType; // TODO enum
|
||||||
|
|
||||||
|
private RewardPreviewData previewData;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return this.Id;
|
return this.Id;
|
||||||
@ -26,8 +29,14 @@ public class DungeonData extends GameResource {
|
|||||||
return ShowLevel;
|
return ShowLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RewardPreviewData getRewardPreview() {
|
||||||
|
return previewData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
if (this.PassRewardPreviewID > 0) {
|
||||||
|
this.previewData = GameData.getRewardPreviewDataMap().get(this.PassRewardPreviewID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package emu.grasscutter.data.def;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.data.GameData;
|
||||||
|
import emu.grasscutter.data.GameResource;
|
||||||
|
import emu.grasscutter.data.ResourceType;
|
||||||
|
|
||||||
|
import emu.grasscutter.game.props.SceneType;
|
||||||
|
|
||||||
|
import emu.grasscutter.data.ResourceType.LoadPriority;
|
||||||
|
import emu.grasscutter.data.common.ItemParamData;
|
||||||
|
import emu.grasscutter.data.common.ItemParamStringData;
|
||||||
|
|
||||||
|
@ResourceType(name = "RewardPreviewExcelConfigData.json", loadPriority = LoadPriority.HIGH)
|
||||||
|
public class RewardPreviewData extends GameResource {
|
||||||
|
private int Id;
|
||||||
|
private ItemParamStringData[] PreviewItems;
|
||||||
|
private ItemParamData[] PreviewItemsArray;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return this.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemParamData[] getPreviewItems() {
|
||||||
|
return PreviewItemsArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
if (this.PreviewItems != null && this.PreviewItems.length > 0) {
|
||||||
|
this.PreviewItemsArray = Arrays.stream(this.PreviewItems)
|
||||||
|
.filter(d -> d.getId() > 0 && d.getCount() != null && !d.getCount().isEmpty())
|
||||||
|
.map(ItemParamStringData::toItemParamData)
|
||||||
|
.toArray(size -> new ItemParamData[size]);
|
||||||
|
} else {
|
||||||
|
this.PreviewItemsArray = new ItemParamData[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,18 +4,29 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
|
import emu.grasscutter.data.common.ItemParamData;
|
||||||
|
import emu.grasscutter.data.def.DungeonData;
|
||||||
import emu.grasscutter.data.def.MonsterData;
|
import emu.grasscutter.data.def.MonsterData;
|
||||||
import emu.grasscutter.game.entity.EntityMonster;
|
import emu.grasscutter.game.entity.EntityMonster;
|
||||||
import emu.grasscutter.game.entity.GameEntity;
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
|
import emu.grasscutter.game.inventory.GameItem;
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
import emu.grasscutter.game.world.Scene;
|
import emu.grasscutter.game.world.Scene;
|
||||||
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
||||||
import emu.grasscutter.scripts.constants.EventType;
|
import emu.grasscutter.scripts.constants.EventType;
|
||||||
import emu.grasscutter.scripts.data.SceneGroup;
|
import emu.grasscutter.scripts.data.SceneGroup;
|
||||||
import emu.grasscutter.scripts.data.SceneMonster;
|
import emu.grasscutter.scripts.data.SceneMonster;
|
||||||
|
import emu.grasscutter.scripts.data.ScriptArgs;
|
||||||
import emu.grasscutter.server.packet.send.PacketChallengeDataNotify;
|
import emu.grasscutter.server.packet.send.PacketChallengeDataNotify;
|
||||||
import emu.grasscutter.server.packet.send.PacketDungeonChallengeBeginNotify;
|
import emu.grasscutter.server.packet.send.PacketDungeonChallengeBeginNotify;
|
||||||
import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify;
|
import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketDungeonSettleNotify;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketGadgetAutoPickDropInfoNotify;
|
||||||
import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
|
import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
|
||||||
|
import emu.grasscutter.utils.Utils;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
|
|
||||||
public class DungeonChallenge {
|
public class DungeonChallenge {
|
||||||
private final Scene scene;
|
private final Scene scene;
|
||||||
@ -28,12 +39,12 @@ public class DungeonChallenge {
|
|||||||
|
|
||||||
private int score;
|
private int score;
|
||||||
private int objective = 0;
|
private int objective = 0;
|
||||||
|
private IntSet rewardedPlayers;
|
||||||
|
|
||||||
public DungeonChallenge(Scene scene, SceneGroup group) {
|
public DungeonChallenge(Scene scene, SceneGroup group) {
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
|
this.setRewardedPlayers(new IntOpenHashSet());
|
||||||
objective += group.monsters.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Scene getScene() {
|
public Scene getScene() {
|
||||||
@ -60,6 +71,14 @@ public class DungeonChallenge {
|
|||||||
this.challengeId = challengeId;
|
this.challengeId = challengeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getObjective() {
|
||||||
|
return objective;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setObjective(int objective) {
|
||||||
|
this.objective = objective;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -76,6 +95,18 @@ public class DungeonChallenge {
|
|||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimeLimit() {
|
||||||
|
return 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntSet getRewardedPlayers() {
|
||||||
|
return rewardedPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRewardedPlayers(IntSet rewardedPlayers) {
|
||||||
|
this.rewardedPlayers = rewardedPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
this.progress = true;
|
this.progress = true;
|
||||||
getScene().broadcastPacket(new PacketDungeonChallengeBeginNotify(this));
|
getScene().broadcastPacket(new PacketDungeonChallengeBeginNotify(this));
|
||||||
@ -83,23 +114,57 @@ public class DungeonChallenge {
|
|||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
this.progress = false;
|
this.progress = false;
|
||||||
|
|
||||||
getScene().broadcastPacket(new PacketDungeonChallengeFinishNotify(this));
|
getScene().broadcastPacket(new PacketDungeonChallengeFinishNotify(this));
|
||||||
|
|
||||||
if (this.isSuccess()) {
|
if (this.isSuccess()) {
|
||||||
|
// Call success script event
|
||||||
this.getScene().getScriptManager().callEvent(EventType.EVENT_CHALLENGE_SUCCESS, null);
|
this.getScene().getScriptManager().callEvent(EventType.EVENT_CHALLENGE_SUCCESS, null);
|
||||||
|
|
||||||
|
// Settle
|
||||||
|
settle();
|
||||||
} else {
|
} else {
|
||||||
this.getScene().getScriptManager().callEvent(EventType.EVENT_CHALLENGE_FAIL, null);
|
this.getScene().getScriptManager().callEvent(EventType.EVENT_CHALLENGE_FAIL, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void settle() {
|
||||||
|
getScene().setAutoCloseTime(Utils.getCurrentSeconds() + 1000);
|
||||||
|
getScene().broadcastPacket(new PacketDungeonSettleNotify(this));
|
||||||
|
|
||||||
|
getScene().getScriptManager().callEvent(EventType.EVENT_DUNGEON_SETTLE, new ScriptArgs(this.isSuccess() ? 1 : 0));
|
||||||
|
}
|
||||||
|
|
||||||
public void onMonsterDie(EntityMonster entity) {
|
public void onMonsterDie(EntityMonster entity) {
|
||||||
score = getScore() + 1;
|
score = getScore() + 1;
|
||||||
|
|
||||||
getScene().broadcastPacket(new PacketChallengeDataNotify(this, 1, getScore()));
|
getScene().broadcastPacket(new PacketChallengeDataNotify(this, 1, getScore()));
|
||||||
|
|
||||||
if (getScore() >= objective) {
|
if (getScore() >= getObjective()) {
|
||||||
this.setSuccess(true);
|
this.setSuccess(true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getStatueDrops(Player player) {
|
||||||
|
DungeonData dungeonData = getScene().getDungeonData();
|
||||||
|
if (!isSuccess() || dungeonData == null || dungeonData.getRewardPreview() == null || dungeonData.getRewardPreview().getPreviewItems().length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Already rewarded
|
||||||
|
if (getRewardedPlayers().contains(player.getUid())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GameItem> rewards = new ArrayList<>();
|
||||||
|
for (ItemParamData param : getScene().getDungeonData().getRewardPreview().getPreviewItems()) {
|
||||||
|
rewards.add(new GameItem(param.getId(), Math.max(param.getCount(), 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().addItems(rewards, ActionReason.DungeonStatueDrop);
|
||||||
|
player.sendPacket(new PacketGadgetAutoPickDropInfoNotify(rewards));
|
||||||
|
|
||||||
|
getRewardedPlayers().add(player.getUid());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,12 +415,6 @@ public class GameItem {
|
|||||||
Reliquary relic = this.toReliquaryProto();
|
Reliquary relic = this.toReliquaryProto();
|
||||||
proto.setEquip(Equip.newBuilder().setReliquary(relic).setIsLocked(this.isLocked()).build());
|
proto.setEquip(Equip.newBuilder().setReliquary(relic).setIsLocked(this.isLocked()).build());
|
||||||
break;
|
break;
|
||||||
case ITEM_MATERIAL:
|
|
||||||
Material material = Material.newBuilder()
|
|
||||||
.setCount(getCount())
|
|
||||||
.build();
|
|
||||||
proto.setMaterial(material);
|
|
||||||
break;
|
|
||||||
case ITEM_FURNITURE:
|
case ITEM_FURNITURE:
|
||||||
Furniture furniture = Furniture.newBuilder()
|
Furniture furniture = Furniture.newBuilder()
|
||||||
.setCount(getCount())
|
.setCount(getCount())
|
||||||
@ -428,6 +422,10 @@ public class GameItem {
|
|||||||
proto.setFurniture(furniture);
|
proto.setFurniture(furniture);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Material material = Material.newBuilder()
|
||||||
|
.setCount(getCount())
|
||||||
|
.build();
|
||||||
|
proto.setMaterial(material);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import emu.grasscutter.game.CoopRequest;
|
|||||||
import emu.grasscutter.game.avatar.Avatar;
|
import emu.grasscutter.game.avatar.Avatar;
|
||||||
import emu.grasscutter.game.avatar.AvatarProfileData;
|
import emu.grasscutter.game.avatar.AvatarProfileData;
|
||||||
import emu.grasscutter.game.avatar.AvatarStorage;
|
import emu.grasscutter.game.avatar.AvatarStorage;
|
||||||
|
import emu.grasscutter.game.entity.EntityGadget;
|
||||||
import emu.grasscutter.game.entity.EntityItem;
|
import emu.grasscutter.game.entity.EntityItem;
|
||||||
import emu.grasscutter.game.entity.GameEntity;
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
import emu.grasscutter.game.friends.FriendsList;
|
import emu.grasscutter.game.friends.FriendsList;
|
||||||
@ -21,6 +22,7 @@ import emu.grasscutter.game.inventory.Inventory;
|
|||||||
import emu.grasscutter.game.mail.Mail;
|
import emu.grasscutter.game.mail.Mail;
|
||||||
import emu.grasscutter.game.mail.MailHandler;
|
import emu.grasscutter.game.mail.MailHandler;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
|
import emu.grasscutter.game.props.EntityType;
|
||||||
import emu.grasscutter.game.props.PlayerProperty;
|
import emu.grasscutter.game.props.PlayerProperty;
|
||||||
import emu.grasscutter.game.shop.ShopLimit;
|
import emu.grasscutter.game.shop.ShopLimit;
|
||||||
import emu.grasscutter.game.world.Scene;
|
import emu.grasscutter.game.world.Scene;
|
||||||
@ -785,6 +787,16 @@ public class Player {
|
|||||||
else
|
else
|
||||||
this.getScene().broadcastPacket(new PacketGadgetInteractRsp(drop, InteractType.INTERACT_PICK_ITEM));
|
this.getScene().broadcastPacket(new PacketGadgetInteractRsp(drop, InteractType.INTERACT_PICK_ITEM));
|
||||||
}
|
}
|
||||||
|
} else if (entity instanceof EntityGadget) {
|
||||||
|
EntityGadget gadget = (EntityGadget) entity;
|
||||||
|
|
||||||
|
if (gadget.getGadgetData().getType() == EntityType.RewardStatue) {
|
||||||
|
if (scene.getChallenge() != null) {
|
||||||
|
scene.getChallenge().getStatueDrops(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sendPacket(new PacketGadgetInteractRsp(gadget, InteractType.INTERACT_OPEN_STATUE));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Delete directly
|
// Delete directly
|
||||||
entity.getScene().removeEntity(entity);
|
entity.getScene().removeEntity(entity);
|
||||||
|
@ -49,6 +49,7 @@ public class Scene {
|
|||||||
private final Set<SceneBlock> loadedBlocks;
|
private final Set<SceneBlock> loadedBlocks;
|
||||||
private boolean dontDestroyWhenEmpty;
|
private boolean dontDestroyWhenEmpty;
|
||||||
|
|
||||||
|
private int autoCloseTime;
|
||||||
private int time;
|
private int time;
|
||||||
private ClimateType climate;
|
private ClimateType climate;
|
||||||
private int weather;
|
private int weather;
|
||||||
@ -107,6 +108,20 @@ public class Scene {
|
|||||||
return this.entities.get(id);
|
return this.entities.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the autoCloseTime
|
||||||
|
*/
|
||||||
|
public int getAutoCloseTime() {
|
||||||
|
return autoCloseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param autoCloseTime the autoCloseTime to set
|
||||||
|
*/
|
||||||
|
public void setAutoCloseTime(int autoCloseTime) {
|
||||||
|
this.autoCloseTime = autoCloseTime;
|
||||||
|
}
|
||||||
|
|
||||||
public int getTime() {
|
public int getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
@ -520,8 +535,22 @@ public class Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spawn gadgets AFTER triggers are added
|
// Spawn gadgets AFTER triggers are added
|
||||||
|
// TODO
|
||||||
for (SceneGroup group : block.groups) {
|
for (SceneGroup group : block.groups) {
|
||||||
this.getScriptManager().spawnGadgetsInGroup(group);
|
if (group.init_config == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int suite = group.init_config.suite;
|
||||||
|
|
||||||
|
if (suite == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
this.getScriptManager().spawnGadgetsInGroup(group, suite);
|
||||||
|
suite++;
|
||||||
|
} while (suite < group.init_config.end_suite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,14 +234,31 @@ public class SceneScriptManager {
|
|||||||
variables.forEach(var -> this.getVariables().put(var.name, var.value));
|
variables.forEach(var -> this.getVariables().put(var.name, var.value));
|
||||||
|
|
||||||
// Add monsters to suite TODO optimize
|
// Add monsters to suite TODO optimize
|
||||||
HashMap<Integer, SceneMonster> map = (HashMap<Integer, SceneMonster>) group.monsters.stream().collect(Collectors.toMap(m -> m.config_id, m -> m));
|
Int2ObjectMap<Object> map = new Int2ObjectOpenHashMap<>();
|
||||||
|
group.monsters.forEach(m -> map.put(m.config_id, m));
|
||||||
|
group.gadgets.forEach(m -> map.put(m.config_id, m));
|
||||||
|
|
||||||
for (SceneSuite suite : group.suites) {
|
for (SceneSuite suite : group.suites) {
|
||||||
suite.sceneMonsters = new ArrayList<>(suite.monsters.size());
|
suite.sceneMonsters = new ArrayList<>(suite.monsters.size());
|
||||||
for (int id : suite.monsters) {
|
for (int id : suite.monsters) {
|
||||||
SceneMonster monster = map.get(id);
|
try {
|
||||||
if (monster != null) {
|
SceneMonster monster = (SceneMonster) map.get(id);
|
||||||
suite.sceneMonsters.add(monster);
|
if (monster != null) {
|
||||||
|
suite.sceneMonsters.add(monster);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
suite.sceneGadgets = new ArrayList<>(suite.gadgets.size());
|
||||||
|
for (int id : suite.gadgets) {
|
||||||
|
try {
|
||||||
|
SceneGadget gadget = (SceneGadget) map.get(id);
|
||||||
|
if (gadget != null) {
|
||||||
|
suite.sceneGadgets.add(gadget);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,8 +291,22 @@ public class SceneScriptManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void spawnGadgetsInGroup(SceneGroup group, int suiteIndex) {
|
||||||
|
spawnGadgetsInGroup(group, group.getSuiteByIndex(suiteIndex));
|
||||||
|
}
|
||||||
|
|
||||||
public void spawnGadgetsInGroup(SceneGroup group) {
|
public void spawnGadgetsInGroup(SceneGroup group) {
|
||||||
for (SceneGadget g : group.gadgets) {
|
spawnGadgetsInGroup(group, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void spawnGadgetsInGroup(SceneGroup group, SceneSuite suite) {
|
||||||
|
List<SceneGadget> gadgets = group.gadgets;
|
||||||
|
|
||||||
|
if (suite != null) {
|
||||||
|
gadgets = suite.sceneGadgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SceneGadget g : gadgets) {
|
||||||
EntityGadget entity = new EntityGadget(getScene(), g.gadget_id, g.pos);
|
EntityGadget entity = new EntityGadget(getScene(), g.gadget_id, g.pos);
|
||||||
|
|
||||||
if (entity.getGadgetData() == null) continue;
|
if (entity.getGadgetData() == null) continue;
|
||||||
|
@ -136,7 +136,7 @@ public class ScriptLib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// param3 (probably time limit for timed dungeons)
|
// param3 (probably time limit for timed dungeons)
|
||||||
public int ActiveChallenge(int challengeId, int challengeIndex, int param3, int groupId, int param4, int param5) {
|
public int ActiveChallenge(int challengeId, int challengeIndex, int param3, int groupId, int objectiveKills, int param5) {
|
||||||
SceneGroup group = getSceneScriptManager().getGroupById(groupId);
|
SceneGroup group = getSceneScriptManager().getGroupById(groupId);
|
||||||
|
|
||||||
if (group == null || group.monsters == null) {
|
if (group == null || group.monsters == null) {
|
||||||
@ -146,6 +146,7 @@ public class ScriptLib {
|
|||||||
DungeonChallenge challenge = new DungeonChallenge(getSceneScriptManager().getScene(), group);
|
DungeonChallenge challenge = new DungeonChallenge(getSceneScriptManager().getScene(), group);
|
||||||
challenge.setChallengeId(challengeId);
|
challenge.setChallengeId(challengeId);
|
||||||
challenge.setChallengeIndex(challengeIndex);
|
challenge.setChallengeIndex(challengeIndex);
|
||||||
|
challenge.setObjective(objectiveKills);
|
||||||
|
|
||||||
getSceneScriptManager().getScene().setChallenge(challenge);
|
getSceneScriptManager().getScene().setChallenge(challenge);
|
||||||
|
|
||||||
@ -163,8 +164,13 @@ public class ScriptLib {
|
|||||||
return getSceneScriptManager().getVariables().getOrDefault(var, 0);
|
return getSceneScriptManager().getVariables().getOrDefault(var, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuaValue ChangeGroupVariableValue(String var, int value) {
|
public int SetGroupVariableValue(String var, int value) {
|
||||||
getSceneScriptManager().getVariables().put(var, value);
|
getSceneScriptManager().getVariables().put(var, value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LuaValue ChangeGroupVariableValue(String var, int value) {
|
||||||
|
getSceneScriptManager().getVariables().put(var, getSceneScriptManager().getVariables().get(var) + value);
|
||||||
return LuaValue.ZERO;
|
return LuaValue.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,8 +185,8 @@ public class ScriptLib {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO just spawn all from group for now
|
|
||||||
this.getSceneScriptManager().spawnMonstersInGroup(group, suite);
|
this.getSceneScriptManager().spawnMonstersInGroup(group, suite);
|
||||||
|
this.getSceneScriptManager().spawnGadgetsInGroup(group, suite);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,10 @@ import emu.grasscutter.utils.Position;
|
|||||||
|
|
||||||
public class SceneSuite {
|
public class SceneSuite {
|
||||||
public List<Integer> monsters;
|
public List<Integer> monsters;
|
||||||
|
public List<Integer> gadgets;
|
||||||
public List<String> triggers;
|
public List<String> triggers;
|
||||||
public int rand_weight;
|
public int rand_weight;
|
||||||
|
|
||||||
public transient List<SceneMonster> sceneMonsters;
|
public transient List<SceneMonster> sceneMonsters;
|
||||||
|
public transient List<SceneGadget> sceneGadgets;
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,14 @@ import emu.grasscutter.net.proto.DungeonChallengeBeginNotifyOuterClass.DungeonCh
|
|||||||
public class PacketDungeonChallengeBeginNotify extends BasePacket {
|
public class PacketDungeonChallengeBeginNotify extends BasePacket {
|
||||||
|
|
||||||
public PacketDungeonChallengeBeginNotify(DungeonChallenge challenge) {
|
public PacketDungeonChallengeBeginNotify(DungeonChallenge challenge) {
|
||||||
super(PacketOpcodes.DungeonChallengeBeginNotify);
|
super(PacketOpcodes.DungeonChallengeBeginNotify, true);
|
||||||
|
|
||||||
DungeonChallengeBeginNotify proto = DungeonChallengeBeginNotify.newBuilder()
|
DungeonChallengeBeginNotify proto = DungeonChallengeBeginNotify.newBuilder()
|
||||||
.setChallengeId(challenge.getChallengeId())
|
.setChallengeId(challenge.getChallengeId())
|
||||||
.setChallengeIndex(challenge.getChallengeIndex())
|
.setChallengeIndex(challenge.getChallengeIndex())
|
||||||
.setGroupId(challenge.getGroup().id)
|
.setGroupId(challenge.getGroup().id)
|
||||||
|
.addParamList(challenge.getObjective())
|
||||||
|
.addParamList(challenge.getTimeLimit())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
|
@ -8,13 +8,12 @@ import emu.grasscutter.net.proto.DungeonChallengeFinishNotifyOuterClass.DungeonC
|
|||||||
public class PacketDungeonChallengeFinishNotify extends BasePacket {
|
public class PacketDungeonChallengeFinishNotify extends BasePacket {
|
||||||
|
|
||||||
public PacketDungeonChallengeFinishNotify(DungeonChallenge challenge) {
|
public PacketDungeonChallengeFinishNotify(DungeonChallenge challenge) {
|
||||||
super(PacketOpcodes.DungeonChallengeFinishNotify);
|
super(PacketOpcodes.DungeonChallengeFinishNotify, true);
|
||||||
|
|
||||||
DungeonChallengeFinishNotify proto = DungeonChallengeFinishNotify.newBuilder()
|
DungeonChallengeFinishNotify proto = DungeonChallengeFinishNotify.newBuilder()
|
||||||
.setChallengeIndex(challenge.getChallengeIndex())
|
.setChallengeIndex(challenge.getChallengeIndex())
|
||||||
.setIsSuccess(challenge.isSuccess())
|
.setIsSuccess(challenge.isSuccess())
|
||||||
.setUnk1(challenge.getChallengeId())
|
.setUnk1(2)
|
||||||
.setUnk2(30)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.game.dungeons.DungeonChallenge;
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.DungeonSettleNotifyOuterClass.DungeonSettleNotify;
|
||||||
|
|
||||||
|
public class PacketDungeonSettleNotify extends BasePacket {
|
||||||
|
|
||||||
|
public PacketDungeonSettleNotify(DungeonChallenge challenge) {
|
||||||
|
super(PacketOpcodes.DungeonSettleNotify);
|
||||||
|
|
||||||
|
DungeonSettleNotify proto = DungeonSettleNotify.newBuilder()
|
||||||
|
.setDungeonId(challenge.getScene().getDungeonData().getId())
|
||||||
|
.setIsSuccess(challenge.isSuccess())
|
||||||
|
.setCloseTime(challenge.getScene().getAutoCloseTime())
|
||||||
|
.setResult(challenge.isSuccess() ? 1 : 0)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import emu.grasscutter.game.inventory.GameItem;
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.GadgetAutoPickDropInfoNotifyOuterClass.GadgetAutoPickDropInfoNotify;
|
||||||
|
import emu.grasscutter.net.proto.GadgetAutoPickDropInfoNotifyOuterClass.GadgetAutoPickDropInfoNotify.Builder;
|
||||||
|
|
||||||
|
public class PacketGadgetAutoPickDropInfoNotify extends BasePacket {
|
||||||
|
|
||||||
|
public PacketGadgetAutoPickDropInfoNotify(Collection<GameItem> items) {
|
||||||
|
super(PacketOpcodes.GadgetAutoPickDropInfoNotify);
|
||||||
|
|
||||||
|
GadgetAutoPickDropInfoNotify.Builder proto = GadgetAutoPickDropInfoNotify.newBuilder();
|
||||||
|
|
||||||
|
items.forEach(item -> proto.addItemList(item.toProto()));
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user