Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.74 KB | None | 0 0
  1. /*
  2.  * This file is part of the L2J Mobius project.
  3.  *
  4.  * This program is free software: you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation, either version 3 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12.  * General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16.  */
  17. package org.l2jmobius.gameserver.model.effects;
  18.  
  19. import java.util.logging.Logger;
  20.  
  21. import org.l2jmobius.Config;
  22. import org.l2jmobius.gameserver.model.actor.Creature;
  23. import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
  24. import org.l2jmobius.gameserver.model.skills.Skill;
  25.  
  26. /**
  27.  * Abstract effect implementation.<br>
  28.  * Instant effects should not override {@link #onExit(Creature, Creature, Skill)}.<br>
  29.  * Instant effects should not override {@link #canStart(Creature, Creature, Skill)}, all checks should be done {@link #onStart(Creature, Creature, Skill, ItemInstance)}.<br>
  30.  * Do not call super class methods {@link #onStart(Creature, Creature, Skill, ItemInstance)} nor {@link #onExit(Creature, Creature, Skill)}.
  31.  * @author Zoey76
  32.  */
  33. public abstract class AbstractEffect
  34. {
  35.     protected static final Logger LOGGER = Logger.getLogger(AbstractEffect.class.getName());
  36.    
  37.     private int _ticks;
  38.    
  39.     /**
  40.      * Gets the effect ticks
  41.      * @return the ticks
  42.      */
  43.     public int getTicks()
  44.     {
  45.         return _ticks;
  46.     }
  47.    
  48.     /**
  49.      * Sets the effect ticks
  50.      * @param ticks the ticks
  51.      */
  52.     protected void setTicks(int ticks)
  53.     {
  54.         _ticks = ticks;
  55.     }
  56.    
  57.     public double getTicksMultiplier()
  58.     {
  59.         return (getTicks() * Config.EFFECT_TICK_RATIO) / 1000f;
  60.     }
  61.    
  62.     /**
  63.      * Calculates whether this effects land or not.<br>
  64.      * If it lands will be scheduled and added to the character effect list.<br>
  65.      * Override in effect implementation to change behavior. <br>
  66.      * <b>Warning:</b> Must be used only for instant effects continuous effects will not call this they have their success handled by activate_rate.
  67.      * @param effector
  68.      * @param effected
  69.      * @param skill
  70.      * @return {@code true} if this effect land, {@code false} otherwise
  71.      */
  72.     public boolean calcSuccess(Creature effector, Creature effected, Skill skill)
  73.     {
  74.         return true;
  75.     }
  76.    
  77.     /**
  78.      * Verify if the buff can start.<br>
  79.      * Used for continuous effects.
  80.      * @param effector
  81.      * @param effected
  82.      * @param skill
  83.      * @return {@code true} if all the start conditions are meet, {@code false} otherwise
  84.      */
  85.     public boolean canStart(Creature effector, Creature effected, Skill skill)
  86.     {
  87.         return true;
  88.     }
  89.    
  90.     public void instant(Creature effector, Creature effected, Skill skill, ItemInstance item)
  91.     {
  92.        
  93.     }
  94.    
  95.     public void continuousInstant(Creature effector, Creature effected, Skill skill, ItemInstance item)
  96.     {
  97.        
  98.     }
  99.    
  100.     public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item)
  101.     {
  102.        
  103.     }
  104.    
  105.     public void onExit(Creature effector, Creature effected, Skill skill)
  106.     {
  107.        
  108.     }
  109.    
  110.     /**
  111.      * Called on each tick.<br>
  112.      * If the abnormal time is lesser than zero it will last forever.
  113.      * @param effector
  114.      * @param effected
  115.      * @param skill
  116.      * @param item
  117.      * @return if {@code true} this effect will continue forever, if {@code false} it will stop after abnormal time has passed
  118.      */
  119.     public boolean onActionTime(Creature effector, Creature effected, Skill skill, ItemInstance item)
  120.     {
  121.         return false;
  122.     }
  123.    
  124.     /**
  125.      * Get the effect flags.
  126.      * @return bit flag for current effect
  127.      */
  128.     public long getEffectFlags()
  129.     {
  130.         return EffectFlag.NONE.getMask();
  131.     }
  132.    
  133.     public boolean checkCondition(Object obj)
  134.     {
  135.         return true;
  136.     }
  137.    
  138.     /**
  139.      * Verify if this effect is an instant effect.
  140.      * @return {@code true} if this effect is instant, {@code false} otherwise
  141.      */
  142.     public boolean isInstant()
  143.     {
  144.         return false;
  145.     }
  146.    
  147.     /**
  148.      * @param effector
  149.      * @param effected
  150.      * @param skill
  151.      * @return {@code true} if pump can be invoked, {@code false} otherwise
  152.      */
  153.     public boolean canPump(Creature effector, Creature effected, Skill skill)
  154.     {
  155.         return true;
  156.     }
  157.    
  158.     /**
  159.      * @param effected
  160.      * @param skill
  161.      */
  162.     public void pump(Creature effected, Skill skill)
  163.     {
  164.        
  165.     }
  166.    
  167.     /**
  168.      * Get this effect's type.<br>
  169.      * TODO: Remove.
  170.      * @return the effect type
  171.      */
  172.     public EffectType getEffectType()
  173.     {
  174.         return EffectType.NONE;
  175.     }
  176.    
  177.     @Override
  178.     public String toString()
  179.     {
  180.         return "Effect " + getClass().getSimpleName();
  181.     }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement