O fórum teve que ser recriado do zero, usuários do fórum antigo precisam se cadastrar novamente e caso você seja usuário vip se identifique perante a um administrador que o status vip será reatribuído..

Welcome to L2JDream Project

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
Zeit

Class Damage Manager

 

File Name: "classDamages.properties"
Location: game\config\main

#Damages to Fighters
Duelist__ToFighter=0.8
DreadNought__ToFighter=1.0
Phoenix_Knight__ToFighter=1.0
Hell_Knight__ToFighter=1.0
Sagittarius__ToFighter=1.0
Adventurer__ToFighter=0.8
Archmage__ToFighter=1.0
Soultaker__ToFighter=1.0
Arcana_Lord__ToFighter=1.0
Cardinal__ToFighter=1.0
Hierophant__ToFighter=1.0
Eva_Templar__ToFighter=1.0
Sword_Muse__ToFighter=1.0
Wind_Rider__ToFighter=0.8
Moonlight_Sentinel__ToFighter=1.0
Mystic_Muse__ToFighter=1.0
Elemental_Master__ToFighter=1.0
Eva_s_Saint__ToFighter=1.0
Shillien_Templar__ToFighter=1.0
Spectral_Dancer__ToFighter=1.0
Ghost_Hunter__ToFighter=0.8
Ghost_Sentinel__ToFighter=1.0
Storm_Screamer__ToFighter=1.0
Spectral_Master__ToFighter=1.0
Shillien_Saint__ToFighter=1.0
Titan__ToFighter=1.0
Grand_Khauatari__ToFighter=0.9
Dominator__ToFighter=1.0
Doomcryer__ToFighter=1.0
Fortune_Seeker__ToFighter=1.0
Maestro__ToFighter=1.0


#Damages to Mage
Duelist__ToMage=0.6
DreadNought__ToMage=1.0
Phoenix_Knight__ToMage=1.0
Hell_Knight__ToMage=1.0
Sagittarius__ToMage=1.0
Adventurer__ToMage=0.8
Archmage__ToMage=1.0
Soultaker__ToMage=1.0
Arcana_Lord__ToMage=1.0
Cardinal__ToMage=1.0
Hierophant__ToMage=1.0
Eva_Templar__ToMage=1.0
Sword_Muse__ToMage=1.0
Wind_Rider__ToMage=0.8
Moonlight_Sentinel__ToMage=1.0
Mystic_Muse__ToMage=1.0
Elemental_Master__ToMage=1.0
Eva_s_Saint__ToMage=1.0
Shillien_Templar__ToMage=1.0
Spectral_Dancer__ToMage=1.0
Ghost_Hunter__ToMage=0.8
Ghost_Sentinel__ToMage=1.0
Storm_Screamer__ToMage=1.0
Spectral_Master__ToMage=1.0
Shillien_Saint__ToMage=1.0
Titan__ToMage=1.0
Grand_Khauatari__ToMage=0.8
Dominator__ToMage=1.0
Doomcryer__ToMage=1.0
Fortune_Seeker__ToMage=1.0
Maestro__ToMage=1.0


#Damages By Fighters
Duelist__ByFighter=0.7
DreadNought__ByFighter=1.0
Phoenix_Knight__ByFighter=1.0
Hell_Knight__ByFighter=1.0
Sagittarius__ByFighter=1.0
Adventurer__ByFighter=0.8
Archmage__ByFighter=1.0
Soultaker__ByFighter=1.0
Arcana_Lord__ByFighter=1.0
Cardinal__ByFighter=1.0
Hierophant__ByFighter=1.0
Eva_Templar__ByFighter=1.0
Sword_Muse__ByFighter=1.0
Wind_Rider__ByFighter=0.8
Moonlight_Sentinel__ByFighter=1.0
Mystic_Muse__ByFighter=1.0
Elemental_Master__ByFighter=1.0
Eva_s_Saint__ByFighter=1.0
Shillien_Templar__ByFighter=1.0
Spectral_Dancer__ByFighter=1.0
Ghost_Hunter__ByFighter=0.8
Ghost_Sentinel__ByFighter=1.0
Storm_Screamer__ByFighter=1.0
Spectral_Master__ByFighter=1.0
Shillien_Saint__ByFighter=1.0
Titan__ByFighter=1.0
Grand_Khauatari__ByFighter=0.9
Dominator__ByFighter=1.0
Doomcryer__ByFighter=1.0
Fortune_Seeker__ByFighter=1.0
Maestro__ByFighter=1.0


#Damages By Mages
Duelist__ByMage=0.8
DreadNought__ByMage=1.0
Phoenix_Knight__ByMage=1.0
Hell_Knight__ByMage=1.0
Sagittarius__ByMage=1.0
Adventurer__ByMage=0.9
Archmage__ByMage=1.0
Soultaker__ByMage=1.0
Arcana_Lord__ByMage=1.0
Cardinal__ByMage=1.0
Hierophant__ByMage=1.0
Eva_Templar__ByMage=1.0
Sword_Muse__ByMage=1.0
Wind_Rider__ByMage=1.0
Moonlight_Sentinel__ByMage=1.0
Mystic_Muse__ByMage=1.0
Elemental_Master__ByMage=1.0
Eva_s_Saint__ByMage=1.0
Shillien_Templar__ByMage=1.0
Spectral_Dancer__ByMage=1.0
Ghost_Hunter__ByMage=1.0
Ghost_Sentinel__ByMage=1.0
Storm_Screamer__ByMage=1.0
Spectral_Master__ByMage=1.0
Shillien_Saint__ByMage=1.0
Titan__ByMage=1.0
Grand_Khauatari__ByMage=0.9
Dominator__ByMage=1.0
Doomcryer__ByMage=1.0
Fortune_Seeker__ByMage=1.0
Maestro__ByMage=1.0

