RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.activity.randomevent.RandomEvent Class Referenceabstract

The random event handler. More...

Inheritance diagram for com.runehive.content.activity.randomevent.RandomEvent:
Collaboration diagram for com.runehive.content.activity.randomevent.RandomEvent:

Public Member Functions

void cleanup ()
 Cleans up the activity when finished.
ActivityDeathType deathType ()
void finish ()
 Finishes the activity.
ActivityType getType ()
void onLogout (Player player)
 Called when the player logs out.
void onRegionChange (Player player)
 Called when the player changes region.
 RandomEvent (Player player, int cooldown)
 Constructs a new RandomEvent.
Public Member Functions inherited from com.runehive.content.activity.Activity
 Activity (int cooldown, int instance)
 Constructs a new SequencedMinigame object.
void add (Mob mob)
 Adds a mob to the activity.
boolean canDrinkPotions (Player player)
boolean canEat (Player player, FoodData foodType)
boolean canEquipItem (Player player, Item item, EquipmentType type)
boolean canLogout (Player player)
boolean canSpellCast (Player player)
boolean canTeleport (Player player)
 Called when the player attempts to teleport.
boolean canUsePrayer (Player player)
boolean canUseSpecial (Player player)
void cooldown (int cooldown)
 Applies a cooldown.
int getInstance ()
 Gets this activity's instance level.
Optional< Activity_PanelgetPanel ()
 Gets an optional of the activity panel.
int getTicks ()
 Gets the current ticks.
void onDeath (Mob mob)
 Called when the player die.
boolean onEvent (Player player, InteractionEvent interactionEvent)
boolean onStep (Mob mob)
void remove (Mob mob)
 Removes a mob from the activity.
void removeAll (Mob... mobs)
 Removes all mobs from the activity.
void sequence ()
 Sequences the activity.
void setInstance (int instance)
void setPanel (Activity_Panel panel)
 Sets the activity panel.
void setPause (boolean pause)
 Sets the pause state of the activity.
void update ()
 The update method.

Public Attributes

Player player
 The player instance.

Protected Member Functions

abstract int eventNpcIdentification ()
 The event npc identification.
abstract String[] eventNpcShout ()
 The event npc shout messages.
void start ()
 Starts the next activity stage.
Protected Member Functions inherited from com.runehive.content.activity.Activity
boolean clickButton (Player player, ClickButtonInteractionEvent event)
boolean clickItem (Player player, ItemInteractionEvent event)
boolean clickNpc (Player player, NpcInteractionEvent event)
boolean clickObject (Player player, ObjectInteractionEvent event)
final void finishCooldown ()
 Sets the cooldown flag to FINISH.
Optional<? extends ActivityListener<? extends Activity > > getListener ()
 Gets an Optional of the ActivityListener for this activity.
final boolean isPaused ()
 Checks if the cooldown is paused.
boolean itemContainerAction (Player player, ItemContainerInteractionEvent event)
final void pause ()
 Sets the cooldown flag to PAUSE.
boolean pickupItem (Player player, PickupItemInteractionEvent event)
final void resetCooldown ()
 Resets the remaining ticks to the cached cooldown ticks.
void restart (int delay, Runnable runnable)
boolean useItem (Player player, ItemOnItemInteractionEvent event)
boolean useItem (Player player, ItemOnObjectInteractionEvent event)

Protected Attributes

boolean angered
 Flag if the event is angered.
Npc eventNpc
 The event npc.

Private Attributes

int count
 Th message count.

Additional Inherited Members

Static Public Member Functions inherited from com.runehive.content.activity.Activity
static boolean evaluate (Mob mob, Predicate< Activity > predicate)
static void forActivity (Mob mob, Consumer< Activity > consumer)
static< T extends Activity > Optional< T > search (Player player, Class< T > clazz)
Static Protected Attributes inherited from com.runehive.content.activity.Activity
static final int FINISH = -1
 The 'finish' cooldown id.
static final int PAUSE = -2
 The 'pause' cooldown id.
static final int START = 0
 The 'start' cooldown id.

Detailed Description

The random event handler.

Author
Daniel.

Definition at line 20 of file RandomEvent.java.

Constructor & Destructor Documentation

◆ RandomEvent()

com.runehive.content.activity.randomevent.RandomEvent.RandomEvent ( Player player,
int cooldown )

Constructs a new RandomEvent.

Definition at line 35 of file RandomEvent.java.

35 {
36 super(cooldown, player.instance);
37 this.player = player;
38 this.count = 0;
39 }

References com.runehive.content.activity.Activity.cooldown, and player.

Member Function Documentation

◆ cleanup()

