Files
Server/src/engine/powers/poweractions/CreateMobPowerAction.java
T
MagicBotandClaude Opus 5.5 3fc5e7253a Build power actions from PowerActions.cfg
PowersManager.loadPowerActions builds every AbstractPowerAction from
PowerActionTemplate (template ctor on all subclasses), in id order with IDs
1..3046; OPENGATE keeps 5000. The ResultSet loader stays until removal.
The parser now reads the SimpleDamage (min, max), Teleport (bool), Track
(two bools) and TransferStat (bool at token 8) header fields.

Parity (JSON-Refactor-Plan/scripts/p47.py, every column): ids 3046/3046 plus
the DB-only AELFBORN row, which nothing references (the cfg has
BOON-AELFBORN). Effect ids, deferred powers, RemoveEffect source/REMOVEALL,
track filter/max, transfer types/ramps/ramp-add, mob level identical. The old
flags match the new header fields: Track 1024/2048 = tokens 3/4,
TransferStat 16384 = token 8, Teleport 32768 = SAB-001A's TRUE.

Value changes (PowerActions.cfg wins):
- DamageOverTime/TransferStatOT: the cfg value is the tick count; tick length
  = action duration / ticks. The DB stored cfg+1 as tick seconds, which only
  worked for 30s DoTs (5 x 6s, unchanged). HOLY-DOT-17 (60s) goes 10 -> 5
  ticks, BLEED-DOT (4s) 0 -> 4, TransferStatOT 30s 6 -> 5 ticks.
- TransferStat amounts are read with ToInt as the client does: 16 actions
  drop by 0.5 (BEL-001A 31.5 -> 31, CON-001A 13.5 -> 13, ...).
- PRE-334..337 become ApplyEffects with one effect; ApplyEffectsPowerAction
  now allows a missing second effect on baked-in items.
- Charm level cap ramp from the LEVELCAP= curve (same values as the DB).
- Charm actions with effect FEAR/CONFUSION (12, DB type Confusion) stay
  ConfusionPowerAction no-ops; CHARM ones use CharmPowerAction (decided).
- CreateMob: the cfg client mob id (49..74, 3500, 3501) maps to the mobbase
  through a map in CreateMobPowerAction, from the old DB values.
- The 50 Charm/Block/SpireDisable rows with no DB effect id get the cfg id
  (unread by those classes); isAggressive differs on 330 rows (unread).
- SimpleDamage keeps min/max instead of the always-0 simpleDamage (unread).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 05:37:36 -04:00

190 lines
7.1 KiB
Java

// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2026
// https://www.magicbane.com
package engine.powers.poweractions;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.DbManager;
import engine.gameManager.DispatchManager;
import engine.gameManager.NPCManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable;
import engine.mbEnums;
import engine.net.Dispatch;
import engine.net.client.ClientConnection;
import engine.net.client.msg.PetMsg;
import engine.objects.*;
import engine.parsers.objects.wpak.PowerActionTemplate;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
public class CreateMobPowerAction extends AbstractPowerAction {
// PowerActions.cfg names the pet by a client object id that no MBDATA file maps; this is the old DB mapping
private static final HashMap<Integer, Integer> MOBBASE_BY_CLIENT_MOB_ID = new HashMap<>();
private int mobID;
private int mobLevel;
static {
for (int clientMobID = 49; clientMobID <= 65; clientMobID++)
MOBBASE_BY_CLIENT_MOB_ID.put(clientMobID, 12000 + clientMobID - 49);
MOBBASE_BY_CLIENT_MOB_ID.put(68, 12018);
MOBBASE_BY_CLIENT_MOB_ID.put(69, 12020);
MOBBASE_BY_CLIENT_MOB_ID.put(70, 12019);
MOBBASE_BY_CLIENT_MOB_ID.put(71, 12021);
MOBBASE_BY_CLIENT_MOB_ID.put(72, 12022);
MOBBASE_BY_CLIENT_MOB_ID.put(74, 12023);
MOBBASE_BY_CLIENT_MOB_ID.put(3500, 11999);
MOBBASE_BY_CLIENT_MOB_ID.put(3501, 11998);
}
public CreateMobPowerAction(ResultSet rs) throws SQLException {
super(rs);
this.mobID = rs.getInt("mobID");
this.mobLevel = rs.getInt("mobLevel");
}
public CreateMobPowerAction(PowerActionTemplate powerActionTemplate, int id) {
super(powerActionTemplate, id);
Integer mobBaseID = MOBBASE_BY_CLIENT_MOB_ID.get(powerActionTemplate.mob_id);
if (mobBaseID == null)
Logger.error("Power action " + powerActionTemplate.action_id + ": no mobbase for client mob " + powerActionTemplate.mob_id);
this.mobID = (mobBaseID == null) ? 0 : mobBaseID;
this.mobLevel = powerActionTemplate.mob_level;
}
public int getMobID() {
return this.mobID;
}
public int getMobLevel() {
return this.mobLevel;
}
@Override
protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
if (source == null || !(source.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)))
return;
PlayerCharacter owner = (PlayerCharacter) source;
Mob currentPet = owner.getPet();
Zone seaFloor = ZoneManager.seaFloor;
Guild guild = Guild.getErrantGuild();
ClientConnection origin = owner.getClientConnection();
if (seaFloor == null || guild == null || origin == null)
return;
MobBase mobbase = MobBase.getMobBase(mobID);
if (mobbase == null) {
Logger.error("Attempt to summon pet with null mobbase: " + mobID);
return;
}
if (mobbase.isNecroPet() && owner.inSafeZone())
return;
//create Pet
Mob pet = Mob.createPetMinion(mobID, seaFloor, owner, (short) mobLevel);
if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet
if (currentPet != null && !currentPet.isNecroPet() && !currentPet.isSiege()) {
DbManager.removeFromCache(currentPet);
WorldGrid.RemoveWorldObject(currentPet);
currentPet.setCombatTarget(null);
seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear();
try {
currentPet.clearEffects();
} catch (Exception e) {
Logger.error(e.getMessage());
}
} else if (currentPet != null && currentPet.isSiege()) {
currentPet.agentType = mbEnums.AIAgentType.MOBILE;
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
WorldGrid.updateObject(currentPet);
}
//remove 10th pet
NPCManager.spawnNecroPet(owner, pet);
} else { //is not a necro pet
if (currentPet != null) {
if (!currentPet.isNecroPet() && !currentPet.isSiege()) {
DbManager.removeFromCache(currentPet);
currentPet.setCombatTarget(null);
currentPet.guardCaptain = null;
WorldGrid.RemoveWorldObject(currentPet);
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear();
currentPet.clearEffects();
//currentPet.disableIntelligence();
} else {
if (currentPet.isSiege()) {
currentPet.agentType = mbEnums.AIAgentType.MOBILE;
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
WorldGrid.updateObject(currentPet);
}
}
NPCManager.auditNecroPets(owner);
NPCManager.resetNecroPets(owner);
}
}
owner.setPet(pet);
pet.recalculateStats();
pet.healthMax = pet.level * 0.5f * 120;
pet.setHealth(pet.healthMax);
PetMsg pm = new PetMsg(5, pet);
Dispatch dispatch = Dispatch.borrow(owner, pm);
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
}
@Override
protected void _handleChant(AbstractCharacter source, AbstractWorldObject target, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
}
@Override
protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc,
int numTrains, ActionsBase ab, PowersBase pb, int duration) {
// TODO Auto-generated method stub
}
}