feat(enemy): sistema d'HP declaratiu i nou enemic big_pentagon

This commit is contained in:
2026-05-25 21:46:48 +02:00
parent 610eaf257e
commit f64c72f9a6
20 changed files with 287 additions and 51 deletions
@@ -0,0 +1,79 @@
name: big_pentagon
ai_type: big_pentagon # Validat contra el directori; mapeja a EnemyType::BIG_PENTAGON.
# Reusa la shape de pentagon però a escala 2.0 — primer enemic gegant del joc.
shape:
path: enemy_pentagon.shp
scale: 2.0
collision_factor: 1.0
physics:
mass: 20.0 # Massa gran: la bala el frena poc, els trossos volen amb la força de la bala.
speed: 30.0 # Avanç lent, com a "tanc carregant".
rotation_delta_min: 0.3
rotation_delta_max: 1.5
restitution: 1.0
linear_damping: 0.0
angular_damping: 0.0
ai:
# Persecució lenta del ship més proper: amb chase_strength baix la inèrcia
# és molt notable, fa el comportament del "boss lent" característic.
movement:
type: chase
chase_strength: 0.3
animation:
pulse:
trigger_prob_per_second: 0.01
duration_min: 1.0
duration_max: 3.0
amplitude_min: 0.08
amplitude_max: 0.20
frequency_min: 1.5
frequency_max: 3.0
rotation_accel:
trigger_prob_per_second: 0.02
duration_min: 3.0
duration_max: 8.0
multiplier_min: 0.3
multiplier_max: 4.0
wounded:
duration: 1.5 # Una mica més llarg que els altres (és un boss).
blink_hz: 10.0
spawn:
invulnerability_duration: 3.0
invulnerability_brightness_start: 0.3
invulnerability_brightness_end: 0.7
invulnerability_scale_start: 0.0
invulnerability_scale_end: 1.0
safety_distance: 72.0 # Doble del normal — és el doble de gran.
colors:
normal: [0, 180, 255] # Blau elèctric per distingir-lo del pentagon cyan.
wounded: [255, 220, 60]
score: 500 # 5x un enemic normal: aguanta 10x més.
# Estrenant el sistema HP: 10 unitats. Cada bala fa decrease_health + flash
# + create_debris_partial (xip a 0.3x). En el 10è hit, on_no_health
# encadena set_hurt (entra wounded). Wound expira → destroy → on_destroy
# fa l'explosió completa.
health: 10
events:
on_hit:
- action: decrease_health # primer: si arriba a 0 dispara on_no_health
- action: flash # feedback visual de damage parcial
- action: create_debris_partial # xip a 0.3x mida (sense ser letal)
- action: apply_impulse # empenta el cos (sense will_die és segur en hit no-letal)
on_no_health:
- action: set_hurt # entra wounded; segon hit durant wounded matarà
on_hurt_end:
- action: destroy
on_destroy:
- action: add_score
- action: create_debris # explosió completa
- action: create_fireworks
+6 -2
View File
@@ -55,10 +55,14 @@ colors:
score: 100
events:
# Comportament clàssic: dos impactes per matar (set_hurt entra wounded;
# el segon hit detecta wounded i destrueix automàticament).
# HP=1 (default): decrement → on_no_health → set_hurt wounded → mort.
# decrease_health primer perquè si la mort cau aquí (segon hit durant wounded),
# el dispatcher salta la resta del chain (incloent apply_impulse) sobre el
# cos ja destruït.
on_hit:
- action: decrease_health
- action: apply_impulse
on_no_health:
- action: set_hurt
on_hurt_end:
- action: destroy
+3
View File
@@ -55,8 +55,11 @@ colors:
score: 200
events:
# HP=1 (default): decrement → on_no_health → set_hurt → wounded → mort.
on_hit:
- action: decrease_health
- action: apply_impulse
on_no_health:
- action: set_hurt
on_hurt_end:
- action: destroy
+3
View File
@@ -56,8 +56,11 @@ colors:
score: 150
events:
# HP=1 (default): decrement → on_no_health → set_hurt → wounded → mort.
on_hit:
- action: decrease_health
- action: apply_impulse
on_no_health:
- action: set_hurt
on_hurt_end:
- action: destroy
+3 -1
View File
@@ -66,8 +66,10 @@ score: 100
events:
# STAR: mor al primer impacte, sense passar per wounded.
# HP=1 (default): decrement → on_no_health → destroy directe (sense wounded).
on_hit:
- action: apply_impulse
- action: decrease_health
on_no_health:
- action: destroy
on_destroy:
- action: add_score