#define Grasarea skill1
#define Grasdist skill2
ENTITY* terr;
var colormap_size_x;
var colormap_size_y;
STRING* str_Gras1 = "gras1.mdl";
STRING* str_Gras2 = "gras2.mdl";
STRING* str_Colormap = "Colormap.tga";
BMAP* bmap_Vegetation;
function Erzeuge_Gras();
function Colormap();
function Setze_Gras();
action multi_terrain()
{
if (my.Grasarea == 0) {my.Grasarea = 500;}
if (my.Grasdist == 0) {my.Grasdist = 70;}
terr = my;
my.material = multirgb;
}
function Erzeuge_Gras()
{
var grass_id = 1;
VECTOR grascoords, grasposition;
ent_create (str_Colormap, nullvector, Colormap);
while ((player == NULL) || (terr == NULL) || (bmap_Vegetation == NULL)) {wait (1);}
grasposition.x = player.x - terr.Grasarea; // set the initial position of the grass models
grasposition.y = player.y - terr.Grasarea; // surround the player with the grass models
grasposition.z = terr.max_z + 400; // and place them up high in the sky
grascoords.x = grasposition.x;
grascoords.y = grasposition.y;
while (grascoords.x < player.x + terr.Grasarea)
{
grasposition.y = grascoords.y + (random(0.2 * terr.Grasdist) - 0.4 * terr.Grasdist);
grasposition.x = grascoords.x + (random(0.2 * terr.Grasdist) - 0.4 * terr.Grasdist);
if (random (1) > 0.1)
{
you = ent_create (str_Gras1, grasposition.x, Setze_Gras);
}
else
{
you = ent_create (str_Gras1, grasposition.x, Setze_Gras);
}
you.skill1 = grass_id;
grass_id %= 10;
grass_id += 1;
grascoords.y += terr.Grasdist;
if (grascoords.y > (player.y + terr.Grasarea))
{
grascoords.x += terr.Grasdist;
grascoords.y = player.y - terr.Grasarea;
}
wait(1);
}
}
function Colormap()
{
set(my, PASSABLE | INVISIBLE);
bmap_Vegetation = bmap_for_entity (my, 0);
colormap_size_x = bmap_width (bmap_Vegetation);
colormap_size_y = bmap_height (bmap_Vegetation);
}
function Setze_Gras()
{
COLOR pixel_color;
var format, pixel, temp1;
VECTOR coords, tempcoords;
set(my, PASSABLE | TRANSLUCENT);
my.scale_x += 0.1 - random(2) / 10;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
while (player != NULL)
{
temp1 = random(10);
wait (temp1);
my.alpha = minv (100, (10000 / ((vec_dist(player.x, my.x) + 1))));
my.x = cycle(my.x, camera.x - terr.Grasarea, camera.x + terr.Grasarea);
my.y = cycle(my.y, camera.y - terr.Grasarea, camera.y + terr.Grasarea);
my.z = terr.max_z + 400;
vec_set(tempcoords.x, my.x);
tempcoords.z -= 10000;
my.skill10 = c_trace (my.x, tempcoords.x, IGNORE_SPRITES | IGNORE_PASSABLE |IGNORE_MODELS);
if (you != NULL)
{
if(trace_hit)
{
coords.x = (my.x - terr.min_x) / ((terr.max_x - terr.min_x) / colormap_size_x);
coords.y = (terr.max_y - my.y) / ((terr.max_y - terr.min_y) / colormap_size_y);
format = bmap_lock (bmap_Vegetation, 888);
pixel = pixel_for_bmap(bmap_Vegetation, coords.x, coords.y);
pixel_to_vec (pixel_color, NULL, format, pixel);
bmap_unlock (bmap_Vegetation);
my.z -= my.skill10-22;
vec_to_angle (my.pan, normal);
my.tilt -= 90;
// if (pixel_color.green >= 200)
// {
// my.z -= 200;
// vec_to_angle (my.pan, normal);
// my.tilt -= 90;
// //reset(my, INVISIBLE);
// }
// else
// {
// //set(my, INVISIBLE);
// }
}
}
wait (1);
}
}