Skip to content

A mina pode causar dano no player#102

Open
iBerserker89 wants to merge 6 commits intomasterfrom
a-mina-pode-causar-dano-no-player
Open

A mina pode causar dano no player#102
iBerserker89 wants to merge 6 commits intomasterfrom
a-mina-pode-causar-dano-no-player

Conversation

@iBerserker89
Copy link
Contributor

Descrição

  • Além disso a mina também não pode dar insta-kill e sim causar um dano conforme a velocidade do objeto que colidiu com ela
  • Inicialmente essa variação de dano vai aplicar apenas para o player mas no futuro teremos inimigos diferentes com velocidades diferentes

Ações nas issues

@iBerserker89 iBerserker89 self-assigned this Nov 24, 2025
@iBerserker89 iBerserker89 added the enhancement New feature or request label Nov 24, 2025
body.health -= damage
_explode()
if body.has_method("take_damage"):
body.take_damage(insta_kill_amount, 1.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iBerserker89 pelo que eu entendi a mina continua dando insta kill nos asteroids, acho que o melhor é ter uma função para calcular o dano e essa função ser utilizada tanto para o player qt para o inimigo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolvido

if not vanish_timer.timeout.is_connected(_on_vanish_timer_timeout):
vanish_timer.timeout.connect(_on_vanish_timer_timeout)
await get_tree().create_timer(0.2).timeout
can_hit_player = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iBerserker89 pq essa variavel é declarada como false para depois mudar para true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func damage_player(body: Node) -> void:
	if body is Player:
		if not can_hit_player:
			return
		damage = body.acceleration / 30.0
		if damage <= 10.0:
			damage = 10.0
		body.health -= damage
		explode()

A variável vira true após o timer de 0.2s no _ready (logo após a mina ser instanciada), pra que o player não tome dano no momento em que instancia a mina no mapa.

Comment on lines +30 to +31
damage_enemy(body)
damage_player(body)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iBerserker89 pq precisamos ter duas funções distintas? não da para unificar em apenas uma única função?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolvido

func _on_body_entered(body: Node) -> void:
	if body is Player:
		if not can_hit_player:
			return
		damage = body.acceleration / 30.0
		if damage <= 10.0:
			damage = 10.0
		body.health -= damage
	if body.has_method("take_damage"):
		damage = body.velocity.length() / 7.0
		if damage <= 10.0:
			damage = 10.0
		body.take_damage(damage, 1.0)
		print("ASTEROID damaged: ", snapped(damage, 0.01))
	_explode()`


## Executa a animação e o som da explosão e desativa colisões.
func _explode() -> void:
func explode() -> void:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iBerserker89 essa função é chamada fora desse script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não, não é chamada fora do código. Resolvido

Copy link
Member

@andrePfeiffer andrePfeiffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iBerserker89 porfavor veja meus comentarios

@iBerserker89
Copy link
Contributor Author

iBerserker89 commented Jan 22, 2026

@iBerserker89 porfavor veja meus comentarios

@andrePfeiffer Visto e resolvido.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A mina pode causar dano no player

2 participants