Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 13,972 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: AI search food help [Re: Rei_Ayanami] #279190
07/16/09 20:33
07/16/09 20:33
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Your code is working like it should. It picks up the only food in the level, and since there's no more, it waits on that while(grub==NULL) line. What is it that you're trying to achieve?

If you add more food sources in your level, you'll have to face a little problem. If you assign all your food models to the same action, then the grub pointer will be assigned to the first food, then it will be overwritten and assigned to the second food source, etc. So when the game starts, the grub pointer will be assigned to the last food model. Your AI will go and eat it which makes the pointer NULL.

Take some time and learn about arrays so you can store ALL food pointers/handles to them, so if you eat the last one, it will go look for other food pointers in that array.

Cheers,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: AI search food help [Re: LarryLaffer] #279197
07/16/09 20:59
07/16/09 20:59
Joined: May 2006
Posts: 30
awstar Offline OP
Newbie
awstar  Offline OP
Newbie

Joined: May 2006
Posts: 30
Yea, i'm trying to have it walk, stand, and scan for food, or other entities nearby.

Re: AI search food help [Re: awstar] #279255
07/17/09 02:27
07/17/09 02:27
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Well, for starters replace this:

Code:
///////////////////////////////////////////
while (grub == null) //////<---------this code gets rid of empty pointer error, but freezes the AI after he picks up the food.
{wait (1);}
if (vec_dist (my.x, grub.pos) < 200) // the player approaches the food
{

// name_ent2();
vec_set(temp, grub.pos);
vec_sub(temp, my.pos);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac smile
walk_speed.x = 10 * time;
walk_speed.y = 0;
walk_speed.z = 0;
ent_move(creature_distance, nullvector);
ent_cycle("walk", my.skill19); // play walk frames animation
my.skill19 += 5 * time; // "walk" animation speed
// ent_playsound (my, walk_snd, 50);

wait (1);

}



with this:

Code:
///////////////////////////////////////////
if (grub != null)
{
if (vec_dist (my.x, grub.pos) < 200) // the player approaches the food
{

// name_ent2();
vec_set(temp, grub.pos);
vec_sub(temp, my.pos);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac smile
walk_speed.x = 10 * time;
walk_speed.y = 0;
walk_speed.z = 0;
ent_move(creature_distance, nullvector);
ent_cycle("walk", my.skill19); // play walk frames animation
my.skill19 += 5 * time; // "walk" animation speed
// ent_playsound (my, walk_snd, 50);

wait (1);

}
}



This will prevent it from crashing or freezing after the bots gets the food, but you still have problems if multiple food models are in the level (all but one will be ignored)

Teach yourself about arrays and you may also want to consider moving from c-script to lite-c so you can use ENTITY* arrays instead of having to deal with handles.

Cheers,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: AI search food help [Re: LarryLaffer] #279860
07/19/09 16:30
07/19/09 16:30
Joined: May 2006
Posts: 30
awstar Offline OP
Newbie
awstar  Offline OP
Newbie

Joined: May 2006
Posts: 30
i tried looking up arrays but it seems confusing, if anyone knows how an example using this template, it would be appreciated, thx all!

Re: AI search food help [Re: awstar] #279878
07/19/09 19:14
07/19/09 19:14
Joined: May 2006
Posts: 30
awstar Offline OP
Newbie
awstar  Offline OP
Newbie

Joined: May 2006
Posts: 30
can someone write an example using arrays with entities? or where i can find info on it? did a aum search but didn't find anything.

Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | 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