Elin Decompiled Documentation EA 23.307 Stable
Loading...
Searching...
No Matches
ConTransmuteHuman.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using Newtonsoft.Json;
4using UnityEngine;
5
7{
8 [JsonProperty]
9 public Chara chara;
10
11 [JsonProperty]
12 public int lastHP;
13
14 public override Card Card => chara;
15
16 public bool IsBaby => chara.HasElement(1232);
17
18 public bool IsNyaru => owner.HasElement(1429);
19
20 public override bool HasDuration => false;
21
22 public override bool ShouldRevealOnContact => false;
23
24 public override bool ShouldRevealOnPush => false;
25
26 public override bool ShouldRevealOnDamage
27 {
28 get
29 {
30 if (!IsNyaru)
31 {
32 return (float)EClass.rnd(50) > (float)owner.hp / (float)owner.MaxHP * 100f;
33 }
34 return false;
35 }
36 }
37
38 public override bool ShouldEndMimicry(Act act)
39 {
40 return false;
41 }
42
44 {
45 if (chara.IsPCC)
46 {
48 }
50 }
51
52 public override void OnBeforeStart()
53 {
54 if (chara == null)
55 {
56 if (IsNyaru)
57 {
59 }
60 else
61 {
62 List<Thing> list = owner.things.List((Thing t) => t.trait is TraitFigure { source: not null } traitFigure && !traitFigure.source.multisize, onlyAccessible: true);
63 if (list.Count > 0)
64 {
65 chara = CharaGen.Create((list.RandomItem().trait as TraitFigure).source.id);
66 }
67 else
68 {
69 List<Chara> list2 = owner.pos.ListCharasInRadius(owner, 6, (Chara c) => !c.IsMultisize && c.IsHumanSpeak && !c.HasElement(1427));
70 if (list2.Count > 0)
71 {
72 chara = list2.RandomItem().Duplicate();
73 }
74 else
75 {
76 chara = CharaGen.CreateFromFilter("c_guest");
77 }
78 }
79 }
80 }
81 base.OnBeforeStart();
82 }
83
84 public void NyaruSpecial()
85 {
86 if (chara != null && chara.id != owner.id)
87 {
88 chara = owner;
89 }
90 else
91 {
92 IEnumerable<SourceChara.Row> ie = EClass.sources.charas.rows.Where((SourceChara.Row a) => !a.multisize && !a.actCombat.IsEmpty() && !a.HasTag(CTAG.suicide) && !a.HasTag(CTAG.noRandomProduct));
93 chara = CharaGen.Create(ie.RandomItem().id);
94 }
95 lastHP = owner.hp;
96 owner.PlayEffect("morph");
97 owner.PlaySound("vanish");
98 }
99
100 public override void Tick()
101 {
102 if (IsNyaru && Mathf.Abs(owner.hp - lastHP) >= owner.MaxHP / 10)
103 {
104 NyaruSpecial();
105 Change();
106 }
107 base.Tick();
108 }
109}
CTAG
Definition: CTAG.cs:2
Definition: ACT.cs:62
Definition: Card.cs:11
string id
Definition: Card.cs:36
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6472
int hp
Definition: Card.cs:245
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6506
Trait trait
Definition: Card.cs:54
ThingContainer things
Definition: Card.cs:39
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6214
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
Definition: CharaGen.cs:22
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
bool IsHumanSpeak
Definition: Chara.cs:1029
Chara Duplicate()
Definition: Chara.cs:1817
override int MaxHP
Definition: Chara.cs:722
override bool IsMultisize
Definition: Chara.cs:720
PCCData pccData
Definition: Chara.cs:67
override bool IsPCC
Definition: Chara.cs:696
override bool ShouldRevealOnDamage
override RendererReplacer GetRendererReplacer()
override bool ShouldRevealOnContact
override void OnBeforeStart()
override void Tick()
override bool HasDuration
override bool ShouldRevealOnPush
override bool ShouldEndMimicry(Act act)
void Change()
Definition: ConTransmute.cs:36
Definition: EClass.cs:6
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
List< Chara > ListCharasInRadius(Chara cc, int dist, Func< Chara, bool > func, bool onlyVisible=true)
Definition: Point.cs:1221
bool multisize
Definition: RenderRow.cs:64
static RendererReplacer CreateFromPCC(string id, PCCData pccData)
static RendererReplacer CreateFrom(string id, int shift=0, int mat=-1)
SourceChara charas
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
Definition: Thing.cs:8
CardRow source
Definition: TraitFigure.cs:10