forked from MagicBane/Server
Fail Conditions for effects fully loaded from parser values
This commit is contained in:
@@ -22,6 +22,7 @@ import engine.jobs.FinishRecycleTimeJob;
|
|||||||
import engine.jobs.UseItemJob;
|
import engine.jobs.UseItemJob;
|
||||||
import engine.jobs.UsePowerJob;
|
import engine.jobs.UsePowerJob;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
|
import engine.mbEnums;
|
||||||
import engine.mbEnums.*;
|
import engine.mbEnums.*;
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
@@ -127,9 +128,6 @@ public enum PowersManager {
|
|||||||
PowersManager.effectsBaseByIDString.put(effectBase.getIDString(), effectBase);
|
PowersManager.effectsBaseByIDString.put(effectBase.getIDString(), effectBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Fail Conditions **Replace with parsed values from cfg file**
|
|
||||||
EffectsBase.getFailConditions(PowersManager.effectsBaseByIDString);
|
|
||||||
|
|
||||||
// Add Modifiers to Effects **Replace with parsed values from cfg file**
|
// Add Modifiers to Effects **Replace with parsed values from cfg file**
|
||||||
dbEffectsBaseHandler.cacheAllEffectModifiers();
|
dbEffectsBaseHandler.cacheAllEffectModifiers();
|
||||||
|
|
||||||
@@ -145,23 +143,8 @@ public enum PowersManager {
|
|||||||
PowersParser.parseWpakFile();
|
PowersParser.parseWpakFile();
|
||||||
PowerActionParser.parseWpakFile();
|
PowerActionParser.parseWpakFile();
|
||||||
|
|
||||||
//InitializeEffects();
|
//Initialize Effects Data
|
||||||
|
InitializeEffects();
|
||||||
ArrayList<EffectsBase> ebList = dbEffectsBaseHandler.getAllEffectsBase();
|
|
||||||
|
|
||||||
for (EffectsBase eb : ebList) {
|
|
||||||
PowersManager.effectsBaseByToken.put(eb.getToken(), eb);
|
|
||||||
PowersManager.effectsBaseByIDString.put(eb.getIDString(), eb);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Fail Conditions
|
|
||||||
EffectsBase.getFailConditions(PowersManager.effectsBaseByIDString);
|
|
||||||
|
|
||||||
// Add Modifiers to Effects
|
|
||||||
dbEffectsBaseHandler.cacheAllEffectModifiers();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add PowerActions
|
// Add PowerActions
|
||||||
AbstractPowerAction.getAllPowerActions(PowersManager.powerActionsByIDString, PowersManager.powerActionsByID, PowersManager.effectsBaseByIDString);
|
AbstractPowerAction.getAllPowerActions(PowersManager.powerActionsByIDString, PowersManager.powerActionsByID, PowersManager.effectsBaseByIDString);
|
||||||
@@ -188,16 +171,6 @@ public enum PowersManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EffectsBase setEffectToken(int ID, int token) {
|
|
||||||
for (EffectsBase eb : PowersManager.effectsBaseByIDString.values()) {
|
|
||||||
if (eb.getUUID() == ID) {
|
|
||||||
eb.setToken(token);
|
|
||||||
return eb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void usePower(final PerformActionMsg msg, ClientConnection origin,
|
public static void usePower(final PerformActionMsg msg, ClientConnection origin,
|
||||||
boolean sendCastToSelf) {
|
boolean sendCastToSelf) {
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import engine.objects.PlayerCharacter;
|
|||||||
import engine.powers.effectmodifiers.*;
|
import engine.powers.effectmodifiers.*;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import engine.util.Hasher;
|
import engine.util.Hasher;
|
||||||
|
import engine.wpak.data.ConditionEntry;
|
||||||
import engine.wpak.data.EffectEntry;
|
import engine.wpak.data.EffectEntry;
|
||||||
import engine.wpak.data.EffectModifier;
|
import engine.wpak.data.EffectModifier;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
@@ -39,6 +40,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -48,34 +50,34 @@ public class EffectsBase {
|
|||||||
public static HashMap<String, HashSet<AbstractEffectModifier>> modifiersMap = new HashMap<>();
|
public static HashMap<String, HashSet<AbstractEffectModifier>> modifiersMap = new HashMap<>();
|
||||||
public static HashMap<Integer, HashSet<mbEnums.DamageType>> EffectDamageTypes = new HashMap<>();
|
public static HashMap<Integer, HashSet<mbEnums.DamageType>> EffectDamageTypes = new HashMap<>();
|
||||||
private static ConcurrentHashMap<String, String> itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
private static ConcurrentHashMap<String, String> itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||||
private static int NewID = 3000;
|
public static int NewID = 3000;
|
||||||
private int UUID;
|
public int UUID;
|
||||||
private String IDString;
|
public String IDString;
|
||||||
// private String name;
|
// public String name;
|
||||||
private int token;
|
public int token;
|
||||||
private float amount;
|
public float amount;
|
||||||
private float amountRamp;
|
public float amountRamp;
|
||||||
// flags
|
// flags
|
||||||
private boolean isItemEffect;
|
public boolean isItemEffect;
|
||||||
private boolean isSpireEffect;
|
public boolean isSpireEffect;
|
||||||
private boolean ignoreNoMod;
|
public boolean ignoreNoMod;
|
||||||
private boolean dontSave;
|
public boolean dontSave;
|
||||||
private boolean cancelOnAttack = false;
|
public boolean cancelOnAttack = false;
|
||||||
private boolean cancelOnAttackSwing = false;
|
public boolean cancelOnAttackSwing = false;
|
||||||
private boolean cancelOnCast = false;
|
public boolean cancelOnCast = false;
|
||||||
private boolean cancelOnCastSpell = false;
|
public boolean cancelOnCastSpell = false;
|
||||||
private boolean cancelOnEquipChange = false;
|
public boolean cancelOnEquipChange = false;
|
||||||
private boolean cancelOnLogout = false;
|
public boolean cancelOnLogout = false;
|
||||||
private boolean cancelOnMove = false;
|
public boolean cancelOnMove = false;
|
||||||
private boolean cancelOnNewCharm = false;
|
public boolean cancelOnNewCharm = false;
|
||||||
private boolean cancelOnSit = false;
|
public boolean cancelOnSit = false;
|
||||||
private boolean cancelOnTakeDamage = false;
|
public boolean cancelOnTakeDamage = false;
|
||||||
private boolean cancelOnTerritoryClaim = false;
|
public boolean cancelOnTerritoryClaim = false;
|
||||||
private boolean cancelOnUnEquip = false;
|
public boolean cancelOnUnEquip = false;
|
||||||
private boolean useRampAdd;
|
public boolean useRampAdd;
|
||||||
private boolean isPrefix = false; //used by items
|
public boolean isPrefix = false; //used by items
|
||||||
private boolean isSuffix = false; //used by items
|
public boolean isSuffix = false; //used by items
|
||||||
private String name = "";
|
public String name = "";
|
||||||
public float value = 0;
|
public float value = 0;
|
||||||
private ConcurrentHashMap<mbEnums.ResourceType, Integer> resourceCosts = new ConcurrentHashMap<>();
|
private ConcurrentHashMap<mbEnums.ResourceType, Integer> resourceCosts = new ConcurrentHashMap<>();
|
||||||
private ConcurrentHashMap<String, Boolean> sourceTypes = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
private ConcurrentHashMap<String, Boolean> sourceTypes = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||||
@@ -127,12 +129,108 @@ public class EffectsBase {
|
|||||||
this.effectSources.add(EffectSourceType.GetEffectSourceType(source));
|
this.effectSources.add(EffectSourceType.GetEffectSourceType(source));
|
||||||
|
|
||||||
//load fail conditions
|
//load fail conditions
|
||||||
for(String condition : entry.conditions.keySet())
|
for(ConditionEntry condition : entry.conditions){
|
||||||
this.effectFailCondition.add(PowerFailCondition.valueOf(condition));
|
PowerFailCondition failCondition = PowerFailCondition.valueOf(condition.condition);
|
||||||
|
this.effectFailCondition.add(failCondition);
|
||||||
|
loadFailConditions(failCondition,this,condition);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO load damage types and slopes from conditions
|
//TODO load damage types and slopes from conditions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadFailConditions(PowerFailCondition failCondition, EffectsBase eb, ConditionEntry entry){
|
||||||
|
|
||||||
|
if (failCondition == null || eb == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (failCondition) {
|
||||||
|
|
||||||
|
case TakeDamage:
|
||||||
|
|
||||||
|
// dont go any further.
|
||||||
|
|
||||||
|
if (eb == null)
|
||||||
|
break;
|
||||||
|
|
||||||
|
eb.cancelOnTakeDamage = true;
|
||||||
|
|
||||||
|
|
||||||
|
eb.amount = entry.arg;
|
||||||
|
eb.amountRamp = (float)entry.curveType.getValue();
|
||||||
|
eb.useRampAdd = (float)entry.curveType.getValue() != 0;
|
||||||
|
|
||||||
|
ArrayList<String> damageTypes = new ArrayList<>();
|
||||||
|
String damageType1 = "";
|
||||||
|
String damageType2 = "";
|
||||||
|
String damageType3 = "";
|
||||||
|
for(mbEnums.DamageType dt : entry.damageTypes){
|
||||||
|
damageTypes.add(dt.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (damageType1.isEmpty() && damageType2.isEmpty() && damageType3.isEmpty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(damageTypes.get(0) != null)
|
||||||
|
damageType1 = damageTypes.get(0);
|
||||||
|
|
||||||
|
if(damageTypes.get(1) != null)
|
||||||
|
damageType1 = damageTypes.get(1);
|
||||||
|
|
||||||
|
if(damageTypes.get(2) != null)
|
||||||
|
damageType1 = damageTypes.get(2);
|
||||||
|
|
||||||
|
if (!EffectsBase.EffectDamageTypes.containsKey(eb.getToken()))
|
||||||
|
EffectsBase.EffectDamageTypes.put(eb.getToken(), new HashSet<>());
|
||||||
|
|
||||||
|
mbEnums.DamageType dt = mbEnums.DamageType.getDamageType(damageType1);
|
||||||
|
if (dt != null)
|
||||||
|
EffectsBase.EffectDamageTypes.get(eb.token).add(dt);
|
||||||
|
|
||||||
|
dt = mbEnums.DamageType.getDamageType(damageType2);
|
||||||
|
if (dt != null)
|
||||||
|
EffectsBase.EffectDamageTypes.get(eb.token).add(dt);
|
||||||
|
dt = mbEnums.DamageType.getDamageType(damageType3);
|
||||||
|
if (dt != null)
|
||||||
|
EffectsBase.EffectDamageTypes.get(eb.token).add(dt);
|
||||||
|
break;
|
||||||
|
case Attack:
|
||||||
|
eb.cancelOnAttack = true;
|
||||||
|
break;
|
||||||
|
case AttackSwing:
|
||||||
|
eb.cancelOnAttackSwing = true;
|
||||||
|
break;
|
||||||
|
case Cast:
|
||||||
|
eb.cancelOnCast = true;
|
||||||
|
break;
|
||||||
|
case CastSpell:
|
||||||
|
eb.cancelOnCastSpell = true;
|
||||||
|
break;
|
||||||
|
case EquipChange:
|
||||||
|
eb.cancelOnEquipChange = true;
|
||||||
|
break;
|
||||||
|
case Logout:
|
||||||
|
eb.cancelOnLogout = true;
|
||||||
|
break;
|
||||||
|
case Move:
|
||||||
|
eb.cancelOnMove = true;
|
||||||
|
break;
|
||||||
|
case NewCharm:
|
||||||
|
eb.cancelOnNewCharm = true;
|
||||||
|
break;
|
||||||
|
case Sit:
|
||||||
|
eb.cancelOnSit = true;
|
||||||
|
break;
|
||||||
|
case TerritoryClaim:
|
||||||
|
eb.cancelOnTerritoryClaim = true;
|
||||||
|
break;
|
||||||
|
case UnEquip:
|
||||||
|
eb.cancelOnUnEquip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public EffectsBase(EffectsBase copyEffect, int newToken, String IDString) {
|
public EffectsBase(EffectsBase copyEffect, int newToken, String IDString) {
|
||||||
|
|
||||||
UUID = NewID++;
|
UUID = NewID++;
|
||||||
@@ -215,7 +313,7 @@ public class EffectsBase {
|
|||||||
// getFailConditions();
|
// getFailConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getFailConditions(HashMap<String, EffectsBase> effects) {
|
public static void loadFailConditions(HashMap<String, EffectsBase> effects) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_failcondition WHERE powerOrEffect = 'Effect';")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_failcondition WHERE powerOrEffect = 'Effect';")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user