Rename and clean up MapleSummon
This commit is contained in:
@@ -189,7 +189,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
private final Map<Integer, Map<BuffStat, MapleBuffStatValueHolder>> buffEffects = new LinkedHashMap<>(); // non-overriding buffs thanks to Ronan
|
private final Map<Integer, Map<BuffStat, MapleBuffStatValueHolder>> buffEffects = new LinkedHashMap<>(); // non-overriding buffs thanks to Ronan
|
||||||
private final Map<Integer, Long> buffExpires = new LinkedHashMap<>();
|
private final Map<Integer, Long> buffExpires = new LinkedHashMap<>();
|
||||||
private final Map<Integer, KeyBinding> keymap = new LinkedHashMap<>();
|
private final Map<Integer, KeyBinding> keymap = new LinkedHashMap<>();
|
||||||
private final Map<Integer, MapleSummon> summons = new LinkedHashMap<>();
|
private final Map<Integer, Summon> summons = new LinkedHashMap<>();
|
||||||
private final Map<Integer, MapleCoolDownValueHolder> coolDowns = new LinkedHashMap<>();
|
private final Map<Integer, MapleCoolDownValueHolder> coolDowns = new LinkedHashMap<>();
|
||||||
private final EnumMap<Disease, Pair<DiseaseValueHolder, MobSkill>> diseases = new EnumMap<>(Disease.class);
|
private final EnumMap<Disease, Pair<DiseaseValueHolder, MobSkill>> diseases = new EnumMap<>(Disease.class);
|
||||||
private byte[] m_aQuickslotLoaded;
|
private byte[] m_aQuickslotLoaded;
|
||||||
@@ -628,7 +628,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSummon(int id, MapleSummon summon) {
|
public void addSummon(int id, Summon summon) {
|
||||||
summons.put(id, summon);
|
summons.put(id, summon);
|
||||||
|
|
||||||
if (summon.isPuppet()) {
|
if (summon.isPuppet()) {
|
||||||
@@ -828,7 +828,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
getMap().broadcastGMMessage(this, PacketCreator.cancelForeignBuff(id, dsstat), false);
|
getMap().broadcastGMMessage(this, PacketCreator.cancelForeignBuff(id, dsstat), false);
|
||||||
getMap().broadcastSpawnPlayerMapObjectMessage(this, this, false);
|
getMap().broadcastSpawnPlayerMapObjectMessage(this, this, false);
|
||||||
|
|
||||||
for (MapleSummon ms : this.getSummonsValues()) {
|
for (Summon ms : this.getSummonsValues()) {
|
||||||
getMap().broadcastNONGMMessage(this, PacketCreator.spawnSummon(ms, false), false);
|
getMap().broadcastNONGMMessage(this, PacketCreator.spawnSummon(ms, false), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3706,7 +3706,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
} else if (mbs == BuffStat.SUMMON || mbs == BuffStat.PUPPET) {
|
} else if (mbs == BuffStat.SUMMON || mbs == BuffStat.PUPPET) {
|
||||||
int summonId = mbsvh.effect.getSourceId();
|
int summonId = mbsvh.effect.getSourceId();
|
||||||
|
|
||||||
MapleSummon summon = summons.get(summonId);
|
Summon summon = summons.get(summonId);
|
||||||
if (summon != null) {
|
if (summon != null) {
|
||||||
getMap().broadcastMessage(PacketCreator.removeSummon(summon, true), summon.getPosition());
|
getMap().broadcastMessage(PacketCreator.removeSummon(summon, true), summon.getPosition());
|
||||||
getMap().removeMapObject(summon);
|
getMap().removeMapObject(summon);
|
||||||
@@ -5867,7 +5867,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<MapleSummon> getSummonsValues() {
|
public Collection<Summon> getSummonsValues() {
|
||||||
return summons.values();
|
return summons.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5875,7 +5875,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
summons.clear();
|
summons.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleSummon getSummonByKey(int id) {
|
public Summon getSummonByKey(int id) {
|
||||||
return summons.get(id);
|
return summons.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5883,7 +5883,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
return summons.isEmpty();
|
return summons.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsSummon(MapleSummon summon) {
|
public boolean containsSummon(Summon summon) {
|
||||||
return summons.containsValue(summon);
|
return summons.containsValue(summon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import client.Client;
|
|||||||
import constants.skills.DarkKnight;
|
import constants.skills.DarkKnight;
|
||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.MapleSummon;
|
import server.maps.Summon;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -38,10 +38,10 @@ public final class BeholderHandler extends AbstractPacketHandler {//Summon Skill
|
|||||||
@Override
|
@Override
|
||||||
public final void handlePacket(InPacket p, Client c) {
|
public final void handlePacket(InPacket p, Client c) {
|
||||||
//System.out.println(slea.toString());
|
//System.out.println(slea.toString());
|
||||||
Collection<MapleSummon> summons = c.getPlayer().getSummonsValues();
|
Collection<Summon> summons = c.getPlayer().getSummonsValues();
|
||||||
int oid = p.readInt();
|
int oid = p.readInt();
|
||||||
MapleSummon summon = null;
|
Summon summon = null;
|
||||||
for (MapleSummon sum : summons) {
|
for (Summon sum : summons) {
|
||||||
if (sum.getObjectId() == oid) {
|
if (sum.getObjectId() == oid) {
|
||||||
summon = sum;
|
summon = sum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import client.Client;
|
|||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.MapObject;
|
import server.maps.MapObject;
|
||||||
import server.maps.MapleSummon;
|
import server.maps.Summon;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
public final class DamageSummonHandler extends AbstractPacketHandler {
|
public final class DamageSummonHandler extends AbstractPacketHandler {
|
||||||
@@ -41,8 +41,8 @@ public final class DamageSummonHandler extends AbstractPacketHandler {
|
|||||||
Character player = c.getPlayer();
|
Character player = c.getPlayer();
|
||||||
MapObject mmo = player.getMap().getMapObject(oid);
|
MapObject mmo = player.getMap().getMapObject(oid);
|
||||||
|
|
||||||
if(mmo != null && mmo instanceof MapleSummon) {
|
if(mmo != null && mmo instanceof Summon) {
|
||||||
MapleSummon summon = (MapleSummon) mmo;
|
Summon summon = (Summon) mmo;
|
||||||
|
|
||||||
summon.addHP(-damage);
|
summon.addHP(-damage);
|
||||||
if (summon.getHP() <= 0) {
|
if (summon.getHP() <= 0) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ package net.server.channel.handlers;
|
|||||||
import client.Character;
|
import client.Character;
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.MapleSummon;
|
import server.maps.Summon;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
import tools.exceptions.EmptyMovementException;
|
import tools.exceptions.EmptyMovementException;
|
||||||
|
|
||||||
@@ -37,9 +37,9 @@ public final class MoveSummonHandler extends AbstractMovementPacketHandler {
|
|||||||
int oid = p.readInt();
|
int oid = p.readInt();
|
||||||
Point startPos = new Point(p.readShort(), p.readShort());
|
Point startPos = new Point(p.readShort(), p.readShort());
|
||||||
Character player = c.getPlayer();
|
Character player = c.getPlayer();
|
||||||
Collection<MapleSummon> summons = player.getSummonsValues();
|
Collection<Summon> summons = player.getSummonsValues();
|
||||||
MapleSummon summon = null;
|
Summon summon = null;
|
||||||
for (MapleSummon sum : summons) {
|
for (Summon sum : summons) {
|
||||||
if (sum.getObjectId() == oid) {
|
if (sum.getObjectId() == oid) {
|
||||||
summon = sum;
|
summon = sum;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import server.MapleItemInformationProvider;
|
|||||||
import server.MapleStatEffect;
|
import server.MapleStatEffect;
|
||||||
import server.life.Monster;
|
import server.life.Monster;
|
||||||
import server.life.MonsterInformationProvider;
|
import server.life.MonsterInformationProvider;
|
||||||
import server.maps.MapleSummon;
|
import server.maps.Summon;
|
||||||
import tools.FilePrinter;
|
import tools.FilePrinter;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
@@ -72,8 +72,8 @@ public final class SummonDamageHandler extends AbstractDealDamageHandler {
|
|||||||
if (!player.isAlive()) {
|
if (!player.isAlive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MapleSummon summon = null;
|
Summon summon = null;
|
||||||
for (MapleSummon sum : player.getSummonsValues()) {
|
for (Summon sum : player.getSummonsValues()) {
|
||||||
if (sum.getObjectId() == oid) {
|
if (sum.getObjectId() == oid) {
|
||||||
summon = sum;
|
summon = sum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -993,7 +993,7 @@ public class MapleStatEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (summonMovementType != null && pos != null) {
|
if (summonMovementType != null && pos != null) {
|
||||||
final MapleSummon tosummon = new MapleSummon(applyfrom, sourceid, pos, summonMovementType);
|
final Summon tosummon = new Summon(applyfrom, sourceid, pos, summonMovementType);
|
||||||
applyfrom.getMap().spawnSummon(tosummon);
|
applyfrom.getMap().spawnSummon(tosummon);
|
||||||
applyfrom.addSummon(sourceid, tosummon);
|
applyfrom.addSummon(sourceid, tosummon);
|
||||||
tosummon.addHP(x);
|
tosummon.addHP(x);
|
||||||
@@ -1171,7 +1171,7 @@ public class MapleStatEffect {
|
|||||||
chr.registerEffect(this, localStartTime, localStartTime + localDuration, true);
|
chr.registerEffect(this, localStartTime, localStartTime + localDuration, true);
|
||||||
SummonMovementType summonMovementType = getSummonMovementType();
|
SummonMovementType summonMovementType = getSummonMovementType();
|
||||||
if (summonMovementType != null) {
|
if (summonMovementType != null) {
|
||||||
final MapleSummon tosummon = new MapleSummon(chr, sourceid, chr.getPosition(), summonMovementType);
|
final Summon tosummon = new Summon(chr, sourceid, chr.getPosition(), summonMovementType);
|
||||||
if (!tosummon.isStationary()) {
|
if (!tosummon.isStationary()) {
|
||||||
chr.addSummon(sourceid, tosummon);
|
chr.addSummon(sourceid, tosummon);
|
||||||
tosummon.addHP(x);
|
tosummon.addHP(x);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import server.loot.LootManager;
|
|||||||
import server.maps.AbstractAnimatedMapObject;
|
import server.maps.AbstractAnimatedMapObject;
|
||||||
import server.maps.MapObjectType;
|
import server.maps.MapObjectType;
|
||||||
import server.maps.MapleMap;
|
import server.maps.MapleMap;
|
||||||
import server.maps.MapleSummon;
|
import server.maps.Summon;
|
||||||
import tools.IntervalBuilder;
|
import tools.IntervalBuilder;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
@@ -1796,14 +1796,14 @@ public class Monster extends AbstractLoadedLife {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
private boolean isPuppetInVicinity(MapleSummon summon) {
|
private boolean isPuppetInVicinity(Summon summon) {
|
||||||
return summon.getPosition().distanceSq(this.getPosition()) < 177777;
|
return summon.getPosition().distanceSq(this.getPosition()) < 177777;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCharacterPuppetInVicinity(Character chr) {
|
public boolean isCharacterPuppetInVicinity(Character chr) {
|
||||||
MapleStatEffect mse = chr.getBuffEffect(BuffStat.PUPPET);
|
MapleStatEffect mse = chr.getBuffEffect(BuffStat.PUPPET);
|
||||||
if (mse != null) {
|
if (mse != null) {
|
||||||
MapleSummon summon = chr.getSummonByKey(mse.getSourceId());
|
Summon summon = chr.getSummonByKey(mse.getSourceId());
|
||||||
|
|
||||||
// check whether mob is currently under a puppet's field of action or not
|
// check whether mob is currently under a puppet's field of action or not
|
||||||
if (summon != null) {
|
if (summon != null) {
|
||||||
@@ -2098,7 +2098,7 @@ public class Monster extends AbstractLoadedLife {
|
|||||||
c.sendPacket(PacketCreator.controlMonster(mob, false, immediateAggro));
|
c.sendPacket(PacketCreator.controlMonster(mob, false, immediateAggro));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void aggroRefreshPuppetVisibility(Character chrController, MapleSummon puppet) {
|
private void aggroRefreshPuppetVisibility(Character chrController, Summon puppet) {
|
||||||
// lame patch for client to redirect all aggro to the puppet
|
// lame patch for client to redirect all aggro to the puppet
|
||||||
|
|
||||||
List<Monster> puppetControlled = new LinkedList<>();
|
List<Monster> puppetControlled = new LinkedList<>();
|
||||||
@@ -2135,7 +2135,7 @@ public class Monster extends AbstractLoadedLife {
|
|||||||
|
|
||||||
MapleStatEffect puppetEffect = chrController.getBuffEffect(BuffStat.PUPPET);
|
MapleStatEffect puppetEffect = chrController.getBuffEffect(BuffStat.PUPPET);
|
||||||
if (puppetEffect != null) {
|
if (puppetEffect != null) {
|
||||||
MapleSummon puppet = chrController.getSummonByKey(puppetEffect.getSourceId());
|
Summon puppet = chrController.getSummonByKey(puppetEffect.getSourceId());
|
||||||
|
|
||||||
if (puppet != null && isPuppetInVicinity(puppet)) {
|
if (puppet != null && isPuppetInVicinity(puppet)) {
|
||||||
controllerHasPuppet = true;
|
controllerHasPuppet = true;
|
||||||
|
|||||||
@@ -2061,7 +2061,7 @@ public class MapleMap {
|
|||||||
return doorPortal;
|
return doorPortal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnSummon(final MapleSummon summon) {
|
public void spawnSummon(final Summon summon) {
|
||||||
spawnAndAddRangedMapObject(summon, c -> {
|
spawnAndAddRangedMapObject(summon, c -> {
|
||||||
if (summon != null) {
|
if (summon != null) {
|
||||||
c.sendPacket(PacketCreator.spawnSummon(summon, true));
|
c.sendPacket(PacketCreator.spawnSummon(summon, true));
|
||||||
@@ -2537,7 +2537,7 @@ public class MapleMap {
|
|||||||
|
|
||||||
MapleStatEffect summonStat = chr.getStatForBuff(BuffStat.SUMMON);
|
MapleStatEffect summonStat = chr.getStatForBuff(BuffStat.SUMMON);
|
||||||
if (summonStat != null) {
|
if (summonStat != null) {
|
||||||
MapleSummon summon = chr.getSummonByKey(summonStat.getSourceId());
|
Summon summon = chr.getSummonByKey(summonStat.getSourceId());
|
||||||
summon.setPosition(chr.getPosition());
|
summon.setPosition(chr.getPosition());
|
||||||
chr.getMap().spawnSummon(summon);
|
chr.getMap().spawnSummon(summon);
|
||||||
updateMapObjectVisibility(chr, summon);
|
updateMapObjectVisibility(chr, summon);
|
||||||
@@ -2699,7 +2699,7 @@ public class MapleMap {
|
|||||||
|
|
||||||
chr.leaveMap();
|
chr.leaveMap();
|
||||||
|
|
||||||
for (MapleSummon summon : new ArrayList<>(chr.getSummonsValues())) {
|
for (Summon summon : new ArrayList<>(chr.getSummonsValues())) {
|
||||||
if (summon.isStationary()) {
|
if (summon.isStationary()) {
|
||||||
chr.cancelEffectFromBuffStat(BuffStat.PUPPET);
|
chr.cancelEffectFromBuffStat(BuffStat.PUPPET);
|
||||||
} else {
|
} else {
|
||||||
@@ -2939,7 +2939,7 @@ public class MapleMap {
|
|||||||
if (isNonRangedType(o.getType())) {
|
if (isNonRangedType(o.getType())) {
|
||||||
o.sendSpawnData(c);
|
o.sendSpawnData(c);
|
||||||
} else if (o.getType() == MapObjectType.SUMMON) {
|
} else if (o.getType() == MapObjectType.SUMMON) {
|
||||||
MapleSummon summon = (MapleSummon) o;
|
Summon summon = (Summon) o;
|
||||||
if (summon.getOwner() == chr) {
|
if (summon.getOwner() == chr) {
|
||||||
if (chr.isSummonsEmpty() || !chr.containsSummon(summon)) {
|
if (chr.isSummonsEmpty() || !chr.containsSummon(summon)) {
|
||||||
objectWLock.lock();
|
objectWLock.lock();
|
||||||
|
|||||||
@@ -29,21 +29,23 @@ import tools.PacketCreator;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Jan
|
* @author Jan
|
||||||
*/
|
*/
|
||||||
public class MapleSummon extends AbstractAnimatedMapObject {
|
public class Summon extends AbstractAnimatedMapObject {
|
||||||
private Character owner;
|
private final Character owner;
|
||||||
private byte skillLevel;
|
private final byte skillLevel;
|
||||||
private int skill, hp;
|
private final int skill;
|
||||||
private SummonMovementType movementType;
|
private int hp;
|
||||||
|
private final SummonMovementType movementType;
|
||||||
|
|
||||||
public MapleSummon(Character owner, int skill, Point pos, SummonMovementType movementType) {
|
public Summon(Character owner, int skill, Point pos, SummonMovementType movementType) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.skillLevel = owner.getSkillLevel(SkillFactory.getSkill(skill));
|
this.skillLevel = owner.getSkillLevel(SkillFactory.getSkill(skill));
|
||||||
if (skillLevel == 0) throw new RuntimeException();
|
if (skillLevel == 0) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
|
||||||
this.movementType = movementType;
|
this.movementType = movementType;
|
||||||
setPosition(pos);
|
setPosition(pos);
|
||||||
}
|
}
|
||||||
@@ -92,12 +94,12 @@ public class MapleSummon extends AbstractAnimatedMapObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isPuppet() {
|
public final boolean isPuppet() {
|
||||||
switch (skill) {
|
switch (skill) {
|
||||||
case 3111002:
|
case 3111002:
|
||||||
case 3211002:
|
case 3211002:
|
||||||
case 13111004:
|
case 13111004:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1095,7 +1095,7 @@ public class PacketCreator {
|
|||||||
* @param animated Animated spawn?
|
* @param animated Animated spawn?
|
||||||
* @return The spawn packet for the map object.
|
* @return The spawn packet for the map object.
|
||||||
*/
|
*/
|
||||||
public static Packet spawnSummon(MapleSummon summon, boolean animated) {
|
public static Packet spawnSummon(Summon summon, boolean animated) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.SPAWN_SPECIAL_MAPOBJECT);
|
OutPacket p = OutPacket.create(SendOpcode.SPAWN_SPECIAL_MAPOBJECT);
|
||||||
p.writeInt(summon.getOwner().getId());
|
p.writeInt(summon.getOwner().getId());
|
||||||
p.writeInt(summon.getObjectId());
|
p.writeInt(summon.getObjectId());
|
||||||
@@ -1118,7 +1118,7 @@ public class PacketCreator {
|
|||||||
* @param animated Animated removal?
|
* @param animated Animated removal?
|
||||||
* @return The packet removing the object.
|
* @return The packet removing the object.
|
||||||
*/
|
*/
|
||||||
public static Packet removeSummon(MapleSummon summon, boolean animated) {
|
public static Packet removeSummon(Summon summon, boolean animated) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.REMOVE_SPECIAL_MAPOBJECT);
|
OutPacket p = OutPacket.create(SendOpcode.REMOVE_SPECIAL_MAPOBJECT);
|
||||||
p.writeInt(summon.getOwner().getId());
|
p.writeInt(summon.getOwner().getId());
|
||||||
p.writeInt(summon.getObjectId());
|
p.writeInt(summon.getObjectId());
|
||||||
|
|||||||
Reference in New Issue
Block a user