Elin Decompiled Documentation EA 23.345.1 Nightly
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 Chara chara = (c.IsPC ? c : EClass.pc);
63 int num = (EClass.debug.enable ? 10 : (c.IsPCFactionOrMinion ? chara.Evalue(1656) : 0));
64 if (!IsLaidByDog && num > 0 && num + 2 > EClass.rnd(10))
65 {
66 string id = "scrap";
67 int idMat = -1;
68 int lv = num * 5 + chara.Evalue(293) / 4 + chara.Evalue(210) / 4;
69 if (EClass.rnd(3) == 0)
70 {
71 id = "junk";
72 }
73 if (EClass.rnd(4) == 0)
74 {
75 id = "microchip";
76 }
77 if (EClass.rnd(20) == 0)
78 {
79 id = "medal";
80 }
81 if (EClass.rnd(30) == 0)
82 {
83 id = "ic";
84 }
85 if (EClass.rnd(4) == 0)
86 {
87 id = "ingot";
88 idMat = MATERIAL.GetRandomMaterial(lv, "metal").id;
89 }
90 if (EClass.rnd(4) == 0)
91 {
92 id = "texture";
93 idMat = MATERIAL.GetRandomMaterial(lv, "leather").id;
94 }
95 Thing thing = ThingGen.Create(id, idMat, lv);
96 thing.isHidden = false;
97 chara.Say("scavenge", owner, thing);
98 EClass._map.TrySmoothPick(owner.pos, thing, chara);
99 }
100 owner.Destroy();
101 return true;
102 }
103 c.Say("disarm_fail", c, owner);
104 c.PlaySound("disarm_fail");
105 c.ModExp(293, 20 + TrapLv / 3);
106 if (c.IsPCParty)
107 {
108 int num2 = owner.GetInt(60);
109 owner.SetInt(60, num2 + 1);
110 }
111 if (IsJammed)
112 {
113 c.Say("trapJammed", owner);
114 c.PlaySound("electricity_insufficient");
115 }
116 return false;
117 }
118
119 public void ActivateTrap(Chara c)
120 {
121 if (IsJammed)
122 {
123 c.Say("trapJammed2", owner);
124 return;
125 }
126 haltMove = true;
128 if (c.IsPC && haltMove)
129 {
130 EClass.player.haltMove = true;
131 }
132 }
133
134 public virtual void OnActivateTrap(Chara c)
135 {
136 }
137}
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
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6645
void SetInt(string id, int value=0)
Definition: Card.cs:2586
Point pos
Definition: Card.cs:60
int DEX
Definition: Card.cs:2405
void Destroy()
Definition: Card.cs:5314
Card SetHidden(bool hide=true)
Definition: Card.cs:6151
int Evalue(int ele)
Definition: Card.cs:2704
void ModExp(string alias, int a)
Definition: Card.cs:2781
int GetInt(string id, int? defaultInt=null)
Definition: Card.cs:2567
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7323
Definition: Chara.cs:10
override bool IsPC
Definition: Chara.cs:630
override bool IsPCParty
Definition: Chara.cs:633
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:1944
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:134
override void OnInstall(bool byPlayer)
Definition: TraitSwitch.cs:24
virtual bool IgnoreWhenLevitating()
Definition: TraitSwitch.cs:19
void ActivateTrap(Chara c)
Definition: TraitSwitch.cs:119
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:115
bool IsPCFaction
Definition: Zone.cs:480