The Daily Click ::. Forums ::. Klik Coding Help ::. Mass Producing Enemies
 

Post Reply  Post Oekaki 
 

Posted By Message

JetpackLover



Registered
  01/03/2007
Points
  212
2nd September, 2007 at 07:53:25 -

I like the type of coding in a game that lends itself to low, or 1 set of code. But I have a problem, I'm not exactly sure how to go about that.

I'm making a game right now that has enemies that run away from you, and so far I have made 1 AI with : "detectors, health bar, and other items". Question is, How would I go about copying this enemy around. All the code I wrote pertains to just this enemy, and I imagine if I were to copy it; what happens to one will happen to the other.

So, how do you guys make a really complex enemy with grouped events, health bars, detectors, etc and then mass produce it without copying events and/or changing the active object/counter which goes with it.

I just want one set of enemies per enemy type. I guess that would be the summary of this post.

Whatever makes level design easier is what I want to use.(codewise and design wise)

**I mean mass producing as a general phrase for copying out of run time, not in.**

...sorry about my broken English I'm actually attending a writing class right now so I'm hoping that improves.

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Hernan



Registered
  04/03/2003
Points
  707

VIP Member
2nd September, 2007 at 08:14:34 -

It should be possible to do this. However it can be quite tricky. Using detectors for every enemy is possibly the most difficult one, so I advice to read this article: http://www.create-games.com/article.asp?id=1639 where you embed the detectors in the animation of every enemy.

Obviously, health and such things should be organized by using alterable values. I'm not sure what you mean with health bar, like every enemy should display its health above them? (sorta like in RTS games) In that case, it's possible to create multiple counters that follow and display each enemy's health.
eg:
Number of counter< Number of enemies => create counter at (0,0) of enemy
Always => set position etc.. and set value to Alterable Value etc...

So if you understand what I said above: it's completely possible, but you'll probably need to recode some stuff.

Image Edited by the Author.

 
This space is for rent

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
2nd September, 2007 at 16:05:59 -

One of the things I hate about mmf is the lack of control over object instances. Specifically the whole 'object focus' thing pisses me off.

Anyways...

Consider how many enemies you will have at the same time on-screen or active at the same time. Many games never have the player engaging in more than 5 or 6 enemies at the same time. In this case you can just have 5 sets of enemies, detectors, health bars etc. Not very elegant but effective. It also allows for VERY complex AI/detector operations. But ya, this depends on what kind of game your making.

Zi-Xiao

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
3rd September, 2007 at 06:12:42 -

Spread a value in all enemies, detectors and health bars, and use a fastloop to attach them to their respective enemies. Like this:

* Always
- Enemy: Spread value 0 in Value A
- Detector: Spread value 0 in Value A

* Always
- Start fastloop "foo" NObjects("Enemy") times

*On loop "foo"
* Value A of "Enemy" == LoopIndex("foo")
* Value A of "Detector" == LoopIndex("foo")

- Detector: Set position to (0,0) from Enemy


 
n/a

Milo



Registered
  17/09/2005
Points
  223
5th September, 2007 at 13:36:07 -

Use alterable values.
*Alterable Value x = 0: Destroy enemy
*Collisions between Weapon and Enemy: Subtract x from alterable value x
*(When you wana make and enemy): Create enemy at where ever (out of frame for random position) set Alterable Value x to x.
Anything else need at start up can be added to another Alterable Value. To give an enemy a tag so it can be found later, on creation: Set alterable value x to Counter. Add 1 to counter. If you want them to fire at certain times,
*Always: Add 1 to Alterable Value x (Repeats 50 times a second)
*Alterable Value x = x: Set alterable value x to 0, Shoot an object from enemy.
If the enemies have a lifespan or something to make them massively do something loop:
*Alterable value x = 0: do ____, set Alterable value x to 1.
Then loop
*Alterable value x = 1: Set alterable value x to 0.
If it's timed then use a counter.

Also you can use arrays (You might need a 3D array though)

Image Edited by the Author.

 
I've wasted my life.
I don't plan on stopping.

ReiKGT



Registered
  09/08/2007
Points
  46
7th September, 2007 at 22:48:22 -

I was just gonna ask this, Luuuuuucky!

 
"last one left to die, please turn out the light."
The human child body template used in my avatar was made by Show Kaizer who can be found on rmxp.org forums.
   

Post Reply



 



Advertisement

Worth A Click