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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 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
Page 1 of 2 1 2
enemy's AI..NOT WORKING!!! #353440
01/10/11 11:55
01/10/11 11:55
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

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. frown

here is the code:

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: carla_mariz] #353445
01/10/11 12:42
01/10/11 12:42
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Maybe the player pointer is not initialised at the begin of your ghost1 action. Set following at the begin of your ghost1 action:

while (!player) wait(1);

That will wait till the player pointer is filled with "player = my;" in your pacman action.

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 Offline
Expert
EvilSOB  Offline
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: EvilSOB] #353454
01/10/11 14:17
01/10/11 14:17
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
In your pacman code you c_move looks like this.

c_move(my, player_speed, IGNORE_PASSABLE, GLIDE);

shouldn´t it be like this?

c_move(my, player_speed, nullvector, IGNORE_PASSABLE | GLIDE);

At all i think your code need some improvements.

Re: enemy's AI..NOT WORKING!!! [Re: Rasch] #353455
01/10/11 14:51
01/10/11 14:51
Joined: Nov 2010
Posts: 125
Germany
chrisp1 Offline
Member
chrisp1  Offline
Member

Joined: Nov 2010
Posts: 125
Germany
Hmm I think so too laugh


---------------------------------------------------
My new project: www.sfc.de.to
My old project: www.littlesubmarine.de.to
My Youtubechannel: http://www.youtube.com/user/darkchrisp#p/a/u/0/5idMXmCDdmA
---------------------------------------------------
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 Offline
Expert
EvilSOB  Offline
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: EvilSOB] #353463
01/10/11 16:12
01/10/11 16:12
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
Originally Posted By: EvilSOB
Surprised it even compiled...


Me too laugh

Re: enemy's AI..NOT WORKING!!! [Re: Rasch] #353520
01/10/11 22:50
01/10/11 22:50
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
thanks all for your replies!!! i really appreciated it laugh

btw, i did everything you'd suggested. it has no error but it hanged frown
having a self study in gs has never been easy to me... ~sigh

the code becomes like this:

Code:
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: carla_mariz] #353536
01/11/11 03:18
01/11/11 03:18
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
First, fix your indendation and accolades.
Then, remove wait(1) in camera_follow.


Click and join the 3dgs irc community!
Room: #3dgs
Re: enemy's AI..NOT WORKING!!! [Re: Joozey] #353537
01/11/11 03:39
01/11/11 03:39
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
uhm..ok, i removed the wait(1) in camera follow, but its still the same.. frown

how come..:((

Last edited by carla_mariz; 01/12/11 10:45.
Page 1 of 2 1 2

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