From 11eb875d2e6cef9a7cd3c079c95ba3cf4ba1ee74 Mon Sep 17 00:00:00 2001 From: Rendo Date: Wed, 10 Dec 2025 00:43:05 +0500 Subject: [PATCH] Grenade bounce and radius --- .../weapon_system/weapon_substate_machine.gd | 3 --- systems/weapon_system/weapon_system.gd | 14 ++++++++++---- weapons/molikman/molik/molik.gd | 17 +++++++++++------ weapons/molikman/molik/molikman_molik.tscn | 3 +++ .../molikman/molik/molikman_molotov_fire.tscn | 4 ++-- weapons/molikman/molik/throw.gd | 3 ++- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/systems/weapon_system/weapon_substate_machine.gd b/systems/weapon_system/weapon_substate_machine.gd index ea22a54..355f382 100644 --- a/systems/weapon_system/weapon_substate_machine.gd +++ b/systems/weapon_system/weapon_substate_machine.gd @@ -72,12 +72,9 @@ func _exit() -> void: super() player.weapon_models[visibility_target].hide() -@rpc("authority","call_local","reliable") func use_begin() -> void: if current_state != null: current_state.use_begin() - -@rpc("authority","call_local","reliable") func use_end() -> void: if current_state != null: current_state.use_end() diff --git a/systems/weapon_system/weapon_system.gd b/systems/weapon_system/weapon_system.gd index 80e2603..52743e3 100644 --- a/systems/weapon_system/weapon_system.gd +++ b/systems/weapon_system/weapon_system.gd @@ -139,6 +139,8 @@ func check_for_empty() -> void: return for child in get_children(): if child is WeaponSubStateMachine and child.ammo == 0 and child.remaining_ammo == 0 and child.destroy_when_empty: + if child == current_state: + return_to_previous(false) child.queue_free() func on_ammo_updated() -> void: @@ -159,13 +161,17 @@ func _physics_process(delta: float) -> void: current_state.physics_update(delta) func use_begin() -> void: - current_state.use_begin.rpc() + if current_state != null: + current_state.use_begin() func use_end() -> void: - current_state.use_end.rpc() + if current_state != null: + current_state.use_end() func alternate_state() -> void: - current_state.alternate_state() + if current_state != null: + current_state.alternate_state() func switch_mode() -> void: - current_state.switch_mode() + if current_state != null: + current_state.switch_mode() diff --git a/weapons/molikman/molik/molik.gd b/weapons/molikman/molik/molik.gd index 614cd37..ac71783 100644 --- a/weapons/molikman/molik/molik.gd +++ b/weapons/molikman/molik/molik.gd @@ -3,12 +3,17 @@ extends CharacterBody3D func _physics_process(delta: float) -> void: if is_multiplayer_authority() == false: return + velocity += get_gravity() * delta / 4 - if is_on_floor(): - var fire: Node3D = preload("res://weapons/molikman/molik/molikman_molotov_fire.tscn").instantiate() - Session.dynamic_objects_parent.add_child(fire,true) - fire.global_position = global_position - queue_free() - move_and_slide() + var collision = move_and_collide(velocity * delta) + if collision: + if collision.get_normal().y > 0: + var fire: Node3D = preload("res://weapons/molikman/molik/molikman_molotov_fire.tscn").instantiate() + Session.dynamic_objects_parent.add_child(fire,true) + fire.global_position = global_position + queue_free() + else: + var normal = collision.get_normal() + velocity = velocity.bounce(normal) * 0.5 diff --git a/weapons/molikman/molik/molikman_molik.tscn b/weapons/molikman/molik/molikman_molik.tscn index 74e1a73..23ef48f 100644 --- a/weapons/molikman/molik/molikman_molik.tscn +++ b/weapons/molikman/molik/molikman_molik.tscn @@ -16,9 +16,12 @@ properties/1/replication_mode = 1 [node name="MolikmanMolik" type="Node" node_paths=PackedStringArray("enter_state")] script = ExtResource("1_e53aq") animation_prefix = &"baked_sp_" +registry_entry = &"mm_molik" visibility_target = &"sp" max_ammo = 3 ammo_mags = 0 +can_be_previous = false +destroy_when_empty = true enter_state = NodePath("Intro") metadata/_custom_type_script = "uid://e6lqknfl4ngt" diff --git a/weapons/molikman/molik/molikman_molotov_fire.tscn b/weapons/molikman/molik/molikman_molotov_fire.tscn index 7e92d5b..882f17d 100644 --- a/weapons/molikman/molik/molikman_molotov_fire.tscn +++ b/weapons/molikman/molik/molikman_molotov_fire.tscn @@ -6,7 +6,7 @@ [sub_resource type="CylinderShape3D" id="CylinderShape3D_hr7p8"] height = 3.0 -radius = 1.5 +radius = 2.5 [sub_resource type="Gradient" id="Gradient_hr7p8"] colors = PackedColorArray(1, 0.53333336, 0, 1, 0.45, 0.45, 0.45, 1) @@ -46,7 +46,7 @@ dps = 25.0 damage_timer = NodePath("DamageTimer") [node name="Decal" type="Decal" parent="."] -size = Vector3(3, 3, 3) +size = Vector3(5, 3, 5) texture_albedo = ExtResource("1_hr7p8") texture_emission = ExtResource("2_qokq0") emission_energy = 0.25 diff --git a/weapons/molikman/molik/throw.gd b/weapons/molikman/molik/throw.gd index 60748e5..414d2e8 100644 --- a/weapons/molikman/molik/throw.gd +++ b/weapons/molikman/molik/throw.gd @@ -10,8 +10,9 @@ func _exit() -> void: machine.animation_player.animation_finished.disconnect(on_animation_finished) func on_animation_finished(animation): - if animation == machine.animation_prefix + "throw": + if animation == machine.animation_prefix + "throw" or animation == machine.animation_prefix + "shoot": transition.emit("Idle") + func fire() -> void: if machine.ammo == 0: