Browse Source

EffectDescription refactored out.

feature-config-parsing2
MagicBot 3 months ago
parent
commit
f4fc7fc75b
  1. 12
      src/engine/gameManager/PowersManager.java
  2. 7
      src/engine/powers/EffectsBase.java
  3. 38
      src/engine/wpak/EffectsParser.java
  4. 136
      src/engine/wpak/PowerActionParser.java
  5. 10
      src/engine/wpak/PowersParser.java
  6. 11
      src/engine/wpak/data/Effect.java
  7. 18
      src/engine/wpak/data/EffectDescription.java
  8. 6
      src/engine/wpak/data/Power.java
  9. 4
      src/engine/wpak/data/PowerAction.java

12
src/engine/gameManager/PowersManager.java

@ -34,7 +34,7 @@ import engine.server.MBServerStatics;
import engine.wpak.EffectsParser; import engine.wpak.EffectsParser;
import engine.wpak.PowerActionParser; import engine.wpak.PowerActionParser;
import engine.wpak.PowersParser; import engine.wpak.PowersParser;
import engine.wpak.data.EffectEntry; import engine.wpak.data.Effect;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
@ -120,7 +120,7 @@ public enum PowersManager {
// Add EffectsBase // Add EffectsBase
ArrayList<EffectsBase> effectList = new ArrayList<>(); ArrayList<EffectsBase> effectList = new ArrayList<>();
for (EffectEntry entry : EffectsParser.effect_data.values()) { for (Effect entry : EffectsParser.effect_data.values()) {
EffectsBase effectBase = new EffectsBase(entry); EffectsBase effectBase = new EffectsBase(entry);
effectList.add(effectBase); effectList.add(effectBase);
PowersManager.effectsBaseByToken.put(effectBase.getToken(), effectBase); PowersManager.effectsBaseByToken.put(effectBase.getToken(), effectBase);
@ -981,7 +981,7 @@ public enum PowersManager {
// if (!stackType.equals("IgnoreStack")) { // if (!stackType.equals("IgnoreStack")) {
if (target.getEffects().containsKey(stackType)) { if (target.getEffects().containsKey(stackType)) {
// remove any existing power that overrides // remove any existing power that overrides
Effect ef = target.getEffects().get(stackType); engine.objects.Effect ef = target.getEffects().get(stackType);
AbstractEffectJob effect = null; AbstractEffectJob effect = null;
if (ef != null) { if (ef != null) {
JobContainer jc = ef.getJobContainer(); JobContainer jc = ef.getJobContainer();
@ -1153,7 +1153,7 @@ public enum PowersManager {
// if (!stackType.equals("IgnoreStack")) { // if (!stackType.equals("IgnoreStack")) {
if (target.getEffects().containsKey(stackType)) { if (target.getEffects().containsKey(stackType)) {
// remove any existing power that overrides // remove any existing power that overrides
Effect ef = target.getEffects().get(stackType); engine.objects.Effect ef = target.getEffects().get(stackType);
AbstractEffectJob effect = null; AbstractEffectJob effect = null;
if (ef != null) { if (ef != null) {
JobContainer jc = ef.getJobContainer(); JobContainer jc = ef.getJobContainer();
@ -1467,7 +1467,7 @@ public enum PowersManager {
stackType = (stackType.equals("IgnoreStack")) ? Integer.toString(ab.getUUID()) : stackType; stackType = (stackType.equals("IgnoreStack")) ? Integer.toString(ab.getUUID()) : stackType;
if (target.getEffects().containsKey(stackType)) { if (target.getEffects().containsKey(stackType)) {
// remove any existing power that overrides // remove any existing power that overrides
Effect ef = target.getEffects().get(stackType); engine.objects.Effect ef = target.getEffects().get(stackType);
AbstractEffectJob effect = null; AbstractEffectJob effect = null;
if (ef != null) { if (ef != null) {
JobContainer jc = ef.getJobContainer(); JobContainer jc = ef.getJobContainer();
@ -1914,7 +1914,7 @@ public enum PowersManager {
stackType = (stackType.equals("IgnoreStack")) ? Integer stackType = (stackType.equals("IgnoreStack")) ? Integer
.toString(toRemove.getUUID()) : stackType; .toString(toRemove.getUUID()) : stackType;
if (fromChant) { if (fromChant) {
Effect eff = awo.getEffects().get(stackType); engine.objects.Effect eff = awo.getEffects().get(stackType);
if (eff != null) if (eff != null)
eff.cancelJob(true); eff.cancelJob(true);
} else } else

7
src/engine/powers/EffectsBase.java

@ -26,12 +26,11 @@ import engine.net.client.ClientConnection;
import engine.net.client.msg.ApplyEffectMsg; import engine.net.client.msg.ApplyEffectMsg;
import engine.objects.AbstractCharacter; import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject; import engine.objects.AbstractWorldObject;
import engine.objects.Effect;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.powers.effectmodifiers.AbstractEffectModifier;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.util.Hasher; import engine.util.Hasher;
import engine.wpak.data.EffectEntry; import engine.wpak.data.Effect;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.Connection; import java.sql.Connection;
@ -94,7 +93,7 @@ public class EffectsBase {
} }
//EffectEntry constructor //EffectEntry constructor
public EffectsBase(EffectEntry entry) { public EffectsBase(Effect entry) {
this.IDString = entry.effect_id; this.IDString = entry.effect_id;
this.name = entry.effect_name; this.name = entry.effect_name;
this.token = Hasher.SBStringHash(entry.effect_name); this.token = Hasher.SBStringHash(entry.effect_name);
@ -433,7 +432,7 @@ public class EffectsBase {
float duration = ab.getDurationInSeconds(trains); float duration = ab.getDurationInSeconds(trains);
if (pb.getToken() == 1672601862) { if (pb.getToken() == 1672601862) {
Effect eff = awo.getEffects().get("DeathShroud"); engine.objects.Effect eff = awo.getEffects().get("DeathShroud");
if (eff != null) { if (eff != null) {

38
src/engine/wpak/EffectsParser.java

@ -11,7 +11,7 @@ package engine.wpak;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.mbEnums; import engine.mbEnums;
import engine.wpak.data.ConditionEntry; import engine.wpak.data.ConditionEntry;
import engine.wpak.data.EffectEntry; import engine.wpak.data.Effect;
import engine.wpak.data.EffectModifier; import engine.wpak.data.EffectModifier;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -25,7 +25,7 @@ import java.util.regex.Pattern;
public class EffectsParser { public class EffectsParser {
public static String effectsPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Effects.cfg"; public static String effectsPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Effects.cfg";
public static HashMap<String, EffectEntry> effect_data = new HashMap<>(); public static HashMap<String, Effect> effect_data = new HashMap<>();
private static final Pattern EFFECT_REGEX = Pattern.compile("(?<=EFFECTBEGIN)(.+?)(?=EFFECTEND)", Pattern.DOTALL); private static final Pattern EFFECT_REGEX = Pattern.compile("(?<=EFFECTBEGIN)(.+?)(?=EFFECTEND)", Pattern.DOTALL);
private static final Pattern SOURCE_REGEX = Pattern.compile("(?<=SOURCEBEGIN)(.+?)(?=SOURCEEND)", Pattern.DOTALL); private static final Pattern SOURCE_REGEX = Pattern.compile("(?<=SOURCEBEGIN)(.+?)(?=SOURCEEND)", Pattern.DOTALL);
private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEND)", Pattern.DOTALL); private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEND)", Pattern.DOTALL);
@ -51,21 +51,21 @@ public class EffectsParser {
Matcher matcher = EFFECT_REGEX.matcher(fileContents); Matcher matcher = EFFECT_REGEX.matcher(fileContents);
while (matcher.find()) { while (matcher.find()) {
EffectEntry effectEntry = parseEffectEntry(matcher.group()); Effect effect = parseEffectEntry(matcher.group());
effect_data.put(effectEntry.effect_id, effectEntry); effect_data.put(effect.effect_id, effect);
} }
} }
private static EffectEntry parseEffectEntry(String effectData) { private static Effect parseEffectEntry(String effectData) {
EffectEntry effectEntry = new EffectEntry(); Effect effect = new Effect();
// Parse fields that lie outside the other tags // Parse fields that lie outside the other tags
effectEntry.isItemEffect = effectData.contains("IsItemEffect"); effect.isItemEffect = effectData.contains("IsItemEffect");
effectEntry.isSpireEffect = effectData.contains("IsSpireEffect"); effect.isSpireEffect = effectData.contains("IsSpireEffect");
effectEntry.ignoreNoMod = effectData.contains("IgnoreNoMod"); effect.ignoreNoMod = effectData.contains("IgnoreNoMod");
effectEntry.dontSave = effectData.contains("DontSave"); effect.dontSave = effectData.contains("DontSave");
// Remove all lines that contain a # and leading/trailing blank lines // Remove all lines that contain a # and leading/trailing blank lines
@ -90,24 +90,24 @@ public class EffectsParser {
while (matcher.find()) while (matcher.find())
effectHeader.add(matcher.group().trim()); effectHeader.add(matcher.group().trim());
effectEntry.effect_id = effectHeader.get(0); effect.effect_id = effectHeader.get(0);
effectEntry.effect_name = effectHeader.get(1); effect.effect_name = effectHeader.get(1);
effectEntry.effect_name = effectEntry.effect_name.replaceAll("\"", ""); effect.effect_name = effect.effect_name.replaceAll("\"", "");
// Some effect mods have no icon // Some effect mods have no icon
// (SEEINVIS-SHADE "See Invis") // (SEEINVIS-SHADE "See Invis")
if (effectHeader.size() == 3) if (effectHeader.size() == 3)
effectEntry.icon = Integer.parseInt(effectHeader.get(2)); effect.icon = Integer.parseInt(effectHeader.get(2));
else else
effectEntry.icon = 0; effect.icon = 0;
// Parse source entries // Parse source entries
matcher = SOURCE_REGEX.matcher(effectData); matcher = SOURCE_REGEX.matcher(effectData);
while (matcher.find()) while (matcher.find())
effectEntry.sources.add(matcher.group().trim()); effect.sources.add(matcher.group().trim());
// Parse modifier entries // Parse modifier entries
@ -117,7 +117,7 @@ public class EffectsParser {
while (matcher.find()) { while (matcher.find()) {
EffectModifier effectModifier = parseModEntry(matcher.group()); EffectModifier effectModifier = parseModEntry(matcher.group());
effectEntry.mods.add(effectModifier); effect.mods.add(effectModifier);
} }
// Parse Conditions // Parse Conditions
@ -141,11 +141,11 @@ public class EffectsParser {
while (iterator.hasNext()) while (iterator.hasNext())
conditionEntry.damageTypes.add(mbEnums.DamageType.valueOf(iterator.next().toUpperCase())); conditionEntry.damageTypes.add(mbEnums.DamageType.valueOf(iterator.next().toUpperCase()));
effectEntry.conditions.add(conditionEntry); effect.conditions.add(conditionEntry);
} }
} }
return effectEntry; return effect;
} }
private static EffectModifier parseModEntry(String modData) { private static EffectModifier parseModEntry(String modData) {

136
src/engine/wpak/PowerActionParser.java

@ -10,8 +10,8 @@ package engine.wpak;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.mbEnums; import engine.mbEnums;
import engine.wpak.data.EffectDescription; import engine.wpak.data.Effect;
import engine.wpak.data.PowerActionEntry; import engine.wpak.data.PowerAction;
import engine.wpak.data.StatTransfer; import engine.wpak.data.StatTransfer;
import engine.wpak.data.TrackEntry; import engine.wpak.data.TrackEntry;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -51,15 +51,15 @@ public class PowerActionParser {
while (matcher.find()) { while (matcher.find()) {
PowerActionEntry powerActionEntry = parsePowerActionEntry(matcher.group().trim()); PowerAction powerAction = parsePowerActionEntry(matcher.group().trim());
} }
} }
private static PowerActionEntry parsePowerActionEntry(String powerActionData) { private static PowerAction parsePowerActionEntry(String powerActionData) {
PowerActionEntry powerActionEntry = new PowerActionEntry(); PowerAction powerAction = new PowerAction();
EffectDescription effectDescription; Effect effect;
StatTransfer statTransfer; StatTransfer statTransfer;
TrackEntry trackEntry; TrackEntry trackEntry;
@ -81,34 +81,34 @@ public class PowerActionParser {
headerData.add(matcher.group().trim()); headerData.add(matcher.group().trim());
Iterator<String> headerIterator = headerData.iterator(); Iterator<String> headerIterator = headerData.iterator();
powerActionEntry.action_id = headerIterator.next(); powerAction.action_id = headerIterator.next();
powerActionEntry.action_type = headerIterator.next(); powerAction.action_type = headerIterator.next();
switch (powerActionEntry.action_type) { switch (powerAction.action_type) {
case "RemoveEffect": case "RemoveEffect":
effectDescription = new EffectDescription(); effect = new Effect();
effectDescription.effect_id = headerIterator.next(); effect.effect_id = headerIterator.next();
powerActionEntry.effects.add(effectDescription); powerAction.effects.add(effect);
break; break;
case "CreateMob": case "CreateMob":
powerActionEntry.petLevel = Integer.parseInt(headerIterator.next()); powerAction.petLevel = Integer.parseInt(headerIterator.next());
powerActionEntry.petRace = Integer.parseInt(headerIterator.next()); powerAction.petRace = Integer.parseInt(headerIterator.next());
break; break;
case "DamageOverTime": case "DamageOverTime":
effectDescription = new EffectDescription(); effect = new Effect();
effectDescription.effect_id = headerIterator.next(); effect.effect_id = headerIterator.next();
effectDescription.cycleDuration = Integer.parseInt(headerIterator.next()); effect.cycleDuration = Integer.parseInt(headerIterator.next());
effectDescription.cycleDelay = Integer.parseInt(headerIterator.next()); effect.cycleDelay = Integer.parseInt(headerIterator.next());
powerActionEntry.effects.add(effectDescription); powerAction.effects.add(effect);
break; break;
case "ApplyEffects": case "ApplyEffects":
int level = Integer.parseInt(headerIterator.next()); int level = Integer.parseInt(headerIterator.next());
while (headerIterator.hasNext()) { while (headerIterator.hasNext()) {
effectDescription = new EffectDescription(); effect = new Effect();
effectDescription.level = level; effect.level = level;
effectDescription.effect_id = headerIterator.next(); effect.effect_id = headerIterator.next();
powerActionEntry.effects.add(effectDescription); powerAction.effects.add(effect);
} }
break; break;
case "Transform": case "Transform":
@ -118,15 +118,15 @@ public class PowerActionParser {
case "DirectDamage": case "DirectDamage":
case "SpireDisable": case "SpireDisable":
while (headerIterator.hasNext()) { while (headerIterator.hasNext()) {
effectDescription = new EffectDescription(); effect = new Effect();
effectDescription.effect_id = headerIterator.next(); effect.effect_id = headerIterator.next();
// Some applyEffect entries are naked withot a level // Some applyEffect entries are naked withot a level
if (headerData.size() > 3) if (headerData.size() > 3)
effectDescription.level = Integer.parseInt(headerIterator.next()); effect.level = Integer.parseInt(headerIterator.next());
powerActionEntry.effects.add(effectDescription); powerAction.effects.add(effect);
} }
break; break;
case "TransferStat": case "TransferStat":
@ -139,7 +139,7 @@ public class PowerActionParser {
statTransfer.toCurve = mbEnums.CompoundCurveType.valueOf(headerIterator.next()); statTransfer.toCurve = mbEnums.CompoundCurveType.valueOf(headerIterator.next());
statTransfer.fromStatBool = Boolean.parseBoolean(headerIterator.next()); statTransfer.fromStatBool = Boolean.parseBoolean(headerIterator.next());
statTransfer.toStatBool = Boolean.parseBoolean(headerIterator.next()); statTransfer.toStatBool = Boolean.parseBoolean(headerIterator.next());
powerActionEntry.statTransfer = statTransfer; powerAction.statTransfer = statTransfer;
break; break;
case "TransferStatOT": case "TransferStatOT":
statTransfer = new StatTransfer(); statTransfer = new StatTransfer();
@ -153,26 +153,26 @@ public class PowerActionParser {
statTransfer.toStatBool = Boolean.parseBoolean(headerIterator.next()); statTransfer.toStatBool = Boolean.parseBoolean(headerIterator.next());
statTransfer.transfer_action = headerIterator.next(); statTransfer.transfer_action = headerIterator.next();
statTransfer.transfer_ticks = Integer.parseInt(headerIterator.next()); statTransfer.transfer_ticks = Integer.parseInt(headerIterator.next());
powerActionEntry.statTransfer = statTransfer; powerAction.statTransfer = statTransfer;
break; break;
case "Charm": case "Charm":
effectDescription = new EffectDescription(); effect = new Effect();
effectDescription.effect_id = headerIterator.next(); effect.effect_id = headerIterator.next();
effectDescription.level = Integer.parseInt(headerIterator.next()); effect.level = Integer.parseInt(headerIterator.next());
effectDescription.type = headerIterator.next(); effect.type = headerIterator.next();
powerActionEntry.effects.add(effectDescription); powerAction.effects.add(effect);
break; break;
case "Block": case "Block":
effectDescription = new EffectDescription(); effect = new Effect();
effectDescription.effect_id = headerIterator.next(); effect.effect_id = headerIterator.next();
effectDescription.level = Integer.parseInt(headerIterator.next()); effect.level = Integer.parseInt(headerIterator.next());
powerActionEntry.effects.add(effectDescription); powerAction.effects.add(effect);
break; break;
case "Resurrect": case "Resurrect":
powerActionEntry.levelCap = Integer.parseInt(headerIterator.next()); powerAction.levelCap = Integer.parseInt(headerIterator.next());
break; break;
case "SetItemFlag": case "SetItemFlag":
powerActionEntry.itemFlag = mbEnums.ItemFlags.valueOf(headerIterator.next()); powerAction.itemFlag = mbEnums.ItemFlags.valueOf(headerIterator.next());
break; break;
case "Track": case "Track":
trackEntry = new TrackEntry(); trackEntry = new TrackEntry();
@ -182,7 +182,7 @@ public class PowerActionParser {
trackEntry.type = headerIterator.next(); trackEntry.type = headerIterator.next();
trackEntry.min = Integer.parseInt(headerIterator.next()); trackEntry.min = Integer.parseInt(headerIterator.next());
trackEntry.max = Integer.parseInt(headerIterator.next()); trackEntry.max = Integer.parseInt(headerIterator.next());
powerActionEntry.trackEntry = trackEntry; powerAction.trackEntry = trackEntry;
break; break;
case "Recall": // No arguments for these tags or not parsed case "Recall": // No arguments for these tags or not parsed
case "Summon": case "Summon":
@ -198,7 +198,7 @@ public class PowerActionParser {
case "Steal": case "Steal":
break; break;
default: default:
Logger.error("Unhandled type " + powerActionEntry.action_type + " for Pow4erAction: " + powerActionEntry.action_id); Logger.error("Unhandled type " + powerAction.action_type + " for Pow4erAction: " + powerAction.action_id);
break; break;
} }
@ -215,81 +215,81 @@ public class PowerActionParser {
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments) for (String bodyPart : arguments)
powerActionEntry.bodyparts.add(Integer.parseInt(bodyPart)); powerAction.bodyparts.add(Integer.parseInt(bodyPart));
break; break;
case "FEMALEBODYPARTS": case "FEMALEBODYPARTS":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments) for (String bodyPart : arguments)
powerActionEntry.femaleBodyParts.add(Integer.parseInt(bodyPart)); powerAction.femaleBodyParts.add(Integer.parseInt(bodyPart));
break; break;
case "SCALEFACTOR": case "SCALEFACTOR":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String scaleFactor : arguments) for (String scaleFactor : arguments)
powerActionEntry.scaleFactor.add(Float.parseFloat(scaleFactor)); powerAction.scaleFactor.add(Float.parseFloat(scaleFactor));
break; break;
case "ISRESISTABLE": case "ISRESISTABLE":
powerActionEntry.isResistible = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.isResistible = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "ISAGGRESSIVE": case "ISAGGRESSIVE":
powerActionEntry.isAggressive = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.isAggressive = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "BLADETRAILS": case "BLADETRAILS":
powerActionEntry.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "SHOULDSHOWWEAPONS": case "SHOULDSHOWWEAPONS":
powerActionEntry.shouldShowWeapons = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.shouldShowWeapons = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "SHOULDSHOWARMOR": case "SHOULDSHOWARMOR":
powerActionEntry.shouldShowArmor = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.shouldShowArmor = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "APPLYEFFECTBLANK": case "APPLYEFFECTBLANK":
powerActionEntry.applyEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.applyEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "WEAROFFEFFECTBLANK": case "WEAROFFEFFECTBLANK":
powerActionEntry.wearOffEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.wearOffEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "ATTACKANIMS": case "ATTACKANIMS":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String animation : arguments) for (String animation : arguments)
powerActionEntry.attackAnimations.add(Integer.parseInt(animation)); powerAction.attackAnimations.add(Integer.parseInt(animation));
break; break;
case "REMOVEALL": case "REMOVEALL":
powerActionEntry.removeAll = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.removeAll = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "EFFECTID": case "EFFECTID":
effectDescription = new EffectDescription(); effect = new Effect();
effectDescription.effect_id = lineValues.get(1).trim(); effect.effect_id = lineValues.get(1).trim();
powerActionEntry.effects.add(effectDescription); powerAction.effects.add(effect);
break; break;
case "LEVELCAP": case "LEVELCAP":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerActionEntry.levelCap = Integer.parseInt(arguments.get(0)); powerAction.levelCap = Integer.parseInt(arguments.get(0));
if (arguments.size() > 1) // Not all level caps have a curve if (arguments.size() > 1) // Not all level caps have a curve
powerActionEntry.levelCurve = mbEnums.CompoundCurveType.valueOf(arguments.get(1)); powerAction.levelCurve = mbEnums.CompoundCurveType.valueOf(arguments.get(1));
break; break;
case "CLEARAGGRO": case "CLEARAGGRO":
powerActionEntry.clearAggro = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.clearAggro = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "TARGETBECOMESPET": case "TARGETBECOMESPET":
powerActionEntry.targetBecomesPet = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.targetBecomesPet = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "DESTROYOLDPET": case "DESTROYOLDPET":
powerActionEntry.destroyOldPet = Boolean.parseBoolean(lineValues.get(1).trim()); powerAction.destroyOldPet = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "DAMAGETYPE": case "DAMAGETYPE":
powerActionEntry.damageType = mbEnums.DamageType.valueOf(lineValues.get(1).trim().toUpperCase()); powerAction.damageType = mbEnums.DamageType.valueOf(lineValues.get(1).trim().toUpperCase());
break; break;
case "ROOTFSMID": case "ROOTFSMID":
powerActionEntry.rootFsmID = mbEnums.MobBehaviourType.valueOf(lineValues.get(1).trim()); powerAction.rootFsmID = mbEnums.MobBehaviourType.valueOf(lineValues.get(1).trim());
break; break;
case "SPLASHDAMAGE": case "SPLASHDAMAGE":
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerActionEntry.splashDamageMin = Integer.parseInt(arguments.get(0)); powerAction.splashDamageMin = Integer.parseInt(arguments.get(0));
powerActionEntry.splashDamageMax = Integer.parseInt(arguments.get(1)); powerAction.splashDamageMax = Integer.parseInt(arguments.get(1));
break; break;
case "APPLYEFFECTOTHER": case "APPLYEFFECTOTHER":
case "APPLYEFFECTSELF": case "APPLYEFFECTSELF":
@ -297,9 +297,9 @@ public class PowerActionParser {
case "WEAROFFEFFECTSELF": case "WEAROFFEFFECTSELF":
break; break;
default: default:
Logger.error("Unhandled variable type:" + key + " for powerAction: " + powerActionEntry.action_id); Logger.error("Unhandled variable type:" + key + " for powerAction: " + powerAction.action_id);
} }
} }
return powerActionEntry; return powerAction;
} }
} }

10
src/engine/wpak/PowersParser.java

@ -49,14 +49,14 @@ public class PowersParser {
while (matcher.find()) { while (matcher.find()) {
PowerEntry powerEntry = parsePowerEntry(matcher.group().trim()); Power power = parsePowerEntry(matcher.group().trim());
} }
} }
private static PowerEntry parsePowerEntry(String powerData) { private static Power parsePowerEntry(String powerData) {
PowerEntry powerEntry = new PowerEntry(); Power powerEntry = new Power();
StringBuilder conditionBuilder = new StringBuilder(); StringBuilder conditionBuilder = new StringBuilder();
StringBuilder powerBuilder = new StringBuilder(); StringBuilder powerBuilder = new StringBuilder();
String conditionString; String conditionString;
@ -222,7 +222,7 @@ public class PowersParser {
powerEntry.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim()); powerEntry.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim());
break; break;
case "EFFECTPREREQ": case "EFFECTPREREQ":
EffectDescription effectPreReq = new EffectDescription(); Effect effectPreReq = new Effect();
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
effectPreReq.effect_id = arguments.get(9); effectPreReq.effect_id = arguments.get(9);
effectPreReq.level = Integer.parseInt(arguments.get(1)); effectPreReq.level = Integer.parseInt(arguments.get(1));
@ -268,7 +268,7 @@ public class PowersParser {
powerEntry.casterPulseParticle = Integer.parseInt(lineValues.get(1).trim()); powerEntry.casterPulseParticle = Integer.parseInt(lineValues.get(1).trim());
break; break;
case "TARGETEFFECTPREREQS_ORED": case "TARGETEFFECTPREREQS_ORED":
EffectDescription preReq = new EffectDescription(); Effect preReq = new Effect();
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+")); arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
preReq.effect_id = arguments.get(0); preReq.effect_id = arguments.get(0);
preReq.level = Integer.parseInt(arguments.get(1)); preReq.level = Integer.parseInt(arguments.get(1));

11
src/engine/wpak/data/EffectEntry.java → src/engine/wpak/data/Effect.java

@ -11,7 +11,7 @@ package engine.wpak.data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
public class EffectEntry { public class Effect {
public String effect_id; public String effect_id;
public String effect_name; public String effect_name;
public int icon; public int icon;
@ -19,8 +19,17 @@ public class EffectEntry {
public ArrayList<EffectModifier> mods = new ArrayList<>(); public ArrayList<EffectModifier> mods = new ArrayList<>();
public ArrayList<ConditionEntry> conditions = new ArrayList<>(); public ArrayList<ConditionEntry> conditions = new ArrayList<>();
// Additional variables outside of tags or parsed
// elsewhere from Effects.cfg
public boolean isItemEffect; public boolean isItemEffect;
public boolean isSpireEffect; public boolean isSpireEffect;
public boolean ignoreNoMod; public boolean ignoreNoMod;
public boolean dontSave; public boolean dontSave;
public String type;
public int level;
public String message;
public int cycleDuration;
public int cycleDelay;
} }

18
src/engine/wpak/data/EffectDescription.java

@ -1,18 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.wpak.data;
public class EffectDescription {
public String effect_id;
public String type;
public int level;
public String message;
public int cycleDuration;
public int cycleDelay;
}

6
src/engine/wpak/data/PowerEntry.java → src/engine/wpak/data/Power.java

@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
public class PowerEntry { public class Power {
public String power_id; public String power_id;
public String power; public String power;
public ArrayList<PowerData> powers = new ArrayList<>(); public ArrayList<PowerData> powers = new ArrayList<>();
@ -49,7 +49,7 @@ public class PowerEntry {
public String category; public String category;
public boolean canCastWhileMoving = false; public boolean canCastWhileMoving = false;
public boolean bladeTrails = false; public boolean bladeTrails = false;
public ArrayList<EffectDescription> effectPreReqs = new ArrayList<>(); public ArrayList<Effect> effectPreReqs = new ArrayList<>();
public ArrayList<EquipmentPreReq> equipmentPreReq = new ArrayList<>(); public ArrayList<EquipmentPreReq> equipmentPreReq = new ArrayList<>();
public EnumSet<mbEnums.MonsterType> monsterRestricts = EnumSet.noneOf(mbEnums.MonsterType.class); public EnumSet<mbEnums.MonsterType> monsterRestricts = EnumSet.noneOf(mbEnums.MonsterType.class);
public EnumSet<mbEnums.MonsterType> monsterPrereqs = EnumSet.noneOf(mbEnums.MonsterType.class); public EnumSet<mbEnums.MonsterType> monsterPrereqs = EnumSet.noneOf(mbEnums.MonsterType.class);
@ -61,7 +61,7 @@ public class PowerEntry {
public int maxPlayerTargets; public int maxPlayerTargets;
public boolean isAdminPower = false; public boolean isAdminPower = false;
public int casterPulseParticle; public int casterPulseParticle;
public ArrayList<EffectDescription> targetEffectPrereqs = new ArrayList<>(); public ArrayList<Effect> targetEffectPrereqs = new ArrayList<>();
public boolean canCastWhileFlying = false; public boolean canCastWhileFlying = false;
public boolean isProjectile = false; public boolean isProjectile = false;
public HashMap<String, Float> conditions = new HashMap<>(); public HashMap<String, Float> conditions = new HashMap<>();

4
src/engine/wpak/data/PowerActionEntry.java → src/engine/wpak/data/PowerAction.java

@ -12,13 +12,13 @@ import engine.mbEnums;
import java.util.ArrayList; import java.util.ArrayList;
public class PowerActionEntry { public class PowerAction {
// Header values // Header values
public String action_id; public String action_id;
public String action_type; public String action_type;
public ArrayList<EffectDescription> effects = new ArrayList<>(); public ArrayList<Effect> effects = new ArrayList<>();
public int petLevel; public int petLevel;
public int petRace; public int petRace;
public StatTransfer statTransfer; public StatTransfer statTransfer;
Loading…
Cancel
Save