-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.gsc
executable file
·106 lines (87 loc) · 2.43 KB
/
stats.gsc
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
/* more like player_stats.gsc */
statsEventAdd(name, func)
{
if (!isDefined(level.statsEvents))
level.statsEvents = [];
if (!isDefined(level.statsEvents[name]))
level.statsEvents[name] = [];
size = level.statsEvents[name].size;
level.statsEvents[name][size] = func;
}
statsEventAddEver(name, func)
{
if (!isDefined(level.statsEventsEver))
level.statsEventsEver = [];
if (!isDefined(level.statsEventsEver[name]))
level.statsEventsEver[name] = [];
size = level.statsEventsEver[name].size;
level.statsEventsEver[name][size] = func;
// add the ever-events also to the normal events
statsEventAdd(name, func);
}
add(name, value)
{
player = self;
if (!isDefined(player.stats))
player.stats = [];
if (!isDefined(player.stats[name]))
player.stats[name] = 0;
/*
trueThenFalse = 1;
while (trueThenFalse) { // do while (0) = SIMULATE GOTO (oups, no do-while in CODscript)
trueThenFalse--; // no auto-decrement in while()
*/
failed = false;
// events for actions
if (isDefined(level.statsEvents))
{
if (isDefined(level.statsEvents[name]))
{
funcs = level.statsEvents[name];
for (i=0; i<funcs.size; i++)
{
ret = player [[funcs[i]]](name, value); // MAYBE i could use "name" in callback sometime
if (ret == false)
{
//std\io::print("event " + name + " failed!\n");
// FUCK, if i already break at persistence-event, the hud shows bullshit
// i just want the default-action then AND the hud-update event!
// so i invented the "ever"-version of this
//break; // SIMULATE GOTO
failed = true;
break; // go to the "return"
}
}
// if failed is not defined, every event went good.
// so we dont need the default-action nor the ever-events
if (!failed)
return; // dont do the default-action anymore
}
}
/*
}
*/
// default action, non-persistent
player.stats[name] += value;
// events for actions that ever happen
// if persistence-money fails, then still update the hud with non-persistent values!
if (isDefined(level.statsEventsEver))
{
if (isDefined(level.statsEventsEver[name]))
{
funcs = level.statsEventsEver[name];
for (i=0; i<funcs.size; i++)
player [[funcs[i]]](name, value); // MAYBE i could use "name" in callback sometime
}
}
}
giveDebugStats()
{
player = self;
while (isDefined(player))
{
player std\stats::add("money", 10);
player std\stats::add("xp", 10);
wait 10;
}
}