2026-07-26 19:08:44 -04:00
|
|
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
|
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
|
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
|
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
|
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
|
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
|
|
|
// https://www.magicbane.com
|
2022-04-30 09:41:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
package engine.powers.poweractions;
|
|
|
|
|
|
|
|
|
|
import engine.InterestManagement.WorldGrid;
|
|
|
|
|
import engine.gameManager.DbManager;
|
2024-05-12 13:14:42 -04:00
|
|
|
import engine.gameManager.DispatchManager;
|
2023-03-31 09:59:49 -04:00
|
|
|
import engine.gameManager.NPCManager;
|
2022-04-30 09:41:17 -04:00
|
|
|
import engine.gameManager.ZoneManager;
|
|
|
|
|
import engine.math.Vector3fImmutable;
|
2024-04-05 07:59:44 -04:00
|
|
|
import engine.mbEnums;
|
2022-04-30 09:41:17 -04:00
|
|
|
import engine.net.Dispatch;
|
|
|
|
|
import engine.net.client.ClientConnection;
|
|
|
|
|
import engine.net.client.msg.PetMsg;
|
|
|
|
|
import engine.objects.*;
|
2026-10-26 05:37:36 -04:00
|
|
|
import engine.parsers.objects.wpak.PowerActionTemplate;
|
2022-04-30 09:41:17 -04:00
|
|
|
import engine.powers.ActionsBase;
|
|
|
|
|
import engine.powers.PowersBase;
|
|
|
|
|
import org.pmw.tinylog.Logger;
|
|
|
|
|
|
2026-10-26 05:37:36 -04:00
|
|
|
import java.util.HashMap;
|
2022-04-30 09:41:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public class CreateMobPowerAction extends AbstractPowerAction {
|
|
|
|
|
|
2026-10-26 05:37:36 -04:00
|
|
|
// 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<>();
|
|
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
private int mobID;
|
|
|
|
|
private int mobLevel;
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2026-10-26 05:37:36 -04:00
|
|
|
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(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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
public int getMobID() {
|
|
|
|
|
return this.mobID;
|
|
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
public int getMobLevel() {
|
|
|
|
|
return this.mobLevel;
|
|
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
@Override
|
|
|
|
|
protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2024-04-05 07:59:44 -04:00
|
|
|
if (source == null || !(source.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)))
|
2023-07-15 09:23:48 -04:00
|
|
|
return;
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
PlayerCharacter owner = (PlayerCharacter) source;
|
|
|
|
|
Mob currentPet = owner.getPet();
|
2023-10-09 06:16:25 -04:00
|
|
|
Zone seaFloor = ZoneManager.seaFloor;
|
2023-07-15 09:23:48 -04:00
|
|
|
Guild guild = Guild.getErrantGuild();
|
|
|
|
|
ClientConnection origin = owner.getClientConnection();
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
if (seaFloor == null || guild == null || origin == null)
|
|
|
|
|
return;
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
MobBase mobbase = MobBase.getMobBase(mobID);
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
if (mobbase == null) {
|
|
|
|
|
Logger.error("Attempt to summon pet with null mobbase: " + mobID);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
if (mobbase.isNecroPet() && owner.inSafeZone())
|
|
|
|
|
return;
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
//create Pet
|
2023-08-26 15:34:27 -04:00
|
|
|
Mob pet = Mob.createPetMinion(mobID, seaFloor, owner, (short) mobLevel);
|
2022-04-30 09:41:17 -04:00
|
|
|
|
|
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet
|
|
|
|
|
if (currentPet != null && !currentPet.isNecroPet() && !currentPet.isSiege()) {
|
|
|
|
|
DbManager.removeFromCache(currentPet);
|
|
|
|
|
WorldGrid.RemoveWorldObject(currentPet);
|
2023-03-31 09:59:49 -04:00
|
|
|
currentPet.setCombatTarget(null);
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 18:38:46 -05:00
|
|
|
seaFloor.zoneMobSet.remove(currentPet);
|
2023-07-15 09:23:48 -04:00
|
|
|
currentPet.playerAgroMap.clear();
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
try {
|
|
|
|
|
currentPet.clearEffects();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Logger.error(e.getMessage());
|
|
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
} else if (currentPet != null && currentPet.isSiege()) {
|
2024-04-05 07:59:44 -04:00
|
|
|
currentPet.agentType = mbEnums.AIAgentType.MOBILE;
|
2023-08-27 21:04:34 -05:00
|
|
|
|
|
|
|
|
currentPet.guardCaptain = null;
|
2023-07-15 09:23:48 -04:00
|
|
|
currentPet.setCombatTarget(null);
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
if (currentPet.isAlive())
|
|
|
|
|
WorldGrid.updateObject(currentPet);
|
|
|
|
|
}
|
|
|
|
|
//remove 10th pet
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
NPCManager.spawnNecroPet(owner, pet);
|
|
|
|
|
|
|
|
|
|
} else { //is not a necro pet
|
|
|
|
|
if (currentPet != null) {
|
|
|
|
|
if (!currentPet.isNecroPet() && !currentPet.isSiege()) {
|
|
|
|
|
DbManager.removeFromCache(currentPet);
|
|
|
|
|
currentPet.setCombatTarget(null);
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-08-27 21:04:34 -05:00
|
|
|
currentPet.guardCaptain = null;
|
2023-07-15 09:23:48 -04:00
|
|
|
WorldGrid.RemoveWorldObject(currentPet);
|
2023-07-15 18:38:46 -05:00
|
|
|
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
|
|
|
|
|
seaFloor.zoneMobSet.remove(currentPet);
|
2023-07-15 09:23:48 -04:00
|
|
|
currentPet.playerAgroMap.clear();
|
|
|
|
|
currentPet.clearEffects();
|
|
|
|
|
//currentPet.disableIntelligence();
|
|
|
|
|
} else {
|
|
|
|
|
if (currentPet.isSiege()) {
|
2024-04-05 07:59:44 -04:00
|
|
|
currentPet.agentType = mbEnums.AIAgentType.MOBILE;
|
2023-08-27 21:04:34 -05:00
|
|
|
|
|
|
|
|
currentPet.guardCaptain = null;
|
2023-07-15 09:23:48 -04:00
|
|
|
currentPet.setCombatTarget(null);
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
if (currentPet.isAlive())
|
|
|
|
|
WorldGrid.updateObject(currentPet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
NPCManager.auditNecroPets(owner);
|
|
|
|
|
NPCManager.resetNecroPets(owner);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
owner.setPet(pet);
|
2023-08-26 14:59:25 -04:00
|
|
|
|
2023-07-18 19:29:12 -05:00
|
|
|
pet.recalculateStats();
|
2023-07-18 19:51:00 -05:00
|
|
|
pet.healthMax = pet.level * 0.5f * 120;
|
2023-07-18 19:29:12 -05:00
|
|
|
pet.setHealth(pet.healthMax);
|
2023-07-15 09:23:48 -04:00
|
|
|
PetMsg pm = new PetMsg(5, pet);
|
|
|
|
|
Dispatch dispatch = Dispatch.borrow(owner, pm);
|
2024-05-12 13:14:42 -04:00
|
|
|
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
2023-07-15 09:23:48 -04:00
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
@Override
|
|
|
|
|
protected void _handleChant(AbstractCharacter source, AbstractWorldObject target, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
|
|
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
@Override
|
|
|
|
|
protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc,
|
|
|
|
|
int numTrains, ActionsBase ab, PowersBase pb, int duration) {
|
|
|
|
|
// TODO Auto-generated method stub
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2023-07-15 09:23:48 -04:00
|
|
|
}
|
2022-04-30 09:41:17 -04:00
|
|
|
}
|