Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Help with CopperCube
Changinf bullet damage value in game
Author Text

malik
Registered User
Quote
2022-07-03 15:48:08

Hello,

Is it possible to change a node character health in javascript? for example , it the ennemy node is hit, his health is decreased by 30.

If someone did something similar and can help me go to in the right direction, that would be great.

In the meantime, I'll read the javascript section of the tutorial, cause its clear it can be achieved only with javascript.

Thanks in advance for all your advices


malik
Registered User
Quote
2022-07-03 16:05:18

ok, so I search and it seems I can use set or change variable by using the syntax enemy.health....but obviously it will impact only this ennemy not all enemy...

edit: .. and it removes all the health, and does not seems to just decreased it by a certain amount. It's always health becomes 0

edit: maybe an alternative solution could be that on impact, the bullet does more damage?It it possible to do this? is there a way to acces the variable bullet shot by the player?


VP
Guest
Quote
2022-07-03 20:32:15

Without java coding, just add a game-character behaviour, when hit, subtract 30 from variable "player.health"


malik
Registered User
Quote
2022-07-04 00:32:44

You mean subtract 30 from enemy.health instead of player.health since I want the enemy to lose health?
Thanks , it works more or less but it seems that the enemy does not lose only 30 but all his life. Strange , why not just 30!? Maybe the action of losing 30 points of life is repeated until he is dead? But why is it repeated ? It is hit only once until the next bullet touch him. I continue to search a solution.


Guest
Guest
Quote
2022-07-04 01:10:53

Are you setting the variable in the every few seconds behavior? If so it will repeat because you put it under a repeating behavior. Check to make sure that isn't the case. Setting a variable is an action and shouldn't repeat unless a behavior is making it do so.


Guest
Guest
Quote
2022-07-04 01:25:24

Also one thing I forget to mention is if you are setting that variable with a key press behavior, then it's probably repeating because keys by default repeat on certain platforms such as Windows. You will need to limit it to fire once using variables. Vegan Pete, the guy who responded to you above, has a post in these forums about how he did away with the key repeat using CC inbuilt actions and behaviors. Let me see if I can find it:

https://www.ambiera.com/forum.ph...

VP says:

"There are a few different methods to do that. Simplest method is that you can use "If" and a "variable".

When Key is pressed,
If variable "Sound_Played?" = 0,
Play Sound "sound.wav",
set variable "Sound_Played?" -1

When Key is released,
set Variable "Sound_Played" = 0

When you press your key, the sound will play once (even if you hold the key down)."

It's about playing a sound but shooting is similar. Hope this helps.


just_in_case
Moderator
Quote
2022-07-04 07:13:12

as @guest has mentioned the action on hit is repeating itself you need to limit it with using a variable , check for a variable on action on hit, if its is true then give the damage and make the variable false. That way it will execute the action on hit only once.


VP
Guest
Quote
2022-07-04 09:21:31

Windows has "key repeat" set to "on" by default - which means: if you hold a key down, it will repeatedly press and release the key - really annoying for coppercube games - and not sure when it would ever be useful to be honest. If the games are just for yourself, you can safely just disable key-repeat on windows and it will stop it happening in coppercube games - almost all windows users have key-repeat set to "enabled", which means your game wont work properly if you share it unless you do some magic in Coppercube to prevent it. I've turned off windows key repeat, so you game would probably work fine for me without having to make any changes.


VP
Guest
Quote
2022-07-04 09:22:53

Sorry - Guest and just_in_case have already said exactly the same thing.


malik
Registered User
Quote
2022-07-04 11:56:28

Ok, everyone, Thank you VP , Guest and just_in_case.
You were all right.
Indeed the actionOnHit in the game actor of the enemy is repeated. So as advised, I added a variable when I shoot called hitOnce, and I use it in the actionOnhit of the enemy.

So now It works. I can decreased a certain amount of life of the enemy when I get a powerup.

Here is a link to my ccb if anyone want to see it, if you think I can do better please, I'm all ears:
https://drive.google.com/file/d/...

Thank you everyone for all your solutions!!


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Int?rnational" (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© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact