Friends

I had problems with my first animated weapon system. I fellow the steps of the Grimber tutorial
and i defined each weapon of the system as view entity. For example:

entity gun0
{
type = <el_revolver.mdl>;
ambient = 0;
pan=90;
x= 5;
scale_x=2;
scale_y=2;
scale_z=2;
layer=1;
y= 3;
z= 0;
ammo=0;
numbergun=1;
recargar=1;
}


Every thing was good. But the problem is that the ligth dont get effect on that views entities. Then when my player get in to a dark room , the entity gun is ever visible. And that sucks!

I dont know if is it possible to fix it. To make the view entity affected with lights and shadows.

In that momment i am starting to depelop a new gun system.
For example I started the next way.


1- i put 2 gun models in the world.

2-i defined two pointers for my two weapons

entity* weapon1; // pointer to our weapon model
entity* weapon2;


3- i defined an action for each entities. and after i attached each action to each entity of guns i my world.

Action playerweapon1
{
weapon1 = my; // I'm weapon1
var player1_pos; // stores the initial position of the player
var player2_pos; // stores the position of the player after a frame
var weapon_height;
var weapon_offset;
my.passable = on;
my.invisible=on;
// the weapon model is passable
while (player == null) {wait (1);} // wait until the player is created
while (1)
{
vec_set (player1_pos.x, player.x); // store the initial player position
// place the weapon 50 quants in front, 18 quants to the right and 20 quants below camera's origin
//vec_set (weapon_offset.x, vector (50, -18, -20));
vec_set (weapon_offset.x, vector (50, 18, -20));
if (vec_dist (player1_pos.x, player2_pos.x) != 0) // the player has moved during the last frame?
{
weapon_height += 30 * time; // then offset weapon_height (30 = weapon waving speed)
weapon_offset.z += 0.3 * sin(weapon_height); // (0.3 = weapon waving amplitude)
}
// rotate weapon_offset according to the camera angles
vec_rotate (weapon_offset.x, vector (camera.pan, camera.tilt, 0));
vec_add (weapon_offset.x, camera.x); // add the camera position to weapon_offset
vec_set (my.x, weapon_offset.x); // set weapon's coords to weapon_offset
my.pan = camera.pan; // use the same camera angles for the weapon
my.tilt = camera.tilt;
vec_set (player2_pos.x, player.x); // store the new player coordinates after 1 frame
wait (1);
}



}


Action playerweapon2
{
weapon2 = my; // I'm weapon2
var player1_pos; // stores the initial position of the player
var player2_pos; // stores the position of the player after a frame
var weapon_height;
var weapon_offset;


my.scale_x=2;
my.scale_y=2;
my.scale_z=2;

my.passable = on; // the weapon model is passable
while (player == null) {wait (1);} // wait until the player is created
while (1)
{
vec_set (player1_pos.x, player.x); // store the initial player position
// place the weapon 50 quants in front, 18 quants to the right and 20 quants below camera's origin

vec_set (weapon_offset.x, vector (65, -18, -20));
if (vec_dist (player1_pos.x, player2_pos.x) != 0) // the player has moved during the last frame?
{
weapon_height += 30 * time; // then offset weapon_height (30 = weapon waving speed)
weapon_offset.z += 0.3 * sin(weapon_height); // (0.3 = weapon waving amplitude)
}
// rotate weapon_offset according to the camera angles
vec_rotate (weapon_offset.x, vector (camera.pan, camera.tilt, 0));
vec_add (weapon_offset.x, camera.x); // add the camera position to weapon_offset
vec_set (my.x, weapon_offset.x); // set weapon's coords to weapon_offset
my.pan = camera.pan; // use the same camera angles for the weapon
my.tilt = camera.tilt;
vec_set (player2_pos.x, player.x); // store the new player coordinates after 1 frame
wait (1);
}



}


3- The problem i that i need a function that make the next:

if i press 1 the weapon1 is visible and the others invisible

if i press 2 the weapon2 is vivislbe and the others invisible.

the problem is that when i put

weapon1.invisible=on;

it desnt work.


i dont know how to do it.

can some body help me?

Thanks