Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package l2d.game.model.instances.custom;
- import java.util.concurrent.ScheduledFuture;
- import l2d.Config;
- import l2d.ext.scripts.Functions;
- import l2d.game.ThreadPoolManager;
- import l2d.game.ai.CtrlIntention;
- import l2d.game.ai.L2CharacterAI;
- import l2d.game.instancemanager.HellboundManager;
- import l2d.game.model.L2Character;
- import l2d.game.model.L2DropData;
- import l2d.game.model.L2Player;
- import l2d.game.model.L2Spawn;
- import l2d.game.model.L2World;
- import l2d.game.model.base.Experience;
- import l2d.game.model.instances.L2NpcInstance;
- import l2d.game.templates.L2NpcTemplate;
- import l2d.util.Util;
- public class L2RabInstance extends L2HellboundNpcInstance
- {
- private ScheduledFuture<?> FallowTask;
- private static L2Player spasitel;
- private static final L2DropData[] DROPS = { new L2DropData(1876, 1, 2, 1000000.0D, 1), new L2DropData(1885, 3, 4, 1000000.0D, 1), new L2DropData(9628, 5, 10, 1000000.0D, 1) };
- public L2RabInstance(int objectId, L2NpcTemplate template)
- {
- super(objectId, template);
- }
- public void doDie(L2Character killer)
- {
- HellboundManager.getInstance().addPoints(-10L);
- }
- public void showChatWindow(L2Player player, int val)
- {
- int hLevel = HellboundManager.getInstance().getLevel();
- String filename = "";
- String path = "data/html/hellbound/rab/";
- if (hLevel < 5)
- filename = "data/html/hellbound/rab/" + getNpcId() + "-no.htm";
- else if (hLevel >= 5) {
- filename = "data/html/hellbound/rab/" + getNpcId() + ".htm";
- }
- super.showChatWindow(player, filename);
- }
- public void onBypassFeedback(L2Player p, String command)
- {
- if (command.equalsIgnoreCase("fallowme"))
- {
- setSpasitel(p);
- startFallowTask();
- }
- super.onBypassFeedback(p, command);
- }
- public void startFallowTask()
- {
- if (this.FallowTask != null) {
- stopFallowTask();
- }
- if (getSpasitel() != null)
- this.FallowTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Fallow(null), 10L, 1000L);
- }
- public void stopFallowTask()
- {
- if (this.FallowTask != null)
- this.FallowTask.cancel(false);
- this.FallowTask = null;
- }
- public void setSpasitel(L2Player p)
- {
- spasitel = p;
- }
- public L2Player getSpasitel()
- {
- return spasitel;
- }
- public void setIsSpasen()
- {
- stopFallowTask();
- stopMove();
- if (getSpasitel() != null)
- {
- double chancemod = Experience.penaltyModifier(calculateLevelDiffForDrop(getSpasitel().getLevel()), 9.0D);
- L2DropData d = DROPS[l2d.util.Rnd.get(0, DROPS.length)];
- if (d != null) {
- dropItem(getSpasitel(), d.getItemId(), Util.rollDrop(d.getMinDrop(), d.getMaxDrop(), d.getChance() * chancemod * Config.RATE_DROP_ITEMS * getSpasitel().getRateItems(), true));
- }
- }
- Functions.npcSay(this, "Thank you for saving me! Here is a small gift.");
- HellboundManager.getInstance().addPoints(10L);
- decayMe();
- getSpawn().respawnNpc(this);
- }
- private void checkInRadius(int id)
- {
- L2NpcInstance Pillar = L2World.findNpcByNpcId(id);
- if (getRealDistance3D(Pillar) <= 200.0D)
- setIsSpasen();
- }
- private class Fallow implements Runnable {
- private Fallow() {
- }
- public void run() {
- L2RabInstance.this.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, L2RabInstance.this.getSpasitel(), Integer.valueOf(200));
- L2RabInstance.this.checkInRadius(18506);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement