테스트

aion-server 4.8

Gitteol
최고관리자 · 1 · 💬 0 클론/새로받기
 4.8 61f661d · 1 commits 새로받기(Pull)
game-server/src/com/aionemu/gameserver/network/aion/serverpackets/SM_ATTACK.java
package com.aionemu.gameserver.network.aion.serverpackets;

import java.util.List;

import com.aionemu.gameserver.controllers.attack.AttackResult;
import com.aionemu.gameserver.model.animations.AttackHandAnimation;
import com.aionemu.gameserver.model.animations.AttackTypeAnimation;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.network.aion.AionConnection;
import com.aionemu.gameserver.network.aion.AionServerPacket;
import com.aionemu.gameserver.skillengine.model.Effect;

/**
 * @author -Nemesiss-, Sweetkr
 */
public class SM_ATTACK extends AionServerPacket {

	private int attackno;
	private int time;
	private AttackHandAnimation attackHandAnimation;
	private AttackTypeAnimation attackTypeAnimation;
	private List<AttackResult> attackList;
	private Creature attacker;
	private Creature target;
	private Effect criticalEffect;

	public SM_ATTACK(Creature attacker, Creature target, int attackno, int time, AttackTypeAnimation attackTypeAnimation, AttackHandAnimation attackHandAnimation, List<AttackResult> attackList) {
		this(attacker, target, attackno, time, attackTypeAnimation, attackHandAnimation, attackList, null);
	}

	public SM_ATTACK(Creature attacker, Creature target, int attackno, int time, AttackTypeAnimation attackTypeAnimation, AttackHandAnimation attackHandAnimation, List<AttackResult> attackList, Effect criticalEffect) {
		this.attacker = attacker;
		this.target = target;
		this.attackno = attackno;// empty
		this.time = time;// empty
		this.attackHandAnimation = attackHandAnimation;
		this.attackTypeAnimation = attackTypeAnimation;
		this.attackList = attackList;
		this.criticalEffect = criticalEffect;
	}

	@Override
	protected void writeImpl(AionConnection con) {
		writeD(attacker.getObjectId());
		writeC(attackno);
		writeH(time);
		writeC(attackTypeAnimation.getId());
		writeC(attackHandAnimation.getId());

		writeD(target.getObjectId());

		int attackerMaxHp = attacker.getLifeStats().getMaxHp();
		int attackerCurrHp = attacker.getLifeStats().getCurrentHp();
		int targetMaxHp = target.getLifeStats().getMaxHp();
		int targetCurrHp = target.getLifeStats().getCurrentHp();

		writeC((byte) (100f * targetCurrHp / targetMaxHp)); // target %hp
		writeC((byte) (100f * attackerCurrHp / attackerMaxHp)); // attacker %hp

		// TODO refactor attack controller
		switch (attackList.get(0).getAttackStatus().getId()) // Counter skills
		{
			case -60: // case CRITICAL_BLOCK
			case 4: // case BLOCK
				writeH(32);
				break;
			case -62: // case CRITICAL_PARRY
			case 2: // case PARRY
				writeH(64);
				break;
			case -64: // case CRITICAL_DODGE
			case 0: // case DODGE
				writeH(128);
				break;
			case -58: // case PHYSICAL_CRITICAL_RESIST
			case 6: // case RESIST
				writeH(256); // need more info becuz sometimes 0
				break;
			default:
				if (criticalEffect != null) {
					if (target instanceof Player)
						writeH(criticalEffect.getSkillId() == 8218 ? 1 : 2);
					else
						writeH(criticalEffect.getSkillId() == 8218 ? 1025 : 1026);
				} else {
					writeH(0);
				}
				break;
		}
		// setting counter skill from packet to have the best synchronization of time with client
		if (target instanceof Player) {
			if (attackList.get(0).getAttackStatus().isCounterSkill())
				((Player) target).setLastCounterSkill(attackList.get(0).getAttackStatus());
		}

		writeH(0);
		if (criticalEffect != null) {
			writeF(criticalEffect.getTargetX());
			writeF(criticalEffect.getTargetY());
			writeF(criticalEffect.getTargetZ());
		}
		// TODO! those 2h (== d) up is some kind of very weird flag...
		// writeD(attackFlag);
		/*
		 * if(attackFlag & 0x10A0F != 0) { writeF(0); writeF(0); writeF(0); } if(attackFlag & 0x10010 != 0) { writeC(0); } if(attackFlag & 0x10000 != 0) {
		 * writeD(0); writeD(0); }
		 */

		writeC(attackList.size());
		for (AttackResult attack : attackList) {
			writeD(attack.getDamage());
			writeC(attack.getAttackStatus().getId());

			byte shieldType = (byte) attack.getShieldType();
			writeC(shieldType);

			/**
			 * shield Type: 1: reflector 2: normal shield 8: protect effect (ex. skillId: 417 Bodyguard) TODO find out 4
			 */
			switch (shieldType) {
				case 0:
				case 2:
					break;
				case 8:
				case 10:
					writeD(attack.getProtectorId()); // protectorId
					writeD(attack.getProtectedDamage()); // protected damage
					writeD(attack.getProtectedSkillId()); // skillId
					break;
				case 16:
					writeD(0);
					writeD(0);
					writeD(0);
					writeD(0);
					writeD(0);
					writeD(attack.getMpAbsorbed());
					writeD(attack.getReflectedSkillId()); // skill id
					break;
				default:
					writeD(attack.getProtectorId()); // protectorId
					writeD(attack.getProtectedDamage()); // protected damage
					writeD(attack.getProtectedSkillId()); // skillId
					writeD(attack.getReflectedDamage()); // reflect damage
					writeD(attack.getReflectedSkillId()); // skill id
					writeD(0);
					writeD(0);
					break;
			}
		}
		writeC(0);
	}

}

📎 첨부파일

댓글 작성 권한이 없습니다.
🏆 포인트 랭킹 TOP 10
순위 닉네임 포인트
1 no_profile 타키야겐지쪽지보내기 자기소개 아이디로 검색 전체게시물 102,949
2 no_profile 동가리쪽지보내기 자기소개 아이디로 검색 전체게시물 63,733
3 no_profile 라프텔쪽지보내기 자기소개 아이디로 검색 전체게시물 51,771
4 no_profile 불멸의행복쪽지보내기 자기소개 아이디로 검색 전체게시물 36,923
5 서번트쪽지보내기 자기소개 아이디로 검색 전체게시물 35,011
6 no_profile 닥터스쪽지보내기 자기소개 아이디로 검색 전체게시물 29,470
7 no_profile 검은고양이쪽지보내기 자기소개 아이디로 검색 전체게시물 29,077
8 no_profile Revolution쪽지보내기 자기소개 아이디로 검색 전체게시물 28,199
9 no_profile 보거스쪽지보내기 자기소개 아이디로 검색 전체게시물 26,731
10 no_profile 호롤롤로쪽지보내기 자기소개 아이디로 검색 전체게시물 17,020
알림 0