테스트

aion-server 4.8

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

import com.aionemu.gameserver.dataholders.DataManager;
import com.aionemu.gameserver.model.PlayerClass;
import com.aionemu.gameserver.model.Race;
import com.aionemu.gameserver.model.animations.ActionAnimation;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.skill.PlayerSkillEntry;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ACTION_ANIMATION;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SKILL_LIST;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SKILL_REMOVE;
import com.aionemu.gameserver.skillengine.SkillEngine;
import com.aionemu.gameserver.skillengine.model.SkillLearnTemplate;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
import com.aionemu.gameserver.utils.PacketSendUtility;

/**
 * @author ATracer, xTz, Neon
 */
public class SkillLearnService {

	public static void onLearnSkill(Player player, int skillId, int skillLevel, boolean isNew) {
		PlayerSkillEntry skill = player.getSkillList().getSkillEntry(skillId);
		if (skill.isProfessionSkill())
			switch (skillLevel) {
				case 1, 100, 200, 300, 400, 450, 500 -> {
					if (skillLevel != 1 || skill.isCraftingSkill()) // exclude lvl 1 tapping skills
						PacketSendUtility.broadcastPacket(player, new SM_ACTION_ANIMATION(player.getObjectId(), ActionAnimation.CRAFT_LEVEL_UP), true);
				}
			}
		if (player.getEffectController() != null) { // null on character creation
			if (player.isSpawned())
				sendPacket(player, skill, isNew);
			SkillTemplate skillTemplate = DataManager.SKILL_DATA.getSkillTemplate(skillId);
			if (skillTemplate.isPassive())
				SkillEngine.getInstance().applyEffectDirectly(skillTemplate, skillLevel, player, player);
			if (skill.isProfessionSkill() && (skill.getSkillLevel() == 399 || skill.getSkillLevel() == 499))
				player.getController().updateNearbyQuests();
		}
		if (skill.isCraftingSkill() || skill.isMorphSkill())
			RecipeService.autoLearnRecipes(player, skillId, skillLevel);
	}

	private static void sendPacket(Player player, PlayerSkillEntry skill, boolean isNew) {
		if (skill.isProfessionSkill()) {
			if (skill.isTappingSkill())
				PacketSendUtility.sendPacket(player, new SM_SKILL_LIST(skill, isNew ? 1330004 : 1330005));
			else
				PacketSendUtility.sendPacket(player, new SM_SKILL_LIST(skill, isNew ? 1330061 : 1330064));
		} else if (isNew)
			PacketSendUtility.sendPacket(player,
				new SM_SKILL_LIST(skill, skill.isStigmaSkill() ? skill.isLinkedStigmaSkill() ? 1402891 : 1300401 : 1300050));
		else
			PacketSendUtility.sendPacket(player, new SM_SKILL_LIST(skill, 0));
	}

	/**
	 * Adds all missing skills and recipes that can be auto-learned for the given level range.
	 */
	public static void learnNewSkills(Player player, int fromLevel, int toLevel) {
		PlayerClass playerClass = player.getCommonData().getPlayerClass();
		PlayerClass playerStartClass = playerClass.isStartingClass() ? null : playerClass.getStartingClass();
		for (int level = toLevel; level >= fromLevel; level--) { // reversed order to add only the highest of each skill (more efficient)
			if (level < 10 && playerStartClass != null) // add missing start class skills if already switched class
				autoLearnSkills(player, level, playerStartClass, player.getRace());
			autoLearnSkills(player, level, playerClass, player.getRace());
		}

		// upgrade human gathering to daeva essence tapping
		if (toLevel >= 10 && player.getCommonData().isDaeva() && player.getSkillList().isSkillPresent(30001)) {
			if (!player.getSkillList().isSkillPresent(30002))
				player.getSkillList().addSkill(player, 30002, player.getSkillList().getSkillLevel(30001));
			removeSkill(player, 30001);
		}
	}

	public static void learnTemporarySkill(Player player, int skillId, int skillLevel) {
		player.getSkillList().addTemporarySkill(player, skillId, skillLevel);
	}

	/**
	 * Adds auto-learned skills to the player, according to the specified level, class and race.
	 */
	private static void autoLearnSkills(Player player, int level, PlayerClass playerClass, Race playerRace) {
		for (SkillLearnTemplate template : DataManager.SKILL_TREE_DATA.getTemplatesFor(playerClass, level, playerRace)) {
			if (!template.isAutolearn())
				continue;
			if (template.getSkillId() == 30001 && !playerClass.isStartingClass()) // no human gathering for main classes
				continue;

			player.getSkillList().addSkill(player, template.getSkillId(), template.getSkillLevel());
		}
	}

	public static void learnSkillBook(Player player, int skillId) {
		for (SkillLearnTemplate skill : DataManager.SKILL_TREE_DATA.getSkillsForSkill(skillId, player.getPlayerClass(), player.getRace(),
			player.getLevel()))
			player.getSkillList().addSkill(player, skillId, skill.getSkillLevel());
	}

	public static boolean removeSkill(Player player, int skillId) {
		PlayerSkillEntry skill = player.getSkillList().getSkillEntry(skillId);
		if (skill != null) {
			player.getEffectController().removeEffect(skillId);
			player.getSkillList().removeSkill(skillId);
			PacketSendUtility.sendPacket(player, new SM_SKILL_REMOVE(skill));
			return true;
		}
		return false;
	}
}

📎 첨부파일

댓글 작성 권한이 없습니다.
🏆 포인트 랭킹 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