hi, I'm trying to make a short program that will generate the floor as the player moves through it.
I have a test pawn with the pointer "rogue" that I'm moving around with some c_move commands to test.
here is the action I'm using on the tiles that make up the ground:
action square()
{
var end_peice = 1;
while (end_peice == 1)
{
// DEBUG_VAR(my.x, 150);
if (vec_dist(my.y, rogue.y) <= 500 && rogue.y <= my.y)
{
ent_create("space.mdl", vector (my.x, my.y+139, my.z), square);
end_peice = 0;
}
if (vec_dist(my.y, rogue.y) <= 500 && rogue.y >= my.y)
{
ent_create("space.mdl", vector (my.x, my.y-139, my.z), square);
end_peice = 0;
}
if (vec_dist(my.x, rogue.x) <= 500 && rogue.x >= my.x)
{
ent_create("space.mdl", vector (my.x-139, my.y, my.z), square);
end_peice = 0;
}
if (vec_dist(my.x, rogue.x) <= 500 && rogue.x <= my.x)
{
ent_create("space.mdl", vector (my.x+139, my.y, my.z), square);
end_peice = 0;
}
wait (1);
}
ent_morph(me, "ender.mdl");
}
The idea here is that when the player is close enough it will generate a new tile in the proper direction,
and then set the variable "end_peice" to 0, so that it won't create any more tiles.
the ent_morph at the end shows me which ones have the variable set to 0 and wihich are still at 1.
some strange things are happening though. When I spawn the player is in the middle of a big square of tiles.
The tiles on the far right and left have end_peice set to 1, while all the rest have it set to 0.
So nothing happens when I move vertically, but an entire column of nine tiles appears when I move horizontally.
Also if I get far enough on the y-axis in either direction it suddenly tells me not enough entities were reserved and crashes.
I'm hoping I'm just doing something silly since I haven't used the vec_dist command this way before.
Thanks in advance, Rtsgamer706