1 registered members (henrybane),
1,246
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: problem with script, please help.
[Re: Pappenheimer]
#314440
03/08/10 17:21
03/08/10 17:21
|
Joined: Mar 2010
Posts: 29
lollollollollol
OP
Newbie
|
OP
Newbie
Joined: Mar 2010
Posts: 29
|
Well the level will load, and the zombies i called up do fight against eachother... but im not playing as the character with the arrowkeys(or awsd). So i cant control any character, as the zombie_fight_against_eachother, just calls up two zombies, which fight against eachother and then loop their animations. So im not controlling the fighting zombies.
Short: How can i move a character with arrow keys (or awsd) while the camera follows me, as i thought the initial post was covering this?
Last edited by lollollollollol; 03/08/10 17:38.
|
|
|
Re: problem with script, please help.
[Re: Pappenheimer]
#314456
03/08/10 18:28
03/08/10 18:28
|
Joined: Mar 2010
Posts: 29
lollollollollol
OP
Newbie
|
OP
Newbie
Joined: Mar 2010
Posts: 29
|
ok so know i have :
#include <acknex.h>
#include <default.c>
#define walk_percentage skill11
#define STATE skill1
#define STATE skill1
#define ANIMATION skill2
////////////////////////////////////////////////////////////////////
BMAP* cursor_pcx = "cursor.pcx";
BMAP* crosshair_pcx = "crosshair.pcx";
////////////////////////////////////////////////////////////////////
function camera_follow(ENTITY* ent)
{
while(1)
{
vec_set(camera.x,vector(-150,10,50)); // camera position relative to the player
vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
vec_add(camera.x,ent.x); // add player position
vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down
wait(1);
}
}
action character_walking()
{
camera_follow(me);
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
my.STATE = 1;
while (1)
{
// state 1: walking ////////////////////////////////////////////
if (my.STATE == 1)
{
// rotate the entity with the arrow keys
my.pan += (key_cul-key_cur)*5*time_step;
// move the entity forward/backward with the arrow keys
var distance = (key_cuu-key_cud)*5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);
// animate the entity
my.ANIMATION += 2*distance;
ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground
}
}
}
function change_mouse_mode()
{
mouse_mode += 1;
mouse_mode %= 3;
if (1 == mouse_mode)
mouse_map = crosshair_pcx;
if (2 == mouse_mode)
mouse_map = cursor_pcx;
}
action zombie_bars()
{
while (1)
{
my.walk_percentage += 2 * time_step; // 3 = animation speed
ent_animate(me, "attack", my.walk_percentage, ANM_CYCLE); // "attack" animation loop
wait (1);
}
}
action zombie_fight_against_eachother()
{
while (1)
{
my.walk_percentage += 3 * time_step; // 3 = animation speed
ent_animate(me, "hit", my.walk_percentage, ANM_CYCLE); // "attack" animation loop
wait (1);
}
}
action zombie_fight_against_eachotherr()
{
while (1)
{
my.walk_percentage += 2.5 * time_step; // 3 = animation speed
ent_animate(me, "hit", my.walk_percentage, ANM_CYCLE); // "attack" animation loop
wait (1);
}
}
function main()
{
video_mode = 7;
level_load ("Huis.wmb");
ent_create("zombiek.mdl",vector(293,-107,-55), zombie_bars);
you = ent_create("zombiek.mdl",vector(0,0,0), character_walking);
you = ent_create("zombiek.mdl",vector(425,106,-47), zombie_fight_against_eachother);
you.pan= 60;
you = ent_create("zombiek.mdl",vector(530,106,-47), zombie_fight_against_eachotherr);
you.pan= 240;
on_m = change_mouse_mode;
while (1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
camera.pan -= mouse_force.x;
camera.tilt += mouse_force.y;
wait (1);
}
camera.z = 120; // choose a convenient height
camera.tilt = -15; // and tilt angle for the camera
}
And it will pass the compiling, but know it will fade to black, instead of shwowing my map. Any idea why?
|
|
|
Re: problem with script, please help.
[Re: lollollollollol]
#314459
03/08/10 18:45
03/08/10 18:45
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
In the while loop of the action 'character_walking', there was a 'wait(1);' missing, look at the following corrected code, please have a close look to place the 'wait(1);' within the curly brackets of the while loop, but not within the curly brackets of the if instruction.
action character_walking()
{
camera_follow(me);
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
my.STATE = 1;
while (1)
{
// state 1: walking ////////////////////////////////////////////
if (my.STATE == 1)
{
// rotate the entity with the arrow keys
my.pan += (key_cul-key_cur)*5*time_step;
// move the entity forward/backward with the arrow keys
var distance = (key_cuu-key_cud)*5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);
// animate the entity
my.ANIMATION += 2*distance;
ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground
}
wait(1);
}
}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|