Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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.ai.ext.tasks;
- import com.l2jserver.gameserver.ai.ext.AI_TaskQueue;
- import com.l2jserver.gameserver.ai.ext.struct.task.AITaskSimpleVar;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import java.util.Collection;
- /**
- * ==============================================<br>
- * CollisionSpdUpdateTask - Insert description...<br>
- * ==============================================<br>
- */
- public class CollisionSpdUpdateTask extends AbstractAITask
- {
- public CollisionSpdUpdateTask(L2Character actor)
- {
- super(actor.getAITaskQueue(), 0, false, true, 0, actor);
- }
- @Override
- protected void initTaskTypeName()
- {
- _name = "CollisionSpdUpdateTask";
- }
- @Override
- public boolean valid()
- {
- return !getActor().isAlikeDead() && !getActor().isMovementDisabled() && !getActor().isFloating() && hasAI() && getAI().getIntention().isAttackingMode();
- }
- @Override
- public boolean ready()
- {
- return getActor().isMoving() && getActor().isRunning();
- }
- @Override
- public boolean run()
- {
- Collection<L2Character> k = getActor().getKnownList().getKnownCharactersInRadius((int) getActor().getCollisionRadius() * 2);
- double factor = 1.0;
- int count = k.size();
- if (count > 10)
- factor = 0.3;
- else if (count > 8)
- factor = 0.4;
- else if (count > 6)
- factor = 0.5;
- else if (count > 4)
- factor = 0.6;
- else if (count > 2)
- factor = 0.7;
- else if (count > 1)
- factor = 0.9;
- getActor().getStat().setCollisionSpdModFactor(factor);
- return true;
- }
- @Override
- public boolean block_think_after_run()
- {
- return false;
- }
- @Override
- public int update_weight()
- {
- return -1;
- }
- @Override
- public boolean valid_update_weight_delay()
- {
- return false;
- }
- @Override
- public boolean removeable()
- {
- return !valid();
- }
- @Override
- public boolean valid_run_delay()
- {
- return getTaskLastExecTimestamp(false) <= 0 || System.currentTimeMillis() - getTaskLastExecTimestamp(false) > 400;
- }
- @Override
- public int max_task_instances()
- {
- return 1;
- }
- @Override
- public void on_variable_listener(AITaskSimpleVar.LISTENER_EVENTS event, AITaskSimpleVar variable)
- {
- }
- @Override
- public void on_added_to_queue(AI_TaskQueue queue)
- {
- }
- @Override
- public void on_remove_from_queue(AI_TaskQueue queue)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement