Elin Decompiled Documentation EA 23.290 Nightly
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 && !traitMonsterBall.IsSilvercatBall && 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 if (t.id == "1177")
131 {
132 c.PlaySound("throw_beachball");
133 }
134 else
135 {
136 c.PlaySound("throw");
137 }
138 EffectIRenderer result = null;
139 if (c.isSynced || p.IsSync)
140 {
141 result = Effect.Get<EffectIRenderer>((t.trait is TraitBall || t.HasTag(CTAG.throwBall) || method == ThrowMethod.Reward) ? "throw_ball" : "throw").Play((c.isChara && c.Chara.host != null) ? c.Chara.host : c, t, c.pos, p, 0.2f);
142 t.renderer.SetFirst(first: false, c.renderer.position);
143 }
144 if (!t.HasElement(410) || method == ThrowMethod.Punish)
145 {
146 t._Move(p);
147 }
148 if (!t.trait.CanBeDestroyed)
149 {
150 c.PlaySound("miss");
151 return result;
152 }
153 ThrowType throwType = t.trait.ThrowType;
154 if ((uint)(throwType - 1) <= 1u)
155 {
156 Msg.Say("shatter");
157 }
158 if (Act.TC?.Chara?.mimicry != null)
159 {
160 Act.TC.Chara.mimicry.RevealMimicry(c, surprise: false);
161 }
162 bool flag = method == ThrowMethod.Reward;
163 bool flag2 = method == ThrowMethod.Default;
164 switch (t.trait.ThrowType)
165 {
166 case ThrowType.Explosive:
167 flag = true;
168 t.c_uidRefCard = c.uid;
169 t.Die(null, c, AttackSource.Throw);
170 break;
171 case ThrowType.Vase:
172 t.Die(null, null, AttackSource.Throw);
173 break;
174 case ThrowType.Potion:
175 flag = true;
176 if (Act.TC != null)
177 {
178 Act.TC.Say("throw_hit", t, Act.TC);
179 }
180 Act.TP.ModFire(-50, extinguish: true);
181 if (Act.TC != null && Act.TC.isChara)
182 {
183 if (t.trait.CanDrink(Act.TC.Chara))
184 {
186 }
187 flag2 = t.IsNegativeGift;
189 }
190 else
191 {
193 }
194 t.Die(null, null, AttackSource.Throw);
195 c.ModExp(108, 50);
196 break;
197 case ThrowType.Dice:
198 t.SetDir(EClass.rnd(6));
199 break;
200 case ThrowType.Snow:
201 flag = true;
202 flag2 = false;
203 if (Act.TC != null && Act.TC.isChara)
204 {
205 Act.TC.Say("throw_hit", t, Act.TC);
206 if (EClass.rnd(2) == 0)
207 {
208 c.Talk("snow_hit");
209 }
211 t.Die(null, null, AttackSource.Throw);
212 c.ModExp(108, 50);
213 }
214 break;
215 case ThrowType.Ball:
216 flag = true;
217 flag2 = false;
218 if (Act.TC != null && Act.TC.isChara)
219 {
220 Act.TC.Say("throw_hit", t, Act.TC);
221 if (EClass.rnd(2) == 0)
222 {
223 c.Talk("snow_hit");
224 }
225 Act.TC.Say("ball_hit");
226 Act.TC.Chara?.Pick(t, msg: false);
227 c.ModExp(108, 50);
228 }
229 break;
230 case ThrowType.Flyer:
231 flag = true;
232 flag2 = false;
233 if (Act.TC != null && Act.TC.isChara && c.isChara)
234 {
235 Act.TC.Say("throw_hit", t, Act.TC);
236 c.Chara.GiveGift(Act.TC.Chara, t);
237 c.ModExp(108, 50);
238 }
239 break;
240 case ThrowType.MonsterBall:
241 {
242 flag = true;
243 flag2 = false;
244 TraitMonsterBall traitMonsterBall = t.trait as TraitMonsterBall;
245 if (traitMonsterBall.chara != null)
246 {
247 if ((traitMonsterBall.IsLittleBall && !(EClass._zone is Zone_LittleGarden) && !EClass.game.IsSurvival) || (traitMonsterBall.IsDuponneBall && !(EClass._zone is Zone_Exile) && !EClass.game.IsSurvival) || (traitMonsterBall.IsSilvercatBall && !(EClass._zone.id == "startVillage2") && !EClass.game.IsSurvival))
248 {
249 break;
250 }
251 Chara _c = EClass._zone.AddCard(traitMonsterBall.chara, p).Chara;
252 if (_c.ai != null)
253 {
254 _c.ai.Cancel();
255 }
256 _c.enemy = null;
257 _c.PlayEffect("identify");
258 t.Die();
259 if (_c.IsMultisize)
260 {
261 _c.DestroyPath(_c.pos);
262 _c.ForeachPoint(delegate(Point p2, bool first)
263 {
264 foreach (Chara item in p2.ListCharas())
265 {
266 if (item != _c)
267 {
268 _c.Kick(p2, ignoreSelf: true, checkWall: false);
269 break;
270 }
271 }
272 });
273 }
274 if ((traitMonsterBall.IsSilvercatBall || _c.id == "cat_silver") && EClass._zone.id == "startVillage2")
275 {
276 _c.orgPos = c.pos.Copy();
277 _c.homeZone = EClass._zone;
278 Chara chara = _c;
279 Hostility c_originalHostility = (_c.hostility = Hostility.Friend);
280 chara.c_originalHostility = c_originalHostility;
282 _c.PlaySound("chime_angel");
283 }
284 else if (traitMonsterBall.IsDuponneBall && _c.id == "lurie_boss")
285 {
286 _c.orgPos = c.pos.Copy();
287 _c.homeZone = EClass._zone;
288 Chara chara2 = _c;
289 Hostility c_originalHostility = (_c.hostility = Hostility.Friend);
290 chara2.c_originalHostility = c_originalHostility;
292 _c.PlaySound("chime_angel");
293 }
294 else if (traitMonsterBall.IsLittleBall && _c.id == "littleOne")
295 {
296 _c.orgPos = c.pos.Copy();
297 Chara chara3 = _c;
298 Hostility c_originalHostility = (_c.hostility = Hostility.Neutral);
299 chara3.c_originalHostility = c_originalHostility;
301 _c.PlaySound("chime_angel");
302 EClass.core.actionsNextFrame.Add(delegate
303 {
304 _c.Talk("little_saved");
305 });
306 EClass.player.flags.little_saved = true;
308 }
309 else
310 {
311 _c.MakeAlly();
312 }
313 }
314 else
315 {
316 if (Act.TC == null || !Act.TC.isChara)
317 {
318 break;
319 }
320 Act.TC.Say("throw_hit", t, Act.TC);
321 Chara chara4 = Act.TC.Chara;
322 if (traitMonsterBall.IsSilvercatBall)
323 {
324 if (chara4.id != "cat_silver" || chara4.IsPCFactionOrMinion || EClass._zone.id == "startVillage2" || EClass._zone.IsUserZone || EClass._zone.Boss == chara4 || chara4.c_bossType != 0)
325 {
326 Msg.Say("monsterball_invalid");
327 break;
328 }
329 }
330 else if (traitMonsterBall.IsDuponneBall)
331 {
332 if (chara4.id != "lurie_boss" || chara4.IsPCFactionOrMinion || EClass._zone is Zone_Exile || EClass._zone.IsUserZone)
333 {
334 Msg.Say("monsterball_invalid");
335 break;
336 }
337 }
338 else if (traitMonsterBall.IsLittleBall)
339 {
340 if (chara4.id != "littleOne" || chara4.IsPCFactionOrMinion || EClass._zone is Zone_LittleGarden || EClass._zone.IsUserZone || chara4.GetBool(132))
341 {
342 Msg.Say("monsterball_invalid");
343 break;
344 }
345 chara4.SetBool(132, enable: true);
346 }
347 else
348 {
349 if (!chara4.trait.CanBeTamed || EClass._zone.IsUserZone)
350 {
351 Msg.Say("monsterball_invalid");
352 break;
353 }
354 if (chara4.LV > traitMonsterBall.owner.LV)
355 {
356 Msg.Say("monsterball_lv");
357 break;
358 }
359 if (!EClass.debug.enable && chara4.hp > chara4.MaxHP / 10)
360 {
361 Msg.Say("monsterball_hp");
362 break;
363 }
364 }
365 Msg.Say("monsterball_capture", c, chara4);
366 chara4.PlaySound("identify");
367 chara4.PlayEffect("identify");
368 t.ChangeMaterial("copper");
369 if (chara4.IsLocalChara)
370 {
371 Debug.Log("Creating Replacement NPC for:" + chara4);
373 }
374 traitMonsterBall.chara = chara4;
375 chara4.UnmakeMinion();
376 EClass._zone.RemoveCard(chara4);
377 chara4.homeZone = null;
378 c.ModExp(108, 100);
379 if (traitMonsterBall.IsDuponneBall && EClass.game.quests.GetPhase<QuestNegotiationDarkness>() == 3)
380 {
381 EClass._zone.SetBGM(120, refresh: true, 3f);
383 }
384 }
385 break;
386 }
387 }
388 if (t.trait is TraitDye)
389 {
391 }
392 if (!flag && Act.TC != null)
393 {
394 AttackProcess.Current.Prepare(c.Chara, t, Act.TC, Act.TP, 0, _isThrow: true);
395 if (method == ThrowMethod.Punish && t.rarity >= Rarity.Legendary)
396 {
397 AttackProcess.Current.critFury = true;
398 }
399 if (AttackProcess.Current.Perform(0, hasHit: false))
400 {
402 {
404 }
405 if (!t.isDestroyed && t.trait.CanBeDestroyed && !t.IsFurniture && !t.category.IsChildOf("instrument") && !t.IsUnique && !t.HasElement(410))
406 {
407 t.Destroy();
408 }
409 }
410 else
411 {
412 c.PlaySound("miss");
413 }
414 }
415 if (EClass.rnd(2) == 0)
416 {
417 c.Chara.RemoveCondition<ConInvisibility>();
418 c.Chara.RemoveCondition<ConDark>();
419 }
420 if (Act.TC != null)
421 {
422 if (flag2)
423 {
425 }
427 {
428 c.Chara.stamina.Mod(-1);
429 }
430 }
431 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)
432 {
434 {
435 target = Act.TC,
436 throwItem = t
437 });
438 }
439 return result;
440 }
441}
AttackSource
Definition: AttackSource.cs:2
CTAG
Definition: CTAG.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:305
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
void SetBool(int id, bool enable)
Definition: BaseCard.cs:20
bool GetBool(int id)
Definition: BaseCard.cs:15
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:2436
bool isDestroyed
Definition: Card.cs:76
bool IsPCFactionOrMinion
Definition: Card.cs:2312
virtual MoveResult _Move(Point p, MoveType type=MoveType.Walk)
Definition: Card.cs:5955
virtual Chara Chara
Definition: Card.cs:2108
Thing Split(int a)
Definition: Card.cs:3566
string id
Definition: Card.cs:36
bool IsUnique
Definition: Card.cs:2129
bool IsRestrainedResident
Definition: Card.cs:2298
virtual void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Definition: Card.cs:5097
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6405
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3117
virtual void SetDir(int d)
Definition: Card.cs:6461
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6965
int hp
Definition: Card.cs:243
Rarity rarity
Definition: Card.cs:315
ICardParent parent
Definition: Card.cs:56
bool ExistsOnMap
Definition: Card.cs:2123
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
Definition: Card.cs:6087
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:8114
bool IsFurniture
Definition: Card.cs:2291
bool HasTag(CTAG tag)
Definition: Card.cs:2635
Point pos
Definition: Card.cs:60
virtual void LookAt(Card c)
Definition: Card.cs:6472
int uid
Definition: Card.cs:123
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6439
Trait trait
Definition: Card.cs:54
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2165
void Destroy()
Definition: Card.cs:5164
bool c_isImportant
Definition: Card.cs:1037
BossType c_bossType
Definition: Card.cs:1247
virtual bool isChara
Definition: Card.cs:2121
Card GetRootCard()
Definition: Card.cs:3508
void ModExp(string alias, int a)
Definition: Card.cs:2688
string c_idRefName
Definition: Card.cs:1667
SourceCategory.Row category
Definition: Card.cs:2087
CardRenderer renderer
Definition: Card.cs:62
void KillAnime()
Definition: Card.cs:6419
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6152
int LV
Definition: Card.cs:387
virtual bool isSynced
Definition: Card.cs:2125
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7082
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:505
AIAct ai
Definition: Chara.cs:204
Chara CreateReplacement()
Definition: Chara.cs:8194
void UnmakeMinion()
Definition: Chara.cs:2411
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9453
override bool IsPC
Definition: Chara.cs:626
Chara host
Definition: Chara.cs:33
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1276
AIAct SetAI(AIAct g)
Definition: Chara.cs:9083
ConTransmuteMimic mimicry
Definition: Chara.cs:106
void DestroyPath(Point pos)
Definition: Chara.cs:3231
override int MaxHP
Definition: Chara.cs:722
void MakeAlly(bool msg=true)
Definition: Chara.cs:2337
Stats stamina
Definition: Chara.cs:1172
bool IsLocalChara
Definition: Chara.cs:855
void GiveGift(Chara c, Thing t)
Definition: Chara.cs:8440
override bool IsMultisize
Definition: Chara.cs:720
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6490
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4381
void OnGiveErohon(Thing t)
Definition: Chara.cs:8562
virtual void RevealMimicry(Card c, bool surprise)
Definition: ConWet.cs:2
bool shiftToUseNegativeAbilityOnSelf
Definition: CoreConfig.cs:194
new GameConfig game
Definition: CoreConfig.cs:609
bool enable
Definition: CoreDebug.cs:286
CoreConfig config
Definition: Core.cs:70
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Core core
Definition: EClass.cs:7
static Zone _zone
Definition: EClass.cs:21
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static float rndf(float a)
Definition: EClass.cs:102
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
Definition: EInput.cs:8
static bool isShiftDown
Definition: EInput.cs:272
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:276
QuestManager quests
Definition: Game.cs:183
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:984
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:491
bool IsSky
Definition: Point.cs:224
Point Set(int _x, int _z)
Definition: Point.cs:503
void ModFire(int value, bool extinguish=false)
Definition: Point.cs:933
bool IsSync
Definition: Point.cs:344
bool Equals(int _x, int _z)
Definition: Point.cs:960
List< Chara > ListCharas()
Definition: Point.cs:1171
Card FindAttackTarget()
Definition: Point.cs:1098
bool IsHidden
Definition: Point.cs:347
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
Definition: Point.cs:769
int GetPhase(string id)
Quest Get(string id)
string id
Definition: Spatial.cs:13
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:535
virtual bool CanBeTamed
Definition: TraitChara.cs:102
virtual bool IsSilvercatBall
virtual bool IsDuponneBall
virtual bool IsLittleBall
virtual bool CanExtendBuild
Definition: Trait.cs:181
virtual bool CanBeAttacked
Definition: Trait.cs:177
virtual void OnThrowGround(Chara c, Point p)
Definition: Trait.cs:1022
virtual bool CanBeDestroyed
Definition: Trait.cs:307
Card owner
Definition: Trait.cs:28
virtual void OnDrink(Chara c)
Definition: Trait.cs:1018
virtual bool CanDrink(Chara c)
Definition: Trait.cs:1013
virtual ThrowType ThrowType
Definition: Trait.cs:261
virtual bool CanOnlyCarry
Definition: Trait.cs:305
virtual bool IsUserZone
Definition: Zone.cs:273
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3026
Chara Boss
Definition: Zone.cs:86
void RemoveCard(Card t)
Definition: Zone.cs:2057
void ModInfluence(int a)
Definition: Zone.cs:3681
Card AddCard(Card t, Point point)
Definition: Zone.cs:2017