Browse Source

Refactored mob powers to rune powers. Now uses rune_id to call into system which is derived in the getter to support minions.

feature-workorder
MagicBot 1 year ago
parent
commit
70a0ed135b
  1. 20
      src/engine/db/handlers/dbPowerHandler.java
  2. 6
      src/engine/devcmd/cmds/aiInfoCmd.java
  3. 30
      src/engine/gameManager/PowersManager.java
  4. 33
      src/engine/mobileAI/MobAI.java
  5. 3
      src/engine/objects/Mob.java
  6. 17
      src/engine/powers/MobPowerEntry.java
  7. 21
      src/engine/powers/RunePowerEntry.java
  8. 2
      src/engine/server/world/WorldServer.java

20
src/engine/db/handlers/dbPowerHandler.java

@ -15,7 +15,7 @@ import engine.gameManager.PowersManager; @@ -15,7 +15,7 @@ import engine.gameManager.PowersManager;
import engine.objects.Mob;
import engine.objects.PreparedStatementShared;
import engine.powers.EffectsBase;
import engine.powers.MobPowerEntry;
import engine.powers.RunePowerEntry;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
@ -86,16 +86,16 @@ public class dbPowerHandler extends dbHandlerBase { @@ -86,16 +86,16 @@ public class dbPowerHandler extends dbHandlerBase {
}
}
public static HashMap<Integer, ArrayList<MobPowerEntry>> LOAD_MOB_POWERS() {
public static HashMap<Integer, ArrayList<RunePowerEntry>> LOAD_MOB_POWERS() {
HashMap<Integer, ArrayList<MobPowerEntry>> mobPowers = new HashMap<>();
MobPowerEntry mobPowerEntry;
HashMap<Integer, ArrayList<RunePowerEntry>> mobPowers = new HashMap<>();
RunePowerEntry runePowerEntry;
int mobbaseID;
int recordsRead = 0;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_mobbase_powers ORDER BY `id` ASC;")) {
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_powers")) {
ResultSet rs = preparedStatement.executeQuery();
@ -104,15 +104,15 @@ public class dbPowerHandler extends dbHandlerBase { @@ -104,15 +104,15 @@ public class dbPowerHandler extends dbHandlerBase {
recordsRead++;
mobbaseID = rs.getInt("mobbaseUUID");
mobPowerEntry = new MobPowerEntry(rs);
runePowerEntry = new RunePowerEntry(rs);
if (mobPowers.get(mobbaseID) == null) {
ArrayList<MobPowerEntry> powerList = new ArrayList<>();
powerList.add(mobPowerEntry);
ArrayList<RunePowerEntry> powerList = new ArrayList<>();
powerList.add(runePowerEntry);
mobPowers.put(mobbaseID, powerList);
} else {
ArrayList<MobPowerEntry> powerList = mobPowers.get(mobbaseID);
powerList.add(mobPowerEntry);
ArrayList<RunePowerEntry> powerList = mobPowers.get(mobbaseID);
powerList.add(runePowerEntry);
mobPowers.put(mobbaseID, powerList);
}
}

6
src/engine/devcmd/cmds/aiInfoCmd.java

@ -15,7 +15,7 @@ import engine.gameManager.PowersManager; @@ -15,7 +15,7 @@ import engine.gameManager.PowersManager;
import engine.objects.AbstractGameObject;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import engine.powers.MobPowerEntry;
import engine.powers.RunePowerEntry;
import java.util.Map;
@ -91,8 +91,8 @@ public class aiInfoCmd extends AbstractDevCmd { @@ -91,8 +91,8 @@ public class aiInfoCmd extends AbstractDevCmd {
output += "Powers:" + newline;
for (MobPowerEntry mobPowerEntry : PowersManager.getPowersForMobile(mob))
output += PowersManager.getPowerByToken(mobPowerEntry.token).getName() + newline;
for (RunePowerEntry runePowerEntry : PowersManager.getPowersForRune(mob.getMobBaseID()))
output += PowersManager.getPowerByToken(runePowerEntry.token).getName() + newline;
throwbackInfo(playerCharacter, output);
}

30
src/engine/gameManager/PowersManager.java

@ -53,13 +53,9 @@ public enum PowersManager { @@ -53,13 +53,9 @@ public enum PowersManager {
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
public static HashMap<Integer, ArrayList<MobPowerEntry>> _allMobPowers;
public static HashMap<Integer, ArrayList<RunePowerEntry>> _allRunePowers;
private static JobScheduler js;
private PowersManager() {
}
public static void initPowersManager(boolean fullPowersLoad) {
if (fullPowersLoad)
@ -103,28 +99,14 @@ public enum PowersManager { @@ -103,28 +99,14 @@ public enum PowersManager {
}
}
public static ArrayList<MobPowerEntry> getPowersForMobile(Mob mobile) {
ArrayList<MobPowerEntry> mobPowers = new ArrayList<>();
ArrayList<MobPowerEntry> powerEntries;
public static ArrayList<RunePowerEntry> getPowersForRune(int rune_id) {
if (mobile.agentType.equals(AIAgentType.GUARDMINION))
powerEntries = PowersManager._allMobPowers.get(mobile.guardCaptain.contractUUID);
else
powerEntries = PowersManager._allMobPowers.get(mobile.contractUUID);
if (powerEntries != null)
mobPowers.addAll(powerEntries);
if (mobile.agentType.equals(AIAgentType.GUARDMINION))
powerEntries = PowersManager._allMobPowers.get(((Mob) mobile.guardCaptain).loadID);
else
powerEntries = PowersManager._allMobPowers.get(mobile.loadID);
ArrayList<RunePowerEntry> powerEntries = PowersManager._allRunePowers.get(rune_id);
if (powerEntries != null)
mobPowers.addAll(powerEntries);
if (powerEntries == null)
powerEntries = new ArrayList<>();
return mobPowers;
return powerEntries;
}
// This pre-loads all powers and effects

33
src/engine/mobileAI/MobAI.java

@ -22,8 +22,8 @@ import engine.net.client.msg.PerformActionMsg; @@ -22,8 +22,8 @@ import engine.net.client.msg.PerformActionMsg;
import engine.net.client.msg.PowerProjectileMsg;
import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.MobPowerEntry;
import engine.powers.PowersBase;
import engine.powers.RunePowerEntry;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
@ -323,7 +323,7 @@ public class MobAI { @@ -323,7 +323,7 @@ public class MobAI {
return false;
}
if (PowersManager.getPowersForMobile(mob).isEmpty())
if (PowersManager.getPowersForRune(mob.getMobBaseID()).isEmpty())
return false;
if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) {
@ -348,8 +348,8 @@ public class MobAI { @@ -348,8 +348,8 @@ public class MobAI {
// and casts it on the current target (or itself). Validation
// (including empty lists) is done previously within canCast();
ArrayList<MobPowerEntry> powerEntries;
ArrayList<MobPowerEntry> purgeEntries;
ArrayList<RunePowerEntry> powerEntries;
ArrayList<RunePowerEntry> purgeEntries;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.behaviourType.callsForHelp)
@ -357,22 +357,22 @@ public class MobAI { @@ -357,22 +357,22 @@ public class MobAI {
// Generate a list of tokens from the mob powers for this mobile.
powerEntries = new ArrayList<>(PowersManager.getPowersForMobile(mob));
powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
purgeEntries = new ArrayList<>();
// If player has this effect on them currently then remove
// this token from our list.
for (MobPowerEntry mobPowerEntry : powerEntries) {
for (RunePowerEntry runePowerEntry : powerEntries) {
PowersBase powerBase = PowersManager.getPowerByToken(mobPowerEntry.token);
PowersBase powerBase = PowersManager.getPowerByToken(runePowerEntry.token);
for (ActionsBase actionBase : powerBase.getActions()) {
String stackType = actionBase.stackType;
if (target.getEffects() != null && target.getEffects().containsKey(stackType))
purgeEntries.add(mobPowerEntry);
purgeEntries.add(runePowerEntry);
}
}
@ -431,37 +431,32 @@ public class MobAI { @@ -431,37 +431,32 @@ public class MobAI {
// and casts it on the current target (or itself). Validation
// (including empty lists) is done previously within canCast();
ArrayList<MobPowerEntry> powerEntries;
ArrayList<MobPowerEntry> purgeEntries;
ArrayList<RunePowerEntry> powerEntries;
ArrayList<RunePowerEntry> purgeEntries;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile.
powerEntries = PowersManager.getPowersForMobile(mob);
purgeEntries = new ArrayList<>();
// If player has this effect on them currently then remove
// this token from our list.
powerEntries = new ArrayList<>(PowersManager.getPowersForMobile(mob));
powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
purgeEntries = new ArrayList<>();
// If player has this effect on them currently then remove
// this token from our list.
for (MobPowerEntry mobPowerEntry : powerEntries) {
for (RunePowerEntry runePowerEntry : powerEntries) {
PowersBase powerBase = PowersManager.getPowerByToken(mobPowerEntry.token);
PowersBase powerBase = PowersManager.getPowerByToken(runePowerEntry.token);
for (ActionsBase actionBase : powerBase.getActions()) {
String stackType = actionBase.stackType;
if (target.getEffects() != null && target.getEffects().containsKey(stackType))
purgeEntries.add(mobPowerEntry);
purgeEntries.add(runePowerEntry);
}
}

3
src/engine/objects/Mob.java

@ -669,6 +669,9 @@ public class Mob extends AbstractIntelligenceAgent { @@ -669,6 +669,9 @@ public class Mob extends AbstractIntelligenceAgent {
public int getMobBaseID() {
if (this.agentType.equals(AIAgentType.GUARDMINION))
return this.guardCaptain.contract.getMobbaseID();
if (this.mobBase != null)
return this.mobBase.getObjectUUID();

17
src/engine/powers/MobPowerEntry.java

@ -1,17 +0,0 @@ @@ -1,17 +0,0 @@
package engine.powers;
import java.sql.ResultSet;
import java.sql.SQLException;
public class MobPowerEntry {
public int token;
public int rank;
public MobPowerEntry(ResultSet rs) throws SQLException {
this.token = rs.getInt("token");
this.rank = rs.getInt("rank");
}
}

21
src/engine/powers/RunePowerEntry.java

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
package engine.powers;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RunePowerEntry {
public String name;
public int token;
public String power_type;
public int rank;
public RunePowerEntry(ResultSet rs) throws SQLException {
this.name = rs.getString("name");
this.token = rs.getInt("token");
this.power_type = rs.getString("power_type");
this.rank = rs.getInt("rank");
}
}

2
src/engine/server/world/WorldServer.java

@ -352,7 +352,7 @@ public class WorldServer { @@ -352,7 +352,7 @@ public class WorldServer {
DbManager.MobBaseQueries.GET_ALL_MOBBASES();
Logger.info("Loading Mob Powers");
PowersManager._allMobPowers = dbPowerHandler.LOAD_MOB_POWERS();
PowersManager._allRunePowers = dbPowerHandler.LOAD_MOB_POWERS();
Logger.info("Loading item enchants");
DbManager.LootQueries.LOAD_ENCHANT_VALUES();

Loading…
Cancel
Save