Items dropped on death[508]
Description: drops Players items on death.
Difficulty: 0/10?
Assumed Knowledge: Copy and paste.
Tested Server: Palidino76's 508
Files/Classes Modified: Player.java Frames.java
Procedure
open your Frames.java
make sure you are importing these two at the top of Frames.java:
Code:
import palidino76.rs2.players.items.PlayerWeapon;
import palidino76.rs2.players.items.PlayerItems;
then find:
Code:
public void setOverlay(Player p, int childId) {
setInterface(p, 1, 548, 5, childId);
}
and under that add:
Code:
/**
* Remove Player Equipment
*@param p The player which the frame should be created for.
*@param index the index of the player
*/
public void removeEquipment(Player p, int itemId, int index)
{
if(p == null || itemId <= 0 || index < 0 || index > 12 || p.stream == null)
{
return;
}
PlayerItems pi = new PlayerItems();
if(!pi.addItem(p, p.equipment[index], p.equipmentN[index]))
{
sendMessage(p, "Not enough space in your inventory.");
return;
}
p.equipment[index] = -1;
p.equipmentN[index] = -1;
p.stream.createFrameVarSizeWord(135);
p.stream.writeByte(1);
p.stream.writeByte(131);
p.stream.writeByte(0);
p.stream.writeByte(28);
p.stream.writeWord(28);
p.stream.writeByte(index);
p.stream.writeWord(0);
p.stream.writeByte(0);
p.stream.endFrameVarSizeWord();
p.appearanceUpdateReq = true;
p.updateReq = true;
p.calculateEquipmentBonus();
pi = null;
PlayerWeapon pweapon = new PlayerWeapon(p);
pweapon.setWeapon();
pweapon = null;
}
thanks to Sir Pk p00n (with a litte additions by me :))
then open player.java
make sure you are importing these two at the top of Player.java:
Code:
import palidino76.rs2.players.items.PlayerWeapon;
import palidino76.rs2.players.items.PlayerItems;
find:
Code:
public int absY = 0;
and under that add:
Code:
/**
* KilledBy.
*/
public int[] killedBy = new int[Engine.players.length];
then find:
Code:
public void requestForceChat(String s) {
forceChat = s;
forceChatUpdateReq = true;
updateReq = true;
}
and under that add:
Code:
public void dropAllItems(int playerGetId)
{
if(playerGetId <= 0 || Engine.players[playerGetId] == null)
{
playerGetId = playerId;
}
Player p2 = Engine.players[playerGetId];
PlayerItems pi = new PlayerItems();
if(playerGetId != playerId)
{
p2.frames.sendMessage(p2, username + " regrets the day they met you in combat.");
}
Engine.items.createGroundItem(526, 1, absX, absY, heightLevel, p2.username);
for(int i = 0; i < items.length; i++)
{
if(items[i] > 0)
{
if(Engine.items.isUntradable((items[i])))
{
Engine.items.createGroundItem(items[i], itemsN[i], absX, absY, heightLevel, username);
Engine.playerItems.deleteItem(this, items[i], pi.getItemSlot(this, items[i]), itemsN[i]);
}
else
{
Engine.items.createGroundItem(items[i], itemsN[i], absX, absY, heightLevel, p2.username);
Engine.playerItems.deleteItem(this, items[i], pi.getItemSlot(this, items[i]), itemsN[i]);
}
}
}
for(int i = 0; i < equipment.length; i++)
{
if(equipment[i] > 0)
{
frames.removeEquipment(this, equipment[i], i);
if(Engine.items.isUntradable((items[0])))
{
Engine.items.createGroundItem(items[0], itemsN[0], absX, absY, heightLevel, username);
Engine.playerItems.deleteItem(this, items[0], pi.getItemSlot(this, items[0]), itemsN[0]);
}
else
{
Engine.items.createGroundItem(items[0], itemsN[0], absX, absY, heightLevel, p2.username);
Engine.playerItems.deleteItem(this, items[0], pi.getItemSlot(this, items[0]), itemsN[0]);
}
}
}
pi = null;
}
then under that void add this int
Code:
public int getPlayerKiller()
{
int Killer = 0;
int Count = 0;
for(int i = 1; i < Engine.players.length; i++)
{
if(Killer == 0)
{
Killer = i;
Count = 1;
}
else
{
if(killedBy[i] > killedBy[Killer])
{
Killer = i;
Count = 1;
}
else if(killedBy[i] == killedBy[Killer])
Count++;
}
}
if(Count > 1)
Killer = playerId;
return Killer;
}
then find your deathDelay (what ever the case maybe) and add this
Code:
dropAllItems(getPlayerKiller());
example of mine
Code:
if(deathDelay <= 0)
{
dropAllItems(getPlayerKiller());
frames.sendMessage(this, "Oh dear you are dead!");
isDead = false;
pkIcon = -1;
teleportToX = 3222;
teleportToY = 3222;
for(int i = 0; i < skillLvl.length; i++)
{
skillLvl[i] = getLevelForXP(i);
frames.setSkillLvl(this, i);
}
canWalkDelay = 0;
subtractDamage(999999);
requestAnim(-1, 0);
updateReq = true;
appearanceUpdateReq = true;
}
}
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
save and compile, that should be it, all done, post here I will be happy to help.
creds to Sir Pk P00n for the remove equipment
creds to pali for the base as always and um anyone else i forgot lol for some reason or the other
EDIT: This changes the time which ground items appear on the floor..
go to palidino76.src.world.items.item.java:
find:
Code:
(g.itemGroundTime == 60)
change the 60 to 220 - since the overall time for the ground item is 240, this means the item will take the difference to appear which would be 20, and it will be on the ground for 220
then find:
Code:
(g.itemGroundTime <= 60
change the 60 to 220 aswell - this is the amount of time before the player can actually pick up the item.
if you want to find the overall timer...its located in groundItem.java as
Code:
public int itemGroundTime = 240;
but i dont recommend changing this
the timer might be a little fast....change it to your desire....