The Daily Click ::. Forums ::. Klik Coding Help ::. Power up problem
 

Post Reply  Post Oekaki 
 

Posted By Message

J.C



Registered
  22/03/2013 05:18:14
Points
  118
7th November, 2014 at 07/11/2014 22:07:49 -

I'm back with yet another roadblock in my project; Making enemies drop random health items upon death.

Here, my problem is that once an enemy dies, it picks one of the seven health items (at random) and places it where the enemy dies.

Image

Image

There are 7 different gems in total. The problem here is that when all 7 gems are collected, they are destroyed for good and the player can no longer receive health pickups.

I'm trying to fix it by adding a Create event for the Gem Group, but as you are all aware MMF2 does not allow for using the Create event on Qualifiers.

Now I'm stumped. So how do I workaround this?

 
n/a

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
8th November, 2014 at 08/11/2014 18:50:17 -

i think you could mark them as in active with a value, then set a later time to destroy them in a loop. Which is selective about what objects that are deleted.

but if you really want to run them to zero. you can pull them from a another level when you create them. This other level the player will never see. It will sort of work like your in program library of objects.

 
https://www.facebook.com/nathon.brown.7

J.C



Registered
  22/03/2013 05:18:14
Points
  118
8th November, 2014 at 08/11/2014 23:33:18 -


Originally Posted by Pan-tosser
i think you could mark them as in active with a value, then set a later time to destroy them in a loop. Which is selective about what objects that are deleted.

but if you really want to run them to zero. you can pull them from a another level when you create them. This other level the player will never see. It will sort of work like your in program library of objects.



Hmm...that might be one way. Not sure how to pull that off though.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
10th November, 2014 at 10/11/2014 00:49:10 -

How about this?

///

IF Count of [Health Item] <7
THEN Create [Health Item] at -100, -100

///

Seems to me like this would always create a health item off-screen. Change the coordinates of item generation if there's a certain zone from which the Event grabs health items.

To double-check that this works, add a sound effect to the Create action. You'll hear it when the event triggers. If you hear it a zillion times overlapping itself, then something's wrong. Same if you never hear it after collecting Health Items.

 
n/a

J.C



Registered
  22/03/2013 05:18:14
Points
  118
10th November, 2014 at 10/11/2014 08:41:15 -


Originally Posted by s-m-r
How about this?

///

IF Count of [Health Item] <7
THEN Create [Health Item] at -100, -100

///

Seems to me like this would always create a health item off-screen. Change the coordinates of item generation if there's a certain zone from which the Event grabs health items.

To double-check that this works, add a sound effect to the Create action. You'll hear it when the event triggers. If you hear it a zillion times overlapping itself, then something's wrong. Same if you never hear it after collecting Health Items.



That'll do it. Thanks s-m-r! I'll go test it out as soon as I can later today.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
10th November, 2014 at 10/11/2014 13:47:35 -

You know, you could also have the health items created upon the destruction of the enemy creatures instead of have them created off to the side and then moved into the play area. I'm sure there's a reason you've not already done this, however.

 
n/a

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
10th November, 2014 at 10/11/2014 20:55:26 -

Good point s-m-r. I guess creating right away would be the most obvious thing to suggest.

But i personal don't use that method. because i like a gap between the death and the power up. Just in case I decide to add any AI routines in too it. Where the AI decides to alter what is dropped based on what the player has.

I've also played around with different directions in a animation storing power up art work. I like your off screen method too. It's good for objects that never move, and might wander on screen when created.

 
https://www.facebook.com/nathon.brown.7

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1331

VIP MemberStarSnow
29th November, 2014 at 29/11/2014 21:00:01 -

Simple-pimple.
Jump into the properties of each of your active object power-ups and disable "Create at start" and "Visible at Start" options. Give each object a "Decay" alterable value (make sure it always replaces AlterableValueD for instance) and set it to 300 or something.

Use your trigger event to create each power-up object at the enemy's location just before it's destroyed - when each power-up is created, it will still be invisible until the decay value hits 0. Want to increase or decrease the duration before a power-up is visible? The Decay rate is dropped by 1 every frame. That doesn't necessarily mean 300 milliseconds especially if the event takes place while fastloops are executed, but it's a close enough guess.

You've already got all your power-ups grouped, so create an Always event and subtract 1 from the power-up group's "AlterableValueD" (Decay Value). Then create a new event that tests if "AlterableValueD" (Decay Value) is equal or less than 0. Chuck in a "Run Once When Event Loops" condition for safety, but you should be able to simply make the power-up visible. If you disabled "Move at start", now would be a good time to start the movement too.

When you get to adding collision data, do it on a individual basis and add a "Is power-up visible?" condition so the player doesn't trigger the power-up before the Decay reaches 0.

Edited by The_Antisony

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
   

Post Reply



 



Advertisement

Worth A Click