The Daily Click ::. Forums ::. Klik Coding Help ::. multi-part enemies
 

Post Reply  Post Oekaki 
 

Posted By Message

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
21st November, 2007 at 13:38:58 -

I'm sure a thread on this exists but I can't find it.

How would I make associations between objects such that each 'enemy' object has a 'weapon' object associated with it? Furthermore, how can create some sort of hierarchy of control (ie. does the enemy object control the weapon object, or does the weapon object control the enemy object?)

As always, mmf isn't the most cooperative software. So far I've tried doing this:

Start of Frame
- spead value 0 in 'enemy' value A


Start of Frame
- if weapon is overlapping enemy
THEN
- 'weapon' value A = 'enemy' value A


if weapon value A = enemy value A
- set weapon at (0,0) relative to enemy


This doesn't work. I tried the same method with fixed values as opposed to the spread value. No luck. Any ideas?

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
21st November, 2007 at 14:44:12 -

The issue you're running into is when two enemies overlap, correct?

 
Craps, I'm an old man!

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
21st November, 2007 at 14:50:25 -

What is the actual problem, do the values of the weapons change at all?

 
n/a

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
21st November, 2007 at 15:59:04 -

Shab:
No, the code executes when the program begins

Whats actually happening is the values of the weapons are messed up. For example, lets say I've got enemy1, enemy2, weapon1 and weapon2. enemy1 is overlapping weapon1 when the frame starts and enemy is overlaping weapon2 when the frame starts. For some reason, weapon1 gets the value of enemy2 and weapon2 gets the value of enemy1.

^^BUT DISREGARD ALL THAT^^ I just wrote all that to demonstrate how much of an illogical bitch, mmf can be.

I'm looking for new ways to create associations between two objects.

 
n/a

erghhhhx



Registered
  15/11/2007
Points
  311

Mushroom
21st November, 2007 at 18:58:55 -

Use action points and hot spots.

Example:

ALWAYS:
Set Sword position at (0,0) from Monster (action point)

Make sure the action point is placed right in every frame (if its an animated bad guy)

 
n/a

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
21st November, 2007 at 20:55:57 -

That doesn't work for a few key reasons.

1. If the number of enemies and weapons are different, strange things will happen
2. There is no relation made between the enemy and weapon therefore neither object can 'talk' with the other. For example, if the enemy shoots a bullet, I can't tell the relative weapon to play the shooting animaton.
3. Similar to the point above, if an enemy dies, there is no way to tell which weapon is associated with that enemy (and therefore also needs to be destroyed)

The whole point of this thread is asking how to acreate ASSOCIATIONS between objects. Not simply sticking two objects together.

 
n/a

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
22nd November, 2007 at 06:20:24 -

You last line:
if weapon value A = enemy value A
- set weapon at (0,0) relative to enemy

should be in a loop (two loops I think, one that goes through all enemies and one that goes through all weapons). MMF only goes through every event just once, so it'll take the last weapon created and last enemy created and starts comparing, whereas you want all weapons and all enemies to be examined.

Toxic Avenger's example does work. Even though there isn't anything that relates weapons and enemies, MMF does some magic and it'll work. Doesn't make sense, but I think it's an exception CT build in.

 
This space is for rent

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
22nd November, 2007 at 08:53:03 -

First, assign an unique ID to all guns and enemies using "spread a value":

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


Then, balance the number of enemies and guns using a fastloop:

* Always
- Run loop "foo" NObjects("Enemy") times

* On loop "foo"
* NObjects("Enemy") < NObjects("Gun")
* Pick one "Gun"
- Gun: Destroy

* On loop "foo"
* NObjects("Enemy") > NObjects("Gun")
- Create "Gun" at (-100, -100)


Then, use a fastloop and the IDs you just assigned to the objects to associate them to each other. As an example, I will attach them to each other, like so:

* Always
- Start loop "bar" NObjects("Enemy")

* On loop "bar"
* Value A of "Enemy" == LoopIndex("bar")
* Value A of "Gun" == LoopIndex("bar")
- Gun: Set position to (0,0) from "Enemy"


Hope this helps!

Image Edited by the Author.

 
n/a

Willy C



Registered
  14/02/2004
Points
  1524

Game of the Week WinnerKlikCast StarPicture Me This -Round8- Winner!VIP MemberWii OwnerIt's-a me, Mario!Hero of TimeThe Cake is a LiePS3 OwnerI am an April Fool
Batman!Teddy Bear
22nd November, 2007 at 11:52:40 -

I've done something similar before.
How about doing this:

if weapon value A = enemy value A
And weapon colliding with Enemy
- set weapon at (0,0) relative to enemy


Also try to change colliding with overlapping.

 
http://www.robocaptain.com

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
23rd November, 2007 at 02:05:10 -

Just try my code. It should work, I've done it many times before.

And if it doesn't, I can make an example MFA... =/

 
n/a

Willy C



Registered
  14/02/2004
Points
  1524

Game of the Week WinnerKlikCast StarPicture Me This -Round8- Winner!VIP MemberWii OwnerIt's-a me, Mario!Hero of TimeThe Cake is a LiePS3 OwnerI am an April Fool
Batman!Teddy Bear
23rd November, 2007 at 05:23:08 -

Yeah, do that, just realized what I just said doesn't work

 
http://www.robocaptain.com

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
23rd November, 2007 at 18:26:28 -

Axel, your code's logic is impeccable. Unfortunately, MMF's operating process isn't. As sound as your code is it doesn't work. Not for me anyways.

I've pretty much given up on multi-part/intelligent enemies. I'm just gonna make bouncing blobs now.

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
24th November, 2007 at 17:23:28 -

Works perfectly for me.

http://aggggge.funpic.org/multipart.mfa

Are you sure you placed the events exactly in that particular order? Because it might not work otherwise

 
n/a

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
24th November, 2007 at 17:40:49 -

Axel's fast loop suggestions should fix everyting in MMF. Since I've discovered the ways of the loop, things that I once thought were impossible are now easy as Yoshi's Story for the Nintendo 64. ;D

 
n/a

~Zigzag~



Registered
  13/03/2007
Points
  292

Game of the Week WinnerSilverNova Member
24th November, 2007 at 22:57:04 -


Originally Posted by axel
First, assign an unique ID to all guns and enemies using "spread a value":

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


Then, balance the number of enemies and guns using a fastloop:

* Always
- Run loop "foo" NObjects("Enemy") times

* On loop "foo"
* NObjects("Enemy") < NObjects("Gun")
* Pick one "Gun"
- Gun: Destroy

* On loop "foo"
* NObjects("Enemy") > NObjects("Gun")
- Create "Gun" at (-100, -100)


Then, use a fastloop and the IDs you just assigned to the objects to associate them to each other. As an example, I will attach them to each other, like so:

* Always
- Start loop "bar" NObjects("Enemy")

* On loop "bar"
* Value A of "Enemy" == LoopIndex("bar")
* Value A of "Gun" == LoopIndex("bar")
- Gun: Set position to (0,0) from "Enemy"


Hope this helps!

Image Edited by the Author.



Using NObjects("Enemy")+1 makes it glitch less, I've found.

 
http://www.SilverNova.co.uk
   

Post Reply



 



Advertisement

Worth A Click