ANNOUNCEMENT: I am currently working on 100% magic. This void does NOT work exactly like it does in runscape for every spell. I'll be making 100% magic; and then releasing once I finish. You can use this for now; but it's not 100%
Description: Well; this isn't exactly a tutorial; but I got bored and decided to write a void to reduce the space magic spells take in your server.
Difficulty: 1
Assumed Knowledge: There is nothing you need to know before doing this.
Tested Server: Cleaned V4 - SHOULD work on all
Files/Classes Modified: Client.Java
Procedure
Part One: Combat Spells
Step 1: Add this void to client.java ABOVE
Code:
public void castTheSpell(int req, int xp, int r1, int a1, int r2, int a2, int r3, int a3, int r4, int a4, int ba, int ra, int anim, int gfx) {
int EnemyX2 = PlayerHandler.players[AttackingOn].absX;
int EnemyY2 = PlayerHandler.players[AttackingOn].absY;
if (playerLevel[6] > req) {
if((!playerHasItemAmount(r1, a1)) || (!playerHasItemAmount(r2, a2)) || (!playerHasItemAmount(r3, a3)) || (!playerHasItemAmount(r4, a4))) {
sendMessage("You do not have the required runes to cast this spell.");
}
if((playerHasItemAmount(r1, a1)) && (playerHasItemAmount(r2, a2)) && (playerHasItemAmount(r3, a3)) && (playerHasItemAmount(r4, a4))) {
hitDiff = ba + misc.random(ra);
setAnimation(anim);
addSkillXP(xp, 6);
deleteItem(r1, getItemSlot(r1), a1);
deleteItem(r2, getItemSlot(r2), a2);
deleteItem(r3, getItemSlot(r3), a3);
deleteItem(r4, getItemSlot(r4), a4);
stillgfx(gfx, EnemyY2, EnemyX2);
}
} else {
sendMessage("You need a magic level of " +req+ " to use this spell");
}
}
Step 2: Now go to where your magic spells are located at. You should see something similar to the void I just gave you. Use the information from the spells you already have to re-write the spells using the void.
Explanation: The new void reduces the size of your spell a lot. Deleting a ton of lines but you may be slightly confused on what to do. Here's an explanation of everything.
Code:
req: The level required to cast the spell
xp: The base experience gained for casting the spell (without hit exp)
r1: The first rune type needed to cast the spell
a1: The amount of the first rune needed to cast the spell
r2: The second rune type needed to cast the spell
a2: The amount of the second rune needed to cast the spell
r3: The third type of rune needed to cast the spell
a3: The amount of the third rune needed to cast the spell
r4: The fourth type of rune needed to cast the spell
a4: The amount of the fourth type of rune needed to cast the spell
ba: The minimum (base) amount of damage done in a spell
ra: The varying damage added to the base of the spell
anim: The animation your character will do when you cast the spell
gfx: The gfx that appears on your enemy (barrage cube for example)
Example: Heres an example using ice barrage
Code:
if(magicID == 12891) { castTheSpell(94, 250, 560, 4, 565, 2, 555, 6, -1, 0, 5, 25, 1979, 369); } //Ice Barrage
Note: If a rune is not needed; Set the ID to -1. And the amount to 0.
Credits: Me: Whoever made the original spell design.
Part Two: Teleport Spells
Step 1:Add this void above
Code:
public void castTheTele(int req, int xp, int gfx, int x, int y, int hl, int r1, int a1, int r2, int a2, int r3, int a3) {
if (playerLevel[6] >= req) {
if((!playerHasItemAmount(r1, a1)) || (!playerHasItemAmount(r2, a2)) || (!playerHasItemAmount(r3, a3))) {
sendMessage("You do not have the required runes to cast this spell.");
}
if((playerHasItemAmount(r1, a1)) && (playerHasItemAmount(r2, a2)) && (playerHasItemAmount(r3, a3))) {
addSkillXP(xp, 6);
teleportToX = x;
teleportToY = y;
heightLevel = hl;
deleteItem(r1, getItemSlot(r1), a1);
deleteItem(r2, getItemSlot(r2), a2);
deleteItem(r3, getItemSlot(r3), a3);
stillgfx(gfx, absX, absY); //308 = Regular -- 392 = Ancients
}
}
sendMessage("You need a magic level of " +req+ " to cast this spell.");
}
Step 2: Teleport spells are found in case 185 (I believe) Add the spells in there.
Explanation:This, like the combat spells, significantly reduces the amount of coding needed to make a spell. Here's an explanation of what everything does.
Code:
req: The magic level needed to cast the spell
xp: The experience gained when you cast the spell
gfx: The gfx when you teleport. (Like the purple cube for ancients)
x: The X coordinate you get teleported to
y: The Y coordinate you get teleported to
hl: The hight level you get teleported to (in most cases; this is 0)
r1: The first rune type needed to cast the spell
a1: The amount of the first rune needed to cast the spell
r2: The second rune type needed to cast the spell
a2: The amount of the second rune needed to cast the spell
r3: The third type of rune needed to cast the spell
a3: The amount of the third rune needed to cast the spell
Example: Here's an example using the falador teleport.
Code:
case 4146: castTheTele(37, 150, 308, 2965, 3379, 0, 555, 1, 556, 3, 563, 1); break; //Falador Teleport
Note: If a third rune is not needed; Set the ID to -1. And the amount to 0.
Credit: Me... I guess