Elin Decompiled Documentation EA 23.287 Stable
Loading...
Searching...
No Matches
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 : (c.IsPCFactionOrMinion ? EClass.pc.Evalue(1656) : 0));
63 if (!IsLaidByDog && num > 0 && num + 2 > EClass.rnd(10))
64 {
65 string id = "scrap";
66 int idMat = -1;
67 int lv = num * 5 + EClass.pc.Evalue(293) / 4 + EClass.pc.Evalue(210) / 4;
68 if (EClass.rnd(3) == 0)
69 {
70 id = "junk";
71 }
72 if (EClass.rnd(4) == 0)
73 {
74 id = "microchip";
75 }
76 if (EClass.rnd(20) == 0)
77 {
78 id = "medal";
79 }
80 if (EClass.rnd(30) == 0)
81 {
82 id = "ic";
83 }
84 if (EClass.rnd(4) == 0)
85 {
86 id = "ingot";
87 idMat = MATERIAL.GetRandomMaterial(lv, "metal").id;
88 }
89 if (EClass.rnd(4) == 0)
90 {
91 id = "texture";
92 idMat = MATERIAL.GetRandomMaterial(lv, "leather").id;
93 }
94 Thing thing = ThingGen.Create(id, idMat, lv);
95 thing.isHidden = false;
96 EClass.pc.Say("scavenge", owner, thing);
98 }
99 owner.Destroy();
100 return true;
101 }
102 c.Say("disarm_fail", c, owner);
103 c.PlaySound("disarm_fail");
104 c.ModExp(293, 20 + TrapLv / 3);
105 if (c.IsPCParty)
106 {
107 int @int = owner.GetInt(60);
108 owner.SetInt(60, @int + 1);
109 }
110 if (IsJammed)
111 {
112 c.Say("trapJammed", owner);
113 c.PlaySound("electricity_insufficient");
114 }
115 return false;
116 }
117
118 public void ActivateTrap(Chara c)
119 {
120 if (IsJammed)
121 {
122 c.Say("trapJammed2", owner);
123 return;
124 }
125 haltMove = true;
127 if (c.IsPC && haltMove)
128 {
129 EClass.player.haltMove = true;
130 }
131 }
132
133 public virtual void OnActivateTrap(Chara c)
134 {
135 }
136}
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:372
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6375
Point pos
Definition: Card.cs:60
int DEX
Definition: Card.cs:2375
void Destroy()
Definition: Card.cs:5164
Card SetHidden(bool hide=true)
Definition: Card.cs:5918
int Evalue(int ele)
Definition: Card.cs:2611
void ModExp(string alias, int a)
Definition: Card.cs:2688
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7052
Definition: Chara.cs:10
override bool IsPC
Definition: Chara.cs:626
override bool IsPCParty
Definition: Chara.cs:629
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:21
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static Chara pc
Definition: EClass.cs:15
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
Definition: MATERIAL.cs:56
void TrySmoothPick(Cell cell, Thing t, Chara c)
Definition: Map.cs:1804
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:133
override void OnInstall(bool byPlayer)
Definition: TraitSwitch.cs:24
virtual bool IgnoreWhenLevitating()
Definition: TraitSwitch.cs:19
void ActivateTrap(Chara c)
Definition: TraitSwitch.cs:118
virtual bool CanDisarmTrap
Definition: TraitSwitch.cs:7
virtual bool IsJammed
Definition: TraitSwitch.cs:15
Definition: Trait.cs:7
Card owner
Definition: Trait.cs:28
override int DangerLv
Definition: Zone.cs:110
bool IsPCFaction
Definition: Zone.cs:475