The Daily Click ::. Forums ::. Klik Coding Help ::. cloned enemies with different hit points (tgf)
 

Post Reply  Post Oekaki 
 

Posted By Message

tetsuya_shino



Registered
  12/08/2004
Points
  491
23rd May, 2008 at 18:03:07 -

Greetings all. I know I must be getting old when I can't remember old when I can't do something basic as this. So here goes; I'm making an a run 'n gun action platform. I want to be able to spam cloned enemies and have them do different actions. That isn't hard at all. It's just that they are all doing the same action at the same time. >_<

Also, I want to shoot a bullet and have it take damage off, without it effecting all the clones. Easy stuff I know, but for the life of me, I can't remember how to do it. Thanks in advance for any help.



 
n/a

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
23rd May, 2008 at 18:41:07 -

In MMF coding, theres two parts; the "actions" and "events, like if you had a line saying;
"When space bar is pressed, end the game"

the "When space bar is pressed" would be the action, and the "end the game" would be the event.
Now how MMF works with multiple copies of the same object type, is that when it reads through an action, it starts off with every single copy of that object being in a list, with the topmost object being the newest one. So say you have 5 active objects of the same type, it would be:

object5
object4
object3
object2
object1

If you were to place an event in this line under the object's tab, such as "Destroy object" or "Sub 1 from Value A", it would read this list and apply this action to EVERY object. Hence it would destroy all 5 objects, or sub 1 from all 5 objects value A.

However, when using the events on the left side, you can narrow down which objects are selected. Since it starts with ALL objects by default, having a condition on your event can pick a specific object. So if we insert the line into our event:
"When 'Bullet' collides with 'object'"

then when the event executes, it will take that list of 5 objects, and choose ONLY the single object that the bullet collided with. So the list becomes

object1

or whatever one got struck. Then when it goes to apply the action, it will only reference this single object and only reduce that one's value A by 1.


Where it gets tricky, is that some actions and some events can only refer to a SINGLE instance of this object. So if we had this event:

"Upon pressing space bar, set global value 1 to alterable value A("object")"

then it would take that list, of object1,2,3,4,5, and since it can only set the global value to a single value, it would set it to the TOPMOST object on the list, object5. So despite there being 5 objects, only a single one would be represented.




Hence, if you want, you can simple code it like this:

"When 'Bullet' collides with 'Object', sub 1 from A("object")"

&
"When A("object") < 0, destroy object".



Since each of these reference the single object, only a single one will be hit, instead of all of them, at a time. It runs into a problem if two objects are struck by bullet simultaneously, which you can rectify as:

"When 'Bullet' is overlapping 'Object' && Pick an object at random, sub 1 from A("object")"

"When A("object") < 0 && Pick an object at random, destroy object"



The "Pick an object at random" command will take a single item randomly, but only from the remaining list, NOT every object on the field. So since the first action, the "A < 0" narrowed it down to only the 1-2 objects whos value is less then 0, it will pick only one of those two and kill it.

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

tetsuya_shino



Registered
  12/08/2004
Points
  491
23rd May, 2008 at 18:43:12 -

Thank you... but um, I have tgf ;

 
n/a

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
23rd May, 2008 at 18:54:17 -

me too, they work the exact same way

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

tetsuya_shino



Registered
  12/08/2004
Points
  491
23rd May, 2008 at 18:59:37 -

okay thanks, I'll try it now. =

 
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
25th May, 2008 at 13:54:23 -

OT: You're stationed in Japan. You military?

 
Craps, I'm an old man!

tetsuya_shino



Registered
  12/08/2004
Points
  491
25th May, 2008 at 17:00:06 -

Yes, sir. I'm in the navy, stationed in Yokosuka Japan. I've been here about a year and a half now.
I can't stand being in the navy, but the way I saw it, it was the only way for a guy like me to have a steady job while living in Japan. (Although I'm gone 7 months out of a year out at sea.) Japan is a great place, expensive, but great.

Edit: Okay, I have a new problem. I have code that has an emeny walk after the hero. The direction is based on the hero's x value. If the enemy's value is less then the heros, the enemy will walk to the left. If it's more, then it will will walk to right. That works perfect. The problem is when the x value = the hero's x value. The enemy will just get stuck quickly shifting walking anim directions from left to right. I tried to make code if the x = the x, but it doesn't always work. any ideas? I want to make the enemy stop and change anim if it equals the hero's x.



Image Edited by the Author.

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
28th May, 2008 at 02:12:18 -

yea ... change the if x is less than hero x ... to ... If x is less than or equal to hero x.

or you could change the greater than side .. but decide which side you want and it'll just move slightly more on one side, no big thing, probably won't even be noticeable. And it solves the problem

Or you could just add an extra line of code to tell the enemy what to do when its x = the x of the hero.


Image Edited by the Author.

LoL ... I misunderstood somehow (not hard cause I'm usually half asleep when online) ... anyways .. the REAL SOLUTION for your "new" problem would be to consider the positions of the edges of the object, and keep the hotspot in mind because that will affect things.

Then what you'll need to do is if x is less than the value of the left edge of the main object OR greater than the value of the right edge of the main object, move the enemy object towards main objects center position. And if x is greater than the value of the left edge and less than the right edge value, then stop the movement of the enemy object.

That will definitely solve it .... sorry about the confusion. ... kinda funny how I mixed it up all backwards like .. I guess I was thinking dyslexicly or something.


Image Edited by the Author.

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?
   

Post Reply



 



Advertisement

Worth A Click