Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,246 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to turn something on when object comes too close to AI obj? #353908
01/14/11 03:26
01/14/11 03:26
Joined: Jan 2011
Posts: 5
D
Dontstealmyfood Offline OP
Newbie
Dontstealmyfood  Offline OP
Newbie
D

Joined: Jan 2011
Posts: 5
I need to turn on a function or just make something happen when my player object gets close enough to my one of my AI objects but have no clue how to make it work? PS I use lite-c...

Re: How to turn something on when object comes too close to AI obj? [Re: Dontstealmyfood] #353909
01/14/11 04:56
01/14/11 04:56
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Code:
function AIObject()
{

while(vec_dist(my.x,player.x) > 200){wait(1);}

// player is closer than 200 to me, do something...

}



Re: How to turn something on when object comes too close to AI obj? [Re: DJBMASTER] #353910
01/14/11 05:07
01/14/11 05:07
Joined: Jan 2011
Posts: 5
D
Dontstealmyfood Offline OP
Newbie
Dontstealmyfood  Offline OP
Newbie
D

Joined: Jan 2011
Posts: 5
Many thanks man!!!

Re: How to turn something on when object comes too close to AI obj? [Re: Dontstealmyfood] #353931
01/14/11 10:12
01/14/11 10:12
Joined: Dec 2010
Posts: 12
P
Psygnal Offline
Newbie
Psygnal  Offline
Newbie
P

Joined: Dec 2010
Posts: 12
Oh good lord. That'll teach me to read the bloody manual properly.
I was checking distance using a rather more cumbersome formula. laugh

Re: How to turn something on when object comes too close to AI obj? [Re: Psygnal] #354008
01/14/11 18:26
01/14/11 18:26
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
vec_dist() is the best. You can also use it instead of c_scan sometimes when you only have a specific entity in mind for scanning. Just like this AI example. Your enemies could scan every frame for the player, which is slow, or they could just check how far away he is, which is fast.


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