Elin Decompiled Documentation EA 23.130 Nightly
Loading...
Searching...
No Matches
ActMelee.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class ActMelee : ActBaseAttack
5{
6 public virtual float BaseDmgMTP => 1f;
7
8 public virtual bool UseWeaponDist => true;
9
10 public override int PerformDistance
11 {
12 get
13 {
14 if (Act.CC != null)
15 {
16 return Act.CC.body.GetMeleeDistance();
17 }
18 return 1;
19 }
20 }
21
22 public override bool ResetAxis => true;
23
24 public override bool CanPressRepeat => true;
25
26 public bool HideHint(Card c)
27 {
28 if (!EClass.pc.isBlind && c != null)
29 {
30 if (c.isChara)
31 {
32 return !EClass.pc.CanSee(c);
33 }
34 return false;
35 }
36 return true;
37 }
38
39 public override string GetHintText(string str = "")
40 {
41 return "";
42 }
43
44 public override string GetTextSmall(Card c)
45 {
46 if (!HideHint(c))
47 {
48 return base.GetTextSmall(c);
49 }
50 return null;
51 }
52
53 public override CursorInfo GetCursorIcon(Card c)
54 {
55 if (!HideHint(c))
56 {
58 }
59 return null;
60 }
61
62 public override bool ShowMouseHint(Card c)
63 {
64 return !HideHint(c);
65 }
66
67 public override bool CanPerform()
68 {
69 if (Act.TC == null || !Act.TC.IsAliveInCurrentZone)
70 {
71 return false;
72 }
74 {
75 return false;
76 }
77 if (PerformDistance == 1)
78 {
80 {
81 return false;
82 }
83 }
84 else if (!Act.CC.CanSeeLos(Act.TC))
85 {
86 return false;
87 }
88 return base.CanPerform();
89 }
90
91 public override bool Perform()
92 {
93 return Attack();
94 }
95
96 public bool Attack(float dmgMulti = 1f, bool maxRoll = false)
97 {
98 Act.CC.combatCount = 10;
101 if (Act.CC.HasCondition<ConFear>())
102 {
103 Act.CC.Say("fear", Act.CC, Act.TC);
104 if (Act.CC.IsPC)
105 {
106 EInput.Consume(consumeAxis: true);
107 }
108 return true;
109 }
111 Act.TC?.Chara?.RequestProtection(Act.CC, delegate(Chara c)
112 {
113 Act.TC = c;
114 });
115 CellEffect effect = Act.TP.cell.effect;
116 if (effect != null && effect.id == 6 && EClass.rnd(2) == 0)
117 {
118 Act.CC.PlaySound("miss");
119 Act.CC.Say("abMistOfDarkness_miss", Act.CC);
120 return true;
121 }
122 bool hasHit = false;
123 bool usedWeapon = false;
124 bool usedTalisman = false;
125 int count = 0;
126 int dist = Act.CC.Dist(Act.TC);
127 Point orgPos = Act.TC.pos.Copy();
128 Card orgTC = Act.TC;
130 foreach (BodySlot slot in Act.CC.body.slots)
131 {
132 _Attack(slot);
133 }
134 if (!usedWeapon)
135 {
136 _Attack(null);
137 }
139 {
140 EClass.Wait(0.25f, Act.CC);
141 }
142 if (!hasHit)
143 {
144 Act.CC.PlaySound("miss");
145 }
146 if (EClass.rnd(2) == 0)
147 {
148 Act.CC.RemoveCondition<ConInvisibility>();
149 }
150 return true;
151 void _Attack(BodySlot slot)
152 {
153 Act.TC = orgTC;
154 Act.TP = orgPos;
155 Thing w;
156 int splash;
157 int chaser;
158 int flurry;
159 int frustration;
160 int feint;
161 int mod_talisman;
162 if (Act.TC != null && Act.TC.IsAliveInCurrentZone)
163 {
164 w = null;
165 if (slot != null)
166 {
167 if (slot.thing == null || slot.elementId != 35 || slot.thing.source.offense.Length < 2)
168 {
169 return;
170 }
171 w = slot.thing;
172 }
173 int num = 1 + Mathf.Max(Act.CC.Evalue(666), (w != null) ? w.Evalue(666) : 0);
174 if (!UseWeaponDist || dist <= 1 || dist <= num)
175 {
176 int num2 = GetWeaponEnc(606, addSelfEnc: false);
177 int scatter = GetWeaponEnc(607, addSelfEnc: false);
178 splash = GetWeaponEnc(608, addSelfEnc: true);
179 chaser = GetWeaponEnc(620, addSelfEnc: true);
180 flurry = GetWeaponEnc(621, addSelfEnc: true);
181 frustration = GetWeaponEnc(624, addSelfEnc: true);
182 int num3 = GetWeaponEnc(622, addSelfEnc: true);
183 feint = GetWeaponEnc(623, addSelfEnc: true);
184 mod_talisman = GetWeaponEnc(609, addSelfEnc: true);
185 List<Point> list2 = EClass._map.ListPointsInLine(Act.CC.pos, Act.TC.pos, num2 / 10 + ((num2 % 10 > EClass.rnd(10)) ? 1 : 0) + 1);
186 if (w != null)
187 {
188 if (safety)
189 {
190 if (!w.HasElement(486))
191 {
192 return;
193 }
194 num2 = (scatter = (splash = (num3 = 0)));
195 }
196 usedWeapon = true;
197 if (w.IsMeleeWithAmmo && Act.CC.IsPC && w.c_ammo <= 0 && !Act.CC.HasCondition<ConReload>())
198 {
200 }
201 }
202 AttackWithFlurry(Act.TC, Act.TP, 1f, subAttack: false);
203 if (num2 > 0)
204 {
205 foreach (Point item in list2)
206 {
207 if (!item.Equals(orgPos))
208 {
209 Chara firstChara = item.FirstChara;
210 if (firstChara != null && firstChara.IsHostile(Act.CC))
211 {
212 AttackWithFlurry(firstChara, item, 1f, subAttack: false);
213 }
214 }
215 }
216 }
217 else if (scatter > 0)
218 {
219 Act.TP.ForeachNeighbor(delegate(Point p)
220 {
221 if (!p.Equals(orgPos))
222 {
223 Chara firstChara2 = p.FirstChara;
224 if (firstChara2 != null && firstChara2.IsHostile(Act.CC))
225 {
226 AttackWithFlurry(firstChara2, p, Mathf.Min(0.5f + 0.05f * Mathf.Sqrt(scatter), 1f + 0.01f * Mathf.Sqrt(scatter)), subAttack: true);
227 }
228 }
229 });
230 }
231 else if (num3 > 0)
232 {
233 List<Point> list = new List<Point>();
234 Act.TP.ForeachNeighbor(delegate(Point p)
235 {
236 list.Add(p.Copy());
237 });
238 list.Shuffle();
239 int num4 = 0;
240 for (int i = 0; i < 9 && num3 > EClass.rnd(10 + (int)Mathf.Pow(3f, i + 2)); i++)
241 {
242 num4++;
243 }
244 foreach (Point item2 in list)
245 {
246 foreach (Card item3 in item2.ListCards().Copy())
247 {
248 if (num4 <= 0 || !Act.CC.IsAliveInCurrentZone)
249 {
250 break;
251 }
252 if (item3.trait.CanBeAttacked || (item3.isChara && item3.Chara.IsHostile(Act.CC)))
253 {
254 AttackWithFlurry(item3, item2, 1f, subAttack: true);
255 num4--;
256 }
257 }
258 }
259 }
260 count++;
261 }
262 }
263 void Attack(Card _tc, Point _tp, float mtp, bool subAttack)
264 {
265 Act.TC = _tc;
266 Act.TP = _tp;
268 int num5 = 1;
269 if (chaser > 0)
270 {
271 for (int j = 0; j < 10; j++)
272 {
273 if (chaser > EClass.rnd(4 + (int)Mathf.Pow(4f, j + 2)))
274 {
275 num5++;
276 }
277 }
278 }
279 bool flag = false;
280 for (int k = 0; k < num5; k++)
281 {
282 if (k > 0)
283 {
284 Act.CC.Say("attack_chaser");
285 }
286 flag = AttackProcess.Current.Perform(count, hasHit, dmgMulti * mtp * BaseDmgMTP, maxRoll, subAttack);
287 if (!flag && frustration > 0 && 10f + 2f * Mathf.Sqrt(frustration) > (float)EClass.rnd(100))
288 {
289 AttackProcess.Current.critFury = true;
290 flag = AttackProcess.Current.Perform(count, hasHit, dmgMulti * mtp, maxRoll, subAttack);
291 AttackProcess.Current.critFury = false;
292 }
294 {
295 break;
296 }
297 }
298 Act.TC = _tc;
299 Act.TP = _tp;
300 if (w != null && w.c_ammo > 0 && !Act.CC.HasCondition<ConReload>() && !safety)
301 {
302 bool flag2 = true;
303 TraitAmmo traitAmmo = ((w.ammoData == null) ? null : (w.ammoData.trait as TraitAmmo));
304 if (traitAmmo != null && traitAmmo is TraitAmmoTalisman traitAmmoTalisman)
305 {
306 flag2 = false;
307 if (flag && !usedTalisman && Act.TC != null && Act.TC.IsAliveInCurrentZone)
308 {
309 Act act = Act.CC.elements.GetElement(traitAmmoTalisman.owner.refVal)?.act ?? ACT.Create(traitAmmoTalisman.owner.refVal);
310 Act.powerMod = traitAmmo.owner.encLV;
311 if (act.Perform(Act.CC, Act.TC, Act.TP))
312 {
313 usedTalisman = true;
314 flag2 = true;
315 if (mod_talisman > 0 && Mathf.Min(10f + Mathf.Sqrt(mod_talisman) * 5f, 90f) > (float)EClass.rnd(100))
316 {
317 flag2 = false;
318 }
319 int spellExp = Act.CC.elements.GetSpellExp(Act.CC, act, 200);
320 Act.CC.ModExp(act.id, spellExp);
321 }
322 Act.powerMod = 100;
323 }
324 }
325 if (flag2)
326 {
327 w.c_ammo--;
328 if (w.ammoData != null)
329 {
330 w.ammoData.Num = w.c_ammo;
331 }
332 if (w.c_ammo <= 0)
333 {
334 w.c_ammo = 0;
335 w.ammoData = null;
336 }
338 }
339 }
340 Act.TC = _tc;
342 {
344 if (feint > 0 && 10f + 4f * Mathf.Sqrt(feint) > (float)EClass.rnd(100))
345 {
346 Act.TC.Chara.AddCondition<ConSupress>(100 + 5 * (int)Mathf.Sqrt(feint));
347 }
348 }
349 if (splash > 0)
350 {
351 Act.TP.ForeachNeighbor(delegate(Point p)
352 {
353 if (p.Equals(Act.TP) || p.Equals(Act.CC.pos))
354 {
355 return;
356 }
357 if (!p.IsBlocked)
358 {
359 p.PlayEffect("smoke_shockwave");
360 p.Copy().Animate(AnimeID.QuakeMini, animeBlock: true);
361 }
362 foreach (Card item4 in p.ListCards())
363 {
364 if (item4.trait.CanBeAttacked || (item4.isChara && item4.Chara.IsHostile(Act.CC)))
365 {
366 int rawDamage = AttackProcess.Current.GetRawDamage(0.1f + 0.05f * Mathf.Sqrt(splash), crit: false, maxRoll: false);
367 rawDamage = item4.ApplyProtection(rawDamage);
368 item4.DamageHP(rawDamage, 0, 100, AttackSource.Shockwave, Act.CC);
369 }
370 }
371 });
372 }
373 }
374 void AttackWithFlurry(Card _tc, Point _tp, float mtp, bool subAttack)
375 {
376 int num6 = 1;
377 if (flurry > 0)
378 {
379 for (int l = 0; l < 10 && flurry > EClass.rnd(25 + (int)Mathf.Pow(5f, l + 2)); l++)
380 {
381 num6++;
382 }
383 }
384 for (int m = 0; m < num6; m++)
385 {
387 {
388 break;
389 }
390 if (!_tc.IsAliveInCurrentZone)
391 {
392 break;
393 }
394 if (m > 0)
395 {
396 Act.CC.Say("attack_flurry");
397 }
398 Attack(_tc, _tp, mtp, subAttack);
399 }
400 }
401 int GetWeaponEnc(int ele, bool addSelfEnc)
402 {
403 return AttackProcess.GetWeaponEnc(Act.CC, w, ele, addSelfEnc);
404 }
405 }
406 }
407}
AnimeID
Definition: AnimeID.cs:2
AttackSource
Definition: AttackSource.cs:2
Definition: ACT.cs:6
static Act Create(int id)
Definition: ACT.cs:36
override bool ResetAxis
Definition: ActMelee.cs:22
bool Attack(float dmgMulti=1f, bool maxRoll=false)
Definition: ActMelee.cs:96
override CursorInfo GetCursorIcon(Card c)
Definition: ActMelee.cs:53
bool HideHint(Card c)
Definition: ActMelee.cs:26
override bool CanPerform()
Definition: ActMelee.cs:67
override bool Perform()
Definition: ActMelee.cs:91
override string GetTextSmall(Card c)
Definition: ActMelee.cs:44
override bool CanPressRepeat
Definition: ActMelee.cs:24
override string GetHintText(string str="")
Definition: ActMelee.cs:39
virtual float BaseDmgMTP
Definition: ActMelee.cs:6
override int PerformDistance
Definition: ActMelee.cs:11
virtual bool UseWeaponDist
Definition: ActMelee.cs:8
override bool ShowMouseHint(Card c)
Definition: ActMelee.cs:62
static bool TryReload(Thing weapon, Thing ammo=null)
Definition: ActRanged.cs:343
Definition: ACT.cs:62
virtual bool Perform()
Definition: ACT.cs:264
static Card TC
Definition: ACT.cs:79
static Point TP
Definition: ACT.cs:81
static Chara CC
Definition: ACT.cs:77
void Prepare(Chara _CC, Thing _weapon, Card _TC=null, Point _TP=null, int _attackIndex=0, bool _isThrow=false)
bool Perform(int count, bool hasHit, float dmgMulti=1f, bool maxRoll=false, bool subAttack=false)
static AttackProcess Current
Definition: AttackProcess.cs:8
int GetRawDamage(float dmgMulti, bool crit, bool maxRoll)
static int GetWeaponEnc(Chara CC, Thing w, int ele, bool addSelfEnc=false)
int elementId
Definition: BodySlot.cs:6
Thing thing
Definition: BodySlot.cs:8
void PlayAnime(AnimeID id, bool force)
virtual void NextFrame()
Definition: Card.cs:11
bool IsPCFactionOrMinion
Definition: Card.cs:2172
virtual Chara Chara
Definition: Card.cs:1970
ElementContainerCard elements
Definition: Card.cs:37
int c_ammo
Definition: Card.cs:1409
void DamageHP(int dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:3810
bool HasElement(int ele, int req=1)
Definition: Card.cs:5395
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5585
Point pos
Definition: Card.cs:55
virtual int ApplyProtection(int dmg, int mod=100)
Definition: Card.cs:3785
Trait trait
Definition: Card.cs:49
int encLV
Definition: Card.cs:310
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2027
virtual bool isChara
Definition: Card.cs:1983
int Evalue(int ele)
Definition: Card.cs:2471
int Dist(Card c)
Definition: Card.cs:7025
void ModExp(string alias, int a)
Definition: Card.cs:2548
CardRenderer renderer
Definition: Card.cs:57
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6232
CellEffect effect
Definition: Cell.cs:94
int GetMeleeDistance()
Definition: CharaBody.cs:420
List< BodySlot > slots
Definition: CharaBody.cs:8
Definition: Chara.cs:10
override bool IsAliveInCurrentZone
Definition: Chara.cs:551
CharaBody body
Definition: Chara.cs:94
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8513
override bool IsPC
Definition: Chara.cs:602
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1064
bool HasCondition(string alias)
Definition: Chara.cs:8666
bool CanSee(Card c)
Definition: Chara.cs:1032
bool CanInteractTo(Card c)
Definition: Chara.cs:2240
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:5765
bool isBlind
Definition: Chara.cs:128
void RequestProtection(Chara attacker, Action< Chara > action)
Definition: Chara.cs:7725
bool IsHostile()
Definition: Chara.cs:5942
override void LookAt(Card c)
Definition: Chara.cs:3238
new GameConfig game
Definition: CoreConfig.cs:598
CoreConfig config
Definition: Core.cs:70
static CursorInfo IconMelee
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:58
static Core core
Definition: EClass.cs:6
static void Wait(float a, Card c)
Definition: EClass.cs:97
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
Definition: EInput.cs:8
static void Consume(int _skipFrame)
Definition: EInput.cs:656
int GetSpellExp(Chara c, Element e, int costMod=100)
Element GetElement(string alias)
int id
Definition: ELEMENT.cs:246
Act act
Definition: ELEMENT.cs:390
static void SetDirty(Thing t)
List< Point > ListPointsInLine(Point center, Point to, int radius)
Definition: Map.cs:2304
Definition: Point.cs:9
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1027
Point Copy()
Definition: Point.cs:479
void ForeachNeighbor(Action< Point > action, bool diagonal=true)
Definition: Point.cs:1373
bool IsBlocked
Definition: Point.cs:351
bool Equals(int _x, int _z)
Definition: Point.cs:936
Effect PlayEffect(string id)
Definition: Point.cs:1224
Cell cell
Definition: Point.cs:51
void Animate(AnimeID id, bool animeBlock=false)
Definition: Point.cs:1278
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
bool IsMeleeWithAmmo
Definition: Thing.cs:20
virtual bool CanBeAttacked
Definition: Trait.cs:163
Card owner
Definition: Trait.cs:26