Thread: removing a ladder

Results 1 to 5 of 5
  1. #1 removing a ladder 
    Quantum Scape Founder Quantum's Avatar
    Join Date
    Oct 2020
    Posts
    64
    Thanks given
    9
    Thanks received
    17
    Discord
    View profile
    Rep Power
    47
    So I've been wanting to despawn a ladder. But, I can't seem to figure this out.

    I've tried despawning it in NPCSpawning, ObjectSpawning, and also looked through spawnlist in data/map, but no matter what I try, the ladder still remains. Is there something that I am missing when it comes to ladder? Is it a global object that cant be deleted?

    My code in both NPCSpawning and ObjectSpawning :

    Code:
    
    World.deleteObject(new WorldTile(3244, 9783, 0));
    World.removeObject(new WorldObject(2405, 10, 3, 3244, 9783, 0), true);
    World.deleteObject(new WorldTile(3244, 9783, 0));
    The ladder returns as :

    2405, 3244, 9783, 0, 10, 3, Ladder

    I'm using Matrix 718 source.
    In a Quantum World, nothing is real. We are one, and one is all. Live in the Quantum World.

    Reply With Quote  
     

  2. #2  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    Need to load the region before trying to delete the objects. World.loadRegion(id) or World.getRegion(id, true) if I remember correctly will load those regions.
    Reply With Quote  
     

  3. #3  
    Quantum Scape Founder Quantum's Avatar
    Join Date
    Oct 2020
    Posts
    64
    Thanks given
    9
    Thanks received
    17
    Discord
    View profile
    Rep Power
    47
    Quote Originally Posted by Kris View Post
    Need to load the region before trying to delete the objects. World.loadRegion(id) or World.getRegion(id, true) if I remember correctly will load those regions.
    So it would be this in NPCSpawning?:

    Code:
    
    World.loadRegion(12952);
    World.removeObject(new WorldObject(2405, 10, 3, 3244, 9783, 0), true);
    Edit: in this server, its getRegion(id); , tried this before the removeobject and didn't work.

    Edit : Went through the world.java and found the function for removeObject :

    Code:
    
    public static final void removeObject(WorldObject object) {
    		getRegion(object.getRegionId()).removeObject(object, object.getPlane(), object.getXInRegion(), object.getYInRegion());
    	}
    Tried to work with it and try : World.getRegion(12952).removeObject(new WorldObject(2405, 10, 3, 3244, 9783, 0));

    Not exactly sure what im missing with this, other objects despawn with either delete or remove object except this ladder.
    Last edited by Quantum; 11-13-2020 at 07:26 PM.
    In a Quantum World, nothing is real. We are one, and one is all. Live in the Quantum World.

    Reply With Quote  
     

  4. #4  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by quantumrebel View Post
    So it would be this in NPCSpawning?:

    Code:
    
    World.loadRegion(12952);
    World.removeObject(new WorldObject(2405, 10, 3, 3244, 9783, 0), true);
    Edit: in this server, its getRegion(id); , tried this before the removeobject and didn't work.
    There should be another method that takes a second parameter, so getRegion(regionId, true) - don't forget the true part. That's what force-loads the requested region, instead of just returning the reference in whatever form it currently is in.
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Quantum Scape Founder Quantum's Avatar
    Join Date
    Oct 2020
    Posts
    64
    Thanks given
    9
    Thanks received
    17
    Discord
    View profile
    Rep Power
    47
    Quote Originally Posted by Kris View Post
    There should be another method that takes a second parameter, so getRegion(regionId, true) - don't forget the true part. That's what force-loads the requested region, instead of just returning the reference in whatever form it currently is in.
    Tried the : World.getRegion(12952, true);

    Found this in World.Java , seems to be the only get regions in it.
    Code:
    
    	public static final Map<Integer, Region> getRegions() {
    		// synchronized (lock) {
    		return regions;
    		// }
    	}
    
    	public static final Region getRegion(int id) {
    		return getRegion(id, false);
    	}
    
    	public static final Region getRegion(int id, boolean load) {
    		// synchronized (lock) {
    		Region region = regions.get(id);
    		if (region == null) {
    			region = new Region(id);
    			regions.put(id, region);
    		}
    		if (load)
    			region.checkLoadMap();
    		return region;
    		// }
    These are the only load regions

    Code:
    
    public static void executeAfterLoadRegion(final int regionId, final Runnable event) {
    		executeAfterLoadRegion(regionId, 0, event);
    	}
    
    	public static void executeAfterLoadRegion(final int regionId, long startTime, final Runnable event) {
    		executeAfterLoadRegion(regionId, startTime, 10000, event);
    	}
    
    	public static void executeAfterLoadRegion(final int fromRegionX, final int fromRegionY, final int toRegionX, final int toRegionY, long startTime, final long expireTime, final Runnable event) {
    		final long start = Utils.currentTimeMillis();
    		for (int x = fromRegionX; x <= toRegionX; x++) {
    			for (int y = fromRegionY; y <= toRegionY; y++) {
    				int regionId = MapUtils.encode(Structure.REGION, x, y);
    				World.getRegion(regionId, true); // forces check load if not
    				// loaded
    			}
    		}
    		GameEngine.get().getFastExecutor().schedule(new TimerTask() {
    
    			@Override
    			public void run() {
    				try {
    					for (int x = fromRegionX; x <= toRegionX; x++) {
    						for (int y = fromRegionY; y <= toRegionY; y++) {
    							int regionId = MapUtils.encode(Structure.REGION, x, y);
    							if (!World.isRegionLoaded(regionId) && Utils.currentTimeMillis() - start < expireTime)
    								return;
    						}
    					}
    					event.run();
    					cancel();
    				} catch (Throwable e) {
    					e.printStackTrace();
    				}
    			}
    
    		}, startTime, 600);
    	}
    
    	/*
    	 * TODO make this use code from above to save lines lo, they do same
    	 */
    	public static void executeAfterLoadRegion(final int regionId, long startTime, final long expireTime, final Runnable event) {
    		final long start = Utils.currentTimeMillis();
    		World.getRegion(regionId, true); // forces check load if not loaded
    		CoresManager.fastExecutor.schedule(new TimerTask() {
    
    			@Override
    			public void run() {
    				try {
    					if (!World.isRegionLoaded(regionId) && Utils.currentTimeMillis() - start < expireTime)
    						return;
    					event.run();
    					cancel();
    				} catch (Throwable e) {
    					e.printStackTrace();
    				}
    			}
    
    		}, startTime, 600);
    	}
    In a Quantum World, nothing is real. We are one, and one is all. Live in the Quantum World.

    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. Removing Flames in Client
    By Guthan in forum Tutorials
    Replies: 15
    Last Post: 07-24-2009, 10:42 PM
  2. [Tut] Adding/Moving/Removing Global Objects
    By XxMixTheMusicxX in forum Tutorials
    Replies: 17
    Last Post: 09-07-2007, 08:44 PM
  3. Removing mass click training (no kicks/bans)
    By The Unforgiven in forum Tutorials
    Replies: 13
    Last Post: 09-01-2007, 10:17 PM
  4. Replies: 7
    Last Post: 08-25-2007, 06:11 AM
  5. Removing Objects In An Area (UNTESTED)
    By Llama in forum Tutorials
    Replies: 10
    Last Post: 06-21-2007, 09:33 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
  •