Elin Decompiled Documentation EA 23.211 Nightly Patch 1
Loading...
Searching...
No Matches
ActThrow.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class ActThrow : ActBaseAttack
4{
5 public Thing target;
6
7 public Chara pcTarget;
8
9 public override bool CanPressRepeat => true;
10
12
13 public override int PerformDistance => 99;
14
15 public override string GetText(string str = "")
16 {
17 string text = "";
18 if (target != null)
19 {
20 TraitMonsterBall traitMonsterBall = target.trait as TraitMonsterBall;
21 if (pcTarget != null && traitMonsterBall != null && !traitMonsterBall.IsDuponneBall && !traitMonsterBall.IsLittleBall && pcTarget.LV > target.LV)
22 {
23 text = " " + "mb_invalidLV".lang();
24 }
25 }
26 return base.GetText(str) + text;
27 }
28
29 public override bool CanPerform()
30 {
31 if (pcTarget != null && pcTarget.ExistsOnMap)
32 {
34 }
35 if (!Act.TP.IsHidden && !Act.TP.IsSky)
36 {
37 return Act.CC.CanSeeLos(Act.TP);
38 }
39 return false;
40 }
41
42 public override bool Perform()
43 {
44 if (target == null)
45 {
46 target = Act.TC as Thing;
47 }
48 if (target == null || target.isDestroyed || target.GetRootCard() != Act.CC)
49 {
50 return false;
51 }
52 if (pcTarget != null)
53 {
55 {
56 return false;
57 }
59 }
61 return true;
62 }
63
64 public static bool CanThrow(Chara c, Thing t, Card target, Point p = null)
65 {
66 if (t == null)
67 {
68 return false;
69 }
70 if (t.c_isImportant && !t.HasElement(410))
71 {
72 return false;
73 }
74 if (p == null && target != null && target.ExistsOnMap)
75 {
76 p = target.pos;
77 }
78 if (p == null)
79 {
80 return false;
81 }
82 if ((p.HasBlock && !p.cell.hasDoor && p.sourceBlock.tileType.IsBlockPass) || p.Equals(EClass.pc.pos) || t.trait.CanExtendBuild || t.trait.CanOnlyCarry)
83 {
84 return false;
85 }
87 {
88 Card card = target ?? p.FindAttackTarget();
89 if (card != null && card.IsPCFactionOrMinion)
90 {
91 return false;
92 }
93 }
94 return true;
95 }
96
97 public static EffectIRenderer Throw(Card c, Point p, Thing t, ThrowMethod method = ThrowMethod.Default, float failChance = 0f)
98 {
99 if (failChance > EClass.rndf(1f))
100 {
101 Point randomPoint = p.GetRandomPoint(1);
102 if (randomPoint != null && !randomPoint.Equals(c.pos))
103 {
104 p = randomPoint;
105 }
106 }
107 return Throw(c, p, p.FindAttackTarget(), t, method);
108 }
109
110 public static EffectIRenderer Throw(Card c, Point p, Card target, Thing t, ThrowMethod method = ThrowMethod.Default)
111 {
112 if (t.parent != EClass._zone && (!t.HasElement(410) || method == ThrowMethod.Punish))
113 {
115 }
116 Act.TP.Set(p);
117 Act.TC = target;
118 if (t.trait.ThrowType == ThrowType.Snow)
119 {
120 t.dir = EClass.rnd(2);
121 c.Talk("snow_throw");
122 if (EClass.rnd(2) == 0)
123 {
124 Act.TC = null;
125 }
126 }
127 c.Say("throw", c, t.GetName(NameStyle.Full, 1));
128 c.LookAt(p);
130 c.PlaySound("throw");
131 EffectIRenderer result = null;
132 if (c.isSynced || p.IsSync)
133 {
134 result = Effect.Get<EffectIRenderer>((t.trait is TraitBall) ? "throw_ball" : "throw").Play((c.isChara && c.Chara.host != null) ? c.Chara.host : c, t, c.pos, p, 0.2f);
135 t.renderer.SetFirst(first: false, c.renderer.position);
136 }
137 if (!t.HasElement(410) || method == ThrowMethod.Punish)
138 {
139 t._Move(p);
140 }
141 if (!t.trait.CanBeDestroyed)
142 {
143 c.PlaySound("miss");
144 return result;
145 }
146 ThrowType throwType = t.trait.ThrowType;
147 if ((uint)(throwType - 1) <= 1u)
148 {
149 Msg.Say("shatter");
150 }
151 bool flag = method == ThrowMethod.Reward;
152 bool flag2 = method == ThrowMethod.Default;
153 switch (t.trait.ThrowType)
154 {
155 case ThrowType.Explosive:
156 flag = true;
157 t.c_uidRefCard = c.uid;
158 t.Die(null, c, AttackSource.Throw);
159 break;
160 case ThrowType.Vase:
161 t.Die(null, null, AttackSource.Throw);
162 break;
163 case ThrowType.Potion:
164 flag = true;
165 if (Act.TC != null)
166 {
167 Act.TC.Say("throw_hit", t, Act.TC);
168 }
169 Act.TP.ModFire(-50, extinguish: true);
170 if (Act.TC != null && Act.TC.isChara)
171 {
172 if (t.trait.CanDrink(Act.TC.Chara))
173 {
175 }
176 flag2 = t.IsNegativeGift;
178 }
179 else
180 {
182 }
183 t.Die(null, null, AttackSource.Throw);
184 c.ModExp(108, 50);
185 break;
186 case ThrowType.Snow:
187 flag = true;
188 flag2 = false;
189 if (Act.TC != null && Act.TC.isChara)
190 {
191 Act.TC.Say("throw_hit", t, Act.TC);
192 if (EClass.rnd(2) == 0)
193 {
194 c.Talk("snow_hit");
195 }
197 t.Die(null, null, AttackSource.Throw);
198 c.ModExp(108, 50);
199 }
200 break;
201 case ThrowType.Ball:
202 flag = true;
203 flag2 = false;
204 if (Act.TC != null && Act.TC.isChara)
205 {
206 Act.TC.Say("throw_hit", t, Act.TC);
207 if (EClass.rnd(2) == 0)
208 {
209 c.Talk("snow_hit");
210 }
211 Act.TC.Say("ball_hit");
212 Act.TC.Chara?.Pick(t);
213 c.ModExp(108, 50);
214 }
215 break;
216 case ThrowType.Flyer:
217 flag = true;
218 flag2 = false;
219 if (Act.TC != null && Act.TC.isChara && c.isChara)
220 {
221 Act.TC.Say("throw_hit", t, Act.TC);
222 c.Chara.GiveGift(Act.TC.Chara, t);
223 c.ModExp(108, 50);
224 }
225 break;
226 case ThrowType.MonsterBall:
227 {
228 flag = true;
229 flag2 = false;
230 TraitMonsterBall traitMonsterBall = t.trait as TraitMonsterBall;
231 if (traitMonsterBall.chara != null)
232 {
233 if ((traitMonsterBall.IsLittleBall && !(EClass._zone is Zone_LittleGarden) && !EClass.game.IsSurvival) || (traitMonsterBall.IsDuponneBall && !(EClass._zone is Zone_Exile) && !EClass.game.IsSurvival))
234 {
235 break;
236 }
237 Chara _c = EClass._zone.AddCard(traitMonsterBall.chara, p).Chara;
238 if (_c.ai != null)
239 {
240 _c.ai.Cancel();
241 }
242 _c.enemy = null;
243 _c.PlayEffect("identify");
244 t.Die();
245 if (_c.IsMultisize)
246 {
247 _c.DestroyPath(_c.pos);
248 _c.ForeachPoint(delegate(Point p2, bool first)
249 {
250 foreach (Chara item in p2.ListCharas())
251 {
252 if (item != _c)
253 {
254 _c.Kick(p2, ignoreSelf: true, checkWall: false);
255 break;
256 }
257 }
258 });
259 }
260 if (traitMonsterBall.IsDuponneBall && _c.id == "lurie_boss")
261 {
262 _c.orgPos = c.pos.Copy();
263 _c.homeZone = EClass._zone;
264 Chara chara = _c;
265 Hostility c_originalHostility = (_c.hostility = Hostility.Friend);
266 chara.c_originalHostility = c_originalHostility;
268 _c.PlaySound("chime_angel");
269 }
270 else if (traitMonsterBall.IsLittleBall && _c.id == "littleOne")
271 {
272 _c.orgPos = c.pos.Copy();
273 Chara chara2 = _c;
274 Hostility c_originalHostility = (_c.hostility = Hostility.Neutral);
275 chara2.c_originalHostility = c_originalHostility;
277 _c.PlaySound("chime_angel");
278 EClass.core.actionsNextFrame.Add(delegate
279 {
280 _c.Talk("little_saved");
281 });
282 EClass.player.flags.little_saved = true;
284 }
285 else
286 {
287 _c.MakeAlly();
288 }
289 }
290 else
291 {
292 if (Act.TC == null || !Act.TC.isChara)
293 {
294 break;
295 }
296 Act.TC.Say("throw_hit", t, Act.TC);
297 Chara chara3 = Act.TC.Chara;
298 if (traitMonsterBall.IsDuponneBall)
299 {
300 if (chara3.id != "lurie_boss" || chara3.IsPCFactionOrMinion || EClass._zone is Zone_Exile || EClass._zone.IsUserZone)
301 {
302 Msg.Say("monsterball_invalid");
303 break;
304 }
305 }
306 else if (traitMonsterBall.IsLittleBall)
307 {
308 if (chara3.id != "littleOne" || chara3.IsPCFactionOrMinion || EClass._zone is Zone_LittleGarden || EClass._zone.IsUserZone)
309 {
310 Msg.Say("monsterball_invalid");
311 break;
312 }
313 }
314 else
315 {
316 if (!chara3.trait.CanBeTamed || EClass._zone.IsUserZone)
317 {
318 Msg.Say("monsterball_invalid");
319 break;
320 }
321 if (chara3.LV > traitMonsterBall.owner.LV)
322 {
323 Msg.Say("monsterball_lv");
324 break;
325 }
326 if (!EClass.debug.enable && chara3.hp > chara3.MaxHP / 10)
327 {
328 Msg.Say("monsterball_hp");
329 break;
330 }
331 }
332 Msg.Say("monsterball_capture", c, chara3);
333 chara3.PlaySound("identify");
334 chara3.PlayEffect("identify");
335 t.ChangeMaterial("copper");
336 if (chara3.IsLocalChara)
337 {
338 Debug.Log("Creating Replacement NPC for:" + chara3);
340 }
341 traitMonsterBall.chara = chara3;
342 chara3.ReleaseMinion();
343 EClass._zone.RemoveCard(chara3);
344 chara3.homeZone = null;
345 c.ModExp(108, 100);
346 if (traitMonsterBall.IsDuponneBall && EClass.game.quests.GetPhase<QuestNegotiationDarkness>() == 3)
347 {
348 EClass.Sound.StopBGM(3f);
349 EClass._zone.SetBGM(1, refresh: false);
351 }
352 }
353 break;
354 }
355 }
356 if (t.trait is TraitDye)
357 {
359 }
360 if (!flag && Act.TC != null)
361 {
362 AttackProcess.Current.Prepare(c.Chara, t, Act.TC, Act.TP, 0, _isThrow: true);
363 if (method == ThrowMethod.Punish && t.rarity >= Rarity.Legendary)
364 {
365 AttackProcess.Current.critFury = true;
366 }
367 if (AttackProcess.Current.Perform(0, hasHit: false))
368 {
370 {
372 }
373 if (!t.isDestroyed && t.trait.CanBeDestroyed && !t.IsFurniture && !t.category.IsChildOf("instrument") && !t.IsUnique && !t.HasElement(410))
374 {
375 t.Destroy();
376 }
377 }
378 else
379 {
380 c.PlaySound("miss");
381 }
382 }
383 if (EClass.rnd(2) == 0)
384 {
385 c.Chara.RemoveCondition<ConInvisibility>();
386 }
387 if (Act.TC != null)
388 {
389 if (flag2)
390 {
392 }
394 {
395 c.Chara.stamina.Mod(-1);
396 }
397 }
398 if (t.HasElement(410) && Act.TC != null && Act.CC == EClass.pc && !(Act.CC.ai is AI_PracticeDummy) && (Act.TC.trait is TraitTrainingDummy || Act.TC.IsRestrainedResident) && Act.CC.stamina.value > 0)
399 {
401 {
402 target = Act.TC,
403 throwItem = t
404 });
405 }
406 return result;
407 }
408}
AttackSource
Definition: AttackSource.cs:2
Hostility
Definition: Hostility.cs:2
NameStyle
Definition: NameStyle.cs:2
Rarity
Definition: Rarity.cs:2
ThrowMethod
Definition: ThrowMethod.cs:2
ThrowType
Definition: ThrowType.cs:2
virtual Status Cancel()
Definition: AIAct.cs:291
Chara pcTarget
Definition: ActThrow.cs:7
static EffectIRenderer Throw(Card c, Point p, Thing t, ThrowMethod method=ThrowMethod.Default, float failChance=0f)
Definition: ActThrow.cs:97
Thing target
Definition: ActThrow.cs:5
override bool CanPerform()
Definition: ActThrow.cs:29
override bool Perform()
Definition: ActThrow.cs:42
override int PerformDistance
Definition: ActThrow.cs:13
override string GetText(string str="")
Definition: ActThrow.cs:15
static bool CanThrow(Chara c, Thing t, Card target, Point p=null)
Definition: ActThrow.cs:64
static EffectIRenderer Throw(Card c, Point p, Card target, Thing t, ThrowMethod method=ThrowMethod.Default)
Definition: ActThrow.cs:110
override bool CanPressRepeat
Definition: ActThrow.cs:9
Definition: ACT.cs:62
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
List< Action > actionsNextFrame
Definition: BaseCore.cs:31
Vector3 position
Definition: CardRenderer.cs:21
virtual void NextFrame()
Definition: Card.cs:11
bool IsNegativeGift
Definition: Card.cs:2370
bool isDestroyed
Definition: Card.cs:73
bool IsPCFactionOrMinion
Definition: Card.cs:2246
virtual MoveResult _Move(Point p, MoveType type=MoveType.Walk)
Definition: Card.cs:5670
virtual Chara Chara
Definition: Card.cs:2044
Thing Split(int a)
Definition: Card.cs:3395
string id
Definition: Card.cs:33
bool IsUnique
Definition: Card.cs:2065
bool IsRestrainedResident
Definition: Card.cs:2232
virtual void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Definition: Card.cs:4895
bool HasElement(int ele, int req=1)
Definition: Card.cs:5767
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5981
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3007
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6536
int hp
Definition: Card.cs:240
Rarity rarity
Definition: Card.cs:312
ICardParent parent
Definition: Card.cs:53
bool ExistsOnMap
Definition: Card.cs:2059
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:7637
bool IsFurniture
Definition: Card.cs:2225
Point pos
Definition: Card.cs:57
virtual void LookAt(Card c)
Definition: Card.cs:6048
int uid
Definition: Card.cs:120
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6015
Trait trait
Definition: Card.cs:51
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2101
void Destroy()
Definition: Card.cs:4962
bool c_isImportant
Definition: Card.cs:1010
virtual bool isChara
Definition: Card.cs:2057
Card GetRootCard()
Definition: Card.cs:3337
void ModExp(string alias, int a)
Definition: Card.cs:2622
string c_idRefName
Definition: Card.cs:1627
SourceCategory.Row category
Definition: Card.cs:2023
CardRenderer renderer
Definition: Card.cs:59
void KillAnime()
Definition: Card.cs:5995
int LV
Definition: Card.cs:384
virtual bool isSynced
Definition: Card.cs:2061
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6633
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:501
AIAct ai
Definition: Chara.cs:200
Chara CreateReplacement()
Definition: Chara.cs:7783
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8968
override bool IsPC
Definition: Chara.cs:610
Chara host
Definition: Chara.cs:33
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1244
void ReleaseMinion()
Definition: Chara.cs:2334
AIAct SetAI(AIAct g)
Definition: Chara.cs:8598
void DestroyPath(Point pos)
Definition: Chara.cs:3143
override int MaxHP
Definition: Chara.cs:706
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
Definition: Chara.cs:5628
void MakeAlly(bool msg=true)
Definition: Chara.cs:2257
Stats stamina
Definition: Chara.cs:1140
bool IsLocalChara
Definition: Chara.cs:839
void GiveGift(Chara c, Thing t)
Definition: Chara.cs:8005
override bool IsMultisize
Definition: Chara.cs:704
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6192
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4229
void OnGiveErohon(Thing t)
Definition: Chara.cs:8127
Definition: ConWet.cs:2
bool shiftToUseNegativeAbilityOnSelf
Definition: CoreConfig.cs:194
new GameConfig game
Definition: CoreConfig.cs:605
bool enable
Definition: CoreDebug.cs:286
CoreConfig config
Definition: Core.cs:70
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static int rnd(long a)
Definition: EClass.cs:58
static float rndf(float a)
Definition: EClass.cs:92
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
static SoundManager Sound
Definition: EClass.cs:46
Definition: EInput.cs:8
static bool isShiftDown
Definition: EInput.cs:261
EffectIRenderer Play(Card _card, Card _origin, Vector3 _to)
Definition: Effect.cs:7
static Effect Get(Effect original)
Definition: Effect.cs:85
bool IsSurvival
Definition: Game.cs:272
QuestManager quests
Definition: Game.cs:179
List< Chara > deadCharas
Definition: Map.cs:46
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
int little_saved
Definition: Player.cs:926
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:479
bool IsSky
Definition: Point.cs:212
Point Set(int _x, int _z)
Definition: Point.cs:491
void ModFire(int value, bool extinguish=false)
Definition: Point.cs:917
bool IsSync
Definition: Point.cs:332
bool Equals(int _x, int _z)
Definition: Point.cs:944
List< Chara > ListCharas()
Definition: Point.cs:1155
Card FindAttackTarget()
Definition: Point.cs:1082
bool IsHidden
Definition: Point.cs:335
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
Definition: Point.cs:757
Quest Get(string id)
virtual void Mod(int a)
Definition: Stats.cs:135
static TargetTypeGround Ground
Definition: TargetType.cs:15
Definition: Thing.cs:8
override string GetName(NameStyle style, int _num=-1)
Definition: Thing.cs:527
virtual bool CanBeTamed
Definition: TraitChara.cs:102
virtual bool IsDuponneBall
virtual bool IsLittleBall
virtual bool CanExtendBuild
Definition: Trait.cs:168
virtual bool CanBeAttacked
Definition: Trait.cs:164
virtual void OnThrowGround(Chara c, Point p)
Definition: Trait.cs:991
virtual bool CanBeDestroyed
Definition: Trait.cs:294
Card owner
Definition: Trait.cs:27
virtual void OnDrink(Chara c)
Definition: Trait.cs:987
virtual bool CanDrink(Chara c)
Definition: Trait.cs:982
virtual ThrowType ThrowType
Definition: Trait.cs:248
virtual bool CanOnlyCarry
Definition: Trait.cs:292
void SetBGM(List< int > ids, bool refresh=true)
Definition: Zone.cs:2906
virtual bool IsUserZone
Definition: Zone.cs:266
void RemoveCard(Card t)
Definition: Zone.cs:1988
void ModInfluence(int a)
Definition: Zone.cs:3521
Card AddCard(Card t, Point point)
Definition: Zone.cs:1948