-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgas.chai
More file actions
180 lines (161 loc) · 3.53 KB
/
Copy pathgas.chai
File metadata and controls
180 lines (161 loc) · 3.53 KB
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
class Gas
{
var gas_thing;
var gas_type;
var gas_dmg;
def Gas(_gas_thing, _gas_type, _gas_dmg)
{
this.gas_thing = _gas_thing;
this.gas_type = _gas_type;
this.gas_dmg = _gas_dmg;
}
def gas_sign()
{
var random_sign = -1;
if (G_RANDOM(2) == 0)
{
random_sign = 1;
}
return random_sign;
}
def gas_find_spot_near(_crd)
{
var crd = _crd;
crd.Xpos += (G_RANDOM(3)+1 * 512) * this.gas_sign();
crd.Zpos += (G_RANDOM(3)+1 * 512) * this.gas_sign();
centre_coord3d_on_block(crd);
return crd;
}
def gas_move()
{
var gas = this.gas_thing.get();
move_thing_within_mapwho(gas, this.gas_find_spot_near(gas.Pos.D3));
}
def gas_random_teleport()
{
var crdd = Coord3D();
crdd.Xpos = G_RANDOM(65536);
crdd.Zpos = G_RANDOM(65536);
crdd.Ypos = G_RANDOM(1024);
centre_coord3d_on_block(crdd);
return crdd;
}
def gas_process_ender()
{
var mw;
mw := world_coord3d_to_map_ptr(this.gas_thing.get().Pos.D3);
if (!mw.MapWhoList.isEmpty())
{
mw.MapWhoList.processList(fun[this](Thing)
{
if (Thing.Type == T_PERSON)
{
if (Thing.Model > 1 && Thing.Model < 8 && is_thing_on_ground(Thing) == 1)
{
move_thing_within_mapwho(Thing, this.gas_random_teleport());
return true;
}
}
return true;
});
}
}
def gas_process_toxic(_dmg)
{
var mw;
mw := world_coord3d_to_map_ptr(this.gas_thing.get().Pos.D3);
if (!mw.MapWhoList.isEmpty())
{
mw.MapWhoList.processList(fun[this, _dmg](Thing)
{
if (Thing.Type == T_PERSON)
{
if (Thing.Model > 1 && Thing.Model < 8 && is_thing_on_ground(Thing) == 1)
{
damage_person(Thing, TRIBE_HOSTBOT, _dmg, TRUE);
return true;
}
}
return true;
});
}
}
def gas_process_heal()
{
var mw;
mw := world_coord3d_to_map_ptr(this.gas_thing.get().Pos.D3);
if (!mw.MapWhoList.isEmpty())
{
mw.MapWhoList.processList(fun[this](Thing)
{
if (Thing.Type == T_PERSON)
{
if (Thing.Model > 1 && Thing.Model < 8 && is_thing_on_ground(Thing) == 1)
{
if (Thing.u.Pers.Life < Thing.u.Pers.MaxLife)
{
Thing.u.Pers.Life += 256;
return true;
}
}
}
return true;
});
}
}
def gas_process()
{
if (!this.gas_thing.isNull())
{
if (this.gas_type == 2){
this.gas_process_ender();
}else if (this.gas_type == -2){
this.gas_process_toxic(this.gas_dmg*10);
}else if (this.gas_type == -1){
this.gas_process_toxic(this.gas_dmg*2);
}else if (this.gas_type == 1){
this.gas_process_heal();
}
this.gas_move();
ensure_thing_on_ground(this.gas_thing.get());
}
}
}
global gases = Vector();
global gases_amount = 64;
global gases_int = 0;
global colour = [2,-2,-1,1];
def generate_rpos()
{
var c3d = Coord3D();
c3d.Xpos = G_RANDOM(65536);
c3d.Zpos = G_RANDOM(65536);
return c3d;
}
def generate_gas()
{
for (var i = gases_amount; i > 0; --i)
{
if (gases.size() < gases_amount)
{
var gas = createThing(T_EFFECT, M_EFFECT_SWAMP_MIST, TRIBE_HOSTBOT, generate_rpos(), false, false);
gas.DrawInfo.Alpha = colour[G_RANDOM(colour.size())];
gases.push_back(Gas(ObjectProxy(gas.ThingNum), gas.DrawInfo.Alpha, 100));
}
}
}
generate_gas();
def OnTurn()
{
if (gases_int < gases.size())
{
gases[gases_int].gas_process();
++gases_int;
gases[gases_int].gas_process();
++gases_int;
}
else
{
gases_int = 0;
}
}