txesmi: I am looking at your sample code, specifically at this function of yours:
action active_weapon_action ()
{
ENTITY *ent = active_weapon;
if ( ent )
{
ent.x = 70;
ent.y = -20;
ent.z = -20;
while ( ent == active_weapon )
wait(1);
ent_remove ( ent );
}
}
I am assuming that this function is meant to position a gun in front of the camera, so that the gun points at wherever the player is facing.
I am trying to change this, in that instead of positioning a gun to point wherever the player faces, I would like to place a hand weapon (like a sword or mace) into the hand of the player. I currently have a function that works in making this happen, but it is not really part of a program that uses arrays.
This is the code that I used (pre-arrays) to place the weapon into the hand of the player:
action attach_weapon()
{
set(my,PASSABLE);
proc_mode = PROC_LATE;
while (player != NULL)
{
vec_for_vertex(temp.x,player,997); //hand palm base: Vector # 987 on player
vec_for_vertex(temp2.x,player,968); //hand palm tip: Vector # 982 on player
vec_set(my.x,temp.x);
vec_diff(temp.x,temp2.x,temp.x);
vec_to_angle(my.pan,temp.x);
vec_set(my.pan,my.pan);
wait(1);
}
}
This code worked for me in attaching a hand weapon to the player's hand, to use as a weapon.
Do you know how I would incorporate the logic of my attach_weapon() function to work in your active_weapon_action() function?
Here is what I tried so far:
action active_weapon_action ()
{
ENTITY *ent = active_weapon;
if ( ent )
{
set(my,PASSABLE);
proc_mode = PROC_LATE;
while (player != NULL)
{
vec_for_vertex(temp.x,player,997); //hand palm base: Vector # 987
vec_for_vertex(temp2.x,player,968); //hand palm tip: Vector # 982
vec_set(my.x,temp.x);
vec_diff(temp.x,temp2.x,temp.x);
vec_to_angle(my.pan,temp.x);
vec_set(my.pan,my.pan);
wait(1);
}
while ( ent == active_weapon )
wait(1);
ent_remove ( ent );
}
}
...but it does not seem to be working. It is not adding a weapon to my player's hand when I place a weapon into the active weapon slot.
Any help would be appreciated. Thanks.