Thread: Livid farm release

Results 1 to 1 of 1
  1. #1 Livid farm release 
    Registered Member

    Join Date
    Mar 2011
    Age
    24
    Posts
    548
    Thanks given
    158
    Thanks received
    162
    Rep Power
    220
    Very close to being fully complete, it just missing some unlocks on the store





    LividFarm Main class
    Code:
    package com.rs.game.minigames.lividfarm;
    
    import java.util.ArrayList;
    
    import com.rs.game.minigames.lividfarm.LividStore.Spell;
    import com.rs.game.player.Player;
    import com.rs.utils.Utils;
    
    /**
     * @author -Andreas 20 feb. 2020 13:29:52
     *    @[Only registered and activated users can see links. ] avalon
     * 
     */
    
    public class LividFarm {
    
    	private transient Player player;
    
    	private int produce;
    	public int spellAmount;
    	private ArrayList<Spell> spellsLearned = new ArrayList<>();
    
    	public LividFarm() {
    		produce = 0;
    	}
    
    	public ArrayList<Spell> getSpellsLearned() {
    		return spellsLearned;
    	}
    
    	public int getSpellAmount() {
    		return spellAmount;
    	}
    
    	public void addSpellAmount() {
    		spellAmount++;
    		player.getVarsManager().sendVarBit(9067, player.getLivid().getSpellAmount(), true);
    	}
    
    	public void setPlayer(Player player) {
    		this.player = player;
    	}
    
    	public int getProduce() {
    		return produce;
    	}
    
    	public void addProduce(int value) {
    		this.produce += (value * 20);
    		player.getVarsManager().sendVarBit(9065, player.getLivid().getProduce() / 10, true);
    		if (player.getControlerManager().getControler() instanceof LividFarmControler)
    			updateProduce(player);
    	}
    
    	public void removeProduce(int value) {
    		this.produce -= value;
    		player.getVarsManager().sendVarBit(9065, player.getLivid().getProduce() / 10, true);
    		if (player.getControlerManager().getControler() instanceof LividFarmControler)
    			updateProduce(player);
    	}
    
    	public static void updateProduce(Player player) {
    		player.getPackets().sendIComponentText(3046, 3,
    				"Produce: " + Utils.getFormattedNumber(player.getLivid().getProd  uce(), ','));
    	}
    
    }
    LividFarmControler
    Code:
    package com.rs.game.minigames.lividfarm;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Map.Entry;
    
    import com.rs.game.Animation;
    import com.rs.game.World;
    import com.rs.game.WorldObject;
    import com.rs.game.WorldTile;
    import com.rs.game.item.Item;
    import com.rs.game.npc.NPC;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.game.player.actions.combat.LunarMagicks;
    import com.rs.game.player.actions.combat.LunarMagicks.RSL  unarSpellStore;
    import com.rs.game.player.actions.combat.lunarspells.Cure  Plant;
    import com.rs.game.player.actions.combat.lunarspells.Fert  ileSoil;
    import com.rs.game.player.actions.combat.lunarspells.Plan  kMake;
    import com.rs.game.player.actions.combat.lunarspells.Stri  ngJewellery;
    import com.rs.game.player.controlers.Controler;
    import com.rs.game.player.dialogues.Dialogue;
    import com.rs.game.tasks.WorldTask;
    import com.rs.game.tasks.WorldTasksManager;
    import com.rs.utils.Utils;
    
    /**
     * 
     * @author Zed & -Andreas
     *
     */
    public class LividFarmControler extends Controler {
    
    	/**
    	 * NPC id for Pauline Polaris
    	 */
    	private transient int PAULINE = 13619;
    
    	/*
    	 * VarBit stages
    	 */
    	private int EMPTY_STAGE = 0, FERTILISED_STAGE = 1, GROWING_STAGE = 2, DISEASED_STAGE = 3, GROWN_STAGE = 4;
    
    	/**
    	 * Variables
    	 */
    	private int gathered;
    
    	private transient int ticks;
    	private transient int flowerTick;
    
    	/**
    	 * Player enters Livid Farm
    	 * 
    	 *    @[Only registered and activated users can see links. ] player - starts controler
    	 */
    	public static void enterLividFarm(Player player) {
    		player.setNextWorldTile(new WorldTile(2110, 3946, 0));
    		player.getControlerManager().startControler("LividFarmHandler");
    		player.sm("The minigame will start soon.");
    	}
    
    	/**
    	 * 
    	 *    @[Only registered and activated users can see links. ] object  - flower clicked
    	 *    @[Only registered and activated users can see links. ] success - if cure is success or not Cures disease of the flower
    	 *                clicked, checks for lunar magic requirements Gives 20 livid
    	 *                points Gives 140 farming experience
    	 */
    
    	public void cureDisease(WorldObject object, Player player, boolean success) {
    		if (player.getCombatDefinitions().getSpellBook() != 430) {
    			player.sm("You need to be on Lunar Magicks to do this.");
    			return;
    		}
    		RSLunarSpellStore spell = RSLunarSpellStore.CURE_PLANT;
    		if (LunarMagicks.simpleRequirementCheck(player, spell.getSpellId())) {
    			if (!success) {
    				LunarMagicks.removeRunes(player, spell.getRune());
    				player.getDialogueManager().startDialogue("SimpleNPCMessage", PAULINE,
    						"Sorry, but that is the wrong flower type.");
    				return;
    			}
    			if (CurePlant.cast(player, spell.getXp(), object)) {
    				LunarMagicks.removeRunes(player);
    				player.getSkills().addXp(Skills.FARMING, 140.0);
    				player.getLivid().addProduce(20);
    			}
    		}
    	}
    
    	/**
    	 * 
    	 *    @[Only registered and activated users can see links. ] object - patch clicked Fertilises the patch, checks for lunar magic
    	 *               requirements. Gives 20 livid points Gives 140 farming
    	 *               experience
    	 */
    	public void fertilisePatch(WorldObject object, Player player) {
    		if (player.getCombatDefinitions().getSpellBook() != 430) {
    			player.sm("You need to be on Lunar Magicks to do this.");
    			return;
    		}
    		RSLunarSpellStore spell = RSLunarSpellStore.FERTILE_SOUL;
    		if (LunarMagicks.simpleRequirementCheck(player, spell.getSpellId())) {
    			if (FertileSoil.cast(player, spell.getXp(), object)) {
    				LunarMagicks.removeRunes(player);
    				flowers.put(object.getTile(), 1);
    				player.getSkills().addXp(Skills.FARMING, 140.0);
    				player.getLivid().addProduce(20);
    			}
    		}
    	}
    
    	/**
    	 * 
    	 *    @[Only registered and activated users can see links. ] amount - amount of logs to give    @[Only registered and activated users can see links. ] player
    	 */
    
    	public void takeLog(Player player, int amount) {
    		if (!player.getInventory().hasFreeSlots()) {
    			player.sm("You don't have any inventory space.");
    			return;
    		}
    		player.getInventory().addItem(20702, amount);
    	}
    
    	/**
    	 * 
    	 *    @[Only registered and activated users can see links. ] slotId - inventory slot to replace with crafted log
    	 *    @[Only registered and activated users can see links. ] item   - item to replace with crafted log
    	 */
    
    	public static void makePlank(int slotId, Item item, Player player) {
    		if (player.getCombatDefinitions().getSpellBook() != 430) {
    			player.sm("You need to be on Lunar Magicks to do this.");
    			return;
    		}
    		RSLunarSpellStore spell = RSLunarSpellStore.PLANK_MAKE;
    		if (LunarMagicks.simpleRequirementCheck(player, spell.getSpellId())) {
    			if (PlankMake.cast(player, spell.getXp(), item.getId(), slotId, true)) {
    				LunarMagicks.removeRunes(player);
    			}
    		}
    	}
    
    	/**
    	 * 
    	 * Creates bunchs' with 5 livid plants each Gives 20 points
    	 */
    
    	public static void makeBunch(Player player) {
    		if (player.getCombatDefinitions().getSpellBook() != 430) {
    			player.sm("You need to be on Lunar Magicks to do this.");
    			return;
    		}
    		RSLunarSpellStore spell = RSLunarSpellStore.STRING_JEWELLERY;
    		if (LunarMagicks.simpleRequirementCheck(player, spell.getSpellId())) {
    			if (StringJewellery.cast(player, spell.getXp())) {
    				LunarMagicks.removeRunes(player);
    				player.getLivid().addProduce(20);
    			}
    		}
    	}
    
    	/**
    	 * Deposits the bunchs' in your inventory Gives 10 points each
    	 */
    
    	private void depositWagon(Player player) {
    		if (!player.getInventory().containsOneItem(20705)) {
    			player.sm("You don't have any plant bunch to trade in.");
    			return;
    		}
    		player.getInventory().deleteItem(20705, 1);
    		player.getLivid().addProduce(10);
    	}
    
    	/**
    	 *    @[Only registered and activated users can see links. ] object - broken fence clicked Checks if you have any planks to repair
    	 *               fence with. Repairs the fence if you have planks Gives 137
    	 *               magic experience + 83.5 construction experience Gives 20 points
    	 */
    
    	public void repairFence(Player player, WorldObject object) {
    		if (!player.getInventory().containsOneItem(20703)) {
    			player.getPackets().sendGameMessage("You don't have any planks to repair the fence with.");
    			return;
    		}
    		player.sm("You begin to repair the fence..");
    		player.lock(2);
    		player.animate(new Animation(11191));
    		WorldTasksManager.schedule(new WorldTask() {
    			int tick;
    
    			@Override
    			public void run() {
    				if (tick == 1) {
    					player.getInventory().deleteItem(new Item(20703));
    					player.getVarsManager().sendVarBit(object.getConfi  gByFile(), 0);
    					player.getSkills().addXp(Skills.MAGIC, 137.0);
    					player.getSkills().addXp(Skills.CONSTRUCTION, 83.5);
    					player.getLivid().addProduce(20);
    					player.sm("You've repaired the fence!");
    				}
    				tick++;
    			}
    		}, 0, 1);
    
    	}
    
    	public ArrayList<WorldObject> plantList = new ArrayList<WorldObject>();
    
    	public void sendPlantInterface(WorldObject object, Player player) {
    		player.getDialogueManager().startDialogue(new Dialogue() {
    
    			@Override
    			public void start() {
    				player.getInterfaceManager().sendInventoryInterfac  e(1081);
    			}
    
    			@Override
    			public void run(int interfaceId, int componentId) {
    				finish();
    				cureDisease(object, player, getCompByType(object) == componentId);
    			}
    
    			private int getCompByType(WorldObject object) {
    				int id = object.getId();
    				switch (id) {
    				case 40460:
    				case 40461:
    				case 40462:
    				case 40463:// done
    					return 3;
    				case 40464:
    				case 40486:
    				case 40487:
    				case 40488:// done
    					return 4;
    				case 40492:
    				case 40499:
    				case 40504:// done
    					return 5;
    				case 40505:
    				case 40534:
    				case 40532:
    				case 40533:// done
    					return 6;
    				}
    				return -1;
    			}
    
    			@Override
    			public void finish() {
    				if (player.getInterfaceManager().containsInventoryInt  er())
    					player.getInterfaceManager().closeInventoryInterfa  ce();
    			}
    		});
    	}
    
    	@Override
    	public boolean processObjectClick1(final WorldObject object) {
    		for (Entry<WorldTile, Integer> flower : flowers.entrySet()) {
    			if (object.getTile().matches(flower.getKey())) {
    				if (flower.getValue() == 3) {
    					sendPlantInterface(object, player);
    					return false;
    				}
    				if (flower.getValue() == 0) {
    					fertilisePatch(object, player);
    					return false;
    				}
    			}
    		}
    		switch (object.getId()) {
    		case 40432:
    		case 40433:
    		case 40434:
    		case 40435:
    		case 40436:
    		case 40437:
    			repairFence(player, object);
    			break;
    		case 40444:
    			takeLog(player, 1);
    			break;
    		case 40441:
    			emptyBin(object, player);
    			break;
    		case 40443:
    			depositWagon(player);
    			break;
    		}
    		return false;
    	}
    
    	private transient WorldTile binTile = new WorldTile(2114, 3951, 0);
    
    	public void spawnFilledBin(Player player) {
    		WorldObject bin = World.getObjectWithType(binTile, 10);
    		player.getVarsManager().sendVarBit(bin.getConfigBy  File(), 1);
    	}
    
    	public void emptyBin(WorldObject object, Player player) {
    		if (gathered == 2) {
    			player.sm("You can't empty the bin more than 2 times each round.");
    			return;
    		}
    		if (player.getInventory().getFreeSlots() < 10) {
    			player.sm("You need at least 10 inventory slots free to empty the bin.");
    			return;
    		}
    		player.getVarsManager().sendVarBit(object.getConfi  gByFile(), 0);
    		gathered++;
    		player.getInventory().addItem(20704, 10);
    		player.getLivid().addProduce(20);
    	}
    
    	private transient WorldTile fenceTile[] = { new WorldTile(2108, 3953, 0), new WorldTile(2116, 3953, 0),
    			new WorldTile(2118, 3953, 0), new WorldTile(2120, 3951, 0), new WorldTile(2120, 3946, 0),
    			new WorldTile(2120, 3945, 0) };
    
    	public void spawnBrokenFences() {
    		for (WorldTile tile : fenceTile) {
    			WorldObject object = World.getStandardWallObject(tile);
    			player.getVarsManager().sendVarBit(object.getConfi  gByFile(), 0);
    		}
    		for (int i = 0; i <= 1; i++) {
    			WorldTile randomTile = fenceTile[Utils.getRandom(fenceTile.length - 1)];
    			WorldObject fence = World.getStandardWallObject(randomTile);
    			player.getVarsManager().sendVarBit(fence.getConfig  ByFile(), 1);
    		}
    	}
    
    	/**
    	 * All patch tiles in order north-west to south-east
    	 */
    	private transient WorldTile patchTile[] = {
    			// first row
    			new WorldTile(2098, 3949, 0), new WorldTile(2100, 3949, 0), new WorldTile(2102, 3949, 0),
    			new WorldTile(2104, 3949, 0), new WorldTile(2106, 3949, 0),
    
    			// second row
    			new WorldTile(2098, 3949 - 3, 0), new WorldTile(2100, 3949 - 3, 0), new WorldTile(2102, 3949 - 3, 0),
    			new WorldTile(2104, 3949 - 3, 0), new WorldTile(2106, 3949 - 3, 0),
    
    			// third row
    			new WorldTile(2098, 3949 - 6, 0), new WorldTile(2100, 3949 - 6, 0), new WorldTile(2102, 3949 - 6, 0),
    			new WorldTile(2104, 3949 - 6, 0), new WorldTile(2106, 3949 - 6, 0) };
    
    	public void spawnPlants() {
    		flowers.clear();
    		for (WorldTile tile : patchTile) {
    			WorldObject livid = World.getStandardFloorObject(tile);
    			int stage = Utils.random(1, 3) == 1 ? DISEASED_STAGE : Utils.random(1, 4) == 1 ? EMPTY_STAGE : GROWN_STAGE;
    			flowers.put(tile, stage);
    			player.getVarsManager().sendVarBit(livid.getConfig  ByFile(), stage);
    		}
    	}
    
    	private transient HashMap<WorldTile, Integer> flowers = new HashMap<>();
    
    	@Override
    	public boolean processNPCClick3(NPC npc) {
    		if (npc.getId() == PAULINE)
    			spawnFilledBin(player);
    		return false;
    
    	}
    
    	@Override
    	public boolean processNPCClick2(NPC npc) {
    		if (npc.getId() == PAULINE)
    			LividStore.openInterface(player);
    		return false;
    
    	}
    
    	@Override
    	public boolean processNPCClick1(NPC npc) {
    		if (npc.getId() == PAULINE)
    			LividStore.openInterface(player);
    		return false;
    
    	}
    
    	@Override
    	public boolean processObjectClick2(final WorldObject object) {
    		if (object.getId() == 40444)
    			takeLog(player, 5);
    		return false;
    	}
    
    	@Override
    	public boolean logout() {
    		plantList.clear();
    		return false;
    	}
    
    	public static void sendPointsInterface(Player player) {
    		player.getInterfaceManager().sendTab(getOverlayId(  player), 3046);
    	}
    
    	public static int getOverlayId(Player player) {
    		return player.getInterfaceManager().isResizableScreen() ? 8 : 11;
    	}
    
    	@Override
    	public void moved() {
    		if (!player.getInterfaceManager().containsTab(getOver  layId(player))) {
    			sendPointsInterface(player);
    			LividFarm.updateProduce(player);
    		}
    	}
    
    	@Override
    	public void start() {
    		sendPointsInterface(player);
    		LividFarm.updateProduce(player);
    		ticks = 48;
    		player.sm("Livid farm minigame will start in 30 seconds.");
    	}
    
    	@Override
    	public boolean login() {
    		sendPointsInterface(player);
    		LividFarm.updateProduce(player);
    		ticks = 48;
    		player.sm("Livid farm minigame will start in 30 seconds.");
    		return false;
    	}
    
    	@Override
    	public void magicTeleported(int teleType) {
    		flowers.clear();
    		player.getControlerManager().forceStop();
    	}
    
    	@Override
    	public void process() {
    		if (flowerTick >= 60) {// 15 seconds
    			for (Entry<WorldTile, Integer> flower : flowers.entrySet()) {
    				if (flower.getValue() == FERTILISED_STAGE) {
    					WorldObject object = World.getStandardFloorObject(flower.getKey());
    					player.getVarsManager().sendVarBit(object.getConfi  gByFile(), GROWING_STAGE);
    				}
    			}
    		}
    		if (ticks >= 96) {
    			ticks = 0;
    			flowerTick = 0;
    			gathered = 0;
    			spawnPlants();
    			spawnBrokenFences();
    		}
    		flowerTick++;
    		ticks++;
    	}
    
    	@Override
    	public void forceClose() {
    		player.getInterfaceManager().closeTab(getOverlayId  (player));
    	}
    }
    Area for LividFarm
    Code:
    package com.rs.game.area;
    
    import com.rs.game.WorldTile;
    import com.rs.game.area.shapes.Polygon;
    
    public final class LividFarmArea extends Area {
    
    	@Override
    	public Area update() {
    		return this;
    	}
    
    	@Override
    	public String name() {
    		return "Livid Farm";
    	}
    
    	@Override
    	public Shape[] shapes() {
    		return new Shape[] { new Polygon(new WorldTile[] {
    
    				new WorldTile(2107, 3939, 0),
    
    				new WorldTile(2107, 3941, 0),
    
    				new WorldTile(2096, 3941, 0),
    
    				new WorldTile(2096, 3951, 0),
    
    				new WorldTile(2107, 3951, 0),
    
    				new WorldTile(2107, 3953, 0),
    
    				new WorldTile(2120, 3953, 0),
    
    				new WorldTile(2120, 3941, 0),
    
    				new WorldTile(2115, 3941, 0),
    
    				new WorldTile(2115, 3939, 0)}) };
    	}
    
    	@Override
    	public boolean member() {
    		return true;
    	}
    
    	@Override
    	public Environment environment() {
    		return Environment.NORMAL;
    	}
    
    }
    LividStore
    Code:
    package com.rs.game.minigames.lividfarm;
    
    import com.rs.cache.loaders.ItemDefinitions;
    import com.rs.game.World;
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    import com.rs.game.player.actions.skills.herblore.Herblor  e.Ingredients;
    import com.rs.utils.Utils;
    
    /**
     * @author -Andreas 21 feb. 2020 00:58:21
     *    @[Only registered and activated users can see links. ] source
     * 
     */
    
    public class LividStore {
    
    	private static Wish[] wishes = Wish.values();
    
    	public enum Wish {
    
    		LET_IT_RAIN_SEEDS(18000) {
    
    			@Override
    			public void process(Player player) {
    				int[] seeds = { 5321, 5280, 5106, 5323, 5286, 5285 };
    				for (int ids : seeds) {
    					World.updateGroundItem(new Item(ids, Utils.random(7, 11)), Utils.getRandomTile(player, 3), player,
    							60, 0);
    				}
    				removeProduce(player);
    				player.getDialogueManager().startDialogue("SimpleMessage",
    						"Your wish has come true.. <br>It's raining seeds!");
    			}
    		},
    
    		GIMMIE_HERBS(18000) {
    
    			@Override
    			public void process(Player player) {
    				if (player.getInventory().getFreeSlots() < 5) {
    					player.getDialogueManager().startDialogue("SimpleMessage",
    							"You need at least 5 inventory spaces free!");
    					return;
    				}
    				Item[] herbs = { new Item(214, 3), new Item(210, 3), new Item(216, 2), new Item(212, 2),
    						new Item(2486) };
    				for (Item item : herbs) {
    					player.getInventory().addItem(item);
    				}
    				removeProduce(player);
    				player.getDialogueManager().startDialogue("SimpleMessage",
    						"Your wish has come true.. <br>You recieved some herbs.");
    			}
    		},
    
    		VIAL_MY_HERBS(5500) {
    
    			Ingredients[] ingredients = Ingredients.values();
    
    			@Override
    			public void process(Player player) {
    				int i = 0;
    				for (Ingredients ingredient : ingredients) {
    					if (i >= 50)
    						break;
    					ItemDefinitions def = ItemDefinitions.getItemDefinitions(ingredient.getI  temId());
    					ItemDefinitions pot = ItemDefinitions.getItemDefinitions(ingredient.getR  ewards()[0]);
    					if (player.getInventory().containsOneItem(def.getId()  )) {
    						int amount = player.getInventory().getNumberOf(def.getId());
    						if (i + amount > 50)
    							amount = 50 - i;
    						i += amount;
    						player.getInventory().deleteItem(def.getId(), amount);
    						player.getInventory().addItem(pot.getId(), amount);
    					}
    					if (player.getInventory().containsOneItem(def.getCert  Id())) {
    						int amount = player.getInventory().getNumberOf(def.getCertId())  ;
    						if (i + amount > 50)
    							amount = 50 - i;
    						i += amount;
    						player.getInventory().deleteItem(def.getCertId(), amount);
    						player.getInventory().addItem(pot.getCertId(), amount);
    					}
    				}
    				if (i == 0) {
    					player.getDialogueManager().startDialogue("SimpleMessage",
    							"You don't have any cleaned herbs in your inventory.");
    				} else {
    					removeProduce(player);
    					player.getDialogueManager().startDialogue("SimpleMessage", "Your wish has come true.. <br>" + i
    							+ " of your cleaned herbs got converted into unfinished potions.");
    				}
    			}
    		},
    
    		TURN_LUNAR_LUMBER_INTO_RUNES(5500) {
    
    			@Override
    			public void process(Player player) {
    				// TODO
    			}
    		},
    
    		REDUCE_THE_FISH_I_BURN(18000) {
    
    			@Override
    			public void process(Player player) {
    				removeProduce(player);
    				player.getTemporaryAttributtes().put("LIVID_WISH_BURN", 1800000 + Utils.currentTimeMillis());
    				player.getDialogueManager().startDialogue("SimpleMessage",
    						"Your wish has come true.. <br>You are less likely to burn fish while cooking for 30 minutes.");
    			}
    		},
    
    		MORE_PLANKS_PLEASE(18000) {
    
    			@Override
    			public void process(Player player) {
    				removeProduce(player);
    				player.getTemporaryAttributtes().put("LIVID_WISH_PLANK", 1800000 + Utils.currentTimeMillis());
    				player.getDialogueManager().startDialogue("SimpleMessage",
    						"Your wish has come true.. <br>You now have a 1/10 chance to recieve an extra plank while using Plank make spell for 30 minutes.");
    			}
    		},
    
    		LET_IT_RAIN_AWESOME_SEED(55000) {
    
    			@Override
    			public void process(Player player) {
    				Item[] seeds = { new Item(5295, 4), new Item(5321, 4), new Item(5286, 6), new Item(5287, 2),
    						new Item(5288, 2), new Item(5313, 4) };
    				for (Item item : seeds) {
    					World.updateGroundItem(item, Utils.getRandomTile(player, 3), player, 60, 0);
    				}
    				removeProduce(player);
    				player.getDialogueManager().startDialogue("SimpleMessage",
    						"Your wish has come true.. <br>It's raining awesome seeds!");
    			}
    		},
    
    		ID_LIKE_A_NEW_PATCH(-1) {
    
    			@Override
    			public void process(Player player) {
    				// TODO
    			}
    		},
    
    		GIVE_ME_AN_ARCANE_CAPACITOR(18000) {
    
    			@Override
    			public void process(Player player) {
    				if (!player.getInventory().hasFreeSlots()) {
    					player.getDialogueManager().startDialogue("SimpleMessage", "You don't have any inventory space.");
    					return;
    				}
    				removeProduce(player);
    				player.getInventory().addItem(21513, 1);
    				player.getDialogueManager().startDialogue("SimpleMessage",
    						"Your wish has come true.. <br>You have been given an Arcane capacitor!");
    			}
    		},
    
    		PROTECT_A_PATCH_FOR_ME(-1) {
    
    			@Override
    			public void process(Player player) {
    				// TODO
    			}
    		};
    
    		private int produce;
    
    		public abstract void process(Player player);
    
    		private Wish(int produce) {
    			this.produce = produce;
    		}
    
    		public void removeProduce(Player player) {
    			player.getLivid().removeProduce(produce);
    		}
    
    		public int getProduce() {
    			return produce;
    		}
    
    		public static Wish getComponentById(int i) {
    			int value = (i >= 525 ? ((i - 470) / 9) : (i - 335) / 9);
    			for (Wish s : wishes) {
    				if (i == 554 || i == 395 || i == 387)
    					continue;
    				if (i == 565)
    					return Wish.PROTECT_A_PATCH_FOR_ME;
    				if (s.ordinal() == value)
    					return s;
    			}
    			return null;
    		}
    	}
    
    	private static Spell[] spells = Spell.values();
    
    	public enum Spell {
    
    		SOUTH_FALADOR_TELEPORT(69840, 263),
    
    		REPAIR_RUNE_POUCH(139760, 272),
    
    		TELEPORT_TO_NORTH_ARDOUGNE(227120, 281),
    
    		REMOVE_FARMING(314480, 290),
    
    		SPIRITUALISE_FOOD(401840, 299),
    
    		MAKE_LEATHER(489200, 308),
    
    		DISRUPTION_SHIELD(576560, 317),
    
    		VENGEANCE_GROUP(663920, 326),
    
    		TELEPORT_TO_TROLLHEIM(806400, 467),
    
    		TELEPORT_GROUP_TO_TROLLHEIM(806400, 477),
    
    		BORROWED_POWER(850000, 487);
    
    		private int produce;
    		private int componentId;
    
    		private Spell(int produce, int componentId) {
    			this.produce = produce;
    			this.componentId = componentId;
    		}
    
    		public static Spell getComponentById(int i) {
    			for (Spell s : spells) {
    				if (i == s.getComponent()) {
    					return s;
    				}
    			}
    			return null;
    		}
    
    		public int getComponent() {
    			return componentId;
    		}
    
    		public int getProduce() {
    			return produce;
    		}
    
    		public String getName() {
    			return Utils.formatString(name());
    		}
    	}
    
    	public static void handleButtons(Player player, int id) {
    		player.getInterfaceManager().closeChatBoxInterface  ();
    		Wish wish = Wish.getComponentById(id);
    		if (wish != null) {
    			makeWish(player, wish);
    			return;
    		}
    		Spell spell = Spell.getComponentById(id);
    		if (spell != null) {
    			learnSpell(player, spell);
    			return;
    		}
    	}
    
    	public static void openInterface(Player player) {
    		player.getInterfaceManager().sendInterface(1083);
    	}
    
    	public static void learnSpell(Player player, Spell spell) {
    		if (spell.ordinal() > player.getLivid().getSpellAmount()) {
    			player.getPackets().sendGameMessage("You must learn all the prior spells before learning this.");
    			return;
    		}
    		if (player.getLivid().getProduce() < spell.getProduce()) {
    			player.getPackets().sendGameMessage("You need at least " + Utils.getFormattedNumber(spell.getProduce(), ',')
    					+ " produce to learn this spell.");
    			return;
    		}
    		player.getInterfaceManager().closeScreenInterface(  );
    		player.getDialogueManager().startDialogue("PaulinePolaris", 13619, spell);
    	}
    
    	public static void makeWish(Player player, Wish wish) {
    		if (!player.getLivid().getSpellsLearned().contains(Sp  ell.BORROWED_POWER))// checks if all spells unlocked or not
    			return;// serversided safety check
    		if (player.getLivid().getProduce() < wish.getProduce()) {
    			player.getPackets().sendGameMessage("You need at least " + Utils.getFormattedNumber(wish.getProduce(), ',')
    					+ " produce to wish for this.");
    			return;
    		}
    		player.getDialogueManager().startDialogue("PaulinePolaris", 13619, wish);
    	}
    }
    Dialogue(not finished yet)
    Code:
    package com.rs.game.player.dialogues.npcs;
    
    import com.rs.cache.loaders.NPCDefinitions;
    import com.rs.cores.CoresManager;
    import com.rs.game.minigames.lividfarm.LividStore;
    import com.rs.game.minigames.lividfarm.LividStore.Spell;
    import com.rs.game.minigames.lividfarm.LividStore.Wish;
    import com.rs.game.player.content.FadingScreen;
    import com.rs.game.player.dialogues.Dialogue;
    import com.rs.utils.Logger;
    
    public class PaulinePolaris extends Dialogue {
    
    	private int npcId;
    	private Spell spell;
    	private Wish wish;
    
    	@Override
    	public void start() {
    		npcId = (Integer) parameters[0];
    		if (parameters.length >= 2) {
    			if (parameters[1] instanceof Wish) {
    				wish = (Wish) parameters[1];
    			} else
    				spell = (Spell) parameters[1];
    		}
    		if (spell != null) {
    			stage = 100;
    			sendEntityDialogue(SEND_1_TEXT_CHAT,
    					new String[] { NPCDefinitions.getNPCDefinitions(npcId).name,
    							"You've gone far in building up this farm! I'll teach you<br>about the " + spell.getName()
    									+ " spell." },
    					IS_NPC, npcId, 9827);
    		} else if (wish != null) {
    			stage = 125;
    			sendEntityDialogue(SEND_1_TEXT_CHAT,
    					new String[] { NPCDefinitions.getNPCDefinitions(npcId).name, "I'll make your wish come true.." },
    					IS_NPC, npcId, 9827);
    		} else {
    			sendEntityDialogue(SEND_1_TEXT_CHAT,
    					new String[] { NPCDefinitions.getNPCDefinitions(npcId).name, "'Hello tall person." }, IS_NPC, npcId,
    					9827);
    		}
    
    	}
    
    	@Override
    	public void run(int interfaceId, int componentId) {
    		if (stage == 100) {
    			player.getInterfaceManager().closeChatBoxInterface  ();
    			player.getInterfaceManager().closeScreenInterface(  );
    			final long time = FadingScreen.fade(player);
    			CoresManager.slowExecutor.execute(new Runnable() {
    				@Override
    				public void run() {
    					try {
    						FadingScreen.unfade(player, time, new Runnable() {
    							@Override
    							public void run() {
    								stage = 101;
    								sendDialogue("Congratulations! You've learned how to cast the " + spell.getName()
    										+ " spell.");
    								player.getLivid().getSpellsLearned().add(spell);
    								player.getLivid().addSpellAmount();
    								if (spell == Spell.BORROWED_POWER)
    									player.getLivid().removeProduce(Spell.BORROWED_POW  ER.getProduce());
    							}
    						});
    					} catch (Throwable e) {
    						Logger.handle(e);
    					}
    				}
    			});
    		} else if (stage == 125) {
    			player.getInterfaceManager().closeChatBoxInterface  ();
    			player.getInterfaceManager().closeScreenInterface(  );
    			final long time = FadingScreen.fade(player);
    			CoresManager.slowExecutor.execute(new Runnable() {
    				@Override
    				public void run() {
    					try {
    						FadingScreen.unfade(player, time, new Runnable() {
    							@Override
    							public void run() {
    								stage = -2;
    								wish.process(player);
    							}
    						});
    					} catch (Throwable e) {
    						Logger.handle(e);
    					}
    				}
    			});
    		} else if (stage == 101) {
    			LividStore.openInterface(player);
    			end();
    		} else if (stage == -2) {
    			end();
    		} else
    			end();
    
    	}
    
    	@Override
    	public void finish() {
    		// TODO Auto-generated method stub
    
    	}
    
    }
    AvalonPK Developer
    Reply With Quote  
     

  2. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Livid farm interface
    By Shnek in forum Help
    Replies: 3
    Last Post: 06-07-2017, 06:32 PM
  2. Replies: 110
    Last Post: 04-27-2016, 01:20 AM
  3. Livid Farming 718
    By .NF. in forum Requests
    Replies: 12
    Last Post: 11-22-2015, 06:36 PM
  4. [718] Farming Release
    By _jordan in forum Snippets
    Replies: 50
    Last Post: 04-05-2014, 10:29 PM
  5. Livid Farm botting
    By Timurazu921 in forum Chat
    Replies: 4
    Last Post: 10-27-2012, 02:51 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •