Fixed Legendary Spirit UI getting stuck when trying to apply scrolls in equipments without upgrade slots available. Revised map leasing. Players no longer lose ownership when changing maps. Players are allowed to lease one map each time. Revised expeditions warping players out as soon as the leader leaves the event or the number of players inside gets to be less than the minimum required to enter. Fixed start/complete quest commands not acting properly for some quests. Refactored quest loadouts unnecessarily reloading MapleData. Implemented support for daily boss limit entry, usable on expeditions. Revised potential exploit cases within chair, face expression, quest action, summon damage and mob damage mob handlers. Adjusted displayed date in Duey. Value displayed now should be consistent with the expected expiration time. Refactored damage for friendly mobs getting handled inside packet structure. Implemented support for Quick Delivery from Duey. Fixed Horntail specifically not dropping loots after recent updates. Refactored commands system. All commands are instanced at boot time instead of at every call. Fixed usage of Maker skill not sending MAKER_RESULT packet to players. This automatically reenables the actions button (such as create) in Maker UI. Adjusted minidungeons, now using time limits specified in their respective recipes. Reviewed the "timeLimit" property utilized by maps, which was poised to work on 2 different concepts altogether. Fixed Gaga space event, should be functional now. Added RPS minigame, resources implemented by Arnah. Fixed damage taken from mob auto-destruction not working properly.
115 lines
5.0 KiB
Java
115 lines
5.0 KiB
Java
/*
|
|
This file is part of the OdinMS Maple Story Server
|
|
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
|
Matthias Butz <matze@odinms.de>
|
|
Jan Christian Meyer <vimes@odinms.de>
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation version 3 as published by
|
|
the Free Software Foundation. You may not use, modify or distribute
|
|
this program under any other version of the GNU Affero General Public
|
|
License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package net.server.channel.handlers;
|
|
|
|
import java.util.Map;
|
|
import client.MapleClient;
|
|
import client.MapleCharacter;
|
|
import client.autoban.AutobanFactory;
|
|
import client.status.MonsterStatus;
|
|
import client.status.MonsterStatusEffect;
|
|
import net.AbstractMaplePacketHandler;
|
|
import server.life.MapleMonster;
|
|
import server.life.MapleMonsterInformationProvider;
|
|
import server.maps.MapleMap;
|
|
import tools.FilePrinter;
|
|
import tools.MaplePacketCreator;
|
|
import tools.data.input.SeekableLittleEndianAccessor;
|
|
|
|
/**
|
|
*
|
|
* @author Jay Estrella
|
|
* @author Ronan
|
|
*/
|
|
public final class MobDamageMobHandler extends AbstractMaplePacketHandler {
|
|
@Override
|
|
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
|
int from = slea.readInt();
|
|
slea.readInt();
|
|
int to = slea.readInt();
|
|
boolean magic = slea.readByte() == 0;
|
|
int dmg = slea.readInt();
|
|
MapleCharacter chr = c.getPlayer();
|
|
|
|
MapleMap map = chr.getMap();
|
|
MapleMonster attacker = map.getMonsterByOid(from);
|
|
MapleMonster damaged = map.getMonsterByOid(to);
|
|
|
|
if (attacker != null && damaged != null) {
|
|
int maxDmg = calcMaxDamage(attacker, damaged, magic); // thanks Darter (YungMoozi) for reporting unchecked dmg
|
|
|
|
if (dmg > maxDmg) {
|
|
AutobanFactory.DAMAGE_HACK.alert(c.getPlayer(), "Possible packet editing hypnotize damage exploit."); // thanks Rien dev team
|
|
|
|
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " had hypnotized " + MapleMonsterInformationProvider.getInstance().getMobNameFromId(attacker.getId()) + " to attack " + MapleMonsterInformationProvider.getInstance().getMobNameFromId(damaged.getId()) + " with damage " + dmg + " (max: " + maxDmg + ")");
|
|
dmg = maxDmg;
|
|
}
|
|
|
|
map.damageMonster(chr, damaged, dmg);
|
|
map.broadcastMessage(chr, MaplePacketCreator.damageMonster(to, dmg), false);
|
|
}
|
|
}
|
|
|
|
private static int calcMaxDamage(MapleMonster attacker, MapleMonster damaged, boolean magic) {
|
|
int attackerAtk, damagedDef, attackerLevel = attacker.getLevel();
|
|
double maxDamage;
|
|
if (magic) {
|
|
int atkRate = calcModifier(attacker, MonsterStatus.MAGIC_ATTACK_UP, MonsterStatus.MATK);
|
|
attackerAtk = (attacker.getStats().getMADamage() * atkRate) / 100;
|
|
|
|
int defRate = calcModifier(damaged, MonsterStatus.MAGIC_DEFENSE_UP, MonsterStatus.MDEF);
|
|
damagedDef = (damaged.getStats().getMDDamage() * defRate) / 100;
|
|
|
|
maxDamage = ((attackerAtk * (1.15 + (0.025 * attackerLevel))) - (0.75 * damagedDef)) * (Math.log(Math.abs(damagedDef - attackerAtk)) / Math.log(12));
|
|
} else {
|
|
int atkRate = calcModifier(attacker, MonsterStatus.WEAPON_ATTACK_UP, MonsterStatus.WATK);
|
|
attackerAtk = (attacker.getStats().getPADamage() * atkRate) / 100;
|
|
|
|
int defRate = calcModifier(damaged, MonsterStatus.WEAPON_DEFENSE_UP, MonsterStatus.WDEF);
|
|
damagedDef = (damaged.getStats().getPDDamage() * defRate) / 100;
|
|
|
|
maxDamage = ((attackerAtk * (1.15 + (0.025 * attackerLevel))) - (0.75 * damagedDef)) * (Math.log(Math.abs(damagedDef - attackerAtk)) / Math.log(17));
|
|
}
|
|
|
|
return (int) maxDamage;
|
|
}
|
|
|
|
private static int calcModifier(MapleMonster monster, MonsterStatus buff, MonsterStatus nerf) {
|
|
int atkModifier;
|
|
final Map<MonsterStatus, MonsterStatusEffect> monsterStati = monster.getStati();
|
|
|
|
MonsterStatusEffect atkBuff = monsterStati.get(buff);
|
|
if (atkBuff != null) {
|
|
atkModifier = atkBuff.getStati().get(buff);
|
|
} else {
|
|
atkModifier = 100;
|
|
}
|
|
|
|
MonsterStatusEffect atkNerf = monsterStati.get(nerf);
|
|
if (atkNerf != null) {
|
|
atkModifier -= atkNerf.getStati().get(nerf);
|
|
}
|
|
|
|
return atkModifier;
|
|
}
|
|
}
|