Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,086 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem with ai's gravity #128249
05/05/07 15:42
05/05/07 15:42
Joined: Oct 2005
Posts: 42
A
aslan123 Offline OP
Newbie
aslan123  Offline OP
Newbie
A

Joined: Oct 2005
Posts: 42
i have a problem with my ai's gravity. he seems to be walking,running in the ground. i can never see his toes. everything works in my code except i dont know why he wont walk/run on the ground instead of in it. what the code does is lets the ai walk on a path, when i come close he gets off the path and attacks me. if i run away he runs back onto the path and so on

here is the code below. can anyone see the problem

sound dead_wav = <dead.wav>;
define TurnSpeed, skill1;
define WalkSpeed, skill2;
define RunSpeed, skill3;
define healthpoints, skill99; // set another name for skill99
Define enemy_z_offset, skill50; //gravity skills
action enemy_action // attached to the dummy enemy that is sensitive to player's sword
{
my.healthpoints = 8;
// give the enemies few health points - they'll die immediately
my.shadow = on;
my.z_offset = 1; //offsets where the gravity race begins and results in how far the player is offsetted from the ground
my.enable_scan = on;
trace_mode = ignore_me+ignore_passable+use_box;
my.TurnSpeed = 5;
my.WalkSpeed = 3;
my.RunSpeed = 8;
// attach entity to nearest path
result = path_scan(me,my.x,my.pan,vector(360,180,1000));
if (result == 0) { return; } // no path found

var NodePos[3];

// find first waypoint
var node = 1; // start at first node
path_getnode(my,node,NodePos,NULL);

var angle[3];

var Gravity;

while (my.healthpoints > 0) // still alive?
{

//find direction
result = vec_to_angle(angle,vec_diff(temp,NodePos,my.x));

// near target? Find next waypoint of the path
if (result < 25)
{
node = path_nextnode(my,node,1);
path_getnode(my,node,NodePos,NULL);
}

my.skill21 = c_trace(my.x,vector(0,0,-4000),use_box|ignore_me|ignore_passents|ignore_passable);

if(my.skill21 > 10)
{
Gravity -= time_step;
}else
{
if(my.skill21 < 0)
{
Gravity += time_step;
}else
{
Gravity = 0;
}
}



if (vec_dist (my.x, player.x) < 600)&& (player != null) // the player approaches the enemy
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
//c_move(my,vector(10*time,0,0),my.player_move_x,use_aabb | ignore_passable | glide);
c_move(me,vector(my.RunSpeed*time_step,0,Gravity),nullvector,glide|ignore_passents|ignore_passable);
ent_animate(my,"run", my.skill20,anm_cycle); // play walk frames animation
my.skill20 += 10 * time_step; // "walk" animation speed


if (vec_dist (my.x, player.x)< 70)&& (player != null) // if the player comes closer attack him
{
//snd_play(club_snd,50,0);
my.skill21 = 0; // reset "attack" frames
while (my.skill21 < 100)&& (player != null)
{
ent_vertex(right_arm_tip, 7); // weapon tip vertex coords - get the value in Med
ent_vertex(right_arm_base, 1); // weapon base vertex coords - get the value in Med
c_trace (right_arm_base, right_arm_tip, ignore_me | ignore_passable|use_box);
if (result != 0) ///made a hit
{
player.health -= 1 * time_step;
//hit_sound();
}
ent_animate(my,"attack", my.skill21,0); // play attack frames animation
my.skill21 += 8 * time_step; // "attack" animation speed
wait (1);
}

}
}
else // the player is farther away
{
// turn and walk towards target
my.pan += ((angle.pan > my.pan)-(angle.pan < my.pan))*time_step*my.TurnSpeed;
//c_move(my,vector(10*time,0,0),my.player_move_x,use_aabb | ignore_passable | glide);
c_move(me,vector(my.WalkSpeed*time_step,0,Gravity),nullvector,glide|ignore_passents|ignore_passable);
ent_animate(my,"walk", my.skill20,anm_cycle); // play walk frames animation
my.skill20 += 5 * time_step; // "walk" animation speed

}
wait (1);
}
my.passable = on; // the corpse can't be hit by the sword from now on; the enemy is dead here
snd_play (dead_wav, 50, 0); // sword sound

while (my.skill10 < 99)
{
ent_animate(my, "death", my.skill10, null);
my.skill10 += 4 * time_step; // "death" animation speed
wait (1);
}
my.transparent = on;
my.alpha = 100;
while (my.alpha > 0)
{
my.alpha -= 4 * time_step;
wait (1);
}
ent_remove (my);
}

Re: problem with ai's gravity [Re: aslan123] #128250
05/05/07 20:11
05/05/07 20:11
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
...at a quick glance
Code:

action enemy_action {

wait(1);
c_updatehull(me, 0);
// or
// c_setminmax(me);
// or set bbox flag in WED

//...
//my.skill21 = c_trace(my.x,vector(0,0,-4000),use_box|ignore_me|ignore_passents|ignore_passable);
vec_set(temp, my.x); temp.z -= 1000;
my.skill21 = c_trace(my.x, temp, use_box | ignore_me | ignore_passents | ignore_passable);

//...



Re: problem with ai's gravity [Re: testDummy] #128251
05/05/07 21:18
05/05/07 21:18
Joined: Oct 2005
Posts: 42
A
aslan123 Offline OP
Newbie
aslan123  Offline OP
Newbie
A

Joined: Oct 2005
Posts: 42
that worked great
thankyou very much
5 stars


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1