Fix dropType de-serialization

enum edition
This commit is contained in:
StartForKiller 2023-06-04 16:50:56 -04:00 committed by KingRainbow44
parent ecb6145e54
commit b5595c3fab
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 14 additions and 6 deletions

View File

@ -3,9 +3,10 @@ package emu.grasscutter.data.binout;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.data.common.DynamicFloat;
import emu.grasscutter.game.props.ElementType; import emu.grasscutter.game.props.ElementType;
import java.io.Serializable;
import lombok.ToString; import lombok.ToString;
import java.io.Serializable;
public class AbilityModifier implements Serializable { public class AbilityModifier implements Serializable {
private static final long serialVersionUID = -2001232313615923575L; private static final long serialVersionUID = -2001232313615923575L;
@ -327,7 +328,7 @@ public class AbilityModifier implements Serializable {
public AbilityModifierAction[] successActions; public AbilityModifierAction[] successActions;
public AbilityModifierAction[] failActions; public AbilityModifierAction[] failActions;
public int dropType; public DropType dropType = DropType.LevelControl;
public DynamicFloat baseEnergy; public DynamicFloat baseEnergy;
public DynamicFloat ratio = DynamicFloat.ONE; public DynamicFloat ratio = DynamicFloat.ONE;
public int configID; public int configID;
@ -335,6 +336,12 @@ public class AbilityModifier implements Serializable {
public int param1; public int param1;
public int param2; public int param2;
public int param3; public int param3;
public enum DropType {
LevelControl,
BigWorldOnly,
ForceDrop
}
} }
// The following should be implemented into DynamicFloat if older resource formats need to be // The following should be implemented into DynamicFloat if older resource formats need to be

View File

@ -5,6 +5,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction.DropType;
import emu.grasscutter.data.binout.config.ConfigLevelEntity; import emu.grasscutter.data.binout.config.ConfigLevelEntity;
import emu.grasscutter.game.ability.Ability; import emu.grasscutter.game.ability.Ability;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
@ -29,7 +30,7 @@ public final class ActionGenerateElemBall extends AbilityActionHandler {
} }
//Check if we should allow elem ball generation //Check if we should allow elem ball generation
if (action.dropType == 0x0) { if(action.dropType == DropType.LevelControl) {
String levelEntityConfig = owner.getScene().getSceneData().getLevelEntityConfig(); String levelEntityConfig = owner.getScene().getSceneData().getLevelEntityConfig();
ConfigLevelEntity config = GameData.getConfigLevelEntityDataMap().get(levelEntityConfig); ConfigLevelEntity config = GameData.getConfigLevelEntityDataMap().get(levelEntityConfig);
if (config != null if (config != null
@ -38,7 +39,7 @@ public final class ActionGenerateElemBall extends AbilityActionHandler {
Grasscutter.getLogger().warn("This level config don't allow element balls"); Grasscutter.getLogger().warn("This level config don't allow element balls");
return true; return true;
} }
} else if (action.dropType == 0x1) { } else if(action.dropType == DropType.BigWorldOnly) {
if(owner.getScene().getSceneData().getSceneType() != SceneType.SCENE_WORLD) { if(owner.getScene().getSceneData().getSceneType() != SceneType.SCENE_WORLD) {
Grasscutter.getLogger().warn("This level config only allows element balls on big world"); Grasscutter.getLogger().warn("This level config only allows element balls on big world");
return true; return true;