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];
}