Thread: Weird object/thieving bug?

Results 1 to 9 of 9
  1. #1 Weird object/thieving bug? 
    Kanketsu
    JacobiYounger's Avatar
    Join Date
    Aug 2009
    Posts
    723
    Thanks given
    49
    Thanks received
    31
    Rep Power
    31
    For some reason when I try and call my thieving class for an object it doesn't work at all...

    Actionhandler.java
    Code:
    case 2561:
    	Thieving.stealFromStall(c, 995, 5000, 16, 5, objectType,obX,obY,2);
    	break;
    Thieving.java

    Code:
    package server.content.skills;
    
    import server.Server;
    import core.util.Misc;
    import server.game.npcs.*;
    import server.game.players.Client;
    import server.game.players.*;
    import server.event.*;
    import server.*;
     
    public class Thieving {
    
    	
    	private static final int SKILLING_XP = 100;
    	public static final int THIEVING_XP = SKILLING_XP;
    	
    	public static void stealFromStall(final Client c, final int id, int amount, int xp, int level, final int i, final int x, final int y, final int face) {
    	/*	if (System.currentTimeMillis() - c.lastThieve < 2500)
    			return;
    		if(c.underAttackBy > 0 || c.underAttackBy2 > 0) {
    			c.sendMessage("You can't steal from a stall while in combat!");
    			return;	
    		}*/
    		//if (c.playerLevel[c.playerThieving] >= level) {
    			//if (c.getItems().addItem(id,amount)) {
    				c.startAnimation(832);
    				c.getPA().addSkillXP(xp * THIEVING_XP, c.playerThieving);
    				c.lastThieve = System.currentTimeMillis();
    				c.sendMessage("You steal some coins.");
    				Server.objectHandler.createAnObject(c, 634, x, y, face);
    				CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    					@Override
    					public void execute(CycleEventContainer container) {
    						Server.objectHandler.createAnObject(c, i, x, y, face);
    						container.stop();
    					}
    					@Override
    					public void stop() {
    
    					}
    				}, getRespawnTime(c, i));
    			//}
    		//} else {
    		//	c.sendMessage("You must have a thieving level of " + level + " to thieve from this stall.");
    		//}
    	}
    
    	private static int getRespawnTime(Client c, int i) {
    		switch (i) {
    			case 2561: return 4;	//BAKER
    			case 2560: return 8;	//SILK
    			case 7053: return 15;	//SEED
    			case 2563: return 22;	//FUR
    			case 2565: return 30;	//SILVER
    			case 2564: return 50;	//SPICE
    			case 2562: return 50;	//GEM
    			case 14011: return 5;	//JUG
    			default: return 5;
    		}
    	}
    	}
    Reply With Quote  
     

  2. #2  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    What happens when you click it.
    Reply With Quote  
     

  3. #3  
    Registered Member
    hacker's Avatar
    Join Date
    Jun 2013
    Posts
    1,409
    Thanks given
    576
    Thanks received
    580
    Rep Power
    5000
    Quote Originally Posted by JacobiYounger View Post
    For some reason when I try and call my thieving class for an object it doesn't work at all...

    Actionhandler.java
    Code:
    case 2561:
    	Thieving.stealFromStall(c, 995, 5000, 16, 5, objectType,obX,obY,2);
    	break;
    Thieving.java

    Code:
    package server.content.skills;
    
    import server.Server;
    import core.util.Misc;
    import server.game.npcs.*;
    import server.game.players.Client;
    import server.game.players.*;
    import server.event.*;
    import server.*;
     
    public class Thieving {
    
    	
    	private static final int SKILLING_XP = 100;
    	public static final int THIEVING_XP = SKILLING_XP;
    	
    	public static void stealFromStall(final Client c, final int id, int amount, int xp, int level, final int i, final int x, final int y, final int face) {
    	/*	if (System.currentTimeMillis() - c.lastThieve < 2500)
    			return;
    		if(c.underAttackBy > 0 || c.underAttackBy2 > 0) {
    			c.sendMessage("You can't steal from a stall while in combat!");
    			return;	
    		}*/
    		//if (c.playerLevel[c.playerThieving] >= level) {
    			//if (c.getItems().addItem(id,amount)) {
    				c.startAnimation(832);
    				c.getPA().addSkillXP(xp * THIEVING_XP, c.playerThieving);
    				c.lastThieve = System.currentTimeMillis();
    				c.sendMessage("You steal some coins.");
    				Server.objectHandler.createAnObject(c, 634, x, y, face);
    				CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    					@Override
    					public void execute(CycleEventContainer container) {
    						Server.objectHandler.createAnObject(c, i, x, y, face);
    						container.stop();
    					}
    					@Override
    					public void stop() {
    
    					}
    				}, getRespawnTime(c, i));
    			//}
    		//} else {
    		//	c.sendMessage("You must have a thieving level of " + level + " to thieve from this stall.");
    		//}
    	}
    
    	private static int getRespawnTime(Client c, int i) {
    		switch (i) {
    			case 2561: return 4;	//BAKER
    			case 2560: return 8;	//SILK
    			case 7053: return 15;	//SEED
    			case 2563: return 22;	//FUR
    			case 2565: return 30;	//SILVER
    			case 2564: return 50;	//SPICE
    			case 2562: return 50;	//GEM
    			case 14011: return 5;	//JUG
    			default: return 5;
    		}
    	}
    	}
    rip it from this source http://www.rune-server.org/runescape...-508-maps.html kinda old but i like the system
    Reply With Quote  
     

  4. #4  
    Banned
    Join Date
    Mar 2014
    Posts
    628
    Thanks given
    109
    Thanks received
    181
    Rep Power
    0
    Horrible code, but where are you calling the method in ActionHandler?
    Reply With Quote  
     

  5. #5  
    Middle Finger is Here


    Join Date
    Feb 2012
    Age
    31
    Posts
    2,546
    Thanks given
    377
    Thanks received
    502
    Rep Power
    162
    Quote Originally Posted by Vili View Post
    Horrible code, but where are you calling the method in ActionHandler?
    under firstclickobject are you high?
    Hi
    Reply With Quote  
     

  6. #6  
    Kanketsu
    JacobiYounger's Avatar
    Join Date
    Aug 2009
    Posts
    723
    Thanks given
    49
    Thanks received
    31
    Rep Power
    31
    Quote Originally Posted by Zivik View Post
    What happens when you click it.
    Nothing. My character just stands in the same spot. When I look at eclipse it says I am clicking it, but nothing happens.

    Quote Originally Posted by Vili View Post
    Horrible code, but where are you calling the method in ActionHandler?
    What this?
    import server.content.skills.Thieving;

    It's in the firstclickobject.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Quote Originally Posted by JacobiYounger View Post
    Nothing. My character just stands in the same spot. When I look at eclipse it says I am clicking it, but nothing happens.



    What this?
    import server.content.skills.Thieving;

    It's in the firstclickobject.
    Try adding some sendmessages in various parts of the code to figure out what areas it reaches and or doesn't reach. From there, you can debug exactly what the issue is.
    Reply With Quote  
     

  8. #8  
    Kanketsu
    JacobiYounger's Avatar
    Join Date
    Aug 2009
    Posts
    723
    Thanks given
    49
    Thanks received
    31
    Rep Power
    31
    Quote Originally Posted by Zivik View Post
    Try adding some sendmessages in various parts of the code to figure out what areas it reaches and or doesn't reach. From there, you can debug exactly what the issue is.
    I just added a message for the actionhandler.java for the clickfirstobject.

    Nothing even popped up.

    case 2561:
    //c.getThieving().stealFromStall(c, 995, 5000, 16, 5, objectType,obX,obY,2);
    c.sendMessage("You move up the stairs..");
    break;

    And its working for other objects... Like everything else is working great.
    Reply With Quote  
     

  9. #9  
    Banned
    Join Date
    Mar 2014
    Posts
    628
    Thanks given
    109
    Thanks received
    181
    Rep Power
    0
    I'll probably find out that this was released under someone else's name, but not using this anymore. Have at it.

    Second Click Object
    Code:
    /** Thieving **/
    case 6162:
    case 6163:
    case 6164:
    Thieving.startThieving(player, objectType, obX, obY);
    break;
    Second Click NPC
    Code:
    case 1:
    		case 2:
    		case 3:
    			Thieving.startPickpocketAction(player, i);
    			break;
    Stalls.java
    Code:
    package org.delrith.world.entity.player.skill.thieving;
    
    /**
    * @author Vili
    */
    
    public enum Stalls {
    
    	/** Represents the values for Gem Stalls **/
    	GEM(6162, 1609, 1, 50.0),
    
    	/** Represents the values for Bakery Stalls **/
    	BAKERY(6163, 1891, 50, 125.0),
    
    	/** Represents the values for Silver Stalls **/
    	SILVER(6164, 2355, 75, 200.0);
    
    	/** Field Variables **/
    	private final int objectIdentifier, itemIdentifier, levelRequired;
    	private final double experience;
    
    	private Stalls(final int objectIdentifier, final int itemIdentifier,
    			final int levelRequired, final double experience) {
    		this.objectIdentifier = objectIdentifier;
    		this.itemIdentifier = itemIdentifier;
    		this.levelRequired = levelRequired;
    		this.experience = experience;
    	}
    
    	/**
    	 * Public constructs objectIdentifier.
    	 * 
    	 * @return
    	 */
    	public int getObject() {
    		return objectIdentifier;
    	}
    
    	/**
    	 * Publicly constructs itemIdentifier.
    	 * 
    	 * @return
    	 */
    	public int getItem() {
    		return itemIdentifier;
    	}
    
    	/**
    	 * Publicly constructs levelRequired.
    	 * 
    	 * @return
    	 */
    	public int getLevel() {
    		return levelRequired;
    	}
    
    	/**
    	 * Publicly constructs experience.
    	 * 
    	 * @return
    	 */
    	public double getExperience() {
    		return experience;
    	}
    
    }
    Thieving.java
    Code:
    package org.delrith.world.entity.player.skill.thieving;
    
    import org.delrith.core.util.Misc;
    import org.delrith.world.entity.Hit;
    import org.delrith.world.entity.Hit.HitType;
    import org.delrith.world.entity.player.Player;
    import org.delrith.world.entity.player.skill.SkillHandler;
    import org.delrith.world.event.WorldEvent;
    import org.delrith.world.event.WorldEventContainer;
    import org.delrith.world.event.WorldEventHandler;
    
    /*
    * @author Vili
    */
    
    public class Thieving extends SkillHandler {
    	
    	/**
    	 *  Calculates the rate of failure to pickpocket.
    	 * @param player
    	 * 		The player trying to pickpocket.
    	 * @param npcId
    	 * 		The npc taking action.
    	 * @return
    	 * 		The failure rate.
    	 */
    	private static int failureRate(final Player player, final int npcId) {
    		final Pickpocket pickpocket = Pickpocket.forId(npcId);
    		double npcFactor = pickpocket.getLevel() / 10;
    		double levelFactor = 100 / ((player.playerLevel[player.playerThieving] + 1) - pickpocket.getLevel());
    		return (int) Math.floor((levelFactor + npcFactor) / 2);
    	}
    	
    	/**
    	 *  Checks if the player meets all requirements.
    	 * @param player
    	 * 		The player being checked.
    	 * @param npcId
    	 * 		The npc being checked by the player level.
    	 * @return
    	 * 		The outcome of the check.
    	 */
    	private static boolean meetsRequirements(final Player player, final int npcId) {
    		final Pickpocket pickpocket = Pickpocket.forId(npcId);
    		if (player.playerLevel[player.playerThieving] < pickpocket.getLevel()) {
    			player.sendMessage("You need a thieving level of " + pickpocket.getLevel() + " to pickpocket this npc.");
    			return false;
    		}
    		return true;
    	}
    	
    	/**
    	 *  Handles the outcome of a successful pickpocket.
    	 * @param player
    	 * 		The player taking action.
    	 * @param npcId
    	 * 		The npc taking action.
    	 */
    	private static void handleSuccess(final Player player, final int npcId) {
    		final Pickpocket pickpocket = Pickpocket.forId(npcId);
    		int random = Misc.random(pickpocket.getProduct().length - 1);
    		player.getItems().addItem(pickpocket.getProduct()[random][0], pickpocket.getProduct()[random][1]);
    		player.getPA().addSkillXP((int) pickpocket.getExperience() , player.playerThieving);
    	}
    	
    	/**
    	 *  Handles the outcome of a failed pickpocket.
    	 * @param player
    	 * 		The player failing.
    	 * @param stunTime
    	 * 		The time between being able to pickpocket again.
    	 * @param damage
    	 * 		The damage resulted in failing.
    	 * @param npcId
    	 * 		The npc stunning and damaging the player.
    	 */
    	private static void handleFailure(final Player player, final int stunTime, final int damage, int npcId) {
    		player.startAnimation(player.getCombat().getBlockEmote());
    		player.dealHit(new Hit(damage, HitType.NORMAL));
    		player.setHitUpdateRequired(true);
    		player.playerLevel[player.playerHitpoints] -= damage;
    		player.getPA().refreshSkill(player.playerHitpoints);
    		player.setIsStunned(true);
    		player.gfx100(80);
    		WorldEventHandler.getSingleton().addEvent(player, new WorldEvent() {
    			@Override
    			public void execute(WorldEventContainer container) {
    				if (System.currentTimeMillis() - player.lastStunned > stunTime) {
    					container.stop();
    				}
    			}
    			@Override
    			public void stop() {
    				player.setIsStunned(false);
    				resetSkill(player);
    			}
    		}, 2);
    	}
    	
    	/**
    	 *  Handles the action of pickpocketing npc.
    	 * @param player
    	 * 		The player taking action.
    	 * @param npcId
    	 * 		The npc being taken action upon.
    	 */
    	public static void startPickpocketAction(final Player player, final int npcId) {
    		final Pickpocket pickpocket = Pickpocket.forId(npcId);
    		
    		if (pickpocket == null)
    			return;
    		
    		if (isBusy(player))
    			return;
    		
    		if (player.getIsStunned())
    			return;
    		
    		if (meetsRequirements(player, npcId)) {
    			player.startAnimation(881);
    			player.sendMessage("You attempt to pickpocket the npc.");
    			WorldEventHandler.getSingleton().addEvent(player, new WorldEvent() {
    				@Override 
    				public void execute(WorldEventContainer container) {
    					setBusy(player, true);						
    					player.startAnimation(881);
    					if (Misc.random(100) < failureRate(player, npcId)) {
    						player.sendMessage("You failed to pickpocket the npc.");
    						player.setSuccessfulThief(false);
    						container.stop();
    					} else {
    						player.setSuccessfulThief(true);
    						container.stop();
    					}
    				}
    				@Override
    				public void stop() {
    					resetSkill(player);
    					if (player.getSuccessfulThief()) {
    						handleSuccess(player, npcId);	
    						player.sendMessage("You successfully pickpocket the npc.");
    						return;
    					} else if (!player.getSuccessfulThief()) {
    						handleFailure(player, pickpocket.getTimer() * 1000, pickpocket.getDamage(), npcId);
    						player.lastStunned = System.currentTimeMillis();
    						return;
    					}
    					
    				}
    			}, 1);
    		}
    	}
    
    	/**
    	 * Handles the action of Theiving Stalls.
    	 * 
    	 * @param player
    	 *            The player thieving.
    	 * @param objectIdentifier
    	 *            The object being thieved from.
    	 * @param objectX
    	 *            The object X.
    	 * @param objectY
    	 *            The object Y.
    	 */
    	public static void startThieving(final Player player,
    			final int objectIdentifier, final int objectX, final int objectY) {
    		if (isBusy(player)) {
    			return;
    		}
    		for (final Stalls stall : Stalls.values()) {
    			if (objectIdentifier == stall.getObject()) {
    				if (player.playerLevel[player.playerThieving] < stall
    						.getLevel()) {
    					player.sendMessage("You don't have the required level to do this.");
    					return;
    				} else if (player.getItems().freeSlots() == 0) {
    					player.sendMessage("You don't have enough space to do this.");
    					return;
    				}
    				if (System.currentTimeMillis() - player.lastThieve > 2500) {
    					player.startAnimation(832);
    					setBusy(player, true);
    					WorldEventHandler.getSingleton().addEvent(player,
    							new WorldEvent() {
    								int random = Misc.random(10);
    
    								@Override
    								public void execute(
    										WorldEventContainer container) {
    									player.startAnimation(832);
    									player.getPA()
    											.addSkillXP(
    													(player.playerRights >= 3
    															&& random == 1
    															&& player
    																	.getItems()
    																	.freeSlots() > 2 ? (stall
    															.getExperience() * 2)
    															: (stall.getExperience())),
    													player.playerThieving);
    									player.getItems()
    											.addItem(
    													stall.getItem(),
    													player.playerRights >= 3
    															&& random == 1
    															&& player
    																	.getItems()
    																	.freeSlots() > 2 ? 2
    															: 1);
    									player.sendMessage(player.playerRights >= 3
    											&& random == 1
    											&& player.getItems().freeSlots() > 2 ? "You managed to steal an extra gem because you're a donator."
    											: "You managed to steal a gem.");
    									player.lastThieve = System
    											.currentTimeMillis();
    									container.stop();
    								}
    
    								@Override
    								public void stop() {
    									resetSkill(player);
    								}
    							}, 1);
    				}
    			}
    		}
    	}
    }
    Code:
    package org.delrith.world.entity.player.skill.thieving;
    
    import java.util.HashMap;
    
    import org.delrith.core.util.Misc;
    
    public enum Pickpocket {
    	
    	/** Represents the values for Men **/
    	MAN(new int[] { 1, 2, 3 }, new int[][] { {995, Misc.random(3) + 3} }, 1, 5, 1, 8.0);
    
    	
    	/** Field Variables **/
    	private final int[] entityIdentifier;
    	private final int[][] entityYield;
    	private final int levelRequired, stunTimer, entityDamage;
    	private double experience;
    	
    	/**
    	 *  Constructs the enumeration.
    	 * @param entityIdentifier
    	 * 		The entity being taken into action.
    	 * @param entityYield
    	 * 		The yield from taking action.
    	 * @param levelRequired
    	 * 		The level required to take action.
    	 * @param stunTimer
    	 * 		The timer for failing to take action.
    	 * @param entityDamage
    	 * 		The damage for failing the action.
    	 * @param experience
    	 * 		The experience received for taking action.
    	 */
    	private Pickpocket(final int[] entityIdentifier, final int[][] entityYield, final int levelRequired, final int stunTimer,
    			final int entityDamage, final double experience) {
    		this.entityIdentifier = entityIdentifier;
    		this.entityYield = entityYield;
    		this.levelRequired = levelRequired;
    		this.stunTimer = stunTimer;
    		this.entityDamage = entityDamage;
    		this.experience = experience;
    	}
    	
    	/** Constructs a HashMap to populate **/
    	public static HashMap <Integer, Pickpocket> pickpocket = new HashMap <Integer, Pickpocket>();
    	
    	/**
    	 *  Populates the HashMap.
    	 */
    	static {
    		for (Pickpocket p : Pickpocket.values()) {
    			for (int id : p.getNpc()) {
    				pickpocket.put(id, p);
    			}
    		}
    	}
    	
    	/**
    	 *  Creates the instance.
    	 * @param id
    	 * 		The thing being instanced.
    	 * @return
    	 * 		The instance.
    	 */
    	public static Pickpocket forId(int id) {
    		return pickpocket.get(id);
    	}
    	
    	/**
    	 *  Publicly constructs entityIdentiifer.
    	 * @return
    	 */
    	public int[] getNpc() {
    		return entityIdentifier;
    	}
    	
    	/**
    	 *  Publicly constructs entityYield.
    	 * @return
    	 */
    	public int[][] getProduct() {
    		return entityYield;
    	}
    	
    	/** 
    	 * Publicly constructs levelRequired.
    	 * @return
    	 */
    	public int getLevel() {
    		return levelRequired;
    	}
    	
    	/**
    	 *  Publicly constructs stunTimer.
    	 * @return
    	 */
    	public int getTimer() {
    		return stunTimer;
    	}
    	
    	/**
    	 *  Publicly constructs entityDamage.
    	 * @return
    	 */
    	public int getDamage() {
    		return entityDamage;
    	}
    	
    	/**
    	 *  Publicly constructs experience.
    	 * @return
    	 */
    	public double getExperience() {
    		return experience;
    	}
    
    }
    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. Weird right click bug..
    By FuckThePolice in forum Help
    Replies: 4
    Last Post: 06-17-2010, 11:49 PM
  2. Thieving Bug (Rep++)
    By artemis in forum Help
    Replies: 12
    Last Post: 06-04-2010, 01:16 PM
  3. [req] need help with weird objects [req]
    By w0w ur d3ad in forum Models
    Replies: 4
    Last Post: 10-17-2009, 04:20 AM
  4. weird player dialoge bug
    By R0cky 0wnz in forum Help
    Replies: 4
    Last Post: 06-17-2009, 10:25 PM
  5. Weird run error bug
    By Ziya in forum Help
    Replies: 2
    Last Post: 05-19-2009, 09:04 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
  •