diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2022-09-07 14:07:30 -0400 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2022-09-07 14:07:30 -0400 |
| commit | c232b92e2dde1277324d1f89d0e75ae641e4ac3b (patch) | |
| tree | e11a5dd52f259c1cc7345baa40b372b304417f00 /godot/scenes/ballistics/Rocket.gd | |
| parent | a0967ebe815cd229b69fb9578f2288b95b2ddb28 (diff) | |
reorganized, ladders, vehicle control
Diffstat (limited to 'godot/scenes/ballistics/Rocket.gd')
| -rw-r--r-- | godot/scenes/ballistics/Rocket.gd | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/godot/scenes/ballistics/Rocket.gd b/godot/scenes/ballistics/Rocket.gd new file mode 100644 index 0000000..374bfd9 --- /dev/null +++ b/godot/scenes/ballistics/Rocket.gd @@ -0,0 +1,48 @@ +extends "res://scripts/ballistics/NetworkedProjectile.gd" + +onready var world = get_tree().get_root().find_node("GAMEWORLD", true, false) + +export var lifetime : float = 2.0 +export var strength : int = 80 + +var life = 0.0 +var cannot_explode = false + +func _ready(): + $RocketTrail.emitting = true + +func get_init_info(): + return {"linear_velocity" : linear_velocity, "angular_velocity" : angular_velocity, "life" : life, "shooter" : shooter, "shooter_id" : shooter_id} + +func _physics_process(delta): + if life < lifetime: + add_central_force(global_transform.basis.x*strength) + life += delta + else: + rpc("explode") + $RocketTrail.emitting = false + + +remotesync func explode(): + if cannot_explode: + return + cannot_explode = true + $RocketTrail.emitting = false + $rocket_mesh.visible = false + mode = MODE_STATIC + set_collision_layer_bit(1,0) + set_collision_mask_bit(1,0) + + var expl = preload("res://particles/p_Explosion.tscn").instance() + world.add_child(expl) + expl.init(global_transform.origin, Vector3.ZERO) + + if is_network_master(): + for body in $BlastArea.get_overlapping_bodies(): + if body.has_method("damage"): + body.rpc("damage", 20, "explosive", [shooter_id, shooter], "using 'rocket'") + body.rpc_id(body.get_network_master(), "net_apply_impulse", (500*(body.global_transform.origin - global_transform.origin).normalized())) + $AnimationPlayer.play("explode") + +func _on_collision(_body): + rpc("explode") |
