Post or expect termination on you.
Read: This will create an avatar based society in you're source. Basically, you can pick from two races at the moment. Each race has it's bonuses and weapons and emotes. Note, this is only version one and many more updates will come. Although this is untested, the file will work but I'm not saying perfect success in the client class. The only thing that may cause a problem is calling upon the methods in the wrong places. If anyone finds errors about the calling, to post the fix here. Also, this will only work for Devolution or Dodian based servers, sorry!
Features for Avatar v.1:
- Goblin/Elf Families
- Goblin/Elf Separate Walking Animations
- Goblin/Elf Separate Banking Spots
- Goblin/Elf Family Based Levels
- Goblin/Elf Family Based Level Weapon Requirements
- Goblin/Elf Family Weapon Bonuses
- Goblin/Elf Family Level Up Messages
- Goblin/Elf Family Based Starter
- Goblin/Elf Family Based Setting of NPC Depending on Combat Level
- Goblin/Elf Basis of Selecting Family in the Beginning
- Goblin/Elf Leveling up with changing of player NPCID
- Goblin Only Emotes in Emote Tab
Adding:
Create a new file and save it as Avatarhandler.java and then put this in:
Code:
/*
Created by: Rog3r
Version: v0.1
*/
public class Avatarhandler {
public static int Elf, Goblin, familyLevel, elfStarter, goblinStarter, bankSpace, walkAnimation, attackAnimation;
public static boolean goblinWeapon, elfWeapon, setPicked;
public static String GetItemName(int ItemID) {
for (int i = 0; i < server.itemHandler.MaxListedItems; i++) {
if (server.itemHandler.ItemList[i] != null) {
if (server.itemHandler.ItemList[i].itemId == ItemID) {
return server.itemHandler.ItemList[i].itemName;
}
if (ItemID == -1) {
return "Unarmed";
}
}
}
return "Non Existing Item - ID:"+ItemID;
}
public static int GetCLElf(int ItemID) {
if (ItemID == -1) {
return 0;
}
String ItemName = GetItemName(ItemID);
if (ItemName.startsWith("New_crystal")) {
return 5; // You need a Elf family level of 5 to wield this item
}
if (ItemName.startsWith("Dragon_vamb")) {
return 3; // You need a Elf family level of 3 to wield this item (and Def of 60 or what ever dragon is set on)
}
return 0;
}
public static int GetCLGoblin(int ItemID) {
if (ItemID == -1) {
return 0;
}
String ItemName = GetItemName(ItemID);
if (ItemName.startsWith("Dragon sp")) {
return 3; // You need a Goblin family level of 5 to wield this item (and Def of 60 or what ever dragon is set on)
}
if (ItemName.startsWith("Dragon hal")) {
return 3; // You need a Goblin family level of 3 to wield this item (and Def of 60 or what ever dragon is set on)
}
return 0;
}
public static void weaponBonus(int ItemID) {
String ItemName = GetItemName(ItemID);
if (Goblin == 1) {
if (ItemName.endsWith("spear") || ItemName.endsWith("spear(p)") || ItemName.endsWith("spear(kp)")) { // Weapons that give the class a bonus when attacking
goblinWeapon = true;
} else {
goblinWeapon = false;
}
}
if (Elf == 1) {
if (ItemName.endsWith("longbow")) { // Weapons that give the class a bonus when attacking
elfWeapon = true;
} else {
elfWeapon = false;
}
}
}
public static void levelUp(int plrID) {
client client = (client) PlayerHandler.players[plrID];
if (Elf == 1) {
switch (client.combatLevel) { // Displays the level up family level at every level followed
case 4:
case 53:
case 73:
case 103:
playerOn(plrID);
client.sendMessage("Congratulations, you are now a level "+familyLevel+" Elf!");
break;
}
}
if (Goblin == 1) {
switch (client.combatLevel) { // Displays the level up family level at every level followed
case 4:
case 53:
case 73:
case 103:
playerOn(plrID);
client.sendMessage("Congratulations, you are now a level "+familyLevel+" Goblin!");
break;
}
}
}
public static void playerOn(int plrID) {
client client = (client) PlayerHandler.players[plrID];
Elf = 1;
if (Elf == 1) {
bankSpace = 350; // Change the bank space given by the race
walkAnimation = 0x333; // Change the walking animation that will be used for the Elf
if (elfStarter == 1) {
setPicked = true; // < Do not change this!
client.addItem(841, 1); // Change the items that is given by the race when he logs in
client.addItem(882, 100);
elfStarter = 2;
}
if (misc.random(2) == 1) {
client.sendMessage("You're race is currently set at a level "+familyLevel+" Elf.");
} else {
client.sendMessage("You are apart of the level "+familyLevel+" Elf family.");
}
if (client.combatLevel == 3) {
client.npcId = 2361;
client.isNpc = true;
familyLevel = 1;
} else if (client.combatLevel >= 4 && client.combatLevel <= 52) {
client.npcId = 2359;
client.isNpc = true;
familyLevel = 2;
} else if (client.combatLevel >= 53 && client.combatLevel <= 72) {
client.npcId = 2362;
client.isNpc = true;
familyLevel = 3;
} else if (client.combatLevel >= 73 && client.combatLevel <= 102) {
client.npcId = 1183;
client.isNpc = true;
familyLevel = 4;
} else if (client.combatLevel >= 103) {
client.npcId = 1201;
client.isNpc = true;
familyLevel = 5;
}
}
if (Goblin == 1) {
bankSpace = 300; // Change the bank space given by the race
walkAnimation = 0x333; // Change the walking animation that will be used for the Goblin
if (goblinStarter == 1) {
setPicked = true; // < Do not change this!
client.addItem(1237, 1); // Change the items that is given by the race when he logs in
client.addItem(1155, 1);
goblinStarter = 2;
}
if (misc.random(2) == 1) {
client.sendMessage("You're race is currently set at a level "+familyLevel+" Goblin.");
} else {
client.sendMessage("You are apart of the level "+familyLevel+" Goblin family.");
}
if (client.combatLevel == 3) {
client.npcId = 100;
client.isNpc = true;
familyLevel = 1;
} else if (client.combatLevel >= 4 && client.combatLevel <= 52) {
client.npcId = 101;
client.isNpc = true;
familyLevel = 2;
} else if (client.combatLevel >= 53 && client.combatLevel <= 72) {
client.npcId = 102;
client.isNpc = true;
familyLevel = 3;
} else if (client.combatLevel >= 73 && client.combatLevel <= 102) {
client.npcId = 122;
client.isNpc = true;
familyLevel = 4;
} else if (client.combatLevel >= 103) {
client.npcId = 3061;
client.isNpc = true;
familyLevel = 5;
}
}
}
}
In the client class, search for:
if (oldLevel < getLevelForXP(playerXP[skill])) {
And below it, add the following:
Code:
Avatarhandler.levelUp(playerId);
In the same class, search for:
if ((playerItems[slot]-1) == wearID) {
And above it, add the following:
Code:
Avatarhandler.weaponBonus(wearID);
Now, add this. It's just a few lines below this, and shouldn't be a problem adding:
Code:
int CLElf = Avatarhandler.GetCLElf(wearID);
int CLGoblin = Avatarhandler.GetCLGoblin(wearID);
A bit down, you should add the following. If you don't know where this goes, ask.
Code:
if (CLElf > Avatarhandler.Elf) {
sendMessage("You're family level or race doesn't match the requirements");
GoFalse = true;
}
if (CLGoblin > Avatarhandler.Goblin) {
sendMessage("You're family level or race doesn't match the requirements");
GoFalse = true;
}
Where ever you're welcome message is, add this.
Code:
Avatarhandler.playerOn(playerId);
if (!Avatarhandler.setPicked) {
/*
TODO: Make a dialogue appear to allow the user to pick their family!
* When they have picked, what ever code selects their family, place this in depending on what family they picked:
Avatarhandler.elfStarter = 1;
Avatarhandler.goblinStarter = 1;
*
You also don't have to set the boolean, setPicked to true as the starter will do it.
*/
}
Oh yeah, if you want some help on how to choose the family, please refer to the quoted out above.
In packet 185, replace case 52071 and 52072 with the following:
Code:
case 52071:
if (Avatarhandler.Goblin == 1) {
if (emotes == 0) {
emotes = 1;
pEmote = 0x84F;
updateRequired = true;
appearanceUpdateRequired = true;
} else {
emotes = 0;
pEmote = playerSE;
updateRequired = true;
appearanceUpdateRequired = true;
}
} else {
sendMessage("You must be in the Goblin family to cast this emote.");
}
break;
case 52072:
if (Avatarhandler.Goblin == 1) {
if (emotes == 0) {
emotes = 1;
pEmote = 0x850;
updateRequired = true;
appearanceUpdateRequired = true;
} else {
emotes = 0;
pEmote = playerSE;
updateRequired = true;
appearanceUpdateRequired = true;
}
} else {
sendMessage("You must be in the Goblin family to cast this emote.");
}
break;
In the method Attack, search for:
And below it, add the following:
Code:
if (Avatarhandler.elfWeapon) {
hitDiff = misc.random(playerMaxHit);
}
if (Avatarhandler.goblinWeapon) {
hitDiff = misc.random(playerMaxHit+misc.random(3));
}
In the player class, replace the max bank spots integer with the following:
Code:
public int playerBankSize = Avatarhandler.bankSpace;
In the same class, replace the pWalk integer with this:
Code:
public int pWalk = Avatarhandler.walkAnimation;
You have now finished adding everything.
Please note that this is untested, but the file itself will work. Just the calling of the methods may be a bit off.
Credits: 95% Rog3r, 5% 0wned_Pl0x