Thread: Improved GraphicsHandler

Results 1 to 7 of 7
  1. #1 Improved GraphicsHandler 
    Diablo1123
    Guest
    Change your GraphicsHandler to this
    Code:
    import java.io.*;
    
    public class GraphicsHandler {
    	public static int timer = 0;
    	public static void createProjectile(int casterY, int casterX, int offsetY, int offsetX, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int MageAttackIndex) {
    		int calcX = 0;
    		int calcY = 0;
    		for (int i = 0; i < PlayerHandler.maxPlayers; i++) {
    			if (PlayerHandler.players[i] != null) {
    				client c = (client)PlayerHandler.players[i];
    				calcX = casterX - c.absX;
    				calcY = casterY - c.absY;
    				if (calcX >= -16 && calcX <= 15 && calcY >= -16 && calcY <= 15) {
    					c.outStream.createFrame(85);
    					c.outStream.writeByteC((casterY - (c.mapRegionY * 8)) - 2);
    					c.outStream.writeByteC((casterX - (c.mapRegionX * 8)) - 3);
    					c.outStream.createFrame(117);
    					c.outStream.writeByte(angle); 
    					c.outStream.writeByte(offsetY);
    					c.outStream.writeByte(offsetX);
    					c.outStream.writeWord(MageAttackIndex);
    					c.outStream.writeWord(gfxMoving); 
    					c.outStream.writeByte(startHeight); 
    					c.outStream.writeByte(endHeight);
    					c.outStream.writeWord(51); 
    					c.outStream.writeWord(speed);
    					c.outStream.writeByte(16);
    					c.outStream.writeByte(64);
    				}
    			}
    		}
    	}
    	public static void StillGFX(int X, int Y, int ID, int Height){
    		int calcX = 0;
    		int calcY = 0;
    		for (int i = 0; i < PlayerHandler.maxPlayers; i++) {
    			if (PlayerHandler.players[i] != null) {
    				client c = (client)PlayerHandler.players[i];
    				calcX = X - c.absX;
    				calcY = Y - c.absY;
    				if (calcX >= -16 && calcX <= 15 && calcY >= -16 && calcY <= 15 && c.heightLevel == Height) {
    					c.outStream.createFrame(85);
    					c.outStream.writeByteC(Y - (c.mapRegionY * 8));
    					c.outStream.writeByteC(X - (c.mapRegionX * 8));
    					c.outStream.createFrame(4);
    					c.outStream.writeByte(0);//Tiles away (X >> 4 + Y & 7)
    					c.outStream.writeWord(ID);//Graphic id
    					c.outStream.writeByte(100);//height of the spell above it's basic place, i think it's written in pixels 100 pixels higher
    					c.outStream.writeWord(0);//Time before casting the graphic
    				}
    			}
    		}
    	}
    	public static void AttackNPC(int npcID, int playerId, int damage, int exp, int startID, int movegfxID, int endgfx){
    		StillGFX(PlayerHandler.players[playerId].absX, PlayerHandler.players[playerId].absY, startID, PlayerHandler.players[playerId].heightLevel);
    		int till = timer + 4;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		while (till != timer);
    		int offsetY = (PlayerHandler.players[playerId].absY - NPCHandler.npcs[npcID].absY) * -1;
    		int offsetX = (PlayerHandler.players[playerId].absX - NPCHandler.npcs[npcID].absX) * -1;
    		createProjectile(PlayerHandler.players[playerId].absY, PlayerHandler.players[playerId].absX, offsetX, offsetY, 50, 90, movegfxID, 100, 100, npcID);
    		till = timer + 8;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		int hitDiff = damage;
    		int EnemyHP = NPCHandler.npcs[npcID].HP;
    		if ((EnemyHP - hitDiff) < 0) {
    			hitDiff = EnemyHP;
    		}
    		NPCHandler.npcs[npcID].hitDiff += hitDiff;
    		NPCHandler.npcs[npcID].Killing[playerId] += hitDiff;
    		NPCHandler.npcs[npcID].updateRequired = true;
    		NPCHandler.npcs[npcID].hitUpdateRequired = true;
    		((client)PlayerHandler.players[playerId]).addSkillXP(exp, 6);
    		StillGFX(NPCHandler.npcs[npcID].absX, NPCHandler.npcs[npcID].absY, endgfx,PlayerHandler.players[playerId].heightLevel);
    	}
    	public static void AttackPlayer(int attackedID, int playerId, int damage, int exp, int startID, int movegfxID, int endgfx){
    		StillGFX(PlayerHandler.players[playerId].absX, PlayerHandler.players[playerId].absY,startID, PlayerHandler.players[playerId].heightLevel);
    		int till = timer + 4;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		while (till != timer);
    		int offsetY = (PlayerHandler.players[playerId].absY - PlayerHandler.players[attackedID].absY) * -1;
    		int offsetX = (PlayerHandler.players[playerId].absX - PlayerHandler.players[attackedID].absX) * -1;
    		createProjectile(PlayerHandler.players[playerId].absY, PlayerHandler.players[playerId].absX, offsetX, offsetY, 50, 90, movegfxID, 100, 100, attackedID * -1);
    		till = timer + 8;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		int hitDiff = damage;
    		int EnemyHP = PlayerHandler.players[attackedID].playerLevel[3];
    		PlayerHandler.players[attackedID].hitUpdateRequired = true;
    		PlayerHandler.players[attackedID].updateRequired = true;
    		PlayerHandler.players[attackedID].appearanceUpdateRequired = true;
    		if ((EnemyHP - hitDiff) < 0) {
    			hitDiff = EnemyHP;
    		}
    		PlayerHandler.players[attackedID].hitDiff += hitDiff;
    		((client)PlayerHandler.players[playerId]).addSkillXP(exp, 6);
    		StillGFX(PlayerHandler.players[attackedID].absX, PlayerHandler.players[attackedID].absY, endgfx, PlayerHandler.players[playerId].heightLevel);
    	}
    	public static void process(){
    		timer++;
    		if (timer > 1000) {
    			timer -= 1000;
    		}
    	}
    }
    Everything there is self explanatory.

    Make sure you go to server.java and add GraphicsHandler.process(); under PlayerHandler.process();
     

  2. #2  
    project-rs owner
    Join Date
    Sep 2006
    Age
    29
    Posts
    914
    Thanks given
    4
    Thanks received
    4
    Rep Power
    49
    thanks will try it now

    edit: i get this errors
    Code:
    \project-new\project-rs\GraphicsHandler.java:61: non-static variable npcs cannot be referenced from a static context
    		int offsetY = (PlayerHandler.players[playerId].absY - NPCHandler.npcs[npcID].absY) * -1;
                                                                                    ^
    D:\project-new\project-rs\GraphicsHandler.java:62: non-static variable npcs cannot be referenced from a static context
    		int offsetX = (PlayerHandler.players[playerId].absX - NPCHandler.npcs[npcID].absX) * -1;
                                                                                    ^
    D:\project-new\project-rs\GraphicsHandler.java:69: non-static variable npcs cannot be referenced from a static context
    		int EnemyHP = NPCHandler.npcs[npcID].HP;
                                            ^
    D:\project-new\project-rs\GraphicsHandler.java:73: non-static variable npcs cannot be referenced from a static context
    		NPCHandler.npcs[npcID].hitDiff += hitDiff;
                              ^
    D:\project-new\project-rs\GraphicsHandler.java:74: non-static variable npcs cannot be referenced from a static context
    		NPCHandler.npcs[npcID].Killing[playerId] += hitDiff;
                              ^
    D:\project-new\project-rs\GraphicsHandler.java:75: non-static variable npcs cannot be referenced from a static context
    		NPCHandler.npcs[npcID].updateRequired = true;
                              ^
    D:\project-new\project-rs\GraphicsHandler.java:76: non-static variable npcs cannot be referenced from a static context
    		NPCHandler.npcs[npcID].hitUpdateRequired = true;
                              ^
    D:\project-new\project-rs\GraphicsHandler.java:78: non-static variable npcs cannot be referenced from a static context
    		StillGFX(NPCHandler.npcs[npcID].absX, NPCHandler.npcs[npcID].absY, endgfx,PlayerHandler.players[playerId].heightLevel);
                                       ^
    D:\project-new\project-rs\GraphicsHandler.java:78: non-static variable npcs cannot be referenced from a static context
    		StillGFX(NPCHandler.npcs[npcID].absX, NPCHandler.npcs[npcID].absY, endgfx,PlayerHandler.players[playerId].heightLevel);
                                                                    ^
    9 errors
     

  3. #3  
    Diablo1123
    Guest
    You need to make all your handlers static
    like in hybridscape
     

  4. #4  
    Pandora
    Guest
    what does change if we should use ur gfx handler?
     

  5. #5  
    Zenzie
    Guest
    I think its useless .. Except when you delete the same stuff out of your client
     

  6. #6  
    Community Veteran


    Join Date
    Oct 2006
    Posts
    451
    Thanks given
    5
    Thanks received
    1
    Discord
    View profile
    Rep Power
    137
    I fixed it to work with my server which is based off of Project16 V6, first find this in NPCHandler.java:

    Code:
    public NPC npcs[] = new NPC[maxNPCs];
    Make that static:

    Code:
    public static NPC npcs[] = new NPC[maxNPCs];
    Then replace your GraphicsHandler.java with this:

    Code:
    import java.io.*;
    
    public class GraphicsHandler {
    	public static int timer = 0;
    	public static void createProjectile(int casterY, int casterX, int offsetY, int offsetX, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int MageAttackIndex) {
    		int calcX = 0;
    		int calcY = 0;
    		for (int i = 0; i < PlayerHandler.maxPlayers; i++) {
    			if (PlayerHandler.players[i] != null) {
    				client c = (client)PlayerHandler.players[i];
    				calcX = casterX - c.absX;
    				calcY = casterY - c.absY;
    				if (calcX >= -16 && calcX <= 15 && calcY >= -16 && calcY <= 15) {
    					c.outStream.createFrame(85);
    					c.outStream.writeByteC((casterY - (c.mapRegionY * 8)) - 2);
    					c.outStream.writeByteC((casterX - (c.mapRegionX * 8)) - 3);
    					c.outStream.createFrame(117);
    					c.outStream.writeByte(angle);
    					c.outStream.writeByte(offsetY);
    					c.outStream.writeByte(offsetX);
    					c.outStream.writeWord(MageAttackIndex);
    					c.outStream.writeWord(gfxMoving);
    					c.outStream.writeByte(startHeight);
    					c.outStream.writeByte(endHeight);
    					c.outStream.writeWord(51);
    					c.outStream.writeWord(speed);
    					c.outStream.writeByte(16);
    					c.outStream.writeByte(64);
    				}
    			}
    		}
    	}
    public static void createSpell(int castId, int casterY, int casterX, int offsetY, int offsetX, int angle, int speed, int movegfxID,int startHeight, int endHeight, int finishID, int enemyY, int enemyX, int MageAttackIndex) {
    for (Player p : server.playerHandler.players) {
    	if(p != null)  {
    		client person = (client)p;
    		if(person.playerName != null || person.playerName != "null")
    			//if(person.distanceToPoint(enemyY, enemyX) <= 60)
    				person.firespell(castId, casterY, casterX, offsetY, offsetX, angle, speed, movegfxID, startHeight, endHeight, finishID, enemyY, enemyX, MageAttackIndex);}
    	}
    }
    public static void removeGFX(int castId, int enemyX, int enemyY) {
    	for (int i = 0; i <= 5000; i++)  {
    		if(GFXspot[i] == castId && targetX[i] == enemyX && targetY[i] == enemyY) {
    		GFXspot[i] = 0;
    		castID[i] = 0;
    		moveID[i] = 0;
    		endID[i] = 0;
    		gfxX[i] = 0;
    		gfxY[i] = 0;
    		offX[i] = 0;
    		offY[i] = 0;
    		gfxA[i] = 0;
    		gfxS[i] = 0;
    		gfxSH[i] = 0;
    		gfxFH[i] = 0;
    		targetX[i] = 0;
    		targetY[i] = 0;
    		lockOn[i] = 0; //-1
    		}
    	}
    }
    	public static void StillGFX(int X, int Y, int ID, int Height){
    		int calcX = 0;
    		int calcY = 0;
    		for (int i = 0; i < PlayerHandler.maxPlayers; i++) {
    			if (PlayerHandler.players[i] != null) {
    				client c = (client)PlayerHandler.players[i];
    				calcX = X - c.absX;
    				calcY = Y - c.absY;
    				if (calcX >= -16 && calcX <= 15 && calcY >= -16 && calcY <= 15 && c.heightLevel == Height) {
    					c.outStream.createFrame(85);
    					c.outStream.writeByteC(Y - (c.mapRegionY * 8));
    					c.outStream.writeByteC(X - (c.mapRegionX * 8));
    					c.outStream.createFrame(4);
    					c.outStream.writeByte(0);//Tiles away (X >> 4 + Y & 7)
    					c.outStream.writeWord(ID);//Graphic id
    					c.outStream.writeByte(100);//height of the spell above it's basic place, i think it's written in pixels 100 pixels higher
    					c.outStream.writeWord(0);//Time before casting the graphic
    				}
    			}
    		}
    	}
    	public static void AttackNPC(int npcID, int playerId, int damage, int exp, int startID, int movegfxID, int endgfx){
    		StillGFX(PlayerHandler.players[playerId].absX, PlayerHandler.players[playerId].absY, startID, PlayerHandler.players[playerId].heightLevel);
    		int till = timer + 4;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		while (till != timer);
    		int offsetY = (PlayerHandler.players[playerId].absY - NPCHandler.npcs[npcID].absY) * -1;
    		int offsetX = (PlayerHandler.players[playerId].absX - NPCHandler.npcs[npcID].absX) * -1;
    		createProjectile(PlayerHandler.players[playerId].absY, PlayerHandler.players[playerId].absX, offsetX, offsetY, 50, 90, movegfxID, 100, 100, npcID);
    		till = timer + 8;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		int hitDiff = damage;
    		int EnemyHP = NPCHandler.npcs[npcID].HP;
    		if ((EnemyHP - hitDiff) < 0) {
    			hitDiff = EnemyHP;
    		}
    		NPCHandler.npcs[npcID].hitDiff += hitDiff;
    		NPCHandler.npcs[npcID].Killing[playerId] += hitDiff;
    		NPCHandler.npcs[npcID].updateRequired = true;
    		NPCHandler.npcs[npcID].hitUpdateRequired = true;
    		((client)PlayerHandler.players[playerId]).addSkillXP(exp, 6);
    		StillGFX(NPCHandler.npcs[npcID].absX, NPCHandler.npcs[npcID].absY, endgfx,PlayerHandler.players[playerId].heightLevel);
    	}
    	public static void AttackPlayer(int attackedID, int playerId, int damage, int exp, int startID, int movegfxID, int endgfx){
    		StillGFX(PlayerHandler.players[playerId].absX, PlayerHandler.players[playerId].absY,startID, PlayerHandler.players[playerId].heightLevel);
    		int till = timer + 4;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		while (till != timer);
    		int offsetY = (PlayerHandler.players[playerId].absY - PlayerHandler.players[attackedID].absY) * -1;
    		int offsetX = (PlayerHandler.players[playerId].absX - PlayerHandler.players[attackedID].absX) * -1;
    		createProjectile(PlayerHandler.players[playerId].absY, PlayerHandler.players[playerId].absX, offsetX, offsetY, 50, 90, movegfxID, 100, 100, attackedID * -1);
    		till = timer + 8;
    		if (till > 1000) {
    			till -= 1000;
    		}
    		int hitDiff = damage;
    		int EnemyHP = PlayerHandler.players[attackedID].playerLevel[3];
    		PlayerHandler.players[attackedID].hitUpdateRequired = true;
    		PlayerHandler.players[attackedID].updateRequired = true;
    		PlayerHandler.players[attackedID].appearanceUpdateRequired = true;
    		if ((EnemyHP - hitDiff) < 0) {
    			hitDiff = EnemyHP;
    		}
    		PlayerHandler.players[attackedID].hitDiff += hitDiff;
    		((client)PlayerHandler.players[playerId]).addSkillXP(exp, 6);
    		StillGFX(PlayerHandler.players[attackedID].absX, PlayerHandler.players[attackedID].absY, endgfx, PlayerHandler.players[playerId].heightLevel);
    	}
    	public static void process(){
    		timer++;
    		if (timer > 1000) {
    			timer -= 1000;
    		}
    	}
    	public static int[] GFXspot = new int[5001];
    	public static int[] castID = new int[5001];
    	public static int[] moveID = new int[5001];
    	public static int[] endID = new int[5001];
    	public static int[] gfxX = new int[5001];
    	public static int[] gfxY = new int[5001];
    	public static int[] offX = new int[5001];
    	public static int[] offY = new int[5001];
    	public static int[] gfxA = new int[5001];
    	public static int[] gfxS = new int[5001];
    	public static int[] gfxSH = new int[5001];
    	public static int[] gfxFH = new int[5001];
    	public static int[] targetX = new int[5001];
    	public static int[] targetY = new int[5001];
    	public static int[] lockOn = new int[5001];
    }
    Est. 2006
     

  7. #7  
    project-rs owner
    Join Date
    Sep 2006
    Age
    29
    Posts
    914
    Thanks given
    4
    Thanks received
    4
    Rep Power
    49
    thanks guthan and diablo but does any of you know why it misses the npc?
    is there a fix for it?
    i mean the big ones the regular works
    but kaphite worker it misses it
     


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. Improved PI Mining
    By Xynth in forum Snippets
    Replies: 20
    Last Post: 07-24-2012, 06:39 PM
  2. Improved PI Woodcutting
    By Xynth in forum Snippets
    Replies: 18
    Last Post: 10-22-2011, 10:30 PM
  3. Distortion V3 (Better and much more improved)
    By Dimitri in forum Advertise
    Replies: 45
    Last Post: 03-03-2010, 09:47 PM
  4. Could this be improved?
    By Brown in forum RS2 Server
    Replies: 3
    Last Post: 11-26-2009, 07:03 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
  •