Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
clones health

coa
Registered User
Quote
2022-05-15 17:14:28

Hi am trying to make a fire damage npc clones when touching it..
I have 1 original and 2 clones on the map

I use on proximity on fire node and in action i have change variable hashtag.npc.health subtract for example 30

but it only seem to subtract health from the original npc node

Anyone know a way i can subtract from the clone that touched the fire

thanks


VP
Guest
Quote
2022-05-17 13:00:28

I know a workaround...

Instead of having the "on proximity"event applied to the fireball (for when it touches the character), you need to do it the other way round - have the "on proximity" event applied to the character (for when it touches the fireball).

Now use the "Current scene node" selection for all the events on the character - so when you clone that character, each clone will have all its events set up as "current scene node" - rather than affecting the original character only.


VP
Guest
Quote
2022-05-17 13:12:47

After you get that working, you can refine it a bit more for efficiency. Another workaround which works is to have 2 originals:

Original 1- has the fire damage event (subtract health on proximity to fireball).

Original 2 has - a "change node position" event on proximity to the fireball.

Next, move/drag Original 1 out of the way (-1000y beneath the map), and make your clones of Original 2 to populate your game with characters.

Now what you want to happen in your game is when the fireball hits Original 2, you swap position of original 2 with original 1 to deduct health.

This is a cheat where you only ever have 1 game character that can have complex events, you just recycle it over and over by bringing it back to life (hash health.original1 =100) and then move it back down off the map (-1000y), ready for the next fireball interaction with an Original 2 clone.

The advantage of this is that you can have thousands of basic enemies and only 1 complex character (with the health event) - without any game slowdown - rather than cloning a complex original that has many "on proximity" events attached to it - which can make the game confusing and you may eventually experience game slowdown trying to keep track of all the events.


coa
Registered User
Quote
2022-05-17 14:05:05

Hi VP thanks for your reply!

im not sure i understand that all that your have suggested

but it looks like changing the clone health is impossible unless they are original node

and thats what i did i I created 3 orginal nodes of the Aliens
so i could add all 3 nodes to fire node on proximity
and change health variable for the alien nodes now they have different name and separate health names


just_in_case
Moderator
Quote
2022-05-19 06:00:09

you probably need to use the name of the cloned scene node in the variable name to give damage to all of them, you can try putting them in a folder and then using the ccbGetChildNode() command to get the name property of the children of that folder, and then using the name to give damage to them.

Yeah, it will require scripting to give damage to all the clone nodes.

there are many ways of doing this with scripting. i recommend you to learn basic javascript.

you can use @VP's method as well. It is not that hard to understand.


coa
Registered User
Quote
2022-05-19 08:18:55

thanks just_in_case for the reply,, I know javascript but im not so used using CC javascript

i tried some code and got it to work I needed to set the names of the clones first


VP
Guest
Quote
2022-05-19 13:46:49

I'll make an example with no code for you and post it here for you.


VP
Guest
Quote
2022-05-19 15:36:07

Here's the demo. just_in_case is correct. While I can get the clones to die whenever they come in contact with the same weapon, I can't adjust their health...

https://drive.google.com/file/d/1vJ-mC6cQh6nAOdZD_TOxIe2ADTQWlu2Y/view?usp=sharing

You could use this demo to kill your clones with the rocket/fire-spell but it would kill them with one-hit, instead of deducting health - sorry about that, I was wrong. I forgot that in my game, the rocket kills enemies with a single shot.

But I think if you used your fire spell as a "bullet", it would successfully delete health from your clones using this method.


coa
Registered User
Quote
2022-05-19 16:43:31

thanks VP but not needed

I found out how to do it with scripting


VP
Guest
Quote
2022-05-19 17:04:54

OK, nice one.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact