Handling enemies

Discussion about everything. New games, 3d math, development tips...
Post Reply
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Handling enemies

Post by monkeycracks »

Well, I figure I'll ask here and get some opinions before I implement this the wrong way and frustrate myself...

What is the best way to handle multiple enemies? Let's say in my server I do this :

createNewEnemyNode()
{
EnemyNode* eNode = new EnemyNode();//it's a class, it contains the health int.
eNode->Mesh = blahblah...etc.
}

Now let's say a player damages this 'EnemyNode' but there are four others currently spawned. How will I remove it from this class' health integer and not all four others. Would it automatically know which because a 'new class' is created for each entity?

Thanks in advance...
Phant0m51
Posts: 106
Joined: Mon Jan 15, 2007 6:07 am

Post by Phant0m51 »

Well you could assign a new ID for each enemy node, then you could handle it that way.
Anteater
Posts: 266
Joined: Thu Jun 01, 2006 4:02 pm
Location: Earth
Contact:

Post by Anteater »

My programming skills are none-too-good, but I think if the enemy class contains a scene node for the enemy, you can just use the node's ID.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Yes but the ID would (after some time) get too high and hit that certain limit that s32's or int's or whatever I use has :P

Then again, that'll never happen. I don't think I should have to do too much since each enemy is a new version of the class..

But I may be wrong, I'll assign ID's as well, though how would I use that to detect who was hit and how much to subtract?
Phant0m51
Posts: 106
Joined: Mon Jan 15, 2007 6:07 am

Post by Phant0m51 »

As far as the problems with the id's getting too high, don't worry about that. Just start re-using the ID's after the enemies have died and their nodes have been deleted.

You could just do some picking to find which nodes are the ones being hit, and using their ID's to remove health. Depending on what type of attacks your players will be doing, you could just use bounding boxes, or hitboxes (if you're using a physics engine).
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Ahh.
I've decided to do the ID's. That way it'll make handling them in different ways easier as well.

Thanks everyone.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

monkey, irrNet already has IDs for everything. It also has "CustomVars" which you can use as health etc. Im sure I already explained all this...
Post Reply