Elin Decompiled Documentation EA 23.271 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 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 if (Act.TC?.Chara?.mimicry != null)
152 {
153 Act.TC.Chara.mimicry.RevealMimicry(c, surprise: false);
154 }
155 bool flag = method == ThrowMethod.Reward;
156 bool flag2 = method == ThrowMethod.Default;
157 switch (t.trait.ThrowType)
158 {
159 case ThrowType.Explosive:
160 flag = true;
161 t.c_uidRefCard = c.uid;
162 t.Die(null, c, AttackSource.Throw);
163 break;
164 case ThrowType.Vase:
165 t.Die(null, null, AttackSource.Throw);
166 break;
167 case ThrowType.Potion:
168 flag = true;
169 if (Act.TC != null)
170 {
171 Act.TC.Say("throw_hit", t, Act.TC);
172 }
173 Act.TP.ModFire(-50, extinguish: true);
174 if (Act.TC != null && Act.TC.isChara)
175 {
176 if (t.trait.CanDrink(Act.TC.Chara))
177 {
179 }
180 flag2 = t.IsNegativeGift;
182 }
183 else
184 {
186 }
187 t.Die(null, null, AttackSource.Throw);
188 c.ModExp(108, 50);
189 break;
190 case ThrowType.Dice:
191 t.SetDir(EClass.rnd(6));
192 break;
193 case ThrowType.Snow:
194 flag = true;
195 flag2 = false;
196 if (Act.TC != null && Act.TC.isChara)
197 {
198 Act.TC.Say("throw_hit", t, Act.TC);
199 if (EClass.rnd(2) == 0)
200 {
201 c.Talk("snow_hit");
202 }
204 t.Die(null, null, AttackSource.Throw);
205 c.ModExp(108, 50);
206 }
207 break;
208 case ThrowType.Ball:
209 flag = true;
210 flag2 = false;
211 if (Act.TC != null && Act.TC.isChara)
212 {
213 Act.TC.Say("throw_hit", t, Act.TC);
214 if (EClass.rnd(2) == 0)
215 {
216 c.Talk("snow_hit");
217 }
218 Act.TC.Say("ball_hit");
219 Act.TC.Chara?.Pick(t);
220 c.ModExp(108, 50);
221 }
222 break;
223 case ThrowType.Flyer:
224 flag = true;
225 flag2 = false;
226 if (Act.TC != null && Act.TC.isChara && c.isChara)
227 {
228 Act.TC.Say("throw_hit", t, Act.TC);
229 c.Chara.GiveGift(Act.TC.Chara, t);
230 c.ModExp(108, 50);
231 }
232 break;
233 case ThrowType.MonsterBall:
234 {
235 flag = true;
236 flag2 = false;
237 TraitMonsterBall traitMonsterBall = t.trait as TraitMonsterBall;
238 if (traitMonsterBall.chara != null)
239 {
240 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))
241 {
242 break;
243 }
244 Chara _c = EClass._zone.AddCard(traitMonsterBall.chara, p).Chara;
245 if (_c.ai != null)
246 {
247 _c.ai.Cancel();
248 }
249 _c.enemy = null;
250 _c.PlayEffect("identify");
251 t.Die();
252 if (_c.IsMultisize)
253 {
254 _c.DestroyPath(_c.pos);
255 _c.ForeachPoint(delegate(Point p2, bool first)
256 {
257 foreach (Chara item in p2.ListCharas())
258 {
259 if (item != _c)
260 {
261 _c.Kick(p2, ignoreSelf: true, checkWall: false);
262 break;
263 }
264 }
265 });
266 }
267 if ((traitMonsterBall.IsSilvercatBall || _c.id == "cat_silver") && EClass._zone.id == "startVillage2")
268 {
269 _c.orgPos = c.pos.Copy();
270 _c.homeZone = EClass._zone;
271 Chara chara = _c;
272 Hostility c_originalHostility = (_c.hostility = Hostility.Friend);
273 chara.c_originalHostility = c_originalHostility;
275 _c.PlaySound("chime_angel");
276 }
277 else if (traitMonsterBall.IsDuponneBall && _c.id == "lurie_boss")
278 {
279 _c.orgPos = c.pos.Copy();
280 _c.homeZone = EClass._zone;
281 Chara chara2 = _c;
282 Hostility c_originalHostility = (_c.hostility = Hostility.Friend);
283 chara2.c_originalHostility = c_originalHostility;
285 _c.PlaySound("chime_angel");
286 }
287 else if (traitMonsterBall.IsLittleBall && _c.id == "littleOne")
288 {
289 _c.orgPos = c.pos.Copy();
290 Chara chara3 = _c;
291 Hostility c_originalHostility = (_c.hostility = Hostility.Neutral);
292 chara3.c_originalHostility = c_originalHostility;
294 _c.PlaySound("chime_angel");
295 EClass.core.actionsNextFrame.Add(delegate
296 {
297 _c.Talk("little_saved");
298 });
299 EClass.player.flags.little_saved = true;
301 }
302 else
303 {
304 _c.MakeAlly();
305 }
306 }
307 else
308 {
309 if (Act.TC == null || !Act.TC.isChara)
310 {
311 break;
312 }
313 Act.TC.Say("throw_hit", t, Act.TC);
314 Chara chara4 = Act.TC.Chara;
315 if (traitMonsterBall.IsSilvercatBall)
316 {
317 if (chara4.id != "cat_silver" || chara4.IsPCFactionOrMinion || EClass._zone.id == "startVillage2" || EClass._zone.IsUserZone || EClass._zone.Boss == chara4 || chara4.c_bossType != 0)
318 {
319 Msg.Say("monsterball_invalid");
320 break;
321 }
322 }
323 else if (traitMonsterBall.IsDuponneBall)
324 {
325 if (chara4.id != "lurie_boss" || chara4.IsPCFactionOrMinion || EClass._zone is Zone_Exile || EClass._zone.IsUserZone)
326 {
327 Msg.Say("monsterball_invalid");
328 break;
329 }
330 }
331 else if (traitMonsterBall.IsLittleBall)
332 {
333 if (chara4.id != "littleOne" || chara4.IsPCFactionOrMinion || EClass._zone is Zone_LittleGarden || EClass._zone.IsUserZone || chara4.GetBool(132))
334 {
335 Msg.Say("monsterball_invalid");
336 break;
337 }
338 chara4.SetBool(132, enable: true);
339 }
340 else
341 {
342 if (!chara4.trait.CanBeTamed || EClass._zone.IsUserZone)
343 {
344 Msg.Say("monsterball_invalid");
345 break;
346 }
347 if (chara4.LV > traitMonsterBall.owner.LV)
348 {
349 Msg.Say("monsterball_lv");
350 break;
351 }
352 if (!EClass.debug.enable && chara4.hp > chara4.MaxHP / 10)
353 {
354 Msg.Say("monsterball_hp");
355 break;
356 }
357 }
358 Msg.Say("monsterball_capture", c, chara4);
359 chara4.PlaySound("identify");
360 chara4.PlayEffect("identify");
361 t.ChangeMaterial("copper");
362 if (chara4.IsLocalChara)
363 {
364 Debug.Log("Creating Replacement NPC for:" + chara4);
366 }
367 traitMonsterBall.chara = chara4;
368 chara4.ReleaseMinion();
369 EClass._zone.RemoveCard(chara4);
370 chara4.homeZone = null;
371 c.ModExp(108, 100);
372 if (traitMonsterBall.IsDuponneBall && EClass.game.quests.GetPhase<QuestNegotiationDarkness>() == 3)
373 {
374 EClass._zone.SetBGM(120, refresh: true, 3f);
376 }
377 }
378 break;
379 }
380 }
381 if (t.trait is TraitDye)
382 {
384 }
385 if (!flag && Act.TC != null)
386 {
387 AttackProcess.Current.Prepare(c.Chara, t, Act.TC, Act.TP, 0, _isThrow: true);
388 if (method == ThrowMethod.Punish && t.rarity >= Rarity.Legendary)
389 {
390 AttackProcess.Current.critFury = true;
391 }
392 if (AttackProcess.Current.Perform(0, hasHit: false))
393 {
395 {
397 }
398 if (!t.isDestroyed && t.trait.CanBeDestroyed && !t.IsFurniture && !t.category.IsChildOf("instrument") && !t.IsUnique && !t.HasElement(410))
399 {
400 t.Destroy();
401 }
402 }
403 else
404 {
405 c.PlaySound("miss");
406 }
407 }
408 if (EClass.rnd(2) == 0)
409 {
410 c.Chara.RemoveCondition<ConInvisibility>();
411 c.Chara.RemoveCondition<ConDark>();
412 }
413 if (Act.TC != null)
414 {
415 if (flag2)
416 {
418 }
420 {
421 c.Chara.stamina.Mod(-1);
422 }
423 }
424 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)
425 {
427 {
428 target = Act.TC,
429 throwItem = t
430 });
431 }
432 return result;
433 }
434}
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:295
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:2399
bool isDestroyed
Definition: Card.cs:76
bool IsPCFactionOrMinion
Definition: Card.cs:2275
virtual MoveResult _Move(Point p, MoveType type=MoveType.Walk)
Definition: Card.cs:5868
virtual Chara Chara
Definition: Card.cs:2071
Thing Split(int a)
Definition: Card.cs:3513
string id
Definition: Card.cs:36
bool IsUnique
Definition: Card.cs:2092
bool IsRestrainedResident
Definition: Card.cs:2261
virtual void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Definition: Card.cs:5040
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6318
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3064
virtual void SetDir(int d)
Definition: Card.cs:6374
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6878
int hp
Definition: Card.cs:243
Rarity rarity
Definition: Card.cs:315
ICardParent parent
Definition: Card.cs:56
bool ExistsOnMap
Definition: Card.cs:2086
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
Definition: Card.cs:6000
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:8007
bool IsFurniture
Definition: Card.cs:2254
Point pos
Definition: Card.cs:60
virtual void LookAt(Card c)
Definition: Card.cs:6385
int uid
Definition: Card.cs:123
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6352
Trait trait
Definition: Card.cs:54
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2128
void Destroy()
Definition: Card.cs:5107
bool c_isImportant
Definition: Card.cs:1025
BossType c_bossType
Definition: Card.cs:1222
virtual bool isChara
Definition: Card.cs:2084
Card GetRootCard()
Definition: Card.cs:3455
void ModExp(string alias, int a)
Definition: Card.cs:2651
string c_idRefName
Definition: Card.cs:1642
SourceCategory.Row category
Definition: Card.cs:2050
CardRenderer renderer
Definition: Card.cs:62
void KillAnime()
Definition: Card.cs:6332
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6065
int LV
Definition: Card.cs:387
virtual bool isSynced
Definition: Card.cs:2088
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6995
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:505
AIAct ai
Definition: Chara.cs:204
Chara CreateReplacement()
Definition: Chara.cs:8034
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9269
override bool IsPC
Definition: Chara.cs:614
Chara host
Definition: Chara.cs:33
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1264
void ReleaseMinion()
Definition: Chara.cs:2396
AIAct SetAI(AIAct g)
Definition: Chara.cs:8899
ConTransmuteMimic mimicry
Definition: Chara.cs:106
void DestroyPath(Point pos)
Definition: Chara.cs:3184
override int MaxHP
Definition: Chara.cs:710
void MakeAlly(bool msg=true)
Definition: Chara.cs:2310
Stats stamina
Definition: Chara.cs:1160
bool IsLocalChara
Definition: Chara.cs:843
void GiveGift(Chara c, Thing t)
Definition: Chara.cs:8256
override bool IsMultisize
Definition: Chara.cs:708
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6352
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4328
void OnGiveErohon(Thing t)
Definition: Chara.cs:8378
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: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: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:929
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:1018
virtual bool CanBeDestroyed
Definition: Trait.cs:307
Card owner
Definition: Trait.cs:28
virtual void OnDrink(Chara c)
Definition: Trait.cs:1014
virtual bool CanDrink(Chara c)
Definition: Trait.cs:1009
virtual ThrowType ThrowType
Definition: Trait.cs:261
virtual bool CanOnlyCarry
Definition: Trait.cs:305
virtual bool IsUserZone
Definition: Zone.cs:271
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:2992
Chara Boss
Definition: Zone.cs:86
void RemoveCard(Card t)
Definition: Zone.cs:2032
void ModInfluence(int a)
Definition: Zone.cs:3647
Card AddCard(Card t, Point point)
Definition: Zone.cs:1992