So I used vec_for_bone to attach an rifle model to my character model.
It works without any issue, however positioning of the weapon can only be achieved through manually adjusting the angle of the weapon to different animation stages (standing, walking, aiming and not aiming, etc.) is very unpractical.

Code:
action attach_weapon()
{
	proc_mode = PROC_LATE;
	//
	ENTITY* actor = you;
	//
	set(my,PASSABLE);
	//////////
	while(actor.health>0)
	{
	        // attach weapon to bone. 
		vec_for_bone (my.x,   actor, "Bip01_R_Finger0");
		ang_for_bone (my.pan, actor, "Bip01_R_Finger0");
		//////////
              /*  individual adjustments of the weapon depending on current animation set of the character in order to keep the positioning/angle correct */
		if(my.state >= 1)
		{
			if(actor.move_speed>1)
			{
				my.tilt -= 80;
				my.pan += 45;
				my.roll += 20;
			}
			else
			{
				my.tilt -= 80;
				my.pan += 0;
				my.roll += 20;
			}
		}
		else
		{
			my.tilt -= 70;
			my.pan -= 10;
			my.roll += 20;
		}
		wait(1);
	}
	wait(1);
	weapon_model();//spawn weapon
}



That is tidies and I am sure there is a smarter way to attach a weapon more reliable and with less effort.

My attempt to improve, which did not work (for some reason), was the the following:

Code:
VECTOR bonevec, bone1, bone2;
ANGLE boneang;
//////////
vec_for_bone (bone1.x,   actor, "Bip01_R_Finger0");
vec_for_bone (bone2.x,   actor, "_no_name_13");	
vec_set(bonevec,bone2.x); 
vec_sub(bonevec,bone1.x);
vec_to_angle(boneang.pan,bonevec);
ang_for_bone (boneang.pan, actor, "Bip01_R_Finger0");
/*weapon is attached to bone1, while the angle boneang is always facing bone2 from bone1*/



The idea was to the attach the weapon to a certain bone and have it face the direction of another bone which is positioned in a way that the weapon would always have the correct angle.

However, the weapon does not attach in the first place with the script above Oo


Last edited by Blobfist; 04/24/18 23:46.