Advertisement
Deedlit

fdsfsdfsdf

Nov 20th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.98 KB | None | 0 0
  1. /*
  2.  * This program is free software: you can redistribute it and/or modify it under
  3.  * the terms of the GNU General Public License as published by the Free Software
  4.  * Foundation, either version 3 of the License, or (at your option) any later
  5.  * version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful, but WITHOUT
  8.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10.  * details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License along with
  13.  * this program. If not, see <http://www.gnu.org/licenses/>.
  14.  */
  15. package com.l2jserver.gameserver.ai.ext.tasks;
  16.  
  17. import com.l2jserver.gameserver.ai.ext.AI_TaskQueue;
  18. import com.l2jserver.gameserver.ai.ext.struct.task.AITaskSimpleVar;
  19. import com.l2jserver.gameserver.model.actor.L2Character;
  20.  
  21. import java.util.Collection;
  22.  
  23. /**
  24.  * ==============================================<br>
  25.  * CollisionSpdUpdateTask - Insert description...<br>
  26.  * ==============================================<br>
  27.  */
  28. public class CollisionSpdUpdateTask extends AbstractAITask
  29. {
  30.     public CollisionSpdUpdateTask(L2Character actor)
  31.     {
  32.         super(actor.getAITaskQueue(), 0, false, true, 0, actor);
  33.     }
  34.  
  35.     @Override
  36.     protected void initTaskTypeName()
  37.     {
  38.         _name = "CollisionSpdUpdateTask";
  39.     }
  40.  
  41.     @Override
  42.     public boolean valid()
  43.     {
  44.         return !getActor().isAlikeDead() && !getActor().isMovementDisabled() && !getActor().isFloating() && hasAI() && getAI().getIntention().isAttackingMode();
  45.     }
  46.  
  47.     @Override
  48.     public boolean ready()
  49.     {
  50.         return getActor().isMoving() && getActor().isRunning();
  51.     }
  52.  
  53.     @Override
  54.     public boolean run()
  55.     {
  56.         Collection<L2Character> k = getActor().getKnownList().getKnownCharactersInRadius((int) getActor().getCollisionRadius() * 2);
  57.         double factor = 1.0;
  58.         int count = k.size();
  59.         if (count > 10)
  60.             factor = 0.3;
  61.         else if (count > 8)
  62.             factor = 0.4;
  63.         else if (count > 6)
  64.             factor = 0.5;
  65.         else if (count > 4)
  66.             factor = 0.6;
  67.         else if (count > 2)
  68.             factor = 0.7;
  69.         else if (count > 1)
  70.             factor = 0.9;
  71.         getActor().getStat().setCollisionSpdModFactor(factor);
  72.         return true;
  73.     }
  74.  
  75.     @Override
  76.     public boolean block_think_after_run()
  77.     {
  78.         return false;
  79.     }
  80.  
  81.     @Override
  82.     public int update_weight()
  83.     {
  84.         return -1;
  85.     }
  86.  
  87.     @Override
  88.     public boolean valid_update_weight_delay()
  89.     {
  90.         return false;
  91.     }
  92.  
  93.     @Override
  94.     public boolean removeable()
  95.     {
  96.         return !valid();
  97.     }
  98.  
  99.     @Override
  100.     public boolean valid_run_delay()
  101.     {
  102.         return getTaskLastExecTimestamp(false) <= 0 || System.currentTimeMillis() - getTaskLastExecTimestamp(false) > 400;
  103.     }
  104.  
  105.     @Override
  106.     public int max_task_instances()
  107.     {
  108.         return 1;
  109.     }
  110.  
  111.     @Override
  112.     public void on_variable_listener(AITaskSimpleVar.LISTENER_EVENTS event, AITaskSimpleVar variable)
  113.     {
  114.  
  115.     }
  116.  
  117.     @Override
  118.     public void on_added_to_queue(AI_TaskQueue queue)
  119.     {
  120.  
  121.     }
  122.  
  123.     @Override
  124.     public void on_remove_from_queue(AI_TaskQueue queue)
  125.     {
  126.  
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement