extends Node2D const DEFINITION := preload("res://resources/items/auxiliary_shield.tres") const GEN := preload("res://scripts/items/item_generator.gd") const LAB := preload("res://scripts/planets/laboratory.gd") func _ready() -> void: GameState.start_new_run() GameState.captain.level = 30 assert(DEFINITION not in GEN.available_definitions()) var captain := GameState.captain var progress: Resource = captain.expedition progress.freighter_rooms.expansion_1 = "laboratory" progress.laboratory_offers.assign(["auxiliary_shield"]) for key in LAB.COSTS.auxiliary_shield: captain.minerals[key] = 100 assert(LAB.start(captain,"auxiliary_shield")) LAB.advance(progress,LAB.DURATION) assert(DEFINITION in GEN.available_definitions()) var item := GEN.generate_for_definition(DEFINITION,30) assert(item.additional_modifiers.is_empty() and item.definition.icon != null) item.extension_cooldown = 30 var ship := preload("res://scenes/game/player_ship.tscn").instantiate() ship.get_node("Camera2D").enabled = false add_child(ship) ship.set_physics_process(false) ship.get_node("WeaponController").set_physics_process(false) var systems := ship.get_node("ExtensionSystems") systems.set_physics_process(false) ship.get_node("ShipInventory").extension_slots[0] = item ship.max_energy = 200.0 ship.max_shields = 120.0 ship.shields = 120.0 ship.hull = 100.0 ship.absorption = Vector3.ZERO ship.energy = 139.99 assert(not ship.activate_ability(0)) assert(ship.auxiliary_shields == 0.0 and not systems.cooldowns.has("auxiliary_shield")) ship.energy = 140.0 assert(ship.activate_ability(0)) assert(ship.energy == 0.0 and ship.auxiliary_shields == 60.0 and ship.auxiliary_max_shields == 60.0) assert(ship.shields == 120.0 and ship.hull == 100.0) var outer: Node2D = ship.get_node("AuxiliaryShieldVisual") assert(is_equal_approx(outer.shield_radius,ship.get_node("ShieldVisual").shield_radius*1.45)) assert(ship.get_active_shield_visual() == outer) ship.take_damage(25.0) assert(ship.auxiliary_shields == 35.0 and ship.shields == 120.0 and ship.hull == 100.0) ship.take_damage(50.0) assert(ship.auxiliary_shields == 0.0 and ship.shields == 105.0 and ship.hull == 100.0) ship.take_damage(200.0) assert(ship.shields == 0.0 and ship.hull == 5.0) ship.energy = 200.0 assert(not ship.activate_ability(0),"Normal extension cooldown applies") systems._physics_process(30.0) assert(ship.activate_ability(0),"Works with empty ordinary shields") assert(ship.energy == 60.0 and ship.auxiliary_shields == 60.0) systems._physics_process(30.0) ship.energy = 200.0 assert(not ship.activate_ability(0) and ship.energy == 200.0,"Cannot stack or refill an active outer layer") ship.max_shields = 200.0 ship._update_shield_visual() assert(ship.auxiliary_shields == 60.0 and ship.auxiliary_max_shields == 60.0,"Capacity is captured at activation") ship.clear_auxiliary_shield() assert(ship.activate_ability(0) and ship.auxiliary_shields == 100.0) await get_tree().physics_frame await get_tree().physics_frame var bolt := preload("res://scenes/game/weapon_projectile.tscn").instantiate() bolt.enemy_shot = true bolt.collision_mask = 2 bolt.configure(Vector2(-150,0),Vector2.RIGHT,ItemDefinition.WeaponKind.PLASMA,1200.0,20.0,1000.0) add_child(bolt) bolt.set_physics_process(false) bolt._physics_process(0.25) assert(bolt.is_queued_for_deletion()) assert(is_equal_approx(bolt.position.length(),outer.shield_radius),"Fast bullets stop on the larger perimeter") assert(ship.auxiliary_shields == 80.0 and ship.shields == 0.0 and ship.hull == 5.0) var hit: Dictionary = preload("res://scripts/game/shield_intersections.gd").intercept({},Vector2(-200,0),Vector2(200,0),2,[],get_tree()) assert(hit.collider == ship and is_equal_approx(hit.position.length(),outer.shield_radius),"Lasers hit the outer shield even with normal shields empty") systems.reset_combat_state() assert(ship.auxiliary_shields == 0.0) ship.energy = 200.0 assert(ship.activate_ability(0)) captain.skills.power_redirect = 1 captain.equip_skill(0,"power_redirect") ship.shields = ship.max_shields assert(captain.activate_skill("power_redirect",ship)) assert(ship.auxiliary_shields == 0.0) systems.cooldowns.clear() ship.energy = 200.0 assert(not ship.activate_ability(0)) captain.reset_combat_state() ship.is_docked = true assert(not ship.activate_ability(0)) ship.is_docked = false assert(ship.activate_ability(0)) ship.is_docked = true ship._physics_process(0.1) assert(ship.auxiliary_shields == 0.0) # Normal-shield emergency technologies must not trigger for absorbed hits. ship.is_docked = false ship.energy = 200.0 ship.shields = ship.max_shields systems.cooldowns.clear() assert(ship.activate_ability(0)) progress.alien_skills.shields_b_next_next = true ship.take_damage(5.0) assert(ship._salvo_cooldown == 0.0 and ship.auxiliary_shields == 95.0) print("AUXILIARY_SHIELD_TEST: PASS (lab unlock, 70% max energy cost, 50% max shield snapshot, no stacking, outer-first damage and overflow, larger bullet/laser collision with empty main shields, cooldown, reset, power redirect and docking)") get_tree().quit()