Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
GML question; instance_nearest and health > 0
Topic Started: Dec 22 2012, 01:11 AM (169 Views)
RonBurgundy
Member Avatar
Forum Borat
[ *  *  *  *  *  * ]
Hit another brick wall. Yet again it's AI related.

Basically what I'am aiming to do is is find the nearest instance of an ally with a health value of greater than 0 for the enemy bots.

Right now the bots just use Target = instance_nearest(x,y,parentObject) to find a target. However, when the target's health is < 0 is doesn't just destroy itself. I use SetModelMaterial to gradually fade it away until it is no longer visible and then destroy it.

While this is happening, the bot still recognizes the closest ally(the one with health < 0) as the target while there are other allies shooting at it.

I've been scouring the GMC for a solution, and found a few scripts like...

instance_nth_nearest():
Spoiler: click to toggle


Cant see how I could make it work. I was thinking about using a for loop to change the ID's but that may be a headache.

There was also an extension that would have been useful if it wasn't corrupted that would have done exactly this.

Any help is appreciated.
Edited by RonBurgundy, Dec 22 2012, 01:12 AM.
!!! DEFEND POP PUNK !!!
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
So your problem is that the allies still recognizes the other ally while it is fading? Can't you just check if the ally's alpha == 255 while it also check if health > 0?
Offline Profile Quote Post Goto Top
 
RonBurgundy
Member Avatar
Forum Borat
[ *  *  *  *  *  * ]
Kinda.
But it's the enemy bot that still recognizes the ally bot even when its health is at 0.

The enemy only targets the ally that is closest.

Lets say it kills that same ally.

instead of targeting the next closest ally it moves to its next pathfinding node, UNLESS another ally bot is closer than the dead one thats fading. Because the ally it just killed is still closest.

What I have now is something like:

Tar = instance_nearest(x,y,objBotAlly)//objBotAlly is the parent for all ally bots.
if Tar.hp > 0 and inFOV = true
{
yadayada raycasting stuff
}
!!! DEFEND POP PUNK !!!
Offline Profile Quote Post Goto Top
 
Reikyrr
Forum God
[ *  *  *  *  *  * ]
it probably is tooo late for that already but I would make a central bot instead of enemy and ally then keep track of the team inside of it. then you can make rules on how bots should act against other teams. that way if a bot dies you just set it to a team that does not get any attention.
as for targeting I would first use a bounding box or grid to determin which bots are close.
~Inspirational quote~
Offline Profile Quote Post Goto Top
 
RonBurgundy
Member Avatar
Forum Borat
[ *  *  *  *  *  * ]
Thanks for the advice. Isn't using Bounding Box for the camera though, or do you mean a different bounding box?

I do want to stay away from grids, just trying to keep things cheap and fast.
EDIT: nevermind figured out a solution thanks!

Even more off topic: Got a new headset microphone for my computador, be starting U3D titorials for GM again sometime this week
!!! DEFEND POP PUNK !!!
Offline Profile Quote Post Goto Top
 
Reikyrr
Forum God
[ *  *  *  *  *  * ]
RonBurgundy
Dec 22 2012, 03:21 AM
Thanks for the advice. Isn't using Bounding Box for the camera though, or do you mean a different bounding box?

I do want to stay away from grids, just trying to keep things cheap and fast.
EDIT: nevermind figured out a solution thanks!

Even more off topic: Got a new headset microphone for my computador, be starting U3D titorials for GM again sometime this week
I just mean the math side.
Code:
 
if (other_x < own_x+10)
if (other_x > own_x-10)
if (other_y < own_y+10)
if (other_y > own_y-10)
//other coordinates are inside a 20x20 rectangle around own coordinates.
~Inspirational quote~
Offline Profile Quote Post Goto Top
 
« Previous Topic · Off-topic · Next Topic »
Add Reply