Types question

Blitz3D Forums/Blitz3D Programming/Types question

cash(Posted 2004) [#1]
I am sorry if this has been asked a thousand time but I still have an issue here.

I am using types to allow me to create multiple enemies and apply common settings. Problem is there is a point say when enemies are chasing me, that they all group up and then start to synchronize with each other so to speak. It work great if you kill them one at a time but if more than one chases then the problem is apparent.

What I need is to use types to create the enemies, then somehow still have the ability to reference them individually or compare one "type" to another of the same "type".

Wowww is that clear or not, I hope so.


Rob Farley(Posted 2004) [#2]
Just give them all a state. Chase, attack, run away etc.

So then when an enemy wants to go into chase state it checks if any of the others are in chase state first, if they are then it won't case as well.


AntonyWells(Posted 2004) [#3]
By comparing I assume you mean to check if a type is the same..in which case you can do if myType=ThisOrThatType then doSomethingFreaky

If the types = the same object, it returns true.

or you could use handle/object to manage types manually..

Failing that, a simple 'typeID' embeded in the type should sort out any remaining issues.

-Edit- actually, re-reading I think I got the wrong of the stick..if it's just to have enemies do unique things, then state variables as rob said are the best way to go.


ryan scott(Posted 2004) [#4]
when you loop through your types, moving them, you could keep track of the position of the previous type, and if your type is too close to him, move the current type away from him a little bit.

it should cause them to space themselves out a bit. i still see a potential problem with this, but i wouldn't know if it'll be ok without trying it and without having some clue what kind of game you are talking about. a pacman situation is different than a shootemup.

you could also do this, which is heavier:
in enemytype, add a flag: movedthistime

for e1.enemy = each enemy
e1\movedthistime=false
for e2.enemy = each enemy
if e1\model<> e2\model and e1\movedthistime=false
compare e1 and e2's distance from each other
and if they are too close, move them a tiny
bit away from each other or turn them a little
away from each other.

e1\movedthistime=true
endif
next
next

i think (obviously not having tried it), that this might do something for you. i am unsure about my little flag there or if this will logically work! but it's something... also this bad boy will get slower as you add a lot of enemies but i don't think it'll be that bad.


also one important thing in all your games IMO is to add a little bit of randomness, *everywhere* that you can. It'll make the game less predictable and help avoid everything walking in lockstep.

one nice thing about 3d is not having to compute how to move away (angles to 2d), you just change the direction a character faces by a few degrees. i'm loving the 3d right now.

wouldn't mind seeing what you are trying to do, it would help.

it sounds like you are using a relatively simplistic method to have your types chase your guy, which i'm guessing is to turn to aim at him and move towards him. you probably want to make that more complex. there would be some parameters controlling how the enemy chases - how fast he turns towards the player, how far he can see (so that he chases only if the player is within his range of vision), how fast he moves, etc. if you give each enemy slightly different tweaks of these parameters, you'll start to get different behaviors out of them and they won't be able to clump up. Add a lot of simple behavior parameters to your types, is one suggestion. a lot of simple differences can add up to a significantly different behavior.


cash(Posted 2004) [#5]
Thanks for the info...I will start mods immediately.