standardized damage system?

Get help using Construct 2

Post » Sun Nov 03, 2013 4:13 pm

I am making a fighting game platformer/side scroller game.

So I have player "char1' (more players to be added later on), and many different kinds of enemies.

char1 has several attacks.

I want to make any instance of the different enemy types that I hit:
- go up if i hit them with attack 1, damage is 10, makes enemy fall
- push them if i hit them with attack 2, damage is 20, doesn't make enemy fall
- slam them down if i hit them with attack 3, damage is 30, makes enemy fall
and so on

and on the other side,
When enemy1 hits char1 (and other player type chars i will add in the future):
- using attack1, any player will be pushed back, damaged by 10, not fall
- using attack2, any player will be pushed up, damaged by 10, will fall

I also want my players and enemies to be hittable even while falling in air OR when they are hit upwards (while moving upwards in air, JUST BEFORE they fall down in air).

How do I code that in a standardized way (for both players and enemies)? like not having to repeat the same events again and again ?

Please someone explain to me as clearly as possible. I can't understand the example of Danuyos. It's too complex.

I'm already using families and hitboxes (for attack) and playerbox (as the "hittable body" of player)
Posts: 301
Reputation: 2,726

Post » Sun Nov 03, 2013 5:01 pm

instance variables and comparing variables

the things that collide with each other carry the variables that tell the game which actions to execute.
So the attack would carry a damage variable as well as pushback pushup slam variables for which you can check. The enemy would carry his health points.
On collission you check for the special actions a attack could carry with it. A condition could look like: attack.pushback = 1 : do stuff that pushes back the enemy
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on or on Steam, read this: Review
Posts: 787
Reputation: 3,786

Post » Sun Nov 03, 2013 5:11 pm

Here's a starting template i've been working on for spawning players that will help a bit

But you are on the right track for wanting to get things setup cleanly right from the beginning so you dont have to re code things over and over.

making use of functions will help repeat tasks with only having to code them once.

What i've done in this example. is Created a function that spawns a player. I then assign a unique ID or name to the newly created player eg: "player 1", and you can also set specific starting values for their health etc.

for example

on object touched "start" - Function Call "Spawn Player"

you can also add arguments if you want to spawn a player with different variables etc, like more health.

eg: on object touched "start" - function call "Spawn Player" (100)

In the function itself you would setup what each of those unique arguments would be eg: argument1 = max health, argument 2 = max damage, argument 3= lives etc.

Then anytime you need a new character to spawn you would use.

on object touched "start" - function call "Spawn Player" (100)(40)(3)

The function itself would look like this...
Function on "Spawn Player"
-> create object "PlayerObject"
-> PlayerObject -Set Health to Function.Param(0)
-> PlayerObject Set Damage to Function.Param(1)


The same idea can be applied to dealing damage however it occurs.

Create a function called "DealDamage"
-> Subtract Function.Param(0) from

Now where you would have the event that occurs when a player collides with the lava or an enemy for example.

You can also add an argument that would specify what type of damage they received, if you want to have multiple different amounts based on who hit who, or what hit what.


in the function called "DealDamage"

If Function.Param(0) = "lava"

-> Subtract 10 from

If Function. Param (0) = "enemy"

-> Subtract 20 from

So when you call the function On Function Call "Deal Damage" (lava)

it would know to deal the amount of damage according to how much damage lava does. This is also helpful that all of your variables are in one place to find later when you want to tweak them.

You can use an argument as well to specify a specific amount of damage taken.


Subtract Function.Param(0) from

Player On collision with "enemy" Call Function "Deal Damage" (20)

See if you can apply these ideas to what you want to do, and fire back any questions you may have and i'll do my best to answer them.

Posts: 993
Reputation: 16,909

Return to How do I....?

Who is online

Users browsing this forum: NN81, TsubaRu and 8 guests