Files
Blockline/scripts/grenade.gd
T

36 lines
900 B
GDScript
Raw Normal View History

2026-09-12 11:01:37 +02:00
class_name FragGrenade
extends RigidBody3D
signal detonation_requested(position: Vector3, owner_id: int, kind: String, grenade_id: int)
var game: Node3D
var owner_id := 0
var fuse := 2.6
var detonated := false
var kind := "frag"
func _ready() -> void:
collision_layer = 4
collision_mask = 1
mass = 0.4
linear_damp = 0.4
angular_damp = 1.0
var physics := PhysicsMaterial.new()
physics.bounce = 0.38
physics.friction = 0.7
physics_material_override = physics
var shape := CollisionShape3D.new()
var sphere := SphereShape3D.new()
sphere.radius = 0.13
shape.shape = sphere
add_child(shape)
if not game.headless:
add_child(StylooEquipment.build(kind))
freeze = not game.is_host
func _physics_process(delta: float) -> void:
if game.is_host and not detonated:
fuse -= delta
if fuse <= 0:
detonated = true
detonation_requested.emit(global_position, owner_id, kind, int(name))