Skip to content

Commit

Permalink
Merge pull request Grasscutters#355 from Grasscutters/dungeon-scripts
Browse files Browse the repository at this point in the history
Implemented Dungeon Support
  • Loading branch information
memetrollsXD committed Apr 29, 2022
2 parents 590ea7d + fd09676 commit edda944
Show file tree
Hide file tree
Showing 71 changed files with 2,179 additions and 93 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ dependencies {

implementation group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.2'
implementation group: 'org.quartz-scheduler', name: 'quartz-jobs', version: '2.3.2'


implementation group: 'org.luaj', name: 'luaj-jse', version: '3.0.1'

protobuf files('proto/')

}

application {
Expand Down
9 changes: 9 additions & 0 deletions proto/ChallengeDataNotify.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message ChallengeDataNotify {
uint32 challenge_index = 1;
uint32 param_index = 2;
uint32 value = 3;
}
11 changes: 11 additions & 0 deletions proto/ChannellerSlabLoopDungeonResultInfo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message ChannellerSlabLoopDungeonResultInfo {
uint32 dungeon_index = 1;
bool is_success = 2;
uint32 challenge_score = 3;
uint32 challenge_max_score = 4;
bool is_in_time_limit = 5;
}
12 changes: 12 additions & 0 deletions proto/DungeonChallengeBeginNotify.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message DungeonChallengeBeginNotify {
uint32 challenge_id = 1;
uint32 challenge_index = 2;
repeated uint32 param_list = 3;
uint32 group_id = 4;
uint32 father_index = 5;
repeated uint32 uid_list = 6;
}
22 changes: 22 additions & 0 deletions proto/DungeonChallengeFinishNotify.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

import "ChannellerSlabLoopDungeonResultInfo.proto";
import "EffigyChallengeDungeonResultInfo.proto";
import "StrengthenPointData.proto";

message DungeonChallengeFinishNotify {
oneof Detail {
ChannellerSlabLoopDungeonResultInfo channeller_slab_loop_dungeon_result_info = 101;
EffigyChallengeDungeonResultInfo effigy_challenge_dungeon_result_info = 102;
}
uint32 challenge_index = 1;
bool is_success = 2;
bool is_new_record = 3;
uint32 challenge_record_type = 4;
uint32 current_value = 5;
map<uint32, StrengthenPointData> strengthen_point_data_map = 6;
uint32 unk1 = 7;
uint32 unk2 = 8;
}
16 changes: 16 additions & 0 deletions proto/DungeonSettleNotify.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

import "ParamList.proto";
import "StrengthenPointData.proto";

message DungeonSettleNotify {
uint32 dungeon_id = 1;
bool is_success = 2;
repeated uint32 fail_cond_list = 3;
map<uint32, ParamList> settle_show = 4;
uint32 close_time = 5;
map<uint32, StrengthenPointData> strengthen_point_data_map = 6;
uint32 result = 7;
}
11 changes: 11 additions & 0 deletions proto/EffigyChallengeDungeonResultInfo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message EffigyChallengeDungeonResultInfo {
uint32 challenge_id = 1;
bool is_success = 2;
uint32 challenge_score = 3;
uint32 challenge_max_score = 4;
bool is_in_time_limit = 5;
}
9 changes: 9 additions & 0 deletions proto/GadgetStateNotify.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message GadgetStateNotify {
uint32 gadget_entity_id = 1;
uint32 gadget_state = 2;
bool is_enable_interact = 3;
}
7 changes: 7 additions & 0 deletions proto/ParamList.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message ParamList {
repeated uint32 param_list_ = 1;
}
8 changes: 8 additions & 0 deletions proto/PlayerEnterDungeonReq.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message PlayerEnterDungeonReq {
uint32 point_id = 1;
uint32 dungeon_id = 2;
}
9 changes: 9 additions & 0 deletions proto/PlayerEnterDungeonRsp.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message PlayerEnterDungeonRsp {
int32 retcode = 1;
uint32 point_id = 2;
uint32 dungeon_id = 3;
}
8 changes: 8 additions & 0 deletions proto/PlayerQuitDungeonReq.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message PlayerQuitDungeonReq {
uint32 point_id = 1;
bool is_quit_immediately = 2;
}
8 changes: 8 additions & 0 deletions proto/PlayerQuitDungeonRsp.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message PlayerQuitDungeonRsp {
int32 retcode = 1;
uint32 point_id = 2;
}
8 changes: 8 additions & 0 deletions proto/SelectWorktopOptionReq.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message SelectWorktopOptionReq {
uint32 gadget_entity_id = 1;
uint32 option_id = 2;
}
9 changes: 9 additions & 0 deletions proto/SelectWorktopOptionRsp.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message SelectWorktopOptionRsp {
int32 retcode = 1;
uint32 gadget_entity_id = 2;
uint32 option_id = 3;
}
8 changes: 8 additions & 0 deletions proto/StrengthenPointData.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message StrengthenPointData {
uint32 base_point = 1;
uint32 cur_point = 2;
}
8 changes: 8 additions & 0 deletions proto/WorktopOptionNotify.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

option java_package = "emu.grasscutter.net.proto";

message WorktopOptionNotify {
uint32 gadget_entity_id = 1;
repeated uint32 option_list = 2;
}
1 change: 1 addition & 0 deletions src/main/java/emu/grasscutter/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public final class Config {
public String PACKETS_FOLDER = "./packets/";
public String DUMPS_FOLDER = "./dumps/";
public String KEY_FOLDER = "./keys/";
public String SCRIPTS_FOLDER = "./resources/Scripts/";
public String PLUGINS_FOLDER = "./plugins/";

public String RunMode = "HYBRID"; // HYBRID, DISPATCH_ONLY, GAME_ONLY
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/emu/grasscutter/Grasscutter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import emu.grasscutter.command.CommandMap;
import emu.grasscutter.plugin.PluginManager;
import emu.grasscutter.scripts.ScriptLoader;
import emu.grasscutter.utils.Utils;
import org.reflections.Reflections;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -67,6 +68,7 @@ public static void main(String[] args) throws Exception {

// Load all resources.
ResourceLoader.loadAll();
ScriptLoader.init();
// Database
DatabaseManager.initialize();

Expand Down
17 changes: 13 additions & 4 deletions src/main/java/emu/grasscutter/data/GameData.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ public class GameData {
private static final Int2ObjectMap<FetterCharacterCardData> fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();

private static final Int2ObjectMap<DungeonData> dungeonDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();

// Cache
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
private static Map<Integer, List<ShopGoodsData>> shopGoods = new HashMap<>();

public static char EJWOA = 's';

public static Int2ObjectMap<?> getMapByResourceDef(Class<?> resourceDefinition) {
Int2ObjectMap<?> map = null;

Expand Down Expand Up @@ -100,6 +102,11 @@ public static Map<String, OpenConfigEntry> getOpenConfigEntries() {
public static Map<String, ScenePointEntry> getScenePointEntries() {
return scenePointEntries;
}

// TODO optimize
public static ScenePointEntry getScenePointEntryById(int sceneId, int pointId) {
return getScenePointEntries().get(sceneId + "_" + pointId);
}

public static Int2ObjectMap<AvatarData> getAvatarDataMap() {
return avatarDataMap;
Expand Down Expand Up @@ -269,8 +276,10 @@ public static Int2ObjectMap<WorldLevelData> getWorldLevelDataMap() {
return worldLevelDataMap;
}

public static char EJWOA = 's';

public static Int2ObjectMap<DungeonData> getDungeonDataMap() {
return dungeonDataMap;
}

public static Map<Integer, List<ShopGoodsData>> getShopGoodsDataEntries() {
if (shopGoods.isEmpty()) {
shopGoodsDataMap.forEach((k, v) -> {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/emu/grasscutter/data/ResourceLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ private static void loadScenePoints() {

for (Map.Entry<String, JsonElement> entry : config.points.entrySet()) {
PointData pointData = Grasscutter.getGsonFactory().fromJson(entry.getValue(), PointData.class);
pointData.setId(Integer.parseInt(entry.getKey()));

ScenePointEntry sl = new ScenePointEntry(sceneId + "_" + entry.getKey(), pointData);
scenePointList.add(sl);
Expand Down
59 changes: 23 additions & 36 deletions src/main/java/emu/grasscutter/data/common/PointData.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,30 @@
package emu.grasscutter.data.common;

public class PointData {
private pos tranPos;
import emu.grasscutter.utils.Position;

public pos getTranPos() {
public class PointData {
private int id;
private String $type;
private Position tranPos;
private int[] dungeonIds;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getType() {
return $type;
}

public Position getTranPos() {
return tranPos;
}

public void setTranPos(pos tranPos) {
this.tranPos = tranPos;
}

public class pos {
private float x;
private float y;
private float z;

public float getX() {
return x;
}

public void setX(float x) {
this.x = x;
}

public float getY() {
return y;
}

public void setY(float y) {
this.y = y;
}

public float getZ() {
return z;
}

public void setZ(float z) {
this.z = z;
}
}
public int[] getDungeonIds() {
return dungeonIds;
}
}
33 changes: 33 additions & 0 deletions src/main/java/emu/grasscutter/data/def/DungeonData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package emu.grasscutter.data.def;

import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

import emu.grasscutter.game.props.SceneType;

@ResourceType(name = "DungeonExcelConfigData.json")
public class DungeonData extends GameResource {
private int Id;
private int SceneId;
private int ShowLevel;
private String InvolveType; // TODO enum

@Override
public int getId() {
return this.Id;
}

public int getSceneId() {
return SceneId;
}

public int getShowLevel() {
return ShowLevel;
}

@Override
public void onLoad() {

}
}
7 changes: 4 additions & 3 deletions src/main/java/emu/grasscutter/data/def/GadgetData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.EntityType;

@ResourceType(name = "GadgetExcelConfigData.json")
public class GadgetData extends GameResource {
private int Id;
private String Type;

private EntityType Type;
private String JsonName;
private boolean IsInteractive;
private String[] Tags;
Expand All @@ -22,7 +23,7 @@ public int getId() {
return this.Id;
}

public String getType() {
public EntityType getType() {
return Type;
}

Expand Down
Loading

0 comments on commit edda944

Please sign in to comment.