|
1
|
|
|
/* |
|
2
|
|
|
* This file is part of Araknemu. |
|
3
|
|
|
* |
|
4
|
|
|
* Araknemu is free software: you can redistribute it and/or modify |
|
5
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
|
6
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
7
|
|
|
* (at your option) any later version. |
|
8
|
|
|
* |
|
9
|
|
|
* Araknemu is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12
|
|
|
* GNU Lesser General Public License for more details. |
|
13
|
|
|
* |
|
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
15
|
|
|
* along with Araknemu. If not, see <https://www.gnu.org/licenses/>. |
|
16
|
|
|
* |
|
17
|
|
|
* Copyright (c) 2017-2019 Vincent Quatrevieux |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
package fr.quatrevieux.araknemu.network.game.out.fight.action; |
|
21
|
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.Buff; |
|
23
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.PassiveFighter; |
|
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.map.FightCell; |
|
25
|
|
|
import fr.quatrevieux.araknemu.game.spell.Spell; |
|
26
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Effect of a fight action |
|
30
|
|
|
*/ |
|
31
|
|
|
public final class ActionEffect { |
|
32
|
|
|
private final int id; |
|
33
|
|
|
private final PassiveFighter caster; |
|
34
|
|
|
private final Object[] arguments; |
|
35
|
|
|
|
|
36
|
1 |
|
public ActionEffect(int id, PassiveFighter caster, Object... arguments) { |
|
37
|
1 |
|
this.id = id; |
|
38
|
1 |
|
this.caster = caster; |
|
39
|
1 |
|
this.arguments = arguments; |
|
40
|
1 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
@Override |
|
43
|
|
|
public String toString() { |
|
44
|
1 |
|
return "GA;" + id + ";" + caster.id() + ";" + StringUtils.join(arguments, ","); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Send used movement points after a movement |
|
49
|
|
|
* |
|
50
|
|
|
* @param fighter The fighter |
|
51
|
|
|
* @param quantity The MP quantity |
|
52
|
|
|
*/ |
|
53
|
|
|
public static ActionEffect usedMovementPoints(PassiveFighter fighter, int quantity) { |
|
54
|
1 |
|
return new ActionEffect(129, fighter, fighter.id(), -quantity); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Send used action points after an action |
|
59
|
|
|
* |
|
60
|
|
|
* @param fighter The fighter |
|
61
|
|
|
* @param quantity The AP quantity |
|
62
|
|
|
*/ |
|
63
|
|
|
public static ActionEffect usedActionPoints(PassiveFighter fighter, int quantity) { |
|
64
|
1 |
|
return new ActionEffect(102, fighter, fighter.id(), -quantity); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Change target life |
|
69
|
|
|
* |
|
70
|
|
|
* @param caster The effect castet |
|
71
|
|
|
* @param target The target |
|
72
|
|
|
* @param quantity The life points difference. Negative for damage, Positive for heal |
|
73
|
|
|
*/ |
|
74
|
|
|
public static ActionEffect alterLifePoints(PassiveFighter caster, PassiveFighter target, int quantity) { |
|
75
|
1 |
|
return new ActionEffect(100, caster, target.id(), quantity); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Critical hit for spell |
|
80
|
|
|
* |
|
81
|
|
|
* @param caster The spell caster |
|
82
|
|
|
* @param spell The launched spell |
|
83
|
|
|
*/ |
|
84
|
|
|
public static ActionEffect criticalHitSpell(PassiveFighter caster, Spell spell) { |
|
85
|
1 |
|
return new ActionEffect(301, caster, spell.id()); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Critical hit for close combat cast |
|
90
|
|
|
* |
|
91
|
|
|
* @param caster The weapon caster |
|
92
|
|
|
*/ |
|
93
|
|
|
public static ActionEffect criticalHitCloseCombat(PassiveFighter caster) { |
|
94
|
1 |
|
return new ActionEffect(304, caster); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* A fighter die |
|
99
|
|
|
* |
|
100
|
|
|
* @param caster The spell caster |
|
101
|
|
|
* @param fighter The dead fighter |
|
102
|
|
|
*/ |
|
103
|
|
|
public static ActionEffect fighterDie(PassiveFighter caster, PassiveFighter fighter) { |
|
104
|
1 |
|
return new ActionEffect(103, caster, fighter.id()); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Teleport a fighter |
|
109
|
|
|
* |
|
110
|
|
|
* @param caster The spell caster |
|
111
|
|
|
* @param fighter The teleport fighter |
|
112
|
|
|
* @param target The target cell |
|
113
|
|
|
*/ |
|
114
|
|
|
public static ActionEffect teleport(PassiveFighter caster, PassiveFighter fighter, FightCell target) { |
|
115
|
1 |
|
return new ActionEffect(4, caster, fighter.id(), target.id()); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* The fighter skip the next turn |
|
120
|
|
|
* |
|
121
|
|
|
* @param caster The buff caster |
|
122
|
|
|
* @param fighter The target fighter |
|
123
|
|
|
*/ |
|
124
|
|
|
public static ActionEffect skipNextTurn(PassiveFighter caster, PassiveFighter fighter) { |
|
125
|
1 |
|
return new ActionEffect(140, caster, fighter.id()); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* The fighter return the spell |
|
130
|
|
|
* |
|
131
|
|
|
* @param fighter The fighter |
|
132
|
|
|
* @param success true is the spell is successfully returned |
|
133
|
|
|
*/ |
|
134
|
|
|
public static ActionEffect returnSpell(PassiveFighter fighter, boolean success) { |
|
135
|
1 |
|
return new ActionEffect(106, fighter, fighter.id(), success ? "1" : "0"); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Buff effect for characteristic change |
|
140
|
|
|
* |
|
141
|
|
|
* @param buff The applied buff |
|
142
|
|
|
*/ |
|
143
|
|
|
public static ActionEffect buff(Buff buff, int value) { |
|
144
|
1 |
|
return new ActionEffect(buff.effect().effect(), buff.caster(), buff.target().id(), value, buff.effect().duration()); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* Add action points for the current turn |
|
149
|
|
|
* |
|
150
|
|
|
* @param fighter The fighter |
|
151
|
|
|
* @param quantity The AP quantity |
|
152
|
|
|
*/ |
|
153
|
|
|
public static ActionEffect addActionPoints(PassiveFighter fighter, int quantity) { |
|
154
|
1 |
|
return new ActionEffect(120, fighter, fighter.id(), quantity); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Remove action points for the current turn |
|
159
|
|
|
* |
|
160
|
|
|
* @param fighter The fighter |
|
161
|
|
|
* @param quantity The AP quantity |
|
162
|
|
|
*/ |
|
163
|
|
|
public static ActionEffect removeActionPoints(PassiveFighter fighter, int quantity) { |
|
164
|
1 |
|
return new ActionEffect(168, fighter, fighter.id(), -quantity); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Add movement points for the current turn |
|
169
|
|
|
* |
|
170
|
|
|
* @param fighter The fighter |
|
171
|
|
|
* @param quantity The MP quantity |
|
172
|
|
|
*/ |
|
173
|
|
|
public static ActionEffect addMovementPoints(PassiveFighter fighter, int quantity) { |
|
174
|
1 |
|
return new ActionEffect(128, fighter, fighter.id(), quantity); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Remove movement points for the current turn |
|
179
|
|
|
* |
|
180
|
|
|
* @param fighter The fighter |
|
181
|
|
|
* @param quantity The MP quantity |
|
182
|
|
|
*/ |
|
183
|
|
|
public static ActionEffect removeMovementPoints(PassiveFighter fighter, int quantity) { |
|
184
|
1 |
|
return new ActionEffect(169, fighter, fighter.id(), -quantity); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Suffered damage value is reduced |
|
189
|
|
|
* |
|
190
|
|
|
* @param fighter The fighter |
|
191
|
|
|
* @param value The reduction value |
|
192
|
|
|
*/ |
|
193
|
|
|
public static ActionEffect reducedDamage(PassiveFighter fighter, int value) { |
|
194
|
1 |
|
return new ActionEffect(105, fighter, fighter.id(), value); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Add state to the fighter |
|
199
|
|
|
* |
|
200
|
|
|
* @param fighter The fighter |
|
201
|
|
|
* @param state The state id to add |
|
202
|
|
|
*/ |
|
203
|
|
|
public static ActionEffect addState(PassiveFighter fighter, int state) { |
|
204
|
1 |
|
return new ActionEffect(950, fighter, fighter.id(), state, 1); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* Remove state from the fighter |
|
209
|
|
|
* |
|
210
|
|
|
* @param fighter The fighter |
|
211
|
|
|
* @param state The state id to remove |
|
212
|
|
|
*/ |
|
213
|
|
|
public static ActionEffect removeState(PassiveFighter fighter, int state) { |
|
214
|
1 |
|
return new ActionEffect(950, fighter, fighter.id(), state, 0); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Remove all buffs that can be removed from the target |
|
219
|
|
|
* |
|
220
|
|
|
* @param caster The caster |
|
221
|
|
|
* @param target The target |
|
222
|
|
|
*/ |
|
223
|
|
|
public static ActionEffect dispelBuffs(PassiveFighter caster, PassiveFighter target) { |
|
224
|
1 |
|
return new ActionEffect(132, caster, target.id()); |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* The fighter has been slided (i.e. move back or front) by the caster |
|
229
|
|
|
* |
|
230
|
|
|
* @param caster The spell caster |
|
231
|
|
|
* @param target The target (which has moved) |
|
232
|
|
|
* @param destination The destination cell |
|
233
|
|
|
*/ |
|
234
|
|
|
public static ActionEffect slide(PassiveFighter caster, PassiveFighter target, FightCell destination) { |
|
235
|
1 |
|
return new ActionEffect(5, caster, target.id(), destination.id()); |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* Damage as been reflected by the target |
|
240
|
|
|
* |
|
241
|
|
|
* @param castTarget The original cast target |
|
242
|
|
|
* @param value Reflected value |
|
243
|
|
|
*/ |
|
244
|
|
|
public static ActionEffect reflectedDamage(PassiveFighter castTarget, int value) { |
|
245
|
1 |
|
return new ActionEffect(107, castTarget, castTarget.id(), value); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* The target has dodged the lost of action points |
|
250
|
|
|
* |
|
251
|
|
|
* @param caster The spell caster |
|
252
|
|
|
* @param target The target (which has dodged point lost) |
|
253
|
|
|
* @param value The dodged point list value |
|
254
|
|
|
*/ |
|
255
|
|
|
public static ActionEffect dodgeActionPointLost(PassiveFighter caster, PassiveFighter target, int value) { |
|
256
|
1 |
|
return new ActionEffect(308, caster, target.id(), value); |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
/** |
|
260
|
|
|
* The target has dodged the lost of movement points |
|
261
|
|
|
* |
|
262
|
|
|
* @param caster The spell caster |
|
263
|
|
|
* @param target The target (which has dodged point lost) |
|
264
|
|
|
* @param value The dodged point list value |
|
265
|
|
|
*/ |
|
266
|
|
|
public static ActionEffect dodgeMovementPointLost(PassiveFighter caster, PassiveFighter target, int value) { |
|
267
|
1 |
|
return new ActionEffect(309, caster, target.id(), value); |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* Change the appearance of the target |
|
272
|
|
|
* |
|
273
|
|
|
* @param caster The spell caster |
|
274
|
|
|
* @param target The effect target |
|
275
|
|
|
* @param newAppearance The new appearance id (can be found in `clips/sprites/[id].swf) |
|
276
|
|
|
* @param duration The effect duration |
|
277
|
|
|
*/ |
|
278
|
|
|
public static ActionEffect changeAppearance(PassiveFighter caster, PassiveFighter target, int newAppearance, int duration) { |
|
279
|
1 |
|
return new ActionEffect(149, caster, target.id(), target.sprite().gfxId(), newAppearance, duration); |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* Reset the appearance of the target |
|
284
|
|
|
*/ |
|
285
|
|
|
public static ActionEffect resetAppearance(PassiveFighter caster, PassiveFighter target) { |
|
286
|
1 |
|
final int baseGfxId = target.sprite().gfxId(); |
|
287
|
|
|
|
|
288
|
1 |
|
return new ActionEffect(149, caster, target.id(), baseGfxId, baseGfxId, 0); |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* Launch visual effect of a spell |
|
293
|
|
|
* |
|
294
|
|
|
* @param caster The visual effect caster |
|
295
|
|
|
* @param targetCell The target cell |
|
296
|
|
|
* @param spell Spell which contains sprite arguments |
|
297
|
|
|
*/ |
|
298
|
|
|
public static ActionEffect launchVisualEffect(PassiveFighter caster, FightCell targetCell, Spell spell) { |
|
299
|
1 |
|
return new ActionEffect(208, caster, targetCell.id(), spell.spriteId(), spell.spriteArgs(), spell.level()); |
|
300
|
|
|
} |
|
301
|
|
|
} |
|
302
|
|
|
|