Requesting some scripts! (Player movement and...)

Posted By: Person99

Requesting some scripts! (Player movement and...) - 06/27/06 21:16

I am requesting a script, and how to install the script to the character...

What I want to do:

- Control the player in third person view, and animate when key combos are pressed:
Example: You press up... The character does a walking forward animation... You press left... The character does a strafing left animation... You press right... The character does a strafing right animation... You press back... the character does a backward walking animation... You press back and left, the character does a walking backwards left diagonally animation... You press back and right, the character does a walking backwards right diagonally... You press uparrow and right, the character does a moving in a right forward diagonal direction...you press uparrow and left, the character does an animation of walking in a left forward animation... ECT.

-Add certian types of collision, like you can't walk through walls, and when you walk up to an item, you "Get on it".


Can anyone PLEASE help me with this?
Posted By: Claus_N

Re: Requesting some scripts! (Player movement and...) - 06/27/06 22:16

Hi

Here you go
But it isn't tested, just wrote it right out of my mind
Code:
define speed,skill1;
define speed_x,skill1;
define speed_y,skill2;
define speed_z,skill3;

// Change these to fit your needs
define cam_dist,100; // Distance to camera
define cam_height,80; // Camera height
define movement_speed,10; // Movement speed
string stand_anim = "stand"; // Stand animation
string walk_anim = "walk"; // Walk/run animation

action thePlayer
{
// I'm the player ;)
player = me;

// Player main loop
while(my)
{
// Set speeds
my.speed_x = ((key_w | key_cur) - (key_s | key_cud)) * movement_speed;
my.speed_y = ((key_d | key_cur) - (key_a | key_cur)) * movement_speed;
my.speed_z = 0;

// Move me
c_move(my,vector(my.speed_x * time,my.speed_y * time,0),vector(0,0,my.speed_z * time),ignore_passable + glide);

// Animate
if(vec_dist(my.speed,nullvector) < 5)
{
ent_animate(my,stand_anim,my.skill46,ANM_CYCLE);
my.skill46 += 2 * time;
}
else
{
ent_animate(my,walk_anim,my.skill46,ANM_CYCLE);
my.skill46 += 8 * time;
}
my.skill46 %= 100; // Get the rest of a division by 100

// Set the camera position
camera.x = my.x + fcos(my.pan,cam_dist);
camera.y = my.y + fsin(my.pan,cam_dist);
camera.z = cam_height;

// Make the camera looking at the player
vec_set(temp,my.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp);

// Avoid endless loops
wait(1);
}
}


Posted By: Person99

Re: Requesting some scripts! (Player movement and. - 06/28/06 02:23

THANKS!
This should work great if... I knew how to apply it.

How can I apply this to the level or character?
Posted By: Claus_N

Re: Requesting some scripts! (Player movement and. - 06/28/06 08:08

Save it in a file, called e.g. "playerscript.wdl", and put it in your project's folder.
Open your level's WDL file (LEVELNAME.wdl), and find the "include" lines. Then add this:
include <playerscript.wdl>;
© 2023 lite-C Forums