The Daily Click ::. Forums ::. Klik Coding Help ::. I'm trying to destroy a duplicate positioned over a duplicate without destroying them all.
 

Post Reply  Post Oekaki 
 

Posted By Message

JetpackLover



Registered
  01/03/2007
Points
  212
13th December, 2008 at 15:29:08 -

I'm having this problem destroying duplicates(skins) positioned over another duplicate(hitbox) when the duplicate(hitbox) is destroyed. I have all my enemy HP in alterable values, so that makes them unique without spreading, but when I want to destroy the skin with the hitbox, it just destroys all of the skins as well.

Also I don't think I'm even using spread values right. For example, I have been using 3 separate events for each action of my enemies which only allows me to have 3 duplicates on the field at once. I've been coding in things like "ID = 1, then do this" Of course I can make more if I add more events but I have a feeling this is the wrong way to make spread values work.

If someone could give me a crash course or example of how to code and position this stuff right please do.

Oh and I have already read and re-read the Spread Values article a few times...although maybe I still don't get it...I thought I did.

I have also posted my own example that shows how I have been using spread values. This isn't from my game since if I posted that MFA I fear people trying to help me would become wildly confused.

I've been working on this for days now and am dying for closure so that I may finally work on some animations.

http://www.mediafire.com/?sharekey=072eee5f4a438ce7d2db6fb9a8902bda

 
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


Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
13th December, 2008 at 21:25:56 -

ah..
you can solve that:

when you create the skin and hitbox... set fixed value of skin to the hitbox alt.val A

so before!!! you destroy the hitbox
hitbox alt A = skin fixed value
destroy skin then hitbox

in that order

It should work fine i think. Also set flags and all that... you don't need spread value at all.

Edited by Don Luciano

 
Code me a sausage!

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
13th December, 2008 at 22:00:11 -

http://www.create-games.com/article.asp?id=1937
Scroll down to the bottom section, #4, it should explain it nicely;

You can't position all your objects in a single event like that, like if you want to position Hitbox#1 to Enemy#1, Hitbox#2 to Enemy#2, etc. What you need to do is create an event that runs the event once for every single object, each frame of gameplay.

My example is:

*Always:

=Bad Guy: Set Flag 0 Off

=Bad Guy: Set Flag 1 Off



*Always:

=Start Loop Pin Swords for (Number of Bad Guys) loops



*On Loop: Pin Swords

+Bad Guy's Flag 0 is Off?

+Pick a Bad Guy at random

=Bad Guy: Set Flag 0 On

=Bad Guy: Set Flag 1 On



*On Loop: Pin Swords

+Bad Guy Flag 1 is On

+Alterable Value A of Sword = Alterable Value A of Bad Guy

=Set Position of Sword (0,0) to Position of Bad Guy



*On Loop: Pin Swords

=Bad Guy: Set Flag 1 Off


 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
14th December, 2008 at 00:33:36 -

actually he can... if he creates the units during gameplay
and if not during gameplay its the same thing, no need for fast loops or spread values.


==solder flag 0 off?
==hitbox flag 0 off?
pick one of solders...
pick hit

set hitbox pos to solder, and fixed to alt.
solder flag 0 on
hit flag on


and he wrote that he has problems destroying them, not setting them up. At least i think so...


Edited by Don Luciano

 
Code me a sausage!

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
14th December, 2008 at 01:27:52 -

I found it hard to interpret, but uh, if you wanted to do a "Destroy attached object to enemy when enemy is destroyed" event, it would go like this:


+When "Enemy" HP < 0
+ID("Object") = ID("Enemy")
=Destroy Enemy
=Destroy Object

Please note you MUST do it in the order OBJECT = ENEMY, not ENEMY = OBJECT, nor can you use the "2 general variables" condition. This is because of object scope: http://www.create-games.com/article.asp?id=1942 - The "Value of 'active'" event reduces the object scope for just the object on the left side of the equation, the ones on the right side do not effect.
So when the game runs through the scope list, it works like this:

Initial: All Enemies, All Objects
+Enemy HP < 0 -----> Now only scopes the Enemies < 0
+Object ID = Enemy ID -----> Compares ALL objects, but only compares them to the (single) Enemy scoped above
Now only 1 object and enemy are scoped (ideally), so when you run;
=Destroy Object
=Destroy Enemy
It just kills those two specified actives.


