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 (Ayumi), 662 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
AI Don't Move #407582
09/16/12 10:08
09/16/12 10:08
Joined: May 2010
Posts: 41
İstanbul/Turkey
Sorrowful Offline OP
Newbie
Sorrowful  Offline OP
Newbie

Joined: May 2010
Posts: 41
İstanbul/Turkey
Code:
ENTITY* dusman_en;
var tarat_v;
VECTOR don_dus;
var dusmanslm;
var tarat_v_d;

action dusman()
{
	dusman_en = me;
	c_setminmax(me);
	//dusman_en.lightrange = 200;
	//vec_set(dusman_en.blue,vector(255,0,0));
	while(1)
	{
     tarat_v = c_scan(my.x,my.pan,vector(150,0,1000),SCAN_ENTS|IGNORE_PASSABLE);
     if(tarat_v > 0&&you==player)
     {
     c_move(me,vector(14*time_step,0,0),nullvector,GLIDE);
     ent_animate(me,"walk",dusmanslm,ANM_CYCLE);
     dusmanslm += 3.13*time_step;
     vec_set(don_dus,player.x);	
     vec_sub(don_dus,my.x);
     vec_to_angle(my.pan,don_dus);
     tarat_v_d = c_scan(my.x,my.pan,vector(5,0,5),SCAN_ENTS|IGNORE_PASSABLE);
     if(tarat_v_d>1)
     {
     	ent_animate(me,"scatt",my.skill2,ANM_CYCLE); // hit
     	my.skill2 += 2;
     }
     }
    wait(1);
	}
}



Character don't move...Only turning And doesnt scatt animation

Last edited by Sorrowful; 09/16/12 10:12.

A8.40 Professional
Sancak Oyun Ekibi
Re: AI Don't Move [Re: Sorrowful] #407583
09/16/12 10:41
09/16/12 10:41
Joined: Apr 2008
Posts: 245
GameScore Offline
Member
GameScore  Offline
Member

Joined: Apr 2008
Posts: 245
take a look at aum 57
there is a nice example for an ai

Code:
action my_enemy // attach this action to your enemies
{
	var idle_percentage = 0;
	var run_percentage = 0;
	var death_percentage = 0;
	var content_right; // tracks the content in front of the player
	var content_left; // tracks the content in front of the player
	my.polygon = on; // use accurate collision detection
	my.health = 100;
	my.enable_impact = on; // the enemy is sensitive to impact with player's bullets
	my.event = got_shot; // and runs this function when it is hit
	my.status = idle; // that's the same thing with my.skill1 = 1; (really!)
	while (my.status != dead) // this loop will run for as long as my.skill1 isn't equal to 3
	{
		if (my.status == idle) // hanging around?
		{
			ent_animate(my, "stand", idle_percentage, anm_cycle); // play the "stand" aka idle animation
			idle_percentage += 3 * time; // "3" controls the animation speed
			if (vec_dist (player.x, my.x) < 1000) // the player has come too close?
			{
				// scanned in the direction of the pan angle and detected the player?
				if ((c_scan(my.x, my.pan, vector(120, 60, 1000), ignore_me) > 0) && (you == player))
				{
					my.status = attacking; // then attack the player even if it hasn't fired at the enemy yet
				}
			}
		}
		if (my.status == attacking) // shooting at the player?
		{
			// the road is clear? then rotate the enemy towards the player
			if (c_content (content_right.x, 0) + c_content (content_left.x, 0) == 2) 
			{
				vec_set(temp, player.x); 
				vec_sub(temp,my.x); 
				vec_to_angle(my.pan, temp); // turn the enemy towards the player
			}
			if (vec_dist (player.x, my.x) > 500)
			{
				vec_set(content_right, vector(50, -20, -15));
				vec_rotate(content_right, my.pan);
				vec_add(content_right.x, my.x);
				if (c_content (content_right.x, 0) != 1) // this area isn't clear?
				{
					my.pan += 5 * time; // then rotate the enemy, allowing it to avoid the obstacle
				}
				vec_set(content_left, vector(50, 20, -15));
				vec_rotate(content_left, my.pan);
				vec_add(content_left.x, my.x);
				if (c_content (content_left.x, 0) != 1) // this area isn't clear?
				{
					my.pan -= 5 * time; // then rotate the enemy, allowing it to avoid the obstacle
				}
				c_move (my, vector(10 * time, 0, 0), nullvector, glide);
				ent_animate(my, "run", run_percentage, anm_cycle); // play the "run" animation
				run_percentage += 6 * time; // "6" controls the animation speed
			}
			else
			{
				ent_animate(my, "alert", 100, null); // use the last frame from the "alert" animation here
			}
			if ((total_frames % 80) == 1) // fire a bullet each second
			{
				vec_for_vertex (temp, my, 8);
				// create the bullet at enemy's position and attach it the "move_enemy_bullets" function
				ent_create (bullet_mdl, temp, move_enemy_bullets); 
			}
			if (vec_dist (player.x, my.x) > 1500) // the player has moved far away from the enemy?
			{
				my.status = idle; // then switch to "idle"
			}
		}
		wait (1);
	}
	while (death_percentage < 100) // the loop runs until the "death" animation percentage reaches 100%	
	{
		ent_animate(my, "deatha", death_percentage, null); // play the "die" animation only once
		death_percentage += 3 * time; // "3" controls the animation speed
		wait (1);
	}
	my.passable = on; // allow the player to pass through the corpse now
}


