Select an enemy

Blitz3D Forums/Blitz3D Programming/Select an enemy

RGF(Posted 2009) [#1]
Need ideas for this...

We are in a cooperative 3rd. person game, where you control a single character.

There are some enemies, whose characteristics are defined in a type with various fields...

There are some allies, whose characteristics are also in a type...

The main player walks through a battlefield, with some allies...

When they reach the enemies' land, these start attacking...

Let's say each of these enemies has to choose one particular objective, which could be the player or an ally. And then, moves towards this objective and starts attacking when they are close enough.

Now the questions:

Which procedure would you use to choose one particular objective? Checking the distance? entitypick? linepick?


Guy Fawkes(Posted 2009) [#2]
use entitypick


Ross C(Posted 2009) [#3]
A distance check would probably be quicker to be honest. You could do a simply angle check, to see if the player/ally is within their field of view.

Using picks is fairly slow depending on distance. The only real reason i personally use a linepick, is for collision, when the blitz collision system isn't much use.

As for choosing which objective the enemy should have is a different matter. :)


RGF(Posted 2009) [#4]
I think distance is better, but here comes the problem with distance... Checking distance from one enemy to several allies, store it somehow (I don't know how), compare the distances, and then choose the closest ally as objective... and that's just from one enemy... if there are 20 enemies, gives me headache. Cheers!


RGF(Posted 2009) [#5]
How they make this stuff in RTS games? any ideas?


Guy Fawkes(Posted 2009) [#6]
try:

global selectedenemy

global maxenemies = 20

global pid = 1

global myplayer = pid

dim player(myplayer)

player(id) = loadanimmesh("mesh.x")

global eid = 1

dim enemy(maxenemies-1)

for x = 1 to maxenemies
if x = 1 then enemy(x) = loadanimmesh("enemyx.x")
next

global maxdist# = 3.0
global maxenemies = 20

for x = 1 to maxenemies
if distance(enemy(x)) <= maxdist#
if enemy(x) ;if enemy x then activate...
selectedenemy = enemy(x)
pointentity enemy(x), player(myplayer)
endif
endif
next

while not keyhit(1)
updateworld()
renderworld()
for x = 1 to maxenemies
if selectedenemy = enemy(x)
text 10, 10, "enemy: "+selectedenemy+" has joined team!"
delay 1000
cls
endif
next
flip
wend



Ross C(Posted 2009) [#7]
Well, distance checking is extremely quick. You could use an array to hold the current list of enemies/allies closest, or a type collection. I tend not to use types when objects are being created and destroyed, as there is a speed difference. I found that out when doing path finding with type objects.

Anyway, you don't want to be checking every enemy in the land, unless it's necessary. You could implement checking on a per screen basis, or section the world into grids, and check the surrounding grid locations. Then just compare against the enemies/allies in those sections.

If your search returns nothing, expanding the distance, or say that nothing was found. I believe in RTS, path finding is one of the most important aspects. That's why i steer clear!


RGF(Posted 2009) [#8]
This is more a question for an RPG than a RTS... I managed to finish coding some kind of solo-player Diablo-I style (in 3d) with inventory and level up stuff... and it works just fine. The method my creatures used for attacking is simple distance checking: when the player isn't too far, they detect the player (or not) and move...
Just wondered what would it be to add some extra allied players... the thing gets more difficult... I know path finding is one of your skills, and truly it is the core of RTS games. I'm going to try to expand this RPG project with some allies, and tell you the results. See ya!


Bobysait(Posted 2009) [#9]
Use a quadtree and only check ennemies in nodes around the player with distance test, then using a "TFormPoint 0,0,0,ennemy,player" you can test if TFormedZ()>0 ennemy is front, else, ennemy is back the player