1 registered members (M_D),
1,501
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
enemy's AI..NOT WORKING!!!
#353440
01/10/11 11:55
01/10/11 11:55
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 97
|
pls help me with this problem.... i modified an AI from another source so that i could use it for my project, but when run it there is an error like ERR E1513 "Script crash in ghost" and Malfunction W1501 "Empty pointer in pacman". I dont know where to find that error and now i'm confused. here is the code:
action pacman()
{
player = my;
set(my, POLYGON);
VECTOR temp;
VECTOR player_speed;
var anim_percentage;
my.health = 100;
while(my.health>0)
{
handle_movement();
c_move(my, player_speed, IGNORE_PASSABLE, GLIDE);
ent_animate(my, "frame", anim_percentage, ANM_CYCLE);
anim_percentage += 5 * time_step;
camera_follow();
wait(1);
}
}
function ghost1();
action ghost1()
{
VECTOR enemy_speed;
VECTOR temp;
VECTOR left_arm, right_arm;
set(my, POLYGON);
my.health = 50;
var anim_percentage = 0;
var attack_type = 0;
var attack_percentage = 0;
while(my.health >=0)
{
c_trace(my.x, player.x, IGNORE_ME | IGNORE_PASSABLE);
if(you == player)
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;
if(vec_dist(player.x, my.x) >17)
{
enemy_speed.x = 5 * time_step;
enemy_speed.y = 0;
enemy_speed.z = 0;
c_move(my, enemy_speed, nullvector, IGNORE_PASSABLE | GLIDE);
anim_percentage += 8 * time_step;
}
else
{
attack_type = 1;
if(player.health<=0)
{
attack_type = 0;
}
if(attack_type == 1)
{
attack_percentage = 0;
while(attack_percentage < 100)
{
vec_for_vertex(left_arm, my, 20);
vec_for_vertex(right_arm, my, 30);
if(c_trace (left_arm, right_arm, IGNORE_ME | IGNORE_PASSABLE)>0)
{
if(you==player)
{ player.health -=5 * time_step; }
}
ent_animate(my, "frame", attack_percentage, NULL);
attack_percentage += 8 * time_step;
wait(1);
}
}
anim_percentage = 0;
while(anim_percentage < 100)
{
ent_animate(my, "frame", anim_percentage, ANM_CYCLE);
attack_percentage += 3 * time_step;
wait(1);
}
}
}
else
{
ent_animate(my, "frame", anim_percentage, ANM_CYCLE);
anim_percentage += 1* time_step;
}
wait(1);
set(my, PASSABLE);
my.alpha = 100;
set(my, TRANSLUCENT);
while(my.alpha > 0)
{
my.alpha -= 3 * time_step;
wait(1);
}
ent_remove(my);
}
}
pls pls pls..help me....
|
|
|
Re: enemy's AI..NOT WORKING!!!
[Re: Widi]
#353448
01/10/11 13:29
01/10/11 13:29
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I cant see anything wrong with the pacman action as long as :: 1> it is being called from the level(entity placed in WED) 1a> or it is being called IN an ent_create command 2> the player entity is never 'ent_remove'd by any other functions.
Maybe show us the 'handle_movement' code too...
And with the ghost1 action :: 1> put Widi's code in before the loop starts. 2> make sure the 'ent_remove(my);' is outside the loop. (it looks inside to me)
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: enemy's AI..NOT WORKING!!!
[Re: chrisp1]
#353461
01/10/11 15:34
01/10/11 15:34
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Good pick Rasch, I completely missed that...
Surprised it even compiled...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: enemy's AI..NOT WORKING!!!
[Re: Rasch]
#353520
01/10/11 22:50
01/10/11 22:50
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 97
|
thanks all for your replies!!! i really appreciated it btw, i did everything you'd suggested. it has no error but it hanged having a self study in gs has never been easy to me... ~sigh the code becomes like this:
var players_lives = 3; // set the number of lives here
var players_score = 0;
var players_power; // stores the current number of power ups that have been picked up
var total_power = 0; // stores the total number of power ups that can be picked up
var level_number = 1; // holds th current level number
var winner = 0;
SOUND* power_wav = "power.wav";
SOUND* extralife_wav = "extralife.wav";
FONT* ethnocentric_tga = "ethnocentric.tga"; // used for the hud
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
PANEL* gui =
{
digits(520, 550, 1, ethnocentric_tga, 1, players_lives);
digits(690, 550, 2, ethnocentric_tga, 1, players_power);
digits(800, 550, 2, ethnocentric_tga, 1, total_power);
flags = SHOW | OVERLAY;
}
PANEL* q1 =
{
bmap = "q1.pcx";
layer = 4;
pos_x = 0;
pos_y = 0;
flags = SHOW;
}
PANEL* health_pan =
{
bmap = "health1.tga";
pos_x = 520;
pos_y = 50;
layer = 25;
flags = SHOW;
}
function splahout()
{
q1.alpha = 0;
while(q1.alpha <=100)
{
q1.alpha += 1*time_step;
wait(1);
}
}
function main()
{
screen_size.x = 800;
screen_size.y = 600;
splahout();
}
function camera_follow()
{
camera.genius = my;
vec_set(camera.x,vector(0,0,0));
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);
vec_set(camera.pan,vector(my.pan,-10,0));
camera.tilt = clamp(camera.tilt,0,0);
wait(1);
}
function handle_movement()
{
VECTOR vFeet;
vec_for_min(vFeet,me);
my.pan += (key_cul-key_cur)*5*time_step;
var distance = (key_cuu-key_cud)*30*time_step;
c_move(me, vector(distance,0,0), NULL, IGNORE_PASSABLE);
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z;
}
function pacman();
action pacman()
{
player = my;
set(my, POLYGON);
VECTOR temp;
VECTOR player_speed;
var anim_percentage;
my.health = 100;
while(my.health>0)
{
handle_movement();
c_move(my, player_speed, nullvector, IGNORE_PASSABLE | GLIDE);
ent_animate(my, "frame", anim_percentage, ANM_CYCLE);
anim_percentage += 5 * time_step;
camera_follow();
wait(1);
}
}
function ghost1();
action ghost1()
{
VECTOR enemy_speed;
VECTOR temp;
VECTOR left_arm, right_arm;
set(my, POLYGON);
my.health = 50;
var anim_percentage = 0;
var attack_type = 0;
var attack_percentage = 0;
while (!player) wait(1);
while(my.health >=0)
{
c_trace(my.x, player.x, IGNORE_ME | IGNORE_PASSABLE);
if(you == player)
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;
if(vec_dist(player.x, my.x) >17)
{
enemy_speed.x = 5 * time_step;
enemy_speed.y = 0;
enemy_speed.z = 0;
c_move(my, enemy_speed, nullvector, IGNORE_PASSABLE | GLIDE);
anim_percentage += 8 * time_step;
}
else
{
attack_type = 1;
if(player.health<=0)
{
attack_type = 0;
}
if(attack_type == 1)
{
attack_percentage = 0;
while(attack_percentage < 100)
{
vec_for_vertex(left_arm, my, 20);
vec_for_vertex(right_arm, my, 30);
if(c_trace (left_arm, right_arm, IGNORE_ME | IGNORE_PASSABLE)>0)
{
if(you==player)
{ player.health -=5 * time_step; }
}
ent_animate(my, "frame", attack_percentage, NULL);
attack_percentage += 8 * time_step;
wait(1);
}
}
anim_percentage = 0;
while(anim_percentage < 100)
{
ent_animate(my, "frame", anim_percentage, ANM_CYCLE);
attack_percentage += 3 * time_step;
wait(1);
}
}
}
else
{
ent_animate(my, "frame", anim_percentage, ANM_CYCLE);
anim_percentage += 1* time_step;
}
wait(1);
set(my, PASSABLE);
my.alpha = 100;
set(my, TRANSLUCENT);
while(my.alpha > 0)
{
my.alpha -= 3 * time_step;
wait(1);
}
}
ent_remove(my);
}
function health_startup()
{
var players_health = 0;
while(!player) { wait(1); }
while(player);
{
health_pan.scale_x = maxv(0.01, player.health / 100);
wait(1);
}
}
|
|
|
Re: enemy's AI..NOT WORKING!!!
[Re: Joozey]
#353537
01/11/11 03:39
01/11/11 03:39
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 97
|
uhm..ok, i removed the wait(1) in camera follow, but its still the same.. how come..:((
Last edited by carla_mariz; 01/12/11 10:45.
|
|
|
|