Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (AndrewAMD, Quad, soulman3, Ayumi), 675 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Ai does nothing!!! [Re: Random] #343905
10/11/10 14:31
10/11/10 14:31
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
is written the function "function enemy_dummy_combat()" in your enemy action
in a while-loop?

Re: Ai does nothing!!! [Re: jane] #343906
10/11/10 14:59
10/11/10 14:59
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Yes, it`s in a loop;

..........
while(my.health > 0)
{
enemy_dummy_combat();

..........



Re: Ai does nothing!!! [Re: Random] #343908
10/11/10 16:39
10/11/10 16:39
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
here a sample to handle the AI (havnt testet):

Code:
var set_stafe_time = 0;

function stafe_time_set()
{
	if(set_stafe_time == 0)
	{
		stafe_time = 1 + random(2);
		stafeing_direction = integer(random(4));
		set_stafe_time = 1;
	}
}

function enemy_dummy_combat()
{
	VECTOR enemy_dummy_speed;
	
	stafe_time_set();
	
	if (vec_dist (my.x, player.x) > 500)  
	{		
		while (stafe_time > 0)
		{
			stafe_time -= time_step / 16;
			
			if(stafeing_direction == 0)
			{
				enemy_dummy_speed.x = 5 * time_step;
				enemy_dummy_speed.y = 0;
				enemy_dummy_speed.z = 0;
				c_move (my, enemy_dummy_speed, nullvector, IGNORE_PASSABLE | GLIDE);
				ent_animate(my, "stafe_forward", anim_percentage, ANM_CYCLE);
				anim_percentage %= 100;
				anim_percentage += 8 * time_step;
			}
			
			if(stafeing_direction == 1)
			{
				enemy_dummy_speed.x -= 5 * time_step;
				enemy_dummy_speed.y = 0;
				enemy_dummy_speed.z = 0;
				c_move (my, enemy_dummy_speed, nullvector, IGNORE_PASSABLE | GLIDE);
				ent_animate(my, "stafe_backward", anim_percentage, ANM_CYCLE);
				anim_percentage %= 100;
				anim_percentage += 8 * time_step;
			}
			
			if(stafeing_direction == 2)
			{
				enemy_dummy_speed.x = 0 * time_step;
				enemy_dummy_speed.y = 5;
				enemy_dummy_speed.z = 0;
				c_move (my, enemy_dummy_speed, nullvector, IGNORE_PASSABLE | GLIDE);
				ent_animate(my, "stafe_left", anim_percentage, ANM_CYCLE);
				anim_percentage %= 100;
				anim_percentage += 8 * time_step;
			}
			
			if(stafeing_direction == 3)
			{
				enemy_dummy_speed.x = 0 * time_step;
				enemy_dummy_speed.y -= 5;
				enemy_dummy_speed.z = 0;
				c_move (my, enemy_dummy_speed, nullvector, IGNORE_PASSABLE | GLIDE);
				ent_animate(my, "stafe_right", anim_percentage, ANM_CYCLE);
				anim_percentage %= 100;
				anim_percentage += 8 * time_step;
			}
		}
		set_stafe_time = 0;
	}
	if (vec_dist (my.x, player.x) < 500)
	{
		vec_set(temp, player.x);
		vec_sub(temp, my.x);
		vec_to_angle(my.pan, temp);
		my.tilt = 0;
		
		//is the distance > 200, enemy wait and stand
		if (vec_dist (my.x, player.x) >= 200) 
		{		
			ent_animate(my, "stand", anim_percentage, ANM_CYCLE); 
			anim_percentage += 1 * time_step;
		}
		
		//is the distance < 200, enemy go to the player to distance 50
		if ((vec_dist (my.x, player.x) < 200)&&(vec_dist (my.x, player.x) > 50)) 
		{		
			enemy_dummy_speed.x = 5 * time_step;
			enemy_dummy_speed.y = 0;
			enemy_dummy_speed.z = 0;
			c_move (my, enemy_dummy_speed, nullvector, IGNORE_PASSABLE | GLIDE);
			ent_animate(my, "stafe_forward", anim_percentage, ANM_CYCLE);
			anim_percentage += 8 * time_step;
			
			if (my.hit_by_player == 1) //by attack from player
			{
				//here your enemy attack function
			}
		}
	}
}



Re: Ai does nothing!!! [Re: jane] #343926
10/11/10 20:24
10/11/10 20:24
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
he moves (realy fast) for like an half seconde in a direktion (randomly :D), and disapirs.
then hes just gone...

Last edited by Random; 10/11/10 20:25.


Re: Ai does nothing!!! [Re: Random] #343936
10/12/10 03:52
10/12/10 03:52
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
its just a sample, in the code moves the enemy 5 quant per frame.
use 0.5 or 0.05 or other values for the speed and adjust the animation-speed (anim_percentage += ...).

Last edited by jane; 10/12/10 03:56.
Re: Ai does nothing!!! [Re: jane] #343975
10/12/10 14:57
10/12/10 14:57
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Thabks for the tipp but, nop...
Still the same problem.
Any geniuses out there, that knows the problem?
This is getting realy frustrating.



Re: Ai does nothing!!! [Re: Random] #343997
10/12/10 17:53
10/12/10 17:53
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
zip your project with a simple level with password ... and uplod it at filefront.
send me the link and the password per PM. i will take a look on it.

Re: Ai does nothing!!! [Re: jane] #344042
10/13/10 07:58
10/13/10 07:58
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Thanks bro wink



Re: Ai does nothing!!! [Re: Random] #344111
10/14/10 06:22
10/14/10 06:22
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
you have a PM with a link to the corected project

have fun

Re: Ai does nothing!!! [Re: jane] #349015
12/03/10 03:41
12/03/10 03:41
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline
Junior Member
carla_mariz  Offline
Junior Member
C

Joined: Sep 2010
Posts: 97
@Random & @jane, can i have it too? please???? i have the same problem and i'm actually looking for that...thanks in advance! hope u can help me guys! laugh

Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

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