EBB Combat Juice Part 2 (Plants)
Opus 4.5
Summary
Comprehensive implementation of the decorative plant system (1.16 from IMPLEMENTATION_PLAN.md), including physics-based sway reactions, death probability mechanics, and visual death effects.
Plant System Foundation:
- Plant class with velocity/acceleration-based sway physics (not spring-based) using
math.dampingfor framerate-independent decay - Two force types matching super emoji box reference:
- Moving force: gentle (accel=80, max_v=4), triggered by ball/weapon passing through plant's ghost collider
- Direct force: snappy (accel=200, max_v=6), triggered by ball hitting ground near plants
- Ghost colliders (sensors) with
{sensor: true, offset_y: -@h/2}for detecting pass-through get_rotation!method to capture current sway state including ambient sine-wave motion
Plant Spawning System:
- 8 predefined plant group templates copied from super emoji box reference
- Each group has validated plant sizes/offsets tested one by one (seedling, sheaf, tulip, blossom, four_leaf_clover)
- Groups track horizontal extents for overlap prevention
- Spawns 2-3 groups per arena with gap-filling algorithm
- Front/back layer separation for visual depth (ball appears "between" plants)
Force Application Mechanics:
- Direct force: plants push AWAY from impact point (
direction = -math.sign(dx)), closer plants get more force (75) vs farther (25) - Added
vyparameter to scale force based on incoming ball's vertical velocity - Weapon velocity calculated from angular velocity:
weapon_vx = -av * offset * sin(angle) - Sensor events fire both directions - identify ball vs plant by checking
weapon_visual_offsetproperty
Death Probability System:
@force_counttracks total forces applied to each plant@force_threshold = 5forces needed before death becomes possible- Strong forces (intensity > 150) trigger death probability check:
math.remap(@force_count, threshold, threshold+10, 0, 100) @dyingflag prevents multiple dying plants from same plant
Dying Plant Visual Effect:
- Captures exact plant state at death (position, rotation, scale, image, layer)
- Spawns at visual center (
@y - @h/2) to rotate around center not base - Physics: initial velocity based on force direction + upward bump, linear damping (
0.92), accumulating gravity - Rotation velocity based on intensity and direction, also damped
- Blinking effect using
timer\during_stepwith accelerating frequency before final death
Critical Bug Fixes:
@dead = truevs@\kill!: direct assignment doesn't propagate to children, so colliders/timers weren't being cleaned up. Changed ALL instances to use@\kill!- Floor hit detection: was checking
normal_y < -0.5(ceiling), fixed tonormal_y > 0.5(floor in screen coordinates) during_stepparameter order: 5th param is step_method, neednilbefore after callback- Dying plants initially added to
@plantscontainer causing iteration errors - moved to@effects
Framework Additions:
math.damping(p, t, dt, v)function added to anchor/math.yue for framerate-independent decay- Physics sensor registration:
an\physics_sensor 'weapon_hitbox', 'plant_ghost'
Debug Keys Added:
- F/G: direct force right/left
- D/A: moving force right/left
- K: kill random plant (for testing death effect)