RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.DestructionSkillAction Class Referenceabstract

The skill action that represents an action where one item is removed from an inventory and lost forever. More...

Inheritance diagram for com.runehive.content.skill.impl.DestructionSkillAction:
Collaboration diagram for com.runehive.content.skill.impl.DestructionSkillAction:

Public Member Functions

boolean canRun ()
 Determines if the task can be ran.
 DestructionSkillAction (Mob mob, Optional< Position > position, boolean instant)
 Creates a new DestructionSkillAction.
abstract Item destructItem ()
 The item that will be removed upon destruction.
final WalkablePolicy getWalkablePolicy ()
 Gets the WalkablePolicy of this action.
void onDestruct (boolean success)
 The method executed upon destruction of the item.
final void onExecute ()
 The method which is called on intervals of the specified #delay;.
boolean prioritized ()
 Determines if this action is prioritized.
abstract double successFactor ()
Public Member Functions inherited from com.runehive.content.skill.SkillAction
abstract Optional< SkillAnimationanimation ()
 The skill animation to execute.
abstract boolean canInit ()
 Determines if this action can be initialized.
abstract double experience ()
 The experience given from this action.
boolean ignore ()
 Determines if future skill actions from the same type should be ignored.
abstract void init ()
 Any functionality that should be handled when this action is submitted.
abstract int skill ()
 The skill we should hand to experience to.
 SkillAction (Mob mob, Optional< Position > position, boolean instant)
 Creates a new Action randomevent.
 SkillAction (Mob mob, Optional< Position > position, int delay, boolean instant)
 Creates a new Action randomevent.
final void start ()
 Attempts to start the skill.
Public Member Functions inherited from com.runehive.game.action.Action< T extends Mob >
 Action (T mob, int delay)
 Creates a new Action randomevent.
 Action (T mob, int delay, boolean instant)
 Creates a new Action randomevent.
boolean cancellableInProgress ()
getMob ()
 Gets the player.
abstract String getName ()
 Gets the name of this action.
Public Member Functions inherited from com.runehive.game.task.Task
Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Private Attributes

final RandomGen random = new RandomGen()

Static Private Attributes

static final int SUCCESS_FACTOR = 10

Additional Inherited Members

Protected Member Functions inherited from com.runehive.content.skill.SkillAction
final void execute ()
 A function representing the unit of work that will be carried out.
final void onSchedule ()
 A function executed on registration.
Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()
boolean canSchedule ()
 A function executed on registration.
void onCancel (boolean logout)
 A function executed on cancellation.
Package Functions inherited from com.runehive.game.task.Task
void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Detailed Description

The skill action that represents an action where one item is removed from an inventory and lost forever.

This type of skill action is very basic and only requires that a player have the item to destruct in their inventory.

The skills that may use this type skill action include, but are not limited to PRAYER.

Author
lare96 http://github.com/lare96
See also
SkillAction
HarvestingSkillAction

Definition at line 26 of file DestructionSkillAction.java.

Constructor & Destructor Documentation

◆ DestructionSkillAction()

com.runehive.content.skill.impl.DestructionSkillAction.DestructionSkillAction ( Mob mob,
Optional< Position > position,
boolean instant )

Creates a new DestructionSkillAction.

Parameters
mobthe mob this skill action is for.
positionthe position the player should face.
instantdetermines if this task should run instantly.

Definition at line 37 of file DestructionSkillAction.java.

37 {
38 super(mob, position, instant);
39 }

References com.runehive.game.task.Task.instant, com.runehive.game.action.Action< T extends Mob >.mob, and com.runehive.content.skill.SkillAction.position.

Member Function Documentation

◆ canRun()

boolean com.runehive.content.skill.impl.DestructionSkillAction.canRun ( )

Determines if the task can be ran.

Reimplemented from com.runehive.game.task.Task.

Definition at line 42 of file DestructionSkillAction.java.

