actual freya branch

This commit is contained in:
2026-09-12 15:41:31 +00:00
parent 8049e0a882
commit 68c1cd27d4
3510 changed files with 336689 additions and 302906 deletions
@@ -0,0 +1,138 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class Condition.
* @author mkizub
*/
public abstract class Condition implements ConditionListener
{
private ConditionListener _listener;
private String _msg;
private int _msgId;
private boolean _addName = false;
private boolean _result;
/**
* Sets the message.
* @param msg the new message
*/
public final void setMessage(String msg)
{
_msg = msg;
}
/**
* Gets the message.
* @return the message
*/
public final String getMessage()
{
return _msg;
}
/**
* Sets the message id.
* @param msgId the new message id
*/
public final void setMessageId(int msgId)
{
_msgId = msgId;
}
/**
* Gets the message id.
* @return the message id
*/
public final int getMessageId()
{
return _msgId;
}
/**
* Adds the name.
*/
public final void addName()
{
_addName = true;
}
/**
* Checks if is adds the name.
* @return true, if is adds the name
*/
public final boolean isAddName()
{
return _addName;
}
/**
* Sets the listener.
* @param listener the new listener
*/
void setListener(ConditionListener listener)
{
_listener = listener;
notifyChanged();
}
/**
* Gets the listener.
* @return the listener
*/
final ConditionListener getListener()
{
return _listener;
}
/**
* Test.
* @param env the env
* @return true, if successful
*/
public final boolean test(Env env)
{
boolean res = testImpl(env);
if ((_listener != null) && (res != _result))
{
_result = res;
notifyChanged();
}
return res;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
*/
abstract boolean testImpl(Env env);
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.ConditionListener#notifyChanged()
*/
@Override
public void notifyChanged()
{
if (_listener != null)
{
_listener.notifyChanged();
}
}
}
@@ -0,0 +1,74 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.templates.item.L2Weapon;
/**
* The Class ConditionChangeWeapon.
* @author nBd
*/
public class ConditionChangeWeapon extends Condition
{
private final boolean _required;
/**
* Instantiates a new condition change weapon.
* @param required the required
*/
public ConditionChangeWeapon(boolean required)
{
_required = required;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
if (_required)
{
L2Weapon weaponItem = env.player.getActiveWeaponItem();
if (weaponItem == null)
{
return false;
}
if (weaponItem.getChangeWeaponId() == 0)
{
return false;
}
if (((L2PcInstance) env.player).isEnchanting())
{
return false;
}
}
return true;
}
}
@@ -0,0 +1,71 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.effects.EffectFusion;
/**
* The Class ConditionForceBuff.
* @author kombat, Forsaiken
*/
public final class ConditionForceBuff extends Condition
{
private static final short BATTLE_FORCE = 5104;
private static final short SPELL_FORCE = 5105;
private final byte[] _forces;
/**
* Instantiates a new condition force buff.
* @param forces the forces
*/
public ConditionForceBuff(byte[] forces)
{
_forces = forces;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (_forces[0] > 0)
{
L2Effect force = env.player.getFirstEffect(BATTLE_FORCE);
if ((force == null) || (((EffectFusion) force)._effect < _forces[0]))
{
return false;
}
}
if (_forces[1] > 0)
{
L2Effect force = env.player.getFirstEffect(SPELL_FORCE);
if ((force == null) || (((EffectFusion) force)._effect < _forces[1]))
{
return false;
}
}
return true;
}
}
@@ -0,0 +1,48 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.util.Rnd;
/**
* The Class ConditionGameChance.
* @author Advi
*/
public class ConditionGameChance extends Condition
{
private final int _chance;
/**
* Instantiates a new condition game chance.
* @param chance the chance
*/
public ConditionGameChance(int chance)
{
_chance = chance;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return Rnd.get(100) < _chance;
}
}
@@ -0,0 +1,65 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionGameTime.
* @author mkizub
*/
public class ConditionGameTime extends Condition
{
/**
* The Enum CheckGameTime.
*/
public enum CheckGameTime
{
NIGHT
}
private final CheckGameTime _check;
private final boolean _required;
/**
* Instantiates a new condition game time.
* @param check the check
* @param required the required
*/
public ConditionGameTime(CheckGameTime check, boolean required)
{
_check = check;
_required = required;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
switch (_check)
{
case NIGHT:
return GameTimeController.getInstance().isNowNight() == _required;
}
return !_required;
}
}
@@ -0,0 +1,45 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionInventory.
* @author mkizub
*/
public abstract class ConditionInventory extends Condition
{
protected final int _slot;
/**
* Instantiates a new condition inventory.
* @param slot the slot
*/
public ConditionInventory(int slot)
{
_slot = slot;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public abstract boolean testImpl(Env env);
}
@@ -0,0 +1,52 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionItemId.
* @author mkizub
*/
public final class ConditionItemId extends Condition
{
private final int _itemId;
/**
* Instantiates a new condition item id.
* @param itemId the item id
*/
public ConditionItemId(int itemId)
{
_itemId = itemId;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.item == null)
{
return false;
}
return env.item.getItemId() == _itemId;
}
}
@@ -0,0 +1,30 @@
/*
* 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.conditions;
/**
* The listener interface for receiving condition events. The class that is interested in processing a condition event implements this interface, and the object created with that class is registered with a component using the component's <code>addConditionListener<code> method. When
* the condition event occurs, that object's appropriate
* method is invoked.
* @author mkizub
*/
public interface ConditionListener
{
/**
* Notify changed.
*/
public void notifyChanged();
}
@@ -0,0 +1,101 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionLogicAnd.
* @author mkizub
*/
public class ConditionLogicAnd extends Condition
{
private static Condition[] _emptyConditions = new Condition[0];
public Condition[] conditions = _emptyConditions;
/**
* Instantiates a new condition logic and.
*/
public ConditionLogicAnd()
{
super();
}
/**
* Adds the.
* @param condition the condition
*/
public void add(Condition condition)
{
if (condition == null)
{
return;
}
if (getListener() != null)
{
condition.setListener(this);
}
final int len = conditions.length;
final Condition[] tmp = new Condition[len + 1];
System.arraycopy(conditions, 0, tmp, 0, len);
tmp[len] = condition;
conditions = tmp;
}
/**
* Sets the listener.
* @param listener the new listener
* @see com.l2jserver.gameserver.skills.conditions.Condition#setListener(com.l2jserver.gameserver.skills.conditions.ConditionListener)
*/
@Override
void setListener(ConditionListener listener)
{
if (listener != null)
{
for (Condition c : conditions)
{
c.setListener(this);
}
}
else
{
for (Condition c : conditions)
{
c.setListener(null);
}
}
super.setListener(listener);
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
for (Condition c : conditions)
{
if (!c.test(env))
{
return false;
}
}
return true;
}
}
@@ -0,0 +1,71 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionLogicNot.
* @author mkizub
*/
public class ConditionLogicNot extends Condition
{
private final Condition _condition;
/**
* Instantiates a new condition logic not.
* @param condition the condition
*/
public ConditionLogicNot(Condition condition)
{
_condition = condition;
if (getListener() != null)
{
_condition.setListener(this);
}
}
/**
* Sets the listener.
* @param listener the new listener
* @see com.l2jserver.gameserver.skills.conditions.Condition#setListener(com.l2jserver.gameserver.skills.conditions.ConditionListener)
*/
@Override
void setListener(ConditionListener listener)
{
if (listener != null)
{
_condition.setListener(this);
}
else
{
_condition.setListener(null);
}
super.setListener(listener);
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return !_condition.test(env);
}
}
@@ -0,0 +1,94 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionLogicOr.
* @author mkizub
*/
public class ConditionLogicOr extends Condition
{
private static Condition[] _emptyConditions = new Condition[0];
public Condition[] conditions = _emptyConditions;
/**
* Adds the.
* @param condition the condition
*/
public void add(Condition condition)
{
if (condition == null)
{
return;
}
if (getListener() != null)
{
condition.setListener(this);
}
final int len = conditions.length;
final Condition[] tmp = new Condition[len + 1];
System.arraycopy(conditions, 0, tmp, 0, len);
tmp[len] = condition;
conditions = tmp;
}
/**
* Sets the listener.
* @param listener the new listener
* @see com.l2jserver.gameserver.skills.conditions.Condition#setListener(com.l2jserver.gameserver.skills.conditions.ConditionListener)
*/
@Override
void setListener(ConditionListener listener)
{
if (listener != null)
{
for (Condition c : conditions)
{
c.setListener(this);
}
}
else
{
for (Condition c : conditions)
{
c.setListener(null);
}
}
super.setListener(listener);
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
for (Condition c : conditions)
{
if (c.test(env))
{
return true;
}
}
return false;
}
}
@@ -0,0 +1,49 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionMinDistance.
* @author Didldak
*/
public class ConditionMinDistance extends Condition
{
private final int _sqDistance;
/**
* Instantiates a new condition min distance.
* @param sqDistance the sq distance
*/
public ConditionMinDistance(int sqDistance)
{
_sqDistance = sqDistance;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.target == null)
{
return false;
}
return env.player.getDistanceSq(env.target) >= _sqDistance;
}
}
@@ -0,0 +1,81 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.datatables.PetDataTable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.templates.item.L2Item;
/**
* @author JIV
*/
public class ConditionPetType extends Condition
{
private final int petType;
public ConditionPetType(int petType)
{
this.petType = petType;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
boolean testImpl(Env env)
{
if (!(env.player instanceof L2PetInstance))
{
return false;
}
/*
* if ((petType & L2Item.ANY_PET) == L2Item.ANY_PET) return true;
*/
int npcid = ((L2Summon) env.player).getNpcId();
if (PetDataTable.isHatchling(npcid) && ((petType & L2Item.HATCHLING) == L2Item.HATCHLING))
{
return true;
}
else if (PetDataTable.isWolf(npcid) && ((petType & L2Item.WOLF) == L2Item.WOLF))
{
return true;
}
else if (PetDataTable.isEvolvedWolf(npcid) && ((petType & L2Item.GROWN_WOLF) == L2Item.GROWN_WOLF))
{
return true;
}
else if (PetDataTable.isStrider(npcid) && ((petType & L2Item.STRIDER) == L2Item.STRIDER))
{
return true;
}
else if (PetDataTable.isBaby(npcid) && ((petType & L2Item.BABY) == L2Item.BABY))
{
return true;
}
else if (PetDataTable.isImprovedBaby(npcid) && ((petType & L2Item.IMPROVED_BABY) == L2Item.IMPROVED_BABY))
{
return true;
}
return false;
}
}
@@ -0,0 +1,65 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerActiveEffectId.
*/
public class ConditionPlayerActiveEffectId extends Condition
{
private final int _effectId;
private final int _effectLvl;
/**
* Instantiates a new condition player active effect id.
* @param effectId the effect id
*/
public ConditionPlayerActiveEffectId(int effectId)
{
_effectId = effectId;
_effectLvl = -1;
}
/**
* Instantiates a new condition player active effect id.
* @param effectId the effect id
* @param effectLevel the effect level
*/
public ConditionPlayerActiveEffectId(int effectId, int effectLevel)
{
_effectId = effectId;
_effectLvl = effectLevel;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
final L2Effect e = env.player.getFirstEffect(_effectId);
if ((e != null) && ((_effectLvl == -1) || (_effectLvl <= e.getSkill().getLevel())))
{
return true;
}
return false;
}
}
@@ -0,0 +1,72 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerActiveSkillId.
* @author DrHouse
*/
public class ConditionPlayerActiveSkillId extends Condition
{
private final int _skillId;
private final int _skillLevel;
/**
* Instantiates a new condition player active skill id.
* @param skillId the skill id
*/
public ConditionPlayerActiveSkillId(int skillId)
{
_skillId = skillId;
_skillLevel = -1;
}
/**
* Instantiates a new condition player active skill id.
* @param skillId the skill id
* @param skillLevel the skill level
*/
public ConditionPlayerActiveSkillId(int skillId, int skillLevel)
{
_skillId = skillId;
_skillLevel = skillLevel;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
for (L2Skill sk : env.player.getAllSkills())
{
if (sk != null)
{
if (sk.getId() == _skillId)
{
if ((_skillLevel == -1) || (_skillLevel <= sk.getLevel()))
{
return true;
}
}
}
}
return false;
}
}
@@ -0,0 +1,45 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerAgathionId.
*/
public class ConditionPlayerAgathionId extends Condition
{
private final int _agathionId;
/**
* Instantiates a new condition player agathion id.
* @param agathionId the agathion id
*/
public ConditionPlayerAgathionId(int agathionId)
{
_agathionId = agathionId;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return ((L2PcInstance) env.player).getAgathionId() == _agathionId;
}
}
@@ -0,0 +1,85 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerBaseStats.
* @author mkizub
*/
public class ConditionPlayerBaseStats extends Condition
{
private final BaseStat _stat;
private final int _value;
/**
* Instantiates a new condition player base stats.
* @param player the player
* @param stat the stat
* @param value the value
*/
public ConditionPlayerBaseStats(L2Character player, BaseStat stat, int value)
{
super();
_stat = stat;
_value = value;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
L2PcInstance player = (L2PcInstance) env.player;
switch (_stat)
{
case Int:
return player.getINT() >= _value;
case Str:
return player.getSTR() >= _value;
case Con:
return player.getCON() >= _value;
case Dex:
return player.getDEX() >= _value;
case Men:
return player.getMEN() >= _value;
case Wit:
return player.getWIT() >= _value;
}
return false;
}
}
enum BaseStat
{
Int,
Str,
Con,
Dex,
Men,
Wit
}
@@ -0,0 +1,46 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerCharges.
*/
public class ConditionPlayerCharges extends Condition
{
private final int _charges;
/**
* Instantiates a new condition player charges.
* @param charges the charges
*/
public ConditionPlayerCharges(int charges)
{
_charges = charges;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return ((L2PcInstance) env.player).getCharges() >= _charges;
}
}
@@ -0,0 +1,51 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerClassIdRestriction.
*/
public class ConditionPlayerClassIdRestriction extends Condition
{
private final ArrayList<Integer> _classIds;
/**
* Instantiates a new condition player class id restriction.
* @param classId the class id
*/
public ConditionPlayerClassIdRestriction(ArrayList<Integer> classId)
{
_classIds = classId;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
return (_classIds.contains(((L2PcInstance) env.player).getClassId().getId()));
}
}
@@ -0,0 +1,50 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerCloakStatus.
*/
public class ConditionPlayerCloakStatus extends Condition
{
private final int _val;
/**
* Instantiates a new condition player cloak status.
* @param val the val
*/
public ConditionPlayerCloakStatus(int val)
{
_val = val;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
return ((L2PcInstance) env.player).getInventory().getCloakStatus() >= _val;
}
}
@@ -0,0 +1,45 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerCp.
*/
public class ConditionPlayerCp extends Condition
{
private final int _cp;
/**
* Instantiates a new condition player cp.
* @param cp the cp
*/
public ConditionPlayerCp(int cp)
{
_cp = cp;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return ((env.player.getCurrentCp() * 100) / env.player.getMaxCp()) >= _cp;
}
}
@@ -0,0 +1,47 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerFlyMounted.
* @author kerberos
*/
public class ConditionPlayerFlyMounted extends Condition
{
private final boolean _val;
/**
* Instantiates a new condition player fly mounted.
* @param val the val
*/
public ConditionPlayerFlyMounted(boolean val)
{
_val = val;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return (env.player instanceof L2PcInstance) ? ((L2PcInstance) env.player).isFlyingMounted() == _val : true;
}
}
@@ -0,0 +1,64 @@
/*
* 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.conditions;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerGrade.
* @author Gigiikun
*/
public final class ConditionPlayerGrade extends Condition
{
protected static final Logger _log = Logger.getLogger(ConditionPlayerGrade.class.getName());
// conditional values
public final static int COND_NO_GRADE = 0x0001;
public final static int COND_D_GRADE = 0x0002;
public final static int COND_C_GRADE = 0x0004;
public final static int COND_B_GRADE = 0x0008;
public final static int COND_A_GRADE = 0x0010;
public final static int COND_S_GRADE = 0x0020;
public final static int COND_S80_GRADE = 0x0040;
public final static int COND_S84_GRADE = 0x0080;
private final int _value;
/**
* Instantiates a new condition player grade.
* @param value the value
*/
public ConditionPlayerGrade(int value)
{
_value = value;
}
/**
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.player instanceof L2PcInstance)
{
final byte expIndex = (byte) ((L2PcInstance) env.player).getExpertiseLevel();
return _value == expIndex;
}
return false;
}
}
@@ -0,0 +1,67 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerHasCastle.
* @author MrPoke
*/
public final class ConditionPlayerHasCastle extends Condition
{
private final int _castle;
/**
* Instantiates a new condition player has castle.
* @param castle the castle
*/
public ConditionPlayerHasCastle(int castle)
{
_castle = castle;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
L2Clan clan = ((L2PcInstance) env.player).getClan();
if (clan == null)
{
return _castle == 0;
}
// Any castle
if (_castle == -1)
{
return clan.getHasCastle() > 0;
}
return clan.getHasCastle() == _castle;
}
}
@@ -0,0 +1,68 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerHasClanHall.
* @author MrPoke
*/
public final class ConditionPlayerHasClanHall extends Condition
{
private final ArrayList<Integer> _clanHall;
/**
* Instantiates a new condition player has clan hall.
* @param clanHall the clan hall
*/
public ConditionPlayerHasClanHall(ArrayList<Integer> clanHall)
{
_clanHall = clanHall;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
L2Clan clan = ((L2PcInstance) env.player).getClan();
if (clan == null)
{
return ((_clanHall.size() == 1) && (_clanHall.get(0) == 0));
}
// All Clan Hall
if ((_clanHall.size() == 1) && (_clanHall.get(0) == -1))
{
return clan.getHasHideout() > 0;
}
return _clanHall.contains(clan.getHasHideout());
}
}
@@ -0,0 +1,67 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerHasFort.
* @author MrPoke
*/
public final class ConditionPlayerHasFort extends Condition
{
private final int _fort;
/**
* Instantiates a new condition player has fort.
* @param fort the fort
*/
public ConditionPlayerHasFort(int fort)
{
_fort = fort;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
L2Clan clan = ((L2PcInstance) env.player).getClan();
if (clan == null)
{
return _fort == 0;
}
// Any fortress
if (_fort == -1)
{
return clan.getHasFort() > 0;
}
return clan.getHasFort() == _fort;
}
}
@@ -0,0 +1,77 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerHasPet.
*/
public class ConditionPlayerHasPet extends Condition
{
private final ArrayList<Integer> _controlItemIds;
/**
* Instantiates a new condition player has pet.
* @param itemIds the item ids
*/
public ConditionPlayerHasPet(ArrayList<Integer> itemIds)
{
if ((itemIds.size() == 1) && (itemIds.get(0) == 0))
{
_controlItemIds = null;
}
else
{
_controlItemIds = itemIds;
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
if (!(env.player.getPet() instanceof L2PetInstance))
{
return false;
}
if (_controlItemIds == null)
{
return true;
}
final L2ItemInstance controlItem = ((L2PetInstance) env.player.getPet()).getControlItem();
if (controlItem == null)
{
return false;
}
return _controlItemIds.contains(controlItem.getItemId());
}
}
@@ -0,0 +1,45 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerHp.
* @author mr
*/
public class ConditionPlayerHp extends Condition
{
private final int _hp;
/**
* Instantiates a new condition player hp.
* @param hp the hp
*/
public ConditionPlayerHp(int hp)
{
_hp = hp;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return ((env.player.getCurrentHp() * 100) / env.player.getMaxVisibleHp()) <= _hp;
}
}
@@ -0,0 +1,66 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerInstanceId.
*/
public class ConditionPlayerInstanceId extends Condition
{
private final ArrayList<Integer> _instanceIds;
/**
* Instantiates a new condition player instance id.
* @param instanceIds the instance ids
*/
public ConditionPlayerInstanceId(ArrayList<Integer> instanceIds)
{
_instanceIds = instanceIds;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
final int instanceId = env.player.getInstanceId();
if (instanceId <= 0)
{
return false; // player not in instance
}
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld((L2PcInstance) env.player);
if ((world == null) || (world.instanceId != instanceId))
{
return false; // player in the different instance
}
return _instanceIds.contains(world.templateId);
}
}
@@ -0,0 +1,51 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerInvSize.
* @author Kerberos
*/
public class ConditionPlayerInvSize extends Condition
{
private final int _size;
/**
* Instantiates a new condition player inv size.
* @param size the size
*/
public ConditionPlayerInvSize(int size)
{
_size = size;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.player instanceof L2PcInstance)
{
return ((L2PcInstance) env.player).getInventory().getSize(false) <= (((L2PcInstance) env.player).getInventoryLimit() - _size);
}
return true;
}
}
@@ -0,0 +1,49 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerIsClanLeader.
*/
public class ConditionPlayerIsClanLeader extends Condition
{
private final boolean _val;
/**
* Instantiates a new condition player is clan leader.
* @param val the val
*/
public ConditionPlayerIsClanLeader(boolean val)
{
_val = val;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
return (((L2PcInstance) env.player).isClanLeader() == _val);
}
}
@@ -0,0 +1,49 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerIsHero.
*/
public class ConditionPlayerIsHero extends Condition
{
private final boolean _val;
/**
* Instantiates a new condition player is hero.
* @param val the val
*/
public ConditionPlayerIsHero(boolean val)
{
_val = val;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
return (((L2PcInstance) env.player).isHero() == _val);
}
}
@@ -0,0 +1,47 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerLandingZone.
* @author kerberos
*/
public class ConditionPlayerLandingZone extends Condition
{
private final boolean _val;
/**
* Instantiates a new condition player landing zone.
* @param val the val
*/
public ConditionPlayerLandingZone(boolean val)
{
_val = val;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return env.player.isInsideZone(L2Character.ZONE_LANDING) == _val;
}
}
@@ -0,0 +1,45 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerLevel.
* @author mkizub
*/
public class ConditionPlayerLevel extends Condition
{
private final int _level;
/**
* Instantiates a new condition player level.
* @param level the level
*/
public ConditionPlayerLevel(int level)
{
_level = level;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return env.player.getLevel() >= _level;
}
}
@@ -0,0 +1,40 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* @author Zoey76
*/
public class ConditionPlayerLevelRange extends Condition
{
private final int[] _levels;
/**
* Instantiates a new condition player levels range.
* @param the {@code levels} range.
*/
public ConditionPlayerLevelRange(int[] levels)
{
_levels = levels;
}
@Override
public boolean testImpl(Env env)
{
return ((env.player.getLevel() >= _levels[0]) && (env.player.getLevel() <= _levels[1]));
}
}
@@ -0,0 +1,45 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerMp.
*/
public class ConditionPlayerMp extends Condition
{
private final int _mp;
/**
* Instantiates a new condition player mp.
* @param mp the mp
*/
public ConditionPlayerMp(int mp)
{
_mp = mp;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return ((env.player.getCurrentMp() * 100) / env.player.getMaxMp()) <= _mp;
}
}
@@ -0,0 +1,50 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerPkCount.
*/
public class ConditionPlayerPkCount extends Condition
{
public final int _pk;
/**
* Instantiates a new condition player pk count.
* @param pk the pk
*/
public ConditionPlayerPkCount(int pk)
{
_pk = pk;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
return ((L2PcInstance) env.player).getPkKills() <= _pk;
}
}
@@ -0,0 +1,64 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerPledgeClass.
* @author MrPoke
*/
public final class ConditionPlayerPledgeClass extends Condition
{
private final int _pledgeClass;
/**
* Instantiates a new condition player pledge class.
* @param pledgeClass the pledge class
*/
public ConditionPlayerPledgeClass(int pledgeClass)
{
_pledgeClass = pledgeClass;
}
/**
* Test impl.
* @param env the env
* @return true, if successful
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
if (((L2PcInstance) env.player).getClan() == null)
{
return false;
}
if (_pledgeClass == -1)
{
return ((L2PcInstance) env.player).isClanLeader();
}
return (((L2PcInstance) env.player).getPledgeClass() >= _pledgeClass);
}
}
@@ -0,0 +1,48 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.Race;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.util.Util;
/**
* The Class ConditionPlayerRace.
* @author mkizub, Zoey76
*/
public class ConditionPlayerRace extends Condition
{
private final Race[] _races;
/**
* Instantiates a new condition player race.
* @param races the list containing the allowed races.
*/
public ConditionPlayerRace(Race[] races)
{
_races = races;
}
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
return Util.contains(_races, env.player.getActingPlayer().getRace());
}
}
@@ -0,0 +1,56 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.skills.Env;
/**
* @author UnAfraid
*/
public class ConditionPlayerRangeFromNpc extends Condition
{
private final int _npcId;
private final int _radius;
public ConditionPlayerRangeFromNpc(int npcId, int radius)
{
_npcId = npcId;
_radius = radius;
}
@Override
boolean testImpl(Env env)
{
if ((_npcId == 0) || (_radius == 0))
{
return false;
}
for (L2Character target : env.player.getKnownList().getKnownCharactersInRadius(_radius))
{
if (target instanceof L2Npc)
{
if (((L2Npc) target).getNpcId() == _npcId)
{
return true;
}
}
}
return false;
}
}
@@ -0,0 +1,64 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerServitorNpcId.
*/
public class ConditionPlayerServitorNpcId extends Condition
{
private final ArrayList<Integer> _npcIds;
/**
* Instantiates a new condition player servitor npc id.
* @param npcIds the npc ids
*/
public ConditionPlayerServitorNpcId(ArrayList<Integer> npcIds)
{
if ((npcIds.size() == 1) && (npcIds.get(0) == 0))
{
_npcIds = null;
}
else
{
_npcIds = npcIds;
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
if ((env.player.getPet() == null))
{
return false;
}
return (_npcIds == null) || _npcIds.contains(env.player.getPet().getNpcId());
}
}
@@ -0,0 +1,46 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerSex.
*/
public class ConditionPlayerSex extends Condition
{
// male 0 fmale 1
private final int _sex;
/**
* Instantiates a new condition player sex.
* @param sex the sex
*/
public ConditionPlayerSex(int sex)
{
_sex = sex;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return (((L2PcInstance) env.player).getAppearance().getSex() ? 1 : 0) == _sex;
}
}
@@ -0,0 +1,46 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerSiegeSide.
*/
public class ConditionPlayerSiegeSide extends Condition
{
private final int _siegeSide;
/**
* Instantiates a new condition player siege side.
* @param side the side
*/
public ConditionPlayerSiegeSide(int side)
{
_siegeSide = side;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return ((L2PcInstance) env.player).getSiegeSide() == _siegeSide;
}
}
@@ -0,0 +1,46 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerSouls.
*/
public class ConditionPlayerSouls extends Condition
{
private final int _souls;
/**
* Instantiates a new condition player souls.
* @param souls the souls
*/
public ConditionPlayerSouls(int souls)
{
_souls = souls;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return ((L2PcInstance) env.player).getSouls() >= _souls;
}
}
@@ -0,0 +1,93 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.PlayerState;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerState.
* @author mkizub
*/
public class ConditionPlayerState extends Condition
{
private final PlayerState _check;
private final boolean _required;
/**
* Instantiates a new condition player state.
* @param check the player state to be verified.
* @param required the required value.
*/
public ConditionPlayerState(PlayerState check, boolean required)
{
_check = check;
_required = required;
}
/**
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
final L2Character character = env.player;
L2PcInstance player = null;
switch (_check)
{
case RESTING:
player = character.getActingPlayer();
if (player != null)
{
return (player.isSitting() == _required);
}
return !_required;
case MOVING:
return character.isMoving() == _required;
case RUNNING:
return character.isRunning() == _required;
case STANDING:
player = character.getActingPlayer();
if (player != null)
{
return (_required != (player.isSitting() || player.isMoving()));
}
return (_required != character.isMoving());
case FLYING:
return (character.isFlying() == _required);
case BEHIND:
return (character.isBehindTarget() == _required);
case FRONT:
return (character.isInFrontOfTarget() == _required);
case CHAOTIC:
player = character.getActingPlayer();
if (player != null)
{
return ((player.getKarma() > 0) == _required);
}
return !_required;
case OLYMPIAD:
player = character.getActingPlayer();
if (player != null)
{
return (player.isInOlympiadMode() == _required);
}
return !_required;
}
return !_required;
}
}
@@ -0,0 +1,45 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerSubclass.
*/
public class ConditionPlayerSubclass extends Condition
{
private final boolean _val;
/**
* Instantiates a new condition player subclass.
* @param val the val
*/
public ConditionPlayerSubclass(boolean val)
{
_val = val;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return (env.player instanceof L2PcInstance) ? ((L2PcInstance) env.player).isSubClassActive() == _val : true;
}
}
@@ -0,0 +1,52 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionPlayerTvTEvent.
*/
public class ConditionPlayerTvTEvent extends Condition
{
private final boolean _val;
/**
* Instantiates a new condition player tv t event.
* @param val the val
*/
public ConditionPlayerTvTEvent(boolean val)
{
_val = val;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
final L2PcInstance player = env.player.getActingPlayer();
if ((player == null) || !TvTEvent.isStarted())
{
return !_val;
}
return (TvTEvent.isPlayerParticipant(player.getObjectId()) == _val);
}
}
@@ -0,0 +1,57 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Stats;
/**
* The Class ConditionPlayerWeight.
* @author Kerberos
*/
public class ConditionPlayerWeight extends Condition
{
private final int _weight;
/**
* Instantiates a new condition player weight.
* @param weight the weight
*/
public ConditionPlayerWeight(int weight)
{
_weight = weight;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.player instanceof L2PcInstance)
{
if (((L2PcInstance) env.player).getMaxLoad() > 0)
{
int weightproc = (((L2PcInstance) env.player).getCurrentLoad() * 100) / ((L2PcInstance) env.player).getMaxLoad();
weightproc *= (int) ((L2PcInstance) env.player).calcStat(Stats.WEIGHT_LIMIT, 1, env.player, null);
return (weightproc < _weight) || ((L2PcInstance) env.player).getDietMode();
}
}
return true;
}
}
@@ -0,0 +1,185 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.FortManager;
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionSiegeZone.
* @author Gigiikun
*/
public final class ConditionSiegeZone extends Condition
{
// conditional values
public final static int COND_NOT_ZONE = 0x0001;
public final static int COND_CAST_ATTACK = 0x0002;
public final static int COND_CAST_DEFEND = 0x0004;
public final static int COND_CAST_NEUTRAL = 0x0008;
public final static int COND_FORT_ATTACK = 0x0010;
public final static int COND_FORT_DEFEND = 0x0020;
public final static int COND_FORT_NEUTRAL = 0x0040;
public final static int COND_TW_CHANNEL = 0x0080;
public final static int COND_TW_PROGRESS = 0x0100;
private final int _value;
private final boolean _self;
/**
* Instantiates a new condition siege zone.
* @param value the value
* @param self the self
*/
public ConditionSiegeZone(int value, boolean self)
{
_value = value;
_self = self;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
L2Character target = _self ? env.player : env.target;
Castle castle = CastleManager.getInstance().getCastle(target);
Fort fort = FortManager.getInstance().getFort(target);
if (((_value & COND_TW_PROGRESS) != 0) && !TerritoryWarManager.getInstance().isTWInProgress())
{
return false;
}
else if (((_value & COND_TW_CHANNEL) != 0) && !TerritoryWarManager.getInstance().isTWChannelOpen())
{
return false;
}
else if ((castle == null) && (fort == null))
{
if ((_value & COND_NOT_ZONE) != 0)
{
return true;
}
return false;
}
if (castle != null)
{
return checkIfOk(target, castle, _value);
}
return checkIfOk(target, fort, _value);
}
/**
* Check if ok.
* @param activeChar the active char
* @param castle the castle
* @param value the value
* @return true, if successful
*/
public static boolean checkIfOk(L2Character activeChar, Castle castle, int value)
{
if ((activeChar == null) || !(activeChar instanceof L2PcInstance))
{
return false;
}
L2PcInstance player = (L2PcInstance) activeChar;
if (((castle == null) || (castle.getCastleId() <= 0)))
{
if ((value & COND_NOT_ZONE) != 0)
{
return true;
}
}
else if (!castle.getZone().isActive())
{
if ((value & COND_NOT_ZONE) != 0)
{
return true;
}
}
else if (((value & COND_CAST_ATTACK) != 0) && player.isRegisteredOnThisSiegeField(castle.getCastleId()) && (player.getSiegeState() == 1))
{
return true;
}
else if (((value & COND_CAST_DEFEND) != 0) && player.isRegisteredOnThisSiegeField(castle.getCastleId()) && (player.getSiegeState() == 2))
{
return true;
}
else if (((value & COND_CAST_NEUTRAL) != 0) && (player.getSiegeState() == 0))
{
return true;
}
return false;
}
/**
* Check if ok.
* @param activeChar the active char
* @param fort the fort
* @param value the value
* @return true, if successful
*/
public static boolean checkIfOk(L2Character activeChar, Fort fort, int value)
{
if ((activeChar == null) || !(activeChar instanceof L2PcInstance))
{
return false;
}
L2PcInstance player = (L2PcInstance) activeChar;
if (((fort == null) || (fort.getFortId() <= 0)))
{
if ((value & COND_NOT_ZONE) != 0)
{
return true;
}
}
else if (!fort.getZone().isActive())
{
if ((value & COND_NOT_ZONE) != 0)
{
return true;
}
}
else if (((value & COND_FORT_ATTACK) != 0) && player.isRegisteredOnThisSiegeField(fort.getFortId()) && (player.getSiegeState() == 1))
{
return true;
}
else if (((value & COND_FORT_DEFEND) != 0) && player.isRegisteredOnThisSiegeField(fort.getFortId()) && (player.getSiegeState() == 2))
{
return true;
}
else if (((value & COND_FORT_NEUTRAL) != 0) && (player.getSiegeState() == 0))
{
return true;
}
return false;
}
}
@@ -0,0 +1,52 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Stats;
/**
* The Class ConditionSkillStats.
* @author mkizub
*/
public class ConditionSkillStats extends Condition
{
private final Stats _stat;
/**
* Instantiates a new condition skill stats.
* @param stat the stat
*/
public ConditionSkillStats(Stats stat)
{
super();
_stat = stat;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.skill == null)
{
return false;
}
return env.skill.getStat() == _stat;
}
}
@@ -0,0 +1,64 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionSlotItemId.
* @author mkizub
*/
public final class ConditionSlotItemId extends ConditionInventory
{
private final int _itemId;
private final int _enchantLevel;
/**
* Instantiates a new condition slot item id.
* @param slot the slot
* @param itemId the item id
* @param enchantLevel the enchant level
*/
public ConditionSlotItemId(int slot, int itemId, int enchantLevel)
{
super(slot);
_itemId = itemId;
_enchantLevel = enchantLevel;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.ConditionInventory#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
Inventory inv = ((L2PcInstance) env.player).getInventory();
L2ItemInstance item = inv.getPaperdollItem(_slot);
if (item == null)
{
return _itemId == 0;
}
return (item.getItemId() == _itemId) && (item.getEnchantLevel() >= _enchantLevel);
}
}
@@ -0,0 +1,61 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionSlotItemType.
* @author mkizub
*/
public final class ConditionSlotItemType extends ConditionInventory
{
private final int _mask;
/**
* Instantiates a new condition slot item type.
* @param slot the slot
* @param mask the mask
*/
public ConditionSlotItemType(int slot, int mask)
{
super(slot);
_mask = mask;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.ConditionInventory#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
Inventory inv = ((L2PcInstance) env.player).getInventory();
L2ItemInstance item = inv.getPaperdollItem(_slot);
if (item == null)
{
return false;
}
return (item.getItem().getItemMask() & _mask) != 0;
}
}
@@ -0,0 +1,46 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetAbnormal.
* @author janiii
*/
public class ConditionTargetAbnormal extends Condition
{
private final int _abnormalId;
/**
* Instantiates a new condition target abnormal.
* @param abnormalId the abnormal id
*/
public ConditionTargetAbnormal(int abnormalId)
{
_abnormalId = abnormalId;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
boolean testImpl(Env env)
{
return (env.target.getAbnormalEffect() & _abnormalId) != 0;
}
}
@@ -0,0 +1,65 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetActiveEffectId.
*/
public class ConditionTargetActiveEffectId extends Condition
{
private final int _effectId;
private final int _effectLvl;
/**
* Instantiates a new condition target active effect id.
* @param effectId the effect id
*/
public ConditionTargetActiveEffectId(int effectId)
{
_effectId = effectId;
_effectLvl = -1;
}
/**
* Instantiates a new condition target active effect id.
* @param effectId the effect id
* @param effectLevel the effect level
*/
public ConditionTargetActiveEffectId(int effectId, int effectLevel)
{
_effectId = effectId;
_effectLvl = effectLevel;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
final L2Effect e = env.target.getFirstEffect(_effectId);
if ((e != null) && ((_effectLvl == -1) || (_effectLvl <= e.getSkill().getLevel())))
{
return true;
}
return false;
}
}
@@ -0,0 +1,72 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetActiveSkillId.
*/
public class ConditionTargetActiveSkillId extends Condition
{
private final int _skillId;
private final int _skillLevel;
/**
* Instantiates a new condition target active skill id.
* @param skillId the skill id
*/
public ConditionTargetActiveSkillId(int skillId)
{
_skillId = skillId;
_skillLevel = -1;
}
/**
* Instantiates a new condition target active skill id.
* @param skillId the skill id
* @param skillLevel the skill level
*/
public ConditionTargetActiveSkillId(int skillId, int skillLevel)
{
_skillId = skillId;
_skillLevel = skillLevel;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
for (L2Skill sk : env.target.getAllSkills())
{
if (sk != null)
{
if (sk.getId() == _skillId)
{
if ((_skillLevel == -1) || (_skillLevel <= sk.getLevel()))
{
return true;
}
}
}
}
return false;
}
}
@@ -0,0 +1,58 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetAggro.
* @author mkizub
*/
public class ConditionTargetAggro extends Condition
{
private final boolean _isAggro;
/**
* Instantiates a new condition target aggro.
* @param isAggro the is aggro
*/
public ConditionTargetAggro(boolean isAggro)
{
_isAggro = isAggro;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
L2Character target = env.target;
if (target instanceof L2MonsterInstance)
{
return ((L2MonsterInstance) target).isAggressive() == _isAggro;
}
if (target instanceof L2PcInstance)
{
return ((L2PcInstance) target).getKarma() > 0;
}
return false;
}
}
@@ -0,0 +1,70 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.templates.item.L2Armor;
import com.l2jserver.gameserver.templates.item.L2Item;
/**
* The Class ConditionTargetBodyPart.
* @author mkizub
*/
public class ConditionTargetBodyPart extends Condition
{
private final L2Armor _armor;
/**
* Instantiates a new condition target body part.
* @param armor the armor
*/
public ConditionTargetBodyPart(L2Armor armor)
{
_armor = armor;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
// target is attacker
if (env.target == null)
{
return true;
}
int bodypart = env.target.getAttackingBodyPart();
int armor_part = _armor.getBodyPart();
switch (bodypart)
{
case Inventory.PAPERDOLL_CHEST:
return (armor_part & (L2Item.SLOT_CHEST | L2Item.SLOT_FULL_ARMOR | L2Item.SLOT_UNDERWEAR)) != 0;
case Inventory.PAPERDOLL_LEGS:
return (armor_part & (L2Item.SLOT_LEGS | L2Item.SLOT_FULL_ARMOR)) != 0;
case Inventory.PAPERDOLL_HEAD:
return (armor_part & L2Item.SLOT_HEAD) != 0;
case Inventory.PAPERDOLL_FEET:
return (armor_part & L2Item.SLOT_FEET) != 0;
case Inventory.PAPERDOLL_GLOVES:
return (armor_part & L2Item.SLOT_GLOVES) != 0;
default:
return true;
}
}
}
@@ -0,0 +1,51 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetClassIdRestriction.
*/
public class ConditionTargetClassIdRestriction extends Condition
{
private final ArrayList<Integer> _classIds;
/**
* Instantiates a new condition target class id restriction.
* @param classId the class id
*/
public ConditionTargetClassIdRestriction(ArrayList<Integer> classId)
{
_classIds = classId;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.target instanceof L2PcInstance))
{
return false;
}
return (_classIds.contains(((L2PcInstance) env.target).getClassId().getId()));
}
}
@@ -0,0 +1,50 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetLevel.
* @author mkizub
*/
public class ConditionTargetLevel extends Condition
{
private final int _level;
/**
* Instantiates a new condition target level.
* @param level the level
*/
public ConditionTargetLevel(int level)
{
_level = level;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.target == null)
{
return false;
}
return env.target.getLevel() >= _level;
}
}
@@ -0,0 +1,42 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetNone.
* @author mkizub
*/
public class ConditionTargetNone extends Condition
{
/**
* Instantiates a new condition target none.
*/
public ConditionTargetNone()
{
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return (env.target == null);
}
}
@@ -0,0 +1,58 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetNpcId.
*/
public class ConditionTargetNpcId extends Condition
{
private final ArrayList<Integer> _npcIds;
/**
* Instantiates a new condition target npc id.
* @param npcIds the npc ids
*/
public ConditionTargetNpcId(ArrayList<Integer> npcIds)
{
_npcIds = npcIds;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.target instanceof L2Npc)
{
return _npcIds.contains(((L2Npc) env.target).getNpcId());
}
if (env.target instanceof L2DoorInstance)
{
return _npcIds.contains(((L2DoorInstance) env.target).getDoorId());
}
return false;
}
}
@@ -0,0 +1,51 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2Object.InstanceType;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetNpcType.
*/
public class ConditionTargetNpcType extends Condition
{
private final InstanceType[] _npcType;
/**
* Instantiates a new condition target npc type.
* @param type the type
*/
public ConditionTargetNpcType(InstanceType[] type)
{
_npcType = type;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.target == null)
{
return false;
}
return env.target.getInstanceType().isTypes(_npcType);
}
}
@@ -0,0 +1,34 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.skills.Env;
/**
* @author DS
*/
public class ConditionTargetPlayable extends Condition
{
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
return (env.target instanceof L2Playable);
}
}
@@ -0,0 +1,48 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.Race;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.util.Util;
/**
* The Class ConditionTargetRace.
* @author mkizub, Zoey76
*/
public class ConditionTargetRace extends Condition
{
private final Race[] _races;
/**
* Instantiates a new condition target race.
* @param races the list containing the allowed races.
*/
public ConditionTargetRace(Race[] races)
{
_races = races;
}
@Override
public boolean testImpl(Env env)
{
if (!(env.target instanceof L2PcInstance))
{
return false;
}
return Util.contains(_races, env.target.getActingPlayer().getRace());
}
}
@@ -0,0 +1,53 @@
/*
* 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.conditions;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionTargetRaceId.
* @author nBd
*/
public class ConditionTargetRaceId extends Condition
{
private final ArrayList<Integer> _raceIds;
/**
* Instantiates a new condition target race id.
* @param raceId the race id
*/
public ConditionTargetRaceId(ArrayList<Integer> raceId)
{
_raceIds = raceId;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.target instanceof L2Npc))
{
return false;
}
return (_raceIds.contains(((L2Npc) env.target).getTemplate().getRace().ordinal() + 1));
}
}
@@ -0,0 +1,60 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.templates.item.L2Weapon;
/**
* The Class ConditionTargetUsesWeaponKind.
* @author mkizub
*/
public class ConditionTargetUsesWeaponKind extends Condition
{
private final int _weaponMask;
/**
* Instantiates a new condition target uses weapon kind.
* @param weaponMask the weapon mask
*/
public ConditionTargetUsesWeaponKind(int weaponMask)
{
_weaponMask = weaponMask;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.target == null)
{
return false;
}
L2Weapon item = env.target.getActiveWeaponItem();
if (item == null)
{
return false;
}
return (item.getItemType().mask() & _weaponMask) != 0;
}
}
@@ -0,0 +1,93 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.templates.item.L2ArmorType;
import com.l2jserver.gameserver.templates.item.L2Item;
/**
* The Class ConditionUsingItemType.
* @author mkizub
*/
public final class ConditionUsingItemType extends Condition
{
private final boolean _armor;
private final int _mask;
/**
* Instantiates a new condition using item type.
* @param mask the mask
*/
public ConditionUsingItemType(int mask)
{
_mask = mask;
_armor = (_mask & (L2ArmorType.MAGIC.mask() | L2ArmorType.LIGHT.mask() | L2ArmorType.HEAVY.mask())) != 0;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!(env.player instanceof L2PcInstance))
{
return false;
}
Inventory inv = ((L2PcInstance) env.player).getInventory();
// If ConditionUsingItemType is one between Light, Heavy or Magic
if (_armor)
{
// Get the itemMask of the weared chest (if exists)
L2ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST);
if (chest == null)
{
return false;
}
int chestMask = chest.getItem().getItemMask();
// If chest armor is different from the condition one return false
if ((_mask & chestMask) == 0)
{
return false;
}
// So from here, chest armor matches conditions
int chestBodyPart = chest.getItem().getBodyPart();
// return True if chest armor is a Full Armor
if (chestBodyPart == L2Item.SLOT_FULL_ARMOR)
{
return true;
}
L2ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
if (legs == null)
{
return false;
}
int legMask = legs.getItem().getItemMask();
// return true if legs armor matches too
return (_mask & legMask) != 0;
}
return (_mask & inv.getWearedMask()) != 0;
}
}
@@ -0,0 +1,49 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionUsingSkill.
* @author mkizub
*/
public final class ConditionUsingSkill extends Condition
{
private final int _skillId;
/**
* Instantiates a new condition using skill.
* @param skillId the skill id
*/
public ConditionUsingSkill(int skillId)
{
_skillId = skillId;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (env.skill == null)
{
return false;
}
return env.skill.getId() == _skillId;
}
}
@@ -0,0 +1,49 @@
/*
* 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.conditions;
import com.l2jserver.gameserver.skills.Env;
/**
* The Class ConditionWithSkill.
* @author Steuf
*/
public class ConditionWithSkill extends Condition
{
private final boolean _skill;
/**
* Instantiates a new condition with skill.
* @param skill the skill
*/
public ConditionWithSkill(boolean skill)
{
_skill = skill;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
*/
@Override
public boolean testImpl(Env env)
{
if (!_skill && (env.skill != null))
{
return false;
}
return true;
}
}