📄 maplestateffect.java
字号:
case 3211005: // golden eagle
case 3111005: // golden hawk
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
monsterStatus.put(MonsterStatus.STUN, Integer.valueOf(1));
break;
case 3221005: // frostprey
case 2121005: // elquines
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
monsterStatus.put(MonsterStatus.FREEZE, Integer.valueOf(1));
break;
case 2311006: // summon dragon
case 3121006: // phoenix
case 2221005: // ifrit
case 2321003: // bahamut
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
break;
case 2311003: // hs
case 5101002: // GM hs
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HOLY_SYMBOL, Integer.valueOf(x)));
break;
case 2211004: // il seal
case 2111004: // fp seal
monsterStatus.put(MonsterStatus.SEAL, 1);
break;
case 4111003: // shadow web
monsterStatus.put(MonsterStatus.SHADOW_WEB, 1);
break;
default:
// nothing needs to be added, that's ok
}
}
ret.monsterStatus = monsterStatus;
// TODO: fixDamage, coolTime
statups.trimToSize();
ret.statups = statups;
return ret;
}
/**
*
* @param applyto
* @param obj
* @param attack damage done by the skill
*/
public void applyPassive(MapleCharacter applyto, MapleMapObject obj, int attack) {
if (makeChanceResult()) {
switch (sourceid) {
// MP eater
case 2100000:
case 2200000:
case 2300000:
if (obj == null || obj.getType() != MapleMapObjectType.MONSTER)
return;
MapleMonster mob = (MapleMonster) obj;
// x is absorb percentage
if (!mob.isBoss()) {
int absorbMp = Math.min((int) (mob.getMaxMp() * (getX() / 100.0)), mob.getMp());
if (absorbMp > 0) {
mob.setMp(mob.getMp() - absorbMp);
applyto.addMP(absorbMp);
applyto.getClient().getSession().write(MaplePacketCreator.showOwnBuffEffect(sourceid, 1));
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.showBuffeffect(applyto.getId(), sourceid, 1), false);
}
}
break;
}
}
}
public boolean applyTo(MapleCharacter chr) {
return applyTo(chr, chr, true, null);
}
public boolean applyTo(MapleCharacter chr, Point pos) {
return applyTo(chr, chr, true, pos);
}
private boolean applyTo(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary, Point pos) {
int hpchange = calcHPChange(applyfrom, primary);
int mpchange = calcMPChange(applyfrom, primary);
if (primary) {
if (itemConNo != 0) {
MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(itemCon);
MapleInventoryManipulator.removeById(applyto.getClient(), type, itemCon, itemConNo, false, true);
}
}
List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<Pair<MapleStat, Integer>>(2);
if (!primary && isResurrection()) {
hpchange = applyto.getMaxHp();
applyto.setStance(0);
}
if (hpchange != 0) {
if (hpchange < 0 && (-hpchange) > applyto.getHp()) {
return false;
}
applyto.setHp(applyto.getHp() + hpchange);
hpmpupdate.add(new Pair<MapleStat, Integer>(MapleStat.HP, Integer.valueOf(applyto.getHp())));
}
if (mpchange != 0) {
if (mpchange < 0 && (-mpchange) > applyto.getMp()) {
return false;
}
applyto.setMp(applyto.getMp() + mpchange);
hpmpupdate.add(new Pair<MapleStat, Integer>(MapleStat.MP, Integer.valueOf(applyto.getMp())));
}
applyto.getClient().getSession().write(MaplePacketCreator.updatePlayerStats(hpmpupdate, true));
if (moveTo != -1) {
MapleMap target;
if (moveTo == 999999999) {
target = applyto.getMap().getReturnMap();
} else {
target = ChannelServer.getInstance(applyto.getClient().getChannel()).getMapFactory().getMap(moveTo);
if (target.getId() / 10000000 != applyto.getMapId() / 10000000) {
log.info("Player {} is trying to use a return scroll to an illegal location ({}->{})",
new Object[] { applyto.getName(), applyto.getMapId(), target.getId() });
return false;
}
}
applyto.changeMap(target, target.getPortal(0));
}
if (overTime) {
applyBuffEffect(applyfrom, applyto, primary);
}
if (primary && (overTime || isHeal())) {
applyBuff(applyfrom);
}
if (primary && isMonsterBuff()) {
applyMonsterBuff(applyfrom);
}
SummonMovementType summonMovementType = getSummonMovementType();
if(summonMovementType != null && pos != null) {
final MapleSummon tosummon = new MapleSummon(applyfrom, sourceid, pos, summonMovementType);
if (!tosummon.isPuppet()) {
applyfrom.getCheatTracker().resetSummonAttack();
}
applyfrom.getMap().spawnSummon(tosummon);
applyfrom.getSummons().put(sourceid, tosummon);
tosummon.addHP(x);
}
// Magic Door
if (isMagicDoor()) {
//applyto.cancelMagicDoor();
Point doorPosition = new Point(applyto.getPosition());
//doorPosition.y -= 280;
MapleDoor door = new MapleDoor(applyto, doorPosition);
applyto.getMap().spawnDoor(door);
applyto.addDoor(door);
door = new MapleDoor(door);
applyto.addDoor(door);
door.getTown().spawnDoor(door);
if (applyto.getParty() != null) {
// update town doors
applyto.silentPartyUpdate();
}
} else if (isMist()) {
Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
MapleMist mist = new MapleMist(bounds, applyfrom, this);
applyfrom.getMap().spawnMist(mist, getDuration(), sourceid == 2111003);
}
return true;
}
private void applyBuff(MapleCharacter applyfrom) {
if (isPartyBuff() && (applyfrom.getParty() != null || isGmBuff())) {
Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
List<MapleMapObject> affecteds = applyfrom.getMap().getMapObjectsInBox(bounds,
Arrays.asList(MapleMapObjectType.PLAYER));
List<MapleCharacter> affectedp = new ArrayList<MapleCharacter>(affecteds.size());
for (MapleMapObject affectedmo : affecteds) {
MapleCharacter affected = (MapleCharacter) affectedmo;
if (affected != applyfrom && (isGmBuff() || applyfrom.getParty().equals(affected.getParty()))) {
boolean isRessurection = isResurrection();
if ((isRessurection && !affected.isAlive()) || (!isRessurection && affected.isAlive())) {
affectedp.add(affected);
}
}
}
for (MapleCharacter affected : affectedp) {
// TODO actually heal (and others) shouldn't recalculate everything
// for heal this is an actual bug since heal hp is decreased with the number
// of affected players
applyTo(applyfrom, affected, false, null);
affected.getClient().getSession().write(MaplePacketCreator.showOwnBuffEffect(sourceid, 2));
affected.getMap().broadcastMessage(affected,
MaplePacketCreator.showBuffeffect(affected.getId(), sourceid, 2), false);
}
}
}
private void applyMonsterBuff(MapleCharacter applyfrom) {
Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
List<MapleMapObject> affected = applyfrom.getMap().getMapObjectsInBox(bounds,
Arrays.asList(MapleMapObjectType.MONSTER));
ISkill skill = SkillFactory.getSkill(sourceid);
int i = 0;
for (MapleMapObject mo : affected) {
MapleMonster monster = (MapleMonster) mo;
if (makeChanceResult()) {
monster.applyStatus(applyfrom, new MonsterStatusEffect(getMonsterStati(), skill, false), isPoison(), getDuration());
}
i++;
if (i >= mobCount) {
break;
}
}
}
private Rectangle calculateBoundingBox(Point posFrom, boolean facingLeft) {
Point mylt;
Point myrb;
if (facingLeft) {
mylt = new Point(lt.x + posFrom.x, lt.y + posFrom.y);
myrb = new Point(rb.x + posFrom.x, rb.y + posFrom.y);
} else {
myrb = new Point(lt.x * -1 + posFrom.x, rb.y + posFrom.y);
mylt = new Point(rb.x * -1 + posFrom.x, lt.y + posFrom.y);
}
Rectangle bounds = new Rectangle(mylt.x, mylt.y, myrb.x - mylt.x, myrb.y - mylt.y);
return bounds;
}
private void applyBuffEffect(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary) {
applyto.cancelEffect(this, true, -1);
List<Pair<MapleBuffStat, Integer>> localstatups = statups;
if (isMonsterRiding()) {
int ridingLevel = 0;
IItem mount = applyfrom.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18);
if (mount != null) {
ridingLevel = mount.getItemId() - 1902000 + 1;
}
localstatups = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MONSTER_RIDING, ridingLevel));
}
int localDuration = duration;
if (primary) {
localDuration = alchemistModifyVal(applyfrom, localDuration, false);
}
if (localstatups.size() > 0) {
applyto.getClient().getSession().write(MaplePacketCreator.giveBuff((skill ? sourceid : -sourceid), localDuration, localstatups));
} else {
log.warn(MapleClient.getLogMessage(applyto, "Applying empty statups (skill {}, id {})", skill, sourceid));
}
if (isDs()) {
List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
MapleBuffStat.DARKSIGHT, 0));
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), dsstat),
false);
}
if (isCombo()) {
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
MapleBuffStat.COMBO, 1));
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), stat),
false);
}
if (isMonsterRiding()) {
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
MapleBuffStat.MONSTER_RIDING, 1));
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), stat),
false);
}
if (isShadowPartner()) {
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
MapleBuffStat.SHADOWPARTNER, 0));
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), stat),
false);
}
if(isEnrage()) {
applyto.handleOrbconsume();
}
long starttime = System.currentTimeMillis();
CancelEffectAction cancelAction = new CancelEffectAction(applyto, this, starttime);
ScheduledFuture<?> schedule = TimerManager.getInstance().schedule(cancelAction, localDuration);
applyto.registerEffect(this, starttime, schedule);
if (primary) {
applyto.getMap().broadcastMessage(applyto,
MaplePacketCreator.showBuffeffect(applyto.getId(), sourceid, 1), false);
}
}
private int calcHPChange(MapleCharacter applyfrom, boolean primary) {
int hpchange = 0;
if (hp != 0) {
if (!skill) {
if (primary) {
hpchange += alchemistModifyVal(applyfrom, hp, true);
} else {
hpchange += hp;
}
} else { // assumption: this is heal
hpchange += makeHealHP(hp / 100.0, applyfrom.getTotalMagic(), 3, 5);
}
}
if (hpR != 0) {
hpchange += (int) (applyfrom.getCurrentMaxHp() * hpR);
}
// actually receivers probably never get any hp when it's not heal but whatever
if (primary) {
if (hpCon != 0) {
hpchange -= hpCon;
}
}
if (isChakra()) {
hpchange += makeHealHP(getY() / 100.0, applyfrom.getTotalLuk(), 2.3, 3.5);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -