|
|
temp "undeclared identifier"
#222958
08/21/08 18:35
08/21/08 18:35
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
the following code works ok in c-script but i get that error in lite c, can anyone point out were this is wrong?
{
camera.pan -= mouse_force.x * 12 * time;
camera.tilt += mouse_force.y * 8 * time;
camera.tilt = clamp(camera.tilt,-30,100);
temp = fcos(camera.tilt,-camera_distance);
vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 10 + fsin(camera.tilt,-camera_distance)));
vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.
trace_mode = ignore_me+ignore_passable+ignore_models;
result = trace(my.x,temp.x); //trace from the player to 16 quants behind the camera.
IF (result > 0)
{
vec_diff(temp.x,my.x,target.x); //find the vector from the point the trace hit to the player
vec_normalize(temp.x,16); //get the magnitude of this vector to 16 quants and store in temp
vec_set(camera.x,target.x); //place the camera at the trace hit point
vec_add(camera.x,temp.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
}
wait(1);
}
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: temp "undeclared identifier"
[Re: flits]
#222964
08/21/08 19:01
08/21/08 19:01
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
erm, were abouts should i put it lol
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: temp "undeclared identifier"
[Re: jigalypuff]
#222966
08/21/08 19:04
08/21/08 19:04
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
at the top
VECTOR temp;
function do_a_func() { ...
"empty"
|
|
|
Re: temp "undeclared identifier"
[Re: flits]
#222969
08/21/08 19:11
08/21/08 19:11
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
cannot convert struct vector to fixed is the error i`m getting with that. here is the whole movement code, it is from the latest aum. the camera code is from an older project though. i beleive i modified the code dave lancaster contributed. the kingdom hearts stuff.
VECTOR temp;
function move_players() // both entities are controlled by the server
{
var walk_percentage;
var stand_percentage;
while (1)
{
c_move(my, vector(my.skill1, 0, 0), nullvector, GLIDE); // move the entity using its own skill1
my.pan += my.skill2; // and rotate it using its own skill2
if (my.skill1) // the player is moving the entity? (skill1 isn't zero)
{
walk_percentage += 1.5 * my.skill1 * sign(my.skill1); // allow forward / back animations
ent_animate(my, "walk", walk_percentage, ANM_CYCLE); // animate the entity
stand_percentage = 0; // reset stand_percentage
}
else
{
stand_percentage += 1.2 * time_step; // the "stand" animation values don't depend on player's input
ent_animate(my, "stand", stand_percentage, ANM_CYCLE); // animate the entity
walk_percentage = 0; // reset walk_percentage
}
ent_sendnow(my); // send the updated entity position regardless of the "dplay_entrate" value, etc
wait (1);
}
{
camera.pan -= mouse_force.x * 12 * time_step;
camera.tilt += mouse_force.y * 8 * time_step;
camera.tilt = clamp(camera.tilt,-30,100);
temp = fcos(camera.tilt,-camera_distance);
vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 10 + fsin(camera.tilt,-camera_distance)));
vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.
trace_mode = ignore_me+ignore_passable+ignore_models;
result = trace(my.x,temp.x); //trace from the player to 16 quants behind the camera.
IF (result > 0)
{
vec_diff(temp.x,my.x,target.x); //find the vector from the point the trace hit to the player
vec_normalize(temp.x,16); //get the magnitude of this vector to 16 quants and store in temp
vec_set(camera.x,target.x); //place the camera at the trace hit point
vec_add(camera.x,temp.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
}
wait(1);
}
}
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: temp "undeclared identifier"
[Re: jigalypuff]
#222976
08/21/08 19:54
08/21/08 19:54
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
var temp[3];
function move_players() // both entities are controlled by the server
{
var walk_percentage;
var stand_percentage;
while (1)
{
c_move(my, vector(my.skill1, 0, 0), nullvector, GLIDE); // move the entity using its own skill1
my.pan += my.skill2; // and rotate it using its own skill2
if (my.skill1) // the player is moving the entity? (skill1 isn't zero)
{
walk_percentage += 1.5 * my.skill1 * sign(my.skill1); // allow forward / back animations
ent_animate(my, "walk", walk_percentage, ANM_CYCLE); // animate the entity
stand_percentage = 0; // reset stand_percentage
}
else
{
stand_percentage += 1.2 * time_step; // the "stand" animation values don't depend on player's input
ent_animate(my, "stand", stand_percentage, ANM_CYCLE); // animate the entity
walk_percentage = 0; // reset walk_percentage
}
ent_sendnow(my); // send the updated entity position regardless of the "dplay_entrate" value, etc
wait (1);
}
{
camera.pan -= mouse_force.x * 12 * time_step;
camera.tilt += mouse_force.y * 8 * time_step;
camera.tilt = clamp(camera.tilt,-30,100);
temp = fcos(camera.tilt,-camera_distance);
vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 10 + fsin(camera.tilt,-camera_distance)));
vec_diff(temp[0],camera.x,my.x); //find the vector from the player to the camera
vec_normalize(temp[0],16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(temp[0],camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.
trace_mode = ignore_me+ignore_passable+ignore_models;
result = trace(my.x,temp[0]); //trace from the player to 16 quants behind the camera.
IF (result > 0)
{
vec_diff(temp[0],my.x,target[0]); //find the vector from the point the trace hit to the player
vec_normalize(temp[0],16); //get the magnitude of this vector to 16 quants and store in temp
vec_set(camera.x,target.x); //place the camera at the trace hit point
vec_add(camera.x,temp[0]); //move the camera away from the wall by the vector temp, 16 quants towards the player
}
wait(1);
}
}
"empty"
|
|
|
Re: temp "undeclared identifier"
[Re: flits]
#222980
08/21/08 20:03
08/21/08 20:03
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
weird now i`m getting error in main but i have not changed georges code at all
function main()
{
fps_max = 60; // limit the number of data packets that are sent each second to 60
///video_screen = 1;
level_load ("dark_frontier.wmb");
vec_set(camera.x, vector (-600, 0, 100)); // set a proper camera position
if (!connection) // no server could be found?
sys_exit(NULL); // then shut down the engine
if (connection == 2) // this instance of the game runs as a client?
{
my = ent_create ("fcc_a.mdl", vector (100, 50, 40), move_players); // then create the red guard!
while (1)
{
my.skill1 = 5 * (key_w - key_s) * time_step;
my.skill2 = 4 * (key_a - key_d) * time_step;
send_skill (my.skill1, SEND_VEC); // send skill1...3 to the server
wait (1);
}
}
if (connection == 3) // this instance of the game runs as a server and client at the same time? (connection = 3)
{
my = ent_create ("cgc_a.mdl", vector (-100, -50, 40), move_players); // create the blue guard
while (1)
{
my.skill1 = 5 * (key_w - key_s) * time_step;
my.skill2 = 4 * (key_a - key_d) * time_step;
wait (1);
}
}
}
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: temp "undeclared identifier"
[Re: jigalypuff]
#222981
08/21/08 20:04
08/21/08 20:04
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
sorry it says error in main line 11 syntax error
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
|