You will encounter a problem, however, if you have [b]multiple objects die at the exact same time[/b]. Since if multiple Enemies fulfill the "ENEMY HP < 0" statement, it will select ALL of them, which if you follow the code, leads to bad funkiness. You can work around this by changing the code to be:

+When "Enemy" HP < 0
+Pick an "Enemy" at random
+ID("Object") = ID("Enemy")
=Destroy Enemy
=Destroy Object


 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

JetpackLover



Registered
  01/03/2007
Points
  212
14th December, 2008 at 07:15:43 -

You guys have been really helpful thank you!

Alright sweet, I've made some decent progress. However I wasn't able to apply the sandwiching loops in groups tricks. Call me stupid, but I could not figure out the flow. Do you use "group is activated?" Is that the same as group is on? And when do you turn it back off? Anyone wanna help me on that? I have a new example with the new code.

http://www.mediafire.com/?sharekey=072eee5f4a438ce7d2db6fb9a8902bda

 
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


-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
14th December, 2008 at 09:33:53 -

"On group activation" will run once when the group is activated.

"Group ___ is activated" will continue to run while the group is activated. It will stop running when the group becomes deactivated.

 
n/a ...

JetpackLover



Registered
  01/03/2007
Points
  212
14th December, 2008 at 09:54:40 -

So you need a condition for activating the group right?

So when it is like this

do this:

(CONDITIONS)
========================================
Open Group: Hello World

Start Loop: Hello World for 100 loops

Close Group: Hello World
========================================

See how it has open group? What condition do I need to use to activate the group in order to run the loop? And then once the loop is finished to close it?


 
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


-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
14th December, 2008 at 10:47:09 -

You'd need to put the "Start Loop" part inside the "Hello World" Group. Like this:

-(Conditions)
> Activate Group "Hello World"

=====================Hello World=====================
-On Group Activation
>Start Loop "Hello World" 100 times

-Loop "Hello World" has run 100 times
>Deactivate Group "Hello World"
=================================================

Of course, you'd need something to check if the loop has run 100 times. You'd replace the "-Loop "Hello World" has run 100 times" condition with a condition that checks if the loop has finished doing what it needs to do.

 
n/a ...

RedEnchilada

formerly RedEchidna

Registered
  01/08/2008
Points
  301

VIP MemberWii OwnerThe Cake is a LiePicture Me This Round 24 Winner!
14th December, 2008 at 13:58:53 -

No, his way is right. The group activation events should be somewhere in the Special object.

 
http://www.youtube.com/watch?v=WYrSD35vHo4
woooooooooooooooooaah maaaaaaaaaaaaaaaaaaaaan

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
14th December, 2008 at 21:48:58 -

no, running a code that simply says:

[Open Group: Fruit Loops
Run Loop: Fruit Loops 1000 Times
Close Group: Fruit Loops]

all in the same event, where somewhere else is the code is the Fruit Loops group that contains the Fruit Loops Loop, will work. When MMF2 executes the list of events, it [b]interrupts the events list when a loop is called[/b]. This is how a stack frame works in most programming languages; it will create a frame that says this:

Open Group
Run Loop
Close Group

It normally walks straight down this list and executes them in order. However, when it reachs the Run Loop, it pauses the stack frame, and builds on top of it:

Open Group (finished)
Run Loop (finished)
---------On Loop "Fruit Loops": stuff
---------On Loop "Fruit Loops": stuff
---------On Loop "Fruit Loops": stuff
Close Group

It will then run all the fruit loops commands, THEN return to the first stack frame, and execute the "Close Group" command. So what happens is, it opens the group, then runs all the commands, THEN closes the group. Any actions located below a "Run Loop" command will not occur until after that loop has finished.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
15th December, 2008 at 03:21:20 -

This topic is really turning into a 20 events for something that you could do really easy.
dont use fast loops, you don't need them for this kind of things. Too much fastloops running will slow down your application.
http://www.mediafire.com/?kmizew2mgtu

do what you want anyway...

 
Code me a sausage!

JetpackLover



Registered
  01/03/2007
Points
  212
15th December, 2008 at 07:29:08 -


Originally Posted by Don Luciano
This topic is really turning into a 20 events for something that you could do really easy.
dont use fast loops, you don't need them for this kind of things. Too much fastloops running will slow down your application.
http://www.mediafire.com/?kmizew2mgtu

do what you want anyway...



Wow that is a lot shorter, and does the same thing...now I don't know which to use...

 
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

   

Post Reply



 



Advertisement

Worth A Click