Compare monster type restrictions as MonsterType
PowersBase.monsterTypeRestrictions is now an EnumSet<MonsterType> (DB values Siege/Centaur/Dwarf/Vampire read with CacheParserUtil.readEnum). MobBase gets monsterType from its race rune's rune_sub_type (all 2380 RACE runes convert); players use RaceType.getMonsterType(). No string compares and no rune lookup per cast. Same results as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b58211386
commit
a6f2495e57
3 files changed
+23
-12
No files matched your search
@@ -28,7 +28,6 @@ import engine.net.Dispatch;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.objects.*;
|
||||
import engine.parsers.objects.RuneTemplate;
|
||||
import engine.parsers.objects.wpak.PowerTemplate;
|
||||
import engine.powers.*;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
@@ -1285,20 +1284,25 @@ public enum PowersManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
// MONSTERTYPERESTRICTS: a target's monster type is its race rune's rune_sub_type (client g_MonsterTypeEnum, rune +0xC)
|
||||
// MONSTERTYPERESTRICTS: mobs use their race rune's monster type, players their RaceType's
|
||||
private static boolean isRestrictedMonsterType(AbstractWorldObject target, PowersBase pb) {
|
||||
|
||||
RuneTemplate raceRune = null;
|
||||
MonsterType monsterType = null;
|
||||
PlayerCharacter player;
|
||||
|
||||
if (target == null || pb.monsterTypeRestrictions.isEmpty())
|
||||
return false;
|
||||
|
||||
if (target.getObjectType() == GameObjectType.Mob)
|
||||
raceRune = RuneTemplate._runes.get(((Mob) target).getMobBaseID());
|
||||
else if (target.getObjectType() == GameObjectType.PlayerCharacter && ((PlayerCharacter) target).race != null)
|
||||
raceRune = RuneTemplate._runes.get(((PlayerCharacter) target).race.getRaceRuneID());
|
||||
if (target.getObjectType() == GameObjectType.Mob && ((Mob) target).getMobBase() != null)
|
||||
monsterType = ((Mob) target).getMobBase().monsterType;
|
||||
else if (target.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
player = (PlayerCharacter) target;
|
||||
|
||||
return raceRune != null && pb.monsterTypeRestrictions.contains(raceRune.rune_sub_type);
|
||||
if (player.race != null && player.race.getRaceType() != null)
|
||||
monsterType = player.race.getRaceType().getMonsterType();
|
||||
}
|
||||
|
||||
return monsterType != null && pb.monsterTypeRestrictions.contains(monsterType);
|
||||
}
|
||||
|
||||
public static void sendRecyclePower(int token, ClientConnection origin) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import engine.gameManager.ItemManager;
|
||||
import engine.gameManager.LootManager;
|
||||
import engine.loot.BootySetEntry;
|
||||
import engine.mbEnums;
|
||||
import engine.parsers.cache.CacheParserUtil;
|
||||
import engine.parsers.objects.RuneTemplate;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -35,6 +36,7 @@ public class MobBase extends AbstractGameObject {
|
||||
public mbEnums.MobBehaviourType fsm;
|
||||
public EnumSet<mbEnums.MonsterType> notEnemy;
|
||||
public EnumSet<mbEnums.MonsterType> enemy;
|
||||
public mbEnums.MonsterType monsterType;
|
||||
private float healthMax;
|
||||
private int attackRating;
|
||||
private int defenseRating;
|
||||
@@ -78,6 +80,8 @@ public class MobBase extends AbstractGameObject {
|
||||
this.fsm = mbEnums.MobBehaviourType.valueOf(fsmName);
|
||||
this.notEnemy = EnumSet.copyOf(rune.rune_not_enemy_monster_types);
|
||||
this.enemy = EnumSet.copyOf(rune.rune_enemy_monster_types);
|
||||
// The race rune's sub type is its monster type (client g_MonsterTypeEnum, rune +0xC)
|
||||
this.monsterType = CacheParserUtil.readEnum(mbEnums.MonsterType.class, rune.rune_sub_type, rune.template_id, "rune_sub_type");
|
||||
this.walk = rune.rune_speed.getOrDefault(mbEnums.MovementType.WALK, 0f);
|
||||
this.walkCombat = rune.rune_speed.getOrDefault(mbEnums.MovementType.COMBATWALK, 0f);
|
||||
this.run = rune.rune_speed.getOrDefault(mbEnums.MovementType.RUN, 0f);
|
||||
|
||||
@@ -9,17 +9,20 @@
|
||||
|
||||
package engine.powers;
|
||||
|
||||
import engine.mbEnums.MonsterType;
|
||||
import engine.mbEnums.PowerCategoryType;
|
||||
import engine.mbEnums.PowerTargetType;
|
||||
import engine.parsers.cache.CacheParserUtil;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class PowersBase {
|
||||
|
||||
public final ArrayList<String> monsterTypeRestrictions = new ArrayList<>();
|
||||
public final EnumSet<MonsterType> monsterTypeRestrictions = EnumSet.noneOf(MonsterType.class);
|
||||
public final ArrayList<ActionsBase> actions = new ArrayList<>();
|
||||
public final ArrayList<PowerPrereq> effectPrereqs = new ArrayList<>();
|
||||
public final ArrayList<PowerPrereq> targetEffectPrereqs = new ArrayList<>();
|
||||
@@ -273,13 +276,13 @@ public class PowersBase {
|
||||
this.requiresHitRoll = true;
|
||||
ct = rs.getString("monsterTypeRestrict1").trim();
|
||||
if (!ct.isEmpty())
|
||||
this.monsterTypeRestrictions.add(ct);
|
||||
this.monsterTypeRestrictions.add(CacheParserUtil.readEnum(MonsterType.class, ct, this.UUID, "monsterTypeRestrict1"));
|
||||
ct = rs.getString("monsterTypeRestrict2").trim();
|
||||
if (!ct.isEmpty())
|
||||
this.monsterTypeRestrictions.add(ct);
|
||||
this.monsterTypeRestrictions.add(CacheParserUtil.readEnum(MonsterType.class, ct, this.UUID, "monsterTypeRestrict2"));
|
||||
ct = rs.getString("monsterTypeRestrict3").trim();
|
||||
if (!ct.isEmpty())
|
||||
this.monsterTypeRestrictions.add(ct);
|
||||
this.monsterTypeRestrictions.add(CacheParserUtil.readEnum(MonsterType.class, ct, this.UUID, "monsterTypeRestrict3"));
|
||||
}
|
||||
|
||||
public void setTargetType(String targetType) {
|
||||
|
||||
Reference in new issue
Block a user