RuneHive-Game
Loading...
Searching...
No Matches
CombatListener.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener;
2
3import com.runehive.game.world.entity.combat.CombatType;
4import com.runehive.game.world.entity.combat.FormulaModifier;
5import com.runehive.game.world.entity.combat.hit.Hit;
6import com.runehive.game.world.entity.mob.Mob;
7
8/**
9 * A combat attack is used to describe what the attacking and defending mobs
10 * should do in each stage of combat.
11 *
12 * @author Michael | Chex
13 */
14public interface CombatListener<T extends Mob> extends FormulaModifier<T> {
15
16 boolean withinDistance(T attacker, Mob defender);
17
18 /**
19 * Checks if the attacker can attack the defender.
20 *
21 * @param attacker the attacking mob
22 * @param defender the defending mob
23 */
24 boolean canAttack(T attacker, Mob defender);
25
26 /**
27 * Checks if the attacker can attack the defender.
28 *
29 * @param attacker the attacking mob
30 * @param defender the defending mob
31 */
32 boolean canOtherAttack(Mob attacker, T defender);
33
34 /**
35 * Called when the strategy initializes.
36 *
37 * @param attacker the attacking mob
38 * @param defender the defending mob
39 */
40 default void init(T attacker, Mob defender) {}
41
42 /**
43 * Called when the strategy starts.
44 *
45 * @param attacker the attacking mob
46 * @param defender the defending mob
47 */
48 void start(T attacker, Mob defender, Hit[] hits);
49
50 /**
51 * Called when the attacking hit executes on the defender.
52 *
53 * @param attacker the attacking mob
54 * @param defender the defending mob
55 * @param hit the hit to apply
56 */
57 void attack(T attacker, Mob defender, Hit hit);
58
59 /**
60 * Called when the attacking mob performs an attack on the defender.
61 *
62 * @param attacker the attacking mob
63 * @param defender the defending mob
64 * @param hit the hit to apply
65 */
66 void hit(T attacker, Mob defender, Hit hit);
67
68 /**
69 * Called when the defending mob blocks a hit from the attacker.
70 *
71 * @param attacker the attacking mob
72 * @param defender the defending mob
73 * @param hit the hit being applied
74 * @param combatType the combat type for this hit
75 */
76 void block(Mob attacker, T defender, Hit hit, CombatType combatType);
77
78 /**
79 * Called right before the defending mob dies.
80 *
81 * @param attacker the attacking mob
82 * @param defender the defending mob
83 * @param hit the hit that killed the defender
84 */
85 void preDeath(Mob attacker, T defender, Hit hit);
86
87 /**
88 * Called when the defending mob dies.
89 *
90 * @param attacker the attacking mob
91 * @param defender the defending mob
92 * @param hit the hit that killed the defender
93 */
94 void onDeath(Mob attacker, T defender, Hit hit);
95
96 /**
97 * Called before attacker killed defender.
98 *
99 * @param attacker the attacking mob
100 * @param defender the defending mob
101 * @param hit the hit that killed the defender
102 */
103 void preKill(Mob attacker, Mob defender, Hit hit);
104
105
106 /**
107 * Called when attacker killed defender.
108 *
109 * @param attacker the attacking mob
110 * @param defender the defending mob
111 * @param hit the hit that killed the defender
112 */
113 void onKill(T attacker, Mob defender, Hit hit);
114
115 /**
116 * Called when attacker does the hitsplat
117 *
118 * @param attacker the attacking mob
119 * @param defender the defending mob
120 * @param hit the hit that killed the defender
121 */
122 void hitsplat(T attacker, Mob defender, Hit hit);
123
124 /**
125 * Called when the defending mob finishes their strategy's attack.
126 *
127 * @param attacker the attacking mob
128 * @param defender the defending mob
129 */
130 void finishOutgoing(T attacker, Mob defender);
131
132 /**
133 * Called when the attacking mob finishes their strategy's attack.
134 *
135 * @param attacker the attacking mob
136 * @param defender the defending mob
137 */
138 void finishIncoming(Mob attacker, T defender);
139
140 void onDamage(T defender, Hit hit);
141
142 default void performChecks(T attacker, Mob defender) {
143
144 }
145
146}
147
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
Handles the mob class.
Definition Mob.java:66
A combat attack is used to describe what the attacking and defending mobs should do in each stage of ...
boolean canAttack(T attacker, Mob defender)
Checks if the attacker can attack the defender.
void block(Mob attacker, T defender, Hit hit, CombatType combatType)
Called when the defending mob blocks a hit from the attacker.
void hit(T attacker, Mob defender, Hit hit)
Called when the attacking mob performs an attack on the defender.
boolean canOtherAttack(Mob attacker, T defender)
Checks if the attacker can attack the defender.
void preDeath(Mob attacker, T defender, Hit hit)
Called right before the defending mob dies.
void start(T attacker, Mob defender, Hit[] hits)
Called when the strategy starts.
void preKill(Mob attacker, Mob defender, Hit hit)
Called before attacker killed defender.
void onKill(T attacker, Mob defender, Hit hit)
Called when attacker killed defender.
void finishIncoming(Mob attacker, T defender)
Called when the attacking mob finishes their strategy's attack.
void finishOutgoing(T attacker, Mob defender)
Called when the defending mob finishes their strategy's attack.
default void init(T attacker, Mob defender)
Called when the strategy initializes.
void onDeath(Mob attacker, T defender, Hit hit)
Called when the defending mob dies.
void attack(T attacker, Mob defender, Hit hit)
Called when the attacking hit executes on the defender.
void hitsplat(T attacker, Mob defender, Hit hit)
Called when attacker does the hitsplat.