RuneHive-Game
Loading...
Searching...
No Matches
SuperHeat.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.magic.spell.impl;
2
3import com.runehive.Config;
4import com.runehive.content.skill.impl.magic.Spellbook;
5import com.runehive.content.skill.impl.magic.spell.Spell;
6import com.runehive.content.skill.impl.smithing.Smelting;
7import com.runehive.content.skill.impl.smithing.SmeltingData;
8import com.runehive.game.Graphic;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.game.world.entity.skill.Skill;
11import com.runehive.game.world.items.Item;
12import com.runehive.net.packet.out.SendForceTab;
13
14import java.util.Optional;
15
16/**
17 * The superheat spell
18 *
19 * @author Daniel
20 */
21public class SuperHeat implements Spell {
22
23 @Override
24 public String getName() {
25 return "Super heat";
26 }
27
28 @Override
29 public int getLevel() {
30 return 43;
31 }
32
33 @Override
34 public Item[] getRunes() {
35 return new Item[] { new Item(554, 1), new Item(561, 1) };
36 }
37
38 @Override
39 public void execute(Player player, Item item) {
40 if (player.spellbook != Spellbook.MODERN)
41 return;
42 if (!player.spellCasting.castingDelay.elapsed(599))
43 return;
44
45 Optional<SmeltingData> data = SmeltingData.getDefinitionByItem(item.getId());
46
47 if (!data.isPresent()) {
48 player.message("You can not super heat this item!");
49 return;
50 }
51
52 if (!player.inventory.containsAll(data.get().required)) {
53 player.message("You do not contain the required items to super heat!");
54 return;
55 }
56
57 if (player.skills.getMaxLevel(Skill.SMITHING) < data.get().requirement) {
58 player.message("You need a smithing level of " + data.get().requirement + " to do super heat this item!");
59 return;
60 }
61
62 player.animate(722);
63 player.graphic(new Graphic(148, false));
64 player.send(new SendForceTab(6));
65 player.inventory.removeAll(data.get().required);
66 player.inventory.addAll(data.get().produced);
68 player.skills.addExperience(Skill.SMITHING, data.get().experience * Config.SMITHING_MODIFICATION);
70 }
71}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double MAGIC_MODIFICATION
The experience modification for magic.
Definition Config.java:268
static final double SMITHING_MODIFICATION
The experience modification for smithing.
Definition Config.java:289
Item[] getRunes()
Gets the runes required to cast the spell.
int getLevel()
Gets the level required to cast spell.
void execute(Player player, Item item)
Executes the magic spell.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
Optional< Graphic > graphic
Definition Mob.java:91
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int SMITHING
The smithing skill id.
Definition Skill.java:60
static final int MAGIC
The magic skill id.
Definition Skill.java:39
void addExperience(int id, double experience)
Adds experience to a given skill.
int getMaxLevel(int id)
Gets the highest possible level of a skill.
The container class that represents an item that can be interacted with.
Definition Item.java:21
final int getId()
Gets the identification of this item.
Definition Item.java:324
boolean addAll(Collection<? extends Item > items)
Attempts to deposit items in bulk into this container.
boolean removeAll(Collection<? extends Item > items)
Attempts to withdraw items in bulk from this container.
final boolean containsAll(int... identifiers)
Determines if this container contains all identifiers.
boolean elapsed(long time, TimeUnit unit)
The in-game spellbooks for players.
Definition Spellbook.java:8
The enumerated type whose elements represent definitions for each smeltable bar.
static Optional< SmeltingData > getDefinitionByItem(int itemId)
Searches for a match for the internal required items.
The itemcontainer for casting a spell.
Definition Spell.java:11