Problem with "voodoo doll" mechanic

Godot Version

3.5.1

Problem with “voodoo doll” mechanic.

The goal

There’s these 2 scenes that represent voodoo dolls based on the 2 main characters (Player and Companion).

  • VoodooDollPlayer

  • VoodooDollCompanion

If they get hurt (Either touched by enemies or the Player’s knife attack), they should make their respective character get hurt.

This is part of a specific level where the main characters protect these dolls from enemies.

The problem

When the Player’s health reaches zero after stabbing their dedicated doll, the live count goes beyond 1, which of course is game breaking.

What I personally find it weird is how no relevant script stuff related to this involves _physics_process().

In general, the way how the doll hurts the player involves a function used in an animation called “doll_hurt”.

One reason being so the doll itself also has a “pain animation” where its hurtboxes are disabled.

Because the Player has their own pain animation, so they can’t lose health in a short time period after getting hurt.

Relevant video: Imgur: The magic of the Internet

The relevant scenes

In case I still can’t use more than 2 links:

Thank you for any help regardless.

This is a tough project to sort through.
It looks to me like there are only 3 places where Signal.lives is decremented:
(Each in the _physics_process())

  1. StellaComp.gd
    healthBar.value = health
	if health <= 0  and state != DEATH:
		state = DEATH
		Signals.lives -= 1
  1. PlayerCopy.gd
	if health <= 0 and state != DEATH:
		state = DEATH
		Signals.lives -= 1
  1. CompanionFourth.gd
	if health <= 0  and state != DEATH:
		state = DEATH
		Signals.lives -= 1

Theoretically #1 and #3 aren’t running when this malfunction happens but double check they aren’t running (print statement or breakpoint, whatever)

#2, PlayerCopy, is the one that is supposed to run but it can’t run more than once because you change the state to DEATH.
The only way it can run multiple times is if somewhere you revert the state back to not DEATH.
I would put a print statement in that if statement to see if it is in fact running more than once.
It could be that you change the state off DEATH but neglect to revert the health (so health is still equal to 0 but the state is already changed to the new life).

It could also be some unfortunate misstep with having both life_count and Signals.lives. These are the same thing (as far as I can tell) but you are mix and matching using them. There could be issues in there.

There is a lot of code in each of the state cases in the PlayerCopy._physics_process() match statement. I think they deserve their own script file.

1 Like

It’s okay, I found a solution that kinda rewrites the concept but the idea of “defend these or you lose” is still there.