VECTOR palm1, palm2, sword_direction;
STRING* sword_mdl = "sword.mdl";
function attach_sword()
{
proc_mode = PROC_LATE;
set (my, PASSABLE); // the sword shouldn't slow down the player
while (you)
{
// get the vertex at the bottom of the palm in Med
vec_for_vertex (palm1, you, 28);
// get the vertex that separates the thumb and the pointer finger in Med
vec_for_vertex (palm2, you, 9);
// compute the vector that will be used by the sword
vec_diff (sword_direction, palm2, palm1);
// rotate the sword accordingly
vec_to_angle (my.pan, sword_direction);
// put the origin of the sword in the vertex that is placed at the bottom of the palm
vec_set (my.x, palm1);
wait (1);
}
}
action spearman_action()
{
var anim_percentage = 0;
ent_create (sword_mdl, my.x, attach_sword); // attach the sword to the player
while (1)
{
anim_percentage += 3 * time_step; // 3 = "walk" animation speed
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation
c_move (my, vector(5 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
my.pan += 2 * time_step; // 2 sets the radius of the circle
wait (1);
}
}