Thread: Wilderness Feed/Kill Feed

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35
  1. #1 Wilderness Feed/Kill Feed 
    Retired. Stop PMing me.


    Galkon's Avatar
    Join Date
    Nov 2007
    Age
    17
    Posts
    7,526
    Thanks given
    1,805
    Thanks received
    2,830
    Rep Power
    5000
    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();',:
    Code:
    		displayKillFeed();
    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();
    					//}
    				}
    			}
    		}
    	}
    Attached image
    Reply With Quote  
     


  2. #2  
    Registered Member
    Join Date
    Feb 2008
    Posts
    2,084
    Thanks given
    1,908
    Thanks received
    1,053
    Rep Power
    5000
    Awesome as always, Galkon.





















    First.
    Reply With Quote  
     

  3. #3  
    Respected Member

    Revil's Avatar
    Join Date
    Nov 2010
    Age
    30
    Posts
    4,860
    Thanks given
    3,715
    Thanks received
    2,228
    Rep Power
    5000
    Holy Shit! Yay More rep for you! I love it when you start releasing, first the chatline splitting now this. Keep em coming
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Aug 2008
    Posts
    2,418
    Thanks given
    721
    Thanks received
    595
    Rep Power
    1220
    sweet
    Reply With Quote  
     

  5. #5  
    Registered Member
    Wiffles's Avatar
    Join Date
    Dec 2007
    Posts
    1,168
    Thanks given
    100
    Thanks received
    198
    Rep Power
    493
    Awesome, I still have no idea why nobody else has shown this before.
    Reply With Quote  
     

  6. #6  
    Fuckin PRO

    Damien's Avatar
    Join Date
    Feb 2008
    Age
    32
    Posts
    2,658
    Thanks given
    928
    Thanks received
    82
    Rep Power
    369
    Very nice Galkon
    Reply With Quote  
     

  7. #7  
    Super Donator


    Join Date
    Sep 2011
    Posts
    1,446
    Thanks given
    138
    Thanks received
    284
    Rep Power
    260
    errors
    Reply With Quote  
     

  8. #8  
    Registered Member
    Wiffles's Avatar
    Join Date
    Dec 2007
    Posts
    1,168
    Thanks given
    100
    Thanks received
    198
    Rep Power
    493
    Galkon, could you please explain the packet sizes and how they work? Thanks so much.
    Reply With Quote  
     

  9. #9  
    Retired. Stop PMing me.


    Galkon's Avatar
    Join Date
    Nov 2007
    Age
    17
    Posts
    7,526
    Thanks given
    1,805
    Thanks received
    2,830
    Rep Power
    5000
    Quote Originally Posted by Dane View Post
    Galkon, could you please explain the packet sizes and how they work? Thanks so much.
    It all depends on the amount of data and the type of data being sent.

    Code:
    byte = 1
    short = 2
    int = 4
    float = 4 (not sure? it's 32bits iirc so 32/8 = 4)
    double = 8
    long = 8
    So let's say you're sending a packet with 2 shorts and a byte. The size is 5 because two shorts = 4 and one byte = 1.
    Last edited by Galkon; 04-04-2012 at 07:40 AM.
    Attached image
    Reply With Quote  
     

  10. Thankful users:


  11. #10  
    Registered Member
    Wiffles's Avatar
    Join Date
    Dec 2007
    Posts
    1,168
    Thanks given
    100
    Thanks received
    198
    Rep Power
    493
    Quote Originally Posted by Galkon View Post
    It all depends on the amount of data and the type of data being sent.

    Code:
    byte = 1
    short = 2
    int = 4
    long = 8
    So let's say you're sending a packet with 2 shorts and a byte. The size is 5 because two shorts = 4 and one byte = 1.
    Oh wow it's that simple? Thanks a bunch.
    Reply With Quote  
     

  12. Thankful user:


Page 1 of 4 123 ... LastLast

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. Kill Feed
    By Benji in forum Snippets
    Replies: 15
    Last Post: 11-28-2011, 12:01 AM
  2. Wilderness Feed
    By Galkon in forum Show-off
    Replies: 43
    Last Post: 11-25-2011, 08:33 AM
  3. Kill Feed + Accolades - RS/Combat Arms
    By Benji in forum Show-off
    Replies: 34
    Last Post: 11-10-2011, 02:32 AM
  4. Feed Me
    By 42 in forum Chat
    Replies: 8
    Last Post: 05-01-2008, 08:25 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
  •