Thread: Warrior Guild

Results 1 to 5 of 5
  1. #1 Warrior Guild 
    Officially Retired


    Join Date
    Oct 2007
    Age
    30
    Posts
    5,454
    Thanks given
    558
    Thanks received
    122
    Rep Power
    1364
    When i use my full rune on object it work fine. When i kill the rune guy npc and try to use my full rune on object it say "You already have armor spawned!". But i kill it already.

    Code:
    package server.model.minigames;
    
    import server.model.players.Client;
    import server.event.Event;
    import server.event.EventManager;
    import server.event.EventContainer;
    import server.Server;
    /**
     * @author Brandyn
     */
    public class WarriorsGuild {
    	
    	public WarriorsGuild() {
    		//TO DO
    	}
    	
    	private int xCoord, yCoord;
    
    	private boolean spawned;
    	
    	public void setSpawned(Client c, boolean spawned) {
    		c.spawned = spawned;
    	}
    
    	private final int[][] ARMORREQUIRED = {{1075, 1117, 1155, 4278, 20, 5, 30, 100}, {1067, 1115, 1153, 4279, 30, 7, 40, 100}, {1069, 1119, 1157, 4280, 40, 10, 60, 100}, {1077, 1125, 1165, 4281, 50, 15, 70, 100},
    									{1071, 1121, 1159, 4282, 60, 15, 80, 100}, {1091, 1123, 1161, 4283, 80, 17, 90, 10}, {1079, 1127, 1163, 4284, 100, 20, 100, 100}};
    	
    	/**
    	 * Handles which armor through ItemOnObject
    	 * @param itemId The item id used
    	 * @param X The object X-Coordinate
    	 * @param Y The object Y-Coordinate
    	 */
    	public void handleArmor(Client c, int itemId, int X, int Y) {
    		if(!spawned) {
    			this.xCoord = X;
    			this.yCoord = Y;
    			for(int i = 0; i < ARMORREQUIRED.length; i++) {
    				for(int f = 0; f < ARMORREQUIRED[0].length; f++) {
    					if(itemId == ARMORREQUIRED[i][f]) {
    						if(hasItem(c, ARMORREQUIRED[i][0], true) && hasItem(c, ARMORREQUIRED[i][1], true) && hasItem(c, ARMORREQUIRED[i][2], true)) {
    							animateArmor(c, new int[] {ARMORREQUIRED[i][0], ARMORREQUIRED[i][1], ARMORREQUIRED[i][2]}, ARMORREQUIRED[i][3], ARMORREQUIRED[i][4], ARMORREQUIRED[i][5], ARMORREQUIRED[i][6], ARMORREQUIRED[i][7]);
    						}
    					}
    				}
    			}
    		} else {
    			c.sendMessage("You already have armor spawned!");
    		}
    	}
    	
    	/**
    	 * Checks if the player has an item in his inventory and/or equipment.
    	 * @param itemId The item id needed
    	 * @param inventory If the item needs to be in inventory, or in equipment
    	 * @return returns if it has the item.
    	 */
    	private boolean hasItem(Client c, int itemId, boolean inventory) {
    		return inventory ? c.getItems().playerHasItem(itemId) : c.getItems().playerHasItem(itemId) || c.playerEquipment[5] == itemId;
    	}
    	
    	/**
    	 * Animates the armor, deletes items, and walks 3 steps back.
    	 *
    	 */
    	private void animateArmor(Client c, int[] usedArmor, int npcId, int hitPoints, int maxHit, int attack, int defence) {
    		c.getPA().walkTo(0, 3);
    		for(int i = 0; i < 3; i++) {
    			c.getItems().deleteItem(usedArmor[i], 1);
    		}
    		spawned = true;
    		Server.npcHandler.spawnNpc(c, npcId, xCoord, yCoord, 0, 0, hitPoints, maxHit, attack, defence, true, true);
    	}
    	
    	private final String[][] DEFENDER = {{"8850", "Rune"}, {"8849", "Adamant"}, {"8848", "Mithril"}, {"8847", "Black"}, {"8846", "Steel"}, {"8845", "Iron"}, {"8844", "Bronze"}};
    	
    	/**
    	 * Gets the cyclops' drop itemid.
    	 */
    	public int getCyclopsDrop(Client c) {
    		if(!c.kamfreenaDone)
    			return Integer.parseInt(DEFENDER[6][0]);
    		for(int i = 0; i < DEFENDER.length; i++) {
    			try {
    				if(hasItem(c, Integer.parseInt(DEFENDER[i][0]), false))
    					return Integer.parseInt(DEFENDER[i - 1][0]);
    			} catch(Exception e) {
    				return Integer.parseInt(DEFENDER[0][0]);
    			}
    		}
    		return Integer.parseInt(DEFENDER[6][0]);
    	}
    	
    	/**
    	 * @return Returns the defender dropped in text.
    	 */
    	public String getCyclopsDrop126(Client c) {
    		for(int i = 0; i < DEFENDER.length; i++) {
    			if(Integer.parseInt(DEFENDER[i][0]) == getCyclopsDrop(c)) {
    				return DEFENDER[i][1];
    			}
    		}
    		return DEFENDER[0][1];
    	}
    	
    	/**
    	 * Handles Kamfreena's Dialogue
    	 */
    	public void handleKamfreena(Client c, boolean door) {
    		if(door) {
    			if(!c.getItems().playerHasItem(8851, 100)) {
    				c.sendMessage("You need 100 tokens to go in!");
    				return;
    			}
    			if(c.absX < 2848) {
    				if(!c.kamfreenaDone)
    					c.getDH().sendDialogues(45, 4289);
    				c.getPA().movePlayer(2847, 3541, 2);
    				executeCyclopsTimer(c);
    			} else {
    				c.inCyclops = false;
    				c.getPA().movePlayer(2846, 3541, 2);
    				c.kamfreenaDone = false;
    			}
    		} else {
    			c.kamfreenaDone = true;
    			c.getDH().sendDialogues(47, 4289);
    		}
    	}
    	
    	/**
    	 * 60 Second timer removing 20 tokens.
    	 * @return returns the timer event
    	 */
    	private Event cyclopsTimer(final Client c) {
    		return new Event() {
    			public void execute(EventContainer e) {
    				if(c.getItems().playerHasItem(8851, 20) && c.inCyclops) {
    					c.sendMessage("You lose 20 tokens.");
    					c.getItems().deleteItem2(8851, 20);
    				} 
    				if(!c.getItems().playerHasItem(8851, 20)) {
    					c.inCyclops = false;
    					c.sendMessage("You have ran out of tokens!");
    					c.getPA().movePlayer(2846, 3541, 2);
    					e.stop();
    				}
    			}
    		};
    	}
    	
    	/**
    	 * Executes the timed token removal. (60 seconds / 1 minute)
    	 */
    	private void executeCyclopsTimer(Client c) {
    		c.inCyclops = true;
    		EventManager.getSingleton().addEvent(cyclopsTimer(c), 60000);
    	}
    }
    Reply With Quote  
     

  2. #2  
    Donator


    Join Date
    Jul 2009
    Posts
    1,875
    Thanks given
    119
    Thanks received
    233
    Rep Power
    408
    theres no check for after the armor has been killed?
    Reply With Quote  
     

  3. #3  
    Officially Retired


    Join Date
    Oct 2007
    Age
    30
    Posts
    5,454
    Thanks given
    558
    Thanks received
    122
    Rep Power
    1364
    when i kill the npc..and i try to use my rune again on object it say "You already have armor spawned!". But the npc is dead already.
    Reply With Quote  
     

  4. #4  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    You've never set spawned to false
    Reply With Quote  
     

  5. #5  
    Donator

    Arithium's Avatar
    Join Date
    May 2010
    Age
    31
    Posts
    4,721
    Thanks given
    199
    Thanks received
    1,256
    Rep Power
    1114
    i would assume u can do where it declares the magepoints in npchandler.java u could do something like
    Code:
    if (npcs[i].npcType = w/e && npcs[i].isDead) {
    npcs[i].spawnedBy = 0;
    }
    Reply With Quote  
     


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. Blk Warrior Guild Bug
    By l0ck in forum Help
    Replies: 3
    Last Post: 12-06-2010, 10:34 PM
  2. Warrior Guild
    By Cubsmiles in forum Show-off
    Replies: 13
    Last Post: 08-08-2010, 06:08 PM
  3. 474 Warrior guild
    By SWAT in forum Downloads
    Replies: 112
    Last Post: 06-08-2010, 12:42 AM
  4. Warrior guild
    By Oh my gawd in forum Show-off
    Replies: 13
    Last Post: 06-07-2009, 11:17 PM
  5. Warrior Guild
    By atrum in forum Requests
    Replies: 0
    Last Post: 08-26-2008, 03:11 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •