Thread: Allstar X - MagicHandler.java

Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1 Allstar X - MagicHandler.java 
    Donator

    Robgob69's Avatar
    Join Date
    Oct 2010
    Age
    30
    Posts
    749
    Thanks given
    71
    Thanks received
    139
    Discord
    View profile
    Rep Power
    117
    Soo Ive been working on fixing up an old Allstarscape server, into something new, something fun. And so far its great. No more of those stupid glitches and bugs well everything.. All that is left is to rewrite the NpcHandler, and werite networking. Add in some new quests and mini games.

    This is my MagicHandler. it has all spells except multi barage, and Lunar. It will be updated more too, Im going to make a class container for the spells - call it Spell.java or something
    I origionally posted this on silabsoft, but this is a more updated version.
    And I'm new to this comunity.. So be gentle ;]

    What do you think?

    Code:
    package Server.Player.Combat;
    
    
    import Server.*;
    import Server.Player.*;
    import Server.Npc.*;
    import Server.World.Misc.*;
    import Server.World.*;
    import Server.Util.*;
    
    
    public class MagicHandler {
    
    	private client c;
    
    	public MagicHandler(client cl) {
    		this.c = cl;
    	}
    
    	// The number for the spells :D
    
    	/* WARNING!!: Do NOT change the Spell ids in these finals
    	 * it can mess up the whole magic handler. To change one thing
    	 * you would then have to chage everything that has to do with
    	 * the spell ID's and their order!! So play it safe and leave
    	 * it as is!! :/
    	*/
    
    	public final static int WIND_STRIKE = 0,
    		CONFUSE_TARGET = 1,
    		WATER_STRIKE = 2,
    		ENCHANT_ITEM_ONE = 3,
    		EARTH_STRIKE = 4,
    		WEAKEN_TARGET = 5,
    		FIRE_STRIKE = 6,
    		BONES_TO_BANANAS = 7,
    		WIND_BOLT = 8,
    		CURSE_TARGET = 9,
    		BIND_TARGET = 10,
    		LOW_LEVEL_ALCHEMY = 11,
    		WATER_BOLT = 12,
    		VARROCK_TELEPORT = 13,
    		ENCHANT_ITEM_TWO = 14,
    		EARTH_BOLT = 15,
    		LUMBRIDGE_TELEPORT = 16,
    		TELEKINETIC_GRAB = 17,
    		FIRE_BOLT = 18,
    		FALADOR_TELEPORT = 19,
    		CRUMBLE_UNDEAD = 20,
    		WIND_BLAST = 21,
    		SUPERHEAT_ITEM = 22,
    		CAMELOT_TELEPORT = 23,
    		WATER_BLAST = 24,
    		ENCHANT_ITEM_THREE = 25,
    		IBAN_BLAST = 26,
    		SNARE_TARGET = 27,
    		MAGIC_DART = 28,
    		ARDOUGNE_TELEPORT = 29,
    		EARTH_BLAST = 30,
    		HIGH_LEVEL_ALCHEMY = 31,
    		CHARGE_WATER_ORB = 32,
    		ENCHANT_ITEM_FOUR = 33,
    		WATCHTOWER_TELEPORT = 34,
    		FIRE_BLAST = 35,
    		CHARGE_EARTH_ORB = 36,
    		BONES_TO_PEACHES = 37,
    		SARADOMIN_STRIKE = 38,
    		CLAWS_OF_GUTHIX = 39,
    		FLAMES_OF_ZAMORAK = 40,
    		TROLLHEIM_TELEPORT = 41,
    		WIND_WAVE = 42,
    		CHARGE_FIRE_ORB = 43,
    		APE_ATOLL_TELEPORT = 44,
    		WATER_WAVE = 45,
    		CHARGE_AIR_ORB = 46,
    		VULNERABILITY_ON_TARGET = 47,
    		ENCHANT_ITEM_FIVE = 48,
    		EARTH_WAVE = 49,
    		ENFEEBLE_ON_TARGET = 50,
    		TELEOTHER_LUMBRIDGE = 51,
    		FIRE_WAVE = 52,
    		ENTANGLE_TARGET = 53,
    		STUN_TARGET = 54,
    		CHARGE_SPELLS = 55,
    		TELEOTHER_FALADOR = 56,
    		TELE_BLOCK = 57,
    		ENCHANT_ITEM_SIX = 58,
    		TELEOTHER_CAMELOT = 59,
    		SMOKE_RUSH = 60, // Ancient Magicks! :D
    		SHADOW_RUSH = 61,
    		PADDEWWA_TELEPORT = 62,
    		BLOOD_RUSH = 63,
    		ICE_RUSH = 64,
    		SENNTISTEN_TELEPORT = 65,
    		SMOKE_BURST = 66,
    		SHADOW_BURST = 67,
    		KHARYRLL_TELEPORT = 68,
    		BLOOD_BURST = 69,
    		ICE_BURST = 70,
    		LASSAR_TELEPORT = 71,
    		SMOKE_BLITZ = 72,
    		SHADOW_BLITZ = 73,
    		DAREEYAK_TELEPORT = 74,
    		BLOOD_BLITZ = 75,
    		ICE_BLITZ = 76,
    		CARRALLANGAR_TELEPORT = 77,
    		SMOKE_BARRAGE = 78,
    		SHADOW_BARRAGE = 79,
    		ANNAKARL_TELEPORT = 80,
    		BLOOD_BARRAGE = 81,
    		ICE_BARRAGE = 82,
    		GHORROCK_TELEPORT = 83;
    
    	// The ID for the required runes you need to perform the spell
    
    	public final int[][] REQUIRED_RUNES = {
    		{556,558}, // Wind Strike
    		{555,557,559}, // Confuse
    		{555,556,558}, // waterstrike
    		{555,564}, // lvl1 enchant
    		{557,556,558}, // earth strike
    		{555,557,559}, // weaken
    		{554,556,558}, // fire strike
    		{557,555,561}, // bones to bananas
    		{556,562}, // wind bolt
    		{555,557,559}, // Curse
    		{557,555,561}, // Bind
    		{554,561}, // Low alche
    		{555,556,562}, // water bolt
    		{554,556,563}, // varrock tele
    		{556,564}, // lvl2 enchant
    		{557,556,562}, // earth bolt
    		{557,556,563}, // lumby tele
    		{556,563}, // tele grab
    		{554,556,562}, // fire bolt
    		{555,556,563}, // falidor tele
    		{557,556,562}, // crumble undead
    		{556,560}, // wind blast
    		{554,561}, // superheat item
    		{556,563}, // camelot tele
    		{555,556,560}, // water bolt
    		{554,564}, // lvl3 enchant
    		{554,560}, // iban blast
    		{557,555,561}, // snare
    		{560,558}, // magic dart
    		{555,563}, // Ardougne tele
    		{557,556,560}, // earth blast
    		{554,561}, // high alche
    		{555,564,567}, // charge water orb
    		{557,564}, // lvl4 enchant
    		{557,563}, // Watchtower tele
    		{554,556,560}, // fire blast
    		{557,564,567}, // charge earth orb
    		{561,555,557}, // bones to peaches
    		{554,565,556}, // Saradomin strike
    		{554,565,556}, // claws of guthix
    		{554,565,556}, // flames of zamorak
    		{554,563}, // Trollheim tele
    		{556,565}, // wind wave
    		{554,564,567}, // charge fire orb
    		{554,555,563,1963}, // ape atoll tele
    		{555,556,565}, // water wave
    		{556,564,567}, // charge air orb
    		{557,555,566}, // vulberability
    		{555,557,564}, // lvl5 enchant
    		{557,556,565}, // earth wave
    		{557,555,566}, // enfeeble
    		{566,563,557}, // teleother lumby
    		{554,556,565}, // fire wave
    		{557,555,561}, // entangle
    		{557,555,566}, // stun
    		{554,565,556}, // charge
    		{566,563,555}, // teleother falador
    		{563,562,560}, // tele block
    		{557,554,564}, // lvl6 enchant
    		{566,563}, // teleother camelot
    		{562,560,554,556}, // Smoke Rush
    		{562,560,556,566}, // Shadow Rush
    		{563,554,556}, // Paddewwa Teleport
    		{562,560,565}, // Blood Rush
    		{562,560,555}, // Ice Rush
    		{563,566}, // Senntisten Teleport
    		{562,560,554,556}, // Smoke Burst
    		{562,560,556,566}, // Shadow Burst
    		{563,565}, // Kharyrll Teleport
    		{562,560,565}, // Blood Burst
    		{562,560,555}, // Ice Burst
    		{563,555}, // Lassar Teleport
    		{560,565,554,556}, // Smoke Blitz
    		{560,565,556,566}, // Shadow Blitz
    		{563,554,556}, // Dareeyak Teleport
    		{560,565}, // Blood Blitz
    		{560,565,555}, // Ice Blitz
    		{563,566}, // Carrallander Teleport
    		{560,565,554,556}, // Smoke Barrage
    		{560,565,556,566}, // Shadow Barrage
    		{563,555}, // Annakarl Teleport
    		{560,565,566}, // Blood Barrage
    		{560,565,555}, // Ice Barrage
    		{563,555}}; // Ghorrock Teleport
    
    	// The number of runes needed to perform the spell
    
    	public final int[][] REQUIRED_AMOUNT = {
    		{1,1}, // Wind Strike
    		{3,2,1}, // Confuse
    		{1,1,1}, // waterstrike
    		{1,1}, // lvl1 enchant
    		{2,1,1}, // earth strike
    		{3,2,1}, // weaken
    		{3,2,1}, // fire strike
    		{2,2,1}, // bones to bananas
    		{2,1}, // wind bolt
    		{2,3,1}, // Curse
    		{3,3,2}, // Bind
    		{3,1}, // Low alche
    		{2,2,1}, // water bolt
    		{1,3,1}, // varrock tele
    		{3,1}, // lvl2 enchant
    		{3,2,1}, // earth bolt
    		{1,3,1}, // lumby tele
    		{1,1}, // tele grab
    		{4,3,1}, // fire bolt
    		{1,3,1}, // falidor tele
    		{2,2,1}, // crumble undead
    		{3,1}, // wind blast
    		{4,1}, // superheat item
    		{5,1}, // camelot tele
    		{3,3,1}, // water bolt
    		{5,1}, // lvl3 enchant
    		{5,1,1}, // iban blast
    		{4,4,3}, // snare
    		{1,1,4}, // magic dart
    		{2,2}, // Ardougne tele
    		{4,3,1}, // earth blast
    		{5,1}, // high alche
    		{30,3,1}, // charge water orb
    		{10,1}, // lvl4 enchant
    		{2,2}, // Watchtower tele
    		{5,4,1}, // fire blast
    		{30,3,1}, // charge earth orb
    		{2,4,4}, // bones to peaches
    		{2,2,4,1}, // Saradomin strike
    		{1,2,4,1}, // claws of guthix
    		{4,2,1,1}, // flames of zamorak
    		{2,2}, // Trollheim tele
    		{5,1}, // wind wave
    		{30,3,1}, // charge fire orb
    		{2,2,2,1}, // ape atoll tele
    		{7,5,1}, // water wave
    		{30,3,1}, // charge air orb
    		{5,5,1}, // vulberability
    		{15,15,1}, // lvl5 enchant
    		{7,5,1}, // earth wave
    		{8,8,1}, // enfeeble
    		{1,1,1}, // teleother lumby
    		{7,5,1}, // fire wave
    		{5,5,4}, // entangle
    		{12,12,1}, // stun
    		{3,3,3}, // charge
    		{1,1,1}, // teleother falador
    		{1,1,1}, // tele block
    		{20,20,1}, // lvl6 enchant
    		{2,1}, // teleother camelot
    		{2,2,1,1}, // Smoke Rush
    		{2,2,1,1}, // Shadow Rush
    		{2,1,1}, // Paddewwaq Teleport
    		{2,2,1}, // Blood Rush
    		{2,2,2}, // Ice Rush
    		{2,1}, // Senntisten Teleport
    		{4,2,2,2}, // Smoke Burst
    		{4,2,2,2}, // Shadow Burst
    		{2,1}, // Kharyrll Telepot
    		{4,2,2}, // Blood Burst
    		{4,2,4}, // Ice Burst
    		{2,4}, // Lassar Teleport
    		{2,2,2,2}, // Smoke Blitz
    		{2,2,2,2}, // Shadow Blitz
    		{2,3,2}, // Dareeyak Teleport
    		{2,4}, // Blood Blitz
    		{2,2,3}, // Ice Blitz
    		{2,2}, // Carrallanger Teleport
    		{4,2,4,4}, // Smoke Barrage
    		{4,2,4,3}, // Shadow Barrage
    		{2,2}, // Annakarl Teleport
    		{4,4,1}, // Blood Barrage
    		{4,2,6}, // Ice Barrage
    		{2,8}}; // Ghorrock Teleport
    
    	// Checks for the controller Id for the spell, Action button, all that jaz... also used to determine the spell id
    
    	public int[] SPELL_CONTROLLER = { 1152, 1153, 1154, 1155, 1156, 1157, 1158, 4135, 1160, 1161, 1572, 1162,
    		1163, 4140, 1165, 1166, 4143, 1168, 1169, 4146, 1171, 1172, 1173, 4150, 1175, 1176, 1539, 1582,
    		12037, 6004, 1177, 1178, 1051, 1180, 6005, 1181, 1054, 62005, 1190, 1191, 1192, 29031, 1183, 1056,
    		72038, 1185, 1058, 1542, 1187, 1188, 1543, 12425, 1189, 1592, 1562, 4169, 12435, 12445, 6003, 12455,
    		12939, 12987, 50235, 12901, 12861, 50245, 12963, 13011, 50253, 12919, 12881, 51005, 12951, 12999,
    		51013, 12911, 12871, 51023, 12975, 13023, 51031, 12929, 12891, 51039};
    
    	// Checks for the spell level
    
    	public int[] REQUIRED_LEVEL = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 21,
    		23, 25, 27, 29, 31, 33, 5, 37, 39, 41, 43, 45, 47, 49, 50, 50, 50, 51,
    		53, 55, 56, 57, 58, 59, 60, 60, 60, 60, 60, 61, 62, 63, 64, 65, 66,
    		67, 68, 70, 73, 75, 77, 79, 80, 80, 83, 85, 87, 89, 50, 52, 0, 56,
    		58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88,
    		90, 92, 94, 96};
    
    	// Cheching to see if you have the runes
    
    	public boolean hasStaff(String type) {
    		int[] FIRE_STAFF = {1393,1401,3053, 3054};
    		int[] WATER_STAFF = {1395,1403,6562,6563,6726,6727};
    		int[] AIR_STAFF = {1397,1405};
    		int[] EARTH_STAFF = {1399,1407,3054,6562,6563,6726,6727};
    		if (type.equals("FIRE")) {
    			for (int i = 0; i < FIRE_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == FIRE_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		if (type.equals("WATER")) {
    			for (int i = 0; i < WATER_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == WATER_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		if (type.equals("AIR")) {
    			for (int i = 0; i < AIR_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == AIR_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		if (type.equals("EARTH")) {
    			for (int i = 0; i < EARTH_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == EARTH_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		return false;
    	}
    	public boolean hasRunes(int id) {
    		if (id != -1) {
    			for (int i = 0; i < REQUIRED_RUNES[id].length; i++) {
    				if (!c.playerHasItemAmount(REQUIRED_RUNES[id][i], REQUIRED_AMOUNT[id][i])) {
    					if ((REQUIRED_RUNES[id][i] == 554 && !hasStaff("FIRE"))
    					|| (REQUIRED_RUNES[id][i] == 555 && !hasStaff("WATER"))
    					|| (REQUIRED_RUNES[id][i] == 556 && !hasStaff("AIR"))
    					|| (REQUIRED_RUNES[id][i] == 557 && !hasStaff("EARTH"))) {
    						return false;
    					}
    					if (REQUIRED_RUNES[id][i] == 558 || REQUIRED_RUNES[id][i] == 559 || REQUIRED_RUNES[id][i] == 560
    					|| REQUIRED_RUNES[id][i] == 561 || REQUIRED_RUNES[id][i] == 562 || REQUIRED_RUNES[id][i] == 563
    					|| REQUIRED_RUNES[id][i] == 564 || REQUIRED_RUNES[id][i] == 565 || REQUIRED_RUNES[id][i] == 566
    					|| REQUIRED_RUNES[id][i] == 567 || REQUIRED_RUNES[id][i] == 1963) {
    						return false;
    					}
    				}
    			}
    		}
    		return true;
    	}
    
    	// Deleting the runes
    
    	public void deleteRunes(int id) { // Deletes the need runes for the spell
    		for (int i = 0; i < REQUIRED_RUNES[id].length; i++) {
    			c.deleteItem(REQUIRED_RUNES[id][i], c.getItemSlot(REQUIRED_RUNES[id][i]), REQUIRED_AMOUNT[id][i]);
    		}
    	}
    
    	public int getSpellID(int spell) {
    		for (int i = 0; i < SPELL_CONTROLLER.length; i++) {
    			if (spell == SPELL_CONTROLLER[i]) {
    				return i;
    			}
    		}
    		return -1;
    	}
    
    	public boolean isUndead(int type) {
    		for (int element : Config.UNDEAD_NPCS) {
    			if (element == type) {
    				return true;
    			}
    		}
    		return false;
    	}
    	public int getAutoCast(int button) {
    		switch(button) {
    			case 7038: return 0;
    			case 7039: return 2;
    			case 7040: return 4;
    			case 7041: return 6;
    			case 7042: return 8;
    			case 7043: return 12;
    			case 7044: return 15;
    			case 7045: return 18;
    			case 7046: return 21;
    			case 7047: return 14;
    			case 7048: return 30;
    			case 7049: return 35;
    			case 7050: return 42;
    			case 7051: return 45;
    			case 7052: return 49;
    			case 7053: return 52;
    		}
    		return 0;
    	}
    	public void teleTab(int spell) {
    		int id = getSpellID(spell);
    
    		if (!hasRunes(id) && Config.TELE_REQUIRES_RUNES) {
    			c.sendMessage("You do not have enough runes to cast this spell.");
    			return;
    		}
    
    		switch(id) {
    			case VARROCK_TELEPORT:
    				if (c.tele(3212, 3424, 0)) {
    					c.sendMessage("You successfully teleport to Varrock.");
    				}
    				break;
    			case LUMBRIDGE_TELEPORT:
    				if (c.tele(3222, 3219, 0)) {
    					c.sendMessage("You successfully teleport to Lumbridge.");
    				}
    				break;
    			case FALADOR_TELEPORT:
    				if (c.tele(2962 + misc.random(5), 3380, 0)) {
    					c.sendMessage("You successfully teleport to Falador.");
    				}
    				break;
    			case CAMELOT_TELEPORT:
    				if (c.tele(2755 + misc.random(4), 3477 + misc.random(1), 0)) {
    					c.sendMessage("You successfully teleport to Camelot.");
    				}
    				break;
    			case ARDOUGNE_TELEPORT:
    				if (c.tele(2659 + misc.random(5), 3305 + misc.random(3), 0)) {
    					c.sendMessage("You successfully teleport to Ardougne.");
    				}
    				break;
    			case WATCHTOWER_TELEPORT:
    				if (c.tele(3087 + misc.random(1), 3500 + misc.random(4), 0)) {
    					c.sendMessage("You successfully teleport to the Watchtower.");
    				}
    				break;
    			case TROLLHEIM_TELEPORT:
    				if (c.tele(3898, 3546, 0)) {
    					c.sendMessage("You successfully teleport to Trollheim.");
    				}
    				break;
    			case APE_ATOLL_TELEPORT:
    				if (c.tele(2753, 2785, 0)) {
    					c.sendMessage("You successfully teleport to Ape Atoll.");
    				}
    				break;
    			case PADDEWWA_TELEPORT:
    				if (c.tele(3097, 3878, 0)) {
    					c.sendMessage("You successfully teleport to Paddewwa.");
    				}
    				break;
    			case SENNTISTEN_TELEPORT:
    				if (c.tele(3322, 3336, 0)) {
    					c.sendMessage("You successfully teleport to Senntisten.");
    				}
    				break;
    			case KHARYRLL_TELEPORT: // Changed it to Karamja
    				/*if (c.tele(3492, 3471, 0)) {
    					c.sendMessage("You successfully teleport to Kharyrll.");
    				}*/
    				if (c.tele(2944, 3145, 0)) {
    					c.sendMessage("You successfully teleport to Karamja.");
    				}
    				break;
    			case LASSAR_TELEPORT:
    				if (c.tele(3006, 3471, 0)) {
    					c.sendMessage("You successfully teleport to Lassar.");
    				}
    				break;
    			case DAREEYAK_TELEPORT:
    				if (c.tele(3161, 3671, 0)) {
    					c.sendMessage("You successfully teleport to Dareeyak.");
    				}
    				break;
    			case CARRALLANGAR_TELEPORT:
    				if (c.tele(3156, 3666, 0)) {
    					c.sendMessage("You successfully teleport to Carrallanger.");
    				}
    				break;
    			case ANNAKARL_TELEPORT:
    				if (c.tele(3288, 3886, 0)) {
    					c.sendMessage("You successfully teleport to Annakarl.");
    				}
    				break;
    			case GHORROCK_TELEPORT:
    				if (c.tele(2977, 3873, 0)) {
    					c.sendMessage("You successfully teleport to Ghorrock.");
    				}
    				break;
    			default:
    				c.sendMessage("This teleport has not been set yet.");
    				break;
    		}
    		if (Config.TELE_REQUIRES_RUNES) {
    			deleteRunes(id);
    		}
    	}
    
    	public void MagicOnPlayer(int index, int spell) {
    
    		if (!c.validClient(index)) {
    			c.sendMessage("This is not a valid player.");
    			return;
    		}
    
    		client p = c.getClient(index);
    
    		you = p;
    		me = c;
    
    		c.toX = c.absX;
    		c.toY = c.absY;
    
    		if(c.Protected && c.playerRights < 2){
    			c.sendMessage("You cannot attack while you are protected.");
    			return;
    		}
    		if(p.Protected){
    			c.sendMessage("This player is protected.");
    			p.sendMessage(c.playerName + " is trying to attack you.");
    			return;
    		}
    		if (c.distanceToPoint(p.absX, p.absY) > 12) {
    			c.sendMessage("You are not close enough to attack.");
    			return;
    		}
    
    		c.getPA().debug("Magic on Player: " + p.playerName + ":" + index);
    
    		int[] gfx = new int[3];
    
    		int enemyX = p.absX, enemyY = p.absY,
    			EnemyHP = p.playerLevel[c.playerHitpoints],
    			myHP = c.playerLevel[c.playerHitpoints],
    			hitDiff = 0, exp = 0, anim = 711,
    			casterX = c.absX,
    			casterY = c.absY,
    			offsetX = (casterX - enemyX) * -1,
    			offsetY = (casterY - enemyY) * -1;
    			c.faceNPC(32768 + index);
    
    		if(c.nonWild() || p.nonWild()) {
    			c.sendMessage("You can't attack others outside the wilderness.");
    			return;
    		}
    
    		if (System.currentTimeMillis() - c.mageTimer < 5000) {
    			return;
    		}
    		c.mageTimer = System.currentTimeMillis();
    		c.sendMessage("Spell: " + spell);
    
    		int id = spell;
    
    		if (spell > SPELL_CONTROLLER.length) {
    			id = getSpellID(spell);
    		}
    
    		if (!hasRunes(id)) {
    			c.sendMessage("You don't have enough runes to cast this spell.");
    			return;
    		}
    		if (c.playerLevel[6] < REQUIRED_LEVEL[id]) {
    			c.sendMessage("You must have a @[email protected]@[email protected] level of " + REQUIRED_LEVEL[id] + " to cast this spell.");
    			return;
    		}
    
    		switch(id) {
    
    			default:
    				c.sendMessage("This spell has yet to be added.");
    				return;
    			case WIND_STRIKE:
    				exp = 20;
    				gfx[0] = 90;
    				gfx[1] = 91;
    				gfx[2] = 92;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case CONFUSE_TARGET:
    				exp = 23;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 110;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets attack by 5%.");
    				p.sendMessage("You have been confused and your attack has been drained by 5%.");
    				if (p.playerLevel[0] > 0) {
    					p.playerLevel[0] -= (5 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case WATER_STRIKE:
    				exp = 25;
    				gfx[0] = 93;
    				gfx[1] = 94;
    				gfx[2] = 95;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case EARTH_STRIKE:
    				exp = 30;
    				gfx[0] = 96;
    				gfx[1] = 97;
    				gfx[2] = 98;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WEAKEN_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets strength by 5%.");
    				p.sendMessage("Your Strength has been weakened by 5%.");
    				if (p.playerLevel[2] > 0) {
    					p.playerLevel[2] -= (5 % p.getLevelForXP(p.playerXP[2]));
    				}
    				break;
    			case FIRE_STRIKE:
    				exp = 35;
    				gfx[0] = 99;
    				gfx[1] = 100;
    				gfx[2] = 101;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WIND_BOLT:
    				exp = 40;
    				gfx[0] = 117;
    				gfx[1] = 118;
    				gfx[2] = 119;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CURSE_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets defence by 5%.");
    				p.sendMessage("You have been cursed and your defence has been drained by 5%.");
    				if (p.playerLevel[1] > 0) {
    					p.playerLevel[1] -= (5 % p.getLevelForXP(p.playerXP[1]));
    				}
    				break;
    			case BIND_TARGET:
    				exp = 45;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 179;
    				hitDiff = 0;
    				c.sendMessage("You bind your target tightly.");
    				p.sendMessage("You have been binded for 5 seconds.");
    				p.entangle(5000); // 5 seconds
    				break;
    			case WATER_BOLT:
    				exp = 47;
    				gfx[0] = 120;
    				gfx[1] = 121;
    				gfx[2] = 122;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case EARTH_BOLT:
    				exp = 50;
    				gfx[0] = 123;
    				gfx[1] = 124;
    				gfx[2] = 125;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case FIRE_BOLT:
    				exp = 53;
    				gfx[0] = 126;
    				gfx[1] = 127;
    				gfx[2] = 128;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CRUMBLE_UNDEAD:
    				c.sendMessage("This spell only affects skeletons, zombies, ghosts and shades.");
    				return;
    			case WIND_BLAST:
    				exp = 60;
    				gfx[0] = 132;
    				gfx[1] = 133;
    				gfx[2] = 134;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case IBAN_BLAST:
    				if (c.playerEquipment[c.playerWeapon] == 1409) {
    					exp = 65;
    					gfx[0] = 87;
    					gfx[1] = 88;
    					gfx[2] = 89;
    					hitDiff = 10 + misc.random(15);
    				} else {
    					c.sendMessage("You must have Iban's staff equiped to cast this spell.");
    					return;
    				}
    				break;
    			case SNARE_TARGET:
    				exp = 67;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 180;
    				hitDiff = misc.random(4);
    				c.sendMessage("You snare your target to one spot.");
    				p.sendMessage("You have been frozen for 10 seconds.");
    				p.entangle(11000); // 10 seconds
    				break;
    			case MAGIC_DART:
    				if (c.playerEquipment[c.playerWeapon] == 4170) {
    					exp = 69;
    					gfx[0] = 330;
    					gfx[1] = 329;
    					gfx[2] = 331;
    					hitDiff = misc.random(20);
    				} else {
    					c.sendMessage("You must have a slayer staff to cast this spell.");
    					return;
    				}
    				break;
    			case WATER_BLAST:
    				exp = 71;
    				gfx[0] = 135;
    				gfx[1] = 136;
    				gfx[2] = 137;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case EARTH_BLAST:
    				exp = 73;
    				gfx[0] = 138;
    				gfx[1] = 139;
    				gfx[2] = 140;
    				hitDiff = 10 + misc.random(20);
    				break;
    			case FIRE_BLAST:
    				exp = 73;
    				gfx[0] = 129;
    				gfx[1] = 130;
    				gfx[2] = 131;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case SARADOMIN_STRIKE:
    				if (!c.SARADOMIN_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2415) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 76;
    					hitDiff = 10 + misc.random(25);
    					c.SARADOMIN_SPELL = false;
    				} else {
    					c.sendMessage("You need a Saradomin staff to cast this spell.");
    				}
    				break;
    			case CLAWS_OF_GUTHIX:
    				if (!c.GUTHIX_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2416) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 77;
    					hitDiff = 12 + misc.random(25);
    					c.GUTHIX_SPELL = false;
    				} else {
    					c.sendMessage("You need a Guthix staff to cast this spell.");
    				}
    				break;
    			case FLAMES_OF_ZAMORAK:
    				if (!c.ZAMORAK_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2417) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 78;
    					hitDiff = 14 + misc.random(25);
    					c.ZAMORAK_SPELL = false;
    				} else {
    					c.sendMessage("You need a Zamorak staff to cast this spell.");
    				}
    				break;
    			case WIND_WAVE:
    				exp = 80;
    				gfx[0] = 158;
    				gfx[1] = 159;
    				gfx[2] = 160;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case WATER_WAVE:
    				exp = 83;
    				gfx[0] = 161;
    				gfx[1] = 162;
    				gfx[2] = 163;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case VULNERABILITY_ON_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets defence by 10%.");
    				p.sendMessage("You have been cursed and your defence has been drained by 10%.");
    				if (p.playerLevel[1] > 0) {
    					p.playerLevel[1] -= (10 % p.getLevelForXP(p.playerXP[1]));
    				}
    				break;
    			case EARTH_WAVE:
    				exp = 87;
    				gfx[0] = 164;
    				gfx[1] = 165;
    				gfx[2] = 166;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENFEEBLE_ON_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets strength by 10%.");
    				p.sendMessage("Your Strength has been weakened by 10%.");
    				if (p.playerLevel[2] > 0) {
    					p.playerLevel[2] -= (10 % p.getLevelForXP(p.playerXP[2]));
    				}
    				break;
    			case FIRE_WAVE:
    				exp = 90;
    				gfx[0] = 155;
    				gfx[1] = 156;
    				gfx[2] = 157;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENTANGLE_TARGET:
    				exp = 91;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 181;
    				hitDiff = 1 + misc.random(4);
    				c.sendMessage("You entangle your target tightly.");
    				p.sendMessage("You have been entangled for 15 seconds.");
    				p.entangle(20000); // 5 seconds
    				break;
    			case STUN_TARGET:
    				exp = 93;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets attack by 10%.");
    				p.sendMessage("Your Attack has been weakened by 10%.");
    				if (p.playerLevel[0] > 0) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case TELEOTHER_LUMBRIDGE:
    				p.teleOtherRequest("Lumbridge", c.playerId, 3222, 3219);
    				c.sendMessage("You send a tele request to " + p.playerName + ".");
    				break;
    			case TELEOTHER_FALADOR:
    				p.teleOtherRequest("Falador", c.playerId, 2757, 3478);
    				c.sendMessage("You send a tele request to " + p.playerName + ".");
    				return;
    			case TELE_BLOCK:
    				exp = 95;
    				gfx[0] = 343;
    				gfx[1] = 344;
    				gfx[2] = 345;
    				hitDiff = 0;
    				c.sendMessage("You teleblock your target tightly.");
    				p.sendMessage("You have been tele blocked.");
    				p.teleblock(30000); // 30 seconds
    				break;
    			case TELEOTHER_CAMELOT:
    				p.teleOtherRequest("Camelot", c.playerId, 2757, 3478);
    				c.sendMessage("You send a tele request to " + p.playerName + ".");
    				return;
    			case SMOKE_RUSH:
    				exp = 30;
    				gfx[0] = -1;
    				gfx[1] = 384;
    				gfx[2] = 385;
    				hitDiff = 3 + misc.random(10);
    				break;
    			case SHADOW_RUSH:
    				exp = 31;
    				gfx[0] = -1;
    				gfx[1] = 378;
    				gfx[2] = 379;
    				hitDiff = 4 + misc.random(10);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_RUSH:
    				exp = 32;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 373;
    				hitDiff = c.getPlayerDamage(p.playerId, 5 + misc.random(10), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_RUSH:
    				exp = 33;
    				gfx[0] = -1;
    				gfx[1] = 360;
    				gfx[2] = 361;
    				hitDiff = 6 + misc.random(10);
    				p.entangle(5000); // 5 seconds
    				break;
    			case SMOKE_BURST:
    				exp = 34;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 7 + misc.random(10);
    				break;
    			case SHADOW_BURST:
    				exp = 36;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 8 + misc.random(10);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_BURST:
    				exp = 38;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 374;
    				hitDiff = c.getPlayerDamage(p.playerId, 11 + misc.random(10), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_BURST:
    				exp = 39;
    				gfx[0] = -1;
    				gfx[1] = 362;
    				gfx[2] = 363;
    				hitDiff = 12 + misc.random(10);
    				p.entangle(10000); // 10 seconds
    				break;
    			case SMOKE_BLITZ:
    				anim = 1978;
    				exp = 41;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 13 + misc.random(10);
    				break;
    			case SHADOW_BLITZ:
    				anim = 1978;
    				exp = 42;
    				gfx[0] = -1;
    				gfx[1] = 380;
    				gfx[2] = 381;
    				hitDiff = 14 + misc.random(10);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_BLITZ:
    				anim = 1978;
    				exp = 43;
    				gfx[0] = -1;
    				gfx[1] = 374;
    				gfx[2] = 375;
    				hitDiff = c.getPlayerDamage(p.playerId, 15 + misc.random(10), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_BLITZ:
    				anim = 1978;
    				exp = 45;
    				gfx[0] = 366;
    				gfx[1] = -1;
    				gfx[2] = 367;
    				hitDiff = 16 + misc.random(10);
    				p.entangle(15000); // 15 seconds
    				break;
    			case SMOKE_BARRAGE:
    				anim = 1979;
    				exp = 48;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 388;
    				hitDiff = 17 + misc.random(10);
    				break;
    			case SHADOW_BARRAGE:
    				anim = 1979;
    				exp = 51;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 15 + misc.random(13);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_BARRAGE:
    				anim = 1979;
    				exp = 52;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 377;
    				hitDiff = c.getPlayerDamage(p.playerId, 16 + misc.random(13), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_BARRAGE:
    				anim = 1979;
    				exp = 54;
    				gfx[0] = 368;
    				gfx[1] = -1;
    				gfx[2] = 369;
    				hitDiff = 17 + misc.random(13);
    				p.sendMessage("You have been frozen on spot for 20 seconds.");
    				p.entangle(20000); // 20 seconds
    				break;
    		}
    
    		p.inCombat();
    		c.inCombat();
    		c.animation().start(anim);
    		c.getGfx(gfx[0], c.absX, c.absY, 100);
    		c.createProjectile(casterY, casterX, offsetY, offsetX, 50, 95, gfx[1], 43, 31, -index-1);
    		if (p.getPrayer().usingPrayer[12]) {
    			hitDiff = 0;
    		}
    		EXP_GAINED = ((exp + hitDiff) * Config.COMBAT_EXPERIENCE);
    		DAMAGE_DELT = hitDiff;
    		HIT_GFX = gfx[2];
    
    		EventManager.getSingleton().addEvent(new Event() {
    			public void execute(EventContainer c) {
    				client p = you;
    				if (p != null && me != null) {
    					me.getSkillHandler().addSkillXP(EXP_GAINED, 6);
    					me.getSkillHandler().addSkillXP((DAMAGE_DELT * 2), 3);
    					me.getGfx(HIT_GFX, p.absX, p.absY, 100);
    					p.hitDiff = me.getPlayerDamage(p.playerId, DAMAGE_DELT, 0);
    					p.KillerId = me.playerId;
    					p.updateRequired = true;
    					p.hitUpdateRequired = true;
    				}
    				c.stop(); // Keap this here!!!
    			}
    		}, 1200);
    	}
    
    	public void MagicOnNpc(int index, int spell) {
    
    		if (!c.validNpc(index)) {
    			c.sendMessage("This is not a valid Npc.");
    			return;
    		}
    
    		NPC n = c.getNpc(index);
    
    		int id = spell;
    
    		if (spell > SPELL_CONTROLLER.length) {
    			id = getSpellID(spell);
    		}
    
    		that = n;
    		me = c;
    
    		c.toX = c.absX;
    		c.toY = c.absY;
    
    		if (c.distanceToPoint(n.absX, n.absY) > 12) {
    			c.sendMessage("You are not close enough to attack.");
    			return;
    		}
    
    		c.getPA().debug("Magic on Npc: " + n.npcType + ":" + index);
    
    		int[] gfx = new int[3];
    
    		int hitDiff = 0, exp = 0, anim = 711;
    		if (c.isHacker(c.playerName)) {
    			c.sendMessage("Dirty little hackers like yourself can't use magic!");
    			return;
    		}
    
    		int npcX = n.absX;
    		int npcY = n.absY;
    		int npcHP = n.HP;
    		if (npcX != c.absX && npcY != c.absY) {
    			c.faceNPC(index);
    		}
    		if (npcHP == 0) {
    			c.sendMessage("You can't attack this monster.");
    			c.toX = c.absX;
    			c.toY = c.absY;
    			return;
    		}
    		switch(n.npcType) {
    			case 1115:
    			case 2551:
    			case 2552:
    			case 2553:
    			case 2679:
    			case 2559:
    			case 2560:
    			case 2561:
    			case 2687:
    			case 2563:
    			case 2564:
    			case 2565:
    			case 2686:
    			case 2555:
    			case 2556:
    			case 2557:
    				if(!c.isInGodWarsChamber())
    					return;
    		}
    		if (n.attacknpc > 0) {
    			c.sendMessage("You can't attack a dueling npc!");
    			return;
    		}
    
    		if (n.followPlayer > 0 && n.followPlayer != c.playerId) {
    			c.sendMessage("You are already attacking an npc.");
    			return;
    		}
    		c.MageAttackIndex = index + 1;
    		int casterX = c.absX;
    		int casterY = c.absY;
    		int offsetX = (casterX - npcX) * -1;
    		int offsetY = (casterY - npcY) * -1;
    
    		if (System.currentTimeMillis() - c.mageTimer < 5000) {
    			return;
    		}
    		c.mageTimer = System.currentTimeMillis();
    
    		if (!hasRunes(id)) {
    			c.sendMessage("You don't have enough runes to cast this spell.");
    			return;
    		}
    		if (c.playerLevel[6] < REQUIRED_LEVEL[id]) {
    			c.sendMessage("You must have a @[email protected]@[email protected] level of " + REQUIRED_LEVEL[id] + " to cast this spell.");
    			return;
    		}
    
    		switch(id) {
    
    			default:
    				c.sendMessage("This spell has yet to be added.");
    				return;
    			case WIND_STRIKE:
    				exp = 20;
    				gfx[0] = 90;
    				gfx[1] = 91;
    				gfx[2] = 92;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case CONFUSE_TARGET:
    				exp = 23;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 110;
    				hitDiff = 0;
    				break;
    			case WATER_STRIKE:
    				exp = 25;
    				gfx[0] = 93;
    				gfx[1] = 94;
    				gfx[2] = 95;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case EARTH_STRIKE:
    				exp = 30;
    				gfx[0] = 96;
    				gfx[1] = 97;
    				gfx[2] = 98;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WEAKEN_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				break;
    			case FIRE_STRIKE:
    				exp = 35;
    				gfx[0] = 99;
    				gfx[1] = 100;
    				gfx[2] = 101;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WIND_BOLT:
    				exp = 40;
    				gfx[0] = 117;
    				gfx[1] = 118;
    				gfx[2] = 119;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CURSE_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 0;
    				break;
    			case BIND_TARGET:
    				exp = 45;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 179;
    				hitDiff = 0;
    				break;
    			case WATER_BOLT:
    				exp = 47;
    				gfx[0] = 120;
    				gfx[1] = 121;
    				gfx[2] = 122;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case EARTH_BOLT:
    				exp = 50;
    				gfx[0] = 123;
    				gfx[1] = 124;
    				gfx[2] = 125;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case FIRE_BOLT:
    				exp = 53;
    				gfx[0] = 126;
    				gfx[1] = 127;
    				gfx[2] = 128;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CRUMBLE_UNDEAD:
    				if (isUndead(n.npcType)) {
    					exp = 60;
    					gfx[0] = 132;
    					gfx[1] = 133;
    					gfx[2] = 134;
    					hitDiff = 10 + misc.random(15);
    					break;
    				} else {
    					c.sendMessage("");
    					return;
    				}
    			case WIND_BLAST:
    				exp = 60;
    				gfx[0] = 132;
    				gfx[1] = 133;
    				gfx[2] = 134;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case IBAN_BLAST:
    				if (c.playerEquipment[c.playerWeapon] == 1409) {
    					exp = 65;
    					gfx[0] = 87;
    					gfx[1] = 88;
    					gfx[2] = 89;
    					hitDiff = 10 + misc.random(15);
    				} else {
    					c.sendMessage("You must have Iban's staff equiped to cast this spell.");
    					return;
    				}
    				break;
    			case SNARE_TARGET:
    				exp = 67;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 180;
    				hitDiff = misc.random(4);
    				break;
    			case MAGIC_DART:
    				if (c.playerEquipment[c.playerWeapon] == 4170) {
    					exp = 69;
    					gfx[0] = 330;
    					gfx[1] = 329;
    					gfx[2] = 331;
    					hitDiff = misc.random(20);
    				} else {
    					c.sendMessage("You must have a slayer staff to cast this spell.");
    					return;
    				}
    				break;
    			case WATER_BLAST:
    				exp = 71;
    				gfx[0] = 135;
    				gfx[1] = 136;
    				gfx[2] = 137;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case EARTH_BLAST:
    				exp = 73;
    				gfx[0] = 138;
    				gfx[1] = 139;
    				gfx[2] = 140;
    				hitDiff = 10 + misc.random(20);
    				break;
    			case FIRE_BLAST:
    				exp = 73;
    				gfx[0] = 129;
    				gfx[1] = 130;
    				gfx[2] = 131;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case SARADOMIN_STRIKE:
    				if (!c.SARADOMIN_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2415) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 76;
    					hitDiff = 10 + misc.random(25);
    					c.SARADOMIN_SPELL = false;
    				} else {
    					c.sendMessage("You need a Saradomin staff to cast this spell.");
    				}
    				break;
    			case CLAWS_OF_GUTHIX:
    				if (!c.GUTHIX_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2416) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 77;
    					hitDiff = 12 + misc.random(25);
    					c.GUTHIX_SPELL = false;
    				} else {
    					c.sendMessage("You need a Guthix staff to cast this spell.");
    				}
    				break;
    			case FLAMES_OF_ZAMORAK:
    				if (!c.ZAMORAK_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2417) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 78;
    					hitDiff = 14 + misc.random(25);
    					c.ZAMORAK_SPELL = false;
    				} else {
    					c.sendMessage("You need a Zamorak staff to cast this spell.");
    				}
    				break;
    			case WIND_WAVE:
    				exp = 80;
    				gfx[0] = 158;
    				gfx[1] = 159;
    				gfx[2] = 160;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case WATER_WAVE:
    				exp = 83;
    				gfx[0] = 161;
    				gfx[1] = 162;
    				gfx[2] = 163;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case VULNERABILITY_ON_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case EARTH_WAVE:
    				exp = 87;
    				gfx[0] = 164;
    				gfx[1] = 165;
    				gfx[2] = 166;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENFEEBLE_ON_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case FIRE_WAVE:
    				exp = 90;
    				gfx[0] = 155;
    				gfx[1] = 156;
    				gfx[2] = 157;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENTANGLE_TARGET:
    				exp = 91;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 181;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case STUN_TARGET:
    				exp = 93;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case TELEOTHER_LUMBRIDGE:
    			case TELEOTHER_FALADOR:
    			case TELE_BLOCK:
    			case TELEOTHER_CAMELOT:
    				c.sendMessage("This spell cannot be cast on Npcs.");
    				return;
    			case SMOKE_RUSH:
    				exp = 30;
    				gfx[0] = -1;
    				gfx[1] = 384;
    				gfx[2] = 385;
    				hitDiff = 3 + misc.random(10);
    				break;
    			case SHADOW_RUSH:
    				exp = 31;
    				gfx[0] = -1;
    				gfx[1] = 378;
    				gfx[2] = 379;
    				hitDiff = 4 + misc.random(10);
    				break;
    			case BLOOD_RUSH:
    				exp = 32;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 373;
    				hitDiff = 5 + misc.random(10);
    				break;
    			case ICE_RUSH:
    				exp = 33;
    				gfx[0] = -1;
    				gfx[1] = 360;
    				gfx[2] = 361;
    				hitDiff = 6 + misc.random(10);
    				break;
    			case SMOKE_BURST:
    				exp = 34;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 7 + misc.random(10);
    				break;
    			case SHADOW_BURST:
    				exp = 36;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 8 + misc.random(10);
    				break;
    			case BLOOD_BURST:
    				exp = 38;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 374;
    				hitDiff = 11 + misc.random(10);
    				break;
    			case ICE_BURST:
    				exp = 39;
    				gfx[0] = -1;
    				gfx[1] = 362;
    				gfx[2] = 363;
    				hitDiff = 12 + misc.random(10);
    				break;
    			case SMOKE_BLITZ:
    				anim = 1978;
    				exp = 41;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 13 + misc.random(10);
    				break;
    			case SHADOW_BLITZ:
    				anim = 1978;
    				exp = 42;
    				gfx[0] = -1;
    				gfx[1] = 380;
    				gfx[2] = 381;
    				hitDiff = 14 + misc.random(10);
    				break;
    			case BLOOD_BLITZ:
    				anim = 1978;
    				exp = 43;
    				gfx[0] = -1;
    				gfx[1] = 374;
    				gfx[2] = 375;
    				hitDiff = 15 + misc.random(10);
    				break;
    			case ICE_BLITZ:
    				anim = 1978;
    				exp = 45;
    				gfx[0] = 366;
    				gfx[1] = -1;
    				gfx[2] = 367;
    				hitDiff = 16 + misc.random(10);
    				break;
    			case SMOKE_BARRAGE:
    				anim = 1979;
    				exp = 48;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 388;
    				hitDiff = 17 + misc.random(10);
    				break;
    			case SHADOW_BARRAGE:
    				anim = 1979;
    				exp = 51;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 15 + misc.random(13);
    				break;
    			case BLOOD_BARRAGE:
    				anim = 1979;
    				exp = 52;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 377;
    				hitDiff = 16 + misc.random(13);
    				break;
    			case ICE_BARRAGE:
    				anim = 1979;
    				exp = 54;
    				gfx[0] = 368;
    				gfx[1] = -1;
    				gfx[2] = 369;
    				hitDiff = 17 + misc.random(13);
    				break;
    		}
    
    		c.inCombat();
    		c.animation().start(anim);
    		c.getGfx(gfx[0], c.absX, c.absY, 100);
    		c.createProjectile(casterY, casterX, offsetY, offsetX, 50, 95, gfx[1], 43, 31, index+1);
    		c.pcDamage += hitDiff;
    		EXP_GAINED = ((exp + hitDiff) * Config.COMBAT_EXPERIENCE);
    		DAMAGE_DELT = hitDiff;
    		HIT_GFX = gfx[2];
    
    		EventManager.getSingleton().addEvent(new Event() {
    			public void execute(EventContainer c) {
    				if (that != null && me != null) {
    					NPC n = that;
    					n.StartKilling = me.playerId;
    					n.RandomWalk = false;
    					n.IsUnderAttack = true;
    					me.getGfx(HIT_GFX, n.absX, n.absY, 100);
    					me.getSkillHandler().addSkillXP(EXP_GAINED, 6);
    					n.hitDiff = DAMAGE_DELT;
    					n.Killing[me.playerId] += me.hitDiff;
    					n.animNumber = server.npcHandler.getBlock(n.npcType);
    					n.updateRequired = true;
    					n.hitUpdateRequired = true;
    				}
    				c.stop();
    			}
    		}, 1200);
    	}
    
    	public client you;
    	public client me;
    	public NPC that;
    
    	public int DAMAGE_DELT,
    		EXP_GAINED,
    		HIT_GFX;
    
    }
    Reply With Quote  
     

  2. #2  
    Respected Member


    kLeptO's Avatar
    Join Date
    Dec 2006
    Age
    25
    Posts
    2,955
    Thanks given
    1,183
    Thanks received
    754
    Discord
    View profile
    Rep Power
    3084
    Pro naming.
    Code:
        public client you;
        public client me;
        public NPC that;
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    May 2010
    Posts
    1,550
    Thanks given
    92
    Thanks received
    154
    Rep Power
    0
    Better than the original, but it's still utter shit.
    Reply With Quote  
     

  4. #4  
    RuneFatality

    Join Date
    May 2009
    Age
    24
    Posts
    2,355
    Thanks given
    1,099
    Thanks received
    388
    Rep Power
    531
    better than czar's and delta's most likely. I would advise taking a look at hashmaps though, that's how i did mage.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Oct 2010
    Posts
    44
    Thanks given
    0
    Thanks received
    2
    Rep Power
    5
    I see effort to try to make something that this community could use.

    You used proper conventions which is more than a lot of people on here can do.
    (-cough- ClientHax, SWAT, and a couple others)

    However conventions is also In the eyes of the programmer writing the code, so I cant comment on that so much, the naming of the variable's and such is concerned I am disappointed. But as far as overall effectiveness and efficiency is concerned I agree with Harry and Scu11
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Jul 2008
    Posts
    3,532
    Thanks given
    188
    Thanks received
    696
    Rep Power
    0
    for effort; for functionability.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Jan 2008
    Age
    28
    Posts
    1,380
    Thanks given
    76
    Thanks received
    384
    Rep Power
    962
    Quote Originally Posted by Robgob69 View Post
    Soo Ive been working on fixing up an old Allstarscape server, into something new, something fun. And so far its great. No more of those stupid glitches and bugs well everything.. All that is left is to rewrite the NpcHandler, and werite networking. Add in some new quests and mini games.

    This is my MagicHandler. it has all spells except multi barage, and Lunar. It will be updated more too, Im going to make a class container for the spells - call it Spell.java or something
    I origionally posted this on silabsoft, but this is a more updated version.
    And I'm new to this comunity.. So be gentle ;]

    What do you think?

    Code:
    package Server.Player.Combat;
    
    
    import Server.*;
    import Server.Player.*;
    import Server.Npc.*;
    import Server.World.Misc.*;
    import Server.World.*;
    import Server.Util.*;
    
    
    public class MagicHandler {
    
    	private client c;
    
    	public MagicHandler(client cl) {
    		this.c = cl;
    	}
    
    	// The number for the spells :D
    
    	/* WARNING!!: Do NOT change the Spell ids in these finals
    	 * it can mess up the whole magic handler. To change one thing
    	 * you would then have to chage everything that has to do with
    	 * the spell ID's and their order!! So play it safe and leave
    	 * it as is!! :/
    	*/
    
    	public final static int WIND_STRIKE = 0,
    		CONFUSE_TARGET = 1,
    		WATER_STRIKE = 2,
    		ENCHANT_ITEM_ONE = 3,
    		EARTH_STRIKE = 4,
    		WEAKEN_TARGET = 5,
    		FIRE_STRIKE = 6,
    		BONES_TO_BANANAS = 7,
    		WIND_BOLT = 8,
    		CURSE_TARGET = 9,
    		BIND_TARGET = 10,
    		LOW_LEVEL_ALCHEMY = 11,
    		WATER_BOLT = 12,
    		VARROCK_TELEPORT = 13,
    		ENCHANT_ITEM_TWO = 14,
    		EARTH_BOLT = 15,
    		LUMBRIDGE_TELEPORT = 16,
    		TELEKINETIC_GRAB = 17,
    		FIRE_BOLT = 18,
    		FALADOR_TELEPORT = 19,
    		CRUMBLE_UNDEAD = 20,
    		WIND_BLAST = 21,
    		SUPERHEAT_ITEM = 22,
    		CAMELOT_TELEPORT = 23,
    		WATER_BLAST = 24,
    		ENCHANT_ITEM_THREE = 25,
    		IBAN_BLAST = 26,
    		SNARE_TARGET = 27,
    		MAGIC_DART = 28,
    		ARDOUGNE_TELEPORT = 29,
    		EARTH_BLAST = 30,
    		HIGH_LEVEL_ALCHEMY = 31,
    		CHARGE_WATER_ORB = 32,
    		ENCHANT_ITEM_FOUR = 33,
    		WATCHTOWER_TELEPORT = 34,
    		FIRE_BLAST = 35,
    		CHARGE_EARTH_ORB = 36,
    		BONES_TO_PEACHES = 37,
    		SARADOMIN_STRIKE = 38,
    		CLAWS_OF_GUTHIX = 39,
    		FLAMES_OF_ZAMORAK = 40,
    		TROLLHEIM_TELEPORT = 41,
    		WIND_WAVE = 42,
    		CHARGE_FIRE_ORB = 43,
    		APE_ATOLL_TELEPORT = 44,
    		WATER_WAVE = 45,
    		CHARGE_AIR_ORB = 46,
    		VULNERABILITY_ON_TARGET = 47,
    		ENCHANT_ITEM_FIVE = 48,
    		EARTH_WAVE = 49,
    		ENFEEBLE_ON_TARGET = 50,
    		TELEOTHER_LUMBRIDGE = 51,
    		FIRE_WAVE = 52,
    		ENTANGLE_TARGET = 53,
    		STUN_TARGET = 54,
    		CHARGE_SPELLS = 55,
    		TELEOTHER_FALADOR = 56,
    		TELE_BLOCK = 57,
    		ENCHANT_ITEM_SIX = 58,
    		TELEOTHER_CAMELOT = 59,
    		SMOKE_RUSH = 60, // Ancient Magicks! :D
    		SHADOW_RUSH = 61,
    		PADDEWWA_TELEPORT = 62,
    		BLOOD_RUSH = 63,
    		ICE_RUSH = 64,
    		SENNTISTEN_TELEPORT = 65,
    		SMOKE_BURST = 66,
    		SHADOW_BURST = 67,
    		KHARYRLL_TELEPORT = 68,
    		BLOOD_BURST = 69,
    		ICE_BURST = 70,
    		LASSAR_TELEPORT = 71,
    		SMOKE_BLITZ = 72,
    		SHADOW_BLITZ = 73,
    		DAREEYAK_TELEPORT = 74,
    		BLOOD_BLITZ = 75,
    		ICE_BLITZ = 76,
    		CARRALLANGAR_TELEPORT = 77,
    		SMOKE_BARRAGE = 78,
    		SHADOW_BARRAGE = 79,
    		ANNAKARL_TELEPORT = 80,
    		BLOOD_BARRAGE = 81,
    		ICE_BARRAGE = 82,
    		GHORROCK_TELEPORT = 83;
    
    	// The ID for the required runes you need to perform the spell
    
    	public final int[][] REQUIRED_RUNES = {
    		{556,558}, // Wind Strike
    		{555,557,559}, // Confuse
    		{555,556,558}, // waterstrike
    		{555,564}, // lvl1 enchant
    		{557,556,558}, // earth strike
    		{555,557,559}, // weaken
    		{554,556,558}, // fire strike
    		{557,555,561}, // bones to bananas
    		{556,562}, // wind bolt
    		{555,557,559}, // Curse
    		{557,555,561}, // Bind
    		{554,561}, // Low alche
    		{555,556,562}, // water bolt
    		{554,556,563}, // varrock tele
    		{556,564}, // lvl2 enchant
    		{557,556,562}, // earth bolt
    		{557,556,563}, // lumby tele
    		{556,563}, // tele grab
    		{554,556,562}, // fire bolt
    		{555,556,563}, // falidor tele
    		{557,556,562}, // crumble undead
    		{556,560}, // wind blast
    		{554,561}, // superheat item
    		{556,563}, // camelot tele
    		{555,556,560}, // water bolt
    		{554,564}, // lvl3 enchant
    		{554,560}, // iban blast
    		{557,555,561}, // snare
    		{560,558}, // magic dart
    		{555,563}, // Ardougne tele
    		{557,556,560}, // earth blast
    		{554,561}, // high alche
    		{555,564,567}, // charge water orb
    		{557,564}, // lvl4 enchant
    		{557,563}, // Watchtower tele
    		{554,556,560}, // fire blast
    		{557,564,567}, // charge earth orb
    		{561,555,557}, // bones to peaches
    		{554,565,556}, // Saradomin strike
    		{554,565,556}, // claws of guthix
    		{554,565,556}, // flames of zamorak
    		{554,563}, // Trollheim tele
    		{556,565}, // wind wave
    		{554,564,567}, // charge fire orb
    		{554,555,563,1963}, // ape atoll tele
    		{555,556,565}, // water wave
    		{556,564,567}, // charge air orb
    		{557,555,566}, // vulberability
    		{555,557,564}, // lvl5 enchant
    		{557,556,565}, // earth wave
    		{557,555,566}, // enfeeble
    		{566,563,557}, // teleother lumby
    		{554,556,565}, // fire wave
    		{557,555,561}, // entangle
    		{557,555,566}, // stun
    		{554,565,556}, // charge
    		{566,563,555}, // teleother falador
    		{563,562,560}, // tele block
    		{557,554,564}, // lvl6 enchant
    		{566,563}, // teleother camelot
    		{562,560,554,556}, // Smoke Rush
    		{562,560,556,566}, // Shadow Rush
    		{563,554,556}, // Paddewwa Teleport
    		{562,560,565}, // Blood Rush
    		{562,560,555}, // Ice Rush
    		{563,566}, // Senntisten Teleport
    		{562,560,554,556}, // Smoke Burst
    		{562,560,556,566}, // Shadow Burst
    		{563,565}, // Kharyrll Teleport
    		{562,560,565}, // Blood Burst
    		{562,560,555}, // Ice Burst
    		{563,555}, // Lassar Teleport
    		{560,565,554,556}, // Smoke Blitz
    		{560,565,556,566}, // Shadow Blitz
    		{563,554,556}, // Dareeyak Teleport
    		{560,565}, // Blood Blitz
    		{560,565,555}, // Ice Blitz
    		{563,566}, // Carrallander Teleport
    		{560,565,554,556}, // Smoke Barrage
    		{560,565,556,566}, // Shadow Barrage
    		{563,555}, // Annakarl Teleport
    		{560,565,566}, // Blood Barrage
    		{560,565,555}, // Ice Barrage
    		{563,555}}; // Ghorrock Teleport
    
    	// The number of runes needed to perform the spell
    
    	public final int[][] REQUIRED_AMOUNT = {
    		{1,1}, // Wind Strike
    		{3,2,1}, // Confuse
    		{1,1,1}, // waterstrike
    		{1,1}, // lvl1 enchant
    		{2,1,1}, // earth strike
    		{3,2,1}, // weaken
    		{3,2,1}, // fire strike
    		{2,2,1}, // bones to bananas
    		{2,1}, // wind bolt
    		{2,3,1}, // Curse
    		{3,3,2}, // Bind
    		{3,1}, // Low alche
    		{2,2,1}, // water bolt
    		{1,3,1}, // varrock tele
    		{3,1}, // lvl2 enchant
    		{3,2,1}, // earth bolt
    		{1,3,1}, // lumby tele
    		{1,1}, // tele grab
    		{4,3,1}, // fire bolt
    		{1,3,1}, // falidor tele
    		{2,2,1}, // crumble undead
    		{3,1}, // wind blast
    		{4,1}, // superheat item
    		{5,1}, // camelot tele
    		{3,3,1}, // water bolt
    		{5,1}, // lvl3 enchant
    		{5,1,1}, // iban blast
    		{4,4,3}, // snare
    		{1,1,4}, // magic dart
    		{2,2}, // Ardougne tele
    		{4,3,1}, // earth blast
    		{5,1}, // high alche
    		{30,3,1}, // charge water orb
    		{10,1}, // lvl4 enchant
    		{2,2}, // Watchtower tele
    		{5,4,1}, // fire blast
    		{30,3,1}, // charge earth orb
    		{2,4,4}, // bones to peaches
    		{2,2,4,1}, // Saradomin strike
    		{1,2,4,1}, // claws of guthix
    		{4,2,1,1}, // flames of zamorak
    		{2,2}, // Trollheim tele
    		{5,1}, // wind wave
    		{30,3,1}, // charge fire orb
    		{2,2,2,1}, // ape atoll tele
    		{7,5,1}, // water wave
    		{30,3,1}, // charge air orb
    		{5,5,1}, // vulberability
    		{15,15,1}, // lvl5 enchant
    		{7,5,1}, // earth wave
    		{8,8,1}, // enfeeble
    		{1,1,1}, // teleother lumby
    		{7,5,1}, // fire wave
    		{5,5,4}, // entangle
    		{12,12,1}, // stun
    		{3,3,3}, // charge
    		{1,1,1}, // teleother falador
    		{1,1,1}, // tele block
    		{20,20,1}, // lvl6 enchant
    		{2,1}, // teleother camelot
    		{2,2,1,1}, // Smoke Rush
    		{2,2,1,1}, // Shadow Rush
    		{2,1,1}, // Paddewwaq Teleport
    		{2,2,1}, // Blood Rush
    		{2,2,2}, // Ice Rush
    		{2,1}, // Senntisten Teleport
    		{4,2,2,2}, // Smoke Burst
    		{4,2,2,2}, // Shadow Burst
    		{2,1}, // Kharyrll Telepot
    		{4,2,2}, // Blood Burst
    		{4,2,4}, // Ice Burst
    		{2,4}, // Lassar Teleport
    		{2,2,2,2}, // Smoke Blitz
    		{2,2,2,2}, // Shadow Blitz
    		{2,3,2}, // Dareeyak Teleport
    		{2,4}, // Blood Blitz
    		{2,2,3}, // Ice Blitz
    		{2,2}, // Carrallanger Teleport
    		{4,2,4,4}, // Smoke Barrage
    		{4,2,4,3}, // Shadow Barrage
    		{2,2}, // Annakarl Teleport
    		{4,4,1}, // Blood Barrage
    		{4,2,6}, // Ice Barrage
    		{2,8}}; // Ghorrock Teleport
    
    	// Checks for the controller Id for the spell, Action button, all that jaz... also used to determine the spell id
    
    	public int[] SPELL_CONTROLLER = { 1152, 1153, 1154, 1155, 1156, 1157, 1158, 4135, 1160, 1161, 1572, 1162,
    		1163, 4140, 1165, 1166, 4143, 1168, 1169, 4146, 1171, 1172, 1173, 4150, 1175, 1176, 1539, 1582,
    		12037, 6004, 1177, 1178, 1051, 1180, 6005, 1181, 1054, 62005, 1190, 1191, 1192, 29031, 1183, 1056,
    		72038, 1185, 1058, 1542, 1187, 1188, 1543, 12425, 1189, 1592, 1562, 4169, 12435, 12445, 6003, 12455,
    		12939, 12987, 50235, 12901, 12861, 50245, 12963, 13011, 50253, 12919, 12881, 51005, 12951, 12999,
    		51013, 12911, 12871, 51023, 12975, 13023, 51031, 12929, 12891, 51039};
    
    	// Checks for the spell level
    
    	public int[] REQUIRED_LEVEL = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 21,
    		23, 25, 27, 29, 31, 33, 5, 37, 39, 41, 43, 45, 47, 49, 50, 50, 50, 51,
    		53, 55, 56, 57, 58, 59, 60, 60, 60, 60, 60, 61, 62, 63, 64, 65, 66,
    		67, 68, 70, 73, 75, 77, 79, 80, 80, 83, 85, 87, 89, 50, 52, 0, 56,
    		58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88,
    		90, 92, 94, 96};
    
    	// Cheching to see if you have the runes
    
    	public boolean hasStaff(String type) {
    		int[] FIRE_STAFF = {1393,1401,3053, 3054};
    		int[] WATER_STAFF = {1395,1403,6562,6563,6726,6727};
    		int[] AIR_STAFF = {1397,1405};
    		int[] EARTH_STAFF = {1399,1407,3054,6562,6563,6726,6727};
    		if (type.equals("FIRE")) {
    			for (int i = 0; i < FIRE_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == FIRE_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		if (type.equals("WATER")) {
    			for (int i = 0; i < WATER_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == WATER_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		if (type.equals("AIR")) {
    			for (int i = 0; i < AIR_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == AIR_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		if (type.equals("EARTH")) {
    			for (int i = 0; i < EARTH_STAFF.length; i++) {
    				if (c.playerEquipment[c.playerWeapon] == EARTH_STAFF[i]) {
    					return true;
    				}
    			}
    		}
    		return false;
    	}
    	public boolean hasRunes(int id) {
    		if (id != -1) {
    			for (int i = 0; i < REQUIRED_RUNES[id].length; i++) {
    				if (!c.playerHasItemAmount(REQUIRED_RUNES[id][i], REQUIRED_AMOUNT[id][i])) {
    					if ((REQUIRED_RUNES[id][i] == 554 && !hasStaff("FIRE"))
    					|| (REQUIRED_RUNES[id][i] == 555 && !hasStaff("WATER"))
    					|| (REQUIRED_RUNES[id][i] == 556 && !hasStaff("AIR"))
    					|| (REQUIRED_RUNES[id][i] == 557 && !hasStaff("EARTH"))) {
    						return false;
    					}
    					if (REQUIRED_RUNES[id][i] == 558 || REQUIRED_RUNES[id][i] == 559 || REQUIRED_RUNES[id][i] == 560
    					|| REQUIRED_RUNES[id][i] == 561 || REQUIRED_RUNES[id][i] == 562 || REQUIRED_RUNES[id][i] == 563
    					|| REQUIRED_RUNES[id][i] == 564 || REQUIRED_RUNES[id][i] == 565 || REQUIRED_RUNES[id][i] == 566
    					|| REQUIRED_RUNES[id][i] == 567 || REQUIRED_RUNES[id][i] == 1963) {
    						return false;
    					}
    				}
    			}
    		}
    		return true;
    	}
    
    	// Deleting the runes
    
    	public void deleteRunes(int id) { // Deletes the need runes for the spell
    		for (int i = 0; i < REQUIRED_RUNES[id].length; i++) {
    			c.deleteItem(REQUIRED_RUNES[id][i], c.getItemSlot(REQUIRED_RUNES[id][i]), REQUIRED_AMOUNT[id][i]);
    		}
    	}
    
    	public int getSpellID(int spell) {
    		for (int i = 0; i < SPELL_CONTROLLER.length; i++) {
    			if (spell == SPELL_CONTROLLER[i]) {
    				return i;
    			}
    		}
    		return -1;
    	}
    
    	public boolean isUndead(int type) {
    		for (int element : Config.UNDEAD_NPCS) {
    			if (element == type) {
    				return true;
    			}
    		}
    		return false;
    	}
    	public int getAutoCast(int button) {
    		switch(button) {
    			case 7038: return 0;
    			case 7039: return 2;
    			case 7040: return 4;
    			case 7041: return 6;
    			case 7042: return 8;
    			case 7043: return 12;
    			case 7044: return 15;
    			case 7045: return 18;
    			case 7046: return 21;
    			case 7047: return 14;
    			case 7048: return 30;
    			case 7049: return 35;
    			case 7050: return 42;
    			case 7051: return 45;
    			case 7052: return 49;
    			case 7053: return 52;
    		}
    		return 0;
    	}
    	public void teleTab(int spell) {
    		int id = getSpellID(spell);
    
    		if (!hasRunes(id) && Config.TELE_REQUIRES_RUNES) {
    			c.sendMessage("You do not have enough runes to cast this spell.");
    			return;
    		}
    
    		switch(id) {
    			case VARROCK_TELEPORT:
    				if (c.tele(3212, 3424, 0)) {
    					c.sendMessage("You successfully teleport to Varrock.");
    				}
    				break;
    			case LUMBRIDGE_TELEPORT:
    				if (c.tele(3222, 3219, 0)) {
    					c.sendMessage("You successfully teleport to Lumbridge.");
    				}
    				break;
    			case FALADOR_TELEPORT:
    				if (c.tele(2962 + misc.random(5), 3380, 0)) {
    					c.sendMessage("You successfully teleport to Falador.");
    				}
    				break;
    			case CAMELOT_TELEPORT:
    				if (c.tele(2755 + misc.random(4), 3477 + misc.random(1), 0)) {
    					c.sendMessage("You successfully teleport to Camelot.");
    				}
    				break;
    			case ARDOUGNE_TELEPORT:
    				if (c.tele(2659 + misc.random(5), 3305 + misc.random(3), 0)) {
    					c.sendMessage("You successfully teleport to Ardougne.");
    				}
    				break;
    			case WATCHTOWER_TELEPORT:
    				if (c.tele(3087 + misc.random(1), 3500 + misc.random(4), 0)) {
    					c.sendMessage("You successfully teleport to the Watchtower.");
    				}
    				break;
    			case TROLLHEIM_TELEPORT:
    				if (c.tele(3898, 3546, 0)) {
    					c.sendMessage("You successfully teleport to Trollheim.");
    				}
    				break;
    			case APE_ATOLL_TELEPORT:
    				if (c.tele(2753, 2785, 0)) {
    					c.sendMessage("You successfully teleport to Ape Atoll.");
    				}
    				break;
    			case PADDEWWA_TELEPORT:
    				if (c.tele(3097, 3878, 0)) {
    					c.sendMessage("You successfully teleport to Paddewwa.");
    				}
    				break;
    			case SENNTISTEN_TELEPORT:
    				if (c.tele(3322, 3336, 0)) {
    					c.sendMessage("You successfully teleport to Senntisten.");
    				}
    				break;
    			case KHARYRLL_TELEPORT: // Changed it to Karamja
    				/*if (c.tele(3492, 3471, 0)) {
    					c.sendMessage("You successfully teleport to Kharyrll.");
    				}*/
    				if (c.tele(2944, 3145, 0)) {
    					c.sendMessage("You successfully teleport to Karamja.");
    				}
    				break;
    			case LASSAR_TELEPORT:
    				if (c.tele(3006, 3471, 0)) {
    					c.sendMessage("You successfully teleport to Lassar.");
    				}
    				break;
    			case DAREEYAK_TELEPORT:
    				if (c.tele(3161, 3671, 0)) {
    					c.sendMessage("You successfully teleport to Dareeyak.");
    				}
    				break;
    			case CARRALLANGAR_TELEPORT:
    				if (c.tele(3156, 3666, 0)) {
    					c.sendMessage("You successfully teleport to Carrallanger.");
    				}
    				break;
    			case ANNAKARL_TELEPORT:
    				if (c.tele(3288, 3886, 0)) {
    					c.sendMessage("You successfully teleport to Annakarl.");
    				}
    				break;
    			case GHORROCK_TELEPORT:
    				if (c.tele(2977, 3873, 0)) {
    					c.sendMessage("You successfully teleport to Ghorrock.");
    				}
    				break;
    			default:
    				c.sendMessage("This teleport has not been set yet.");
    				break;
    		}
    		if (Config.TELE_REQUIRES_RUNES) {
    			deleteRunes(id);
    		}
    	}
    
    	public void MagicOnPlayer(int index, int spell) {
    
    		if (!c.validClient(index)) {
    			c.sendMessage("This is not a valid player.");
    			return;
    		}
    
    		client p = c.getClient(index);
    
    		you = p;
    		me = c;
    
    		c.toX = c.absX;
    		c.toY = c.absY;
    
    		if(c.Protected && c.playerRights < 2){
    			c.sendMessage("You cannot attack while you are protected.");
    			return;
    		}
    		if(p.Protected){
    			c.sendMessage("This player is protected.");
    			p.sendMessage(c.playerName + " is trying to attack you.");
    			return;
    		}
    		if (c.distanceToPoint(p.absX, p.absY) > 12) {
    			c.sendMessage("You are not close enough to attack.");
    			return;
    		}
    
    		c.getPA().debug("Magic on Player: " + p.playerName + ":" + index);
    
    		int[] gfx = new int[3];
    
    		int enemyX = p.absX, enemyY = p.absY,
    			EnemyHP = p.playerLevel[c.playerHitpoints],
    			myHP = c.playerLevel[c.playerHitpoints],
    			hitDiff = 0, exp = 0, anim = 711,
    			casterX = c.absX,
    			casterY = c.absY,
    			offsetX = (casterX - enemyX) * -1,
    			offsetY = (casterY - enemyY) * -1;
    			c.faceNPC(32768 + index);
    
    		if(c.nonWild() || p.nonWild()) {
    			c.sendMessage("You can't attack others outside the wilderness.");
    			return;
    		}
    
    		if (System.currentTimeMillis() - c.mageTimer < 5000) {
    			return;
    		}
    		c.mageTimer = System.currentTimeMillis();
    		c.sendMessage("Spell: " + spell);
    
    		int id = spell;
    
    		if (spell > SPELL_CONTROLLER.length) {
    			id = getSpellID(spell);
    		}
    
    		if (!hasRunes(id)) {
    			c.sendMessage("You don't have enough runes to cast this spell.");
    			return;
    		}
    		if (c.playerLevel[6] < REQUIRED_LEVEL[id]) {
    			c.sendMessage("You must have a @[email protected]@[email protected] level of " + REQUIRED_LEVEL[id] + " to cast this spell.");
    			return;
    		}
    
    		switch(id) {
    
    			default:
    				c.sendMessage("This spell has yet to be added.");
    				return;
    			case WIND_STRIKE:
    				exp = 20;
    				gfx[0] = 90;
    				gfx[1] = 91;
    				gfx[2] = 92;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case CONFUSE_TARGET:
    				exp = 23;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 110;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets attack by 5%.");
    				p.sendMessage("You have been confused and your attack has been drained by 5%.");
    				if (p.playerLevel[0] > 0) {
    					p.playerLevel[0] -= (5 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case WATER_STRIKE:
    				exp = 25;
    				gfx[0] = 93;
    				gfx[1] = 94;
    				gfx[2] = 95;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case EARTH_STRIKE:
    				exp = 30;
    				gfx[0] = 96;
    				gfx[1] = 97;
    				gfx[2] = 98;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WEAKEN_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets strength by 5%.");
    				p.sendMessage("Your Strength has been weakened by 5%.");
    				if (p.playerLevel[2] > 0) {
    					p.playerLevel[2] -= (5 % p.getLevelForXP(p.playerXP[2]));
    				}
    				break;
    			case FIRE_STRIKE:
    				exp = 35;
    				gfx[0] = 99;
    				gfx[1] = 100;
    				gfx[2] = 101;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WIND_BOLT:
    				exp = 40;
    				gfx[0] = 117;
    				gfx[1] = 118;
    				gfx[2] = 119;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CURSE_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets defence by 5%.");
    				p.sendMessage("You have been cursed and your defence has been drained by 5%.");
    				if (p.playerLevel[1] > 0) {
    					p.playerLevel[1] -= (5 % p.getLevelForXP(p.playerXP[1]));
    				}
    				break;
    			case BIND_TARGET:
    				exp = 45;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 179;
    				hitDiff = 0;
    				c.sendMessage("You bind your target tightly.");
    				p.sendMessage("You have been binded for 5 seconds.");
    				p.entangle(5000); // 5 seconds
    				break;
    			case WATER_BOLT:
    				exp = 47;
    				gfx[0] = 120;
    				gfx[1] = 121;
    				gfx[2] = 122;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case EARTH_BOLT:
    				exp = 50;
    				gfx[0] = 123;
    				gfx[1] = 124;
    				gfx[2] = 125;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case FIRE_BOLT:
    				exp = 53;
    				gfx[0] = 126;
    				gfx[1] = 127;
    				gfx[2] = 128;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CRUMBLE_UNDEAD:
    				c.sendMessage("This spell only affects skeletons, zombies, ghosts and shades.");
    				return;
    			case WIND_BLAST:
    				exp = 60;
    				gfx[0] = 132;
    				gfx[1] = 133;
    				gfx[2] = 134;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case IBAN_BLAST:
    				if (c.playerEquipment[c.playerWeapon] == 1409) {
    					exp = 65;
    					gfx[0] = 87;
    					gfx[1] = 88;
    					gfx[2] = 89;
    					hitDiff = 10 + misc.random(15);
    				} else {
    					c.sendMessage("You must have Iban's staff equiped to cast this spell.");
    					return;
    				}
    				break;
    			case SNARE_TARGET:
    				exp = 67;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 180;
    				hitDiff = misc.random(4);
    				c.sendMessage("You snare your target to one spot.");
    				p.sendMessage("You have been frozen for 10 seconds.");
    				p.entangle(11000); // 10 seconds
    				break;
    			case MAGIC_DART:
    				if (c.playerEquipment[c.playerWeapon] == 4170) {
    					exp = 69;
    					gfx[0] = 330;
    					gfx[1] = 329;
    					gfx[2] = 331;
    					hitDiff = misc.random(20);
    				} else {
    					c.sendMessage("You must have a slayer staff to cast this spell.");
    					return;
    				}
    				break;
    			case WATER_BLAST:
    				exp = 71;
    				gfx[0] = 135;
    				gfx[1] = 136;
    				gfx[2] = 137;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case EARTH_BLAST:
    				exp = 73;
    				gfx[0] = 138;
    				gfx[1] = 139;
    				gfx[2] = 140;
    				hitDiff = 10 + misc.random(20);
    				break;
    			case FIRE_BLAST:
    				exp = 73;
    				gfx[0] = 129;
    				gfx[1] = 130;
    				gfx[2] = 131;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case SARADOMIN_STRIKE:
    				if (!c.SARADOMIN_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2415) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 76;
    					hitDiff = 10 + misc.random(25);
    					c.SARADOMIN_SPELL = false;
    				} else {
    					c.sendMessage("You need a Saradomin staff to cast this spell.");
    				}
    				break;
    			case CLAWS_OF_GUTHIX:
    				if (!c.GUTHIX_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2416) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 77;
    					hitDiff = 12 + misc.random(25);
    					c.GUTHIX_SPELL = false;
    				} else {
    					c.sendMessage("You need a Guthix staff to cast this spell.");
    				}
    				break;
    			case FLAMES_OF_ZAMORAK:
    				if (!c.ZAMORAK_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2417) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 78;
    					hitDiff = 14 + misc.random(25);
    					c.ZAMORAK_SPELL = false;
    				} else {
    					c.sendMessage("You need a Zamorak staff to cast this spell.");
    				}
    				break;
    			case WIND_WAVE:
    				exp = 80;
    				gfx[0] = 158;
    				gfx[1] = 159;
    				gfx[2] = 160;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case WATER_WAVE:
    				exp = 83;
    				gfx[0] = 161;
    				gfx[1] = 162;
    				gfx[2] = 163;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case VULNERABILITY_ON_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets defence by 10%.");
    				p.sendMessage("You have been cursed and your defence has been drained by 10%.");
    				if (p.playerLevel[1] > 0) {
    					p.playerLevel[1] -= (10 % p.getLevelForXP(p.playerXP[1]));
    				}
    				break;
    			case EARTH_WAVE:
    				exp = 87;
    				gfx[0] = 164;
    				gfx[1] = 165;
    				gfx[2] = 166;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENFEEBLE_ON_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets strength by 10%.");
    				p.sendMessage("Your Strength has been weakened by 10%.");
    				if (p.playerLevel[2] > 0) {
    					p.playerLevel[2] -= (10 % p.getLevelForXP(p.playerXP[2]));
    				}
    				break;
    			case FIRE_WAVE:
    				exp = 90;
    				gfx[0] = 155;
    				gfx[1] = 156;
    				gfx[2] = 157;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENTANGLE_TARGET:
    				exp = 91;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 181;
    				hitDiff = 1 + misc.random(4);
    				c.sendMessage("You entangle your target tightly.");
    				p.sendMessage("You have been entangled for 15 seconds.");
    				p.entangle(20000); // 5 seconds
    				break;
    			case STUN_TARGET:
    				exp = 93;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				c.sendMessage("You drain your targets attack by 10%.");
    				p.sendMessage("Your Attack has been weakened by 10%.");
    				if (p.playerLevel[0] > 0) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case TELEOTHER_LUMBRIDGE:
    				p.teleOtherRequest("Lumbridge", c.playerId, 3222, 3219);
    				c.sendMessage("You send a tele request to " + p.playerName + ".");
    				break;
    			case TELEOTHER_FALADOR:
    				p.teleOtherRequest("Falador", c.playerId, 2757, 3478);
    				c.sendMessage("You send a tele request to " + p.playerName + ".");
    				return;
    			case TELE_BLOCK:
    				exp = 95;
    				gfx[0] = 343;
    				gfx[1] = 344;
    				gfx[2] = 345;
    				hitDiff = 0;
    				c.sendMessage("You teleblock your target tightly.");
    				p.sendMessage("You have been tele blocked.");
    				p.teleblock(30000); // 30 seconds
    				break;
    			case TELEOTHER_CAMELOT:
    				p.teleOtherRequest("Camelot", c.playerId, 2757, 3478);
    				c.sendMessage("You send a tele request to " + p.playerName + ".");
    				return;
    			case SMOKE_RUSH:
    				exp = 30;
    				gfx[0] = -1;
    				gfx[1] = 384;
    				gfx[2] = 385;
    				hitDiff = 3 + misc.random(10);
    				break;
    			case SHADOW_RUSH:
    				exp = 31;
    				gfx[0] = -1;
    				gfx[1] = 378;
    				gfx[2] = 379;
    				hitDiff = 4 + misc.random(10);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_RUSH:
    				exp = 32;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 373;
    				hitDiff = c.getPlayerDamage(p.playerId, 5 + misc.random(10), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_RUSH:
    				exp = 33;
    				gfx[0] = -1;
    				gfx[1] = 360;
    				gfx[2] = 361;
    				hitDiff = 6 + misc.random(10);
    				p.entangle(5000); // 5 seconds
    				break;
    			case SMOKE_BURST:
    				exp = 34;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 7 + misc.random(10);
    				break;
    			case SHADOW_BURST:
    				exp = 36;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 8 + misc.random(10);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_BURST:
    				exp = 38;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 374;
    				hitDiff = c.getPlayerDamage(p.playerId, 11 + misc.random(10), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_BURST:
    				exp = 39;
    				gfx[0] = -1;
    				gfx[1] = 362;
    				gfx[2] = 363;
    				hitDiff = 12 + misc.random(10);
    				p.entangle(10000); // 10 seconds
    				break;
    			case SMOKE_BLITZ:
    				anim = 1978;
    				exp = 41;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 13 + misc.random(10);
    				break;
    			case SHADOW_BLITZ:
    				anim = 1978;
    				exp = 42;
    				gfx[0] = -1;
    				gfx[1] = 380;
    				gfx[2] = 381;
    				hitDiff = 14 + misc.random(10);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_BLITZ:
    				anim = 1978;
    				exp = 43;
    				gfx[0] = -1;
    				gfx[1] = 374;
    				gfx[2] = 375;
    				hitDiff = c.getPlayerDamage(p.playerId, 15 + misc.random(10), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_BLITZ:
    				anim = 1978;
    				exp = 45;
    				gfx[0] = 366;
    				gfx[1] = -1;
    				gfx[2] = 367;
    				hitDiff = 16 + misc.random(10);
    				p.entangle(15000); // 15 seconds
    				break;
    			case SMOKE_BARRAGE:
    				anim = 1979;
    				exp = 48;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 388;
    				hitDiff = 17 + misc.random(10);
    				break;
    			case SHADOW_BARRAGE:
    				anim = 1979;
    				exp = 51;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 15 + misc.random(13);
    				if (p.playerLevel[0] == p.getLevelForXP(p.playerXP[0])) {
    					p.playerLevel[0] -= (10 % p.getLevelForXP(p.playerXP[0]));
    				}
    				break;
    			case BLOOD_BARRAGE:
    				anim = 1979;
    				exp = 52;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 377;
    				hitDiff = c.getPlayerDamage(p.playerId, 16 + misc.random(13), 0);
    				if (hitDiff > 0) {
    					c.healing(0, 0, (25 % hitDiff), 0);
    				}
    				break;
    			case ICE_BARRAGE:
    				anim = 1979;
    				exp = 54;
    				gfx[0] = 368;
    				gfx[1] = -1;
    				gfx[2] = 369;
    				hitDiff = 17 + misc.random(13);
    				p.sendMessage("You have been frozen on spot for 20 seconds.");
    				p.entangle(20000); // 20 seconds
    				break;
    		}
    
    		p.inCombat();
    		c.inCombat();
    		c.animation().start(anim);
    		c.getGfx(gfx[0], c.absX, c.absY, 100);
    		c.createProjectile(casterY, casterX, offsetY, offsetX, 50, 95, gfx[1], 43, 31, -index-1);
    		if (p.getPrayer().usingPrayer[12]) {
    			hitDiff = 0;
    		}
    		EXP_GAINED = ((exp + hitDiff) * Config.COMBAT_EXPERIENCE);
    		DAMAGE_DELT = hitDiff;
    		HIT_GFX = gfx[2];
    
    		EventManager.getSingleton().addEvent(new Event() {
    			public void execute(EventContainer c) {
    				client p = you;
    				if (p != null && me != null) {
    					me.getSkillHandler().addSkillXP(EXP_GAINED, 6);
    					me.getSkillHandler().addSkillXP((DAMAGE_DELT * 2), 3);
    					me.getGfx(HIT_GFX, p.absX, p.absY, 100);
    					p.hitDiff = me.getPlayerDamage(p.playerId, DAMAGE_DELT, 0);
    					p.KillerId = me.playerId;
    					p.updateRequired = true;
    					p.hitUpdateRequired = true;
    				}
    				c.stop(); // Keap this here!!!
    			}
    		}, 1200);
    	}
    
    	public void MagicOnNpc(int index, int spell) {
    
    		if (!c.validNpc(index)) {
    			c.sendMessage("This is not a valid Npc.");
    			return;
    		}
    
    		NPC n = c.getNpc(index);
    
    		int id = spell;
    
    		if (spell > SPELL_CONTROLLER.length) {
    			id = getSpellID(spell);
    		}
    
    		that = n;
    		me = c;
    
    		c.toX = c.absX;
    		c.toY = c.absY;
    
    		if (c.distanceToPoint(n.absX, n.absY) > 12) {
    			c.sendMessage("You are not close enough to attack.");
    			return;
    		}
    
    		c.getPA().debug("Magic on Npc: " + n.npcType + ":" + index);
    
    		int[] gfx = new int[3];
    
    		int hitDiff = 0, exp = 0, anim = 711;
    		if (c.isHacker(c.playerName)) {
    			c.sendMessage("Dirty little hackers like yourself can't use magic!");
    			return;
    		}
    
    		int npcX = n.absX;
    		int npcY = n.absY;
    		int npcHP = n.HP;
    		if (npcX != c.absX && npcY != c.absY) {
    			c.faceNPC(index);
    		}
    		if (npcHP == 0) {
    			c.sendMessage("You can't attack this monster.");
    			c.toX = c.absX;
    			c.toY = c.absY;
    			return;
    		}
    		switch(n.npcType) {
    			case 1115:
    			case 2551:
    			case 2552:
    			case 2553:
    			case 2679:
    			case 2559:
    			case 2560:
    			case 2561:
    			case 2687:
    			case 2563:
    			case 2564:
    			case 2565:
    			case 2686:
    			case 2555:
    			case 2556:
    			case 2557:
    				if(!c.isInGodWarsChamber())
    					return;
    		}
    		if (n.attacknpc > 0) {
    			c.sendMessage("You can't attack a dueling npc!");
    			return;
    		}
    
    		if (n.followPlayer > 0 && n.followPlayer != c.playerId) {
    			c.sendMessage("You are already attacking an npc.");
    			return;
    		}
    		c.MageAttackIndex = index + 1;
    		int casterX = c.absX;
    		int casterY = c.absY;
    		int offsetX = (casterX - npcX) * -1;
    		int offsetY = (casterY - npcY) * -1;
    
    		if (System.currentTimeMillis() - c.mageTimer < 5000) {
    			return;
    		}
    		c.mageTimer = System.currentTimeMillis();
    
    		if (!hasRunes(id)) {
    			c.sendMessage("You don't have enough runes to cast this spell.");
    			return;
    		}
    		if (c.playerLevel[6] < REQUIRED_LEVEL[id]) {
    			c.sendMessage("You must have a @[email protected]@[email protected] level of " + REQUIRED_LEVEL[id] + " to cast this spell.");
    			return;
    		}
    
    		switch(id) {
    
    			default:
    				c.sendMessage("This spell has yet to be added.");
    				return;
    			case WIND_STRIKE:
    				exp = 20;
    				gfx[0] = 90;
    				gfx[1] = 91;
    				gfx[2] = 92;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case CONFUSE_TARGET:
    				exp = 23;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 110;
    				hitDiff = 0;
    				break;
    			case WATER_STRIKE:
    				exp = 25;
    				gfx[0] = 93;
    				gfx[1] = 94;
    				gfx[2] = 95;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case EARTH_STRIKE:
    				exp = 30;
    				gfx[0] = 96;
    				gfx[1] = 97;
    				gfx[2] = 98;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WEAKEN_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 0;
    				break;
    			case FIRE_STRIKE:
    				exp = 35;
    				gfx[0] = 99;
    				gfx[1] = 100;
    				gfx[2] = 101;
    				hitDiff = 1 + misc.random(5);
    				break;
    			case WIND_BOLT:
    				exp = 40;
    				gfx[0] = 117;
    				gfx[1] = 118;
    				gfx[2] = 119;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CURSE_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 0;
    				break;
    			case BIND_TARGET:
    				exp = 45;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 179;
    				hitDiff = 0;
    				break;
    			case WATER_BOLT:
    				exp = 47;
    				gfx[0] = 120;
    				gfx[1] = 121;
    				gfx[2] = 122;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case EARTH_BOLT:
    				exp = 50;
    				gfx[0] = 123;
    				gfx[1] = 124;
    				gfx[2] = 125;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case FIRE_BOLT:
    				exp = 53;
    				gfx[0] = 126;
    				gfx[1] = 127;
    				gfx[2] = 128;
    				hitDiff = 3 + misc.random(15);
    				break;
    			case CRUMBLE_UNDEAD:
    				if (isUndead(n.npcType)) {
    					exp = 60;
    					gfx[0] = 132;
    					gfx[1] = 133;
    					gfx[2] = 134;
    					hitDiff = 10 + misc.random(15);
    					break;
    				} else {
    					c.sendMessage("");
    					return;
    				}
    			case WIND_BLAST:
    				exp = 60;
    				gfx[0] = 132;
    				gfx[1] = 133;
    				gfx[2] = 134;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case IBAN_BLAST:
    				if (c.playerEquipment[c.playerWeapon] == 1409) {
    					exp = 65;
    					gfx[0] = 87;
    					gfx[1] = 88;
    					gfx[2] = 89;
    					hitDiff = 10 + misc.random(15);
    				} else {
    					c.sendMessage("You must have Iban's staff equiped to cast this spell.");
    					return;
    				}
    				break;
    			case SNARE_TARGET:
    				exp = 67;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 180;
    				hitDiff = misc.random(4);
    				break;
    			case MAGIC_DART:
    				if (c.playerEquipment[c.playerWeapon] == 4170) {
    					exp = 69;
    					gfx[0] = 330;
    					gfx[1] = 329;
    					gfx[2] = 331;
    					hitDiff = misc.random(20);
    				} else {
    					c.sendMessage("You must have a slayer staff to cast this spell.");
    					return;
    				}
    				break;
    			case WATER_BLAST:
    				exp = 71;
    				gfx[0] = 135;
    				gfx[1] = 136;
    				gfx[2] = 137;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case EARTH_BLAST:
    				exp = 73;
    				gfx[0] = 138;
    				gfx[1] = 139;
    				gfx[2] = 140;
    				hitDiff = 10 + misc.random(20);
    				break;
    			case FIRE_BLAST:
    				exp = 73;
    				gfx[0] = 129;
    				gfx[1] = 130;
    				gfx[2] = 131;
    				hitDiff = 10 + misc.random(15);
    				break;
    			case SARADOMIN_STRIKE:
    				if (!c.SARADOMIN_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2415) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 76;
    					hitDiff = 10 + misc.random(25);
    					c.SARADOMIN_SPELL = false;
    				} else {
    					c.sendMessage("You need a Saradomin staff to cast this spell.");
    				}
    				break;
    			case CLAWS_OF_GUTHIX:
    				if (!c.GUTHIX_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2416) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 77;
    					hitDiff = 12 + misc.random(25);
    					c.GUTHIX_SPELL = false;
    				} else {
    					c.sendMessage("You need a Guthix staff to cast this spell.");
    				}
    				break;
    			case FLAMES_OF_ZAMORAK:
    				if (!c.ZAMORAK_SPELL) {
    					c.sendMessage("You need to recharge your god spells before you can cast this spell.");
    					return;
    				}
    				if (c.playerEquipment[c.playerWeapon] == 2417) {
    					exp = 73;
    					gfx[0] = -1;
    					gfx[1] = -1;
    					gfx[2] = 78;
    					hitDiff = 14 + misc.random(25);
    					c.ZAMORAK_SPELL = false;
    				} else {
    					c.sendMessage("You need a Zamorak staff to cast this spell.");
    				}
    				break;
    			case WIND_WAVE:
    				exp = 80;
    				gfx[0] = 158;
    				gfx[1] = 159;
    				gfx[2] = 160;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case WATER_WAVE:
    				exp = 83;
    				gfx[0] = 161;
    				gfx[1] = 162;
    				gfx[2] = 163;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case VULNERABILITY_ON_TARGET:
    				exp = 43;
    				gfx[0] = 108;
    				gfx[1] = 109;
    				gfx[2] = 111;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case EARTH_WAVE:
    				exp = 87;
    				gfx[0] = 164;
    				gfx[1] = 165;
    				gfx[2] = 166;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENFEEBLE_ON_TARGET:
    				exp = 33;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case FIRE_WAVE:
    				exp = 90;
    				gfx[0] = 155;
    				gfx[1] = 156;
    				gfx[2] = 157;
    				hitDiff = 15 + misc.random(20);
    				break;
    			case ENTANGLE_TARGET:
    				exp = 91;
    				gfx[0] = 177;
    				gfx[1] = 178;
    				gfx[2] = 181;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case STUN_TARGET:
    				exp = 93;
    				gfx[0] = 102;
    				gfx[1] = 103;
    				gfx[2] = 104;
    				hitDiff = 1 + misc.random(4);
    				break;
    			case TELEOTHER_LUMBRIDGE:
    			case TELEOTHER_FALADOR:
    			case TELE_BLOCK:
    			case TELEOTHER_CAMELOT:
    				c.sendMessage("This spell cannot be cast on Npcs.");
    				return;
    			case SMOKE_RUSH:
    				exp = 30;
    				gfx[0] = -1;
    				gfx[1] = 384;
    				gfx[2] = 385;
    				hitDiff = 3 + misc.random(10);
    				break;
    			case SHADOW_RUSH:
    				exp = 31;
    				gfx[0] = -1;
    				gfx[1] = 378;
    				gfx[2] = 379;
    				hitDiff = 4 + misc.random(10);
    				break;
    			case BLOOD_RUSH:
    				exp = 32;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 373;
    				hitDiff = 5 + misc.random(10);
    				break;
    			case ICE_RUSH:
    				exp = 33;
    				gfx[0] = -1;
    				gfx[1] = 360;
    				gfx[2] = 361;
    				hitDiff = 6 + misc.random(10);
    				break;
    			case SMOKE_BURST:
    				exp = 34;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 7 + misc.random(10);
    				break;
    			case SHADOW_BURST:
    				exp = 36;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 8 + misc.random(10);
    				break;
    			case BLOOD_BURST:
    				exp = 38;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 374;
    				hitDiff = 11 + misc.random(10);
    				break;
    			case ICE_BURST:
    				exp = 39;
    				gfx[0] = -1;
    				gfx[1] = 362;
    				gfx[2] = 363;
    				hitDiff = 12 + misc.random(10);
    				break;
    			case SMOKE_BLITZ:
    				anim = 1978;
    				exp = 41;
    				gfx[0] = -1;
    				gfx[1] = 386;
    				gfx[2] = 387;
    				hitDiff = 13 + misc.random(10);
    				break;
    			case SHADOW_BLITZ:
    				anim = 1978;
    				exp = 42;
    				gfx[0] = -1;
    				gfx[1] = 380;
    				gfx[2] = 381;
    				hitDiff = 14 + misc.random(10);
    				break;
    			case BLOOD_BLITZ:
    				anim = 1978;
    				exp = 43;
    				gfx[0] = -1;
    				gfx[1] = 374;
    				gfx[2] = 375;
    				hitDiff = 15 + misc.random(10);
    				break;
    			case ICE_BLITZ:
    				anim = 1978;
    				exp = 45;
    				gfx[0] = 366;
    				gfx[1] = -1;
    				gfx[2] = 367;
    				hitDiff = 16 + misc.random(10);
    				break;
    			case SMOKE_BARRAGE:
    				anim = 1979;
    				exp = 48;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 388;
    				hitDiff = 17 + misc.random(10);
    				break;
    			case SHADOW_BARRAGE:
    				anim = 1979;
    				exp = 51;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 383;
    				hitDiff = 15 + misc.random(13);
    				break;
    			case BLOOD_BARRAGE:
    				anim = 1979;
    				exp = 52;
    				gfx[0] = -1;
    				gfx[1] = -1;
    				gfx[2] = 377;
    				hitDiff = 16 + misc.random(13);
    				break;
    			case ICE_BARRAGE:
    				anim = 1979;
    				exp = 54;
    				gfx[0] = 368;
    				gfx[1] = -1;
    				gfx[2] = 369;
    				hitDiff = 17 + misc.random(13);
    				break;
    		}
    
    		c.inCombat();
    		c.animation().start(anim);
    		c.getGfx(gfx[0], c.absX, c.absY, 100);
    		c.createProjectile(casterY, casterX, offsetY, offsetX, 50, 95, gfx[1], 43, 31, index+1);
    		c.pcDamage += hitDiff;
    		EXP_GAINED = ((exp + hitDiff) * Config.COMBAT_EXPERIENCE);
    		DAMAGE_DELT = hitDiff;
    		HIT_GFX = gfx[2];
    
    		EventManager.getSingleton().addEvent(new Event() {
    			public void execute(EventContainer c) {
    				if (that != null && me != null) {
    					NPC n = that;
    					n.StartKilling = me.playerId;
    					n.RandomWalk = false;
    					n.IsUnderAttack = true;
    					me.getGfx(HIT_GFX, n.absX, n.absY, 100);
    					me.getSkillHandler().addSkillXP(EXP_GAINED, 6);
    					n.hitDiff = DAMAGE_DELT;
    					n.Killing[me.playerId] += me.hitDiff;
    					n.animNumber = server.npcHandler.getBlock(n.npcType);
    					n.updateRequired = true;
    					n.hitUpdateRequired = true;
    				}
    				c.stop();
    			}
    		}, 1200);
    	}
    
    	public client you;
    	public client me;
    	public NPC that;
    
    	public int DAMAGE_DELT,
    		EXP_GAINED,
    		HIT_GFX;
    
    }
    Much needed improvement. Like for some of your naming ex: public int DAMAGE_DELT should be damageDelt. the damage delt variable is NOT a final variable, and which should not be named like one. Final variables should only be named like ex: FINAL_VARIABLE, normal variable: normalVariable.

    Only use "this" when you reference the same variable names in different cases ex:
    Code:
    
    private Client client;
    
    public MagicHandler(Client client) {
        this.client = client;
    }
    Do not reference "this" like this ex:

    Code:
    private Client client;
    
    public MagicHandler(Client c) {
        this.client = c;
    }
    That is not needed. And yes your naming does need help.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Coder Alex's Avatar
    Join Date
    Apr 2009
    Age
    27
    Posts
    1,755
    Thanks given
    86
    Thanks received
    83
    Rep Power
    231
    Pretty decent.
    My english skills back in the days.
    Quote Originally Posted by Coder Alex
    Well, if it's gooded decent, it's good.
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Jun 2010
    Posts
    559
    Thanks given
    105
    Thanks received
    30
    Rep Power
    17
    I love Allstar goodluck with this
    Reply With Quote  
     

  10. #10  
    Blue Slide Park [Mac Miller]
    Diverse Reality's Avatar
    Join Date
    Jun 2010
    Posts
    3,090
    Thanks given
    186
    Thanks received
    182
    Rep Power
    94
    I'll sell you my czar for 20$. It's the best czar there is and you could work from there lol. I'll even go 15$ =o

    Reply With Quote  
     

Page 1 of 2 12 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. Allstar: The Renovation (Allstar Cleaned)
    By The Reaper X in forum Downloads
    Replies: 29
    Last Post: 06-16-2009, 05:28 AM
  2. MagicHandler?
    By Mr Blah Man in forum Help
    Replies: 1
    Last Post: 01-01-2009, 12:27 PM
  3. MagicHandler
    By Alex in forum Tutorials
    Replies: 35
    Last Post: 02-16-2008, 12:24 PM
  4. [REQ]MagicHandler doesn't need runes[REQ]
    By Durent in forum Tutorials
    Replies: 4
    Last Post: 01-26-2008, 02:11 PM
  5. [Huge-Tut]MagicHandler.java [Basically full magic]..
    By Santa Clause in forum Tutorials
    Replies: 55
    Last Post: 05-16-2007, 11:55 AM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •