-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrowTrees.chai
More file actions
66 lines (59 loc) · 1.38 KB
/
Copy pathGrowTrees.chai
File metadata and controls
66 lines (59 loc) · 1.38 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
def find_random_land_pos_c2d() // Not guaranteed to find land.
{
var give_up = MAX_NUM_SEARCHES;
var c2d = Coord2D();
c2d.Xpos = G_RANDOM(65535);
c2d.Zpos = G_RANDOM(65535);
while (give_up > 0 && (c2d.Xpos > 0 || c2d.Zpos > 0))
{
if (is_map_point_land(c2d) == TRUE)
{
break;
}
if (c2d.Xpos > 0)
{
--c2d.Xpos;
}
if (c2d.Zpos > 0)
{
--c2d.Zpos;
}
--give_up;
}
return c2d;
}
def spawn_thing_at_random_pos()
{
var c2d = find_random_land_pos_c2d();
var c3d = Coord3D();
coord2D_to_coord3D(c2d, c3d);
CREATE_THING_WITH_PARAMS4(T_SCENERY,M_SCENERY_DORMANT_TREE,TRIBE_HOSTBOT,c3d,T_SCENERY,G_RANDOM(6),16,16);
}
// def DebugTrees(Thing)
// {
// if (Thing.State == S_SCENERY_DORMANT_TREE)
// {
// log("This epic tree is in this state: " + Thing.ThingNum.to_string() + " State: " + Thing.State.to_string() + " Model: " + Thing.Model.to_string());
// }
// else
// {
// log("This epic tree is not dormant hehe: " + Thing.ThingNum.to_string() + " State: " + Thing.State.to_string() + " Model: " + Thing.Model.to_string());
// }
// return true;
// }
// Scripts entry point
def OnTurn()
{
/* if (EVERY_2POW_TURNS(4))
{
ProcessGlobalTypeList(T_SCENERY, DebugTrees);
} */
if (EVERY_2POW_TURNS(2))
{
var chance = G_RANDOM(1000);
if (chance >= 995)
{
spawn_thing_at_random_pos();
}
}
}