Elin Decompiled Documentation EA 23.236 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 && !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 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.Dice:
187 t.SetDir(EClass.rnd(6));
188 break;
189 case ThrowType.Snow:
190 flag = true;
191 flag2 = false;
192 if (Act.TC != null && Act.TC.isChara)
193 {
194 Act.TC.Say("throw_hit", t, Act.TC);
195 if (EClass.rnd(2) == 0)
196 {
197 c.Talk("snow_hit");
198 }
200 t.Die(null, null, AttackSource.Throw);
201 c.ModExp(108, 50);
202 }
203 break;
204 case ThrowType.Ball:
205 flag = true;
206 flag2 = false;
207 if (Act.TC != null && Act.TC.isChara)
208 {
209 Act.TC.Say("throw_hit", t, Act.TC);
210 if (EClass.rnd(2) == 0)
211 {
212 c.Talk("snow_hit");
213 }
214 Act.TC.Say("ball_hit");
215 Act.TC.Chara?.Pick(t);
216 c.ModExp(108, 50);
217 }
218 break;
219 case ThrowType.Flyer:
220 flag = true;
221 flag2 = false;
222 if (Act.TC != null && Act.TC.isChara && c.isChara)
223 {
224 Act.TC.Say("throw_hit", t, Act.TC);
225 c.Chara.GiveGift(Act.TC.Chara, t);
226 c.ModExp(108, 50);
227 }
228 break;
229 case ThrowType.MonsterBall:
230 {
231 flag = true;
232 flag2 = false;
233 TraitMonsterBall traitMonsterBall = t.trait as TraitMonsterBall;
234 if (traitMonsterBall.chara != null)
235 {
236 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))
237 {
238 break;
239 }
240 Chara _c = EClass._zone.AddCard(traitMonsterBall.chara, p).Chara;
241 if (_c.ai != null)
242 {
243 _c.ai.Cancel();
244 }
245 _c.enemy = null;
246 _c.PlayEffect("identify");
247 t.Die();
248 if (_c.IsMultisize)
249 {
250 _c.DestroyPath(_c.pos);
251 _c.ForeachPoint(delegate(Point p2, bool first)
252 {
253 foreach (Chara item in p2.ListCharas())
254 {
255 if (item != _c)
256 {
257 _c.Kick(p2, ignoreSelf: true, checkWall: false);
258 break;
259 }
260 }
261 });
262 }
263 if ((traitMonsterBall.IsSilvercatBall || _c.id == "cat_silver") && EClass._zone.id == "startVillage2")
264 {
265 _c.orgPos = c.pos.Copy();
266 _c.homeZone = EClass._zone;
267 Chara chara = _c;
268 Hostility c_originalHostility = (_c.hostility = Hostility.Friend);
269 chara.c_originalHostility = c_originalHostility;
271 _c.PlaySound("chime_angel");
272 }
273 else if (traitMonsterBall.IsDuponneBall && _c.id == "lurie_boss")
274 {
275 _c.orgPos = c.pos.Copy();
276 _c.homeZone = EClass._zone;
277 Chara chara2 = _c;
278 Hostility c_originalHostility = (_c.hostility = Hostility.Friend);
279 chara2.c_originalHostility = c_originalHostility;
281 _c.PlaySound("chime_angel");
282 }
283 else if (traitMonsterBall.IsLittleBall && _c.id == "littleOne")
284 {
285 _c.orgPos = c.pos.Copy();
286 Chara chara3 = _c;
287 Hostility c_originalHostility = (_c.hostility = Hostility.Neutral);
288 chara3.c_originalHostility = c_originalHostility;
290 _c.PlaySound("chime_angel");
291 EClass.core.actionsNextFrame.Add(delegate
292 {
293 _c.Talk("little_saved");
294 });
295 EClass.player.flags.little_saved = true;
297 }
298 else
299 {
300 _c.MakeAlly();
301 }
302 }
303 else
304 {
305 if (Act.TC == null || !Act.TC.isChara)
306 {
307 break;
308 }
309 Act.TC.Say("throw_hit", t, Act.TC);
310 Chara chara4 = Act.TC.Chara;
311 if (traitMonsterBall.IsSilvercatBall)
312 {
313 if (chara4.id != "cat_silver" || chara4.IsPCFactionOrMinion || EClass._zone.id == "startVillage2" || EClass._zone.IsUserZone)
314 {
315 Msg.Say("monsterball_invalid");
316 break;
317 }
318 if (chara4.LV > 10)
319 {
320 Msg.Say("monsterball_lv");
321 break;
322 }
323 }
324 else if (traitMonsterBall.IsDuponneBall)
325 {
326 if (chara4.id != "lurie_boss" || chara4.IsPCFactionOrMinion || EClass._zone is Zone_Exile || EClass._zone.IsUserZone)
327 {
328 Msg.Say("monsterball_invalid");
329 break;
330 }
331 }
332 else if (traitMonsterBall.IsLittleBall)
333 {
334 if (chara4.id != "littleOne" || chara4.IsPCFactionOrMinion || EClass._zone is Zone_LittleGarden || EClass._zone.IsUserZone || chara4.GetBool(132))
335 {
336 Msg.Say("monsterball_invalid");
337 break;
338 }
339 chara4.SetBool(132, enable: true);
340 }
341 else
342 {
343 if (!chara4.trait.CanBeTamed || EClass._zone.IsUserZone)
344 {
345 Msg.Say("monsterball_invalid");
346 break;
347 }
348 if (chara4.LV > traitMonsterBall.owner.LV)
349 {
350 Msg.Say("monsterball_lv");
351 break;
352 }
353 if (!EClass.debug.enable && chara4.hp > chara4.MaxHP / 10)
354 {
355 Msg.Say("monsterball_hp");
356 break;
357 }
358 }
359 Msg.Say("monsterball_capture", c, chara4);
360 chara4.PlaySound("identify");
361 chara4.PlayEffect("identify");
362 t.ChangeMaterial("copper");
363 if (chara4.IsLocalChara)
364 {
365 Debug.Log("Creating Replacement NPC for:" + chara4);
367 }
368 traitMonsterBall.chara = chara4;
369 chara4.ReleaseMinion();
370 EClass._zone.RemoveCard(chara4);
371 chara4.homeZone = null;
372 c.ModExp(108, 100);
373 if (traitMonsterBall.IsDuponneBall && EClass.game.quests.GetPhase<QuestNegotiationDarkness>() == 3)
374 {
375 EClass._zone.SetBGM(120, refresh: true, 3f);
377 }
378 }
379 break;
380 }
381 }
382 if (t.trait is TraitDye)
383 {
385 }
386 if (!flag && Act.TC != null)
387 {
388 AttackProcess.Current.Prepare(c.Chara, t, Act.TC, Act.TP, 0, _isThrow: true);
389 if (method == ThrowMethod.Punish && t.rarity >= Rarity.Legendary)
390 {
391 AttackProcess.Current.critFury = true;
392 }
393 if (AttackProcess.Current.Perform(0, hasHit: false))
394 {
396 {
398 }
399 if (!t.isDestroyed && t.trait.CanBeDestroyed && !t.IsFurniture && !t.category.IsChildOf("instrument") && !t.IsUnique && !t.HasElement(410))
400 {
401 t.Destroy();
402 }
403 }
404 else
405 {
406 c.PlaySound("miss");
407 }
408 }
409 if (EClass.rnd(2) == 0)
410 {
411 c.Chara.RemoveCondition<ConInvisibility>();
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: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
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:2384
bool isDestroyed
Definition: Card.cs:75
bool IsPCFactionOrMinion
Definition: Card.cs:2260
virtual MoveResult _Move(Point p, MoveType type=MoveType.Walk)
Definition: Card.cs:5784
virtual Chara Chara
Definition: Card.cs:2058
Thing Split(int a)
Definition: Card.cs:3469
string id
Definition: Card.cs:35
bool IsUnique
Definition: Card.cs:2079
bool IsRestrainedResident
Definition: Card.cs:2246
virtual void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Definition: Card.cs:4984
bool HasElement(int ele, int req=1)
Definition: Card.cs:5881
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6113
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3026
virtual void SetDir(int d)
Definition: Card.cs:6169
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6668
int hp
Definition: Card.cs:242
Rarity rarity
Definition: Card.cs:314
ICardParent parent
Definition: Card.cs:55
bool ExistsOnMap
Definition: Card.cs:2073
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:7779
bool IsFurniture
Definition: Card.cs:2239
Point pos
Definition: Card.cs:59
virtual void LookAt(Card c)
Definition: Card.cs:6180
int uid
Definition: Card.cs:122
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6147
Trait trait
Definition: Card.cs:53
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2115
void Destroy()
Definition: Card.cs:5051
bool c_isImportant
Definition: Card.cs:1024
virtual bool isChara
Definition: Card.cs:2071
Card GetRootCard()
Definition: Card.cs:3411
void ModExp(string alias, int a)
Definition: Card.cs:2636
string c_idRefName
Definition: Card.cs:1641
SourceCategory.Row category
Definition: Card.cs:2037
CardRenderer renderer
Definition: Card.cs:61
void KillAnime()
Definition: Card.cs:6127
int LV
Definition: Card.cs:386
virtual bool isSynced
Definition: Card.cs:2075
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6765
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:503
AIAct ai
Definition: Chara.cs:202
Chara CreateReplacement()
Definition: Chara.cs:7897
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9132
override bool IsPC
Definition: Chara.cs:612
Chara host
Definition: Chara.cs:33
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1250
void ReleaseMinion()
Definition: Chara.cs:2351
AIAct SetAI(AIAct g)
Definition: Chara.cs:8762
void DestroyPath(Point pos)
Definition: Chara.cs:3160
override int MaxHP
Definition: Chara.cs:708
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
Definition: Chara.cs:5702
void MakeAlly(bool msg=true)
Definition: Chara.cs:2265
Stats stamina
Definition: Chara.cs:1146
bool IsLocalChara
Definition: Chara.cs:841
void GiveGift(Chara c, Thing t)
Definition: Chara.cs:8119
override bool IsMultisize
Definition: Chara.cs:706
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6266
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4253
void OnGiveErohon(Thing t)
Definition: Chara.cs:8241
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: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
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:275
QuestManager quests
Definition: Game.cs:182
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
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:531
virtual bool CanBeTamed
Definition: TraitChara.cs:102
virtual bool IsSilvercatBall
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:995
virtual bool CanBeDestroyed
Definition: Trait.cs:294
Card owner
Definition: Trait.cs:27
virtual void OnDrink(Chara c)
Definition: Trait.cs:991
virtual bool CanDrink(Chara c)
Definition: Trait.cs:986
virtual ThrowType ThrowType
Definition: Trait.cs:248
virtual bool CanOnlyCarry
Definition: Trait.cs:292
virtual bool IsUserZone
Definition: Zone.cs:268
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:2923
void RemoveCard(Card t)
Definition: Zone.cs:1999
void ModInfluence(int a)
Definition: Zone.cs:3578
Card AddCard(Card t, Point point)
Definition: Zone.cs:1959