Jump to content
  • 0

Olympiad Enchant Limit 6 Not Reduce Hp When Player Is Olympiad


Question

Posted

Hello. 

i set 

 

# Enchant limit for items during Olympiad battles. Disabled = -1.
# Default: -1
AltOlyEnchantLimit = 6

when player enter to olympiad arena all stats reduce but hp not, (HP should be reduced to all items +6 from +16 that is max in my server)

 

i searcjing where is problem,

but in FuncEnchant.java

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * 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 General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver.gameserver.skills.funcs;

import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Stats;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2WeaponType;

public class FuncEnchant extends Func
{
	
	public FuncEnchant(Stats pStat, int pOrder, Object owner, Lambda lambda)
	{
		super(pStat, pOrder, owner);
	}
	
	@Override
	public void calc(Env env)
	{
		if (cond != null && !cond.test(env))
			return;
		L2ItemInstance item = (L2ItemInstance) funcOwner;
		
		int enchant = item.getEnchantLevel();
		
		if (enchant <= 0)
			return;
		
		int overenchant = 0;
		
		if (enchant > 3)
		{
			overenchant = enchant - 3;
			enchant = 3;
		}
		
		if (env.player != null && env.player instanceof L2PcInstance)
		{
			L2PcInstance player = (L2PcInstance)env.player;
			if (player.isInOlympiadMode() && Config.ALT_OLY_ENCHANT_LIMIT >= 0 &&
					(enchant + overenchant) > Config.ALT_OLY_ENCHANT_LIMIT)
			{
				if (Config.ALT_OLY_ENCHANT_LIMIT > 3)
				{
					overenchant = Config.ALT_OLY_ENCHANT_LIMIT - 3;
				}
				else
				{
					overenchant = 0;
					enchant = Config.ALT_OLY_ENCHANT_LIMIT;
				}
			}
		}
		
		if (stat == Stats.MAGIC_DEFENCE || stat == Stats.POWER_DEFENCE)
		{
			env.value += enchant + 3 * overenchant;
			return;
		}
		
		if (stat == Stats.MAGIC_ATTACK)
		{
			switch (item.getItem().getItemGradeSPlus())
			{
				case L2Item.CRYSTAL_S:
					env.value += 4 * enchant + 8 * overenchant;
					break;
				case L2Item.CRYSTAL_A:
					env.value += 3 * enchant + 6 * overenchant;
					break;
				case L2Item.CRYSTAL_B:
					env.value += 3 * enchant + 6 * overenchant;
					break;
				case L2Item.CRYSTAL_C:
					env.value += 3 * enchant + 6 * overenchant;
					break;
				case L2Item.CRYSTAL_D:
					env.value += 2 * enchant + 4 * overenchant;
					break;
			}
			return;
		}
		
		
		if (item.isWeapon())
		{
			L2WeaponType type = (L2WeaponType) item.getItemType();
			
			switch (item.getItem().getItemGradeSPlus())
			{
				case L2Item.CRYSTAL_S:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 10 * enchant + 20 * overenchant;
							break;
						default:
							env.value += 5 * enchant + 10 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_A:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 8 * enchant + 16 * overenchant;
							break;
						default:
							env.value += 4 * enchant + 8 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_B:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 6 * enchant + 12 * overenchant;
							break;
						default:
							env.value += 3 * enchant + 6 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_C:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 6 * enchant + 12 * overenchant;
							break;
						default:
							env.value += 3 * enchant + 6 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_D:
				case L2Item.CRYSTAL_NONE:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
						{
							env.value += 4 * enchant + 8 * overenchant;
							break;
						}
						default:
							env.value += 2 * enchant + 4 * overenchant;
							break;
					}
					break;
			}
		}
	}
}

and FuncEnchantHP.java

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * 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 General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver.gameserver.skills.funcs;

import com.l2jserver.gameserver.datatables.EnchantHPBonusData;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Stats;

/**
 *
 * @author  Yamaneko
 */
