-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightstorm.chai
90 lines (80 loc) · 1.57 KB
/
lightstorm.chai
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
/*
A new spell lightning storm that replaces regular firestorm.
Made by MrKosjaK
*/
class LightningStorm
{
def LightningStorm(_center, _owner, _tick)
{
this.center = _center;
this.owner = _owner;
this.tick = gsi.Counts.GameTurn+_tick
this.amount = 25 + G_RANDOM(55);
}
def processIt()
{
if (gsi.Counts.GameTurn > this.tick)
{
this.tick = gsi.Counts.GameTurn+6;
--this.amount;
var c3d = this.center;
c3d.Xpos += 512 * G_RANDOM(4) * randSign();
c3d.Zpos += 512 * G_RANDOM(4) * randSign();
var light = createThing(T_EFFECT, M_EFFECT_LIGHTNING_BOLT, this.owner, c3d, false, false);
}
}
def check()
{
return this.amount;
}
var amount;
var tick;
var owner;
var center;
}
global storms = Vector();
global index = 0;
def OnCreateThing(Thing t)
{
/*Store lightning's bolt Coord3D position and remove thing itself*/
if (t.Type == T_EFFECT && t.Model == M_EFFECT_FIRESTORM && t.Pos.D3.Ypos != 2048)
{
storms.push_back(LightningStorm(t.Pos.D3, t.Owner, 6));
DestroyThing(t);
}
}
def randSign()
{
var sign = -1;
if (G_RANDOM(2) == 0)
{
sign = 1;
}
return sign;
}
def process(n)
{
for (var i = 0; i < n; ++i)
{
if (index < storms.size())
{
if (storms[index].check() > 0)
{
storms[index].processIt();
}
else
{
storms.erase_at(index);
}
++index;
}
else
{
index = 0;
}
}
}
def OnTurn()
{
process(12);
}