Thread: Warriors guild with cyclops and npc spawning

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 Warriors guild with cyclops and npc spawning 
    Banned
    Join Date
    Jan 2014
    Posts
    596
    Thanks given
    91
    Thanks received
    60
    Discord
    View profile
    Rep Power
    0
    Well i know it's not the best but im just learning

    but i think it's pretty good for me

    First make a new class "WarriorsGuild"

    and add this in it

    Code:
    package server.model.minigames;
    
    import java.util.Random;
    
    import server.Server;
    import server.event.CycleEvent;
    import server.event.CycleEventContainer;
    import server.event.CycleEventHandler;
    import server.model.players.Client;
    
    /**
     * 
     * Rep me on rune-server if it helped you :) name = Emrage
     * @author Emre
     *
     */
    public class WarriorsGuild {
    
    	public static final Random r = new Random();
    	public static final int CyclopsId = 6270;
    
    	/**
    	 * arrays
    	 */
    	private static final int[] bronze = { 1075, 1117, 1155, -1};
    	private static final int[] iron = { 1067, 1115, 1153, -1 };
    	private static final int[] steel = { 1069, 1119, 1157, -1 };
    	private static final int[] black = { 1077, 1125, 1165, -1 };
    	private static final int[] mithril = { 1071, 1121, 1159, -1 };
    	private static final int[] adamant = { 1073, 1123, 1161, -1 };
    	private static final int[] rune = { 1079, 1127, 1163, -1 };
    	/**
    	 * Enum
    	 *
    	 *
    	 */
    	public enum spawnNpc {
    		BRONZE(bronze),
    		IRON(iron),
    		STEEL(steel),
    		BLACK(black),
    		MITHRIL(mithril),
    		ADAMANT(adamant),
    		RUNE(rune);
    
    		private int[] itemId;
    		spawnNpc(int[] requiredItems) {
    			this.itemId = requiredItems;
    		}
    		public int[] getItemId() {
    			return itemId;
    		}
    
    		public static spawnNpc forId(int id) {
    			for(spawnNpc s : values()) {
    				for(int i : s.itemId) {
    					if(i == id) {
    						return s;
    					}
    				}
    			}
    			return null;
    		}
    	}
    	/**
    	 * 
    	 * For players that dont have tokens left
    	 */
    	public static void noTokens(Client c) {
    		if(c.inCY())
    			if(c.getItems().playerHasItem(8851, 0)) {
    				c.getPA().movePlayer(2846, 3541, 2);
    			}
    	}
    	/**
    	 * 
    	 * If the player logs out this happens
    	 */
    	public static void logOut(Client c) {
    		if(c.inCY());
    		c.getPA().movePlayer(2846, 3541, 2);
    	}
    	/**
    	 * 
    	 * Handling stuff if player is in cyclops area
    	 * @param c
    	 */
    	public static void inCyclops(Client c) {
    		c.getPA().movePlayer(2848, 3540, 2);
    		//System.out.println("works");
    		CyclopsDrops(c);
    		loseTokens(c);
    		noTokens(c);
    	}
    	/**
    	 * 
    	 * For losing tokens
    	 * @param c
    	 */
    	public static void loseTokens(Client c) {
    		CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    			public void execute(CycleEventContainer container) {
    				if(c.inCY()) {
    					c.getItems().deleteItem(8851, c.getItems().getItemSlot(8851), 30);
    					//System.out.println(c.playerName + "Lost 100 tokens");
    				}
    			}
    			@Override
    			public void onFinish() {
    			}
    		},500);
    	}
    	/**
    	 * 
    	 * Cyclops drops
    	 */
    	public static void CyclopsDrops(Client c) {
    		if(c.inCY()) {
    			if(c.WarriorsGuild == 0) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/10.0) {
    					Server.itemHandler.createGroundItem(c, 8844, c.getX()+1, c.getY(), 1, c.playerId);
    					c.WarriorsGuild = 1;
    				}
    			}
    			if(c.WarriorsGuild == 1) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/12.0) {
    					Server.itemHandler.createGroundItem(c, 8845, c.getX()+1, c.getY(), 1, c.playerId);
    					c.WarriorsGuild = 2;
    				}
    			}
    			if(c.WarriorsGuild == 2) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/14.0) {
    					Server.itemHandler.createGroundItem(c, 8846, c.getX()+1, c.getY(), 1, c.playerId);
    					c.WarriorsGuild = 3;
    				}
    			}
    			if(c.WarriorsGuild == 3) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/14.0) {
    					Server.itemHandler.createGroundItem(c, 8847, c.getX()+1, c.getY(), 1, c.playerId);
    					c.WarriorsGuild = 4;
    				}
    			}
    			if(c.WarriorsGuild == 4) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/14.0) {
    					Server.itemHandler.createGroundItem(c, 8848, c.getX()+1, c.getY(), 1, c.playerId);
    					c.WarriorsGuild = 5;
    				}
    			}
    			if(c.WarriorsGuild == 5) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/14.0) {
    					Server.itemHandler.createGroundItem(c, 8849, c.getX()+1, c.getY(), 1, c.playerId);
    					c.WarriorsGuild = 6;
    				}
    			}
    			if(c.WarriorsGuild == 6) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/14.0) {
    					Server.itemHandler.createGroundItem(c, 8850, c.getX()+1, c.getY(), 1, c.playerId);
    					c.WarriorsGuild = 7;
    				}
    			}
    			if(c.WarriorsGuild >= 7) {
    				double chance = r.nextDouble();
    				if(chance < 1.0/18.0) {
    					Server.itemHandler.createGroundItem(c, 20072, c.getX()+1, c.getY(), 1, c.playerId);
    				}
    			}
    		}
    	}
    	/**
    	 * Entering the place
    	 * @param c
    	 */
    	public static void isEntering(Client c) {
    		if(canEnter(c)) {
    			c.getDH().sendOption2("I wanna go in the warriors guild", "No thank you");;
    			c.dialogueAction = 1015;
    		}
    	}
    	/**
    	 * 
    	 * Checking of the player has the item
    	 * @param c
    	 * @return
    	 */
    	public static boolean canEnter(Client c) {
    		if(!c.getItems().playerHasItem(8851, 100)) {
    			c.sendMessage("You dont have enough tokens. you need 100 tokens");
    			return false;
    		}
    		return true;
    	}
    	/**
    	 * 
    	 * Checking of the player has the right item
    	 * @return
    	 */
    	public static boolean hasItem(Client c, int[] ids) {
    		for(int id : ids) {
    			if(!c.getItems().playerHasItem(id)) {
    				c.sendMessage("You dont have the right items");
    				return false;
    			}
    		}
    		return true;
    	}
    	/**
    	 * 
    	 * Method for spawning them
    	 * @param itemId 
    	 */
    	public static void NpcSpawning(Client c, int itemId) {
    		spawnNpc s = spawnNpc.forId(itemId);
    		if(s != null) {
    			if(hasItem(c, s.getItemId())) {
    				spawningNpc(c,s);
    			}
    		} else {
    			c.sendMessage("you can't use this item");
    		}
    	}
    	/**
    	 * 
    	 * Checking to spawn the right npc and spawning them
    	 */
    	public static void spawningNpc(Client c, spawnNpc s) {
    		switch(s) {
    		case BRONZE:
    			Server.npcHandler.spawnNpc(c, 4278,
    					c.getX(), c.getY() +1, 0, 0, 20, 10, 100, 100, true, true);
    			break;
    
    		case IRON:
    			Server.npcHandler.spawnNpc(c, 4279,
    					c.getX(), c.getY() +1, 0, 0, 30, 12, 120, 100, true, true);
    			break;
    
    		case STEEL:
    			Server.npcHandler.spawnNpc(c, 4280,
    					c.getX(), c.getY() +1, 0, 0, 40, 14, 140, 100, true, true);
    			break;
    		case BLACK:
    			Server.npcHandler.spawnNpc(c, 4281,
    					c.getX(), c.getY() +1, 0, 0, 50, 16, 145, 105, true, true);
    			break;
    		case MITHRIL:
    			Server.npcHandler.spawnNpc(c, 4282,
    					c.getX(), c.getY() +1, 0, 0, 55, 18, 155, 115, true, true);
    			break;
    		case ADAMANT:
    			Server.npcHandler.spawnNpc(c, 4283,
    					c.getX(), c.getY() +1, 0, 0, 60, 20, 160, 120, true, true);
    			break;
    		case RUNE:
    			Server.npcHandler.spawnNpc(c, 4284,
    					c.getX(), c.getY() +1, 0, 0, 70, 25, 180, 125, true, true);
    			break;
    		}
    		for(int i : s.getItemId())
    			c.getItems().deleteItem(i, c.getItems().getItemSlot(i), 1);
    		//c-npc-x-y-h-walking-hp-max-atk-def-agressive-headicon
    	}
    }
    You could get a error at onFishish change onFinish to whatever is in your cycleevent class could be onStop or Stop

    now in actionhandler.java

    under firstclicknpc add

    Code:
    case 4289:
    			WarriorsGuild.isEntering(c);
    			break;
    now in useItem.java add

    Code:
    case 15621:
    			WarriorsGuild.NpcSpawning(c, itemId);
    			break;
    not sure of that is the right object id

    now in player.java add

    Code:
    public int WarriorsGuild;
    and now again in player.java look for inWild()

    and above or under that add

    Code:
    public boolean inCY() {
    		if(absX >= 2847 && absX <= 2876 && absY >= 3534 && absY <= 3556 || absX >= 2838 && absX <= 2847 && absY >= 3543 && absY <= 3556 && heightLevel == 2) {
    			return true;
    		}
    		return false;
    	}
    now in playersave.java look for pc-points or something and under that add this

    Code:
    } else if (token.equals("Warriors-Guild")) {
    p.WarriorsGuild = Integer.parseInt(token2);
    again look for pc-points and add this under it

    Code:
     characterfile.write("Warriors-Guild = ", 0, 12);
                characterfile.write(Integer.toString(p.WarriorsGuild), 0, Integer.toString(p.WarriorsGuild).length());
                characterfile.newLine();
    if pc-points doesn't exist look for something similar like this

    now in clickingbuttons under case 9157 add:

    Code:
    } else if (c.dialogueAction == 1015) {
    	WarriorsGuild.inCyclops(c);
    idk why but under case 9157 only } else if works i tried everything

    now in case 9158

    Code:
    if(c.dialogueAction == 1015) {
    	c.getPA().removeAllWindows();
    	break;
    }
    now in client.java under the logout method

    Code:
    if(inCY()) {
    server.model.minigames.WarriorsGuild.logOut(this);
    }
    now in npchandler.java under the dropItem method add this

    Code:
    if(npcs[i].npcType == 6270) {
    WarriorsGuild.CyclopsDrops(c);
    }
    now look for you dare to disturb me and under that add

    Code:
    int[] animatedArmor = {4278, 4279, 4280, 4281, 4282, 4283, 4284};
    				for(int z = 0; z < animatedArmor.length; z++) {
    					if (newNPC.npcType == animatedArmor[z]) {
    						newNPC.forceChat("I'M ALIVE!");
    					}
    				}
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Banned
    Join Date
    Jan 2014
    Posts
    596
    Thanks given
    91
    Thanks received
    60
    Discord
    View profile
    Rep Power
    0
    Reserverd for editing stuff because when i edit it has to be approved


    edit 1:

    dont forget to import

    Code:
    import server.model.minigames.WarriorsGuild;
    edit 2:

    add this in npcconstants.cfg

    Code:
    4278	1075	1117	1155
    4279	1067	1115	1153
    4280	1069	1119	1157
    4281	1077	1125	1165
    4282	1071	1121	1159
    4283	1091	1123	1161
    4284	1079	1127	1163
    this in spawn-config

    Code:
    spawn = 6270	2856	3551	2	1	20	120	100	
    spawn = 6270	2845	3446	2	1	20	120	100	
    spawn = 6270	2844	3551	2	1	20	120	100	
    spawn = 6270	2857	3546	2	1	20	120	100	
    spawn = 6270	2858	3540	2	1	20	120	100	
    spawn = 6270	2853	3540	2	1	20	120	100	
    spawn = 6270	2871	3550	2	1	20	120	100	
    spawn = 6270	2871	3542	2	1	20	120	100	
    spawn = 4289	2846	3539	2	0	0	0	0
    Reply With Quote  
     

  4. #3  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    25
    Posts
    4,432
    Thanks given
    892
    Thanks received
    1,525
    Rep Power
    3228
    Can be done a lot better, and you could have used enumeration for something like this.

    Thanks though, hopefully you learned something.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #4  
    Banned

    Join Date
    Jun 2013
    Posts
    939
    Thanks given
    462
    Thanks received
    171
    Rep Power
    0
    as stated above code be done better but thanks for contribution
    Reply With Quote  
     

  6. #5  
    Donator

    Join Date
    Feb 2013
    Posts
    1,674
    Thanks given
    479
    Thanks received
    244
    Rep Power
    29
    As stated twice above, can be done better (as we discussed on Skype).
    I am glad you're learning though.
    Reply With Quote  
     

  7. #6  
    Banned
    Join Date
    Jan 2014
    Posts
    596
    Thanks given
    91
    Thanks received
    60
    Discord
    View profile
    Rep Power
    0
    Quote Originally Posted by Ludwig View Post
    As stated twice above, can be done better (as we discussed on Skype).
    I am glad you're learning though.
    everyone from the skype group has stated it lol
    Reply With Quote  
     

  8. #7  
    Registered Member
    Join Date
    Feb 2014
    Posts
    209
    Thanks given
    20
    Thanks received
    6
    Rep Power
    11
    OMG NOOO WHY DID YOU RELEASE THIS
    joking
    Reply With Quote  
     

  9. #8  
    Banned
    Join Date
    Jan 2014
    Posts
    596
    Thanks given
    91
    Thanks received
    60
    Discord
    View profile
    Rep Power
    0
    Quote Originally Posted by distryct View Post
    OMG NOOO WHY DID YOU RELEASE THIS
    joking
    lol you know it's pretty shit
    Reply With Quote  
     

  10. #9  
    Banned
    Join Date
    Jan 2014
    Posts
    596
    Thanks given
    91
    Thanks received
    60
    Discord
    View profile
    Rep Power
    0
    why is no one hating like normally? lol
    Reply With Quote  
     

  11. #10  
    Banned Market Banned Market Banned


    Join Date
    Jan 2011
    Age
    23
    Posts
    3,115
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Quote Originally Posted by Emrage View Post
    why is no one hating like normally? lol
    looks ugly
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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. Replies: 5
    Last Post: 10-23-2012, 07:24 AM
  2. Replies: 2
    Last Post: 06-14-2011, 05:22 PM
  3. Coords and NPC spawns
    By D Dox in forum Requests
    Replies: 0
    Last Post: 04-14-2011, 02:44 PM
  4. Help with projectiles and npcs spawning npcs.
    By arr0wtohell in forum Help
    Replies: 7
    Last Post: 03-15-2010, 05:29 PM
  5. [508]Warrior guild npc spawns
    By Proffesor Oak in forum Configuration
    Replies: 2
    Last Post: 05-14-2009, 12:55 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
  •