public class FuncEnchantHp extends Func
{
	public FuncEnchantHp(Stats pStat, int pOrder, Object owner, Lambda lambda)
	{
		super(pStat, pOrder, owner);
	}
	
	@Override
	public void calc(Env env)
	{
		if (cond != null && !cond.test(env))
			return;
		
		final L2ItemInstance item = (L2ItemInstance) funcOwner;
		if (item.getEnchantLevel() > 0)
			env.value += EnchantHPBonusData.getInstance().getHPBonus(item);
	}
}

all looks fine.

 

maybe there is some other config for this? or i have to look somewer else. pls help me

6 answers to this question

Recommended Posts

  • 0
Posted

Hello. 

i set 

 

# Enchant limit for items during Olympiad battles. Disabled = -1.
# Default: -1
AltOlyEnchantLimit = 6

when player enter to olympiad arena all stats reduce but hp not, (HP should be reduced to all items +6 from +16 that is max in my server)

 

i searcjing where is problem,

but in FuncEnchant.java

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * 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 General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver.gameserver.skills.funcs;

import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Stats;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2WeaponType;

public class FuncEnchant extends Func
{
	
	public FuncEnchant(Stats pStat, int pOrder, Object owner, Lambda lambda)
	{
		super(pStat, pOrder, owner);
	}
	
	@Override
	public void calc(Env env)
	{
		if (cond != null && !cond.test(env))
			return;
		L2ItemInstance item = (L2ItemInstance) funcOwner;
		
		int enchant = item.getEnchantLevel();
		
		if (enchant <= 0)
			return;
		
		int overenchant = 0;
		
		if (enchant > 3)
		{
			overenchant = enchant - 3;
			enchant = 3;
		}
		
		if (env.player != null && env.player instanceof L2PcInstance)
		{
			L2PcInstance player = (L2PcInstance)env.player;
			if (player.isInOlympiadMode() && Config.ALT_OLY_ENCHANT_LIMIT >= 0 &&
					(enchant + overenchant) > Config.ALT_OLY_ENCHANT_LIMIT)
			{
				if (Config.ALT_OLY_ENCHANT_LIMIT > 3)
				{
					overenchant = Config.ALT_OLY_ENCHANT_LIMIT - 3;
				}
				else
				{
					overenchant = 0;
					enchant = Config.ALT_OLY_ENCHANT_LIMIT;
				}
			}
		}
		
		if (stat == Stats.MAGIC_DEFENCE || stat == Stats.POWER_DEFENCE)
		{
			env.value += enchant + 3 * overenchant;
			return;
		}
		
		if (stat == Stats.MAGIC_ATTACK)
		{
			switch (item.getItem().getItemGradeSPlus())
			{
				case L2Item.CRYSTAL_S:
					env.value += 4 * enchant + 8 * overenchant;
					break;
				case L2Item.CRYSTAL_A:
					env.value += 3 * enchant + 6 * overenchant;
					break;
				case L2Item.CRYSTAL_B:
					env.value += 3 * enchant + 6 * overenchant;
					break;
				case L2Item.CRYSTAL_C:
					env.value += 3 * enchant + 6 * overenchant;
					break;
				case L2Item.CRYSTAL_D:
					env.value += 2 * enchant + 4 * overenchant;
					break;
			}
			return;
		}
		
		
		if (item.isWeapon())
		{
			L2WeaponType type = (L2WeaponType) item.getItemType();
			
			switch (item.getItem().getItemGradeSPlus())
			{
				case L2Item.CRYSTAL_S:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 10 * enchant + 20 * overenchant;
							break;
						default:
							env.value += 5 * enchant + 10 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_A:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 8 * enchant + 16 * overenchant;
							break;
						default:
							env.value += 4 * enchant + 8 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_B:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 6 * enchant + 12 * overenchant;
							break;
						default:
							env.value += 3 * enchant + 6 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_C:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
							env.value += 6 * enchant + 12 * overenchant;
							break;
						default:
							env.value += 3 * enchant + 6 * overenchant;
							break;
					}
					break;
				case L2Item.CRYSTAL_D:
				case L2Item.CRYSTAL_NONE:
					switch(type)
					{
						case BOW:
						case CROSSBOW:
						{
							env.value += 4 * enchant + 8 * overenchant;
							break;
						}
						default:
							env.value += 2 * enchant + 4 * overenchant;
							break;
					}
					break;
			}
		}
	}
}

and FuncEnchantHP.java

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * 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 General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver.gameserver.skills.funcs;

import com.l2jserver.gameserver.datatables.EnchantHPBonusData;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Stats;

/**
 *
 * @author  Yamaneko
 */
public class FuncEnchantHp extends Func
{
	public FuncEnchantHp(Stats pStat, int pOrder, Object owner, Lambda lambda)
	{
		super(pStat, pOrder, owner);
	}
	
	@Override
	public void calc(Env env)
	{
		if (cond != null && !cond.test(env))
			return;
		
		final L2ItemInstance item = (L2ItemInstance) funcOwner;
		if (item.getEnchantLevel() > 0)
			env.value += EnchantHPBonusData.getInstance().getHPBonus(item);
	}
}

all looks fine.

 

maybe there is some other config for this? or i have to look somewer else. pls help me

com/l2jserver/gameserver/datatables/EnchantHPBonusData.java

 

In the latest revision of l2jserver there is a method getOlyEnchantLevel() located in the L2ItemInstance that does the job.. you can use it in your core to extend EnchantHPBonusData.java! :)

  • 0
Posted

That is why i suggest you to check their last revision..

The method in L2ItemInstance (com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java):

	public int getOlyEnchantLevel()
	{
		L2PcInstance player = getActingPlayer();
		int enchant = getEnchantLevel();
		
		if (player == null)
		{
			return enchant;
		}
		
		if (player.isInOlympiadMode() && (Config.ALT_OLY_ENCHANT_LIMIT >= 0) && (enchant > Config.ALT_OLY_ENCHANT_LIMIT))
		{
			enchant = Config.ALT_OLY_ENCHANT_LIMIT;
		}
		
		return enchant;
	}

The method that takes care of the HP bonus (com/l2jserver/gameserver/datatables/EnchantItemHPBonusData.java):

	public final int getHPBonus(L2ItemInstance item)
	{
		final List<Integer> values = _armorHPBonuses.get(item.getItem().getItemGradeSPlus());
		if ((values == null) || values.isEmpty() || (item.getOlyEnchantLevel() <= 0))
		{
			return 0;
		}
		
		final int bonus = values.get(Math.min(item.getOlyEnchantLevel(), values.size()) - 1);
		if (item.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR)
		{
			return (int) (bonus * fullArmorModifier);
		}
		return bonus;
	}
  • 0
Posted (edited)

i do like you say, but when enter in oly and "AltOlyEnchantLimit = 0"  hp reduced only around 400 hp it should be more. ill try another way because i had error at  "_armorHPBonuses" so i replaced by "_armorHPBonus"

 

 

 

 

edit: now hpbonus not work at all, i wondering why this not work how it should work in freya. i do nothing with hpbonus in my pack before.

Edited by dymek1984
  • 0
Posted

i do like you say, but when enter in oly and "AltOlyEnchantLimit = 0"  hp reduced only around 400 hp it should be more. ill try another way because i had error at  "_armorHPBonuses" so i replaced by "_armorHPBonus"

 

 

 

 

edit: now hpbonus not work at all, i wondering why this not work how it should work in freya. i do nothing with hpbonus in my pack before.

It works the same way, just the code is optimized.. you can use only the check in your getHPBonus (com/l2jserver/gameserver/datatables/EnchantHPBonusData.java) method if you want, but it's not a good practice in the OOP :lol:

  • 0
Posted

if u mean if (player.isInOlympiadMode()) i tried but heva error in"player" dont know how to import player as L2PcInstance ;/ 

and for real i need if (player.isInOlympiadMode()) hpbonus = 0  

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


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock