Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.model.players;
- import server.Server;
- import server.model.npcs.*;
- import server.model.players.Client;
- import server.util.Misc;
- /**
- *
- * @author Tokashi
- *
- */
- public class Pets {
- private Client c;
- public Pets(Client client) {
- this.c = client;
- }
- public void pickUp(int Type) {
- /*if (c.inWild){
- c.sendMessage("How did you get a pet in the wilderness?");
- }*/
- for (int i = 0; i < NPCHandler.maxNPCs; i++) {
- if (NPCHandler.npcs[i] == null)
- continue;
- }
- for (int i = 0; i < NPCHandler.maxNPCs; i++) {
- if (NPCHandler.npcs[i] != null) {
- if (NPCHandler.npcs[i].npcType == Type) {
- if (NPCHandler.npcs[i].spawnedBy == c.playerId && NPCHandler.npcs[i].spawnedBy > 0) {
- NPCHandler.npcs[i].absX = 0;
- NPCHandler.npcs[i].absY = 0;
- NPCHandler.npcs[i] = null;
- break;
- }
- }
- }
- }
- }
- public int[][] Pets = {
- {766, 1560}, //Pet Kitten
- {765, 1559}, //Pet Kitten
- {764, 1558}, //Pet Kitten
- {763, 1557}, //Pet Kitten
- {762, 1556}, //Pet Kitten
- {761, 1555}, //Pet Kitten
- {768, 1561}, //Pet Cat
- {769, 1562}, //Pet Cat
- {770, 1563}, //Pet Cat
- {771, 1564}, //Pet Cat
- {772, 1565}, //Pet Cat
- {773, 1566}, //Pet Cat
- {774, 1567}, //Pet Cat Overgrown
- {775, 1568}, //Pet Cat overgrown
- {776, 1569}, //Pet Cat overgrown
- {777, 1570}, //Pet Cat overgrown
- {778, 1571}, //Pet Cat overgrown
- {779, 1572}, //Pet Cat overgrown
- {3000, 4149}, //Abyssal demon
- {3001, 4133}, //Crawling hand
- {3002, 4134}, //Cave crawler
- {3003, 4135}, //Banshee
- {3004, 4136}, //Rockslug
- {3005, 4137}, //Cockatrice
- {3006, 4138}, //Pyrefiend
- {3007, 4139}, //Basilisk
- {3008, 4141}, //Bloodveld
- {3009, 4142}, //Jelly
- {3010, 4143}, //Turoth
- {3011, 4144}, //Aberrant specter
- {3012, 4145}, //Dust devil
- {3013, 4146}, //Kurask
- {3014, 4147}, //Gargoyle
- {3015, 4148}, //Nechryael
- };
- public int[][] petStats = { //id, health, attack, defense, speed
- {761, 10, 1, 1, 4}, //kittens //noob
- {762, 10, 1, 1, 4},
- {763, 10, 1, 1, 4},
- {764, 10, 1, 1, 4},
- {765, 10, 1, 1, 4},
- {766, 10, 1, 1, 4}, //end kittens //end noob
- {768, 25, 5, 3, 3}, //cats
- {769, 25, 5, 3, 3},
- {770, 25, 5, 3, 3},
- {771, 25, 5, 3, 3},
- {772, 25, 5, 3, 3},
- {773, 25, 5, 3, 3}, //end cats
- {774, 40, 3, 7, 1}, //fat cats
- {775, 40, 3, 7, 1},
- {776, 40, 3, 7, 1},
- {777, 40, 3, 7, 1},
- {778, 40, 3, 7, 1},
- {779, 40, 3, 7, 1}, //end fat cats
- {3001, 15, 2, 2, 2}, //crawling hand //novice
- {3002, 20, 3, 3, 2}, //cave crawler
- {3003, 15, 6, 2, 2}, //banshee
- {3004, 30, 3, 5, 2}, //rockslug
- {3005, 25, 6, 3, 3}, //cockatrice
- {3006, 20, 8, 2, 4}, //pyrefiend //end novice
- {3007, 55, 6, 5, 2}, //basilisk //veteran
- {3008, 60, 5, 6, 2}, //bloodveld
- {3009, 80, 3, 9, 1}, //jelly
- {3010, 30, 12, 3, 4}, //turoth //end veteran
- {3011, 100, 7, 12, 3}, //aberrant specter //renowned
- {3012, 60, 14, 5, 5}, //dust devil
- {3013, 80, 10, 10, 3}, //kurask
- {3014, 70, 12, 8, 4}, //gargoyle
- {3015, 40, 15, 9, 3}, //nechryael
- {3000, 66, 16, 6, 6}, //abyssal demon //end renowned
- };
- int[] array = {1,2,3,4};
- int[][] array2 = {{1, 1}, {2, 2}};
- public void fightPets(int oppPet, int myPet, Client opp, Client me) {
- int myHP = 0, myAtt = 0, myDef = 0, mySpe = 0;
- int oppHP = 0, oppAtt = 0, oppDef = 0, oppSpe = 0;
- for (int mP = 0; mP < petStats.length; mP++) {
- if (petStats[mP][0] == myPet) {
- myHP = petStats[mP][1];
- myAtt = petStats[mP][2];
- myDef = petStats[mP][3];
- mySpe = petStats[mP][4];
- }
- }
- for (int oP = 0; oP < petStats.length; oP++) {
- if (petStats[oP][0] == oppPet) {
- oppHP = petStats[oP][1];
- oppAtt = petStats[oP][2];
- oppDef = petStats[oP][3];
- oppSpe = petStats[oP][4];
- }
- }
- while (myHP > 0 && oppHP > 0) {
- if (mySpe > oppSpe) {
- oppHP -= (myAtt*Misc.random(2)) - oppDef + 1;
- if (oppHP < 0)
- oppHP = 0;
- opp.sendMessage("Your monsters health: "+oppHP);
- if (oppHP <= 0) {
- me.PVPMonsterFights++;
- me.sendMessage("You win! Your monster has won "+me.PVPMonsterFights+" fights!");
- if (me.PVPMonsterFights % 5 == 0) {
- me.monsterLevel++;
- me.sendMessage("Congratulations! Your monster is now level "+me.monsterLevel);
- }
- opp.sendMessage("You lose! Better luck next time!");
- return;
- }
- } else if (oppSpe > mySpe) {
- myHP -= (oppAtt*Misc.random(2)) - myDef + 1;
- if (myHP < 0)
- myHP = 0;
- me.sendMessage("Your monsters health: "+myHP);
- if (myHP <= 0) {
- opp.PVPMonsterFights++;
- opp.sendMessage("You win! Your monster has won "+opp.PVPMonsterFights+" fights!");
- if (opp.PVPMonsterFights % 5 == 0) {
- opp.monsterLevel++;
- opp.sendMessage("Congratulations! Your monster is now level "+opp.monsterLevel);
- }
- me.sendMessage("You lose! Better luck next time!");
- return;
- }
- } else {
- if (Misc.random(1) == 0) {
- oppHP -= (myAtt*Misc.random(2)) - oppDef + 1;
- if (oppHP < 0)
- oppHP = 0;
- opp.sendMessage("Your monsters health: "+oppHP);
- if (oppHP <= 0) {
- me.PVPMonsterFights++;
- me.sendMessage("You win! Your monster has won "+me.PVPMonsterFights+" fights!");
- if (me.PVPMonsterFights % 5 == 0) {
- me.monsterLevel++;
- me.sendMessage("Congratulations! Your monster is now level "+me.monsterLevel);
- }
- opp.sendMessage("You lose! Better luck next time!");
- return;
- }
- } else {
- myHP -= (oppAtt*Misc.random(2)) - myDef + 1;
- if (myHP < 0)
- myHP = 0;
- me.sendMessage("Your monsters health: "+myHP);
- if (myHP <= 0) {
- opp.PVPMonsterFights++;
- opp.sendMessage("You win! Your monster has won "+opp.PVPMonsterFights+" fights!");
- if (opp.PVPMonsterFights % 5 == 0) {
- opp.monsterLevel++;
- opp.sendMessage("Congratulations! Your monster is now level "+opp.monsterLevel);
- }
- me.sendMessage("You lose! Better luck next time!");
- return;
- }
- }
- }
- }
- }
- public void pickUpClean(int id) {
- for (int i = 0; i < Pets.length; i++)
- if (Pets[i][0] == id) {
- //c.getItems().addItem(Pets[i][1], 1);
- if (!c.getItems().playerHasItem(2717)) {
- c.sendMessage("You need your monster chest to pick up your pet!");
- return;
- }
- }
- for (int i = 0; i < NPCHandler.maxNPCs; i++) {
- if (NPCHandler.npcs[i] == null)
- continue;
- if (NPCHandler.npcs[i].npcType == id) {
- NPCHandler.npcs[i].absX = 0;
- NPCHandler.npcs[i].absY = 0;
- }
- }
- c.sendMessage("You pick up your pet.");
- c.summonId = -1;
- c.hasNpc = false;
- }
- public int getPetNpc(int petItem) {
- for (int i = 0; i < Pets.length; i++) {
- //System.out.println("a");
- if (Pets[i][1] == petItem) {
- //System.out.println(""+Pets[i][1]);
- return Pets[i][0];
- }
- }
- return -1;
- }
- public boolean isPet(int npcId) {
- for (int i = 0; i < Pets.length; i++) {
- if (Pets[i][0] == npcId) {
- return true;
- }
- }
- return false;
- }
- public void dropPet(int itemId) {
- if (!c.hasNpc && c.summonId < 1) {
- c.turnPlayerTo(c.absX, c.absY-1);
- Server.npcHandler.spawnNpc3(c, getPetNpc(itemId), c.absX, c.absY-1, c.heightLevel, 0, 0, 0, 0, 0, false, false, true);
- c.getPA().followPlayer();
- c.getItems().deleteItem(itemId, 1);
- c.sendMessage("You set your pet on the ground.");
- c.hasNpc = true;
- } else {
- c.sendMessage("You already have a pet following you.");
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement