Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Intersect object with arrayed enemies (DBPro)

Author
Message
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 16th Jan 2006 12:34
Hi guys,

Been working through the tuts on here (which are fantastically done), espectially the FPS ones.

I am having a little trouble getting the intersect object function to work, however, when using enemies called from an array at the top.

Say I have enemy(e). = enemies
enemies = 10
and the enemy variables called afterwards and the media required to actually make the enemies.

This all works fine. I have the states set up so they wander and attack me if close etc.

My problems occur when trying to get it so my player can shoot the enemy objects.

I can do this fine using the intersect object function when I only have 1 enemy made without arrays. I just follow the syntax of the function through and if any of the x,y or z from my bullet intercept limb are >1 - then DEC enemy HP - 10 (or enemy.hp=enemy.hp-10)

What I believe I am getting confused with is how to display the arrayed enemy in the Intersect syntax.

Can anyone shed any light?

The tuts Ive seen all relate to just using one enemy - which is easy enough as I can just call the object number (2 or 3 or whatever).

Am I going about this wrong? Do I instead need to call the enemy(e) x, y & z posiions as seperate variables and then use them in a different way?

Apologies if this is a bit thin - I dont have the code to hand on this PC, so I apologies for that.

Any help much appreciated.

Mabuggi

DAB Studios
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 16th Jan 2006 13:45
Hi,

I've been looking at the same thing. While your enemy data is contained in arrays, each of the actual enemies will have an individual and unique object number, for example enemies(1-10) are object numbers 21-30 and you need to link the two together. Your collision or intersect command will return the object collided with so if you had a variable (objhit) which returned a collision with object 26 you could apply it to your enemy arrays by enemies(objhit-20).

If you've got a lot of different objects which could be hit you'd need to filter the collision check so that if objhit was between a certain range the -20 would change to refer to the required variable/array reference.

This is the way I've been thinking of doing it - where I've got 10 levels, each with 10 enemies on it:
Level 1 enemies(1-10) = objects 101-110
Level 2 enemies(11-20) = objects 111-120
Level 3 enemies(21-30) = objects 121-130

In this case decrementing 100 from the returned collision variable to give the array containing the enemy data =enemies(objhit-100).

I'd be interested in hearing if there's a better way of doing it as it seems a bit cumbersome!
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 16th Jan 2006 18:27
CHeers for this StevetS,

I shall attempt this this evening and let you know how I get on.

When you say
Quote: "for example enemies(1-10) are object numbers 21-30"
do you mean that they default to these objects - or they are user defined?

I mean - if I made an array enemies=10, then would the enemy objects default to object numbers 21-30?

Thanks for your speedy reponse

DAB Studios
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 16th Jan 2006 21:43 Edited at: 16th Jan 2006 21:45
No, the object numbers can be anything and are in no way tied to the variables or arrays for your enemies.

You could have enemy(12) linked to object 132 by using the object collision command (which will return 132 when hit) and having it interact with enemy(132-120) :its the 120 in this case which links the object and its variables.

In pseudo-code (not real code):



This may be suitable for slow moving missiles you want to see, but you don't want to be creating objects for fast moving bullets, i.e from a gun!

As noted above, I'd be interested to know if there's a more streamlined way of doing this!
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 17th Jan 2006 12:32 Edited at: 17th Jan 2006 12:43
right right right - Im with you stevetS!

Hmmm your right, though, this wouldn't be so hot if wanting to use modern day bullets, which of course you cant really see or dont want to have to make objects for projectiles.

Im gonna do some more digging - Will post as soon as I have anything to report -

I have a bullet intersection limb set up and tested on multiple enemies last night (non arrayed ) and it worked perfectly.

I just need to get this damn intersection on arrays working other wise my code is gonna be H U G E !!!

Lol

Cheers mate.

DAB Studios
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 18th Jan 2006 15:52
StevetS

Right - I figured it out last night!

With the help of zotoasters A.i. tutorial (awesome).

I dont have the code to hand (Im at work) -

But will post it up tomorrow for ya.



DAB Studios
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 18th Jan 2006 23:04
Hi,

Yup - I think thats pretty much how Zo did it in his tut.

Quote: "
First=10:`This is the first object used for the enemies
For e=1 to enemies
make object cube first+e,50
position object first+e,enemy(e).x,enemy(e).y,enemy(e).z
next e
"


It looks like the 'first' variable is the one that ties the objects to the arrays/variables so object 11 relates to enemy 1 which is (e).

Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 19th Jan 2006 12:24 Edited at: 19th Jan 2006 16:05
HAAAAAAAAAAAAAAA!!!!

Excellent.

Im getting this now - THANK YOU StevetS.

Great help buddy - I think the penny has dropped......


EDIT - Yeah, this is why i can only have 5 enemies at the mo - cos I already use objects 11-15 as ammo boxes.........

Perfect - I think I get it now. I owe ya a beer.

DAB Studios

Login to post a reply

Server time is: 2024-09-24 13:32:47
Your offset time is: 2024-09-24 13:32:47