So I made this awhile ago when someone showed off their idea. This is my version of it.
This can stack up to 5 kills by default, you can change it with 'killsDisplayed'.
Code:
public String[] feedKiller;
public String[] feedVictim;
public int[] feedWeapon;
public boolean[] feedPoison;
public boolean[] feedCritical;
public Sprite[] feedImage;
public int[] feedAlpha;
public int[] feedYPos;
public int killsDisplayed = 5;
public void pushKill(String killer, String victim, int weapon, boolean poison, boolean critical) {
for (int index = killsDisplayed - 1; index > 0; index--) {
feedKiller[index] = feedKiller[index - 1];
feedVictim[index] = feedVictim[index - 1];
feedWeapon[index] = feedWeapon[index - 1];
feedPoison[index] = feedPoison[index - 1];
feedCritical[index] = feedCritical[index - 1];
feedAlpha[index] = feedAlpha[index - 1];
feedYPos[index] = feedYPos[index - 1];
}
feedKiller[0] = killer;
feedVictim[0] = victim;
feedWeapon[0] = weapon;
feedPoison[0] = poison;
feedCritical[0] = critical;
feedAlpha[0] = 0;
feedYPos[0] = 0;
}
public void displayKillFeed() {
int x = 5;
for (int index = 0; index < killsDisplayed; index++) {
if (feedKiller[index] != null && feedVictim[index] != null) {
if (feedKiller[index].length() > 0) {
if (feedWeapon[index] == -1) {
return;
}
if (feedKiller[index].equalsIgnoreCase(myUsername)) {
feedKiller[index] = "You";
}
if (feedVictim[index].equalsIgnoreCase(myUsername)) {
feedVictim[index] = "You";
}
if (feedYPos[index] < (index + 1) * 22) {
feedYPos[index] += 1;
if (index == 0) {
feedAlpha[index] += 256 / 22;
}
} else if (feedYPos[index] == (index + 1) * 22) {
if (feedAlpha[index] > 200) {
feedAlpha[index] -= 1;
} else if (feedAlpha[index] <= 200 && feedAlpha[index] > 0) {
feedAlpha[index] -= 5;
}
if (feedAlpha[index] < 0) {
feedAlpha[index] = 0;
}
if (feedAlpha[index] == 0) {
clearKill(index);
}
}
if (feedAlpha[index] != 0) {
String text = "[" + feedKiller[index] + "] ";
String text2 = " [" + feedVictim[index] + "]";
String poisontext = " <col=00ff00>[poisoned]</col>";
String onehittext = " <col=ff0000>[critical hit]</col>";
RSDrawingArea.drawAlphaFilledPixels(x, feedYPos[index], newSmallFont.getTextWidth(text + text2 + (feedPoison[index] ? poisontext : "") + (feedCritical[index] ? onehittext : "")) + 22, 19, 0, feedAlpha[index]);
newSmallFont.drawBasicString("<trans=" + feedAlpha[index] + ">" + text, x + 3, feedYPos[index] + 14, 0xffffff, 0);
newSmallFont.drawBasicString("<trans=" + feedAlpha[index] + ">" + text2 + (feedPoison[index] ? poisontext : "") + (feedCritical[index] ? onehittext : ""), x + 3 + newSmallFont.getTextWidth(text) + 16, feedYPos[index] + 14, 0xffffff, 0);
if (feedWeapon[index] != -1 && feedWeapon[index] != 65535) {
feedImage[index] = ItemDef.createFeedImage(feedWeapon[index], 0, 0x000000, 2);
}
if (feedImage[index] != null) {
feedImage[index].drawSprite(newSmallFont.getTextWidth(text) + 0, feedYPos[index] - 6, feedAlpha[index]);
}
}
}
}
}
}
public void clearKill(int index) {
feedKiller[index] = null;
feedVictim[index] = null;
feedWeapon[index] = -1;
feedPoison[index] = false;
feedCritical[index] = false;
feedAlpha[index] = -1;
feedYPos[index] = -1;
}
Under 'draw3dScreen();',:
This is in ItemDef.java for generating the item image:
Code:
public static Sprite createFeedImage(int id, int size, int color, int zoom) {
ItemDef item = getDef(id);
if(item.stackIDs == null) {
size = -1;
}
if(size > 1) {
int i1 = -1;
for(int j1 = 0; j1 < 10; j1++) {
if(size >= item.stackAmounts[j1] && item.stackAmounts[j1] != 0) {
i1 = item.stackIDs[j1];
}
}
if(i1 != -1) {
item = getDef(i1);
}
}
Model model = item.getModelForAmount(1);
if(model == null)
return null;
Sprite image = new Sprite(32, 32);
int k1 = Rasterizer.textureInt1;
int l1 = Rasterizer.textureInt2;
int ai[] = Rasterizer.anIntArray1472;
int ai1[] = DrawingArea.pixels;
int i2 = DrawingArea.width;
int j2 = DrawingArea.height;
int k2 = DrawingArea.startX;
int l2 = DrawingArea.endX;
int i3 = DrawingArea.startY;
int j3 = DrawingArea.endY;
Rasterizer.aBoolean1464 = false;
DrawingArea.initDrawingArea(32, 32, image.myPixels);
DrawingArea.drawPixels(32, 0, 0, 0, 32);
Rasterizer.method364();
int itemZoom = item.zoom * zoom - 500;
int l3 = Rasterizer.anIntArray1470[item.rotationX] * itemZoom >> 16;
int i4 = Rasterizer.anIntArray1471[item.rotationX] * itemZoom >> 16;
model.method482(item.rotationY, item.inventoryScale, item.rotationX, item.offsetX, l3 + model.modelHeight / 2 + item.offsetY, i4 + item.offsetY, 0);
if(color == 0) {
for(int index = 31; index >= 0; index--) {
for(int index2 = 31; index2 >= 0; index2--)
if(image.myPixels[index + index2 * 32] == 0 && index > 0 && index2 > 0 && image.myPixels[(index - 1) + (index2 - 1) * 32] > 0)
image.myPixels[index + index2 * 32] = 0x302020;
}
}
DrawingArea.initDrawingArea(i2, j2, ai1);
DrawingArea.setBounds(k2, i3, l2, j3);
Rasterizer.textureInt1 = k1;
Rasterizer.textureInt2 = l1;
Rasterizer.anIntArray1472 = ai;
Rasterizer.aBoolean1464 = true;
if (item.stackable) {
image.anInt1444 = 33;
} else {
image.anInt1444 = 32;
}
image.anInt1445 = size;
return image;
}
I use packet 173 (incoming packets) for the feed:
Code:
case 173:
try {
pushKill(in.getString(), in.getString(), in.getShort(), in.getByte() == 1, in.getByte() == 1);
} catch (Exception e) {
e.printStackTrace();
}
opCode = -1;
return true;
In SizeConstants.java you have to make the size of the packet different:
Code:
0, 3, /* 0 */ -2, /* 0 */ -2, 6, 0, 10, 6, 0, 0, // 170
And here is the server-sided packet:
Code:
public void sendKill(String killer, String victim, int weapon, boolean poison, boolean critical) {
for (int index = 0; index < Constants.MAX_PLAYERS; index++) {
if (PlayerHandler.players[index] != null) {
Client p = (Client) PlayerHandler.players[index];
if (p.getOut() != null && p != null) {
//if (p.inWild()) {
p.getOut().createFrameVarSizeWord(173);
p.getOut().putString(killer);
p.getOut().putString(victim);
p.getOut().putShort(weapon);
p.getOut().putByte(poison ? 1 : 0);
p.getOut().putByte(critical ? 1 : 0);
p.getOut().endFrameVarSizeWord();
//}
}
}
}
}