Re: AI Don't Move [Re: Sorrowful] #407584
09/16/12 10:44
09/16/12 10:44
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Probably stuck somehow, BTW does your model contain "walk" and/or "scatt" animations?

Edit: try this one, I've edited it a little bit:
Code:
action dusman()
{
	VECTOR temp;
	var scan_result[2];
	var animation_percent[3];
	// wait till player is created!
	while(!player){ wait(1); }
	
	c_setminmax(me);
	while(1)
	{
		// scan for player:
		move_mode = SCAN_ENTS | IGNORE_PASSABLE;
		scan_result[0] = c_scan(my.x, my.pan, vector(150, 0, 1000), move_mode);
		// if found one:
		if(scan_result[0] > 0 && you == player)
		{
			// handle animations:
			move_mode = SCAN_ENTS | IGNORE_PASSABLE;
			scan_result[1] = c_scan(my.x, my.pan, vector(5, 0, 5), move_mode);
			if(scan_result[1] > 1)
			{
				// if near something (I don't really know why you scan again..)
				ent_animate(me, "scatt", animation_percent[0], ANM_CYCLE); // hit
				animation_percent[0] += 2 * time_step; // DON'T FORGET TO USE "time_step" !!
			}
			else{
				// walk here!!
				ent_animate(me, "walk", animation_percent[1], ANM_CYCLE);
				animation_percent[1] += 3.13 * time_step;
			}
			
			// turn to player:
			vec_set(temp, player.x);	
			vec_sub(temp, my.x);
			vec_to_angle(my.pan, temp);
			// don't allow to change TILT (looks weird):
			my.tilt = 0;
			
			// move to target:
			move_mode = IGNORE_PASSABLE | GLIDE;
			c_move(me, vector(14 * time_step, 0, 0),nullvector, move_mode);
		}
		else // if player wasn't found:
		{
			// play stand animation here:
			ent_animate(me, "stand", animation_percent[2], ANM_CYCLE);
			animation_percent[2] += 2 * time_step;
		}
		wait(1);
	}
}

I didn't test it, but it shouldn't crash. Plus, it's better organized! You should always take care of that, to make your script more readable. And you also, should handle such situations, where "player" wasn't found (add). And script should work with multiply bots at the same time, cause of using external variables and vector (better use skills for this). Please, read comments, I hope this will be useful.

Last edited by 3run; 09/16/12 10:58.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: AI Don't Move [Re: 3run] #407585
09/16/12 10:50
09/16/12 10:50
Joined: May 2010
Posts: 41
İstanbul/Turkey
Sorrowful Offline OP
Newbie
Sorrowful  Offline OP
Newbie

Joined: May 2010
Posts: 41
İstanbul/Turkey
model have walk and scatt animation

but but I want to make an enemy approaches scatt animation


A8.40 Professional
Sancak Oyun Ekibi
Re: AI Don't Move [Re: Sorrowful] #407586
09/16/12 11:04
09/16/12 11:04
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Try script which I've added. Plus, could you explain what are you trying to archive with "scatt" animations and second "c_scan".


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: AI Don't Move [Re: 3run] #407588
09/16/12 12:26
09/16/12 12:26
Joined: May 2010
Posts: 41
İstanbul/Turkey
Sorrowful Offline OP
Newbie
Sorrowful  Offline OP
Newbie

Joined: May 2010
Posts: 41
İstanbul/Turkey
why don't move? c_move?


A8.40 Professional
Sancak Oyun Ekibi
Re: AI Don't Move [Re: Sorrowful] #407592
09/16/12 13:00
09/16/12 13:00
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
which animation does model play?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

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