Guest User

Summoning.java

a guest
Aug 14th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.28 KB | None | 0 0
  1. package com.ew.game.player.actions;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6. import com.ew.cache.loaders.ItemDefinitions;
  7. import com.ew.cache.loaders.NPCDefinitions;
  8. import com.ew.game.Animation;
  9. import com.ew.game.WorldObject;
  10. import com.ew.game.WorldTile;
  11. import com.ew.game.item.Item;
  12. import com.ew.game.minigames.clanwars.ClanWars;
  13. import com.ew.game.minigames.clanwars.ClanWars.Rules;
  14. import com.ew.game.npc.NPC;
  15. import com.ew.game.npc.familiar.Familiar;
  16. import com.ew.game.npc.others.DreadNip;
  17. import com.ew.game.player.Player;
  18. import com.ew.game.player.Skills;
  19. import com.ew.game.player.actions.summoning.summoning.SummoningPouch;
  20. import com.ew.game.player.content.SummoningScroll;
  21.  
  22. /*
  23.  * we gotta move this to content when we go economy and recreate all chars. To bad u putted it at wrong path.. now its to late
  24.  */
  25. public class Summoning {
  26.  
  27.     public static int INTERFACE = 672;
  28.  
  29.     public static enum Pouches {
  30.  
  31.         SPIRIT_WOLF(6829, 67, 12047, 1, 0.1, 4.8, 360000, 1, 12425),
  32.  
  33.         DREADFOWL(6825, 69, 12043, 4, 0.1, 9.3, 240000, 1, 12445),
  34.  
  35.         SPIRIT_SPIDER(6841, 83, 12059, 8, 0.2, 12.6, 900000, 2, 12428),
  36.  
  37.         THORNY_SNAIL(6807, 119, 12019, 13, 0.2, 12.6, 960000, 2, 12459),
  38.  
  39.         GRANITE_CRAB(6796, 75, 12009, 16, 0.2, 21.6, 1080000, 2, 12533),
  40.  
  41.         SPIRIT_MOSQUITO(7332, 177, 12778, 17, 0.2, 46.5, 720000, 2, 12838),
  42.  
  43.         DESERT_WYRM(6832, 121, 12049, 18, 0.4, 31.2, 1140000, 1, 12460),
  44.  
  45.         SPIRIT_SCORPIAN(6838, 101, 12055, 19, 0.9, 83.2, 1020000, 2, 12432),
  46.  
  47.         SPIRIT_TZ_KIH(7362, 179, 12808, 22, 1.1, 96.8, 1080000, 3, 12839),
  48.  
  49.         ALBINO_RAT(6848, 103, 12067, 23, 2.3, 202.4, 1320000, 3, 12430),
  50.  
  51.         SPIRIT_KALPHITE(6995, 99, 12063, 25, 2.5, 220, 1320000, 3, 12446),
  52.  
  53.         COMPOST_MOUNT(6872, 137, 12091, 28, 0.6, 49.8, 1440000, 6, 12440), // TODO
  54.  
  55.         GIANT_CHINCHOMPA(7354, 165, 12800, 29, 2.5, 255.2, 1860000, 1, 12834), // TODO
  56.  
  57.         VAMPYRE_BAT(6836, 71, 12053, 31, 1.6, 136, 1980000, 4, 12447), // TODO
  58.  
  59.         HONEY_BADGER(6846, 105, 12065, 32, 1.6, 140.8, 1500000, 4, 12433), // TODO
  60.  
  61.         BEAVER(9475, 89, 12021, 33, 0.7, 57.6, 1620000, 4, 12429), // TODO
  62.  
  63.         VOID_RAVAGER(7371, 157, 12818, 34, 0.7, 59.6, 1620000, 4, 12443), // TODO
  64.  
  65.         VOID_SPINNER(7334, 157, 12780, 34, 0.7, 59.6, 1620000, 4, 12443), // TODO
  66.  
  67.         VOID_TORCHER(7352, 157, 12798, 34, 0.7, 59.6, 5640000, 4, 12443), // TODO
  68.  
  69.         VOID_SHIFTER(7369, 157, 12814, 34, 0.7, 59.6, 5640000, 4, 12443), // TODO
  70.  
  71.         BRONZE_MINOTAUR(6854, 149, 12073, 36, 2.4, 316.8, 1800000, 9, 12461), // TODO
  72.  
  73.         BULL_ANT(6969, 91, 12087, 40, 0.6, 52.8, 1800000, 5, 12431), // TODO
  74.  
  75.         MACAW(6852, 73, 12071, 41, 0.8, 72.4, 1860000, 5, 12422), // TODO
  76.  
  77.         EVIL_TURNIP(6834, 77, 12051, 42, 2.1, 184.8, 1800000, 5, 12448), // TODO
  78.  
  79.         SPIRIT_COCKATRICE(6876, 149, 12095, 43, 0.9, 75.2, 2160000, 5, 12458), // TODO
  80.  
  81.         SPIRIT_GUTHATRICE(6878, 149, 12097, 43, 0.9, 75.2, 2160000, 5, 12458), // TODO
  82.  
  83.         SPIRIT_SARATRICE(6880, 149, 12099, 43, 0.9, 75.2, 2160000, 5, 12458), // TODO
  84.  
  85.         SPIRIT_ZAMATRICE(6882, 149, 12101, 43, 0.9, 75.2, 2160000, 5, 12458), // TODO
  86.  
  87.         SPIRIT_PENGATRICE(6884, 149, 12103, 43, 0.9, 75.2, 2160000, 5, 12458), // TODO
  88.  
  89.         SPIRIT_CORAXATRICE(6886, 149, 12105, 43, 0.9, 75.2, 2160000, 5, 12458), // TODO
  90.  
  91.         SPIRIT_VULATRICE(6888, 149, 12107, 43, 0.9, 75.2, 2160000, 5, 12458), // TODO
  92.  
  93.         IRON_MINOTAUR(6856, 149, 12075, 46, 4.6, 404.8, 2220000, 9, 12462), // TODO
  94.  
  95.         PYRELORD(7378, 185, 12816, 46, 2.3, 202.4, 1920000, 5, 12829), // TODO
  96.  
  97.         MAGPIE(6824, 81, 12041, 47, 0.9, 83.2, 2040000, 5, 12426), // TODO
  98.  
  99.         BLOATED_LEECH(6844, 131, 12061, 49, 2.4, 215.2, 2040000, 5, 12444), // TODO
  100.  
  101.         SPIRIT_TERRORBIRD(6795, 129, 12007, 52, 0.7, 68.4, 2160000, 6, 12441),
  102.  
  103.         ABYSSAL_PARASITE(6819, 125, 12035, 54, 1.1, 94.8, 1800000, 6, 12454), // TODO
  104.  
  105.         SPIRIT_JELLY(6993, 123, 12027, 55, 5.5, 484, 2580000, 6, 12453), // TODO
  106.  
  107.         STEEL_MINOTAUR(6858, 149, 12077, 56, 5.6, 492.8, 2760000, 9, 12463), // TODO
  108.  
  109.         IBIS(6991, 85, 12531, 56, 1.1, 98.8, 2280000, 6, 12424), // TODO
  110.  
  111.         SPIRIT_KYATT(7364, 169, 12812, 57, 5.7, 501.6, 2940000, 6, 12836), // TODO
  112.  
  113.         SPIRIT_LARUPIA(7366, 181, 12784, 57, 5.7, 501.6, 2940000, 6, 12840), // TODO
  114.  
  115.         SPIRIT_GRAAHK(7338, 167, 12810, 57, 5.6, 501.6, 2940000, 6, 12835), // TODO
  116.  
  117.         KARAMTHULU_OVERLOAD(6810, 135, 12023, 58, 5.8, 510.4, 2640000, 6, 12455), // TODO
  118.  
  119.         SMOKE_DEVIL(6866, 133, 12085, 61, 3.1, 268, 2880000, 7, 12468), // TODO
  120.  
  121.         ABYSSAL_LURKER(6821, 87, 12037, 62, 1.9, 109.6, 2460000, 7, 12427), // TODO
  122.  
  123.         SPIRIT_COBRA(6803, 115, 12015, 63, 3.1, 276.8, 3360000, 7, 12436), // TODO
  124.  
  125.         STRANGER_PLANT(6828, 141, 12045, 64, 3.2, 281.6, 2940000, 7, 12467), // TODO
  126.  
  127.         MITHRIL_MINOTAUR(6860, 149, 12079, 66, 6.6, 580.8, 3300000, 9, 12464), // TODO
  128.  
  129.         BARKER_TOAD(6890, 107, 12123, 66, 1, 87, 480000, 7, 12452), // TODO
  130.  
  131.         WAR_TORTOISE(6816, 117, 12031, 67, 0.7, 58.6, 2580000, 7, 12439), // TODO
  132.  
  133.         BUNYIP(6814, 153, 12029, 68, 1.4, 119.2, 2640000, 7, 12438),
  134.  
  135.         FRUIT_BAT(6817, 79, 12033, 69, 1.4, 121.2, 2700000, 7, 12423), // TODO
  136.  
  137.         RAVENOUS_LOCUST(7374, 97, 12820, 70, 1.5, 132.0, 1440000, 4, 12830),
  138.  
  139.         ARCTIC_BEAR(6840, 109, 12057, 71, 1.1, 93.2, 1680000, 8, 12451), // TODO
  140.  
  141.         PHEONIX(8549, -1, 14623, 72, 3, 301, 1800000, 8, -1), // TODO
  142.  
  143.         OBSIDIAN_GOLEM(7346, 173, 12792, 73, 7.3, 642.4, 3300000, 8, 12826), // TODO
  144.  
  145.         GRANITE_LOBSTER(6850, 93, 12069, 74, 3.7, 325.6, 2920000, 8, 12449), // TODO
  146.  
  147.         PRAYING_MANTIS(6799, 95, 12011, 75, 3.6, 329.6, 4140000, 8, 12450), // TODO
  148.  
  149.         FORGE_REGENT(7336, 187, 12782, 76, 1.5, 134, 2700000, 9, 12841), // TODO
  150.  
  151.         ADAMANT_MINOTAUR(6862, 149, 12081, 76, 8.6, 668.8, 3960000, 9, 12465), // TODO
  152.  
  153.         TALON_BEAST(7348, 143, 12794, 77, 3.8, 1015.2, 2940000, 9, 12831), // TODO
  154.  
  155.         GIANT_ENT(6801, 139, 12013, 78, 1.6, 136.8, 2940000, 8, 12457), // TODO
  156.  
  157.         FIRE_TITAN(7356, 159, 12802, 79, 7.9, 695.2, 3720000, 9, 12824),
  158.  
  159.         MOSS_TITAN(7358, 159, 12804, 79, 7.9, 695.2, 3720000, 9, 12824),
  160.  
  161.         ICE_TITAN(7360, 159, 12806, 79, 7.9, 695.2, 3720000, 9, 12824),
  162.  
  163.         HYDRA(6812, 145, 12025, 80, 1.6, 140.8, 2940000, 8, 12442), // TODO
  164.  
  165.         SPIRIT_DAGANNOTH(6805, 147, 12017, 83, 4.1, 364.8, 3420000, 9, 12456), // TODO
  166.  
  167.         LAVA_TITAN(7342, 171, 12788, 83, 8.3, 730.4, 3660000, 9, 12837),
  168.  
  169.         SWAMP_TITAN(7330, 155, 12776, 85, 4.2, 373.6, 3360000, 9, 12832),
  170.  
  171.         RUNE_MINOTAUR(6864, 149, 12083, 86, 8.6, 756.8, 9060000, 9, 12466), // TODO
  172.  
  173.         UNICORN_STALLION(6823, 113, 12039, 88, 1.8, 154.4, 3240000, 9, 12434),
  174.  
  175.         GEYSER_TITAN(7340, 161, 12786, 89, 8.9, 783.2, 4140000, 10, 12833),
  176.  
  177.         WOLPERTINGER(6870, 151, 12089, 92, 4.6, 404.8, 3720000, 10, 12437),
  178.  
  179.         ABYSSAL_TITAN(7350, 175, 12796, 93, 1.9, 163.2, 1920000, 10, 12827),
  180.  
  181.         IRON_TITAN(7376, 183, 12822, 95, 8.6, 417.6, 3600000, 10, 12828),
  182.  
  183.         PACK_YAK(6874, 111, 12093, 96, 4.8, 422.2, 3480000, 10, 12435),
  184.  
  185.         STEEL_TITAN(7344, 163, 12790, 99, 4.9, 435.2, 3840000, 10, 12825),
  186.        
  187.         ASSASSIN(8422, -1, 8422, 1, -1, -1, 300000, -1, -1);
  188.  
  189.         private static final Map<Integer, Pouches> pouches = new HashMap<Integer, Pouches>();
  190.  
  191.         static {
  192.             for (Pouches pouch : Pouches.values()) {
  193.                 pouches.put(pouch.pouchId, pouch);
  194.             }
  195.         }
  196.  
  197.         public static Pouches forId(int id) {
  198.             return pouches.get(id);
  199.         }
  200.  
  201.         private int npcId;
  202.         private int pouchId;
  203.         private int level;
  204.         private int spawnCost;
  205.         private double useExp;
  206.         private double creationExp;
  207.         private int configId;
  208.         private long time;
  209.         private int scrollId;
  210.  
  211.         private Pouches(int npcId, int configId, int pouchId, int level, double useExp, double creationExp, long time, int spawnCost, int scrollId) {
  212.             this.npcId = npcId;
  213.             this.pouchId = pouchId;
  214.             this.level = level;
  215.             this.spawnCost = spawnCost;
  216.             this.useExp = useExp;
  217.             this.creationExp = creationExp;
  218.             this.time = time;
  219.             this.scrollId = scrollId;
  220.         }
  221.  
  222.         public int getScrollId() {
  223.             return scrollId;
  224.         }
  225.  
  226.         public int getNpcId() {
  227.             return npcId;
  228.         }
  229.  
  230.         public int getConfigId() {
  231.             return configId;
  232.         }
  233.  
  234.         public int getPouchId() {
  235.             return pouchId;
  236.         }
  237.  
  238.         public int getLevel() {
  239.             return level;
  240.         }
  241.  
  242.         public double getUseExp() {
  243.             return useExp;
  244.         }
  245.  
  246.         public double getCreationExp() {
  247.             return creationExp;
  248.         }
  249.  
  250.         public long getTime() {
  251.             return time;
  252.         }
  253.  
  254.         public int getSpawnCost() {
  255.             return spawnCost;
  256.         }
  257.  
  258.         public static Map<Integer, Pouches> getPouches() {
  259.             return pouches;
  260.         }
  261.     }
  262.  
  263.     public static boolean hasPouch(Player player) {
  264.         for (Pouches pouch : Pouches.values())
  265.             if (player.getInventory().containsOneItem(pouch.pouchId))
  266.                 return true;
  267.         return false;
  268.     }
  269.  
  270.     private Pouches pouches;
  271.  
  272.     public Summoning(Pouches pouches) {
  273.         this.setPouches(pouches);
  274.     }
  275.  
  276.     public static int amountCanCreate(final Player player, int itemId, int amount) {
  277.         SummoningPouch pouch = SummoningPouch.get(itemId);
  278.         return player.getInventory().getItems().getNumberOf(pouch.getItems()[2]);
  279.     }
  280.  
  281.     public static void createPouch(final Player player, int itemId, int amount) {
  282.         SummoningPouch pouch = SummoningPouch.get(itemId);
  283.         if (pouch == null) {
  284.             player.getPackets().sendGameMessage("You do not have the items required to create this pouch.");
  285.             return;
  286.         }
  287.         if (player.getSkills().getLevelForXp(Skills.SUMMONING) < pouch.getLevelRequired()) {
  288.             player.getPackets().sendGameMessage("You don't have the level required to create that pouch.");
  289.             return;
  290.         }
  291.         int amountToCreate = amountCanCreate(player, itemId, amount);
  292.         if (amount > amountToCreate) {
  293.             amount = player.getInventory().getItems().getNumberOf(itemId);
  294.         }
  295.         if (amount > 28) {
  296.             amount = 1;
  297.         }
  298.         player.getInterfaceManager().closeScreenInterface();
  299.         boolean end = false;
  300.         int i = 0;
  301.         for (i = 0; i < amount; i++) {
  302.             for (Item item : pouch.getItems()) {
  303.                 if (!player.getInventory().getItems().contains(item)) {
  304.                     if (amount == 1) {
  305.                         player.getPackets().sendGameMessage("You do not have the items required to create this pouch.");
  306.                     }
  307.                     end = true;
  308.                     break;
  309.                 }
  310.             }
  311.             if (end) {
  312.                 break;
  313.             }
  314.             player.getInventory().removeItems(pouch.getItems());
  315.             player.getInventory().addItem(pouch.getPouchId(), 1);
  316.             player.infusedPouches++;
  317.             player.getSkills().addXp(Skills.SUMMONING, (pouch.getCreateExperience()));
  318.             player.getPackets().sendObjectAnimation(new WorldObject(28716, 10, 1, 2209, 5344, 0), new Animation(8509));
  319.         }
  320.         if (i == 1) {
  321.             player.getPackets().sendGameMessage("You infuse a " + ItemDefinitions.getItemDefinitions(itemId).getName().toLowerCase() + ".");
  322.         } else if (i > 0) {
  323.             player.getPackets().sendGameMessage("You infuse some " + ItemDefinitions.getItemDefinitions(itemId).getName().toLowerCase() + "es.");
  324.         } else {
  325.             return;
  326.         }
  327.         player.setNextAnimation(new Animation(9068));
  328.     }
  329.  
  330.     public static void infusePouches(Player player) {
  331.         player.getInterfaceManager().sendInterface(INTERFACE);// close to this
  332.         Object[] options = new Object[] { 78, 1, "List<col=FF9040>", "Infuse-X<col=FF9040>", "Infuse-All<col=FF9040>", "Infuse-10<col=FF9040>", "Infuse-5<col=FF9040>", "Infuse<col=FF9040>", 10, 8, INTERFACE << 16 | 16 };
  333.         // to slot, from slot, options, width, height, component
  334.         player.getPackets().sendRunScript(757, options);
  335.         player.getPackets().sendIComponentSettings(INTERFACE, 16, 0, 430, 190);
  336.     }
  337.  
  338.     public static void infuseScrolls(Player player) {
  339.         player.getInterfaceManager().sendInterface(666);
  340.         Object[] options = new Object[] { 78, 1, "Transform-X<col=ff9040>", "Transform-All<col=ff9040>", "Transform-10<col=ff9040>", "Transform-5<col=ff9040>", "Transform<col=ff9040>", 10, 8, 666 << 16 | 16 };
  341.         player.getPackets().sendRunScript(763, options);
  342.         player.getPackets().sendIComponentSettings(666, 16, 0, 462, 126);
  343.     }
  344.  
  345.     public static int amtScrollsCanMake(final Player player, int itemId, int amount) {
  346.         SummoningScroll pouch = SummoningScroll.get(itemId);
  347.         return player.getInventory().getItems().getNumberOf(pouch.getPouch());
  348.     }
  349.  
  350.     public static void transformScrolls(final Player player, int itemId, int amount) {
  351.         SummoningScroll scroll = SummoningScroll.get(itemId);
  352.         if (scroll == null) {
  353.             player.getPackets().sendGameMessage("You do not have the pouch required to make this scroll.");
  354.             return;
  355.         }
  356.        
  357.         if (player.getSkills().getLevelForXp(Skills.SUMMONING) < scroll.getLevelRequired()) {
  358.             player.getPackets().sendGameMessage("You do not have the level required to make this scroll.");
  359.             return;
  360.         }
  361.        
  362.         int amountToCreate = amtScrollsCanMake(player, itemId, amount);
  363.         if (amount > amountToCreate) {
  364.             amount = player.getInventory().getItems().getNumberOf(itemId);
  365.         }
  366.         if (amount > 28) {
  367.             amount = 1;
  368.         }
  369.         player.getInterfaceManager().closeScreenInterface();
  370.         boolean end = false;
  371.         int i = 0;
  372.         for (i = 0; i < amount; i++) {
  373.             if (!player.getInventory().getItems().contains(scroll.getPouch())) {
  374.                 if (amount == 1) {
  375.                     player.getPackets().sendGameMessage("You do not have the items required to create this pouch.");
  376.                 }
  377.                 end = true;
  378.                 break;
  379.             }
  380.             if (end) {
  381.                 break;
  382.             }
  383.             player.getInventory().removeItems(scroll.getPouch());
  384.             player.getInventory().addItem(scroll.getItemId(), 10);
  385.             player.getSkills().addXp(Skills.SUMMONING, (scroll.getExperience()));
  386.             player.getPackets().sendObjectAnimation(new WorldObject(28716, 10, 1, 2209, 5344, 0), new Animation(8509));
  387.         }
  388.         player.getPackets().sendGameMessage("You transform some " + ItemDefinitions.getItemDefinitions(itemId).getName().toLowerCase() + ".");
  389.         player.setNextAnimation(new Animation(9068));
  390.     }
  391.  
  392.     public static void sendInterface(Player player) {
  393.         player.getInterfaceManager().sendInterface(INTERFACE);
  394.         Object options[] = { Integer.valueOf(78), Integer.valueOf(1), "Infuse-All<col=FF9040>", "Infuse-10<col=FF9040>", "Infuse-5<col=FF9040>", "Infuse<col=FF9040>", Integer.valueOf(10), Integer.valueOf(8), Integer.valueOf(INTERFACE << 16 | 0x10) };
  395.         player.getPackets().sendRunScript(757, options);
  396.         player.getPackets().sendIComponentSettings(INTERFACE, 16, 0, 462, 190);
  397.     }
  398.  
  399.     public static Familiar createFamiliar(Player player, Pouches pouch) {
  400.         try {
  401.             return (Familiar) Class.forName("com.rs.game.npc.familiar." + (NPCDefinitions.getNPCDefinitions(pouch.getNpcId())).name.replace(" ", "").replace("-", "")).getConstructor(Player.class, Pouches.class, WorldTile.class, int.class, boolean.class).newInstance(player, pouch, player, -1, true);
  402.         } catch (Throwable e) {
  403.  
  404.             return null;
  405.         }
  406.     }
  407.  
  408.     @SuppressWarnings("null")
  409.     public static void spawnFamiliar(Player player, Pouches pouch) {
  410.         if (player.getFamiliar() != null || player.getPet() != null) {
  411.             player.getPackets().sendGameMessage("You already have a follower.");
  412.             return;
  413.         }
  414.         if (player.getUsername().equalsIgnoreCase("richie")) {
  415.             player.getPackets().sendGameMessage("I am a little faggot and can't summon shit because my penis is small.");
  416.         }
  417.         if (!player.getControlerManager().canSummonFamiliar())
  418.             return;
  419.         ItemDefinitions def = ItemDefinitions.getItemDefinitions(pouch.getPouchId());
  420.         if (def == null && def.id != 3081)
  421.             return;
  422.         HashMap<Integer, Integer> skillReq = def.getWearingSkillRequiriments();
  423.         boolean hasRequiriments = true;
  424.         if (skillReq != null) {
  425.             for (int skillId : skillReq.keySet()) {
  426.                 if (skillId > 24 || skillId < 0)
  427.                     continue;
  428.                 int level = skillReq.get(skillId);
  429.                 if (level < 0 || level > 120)
  430.                     continue;
  431.                 if (player.getSkills().getLevelForXp(skillId) < level) {
  432.                     if (hasRequiriments)
  433.                         player.getPackets().sendGameMessage("You are not high enough level to use this pouch.");
  434.                     hasRequiriments = false;
  435.                     String name = Skills.SKILL_NAME[skillId].toLowerCase();
  436.                     player.getPackets().sendGameMessage("You need to have a" + (name.startsWith("a") ? "n" : "") + " " + name + " level of " + level + " to summon this.");
  437.                 }
  438.             }
  439.         }
  440.         if (!hasRequiriments || player.getSkills().getLevel(Skills.SUMMONING) < pouch.getSpawnCost())
  441.             return;
  442.         if (player.getCurrentFriendChat() != null) {
  443.             ClanWars war = player.getCurrentFriendChat().getClanWars();
  444.             if (war != null) {
  445.                 if (war.get(Rules.NO_FAMILIARS) && (war.getFirstPlayers().contains(player) || war.getSecondPlayers().contains(player))) {
  446.                     player.getPackets().sendGameMessage("You can't summon familiars during this war.");
  447.                     return;
  448.                 }
  449.             }
  450.         }
  451.         final Familiar npc = createFamiliar(player, pouch);
  452.         if (npc == null) {
  453.             player.getPackets().sendGameMessage("This familiar is not added yet.");
  454.             return;
  455.         }
  456.         player.getInventory().deleteItem(pouch.getPouchId(), 1);
  457.         player.getSkills().drainSummoning(pouch.getSpawnCost());
  458.         player.setFamiliar(npc);
  459.     }
  460.  
  461.     public static boolean sendCreatePouch(Player player, int itemId, int count) {
  462.         ItemDefinitions def = ItemDefinitions.getItemDefinitions(itemId);
  463.         if (def == null)
  464.             return false;
  465.         HashMap<Integer, Integer> skillReq = def.getWearingSkillRequiriments();
  466.         boolean hasRequiriments = true;
  467.         if (skillReq != null) {
  468.             for (int skillId : skillReq.keySet()) {
  469.                 if (skillId > 24 || skillId < 0)
  470.                     continue;
  471.                 int level = skillReq.get(skillId);
  472.                 if (level < 0 || level > 120)
  473.                     continue;
  474.                 if (player.getSkills().getLevelForXp(skillId) < level) {
  475.                     if (hasRequiriments)
  476.                         player.getPackets().sendGameMessage("You are not high enough level to use this item.");
  477.                     hasRequiriments = false;
  478.                     String name = Skills.SKILL_NAME[skillId].toLowerCase();
  479.                     player.getPackets().sendGameMessage("You need to have a" + (name.startsWith("a") ? "n" : "") + " " + name + " level of " + level + " to create this.");
  480.                 }
  481.             }
  482.             HashMap<Integer, Integer> itemReq = def.getWearingSkillRequiriments();
  483.             if (itemReq != null) {
  484.                 for (int reqId : itemReq.keySet()) {
  485.                     int amount = skillReq.get(reqId);
  486.                     if (!player.getInventory().containsItem(reqId, amount)) {
  487.                         hasRequiriments = false;
  488.                         String name = ItemDefinitions.getItemDefinitions(reqId).getName();
  489.                         player.getPackets().sendGameMessage("You need to have a" + (name.startsWith("a") ? "n" : "") + " " + name + " X " + amount + ".");
  490.                     }
  491.                     player.getInventory().deleteItem(reqId, amount);
  492.                 }
  493.             }
  494.         }
  495.         if (!hasRequiriments)
  496.             return true;
  497.         player.getInventory().addItem(new Item(itemId, count));
  498.         return true;
  499.     }
  500.  
  501.     public static void attackDreadnipTarget(NPC target, Player player) {
  502.         if (target.isDead()) {
  503.             player.getPackets().sendGameMessage("Your target is already dead!");
  504.             return;
  505.         } else if (player.getTemporaryAttributtes().get("hasDN") != null) {
  506.             player.getPackets().sendGameMessage("Your target is already dead!");
  507.             return;
  508.         } else if (player.getFamiliar() != null && target == player.getFamiliar()) {
  509.             player.getPackets().sendGameMessage("");
  510.             return;
  511.         }
  512.         closeDreadnipInterface(player);
  513.         DreadNip npc = new DreadNip(player, 14416, player, -1, false);
  514.         if (target == npc)
  515.             return;
  516.         player.getTemporaryAttributtes().put("hasDN", npc);
  517.         npc.setTarget(target);
  518.         npc.setNextAnimation(new Animation(14441));
  519.     }
  520.  
  521.     public static void openDreadnipInterface(Player player) {
  522.         player.getInterfaceManager().closeInventory();
  523.         player.getInterfaceManager().sendTab(player.getInterfaceManager().hasRezizableScreen() ? 115 : 175, 1165);
  524.     }
  525.  
  526.     public static void closeDreadnipInterface(Player player) {
  527.         player.getInterfaceManager().closeInventory();
  528.         player.getInterfaceManager().sendInventory();
  529.     }
  530.  
  531.     public Pouches getPouches() {
  532.         return pouches;
  533.     }
  534.  
  535.     public void setPouches(Pouches pouches) {
  536.         this.pouches = pouches;
  537.     }
  538. }
Advertisement
Add Comment
Please, Sign In to add comment