Ya, I need help with this little beasty.
What I want it to do is place grass around the player as he walks. The problem is that only one grass stalk moves, and the others stay still. I only want to move those stalks that are a certain distance away from the player. Also I would like to place it above the terrain in my level... but I have no idea on how to do that. Anyways heres the cog:
Its pretty simple. Any ideas?
What I want it to do is place grass around the player as he walks. The problem is that only one grass stalk moves, and the others stay still. I only want to move those stalks that are a certain distance away from the player. Also I would like to place it above the terrain in my level... but I have no idea on how to do that. Anyways heres the cog:
Code:
# Jedi Knight Cog Script
#
# grass.COG
#
# A cog which plants grass in a certian radius around the player.
# The catch is it has to land on top of the terrain.
#
# [Hellcat]
# This Cog is Not supported by LucasArts Entertainment Co
flags=0x240
symbols
int i=0 local
int player=-1 local
int g_dist=2 local
flex randx=0 local
flex randy=0 local
vector grass_pos local
template grass_mdl
message startup
message pulse
end
# ========================================================================================
code
startup:
sleep(1);
player = GetLocalPlayerThing();
while (i<101)
{
//Get the players position
grass_pos = GetThingPos(player);
//Make some random values within the boudry
randx = (Rand() * g_dist) - (g_dist/2);
randy = (Rand() * g_dist) - (g_dist/2);
grass_pos = VectorSet((VectorX(grass_pos) + randx), (VectorY(grass_pos) + randy), (VectorZ(grass_pos)));
grass0i = CreateThingAtPos(grass_mdl, 0, grass_pos, '0 0 0');
i = i + 1;
}
setpulse(0.5);
return;
# ........................................................................................
pulse:
i=0;
for(i=0; i < 101; i=i+1)
{
PrintFlex(VectorDist(GetThingPos(player), GetThingPos(grass0i)));
If (VectorDist(GetThingPos(player), GetThingPos(grass0i)) >=(g_dist/2))
{
//Get the players position
grass_pos = GetThingPos(player);
//Make some random values within the boudry
randx = (Rand() * g_dist) - (g_dist/2);
randy = (Rand() * g_dist) - (g_dist/2);
grass_pos = VectorSet((VectorX(grass_pos) + randx), (VectorY(grass_pos) + randy), (VectorZ(grass_pos)));
SetThingPos(grass0i, grass_pos);
}
}
return;
# ........................................................................................
endIts pretty simple. Any ideas?
![http://forums.massassi.net/html/biggrin.gif [http://forums.massassi.net/html/biggrin.gif]](http://forums.massassi.net/html/biggrin.gif)
![http://forums.massassi.net/html/frown.gif [http://forums.massassi.net/html/frown.gif]](http://forums.massassi.net/html/frown.gif)
![http://forums.massassi.net/html/tongue.gif [http://forums.massassi.net/html/tongue.gif]](http://forums.massassi.net/html/tongue.gif)
![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)

![http://forums.massassi.net/html/eek.gif [http://forums.massassi.net/html/eek.gif]](http://forums.massassi.net/html/eek.gif)