Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
TraitSwitch.cs
Go to the documentation of this file.
1public class TraitSwitch : Trait
2{
3 public static bool haltMove;
4
5 public int TrapLv => EClass._zone.DangerLv;
6
7 public virtual bool CanDisarmTrap => false;
8
9 public virtual bool CanManucalActivate => false;
10
11 public virtual bool StartHidden => false;
12
13 public virtual bool IsNegativeEffect => false;
14
15 public virtual bool IsJammed => owner.GetInt(60) >= 3;
16
17 public virtual bool IsLaidByDog => owner.c_idRefCard == "dog_mine";
18
19 public virtual bool IgnoreWhenLevitating()
20 {
21 return false;
22 }
23
24 public override void OnInstall(bool byPlayer)
25 {
26 if (byPlayer && StartHidden)
27 {
29 }
30 }
31
32 public override void TrySetAct(ActPlan p)
33 {
35 {
36 p.TrySetAct("actDisarm", delegate
37 {
38 if (!TryDisarmTrap(EClass.pc) && EClass.pc.Evalue(1656) < 3 && EClass.rnd(2) == 0)
39 {
40 ActivateTrap(EClass.pc);
41 }
42 return true;
43 }, owner);
44 }
45 else if (CanManucalActivate)
46 {
47 p.TrySetAct("actUse", delegate
48 {
50 return true;
51 }, owner);
52 }
53 }
54
55 public bool TryDisarmTrap(Chara c)
56 {
57 if (EClass.rnd(c.Evalue(293) * 15 + 20 + c.DEX) > EClass.rnd(TrapLv * 12 + 100))
58 {
59 c.Say("disarm_success", c, owner);
60 owner.PlaySound("disarm");
61 c.ModExp(293, 50 + TrapLv);
62 int num = (EClass.debug.enable ? 10 : EClass.pc.Evalue(1656));
63 if (!c.IsPCParty)
64 {
65 num = 0;
66 }
67 if (!IsLaidByDog && num > 0 && num + 2 > EClass.rnd(10))
68 {
69 string id = "scrap";
70 int idMat = -1;
71 int lv = num * 5 + EClass.pc.Evalue(293) / 4 + EClass.pc.Evalue(210) / 4;
72 if (EClass.rnd(3) == 0)
73 {
74 id = "junk";
75 }
76 if (EClass.rnd(4) == 0)
77 {
78 id = "microchip";
79 }
80 if (EClass.rnd(20) == 0)
81 {
82 id = "medal";
83 }
84 if (EClass.rnd(30) == 0)
85 {
86 id = "ic";
87 }
88 if (EClass.rnd(4) == 0)
89 {
90 id = "ingot";
91 idMat = MATERIAL.GetRandomMaterial(lv, "metal").id;
92 }
93 if (EClass.rnd(4) == 0)
94 {
95 id = "texture";
96 idMat = MATERIAL.GetRandomMaterial(lv, "leather").id;
97 }
98 Thing thing = ThingGen.Create(id, idMat, lv);
99 thing.isHidden = false;
100 EClass.pc.Say("scavenge", owner, thing);
102 }
103 owner.Destroy();
104 return true;
105 }
106 c.Say("disarm_fail", c, owner);
107 c.PlaySound("disarm_fail");
108 c.ModExp(293, 20 + TrapLv / 3);
109 if (c.IsPCFaction)
110 {
111 int @int = owner.GetInt(60);
112 owner.SetInt(60, @int + 1);
113 }
114 if (IsJammed)
115 {
116 c.Say("trapJammed", owner);
117 c.PlaySound("electricity_insufficient");
118 }
119 return false;
120 }
121
122 public void ActivateTrap(Chara c)
123 {
124 if (IsJammed)
125 {
126 c.Say("trapJammed2", owner);
127 return;
128 }
129 haltMove = true;
131 if (c.IsPC && haltMove)
132 {
133 EClass.player.haltMove = true;
134 }
135 }
136
137 public virtual void OnActivateTrap(Chara c)
138 {
139 }
140}
bool TrySetAct(string lang, Func< bool > onPerform, Card tc, CursorInfo cursor=null, int dist=1, bool isHostileAct=false, bool localAct=true, bool canRepeat=false)
Definition: ActPlan.cs:344
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
void SetHidden(bool hide=true)
Definition: Card.cs:5111
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Point pos
Definition: Card.cs:55
int DEX
Definition: Card.cs:2195
void Destroy()
Definition: Card.cs:4538
int Evalue(int ele)
Definition: Card.cs:2431
void ModExp(string alias, int a)
Definition: Card.cs:2508
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Definition: Chara.cs:10
override bool IsPC
Definition: Chara.cs:597
override bool IsPCParty
Definition: Chara.cs:600
override bool IsPCFaction
Definition: Chara.cs:656
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
Definition: MATERIAL.cs:43
void TrySmoothPick(Cell cell, Thing t, Chara c)
Definition: Map.cs:1791
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
override void TrySetAct(ActPlan p)
Definition: TraitSwitch.cs:32
virtual bool IsLaidByDog
Definition: TraitSwitch.cs:17
virtual bool StartHidden
Definition: TraitSwitch.cs:11
bool TryDisarmTrap(Chara c)
Definition: TraitSwitch.cs:55
virtual bool CanManucalActivate
Definition: TraitSwitch.cs:9
virtual bool IsNegativeEffect
Definition: TraitSwitch.cs:13
static bool haltMove
Definition: TraitSwitch.cs:3
virtual void OnActivateTrap(Chara c)
Definition: TraitSwitch.cs:137
override void OnInstall(bool byPlayer)
Definition: TraitSwitch.cs:24
virtual bool IgnoreWhenLevitating()
Definition: TraitSwitch.cs:19
void ActivateTrap(Chara c)
Definition: TraitSwitch.cs:122
virtual bool CanDisarmTrap
Definition: TraitSwitch.cs:7
virtual bool IsJammed
Definition: TraitSwitch.cs:15
Definition: Trait.cs:7
Card owner
Definition: Trait.cs:26
override int DangerLv
Definition: Zone.cs:107
bool IsPCFaction
Definition: Zone.cs:464