fixed gadget hp properties and invincibility handling (#1773)

* fixed gadget hp properties and invincibility handling

* Allow killing of hp locked entities, if the damage is higher then the hp

Co-authored-by: hartie95 <mail@hartie95.de>
This commit is contained in:
Alexander Hartmann
2022-09-15 04:26:20 +02:00
committed by GitHub
parent 21ff749dca
commit 08fdcf6ed4
7 changed files with 111 additions and 10 deletions

View File

@@ -29,6 +29,7 @@ public class GameData {
private static final Int2ObjectMap<QuestEncryptionKey> questsKeys = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<HomeworldDefaultSaveData> homeworldDefaultSaveData = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<SceneNpcBornData> npcBornData = new Int2ObjectOpenHashMap<>();
@Getter private static final Map<String, ConfigGadget> gadgetConfigData = new HashMap<>();
// ExcelConfigs
private static final Int2ObjectMap<PlayerLevelData> playerLevelDataMap = new Int2ObjectOpenHashMap<>();

View File

@@ -68,6 +68,7 @@ public class ResourceLoader {
// Process into depots
GameDepot.load();
// Load spawn data and quests
loadGadgetConfigData();
loadSpawnData();
loadQuests();
loadScriptSceneData();
@@ -493,6 +494,31 @@ public class ResourceLoader {
Grasscutter.getLogger().debug("Loaded " + GameData.getSceneNpcBornData().size() + " SceneNpcBornDatas.");
}
@SneakyThrows
private static void loadGadgetConfigData() {
Files.list(Path.of(RESOURCE("BinOutput/Gadget/"))).forEach(filePath -> {
var file = filePath.toFile();
if (file.isDirectory() || !file.getName().endsWith("json")) {
return;
}
Map<String, ConfigGadget> config;
try {
config = JsonUtils.loadToMap(filePath.toString(), String.class, ConfigGadget.class);
} catch (Exception e) {
Grasscutter.getLogger().error("failed to load ConfigGadget entries for "+filePath, e);
return;
}
for (Entry<String, ConfigGadget> e : config.entrySet()) {
GameData.getGadgetConfigData().put(e.getKey(), e.getValue());
}
});
Grasscutter.getLogger().debug("Loaded {} ConfigGadget entries.", GameData.getGadgetConfigData().size());
}
@SneakyThrows
private static void loadBlossomResources() {
GameDepot.setBlossomConfig(DataLoader.loadClass("BlossomConfig.json", BlossomConfig.class));

View File

@@ -0,0 +1,15 @@
package emu.grasscutter.data.binout;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import javax.annotation.Nullable;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigGadget {
// There are more values that can be added that might be useful in the json
@Nullable
ConfigGadgetCombat combat;
}

View File

@@ -0,0 +1,12 @@
package emu.grasscutter.data.binout;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigGadgetCombat {
// There are more values that can be added that might be useful in the json
ConfigGadgetCombatProperty property;
}

View File

@@ -0,0 +1,19 @@
package emu.grasscutter.data.binout;
import com.google.gson.annotations.SerializedName;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigGadgetCombatProperty {
float HP;
boolean isLockHP;
boolean isInvincible;
boolean isGhostToAllied;
float attack;
float defence;
float weight;
boolean useCreatorProperty;
}