42 {
43 String name = ItemDefinition.get(destructItem().getId()).getName();
44 if(getMob().isPlayer() && !getMob().getPlayer().inventory.contains(destructItem().getId())) {
45 getMob().getPlayer().send(new SendMessage("You do not have any " + name + " in your inventory."));
46 return false;
47 }
48 return true;
49 }

References destructItem(), com.runehive.game.world.items.ItemDefinition.get(), com.runehive.game.action.Action< T extends Mob >.getMob(), and com.runehive.game.world.items.ItemDefinition.getName().

Here is the call graph for this function:

◆ destructItem()

abstract Item com.runehive.content.skill.impl.DestructionSkillAction.destructItem ( )
abstract

The item that will be removed upon destruction.

Returns
the item that will be removed.

Reimplemented in com.runehive.content.skill.impl.firemaking.FiremakingAction.

Referenced by canRun().

Here is the caller graph for this function:

◆ getWalkablePolicy()

final WalkablePolicy com.runehive.content.skill.impl.DestructionSkillAction.getWalkablePolicy ( )

Gets the WalkablePolicy of this action.

Returns
The walkable policy of this action.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 70 of file DestructionSkillAction.java.

70 {
71 return WalkablePolicy.NON_WALKABLE;
72 }

References com.runehive.game.action.policy.WalkablePolicy.NON_WALKABLE.

◆ onDestruct()

void com.runehive.content.skill.impl.DestructionSkillAction.onDestruct ( boolean success)

The method executed upon destruction of the item.

Parameters
successdetermines if the destruction was successful or not.

Reimplemented in com.runehive.content.skill.impl.firemaking.FiremakingAction.

Definition at line 78 of file DestructionSkillAction.java.

78 {
79
80 }

Referenced by onExecute().

Here is the caller graph for this function:

◆ onExecute()

final void com.runehive.content.skill.impl.DestructionSkillAction.onExecute ( )

The method which is called on intervals of the specified #delay;.

Reimplemented from com.runehive.content.skill.SkillAction.

Definition at line 54 of file DestructionSkillAction.java.

54 {
55 int factor = (getMob().skills.getSkills()[skill()].getLevel() / SUCCESS_FACTOR);
56 double boost = (factor * 0.01);
57 if (random.success((successFactor() + boost))) {
58 if(getMob().isPlayer()) {
59 onDestruct(true);
60 getMob().skills.addExperience(skill(), experience());
61 this.cancel();
62 return;
63 }
64 } else {
65 onDestruct(false);
66 }
67 }

References com.runehive.game.task.Task.cancel(), com.runehive.content.skill.SkillAction.experience(), com.runehive.game.action.Action< T extends Mob >.getMob(), onDestruct(), random, com.runehive.content.skill.SkillAction.skill(), SUCCESS_FACTOR, and successFactor().

Here is the call graph for this function:

◆ prioritized()

boolean com.runehive.content.skill.impl.DestructionSkillAction.prioritized ( )

Determines if this action is prioritized.

When making an action prioritized, the next action will be ignored if not queued.

Returns
true if this action is prioritized, false otherwise.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 89 of file DestructionSkillAction.java.

89 {
90 return false;
91 }

◆ successFactor()

abstract double com.runehive.content.skill.impl.DestructionSkillAction.successFactor ( )
abstract

Reimplemented in com.runehive.content.skill.impl.firemaking.FiremakingAction.

Referenced by onExecute().

Here is the caller graph for this function:

Member Data Documentation

◆ random

final RandomGen com.runehive.content.skill.impl.DestructionSkillAction.random = new RandomGen()
private

Definition at line 29 of file DestructionSkillAction.java.

Referenced by onExecute().

◆ SUCCESS_FACTOR

final int com.runehive.content.skill.impl.DestructionSkillAction.SUCCESS_FACTOR = 10
staticprivate

Definition at line 28 of file DestructionSkillAction.java.

Referenced by onExecute().


The documentation for this class was generated from the following file: