use of server.MapleStatEffect in project HeavenMS by ronancpl.
the class CloseRangeDamageHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
chr.setPetLootCd(System.currentTimeMillis());
/*long timeElapsed = System.currentTimeMillis() - chr.getAutobanManager().getLastSpam(8);
if(timeElapsed < 300) {
AutobanFactory.FAST_ATTACK.alert(chr, "Time: " + timeElapsed);
}
chr.getAutobanManager().spam(8);*/
AttackInfo attack = parseDamage(slea, chr, false, false);
if (chr.getBuffEffect(MapleBuffStat.MORPH) != null) {
if (chr.getBuffEffect(MapleBuffStat.MORPH).isMorphWithoutAttack()) {
// How are they attacking when the client won't let them?
chr.getClient().disconnect(false, false);
return;
}
}
if (// PE hacking or maybe just lagging
chr.getDojoEnergy() < 10000 && (attack.skill == 1009 || attack.skill == 10001009 || attack.skill == 20001009))
return;
if (chr.getMap().isDojoMap() && attack.numAttacked > 0) {
chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_ATK);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}
chr.getMap().broadcastMessage(chr, MaplePacketCreator.closeRangeAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, attack.allDamage, attack.speed, attack.direction, attack.display), false, true);
int numFinisherOrbs = 0;
Integer comboBuff = chr.getBuffedValue(MapleBuffStat.COMBO);
if (GameConstants.isFinisherSkill(attack.skill)) {
if (comboBuff != null) {
numFinisherOrbs = comboBuff.intValue() - 1;
}
chr.handleOrbconsume();
} else if (attack.numAttacked > 0) {
if (attack.skill != 1111008 && comboBuff != null) {
int orbcount = chr.getBuffedValue(MapleBuffStat.COMBO);
int oid = chr.isCygnus() ? DawnWarrior.COMBO : Crusader.COMBO;
int advcomboid = chr.isCygnus() ? DawnWarrior.ADVANCED_COMBO : Hero.ADVANCED_COMBO;
Skill combo = SkillFactory.getSkill(oid);
Skill advcombo = SkillFactory.getSkill(advcomboid);
MapleStatEffect ceffect;
int advComboSkillLevel = chr.getSkillLevel(advcombo);
if (advComboSkillLevel > 0) {
ceffect = advcombo.getEffect(advComboSkillLevel);
} else {
int comboLv = chr.getSkillLevel(combo);
if (comboLv <= 0 || chr.isGM())
comboLv = SkillFactory.getSkill(oid).getMaxLevel();
if (comboLv > 0)
ceffect = combo.getEffect(comboLv);
else
ceffect = null;
}
if (ceffect != null) {
if (orbcount < ceffect.getX() + 1) {
int neworbcount = orbcount + 1;
if (advComboSkillLevel > 0 && ceffect.makeChanceResult()) {
if (neworbcount <= ceffect.getX()) {
neworbcount++;
}
}
int olv = chr.getSkillLevel(oid);
if (olv <= 0)
olv = SkillFactory.getSkill(oid).getMaxLevel();
int duration = combo.getEffect(olv).getDuration();
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.COMBO, neworbcount));
chr.setBuffedValue(MapleBuffStat.COMBO, neworbcount);
duration -= (int) (System.currentTimeMillis() - chr.getBuffedStarttime(MapleBuffStat.COMBO));
c.announce(MaplePacketCreator.giveBuff(oid, duration, stat));
chr.getMap().broadcastMessage(chr, MaplePacketCreator.giveForeignBuff(chr.getId(), stat), false);
}
}
} else if (chr.getSkillLevel(chr.isCygnus() ? SkillFactory.getSkill(15100004) : SkillFactory.getSkill(5110001)) > 0 && (chr.getJob().isA(MapleJob.MARAUDER) || chr.getJob().isA(MapleJob.THUNDERBREAKER2))) {
for (int i = 0; i < attack.numAttacked; i++) {
chr.handleEnergyChargeGain();
}
}
}
if (attack.numAttacked > 0 && attack.skill == DragonKnight.SACRIFICE) {
// sacrifice attacks only 1 mob with 1 attack
int totDamageToOneMonster = 0;
final Iterator<List<Integer>> dmgIt = attack.allDamage.values().iterator();
if (dmgIt.hasNext()) {
totDamageToOneMonster = dmgIt.next().get(0).intValue();
}
int remainingHP = chr.getHp() - totDamageToOneMonster * attack.getAttackEffect(chr, null).getX() / 100;
if (remainingHP > 1) {
chr.setHp(remainingHP);
} else {
chr.setHp(1);
}
chr.updateSingleStat(MapleStat.HP, chr.getHp());
chr.checkBerserk(chr.isHidden());
}
if (attack.numAttacked > 0 && attack.skill == 1211002) {
boolean advcharge_prob = false;
int advcharge_level = chr.getSkillLevel(SkillFactory.getSkill(1220010));
if (advcharge_level > 0) {
advcharge_prob = SkillFactory.getSkill(1220010).getEffect(advcharge_level).makeChanceResult();
}
if (!advcharge_prob) {
chr.cancelEffectFromBuffStat(MapleBuffStat.WK_CHARGE);
}
}
int attackCount = 1;
if (attack.skill != 0) {
attackCount = attack.getAttackEffect(chr, null).getAttackCount();
}
if (numFinisherOrbs == 0 && GameConstants.isFinisherSkill(attack.skill)) {
return;
}
if (attack.skill % 10000000 == 1009) {
// bamboo
if (chr.getDojoEnergy() < 10000) {
// PE hacking or maybe just lagging
return;
}
chr.setDojoEnergy(0);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
c.announce(MaplePacketCreator.serverNotice(5, "As you used the secret skill, your energy bar has been reset."));
} else if (attack.skill > 0) {
Skill skill = SkillFactory.getSkill(attack.skill);
MapleStatEffect effect_ = skill.getEffect(chr.getSkillLevel(skill));
if (effect_.getCooldown() > 0) {
if (chr.skillIsCooling(attack.skill)) {
return;
} else {
c.announce(MaplePacketCreator.skillCooldown(attack.skill, effect_.getCooldown()));
chr.addCooldown(attack.skill, System.currentTimeMillis(), effect_.getCooldown() * 1000);
}
}
}
if ((chr.getSkillLevel(SkillFactory.getSkill(NightWalker.VANISH)) > 0 || chr.getSkillLevel(SkillFactory.getSkill(Rogue.DARK_SIGHT)) > 0) && chr.getBuffedValue(MapleBuffStat.DARKSIGHT) != null) {
// && chr.getBuffSource(MapleBuffStat.DARKSIGHT) != 9101004
chr.cancelEffectFromBuffStat(MapleBuffStat.DARKSIGHT);
chr.cancelBuffStats(MapleBuffStat.DARKSIGHT);
} else if (chr.getSkillLevel(SkillFactory.getSkill(WindArcher.WIND_WALK)) > 0 && chr.getBuffedValue(MapleBuffStat.WIND_WALK) != null) {
chr.cancelEffectFromBuffStat(MapleBuffStat.WIND_WALK);
chr.cancelBuffStats(MapleBuffStat.WIND_WALK);
}
applyAttack(attack, chr, attackCount);
}
use of server.MapleStatEffect in project HeavenMS by ronancpl.
the class EventInstanceManager method applyEventPlayersItemBuff.
public void applyEventPlayersItemBuff(int itemId) {
List<MapleCharacter> players = getPlayerList();
MapleStatEffect mse = MapleItemInformationProvider.getInstance().getItemEffect(itemId);
if (mse != null) {
for (MapleCharacter player : players) {
mse.applyTo(player);
}
}
}
use of server.MapleStatEffect in project HeavenMS by ronancpl.
the class EventInstanceManager method applyEventPlayersSkillBuff.
public void applyEventPlayersSkillBuff(int skillId, int skillLv) {
List<MapleCharacter> players = getPlayerList();
Skill skill = SkillFactory.getSkill(skillId);
if (skill != null) {
MapleStatEffect mse = skill.getEffect(Math.min(skillLv, skill.getMaxLevel()));
if (mse != null) {
for (MapleCharacter player : players) {
mse.applyTo(player);
}
}
}
}
use of server.MapleStatEffect in project HeavenMS by ronancpl.
the class MapleCharacter method registerChairBuff.
public void registerChairBuff() {
if (!ServerConstants.USE_CHAIR_EXTRAHEAL)
return;
int skillId = getJobMapChair(job);
int skillLv = getSkillLevel(skillId);
if (skillLv > 0) {
MapleStatEffect mapChairSkill = SkillFactory.getSkill(skillId).getEffect(skillLv);
mapChairSkill.applyTo(this);
}
}
use of server.MapleStatEffect in project HeavenMS by ronancpl.
the class MapleCharacter method handleEnergyChargeGain.
public void handleEnergyChargeGain() {
// to get here energychargelevel has to be > 0
Skill energycharge = isCygnus() ? SkillFactory.getSkill(ThunderBreaker.ENERGY_CHARGE) : SkillFactory.getSkill(Marauder.ENERGY_CHARGE);
MapleStatEffect ceffect;
ceffect = energycharge.getEffect(getSkillLevel(energycharge));
TimerManager tMan = TimerManager.getInstance();
if (energybar < 10000) {
energybar += 102;
if (energybar > 10000) {
energybar = 10000;
}
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.ENERGY_CHARGE, energybar));
setBuffedValue(MapleBuffStat.ENERGY_CHARGE, energybar);
client.announce(MaplePacketCreator.giveBuff(energybar, 0, stat));
client.announce(MaplePacketCreator.showOwnBuffEffect(energycharge.getId(), 2));
getMap().broadcastMessage(this, MaplePacketCreator.showBuffeffect(id, energycharge.getId(), 2));
getMap().broadcastMessage(this, MaplePacketCreator.giveForeignBuff(energybar, stat));
}
if (energybar >= 10000 && energybar < 11000) {
energybar = 15000;
final MapleCharacter chr = this;
tMan.schedule(new Runnable() {
@Override
public void run() {
energybar = 0;
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.ENERGY_CHARGE, energybar));
setBuffedValue(MapleBuffStat.ENERGY_CHARGE, energybar);
client.announce(MaplePacketCreator.giveBuff(energybar, 0, stat));
getMap().broadcastMessage(chr, MaplePacketCreator.giveForeignBuff(energybar, stat));
}
}, ceffect.getDuration());
}
}
Aggregations