void com.runehive.content.activity.randomevent.RandomEvent.cleanup ( )

Cleans up the activity when finished.

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 99 of file RandomEvent.java.

99 {
100 remove(eventNpc);
101 }

References eventNpc.

Referenced by finish().

Here is the caller graph for this function:

◆ deathType()

ActivityDeathType com.runehive.content.activity.randomevent.RandomEvent.deathType ( )

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 104 of file RandomEvent.java.

104 {
105 return ActivityDeathType.NORMAL;
106 }

References com.runehive.content.activity.ActivityDeathType.NORMAL.

◆ eventNpcIdentification()

abstract int com.runehive.content.activity.randomevent.RandomEvent.eventNpcIdentification ( )
abstractprotected

The event npc identification.

Reimplemented in com.runehive.content.activity.randomevent.impl.DrillDemonEvent, com.runehive.content.activity.randomevent.impl.GenieEvent, and com.runehive.content.activity.randomevent.impl.MimeEvent.

Referenced by start().

Here is the caller graph for this function:

◆ eventNpcShout()

abstract String[] com.runehive.content.activity.randomevent.RandomEvent.eventNpcShout ( )
abstractprotected

The event npc shout messages.

Reimplemented in com.runehive.content.activity.randomevent.impl.DrillDemonEvent, com.runehive.content.activity.randomevent.impl.GenieEvent, and com.runehive.content.activity.randomevent.impl.MimeEvent.

Referenced by start().

Here is the caller graph for this function:

◆ finish()

void com.runehive.content.activity.randomevent.RandomEvent.finish ( )

Finishes the activity.

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 81 of file RandomEvent.java.

81 {
82 cleanup();
83 remove(player);
84 }

References cleanup(), and player.

Referenced by onLogout(), and start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getType()

ActivityType com.runehive.content.activity.randomevent.RandomEvent.getType ( )

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 109 of file RandomEvent.java.

109 {
110 return ActivityType.RANDOM_EVENT;
111 }

References com.runehive.content.activity.ActivityType.RANDOM_EVENT.

◆ onLogout()

void com.runehive.content.activity.randomevent.RandomEvent.onLogout ( Player player)

Called when the player logs out.

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 94 of file RandomEvent.java.

94 {
95 finish();
96 }

References finish(), and player.

Here is the call graph for this function:

◆ onRegionChange()

void com.runehive.content.activity.randomevent.RandomEvent.onRegionChange ( Player player)

Called when the player changes region.

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 87 of file RandomEvent.java.

87 {
88 if (eventNpc != null && eventNpc.getPosition().isWithinDistance(player.getPosition(), 15)) {
89 finishCooldown();
90 }
91 }

References eventNpc, com.runehive.content.activity.Activity.finishCooldown(), and player.

Here is the call graph for this function:

◆ start()

void com.runehive.content.activity.randomevent.RandomEvent.start ( )
protected

Starts the next activity stage.

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 48 of file RandomEvent.java.

48 {
49 if (count >= eventNpcShout().length) {
50 player.damage(new Hit(5));
51 finish();
52 return;
53 }
54 if (eventNpc == null) {
55 eventNpc = new Npc(eventNpcIdentification(), player.getPosition());
56 add(eventNpc);
57 eventNpc.interact(player);
58 eventNpc.follow(player);
59 eventNpc.graphic(new Graphic(86, true));
60 eventNpc.owner = player;
61 cooldown(2);
62 return;
63 }
64 eventNpc.animate(new Animation(863));
65 eventNpc.speak(eventNpcShout()[count].replace("%name", player.getName()));
66 eventNpc.follow(player);
67 count++;
68 if (count >= eventNpcShout().length) {
69 angered = true;
70 eventNpc.graphic(new Graphic(86, true));
71 eventNpc.animate(new Animation(864));
72 player.move(Config.DEFAULT_POSITION);
73 player.send(new SendMessage("You have been teleported home since you've ignored the random event."));
74 cooldown(2);
75 } else {
76 resetCooldown();
77 }
78 }

References com.runehive.content.activity.Activity.add(), angered, com.runehive.content.activity.Activity.cooldown, count, com.runehive.Config.DEFAULT_POSITION, eventNpc, eventNpcIdentification(), eventNpcShout(), finish(), player, and com.runehive.content.activity.Activity.resetCooldown().

Here is the call graph for this function:

Member Data Documentation

◆ angered

boolean com.runehive.content.activity.randomevent.RandomEvent.angered
protected

◆ count

int com.runehive.content.activity.randomevent.RandomEvent.count
private

Th message count.

Definition at line 29 of file RandomEvent.java.

Referenced by start().

◆ eventNpc

◆ player


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