summaryrefslogtreecommitdiff
path: root/godot/scripts/ballistics/Cannonball.gd
diff options
context:
space:
mode:
Diffstat (limited to 'godot/scripts/ballistics/Cannonball.gd')
-rw-r--r--godot/scripts/ballistics/Cannonball.gd17
1 files changed, 17 insertions, 0 deletions
diff --git a/godot/scripts/ballistics/Cannonball.gd b/godot/scripts/ballistics/Cannonball.gd
new file mode 100644
index 0000000..14de00c
--- /dev/null
+++ b/godot/scripts/ballistics/Cannonball.gd
@@ -0,0 +1,17 @@
+extends "res://scripts/ballistics/NetworkedProjectile.gd"
+
+export var drag_constant = 0.3
+var damage_exceptions = []
+var oldvel
+
+func _physics_process(_delta):
+ oldvel = linear_velocity
+ add_force(-1*linear_velocity*drag_constant, Vector3.ZERO)
+
+func get_init_info():
+ return {"linear_velocity" : linear_velocity, "angular_velocity" : angular_velocity, "oldvel" : oldvel, "shooter" : shooter, "shooter_id" : shooter_id}
+
+func _on_collision(body):
+ if oldvel.length() > 20 and !damage_exceptions.has(body) and body.has_method("damage"):
+ body.rpc("damage", oldvel.length(), "blunt", shooter, "using 'cannon'")
+ damage_exceptions.append(body)