summaryrefslogtreecommitdiff
path: root/scenes/ballistics/Rocket.gd
diff options
context:
space:
mode:
Diffstat (limited to 'scenes/ballistics/Rocket.gd')
-rw-r--r--scenes/ballistics/Rocket.gd21
1 files changed, 9 insertions, 12 deletions
diff --git a/scenes/ballistics/Rocket.gd b/scenes/ballistics/Rocket.gd
index d21b9f6..171a49e 100644
--- a/scenes/ballistics/Rocket.gd
+++ b/scenes/ballistics/Rocket.gd
@@ -12,7 +12,7 @@ func _ready():
$RocketTrail.emitting = true
func get_init_info():
- return {"linear_velocity" : linear_velocity, "angular_velocity" : angular_velocity, "life" : life, "shooter" : shooter}
+ return {"linear_velocity" : linear_velocity, "angular_velocity" : angular_velocity, "life" : life, "shooter" : shooter, "shooter_id" : shooter_id}
remote func update_phys_transform(t, lv, av):
transform = t
@@ -24,10 +24,10 @@ func _physics_process(delta):
add_central_force(global_transform.basis.x*strength)
life += delta
else:
- explode()
+ rpc("explode")
$RocketTrail.emitting = false
-func explode():
+remotesync func explode():
if cannot_explode:
return
cannot_explode = true
@@ -41,15 +41,12 @@ func explode():
world.add_child(expl)
expl.init(global_transform.origin, Vector3.ZERO)
-
- for body in $BlastArea.get_overlapping_bodies():
- if body.has_method("damage") and body.is_network_master():
- body.rpc("damage", 50, "explosive", shooter, "using 'rocket'")
- print((5000*(global_transform.origin - body.global_transform.origin).normalized()))
- body.apply_central_impulse((5000*(global_transform.origin - body.global_transform.origin).normalized()))
- body.rpc("apply_central_impulse", (5000*(global_transform.origin - body.global_transform.origin).normalized()))
-
+ 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):
- explode()
+ rpc("explode")