Thread: items kept on death

Results 1 to 7 of 7
  1. #1 items kept on death 
    Registered Member
    Join Date
    Jan 2010
    Posts
    696
    Thanks given
    109
    Thanks received
    29
    Rep Power
    3
    can some one provide me SendDeath and ItemsKeptOnDeath ? becouse now when i die i lose nothing
    Reply With Quote  
     

  2. #2  
    I don't speak Spanish
    Daron's Avatar
    Join Date
    Feb 2012
    Age
    28
    Posts
    218
    Thanks given
    1
    Thanks received
    39
    Rep Power
    45
    Code:
        @Override
        public void sendDeath(final Entity source) {
        	if (getRights() == 2 && getHitpoints() == 0) {
        		setNextAnimation(new Animation(21280));
        		setHitpoints((int) (getMaxHitpoints()));
        		lock(4);
        		return;
        	}
    	if (getEffectsManager().hasActiveEffect(EffectType.IMMORTALITY)) {
    	    resetReceivedHits();
    	    setHitpoints((int) (getMaxHitpoints() * 0.40));
    	    setNextAnimation(new Animation(18119));
    	    setNextGraphics(new Graphics(3630));
    	    World.sendGraphics(this, new Graphics(3631, 0, 0, getDirection(), true), this);
    	    getEffectsManager().removeEffect(EffectType.IMMORTALITY);
    	    return;
    	}
    	if (prayer.hasPrayersOn() && getTemporaryAttributtes().get("startedDuel") != Boolean.TRUE) {
    	    if (prayer.usingPrayer(0, 14)) {
    		setNextGraphics(new Graphics(437));
    		final Player target = this;
    
    		for (int regionId : getMapRegionsIds()) {
    		    List<Integer> playersIndexes = World.getRegion(regionId).getPlayerIndexes();
    		    if (playersIndexes != null) {
    			for (int playerIndex : playersIndexes) {
    			    Player player = World.getPlayers().get(playerIndex);
    			    if (player == null || !player.hasStarted() || player.isDead() || player.hasFinished()
    				    || !player.withinDistance(this, 1) || !player.isCanPvp()
    				    || !target.getControlerManager().canHit(player))
    				continue;
    			    player.applyHit(
    				    new Hit(target, Utils.random((int) (skills.getLevelForXp(Skills.PRAYER) * 2.5)),
    					    HitLook.REGULAR_DAMAGE));
    			}
    		    }
    		    List<Integer> npcsIndexes = World.getRegion(regionId).getNPCsIndexes();
    		    if (npcsIndexes != null) {
    			for (int npcIndex : npcsIndexes) {
    			    NPC npc = World.getNPCs().get(npcIndex);
    			    if (npc == null || npc.isDead() || npc.hasFinished() || !npc.withinDistance(this, 1)
    				    || !npc.getDefinitions().hasAttackOption()
    				    || !target.getControlerManager().canHit(npc))
    				continue;
    			    npc.applyHit(
    				    new Hit(target, Utils.random((int) (skills.getLevelForXp(Skills.PRAYER) * 25.00)),
    					    HitLook.REGULAR_DAMAGE));
    			}
    		    }
    		}
    
    		WorldTasksManager.schedule(new WorldTask() {
    		    @Override
    		    public void run() {
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() - 1, target.getY(), target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() + 1, target.getY(), target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX(), target.getY() - 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX(), target.getY() + 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() - 1, target.getY() - 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() - 1, target.getY() + 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() + 1, target.getY() - 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() + 1, target.getY() + 1, target.getPlane()));
    		    }
    		});
    	    } else if (prayer.usingPrayer(1, 23)) {
    		World.sendProjectile(this, new WorldTile(getX() + 2, getY() + 2, getPlane()), 2261, 24, 0, 41, 35, 30,
    			0);
    		World.sendProjectile(this, new WorldTile(getX() + 2, getY(), getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		World.sendProjectile(this, new WorldTile(getX() + 2, getY() - 2, getPlane()), 2261, 41, 0, 41, 35, 30,
    			0);
    
    		World.sendProjectile(this, new WorldTile(getX() - 2, getY() + 2, getPlane()), 2261, 41, 0, 41, 35, 30,
    			0);
    		World.sendProjectile(this, new WorldTile(getX() - 2, getY(), getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		World.sendProjectile(this, new WorldTile(getX() - 2, getY() - 2, getPlane()), 2261, 41, 0, 41, 35, 30,
    			0);
    
    		World.sendProjectile(this, new WorldTile(getX(), getY() + 2, getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		World.sendProjectile(this, new WorldTile(getX(), getY() - 2, getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		final Player target = this;
    		WorldTasksManager.schedule(new WorldTask() {
    		    @Override
    		    public void run() {
    			setNextGraphics(new Graphics(2259));
    
    			for (int regionId : getMapRegionsIds()) {
    			    List<Integer> playersIndexes = World.getRegion(regionId).getPlayerIndexes();
    			    if (playersIndexes != null) {
    				for (int playerIndex : playersIndexes) {
    				    Player player = World.getPlayers().get(playerIndex);
    				    if (player == null || !player.hasStarted() || player.isDead()
    					    || player.hasFinished() || !player.isCanPvp()
    					    || !player.withinDistance(target, 2)
    					    || !target.getControlerManager().canHit(player))
    					continue;
    				    player.applyHit(new Hit(target,
    					    (int) Utils.random((skills.getLevelForXp(Skills.PRAYER) * 25.00)),
    					    HitLook.REGULAR_DAMAGE));
    				}
    			    }
    			    List<Integer> npcsIndexes = World.getRegion(regionId).getNPCsIndexes();
    			    if (npcsIndexes != null) {
    				for (int npcIndex : npcsIndexes) {
    				    NPC npc = World.getNPCs().get(npcIndex);
    				    if (npc == null || npc.isDead() || npc.hasFinished()
    					    || !npc.withinDistance(target, 2) || !npc.getDefinitions().hasAttackOption()
    					    || !target.getControlerManager().canHit(npc))
    					continue;
    				    npc.applyHit(new Hit(target,
    					    (int) Utils.random((skills.getLevelForXp(Skills.PRAYER) * 25.00)),
    					    HitLook.REGULAR_DAMAGE));
    				}
    			    }
    			}
    
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 2, getY() + 2, getPlane()));
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() + 2, getY(), getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 2, getY() - 2, getPlane()));
    
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 2, getY() + 2, getPlane()));
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() - 2, getY(), getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 2, getY() - 2, getPlane()));
    
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX(), getY() + 2, getPlane()));
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX(), getY() - 2, getPlane()));
    
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 1, getY() + 1, getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 1, getY() - 1, getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 1, getY() + 1, getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 1, getY() - 1, getPlane()));
    		    }
    		});
    	    }
    	}
    	setNextAnimation(new Animation(-1));
    	if (!controlerManager.sendDeath())
    	    return;
    	lock(8);
    	stopAll();
    	if (familiar != null)
    	    familiar.sendDeath(this);
    	final WorldTile deathTile = new WorldTile(this);
    	WorldTasksManager.schedule(new WorldTask() {
    	    int loop;
    
    	    @Override
    	    public void run() {
    		if (loop == 0) {    
    			if (deathByFire = true){
    		    setNextAnimation(new Animation(20168));
    			setNextGraphics(new Graphics(3958));
    		    }else if (deathByWater = true){
    			    setNextAnimation(new Animation(20164));
    				setNextGraphics(new Graphics(3956));
    		    }else if (deathByAir = true){
    			    setNextAnimation(new Animation(20162));
    				setNextGraphics(new Graphics(3955));
    		    }else if (deathByEarth = true){
    			    setNextAnimation(new Animation(20166));
    				setNextGraphics(new Graphics(3957));
    		    }else{
    		    setNextAnimation(getDeathAnimation());
    		    }
    		} else if (loop == 1) {
    		    getPackets().sendGameMessage("Oh dear, you have died.");
    		} else if (loop == 3) {
    		    controlerManager.startControler("DeathEvent", deathTile, hasSkull());
    		} else if (loop == 4) {
    		    getMusicsManager().playMusicEffect(MusicsManager.DEATH_MUSIC_EFFECT);
    		    stop();
    		}
    		loop++;
    	    }
    	}, 0, 1);
        }
    
        public void sendItemsOnDeath(Player killer, boolean dropItems, boolean dropLostItems) {
    	Integer[][] slots = GraveStone.getItemSlotsKeptOnDeath(this, true, dropItems, getPrayer().isProtectingItem());
    	sendItemsOnDeath(killer, getLastWorldTile(), new WorldTile(this), true, slots, dropLostItems);
        }
    
        /*
         * default items on death, now only used for wilderness
         */
        public void sendItemsOnDeath(Player killer, boolean dropItems) {
    	sendItemsOnDeath(killer, dropItems, true);
        }
    
        /*
         * default items on death, now only used for wilderness
         */
        public void sendItemsOnDeath(Player killer) {
    	sendItemsOnDeath(killer, hasSkull());
        }
    
        public void sendItemsOnDeath(Player killer, WorldTile deathTile, WorldTile respawnTile, boolean wilderness,
    	    Integer[][] slots, boolean dropLostItems) {
    	/*
    	 * if ((((killer != null && killer.getRights() >= 2) || getRights() >=
    	 * 2) && Settings.HOSTED) || hasFinished()) return;
    	 */
    	if (Settings.HOSTED) {
    	    if (getRights() >= 2 || hasFinished())
    		return;
    	    if (killer != null) {
    		if (killer.getRights() >= 2)
    		    return;
    	    }
    	}
    
    	charges.die(slots[1], slots[3]); // degrades droped and lost items only
    	auraManager.removeAura();
    	Item[][] items = GraveStone.getItemsKeptOnDeath(this, slots);
    	inventory.reset();
    	equipment.reset();
    	appearence.generateAppearenceData();
    	for (Item item : items[0])
    	    inventory.addItemDrop(item.getId(), item.getAmount(), respawnTile);
    	if (dropLostItems) {
    	    if (items[1].length != 0) {
    		if (wilderness) {
    		    if (!isBeginningAccount())
    			for (Item item : items[1])
    			    World.addGroundItem(item, deathTile, killer == null ? this : killer, true, 60,
    				    killer == null ? 1 : 0);
    		} else
    		    new GraveStone(this, deathTile, items[1]);
    	    }
    
    	}
    	if (killer != null)
    	    Logger.globalLog(username, session.getIP(),
    		    new String(killer.getUsername() + " has killed " + username + " with the ip: "
    			    + killer.getSession().getIP() + " items are as follows:"
    			    + Arrays.toString(items[1]).replace("null,", "") + " ."));
        }
    My methods, edit them to your liking
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2010
    Posts
    696
    Thanks given
    109
    Thanks received
    29
    Rep Power
    3
    Quote Originally Posted by Daron View Post
    Code:
        @Override
        public void sendDeath(final Entity source) {
        	if (getRights() == 2 && getHitpoints() == 0) {
        		setNextAnimation(new Animation(21280));
        		setHitpoints((int) (getMaxHitpoints()));
        		lock(4);
        		return;
        	}
    	if (getEffectsManager().hasActiveEffect(EffectType.IMMORTALITY)) {
    	    resetReceivedHits();
    	    setHitpoints((int) (getMaxHitpoints() * 0.40));
    	    setNextAnimation(new Animation(18119));
    	    setNextGraphics(new Graphics(3630));
    	    World.sendGraphics(this, new Graphics(3631, 0, 0, getDirection(), true), this);
    	    getEffectsManager().removeEffect(EffectType.IMMORTALITY);
    	    return;
    	}
    	if (prayer.hasPrayersOn() && getTemporaryAttributtes().get("startedDuel") != Boolean.TRUE) {
    	    if (prayer.usingPrayer(0, 14)) {
    		setNextGraphics(new Graphics(437));
    		final Player target = this;
    
    		for (int regionId : getMapRegionsIds()) {
    		    List<Integer> playersIndexes = World.getRegion(regionId).getPlayerIndexes();
    		    if (playersIndexes != null) {
    			for (int playerIndex : playersIndexes) {
    			    Player player = World.getPlayers().get(playerIndex);
    			    if (player == null || !player.hasStarted() || player.isDead() || player.hasFinished()
    				    || !player.withinDistance(this, 1) || !player.isCanPvp()
    				    || !target.getControlerManager().canHit(player))
    				continue;
    			    player.applyHit(
    				    new Hit(target, Utils.random((int) (skills.getLevelForXp(Skills.PRAYER) * 2.5)),
    					    HitLook.REGULAR_DAMAGE));
    			}
    		    }
    		    List<Integer> npcsIndexes = World.getRegion(regionId).getNPCsIndexes();
    		    if (npcsIndexes != null) {
    			for (int npcIndex : npcsIndexes) {
    			    NPC npc = World.getNPCs().get(npcIndex);
    			    if (npc == null || npc.isDead() || npc.hasFinished() || !npc.withinDistance(this, 1)
    				    || !npc.getDefinitions().hasAttackOption()
    				    || !target.getControlerManager().canHit(npc))
    				continue;
    			    npc.applyHit(
    				    new Hit(target, Utils.random((int) (skills.getLevelForXp(Skills.PRAYER) * 25.00)),
    					    HitLook.REGULAR_DAMAGE));
    			}
    		    }
    		}
    
    		WorldTasksManager.schedule(new WorldTask() {
    		    @Override
    		    public void run() {
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() - 1, target.getY(), target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() + 1, target.getY(), target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX(), target.getY() - 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX(), target.getY() + 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() - 1, target.getY() - 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() - 1, target.getY() + 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() + 1, target.getY() - 1, target.getPlane()));
    			World.sendGraphics(target, new Graphics(438),
    				new WorldTile(target.getX() + 1, target.getY() + 1, target.getPlane()));
    		    }
    		});
    	    } else if (prayer.usingPrayer(1, 23)) {
    		World.sendProjectile(this, new WorldTile(getX() + 2, getY() + 2, getPlane()), 2261, 24, 0, 41, 35, 30,
    			0);
    		World.sendProjectile(this, new WorldTile(getX() + 2, getY(), getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		World.sendProjectile(this, new WorldTile(getX() + 2, getY() - 2, getPlane()), 2261, 41, 0, 41, 35, 30,
    			0);
    
    		World.sendProjectile(this, new WorldTile(getX() - 2, getY() + 2, getPlane()), 2261, 41, 0, 41, 35, 30,
    			0);
    		World.sendProjectile(this, new WorldTile(getX() - 2, getY(), getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		World.sendProjectile(this, new WorldTile(getX() - 2, getY() - 2, getPlane()), 2261, 41, 0, 41, 35, 30,
    			0);
    
    		World.sendProjectile(this, new WorldTile(getX(), getY() + 2, getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		World.sendProjectile(this, new WorldTile(getX(), getY() - 2, getPlane()), 2261, 41, 0, 41, 35, 30, 0);
    		final Player target = this;
    		WorldTasksManager.schedule(new WorldTask() {
    		    @Override
    		    public void run() {
    			setNextGraphics(new Graphics(2259));
    
    			for (int regionId : getMapRegionsIds()) {
    			    List<Integer> playersIndexes = World.getRegion(regionId).getPlayerIndexes();
    			    if (playersIndexes != null) {
    				for (int playerIndex : playersIndexes) {
    				    Player player = World.getPlayers().get(playerIndex);
    				    if (player == null || !player.hasStarted() || player.isDead()
    					    || player.hasFinished() || !player.isCanPvp()
    					    || !player.withinDistance(target, 2)
    					    || !target.getControlerManager().canHit(player))
    					continue;
    				    player.applyHit(new Hit(target,
    					    (int) Utils.random((skills.getLevelForXp(Skills.PRAYER) * 25.00)),
    					    HitLook.REGULAR_DAMAGE));
    				}
    			    }
    			    List<Integer> npcsIndexes = World.getRegion(regionId).getNPCsIndexes();
    			    if (npcsIndexes != null) {
    				for (int npcIndex : npcsIndexes) {
    				    NPC npc = World.getNPCs().get(npcIndex);
    				    if (npc == null || npc.isDead() || npc.hasFinished()
    					    || !npc.withinDistance(target, 2) || !npc.getDefinitions().hasAttackOption()
    					    || !target.getControlerManager().canHit(npc))
    					continue;
    				    npc.applyHit(new Hit(target,
    					    (int) Utils.random((skills.getLevelForXp(Skills.PRAYER) * 25.00)),
    					    HitLook.REGULAR_DAMAGE));
    				}
    			    }
    			}
    
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 2, getY() + 2, getPlane()));
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() + 2, getY(), getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 2, getY() - 2, getPlane()));
    
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 2, getY() + 2, getPlane()));
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() - 2, getY(), getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 2, getY() - 2, getPlane()));
    
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX(), getY() + 2, getPlane()));
    			World.sendGraphics(target, new Graphics(2260), new WorldTile(getX(), getY() - 2, getPlane()));
    
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 1, getY() + 1, getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() + 1, getY() - 1, getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 1, getY() + 1, getPlane()));
    			World.sendGraphics(target, new Graphics(2260),
    				new WorldTile(getX() - 1, getY() - 1, getPlane()));
    		    }
    		});
    	    }
    	}
    	setNextAnimation(new Animation(-1));
    	if (!controlerManager.sendDeath())
    	    return;
    	lock(8);
    	stopAll();
    	if (familiar != null)
    	    familiar.sendDeath(this);
    	final WorldTile deathTile = new WorldTile(this);
    	WorldTasksManager.schedule(new WorldTask() {
    	    int loop;
    
    	    @Override
    	    public void run() {
    		if (loop == 0) {    
    			if (deathByFire = true){
    		    setNextAnimation(new Animation(20168));
    			setNextGraphics(new Graphics(3958));
    		    }else if (deathByWater = true){
    			    setNextAnimation(new Animation(20164));
    				setNextGraphics(new Graphics(3956));
    		    }else if (deathByAir = true){
    			    setNextAnimation(new Animation(20162));
    				setNextGraphics(new Graphics(3955));
    		    }else if (deathByEarth = true){
    			    setNextAnimation(new Animation(20166));
    				setNextGraphics(new Graphics(3957));
    		    }else{
    		    setNextAnimation(getDeathAnimation());
    		    }
    		} else if (loop == 1) {
    		    getPackets().sendGameMessage("Oh dear, you have died.");
    		} else if (loop == 3) {
    		    controlerManager.startControler("DeathEvent", deathTile, hasSkull());
    		} else if (loop == 4) {
    		    getMusicsManager().playMusicEffect(MusicsManager.DEATH_MUSIC_EFFECT);
    		    stop();
    		}
    		loop++;
    	    }
    	}, 0, 1);
        }
    
        public void sendItemsOnDeath(Player killer, boolean dropItems, boolean dropLostItems) {
    	Integer[][] slots = GraveStone.getItemSlotsKeptOnDeath(this, true, dropItems, getPrayer().isProtectingItem());
    	sendItemsOnDeath(killer, getLastWorldTile(), new WorldTile(this), true, slots, dropLostItems);
        }
    
        /*
         * default items on death, now only used for wilderness
         */
        public void sendItemsOnDeath(Player killer, boolean dropItems) {
    	sendItemsOnDeath(killer, dropItems, true);
        }
    
        /*
         * default items on death, now only used for wilderness
         */
        public void sendItemsOnDeath(Player killer) {
    	sendItemsOnDeath(killer, hasSkull());
        }
    
        public void sendItemsOnDeath(Player killer, WorldTile deathTile, WorldTile respawnTile, boolean wilderness,
    	    Integer[][] slots, boolean dropLostItems) {
    	/*
    	 * if ((((killer != null && killer.getRights() >= 2) || getRights() >=
    	 * 2) && Settings.HOSTED) || hasFinished()) return;
    	 */
    	if (Settings.HOSTED) {
    	    if (getRights() >= 2 || hasFinished())
    		return;
    	    if (killer != null) {
    		if (killer.getRights() >= 2)
    		    return;
    	    }
    	}
    
    	charges.die(slots[1], slots[3]); // degrades droped and lost items only
    	auraManager.removeAura();
    	Item[][] items = GraveStone.getItemsKeptOnDeath(this, slots);
    	inventory.reset();
    	equipment.reset();
    	appearence.generateAppearenceData();
    	for (Item item : items[0])
    	    inventory.addItemDrop(item.getId(), item.getAmount(), respawnTile);
    	if (dropLostItems) {
    	    if (items[1].length != 0) {
    		if (wilderness) {
    		    if (!isBeginningAccount())
    			for (Item item : items[1])
    			    World.addGroundItem(item, deathTile, killer == null ? this : killer, true, 60,
    				    killer == null ? 1 : 0);
    		} else
    		    new GraveStone(this, deathTile, items[1]);
    	    }
    
    	}
    	if (killer != null)
    	    Logger.globalLog(username, session.getIP(),
    		    new String(killer.getUsername() + " has killed " + username + " with the ip: "
    			    + killer.getSession().getIP() + " items are as follows:"
    			    + Arrays.toString(items[1]).replace("null,", "") + " ."));
        }
    My methods, edit them to your liking

    still not what i want im trying to make that no death event would be involved. and now when i die from npc i lose stuff but if i remove death event and i make my own respawn point i get glitched and plus in pvp still dont lose items :/
    Reply With Quote  
     

  4. #4  
    ♢♢♢♢♢♢

    Con Artist's Avatar
    Join Date
    Jan 2012
    Posts
    1,350
    Thanks given
    665
    Thanks received
    308
    Rep Power
    386
    Code:
     } else if (loop == 3) {
                        Player killer = thisPlayer;
                        if (killer != null) {
                            killer.removeDamage(thisPlayer);
                            killer.increaseKillCount(thisPlayer);
                        }
                        thisPlayer.sendItemsOnDeath(killer);
                        thisPlayer.getEquipment().init();
                        thisPlayer.getInventory().init();
                        thisPlayer.reset();
                        thisPlayer.setNextWorldTile(new WorldTile(Constants.RESPAWN_PLAYER_LOCATION));
                        thisPlayer.setNextAnimation(new Animation(-1));
                    } else if (loop == 4) {
                        getPackets().sendMusicEffect(90);
                        stop();
                    }
                    loop++;
                }
            }, 0, 1);
        }


    widdy widdy


    /|\
    / \

    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jan 2010
    Posts
    696
    Thanks given
    109
    Thanks received
    29
    Rep Power
    3
    oh god im terrible if some one can help me please add me on skype tomis_tinklas

    Quote Originally Posted by Con Artist View Post
    Code:
     } else if (loop == 3) {
                        Player killer = thisPlayer;
                        if (killer != null) {
                            killer.removeDamage(thisPlayer);
                            killer.increaseKillCount(thisPlayer);
                        }
                        thisPlayer.sendItemsOnDeath(killer);
                        thisPlayer.getEquipment().init();
                        thisPlayer.getInventory().init();
                        thisPlayer.reset();
                        thisPlayer.setNextWorldTile(new WorldTile(Constants.RESPAWN_PLAYER_LOCATION));
                        thisPlayer.setNextAnimation(new Animation(-1));
                    } else if (loop == 4) {
                        getPackets().sendMusicEffect(90);
                        stop();
                    }
                    loop++;
                }
            }, 0, 1);
        }
    gettings lots of errors with thisplayer
    Reply With Quote  
     

  6. #6  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Tomas View Post
    oh god im terrible if some one can help me please add me on skype tomis_tinklas



    gettings lots of errors with thisplayer
    This code is clean. As long as you don't copy and paste you should be fine.
    Project thread
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Jan 2010
    Posts
    696
    Thanks given
    109
    Thanks received
    29
    Rep Power
    3
    Code:
    	public void sendDeath(final Entity source) {
    		if (prayer.hasPrayersOn()
    				&& getTemporaryAttributtes().get("startedDuel") != Boolean.TRUE) {
    			if (prayer.usingPrayer(0, 22)) {
    				setNextGraphics(new Graphics(437));
    				final Player target = this;
    				if (isAtMultiArea()) {
    					for (int regionId : getMapRegionsIds()) {
    						List<Integer> playersIndexes = World
    								.getRegion(regionId).getPlayerIndexes();
    						if (playersIndexes != null) {
    							for (int playerIndex : playersIndexes) {
    								Player player = World.getPlayers().get(
    										playerIndex);
    								if (player == null
    										|| !player.hasStarted()
    										|| player.isDead()
    										|| player.hasFinished()
    										|| !player.withinDistance(this, 1)
    										|| !player.isCanPvp()
    										|| !target.getControlerManager()
    												.canHit(player))
    									continue;
    								player.applyHit(new Hit(
    										target,
    										Utils.getRandom((int) (skills
    												.getLevelForXp(Skills.PRAYER) * 2.5)),
    										HitLook.REGULAR_DAMAGE));
    							}
    						}
    						List<Integer> npcsIndexes = World.getRegion(regionId)
    								.getNPCsIndexes();
    						if (npcsIndexes != null) {
    							for (int npcIndex : npcsIndexes) {
    								NPC npc = World.getNPCs().get(npcIndex);
    								if (npc == null
    										|| npc.isDead()
    										|| npc.hasFinished()
    										|| !npc.withinDistance(this, 1)
    										|| !npc.getDefinitions()
    												.hasAttackOption()
    										|| !target.getControlerManager()
    												.canHit(npc))
    									continue;
    								npc.applyHit(new Hit(
    										target,
    										Utils.getRandom((int) (skills
    												.getLevelForXp(Skills.PRAYER) * 2.5)),
    										HitLook.REGULAR_DAMAGE));
    							}
    						}
    					}
    				} else {
    					if (source != null && source != this && !source.isDead()
    							&& !source.hasFinished()
    							&& source.withinDistance(this, 1))
    						source.applyHit(new Hit(target, Utils
    								.getRandom((int) (skills
    										.getLevelForXp(Skills.PRAYER) * 2.5)),
    								HitLook.REGULAR_DAMAGE));
    				}
    				WorldTasksManager.schedule(new WorldTask() {
    					@Override
    					public void run() {
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX() - 1, target.getY(),
    										target.getPlane()));
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX() + 1, target.getY(),
    										target.getPlane()));
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX(), target.getY() - 1,
    										target.getPlane()));
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX(), target.getY() + 1,
    										target.getPlane()));
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX() - 1,
    										target.getY() - 1, target.getPlane()));
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX() - 1,
    										target.getY() + 1, target.getPlane()));
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX() + 1,
    										target.getY() - 1, target.getPlane()));
    						World.sendGraphics(target, new Graphics(438),
    								new WorldTile(target.getX() + 1,
    										target.getY() + 1, target.getPlane()));
    					}
    				});
    			} else if (prayer.usingPrayer(1, 17)) {
    				World.sendProjectile(this, new WorldTile(getX() + 2,
    						getY() + 2, getPlane()), 2260, 24, 0, 41, 35, 30, 0);
    				World.sendProjectile(this, new WorldTile(getX() + 2, getY(),
    						getPlane()), 2260, 41, 0, 41, 35, 30, 0);
    				World.sendProjectile(this, new WorldTile(getX() + 2,
    						getY() - 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);
    
    				World.sendProjectile(this, new WorldTile(getX() - 2,
    						getY() + 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);
    				World.sendProjectile(this, new WorldTile(getX() - 2, getY(),
    						getPlane()), 2260, 41, 0, 41, 35, 30, 0);
    				World.sendProjectile(this, new WorldTile(getX() - 2,
    						getY() - 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);
    
    				World.sendProjectile(this, new WorldTile(getX(), getY() + 2,
    						getPlane()), 2260, 41, 0, 41, 35, 30, 0);
    				World.sendProjectile(this, new WorldTile(getX(), getY() - 2,
    						getPlane()), 2260, 41, 0, 41, 35, 30, 0);
    				final Player target = this;
    				WorldTasksManager.schedule(new WorldTask() {
    					@Override
    					public void run() {
    						setNextGraphics(new Graphics(2259));
    
    						if (isAtMultiArea()) {
    							for (int regionId : getMapRegionsIds()) {
    								List<Integer> playersIndexes = World.getRegion(
    										regionId).getPlayerIndexes();
    								if (playersIndexes != null) {
    									for (int playerIndex : playersIndexes) {
    										Player player = World.getPlayers().get(
    												playerIndex);
    										if (player == null
    												|| !player.hasStarted()
    												|| player.isDead()
    												|| player.hasFinished()
    												|| !player.isCanPvp()
    												|| !player.withinDistance(
    														target, 2)
    												|| !target
    														.getControlerManager()
    														.canHit(player))
    											continue;
    										player.applyHit(new Hit(
    												target,
    												Utils.getRandom((skills
    														.getLevelForXp(Skills.PRAYER) * 3)),
    												HitLook.REGULAR_DAMAGE));
    									}
    								}
    								List<Integer> npcsIndexes = World.getRegion(
    										regionId).getNPCsIndexes();
    								if (npcsIndexes != null) {
    									for (int npcIndex : npcsIndexes) {
    										NPC npc = World.getNPCs().get(npcIndex);
    										if (npc == null
    												|| npc.isDead()
    												|| npc.hasFinished()
    												|| !npc.withinDistance(target,
    														2)
    												|| !npc.getDefinitions()
    														.hasAttackOption()
    												|| !target
    														.getControlerManager()
    														.canHit(npc))
    											continue;
    										npc.applyHit(new Hit(
    												target,
    												Utils.getRandom((skills
    														.getLevelForXp(Skills.PRAYER) * 3)),
    												HitLook.REGULAR_DAMAGE));
    									}
    								}
    							}
    						} else {
    							if (source != null && source != target
    									&& !source.isDead()
    									&& !source.hasFinished()
    									&& source.withinDistance(target, 2))
    								source.applyHit(new Hit(
    										target,
    										Utils.getRandom((skills
    												.getLevelForXp(Skills.PRAYER) * 3)),
    										HitLook.REGULAR_DAMAGE));
    						}
    
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() + 2, getY() + 2,
    										getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() + 2, getY(), getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() + 2, getY() - 2,
    										getPlane()));
    
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() - 2, getY() + 2,
    										getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() - 2, getY(), getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() - 2, getY() - 2,
    										getPlane()));
    
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX(), getY() + 2, getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX(), getY() - 2, getPlane()));
    
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() + 1, getY() + 1,
    										getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() + 1, getY() - 1,
    										getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() - 1, getY() + 1,
    										getPlane()));
    						World.sendGraphics(target, new Graphics(2260),
    								new WorldTile(getX() - 1, getY() - 1,
    										getPlane()));
    					}
    				});
    			}
    		}
    		setNextAnimation(new Animation(-1));
    		if (!controlerManager.sendDeath())
    			return;
    		lock(7);
    		stopAll();
    		if (familiar != null)
    			familiar.sendDeath(this);
    		WorldTasksManager.schedule(new WorldTask() {
    			int loop;
    
    			@Override
    			public void run() {
    				int Phylactery = 25203;
    				if (getInventory().containsItem(Phylactery, 1) == false) {
    				if (loop == 0) {
    					setNextAnimation(new Animation(836));
    					getPackets().sendGameMessage("Oh dear, you have died.");
    				} else if (loop == 3) {
    					reset();
    					controlerManager.startControler("DeathEvent");
    					setNextAnimation(new Animation(-1));
    				} else if (loop == 4) {
    					getPackets().sendMusicEffect(90);
    					stop();
    				}
    				} else {
    					if (loop == 0) {
    						setNextAnimation(new Animation(17768));
    						setNextGraphics(new Graphics(3425));
    						getPackets().sendGameMessage("Oh dear, you have died.");
    					} else if (loop == 3) {
    	                 
    						Player killer = thisPlayer;
    	                    if (killer != null) {
    	                        killer.removeDamage(thisPlayer);
    	                        killer.increaseKillCount(thisPlayer);
    	                    }
    	                    thisPlayer.sendItemsOnDeath(killer);
    	                    thisPlayer.getEquipment().init();
    	                    thisPlayer.getInventory().init();
    	                    thisPlayer.reset();
    	                    thisPlayer.setNextWorldTile(new WorldTile(Settings.RESPAWN_DEATH_LOCATION));
    	                    thisPlayer.setNextAnimation(new Animation(-1));
    	                }  else if (loop == 4) {
    	                	getPackets().sendMusicEffect(90);
    	                    stop();
    					}
    				}
    				
    				loop++;
    			}
    		}, 0, 1);
    	}
    this is my sendDeath

    Code:
    	public void sendItemsOnDeath(Player killer) {
    		if (rights == 2)
    			return;
    		if (isTradeLocked())
    			return;
    		charges.die();
    		auraManager.removeAura();
    		CopyOnWriteArrayList<Item> containedItems = new CopyOnWriteArrayList<Item>();
    		for (int i = 0; i < 14; i++) {
    			if (equipment.getItem(i) != null
    					&& equipment.getItem(i).getId() != -1
    					&& equipment.getItem(i).getAmount() != -1)
    				containedItems.add(new Item(equipment.getItem(i).getId(),
    						equipment.getItem(i).getAmount()));
    		}
    		for (int i = 0; i < 28; i++) {
    			if (inventory.getItem(i) != null
    					&& inventory.getItem(i).getId() != -1
    					&& inventory.getItem(i).getAmount() != -1)
    				containedItems.add(new Item(getInventory().getItem(i).getId(),
    						getInventory().getItem(i).getAmount()));
    		}
    		if (containedItems.isEmpty())
    			return;
    		int keptAmount = 0;
    		if (!(controlerManager.getControler() instanceof CorpBeastControler)
    				&& !(controlerManager.getControler() instanceof CrucibleControler)) {
    			keptAmount = hasSkull() ? 0 : 3;
    			if (prayer.usingPrayer(0, 10) || prayer.usingPrayer(1, 0))
    				keptAmount++;
    		}
    		if (donator && Utils.random(2) == 0)
    			keptAmount += 1;
    		CopyOnWriteArrayList<Item> keptItems = new CopyOnWriteArrayList<Item>();
    		Item lastItem = new Item(1, 1);
    		for (int i = 0; i < keptAmount; i++) {
    			for (Item item : containedItems) {
    				int price = item.getDefinitions().getValue();
    				if (price >= lastItem.getDefinitions().getValue()) {
    					lastItem = item;
    				}
    			}
    			keptItems.add(lastItem);
    			containedItems.remove(lastItem);
    			lastItem = new Item(1, 1);
    		}
    		inventory.reset();
    		equipment.reset();
    		for (Item item : keptItems) {
    			if (item.getId() == -1)
    				continue;
    			getInventory().addItem(item);
    		}
    
    		for (Item item : containedItems) {
    				World.addGroundItem(item, getLastWorldTile(), killer, true, 2000000000);
    		}
    	}
    senditemsondeath
    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. Items kept on death
    By `Rich in forum Show-off
    Replies: 33
    Last Post: 02-11-2009, 12:43 AM
  2. Simple Items Kept On Death base.
    By Extea in forum Tutorials
    Replies: 10
    Last Post: 01-09-2009, 12:20 AM
  3. Items Kept on Death Strings
    By madman00901 in forum Configuration
    Replies: 8
    Last Post: 09-15-2008, 08:09 PM
  4. Add Equip Screen and Items kept on death *soooo easy*
    By knight30303 in forum Tutorials
    Replies: 13
    Last Post: 08-15-2008, 06:54 AM
  5. Items kept on death and enchant bolts
    By Aaron C. in forum Tutorials
    Replies: 7
    Last Post: 08-04-2008, 03:36 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
  •