1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
#strict 2
#include SN7I
local color, controllingCard;
func Init()
{
SetColor(HSL(Random(255), 255, 127));
var card = CreateContents(KC7I);
card->AddReader(this);
Collection2(card);
}
func SetColor(int newColor)
{
color = newColor;
SetColorDw(color);
}
func GetColor() { return color; }
func OnOwnerChanged()
{
SetColorDw(color);
}
func Triggers() { return [["$RightCard$"], ["$WrongCard$"]];}
func ControlThrow(object caller)
{
var card, success;
if(card = FindCard(caller, success))
{
if(!controllingCard)
{
ShowSuccess(success);
Trigger(!success, caller);
}
else
{
PlayerMessage(GetController(caller), "$CardLoaded$", this);
}
}
else if(controllingCard)
{
GetCard(0, caller);
}
return ClearCom(caller);
}
func ControlThrowDouble() { return ControlThrow(...); }
func ShowSuccess(bool success)
{
if(!success)
{
Sound("Error");
CreateParticle("PSpark", -5, -1, 0, 0, 50, RGB(192, 0, 0));
}
else
{
CreateParticle("PSpark", -5, -1, 0, 0, 50, RGB(0, 192, 0));
}
}
func Setup(object caller, int& menuIndex)
{
if(controllingCard && Contained(controllingCard) == this)
{
AddMenuItem("$GetCard$", "GetCard", KC7I, caller, 0, caller, 0, C4MN_Add_ForceNoDesc | C4MN_Add_ImgObject, controllingCard);
++menuIndex;
var success, card = FindCard(caller, success);
if(card && !card->HasReader(this))
{
selectCaller = caller;
AddMenuItem("$AddReader$", "AddReader", KC7I, caller, 0, card, 0, C4MN_Add_ForceNoDesc | C4MN_Add_ImgObject, card);
++menuIndex;
}
if(ObjectCount2(Find_ID(KC7I), Find_Func("HasReader", this), Find_Exclude(controllingCard)))
{
AddMenuItem("$RemoveReader$", "RemoveReader", KC7I, caller, 0, caller, 0, C4MN_Add_ForceNoDesc | C4MN_Add_ImgObject, controllingCard);
++menuIndex;
}
}
else
{
var success;
FindCard(caller, success);
if(success)
{
AddMenuItem("$LoadCard$", "LoadCard", KC7I, caller, 0, caller, 0, C4MN_Add_ForceNoDesc | C4MN_Add_ImgColor, RGB(255, 255, 255));
++menuIndex;
}
}
return true;
}
func GetCard(id id, object caller)
{
if(controllingCard)
{
Exit(controllingCard);
caller->Collect(controllingCard);
}
}
func LoadCard(id id, object caller)
{
var success;
var card = FindCard(caller, success);
if(success)
{
Enter(this, card);
}
_Setup(caller);
SelectMenuItem(2, caller);
}
func AddReader(id id, object card)
{
card->AddReader(this);
}
func RemoveReader(id id, object caller)
{
if(controllingCard)
{
controllingCard->RemoveReader(this);
GetCard(id, caller);
}
}
func FindCard(object container, bool& success)
{
var card;
success = false;
for(var i = 0; i < ContentsCount(0, container); ++i)
{
var content = Contents(i, container);
if(GetID(content) == KC7I)
{
if(content->HasReader(this))
{
card = content;
success = true;
break;
}
else if(!card)
{
card = content;
}
}
}
return card;
}
func Collection2(object obj)
{
if(!controllingCard && obj->GetID() == KC7I && obj->HasReader(this))
{
controllingCard = obj;
SetGraphics("Card", this, GetID(), GFX_Overlay, GFXOV_MODE_Base);
SetClrModulation(obj->GetColor(), this, GFX_Overlay);
}
}
func ContentsDestruction(object obj) { return Ejection(obj); }
func Ejection(object obj)
{
if(obj == controllingCard)
{
SetGraphics(0, this, 0, GFX_Overlay);
controllingCard = 0;
}
}
func SetupCondition(object caller)
{
if(controllingCard)
{
return true;
}
var success;
FindCard(caller, success);
return success;
}
func CalcDefValue()
{
return Value(GetID()) + GetValue(0, KC7I);
}
|