New Class in package com.dream.game.manager;

package com.dream.game.manager;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Set;

import java.util.logging.Logger;
import com.dream.ConfigFiles;
import com.dream.game.datatables.xml.CharTemplateTable;
import com.dream.game.model.actor.instance.L2PcInstance;

/**
 * @author Shyla
 * Adapted By Zeit
 */

public class ClassDamageManager
{
	protected static final Logger _log = Logger.getLogger(ClassDamageManager.class.getName());
	
	private static Hashtable<Integer, Double> damage_to_mage = new Hashtable<>();
	private static Hashtable<Integer, Double> damage_to_fighter = new Hashtable<>();
	private static Hashtable<Integer, Double> damage_by_mage = new Hashtable<>();
	private static Hashtable<Integer, Double> damage_by_fighter = new Hashtable<>();
	
	private static Hashtable<Integer, String> id_to_name = new Hashtable<>();
	private static Hashtable<String, Integer> name_to_id = new Hashtable<>();
	
	public static void loadConfig()
	{
		final String SCRIPT = ConfigFiles.CLASS_DAMAGES_FILE;
		InputStream is = null;
		File file = null;
		try
		{
			final Properties scriptSetting = new Properties();
			file = new File(SCRIPT);
			is = new FileInputStream(file);
			scriptSetting.load(is);
			
			final Set<Object> key_set = scriptSetting.keySet();
			
			for (final Object key : key_set)
			{
				
				final String key_string = (String) key;
				
				final String[] class_and_type = key_string.split("__");
				
				String class_name = class_and_type[0].replace("_", " ");
				
				if (class_name.equals("Eva s Saint"))
					class_name = "Eva's Saint";
				
				final String type = class_and_type[1];
				
				final Integer class_id = CharTemplateTable.getClassIdByName(class_name) - 1;
				
				id_to_name.put(class_id, class_name);
				name_to_id.put(class_name, class_id);
				
				if (type.equals("ToFighter"))
				{
					damage_to_fighter.put(class_id, Double.parseDouble(scriptSetting.getProperty(key_string)));
				}
				else if (type.equals("ToMage"))
				{
					damage_to_mage.put(class_id, Double.parseDouble(scriptSetting.getProperty(key_string)));
				}
				else if (type.equals("ByFighter"))
				{
					damage_by_fighter.put(class_id, Double.parseDouble(scriptSetting.getProperty(key_string)));
				}
				else if (type.equals("ByMage"))
				{
					damage_by_mage.put(class_id, Double.parseDouble(scriptSetting.getProperty(key_string)));
				}
			}
			
			_log.info("ClassDamageManager: Loaded " + id_to_name.size() + " class damage configurations");
		}
		catch (final Exception e)
		{
			e.printStackTrace();
			
		}
		finally
		{
			
			if (is != null)
			{
				try
				{
					is.close();
				}
				catch (final IOException e)
				{
					e.printStackTrace();
				}
			}
		}
		
	}
	
	public static double getClassDamageToMage(final int id)
	{
		
		final Double multiplier = damage_to_mage.get(id);
		
		if (multiplier != null)
			return multiplier;
		return 1;
	}
	
	public static double getClassDamageToFighter(final int id)
	{
		final Double multiplier = damage_to_fighter.get(id);
		if (multiplier != null)
			return multiplier;
		return 1;
	}
	
	public static double getClassDamageByMage(final int id)
	{
		final Double multiplier = damage_by_mage.get(id);
		if (multiplier != null)
			return multiplier;
		return 1;
	}
	
	public static double getClassDamageByFighter(final int id)
	{
		final Double multiplier = damage_by_fighter.get(id);
		if (multiplier != null)
			return multiplier;
		return 1;
	}
	
	public static int getIdByName(final String name)
	{
		
		final Integer id = name_to_id.get(name);
		if (id != null)
			return id;
		return 0;
	}
	
	public static String getNameById(final int id)
	{
		
		final String name = id_to_name.get(id);
		if (name != null)
			return name;
		return "";
	}
	
	/**
	 * return the product between the attackerMultiplier and attackedMultiplier configured into the classDamages.properties
	 * @param attacker
	 * @param attacked
	 * @return output = attackerMulti*attackedMulti
	 */
	public static double getDamageMultiplier(final L2PcInstance attacker, final L2PcInstance attacked)
	{
		
		if (attacker == null || attacked == null)
			return 1;
		
		double attackerMulti = 1;
		
		if (attacked.isMageClass())
			attackerMulti = getClassDamageToMage(attacker.getClassId().getId());
		else
			attackerMulti = getClassDamageToFighter(attacker.getClassId().getId());
		
		double attackedMulti = 1;
		
		if (attacker.isMageClass())
			attackedMulti = getClassDamageByMage(attacked.getClassId().getId());
		else
			attackedMulti = getClassDamageByFighter(attacked.getClassId().getId());
		
		final double output = attackerMulti * attackedMulti;
		

		
		return output;
	}
	
}

package com.dream.ConfigFiles;

 

public class ConfigFiles
{
	public static final String NPC_FILE = "./config/main/npc.properties";

	public static final String PLAYER_FILE = "./config/main/player.properties";

	public static final String ALT_FILE = "./config/main/altgame.properties";
	
	+public static final String CLASS_DAMAGES_FILE = "./config/main/classDamages.properties";

	public static final String RATES_FILE = "./config/main/rates.properties";

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0