summaryrefslogtreecommitdiff
path: root/godot/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'godot/scripts')
-rw-r--r--godot/scripts/GameBase.gd4
-rw-r--r--godot/scripts/ballistics/Cannonball.gd4
-rw-r--r--godot/scripts/characters/player_controller_new.gd5
-rw-r--r--godot/scripts/machines/Cannon.gd9
-rw-r--r--godot/scripts/vehicles/Gunboat.gd8
5 files changed, 26 insertions, 4 deletions
diff --git a/godot/scripts/GameBase.gd b/godot/scripts/GameBase.gd
index 85af89a..9f24d7b 100644
--- a/godot/scripts/GameBase.gd
+++ b/godot/scripts/GameBase.gd
@@ -103,9 +103,9 @@ func back_to_main():
queue_free()
func join_team(team):
- if player_char != null:
+ if player_char != null:
player_char.deselect_character()
- $DEFAULTCAM.current = true
+ cam.attach($DEFAULTCAM, "STATIC", NodePath("."))
player_team = team
rpc_id(1, "_call_on_server", "_client_change_teams", {"id" : client_id, "team" : team})
diff --git a/godot/scripts/ballistics/Cannonball.gd b/godot/scripts/ballistics/Cannonball.gd
index 241fc7d..b41f104 100644
--- a/godot/scripts/ballistics/Cannonball.gd
+++ b/godot/scripts/ballistics/Cannonball.gd
@@ -15,6 +15,10 @@ 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 is_network_master() and body.has_method("load_cannonball") and !body.loaded:
+ body.rpc("load_cannonball")
+ rpc("net_remove")
+ return
if is_network_master() and oldvel.length() > 20 and !damage_exceptions.has(body) and body.has_method("damage"):
body.rpc("damage", oldvel.length(), "BLUNT", [shooter_id, shooter], "using 'cannon'")
damage_exceptions.append(body)
diff --git a/godot/scripts/characters/player_controller_new.gd b/godot/scripts/characters/player_controller_new.gd
index a61ef1d..b1a8718 100644
--- a/godot/scripts/characters/player_controller_new.gd
+++ b/godot/scripts/characters/player_controller_new.gd
@@ -105,6 +105,7 @@ func _process(_delta: float) -> void:
else:
weapon.mouse_input(Input.get_action_strength("fire"), Input.get_action_strength("fire3"),Input.get_action_strength("fire2"))
jumping = Input.get_action_strength("move_jump")
+ walk_speed = 5.0 if Input.get_action_strength("move_walk") else 7.5
if Input.is_action_just_pressed("fire"):
weapon.attack1()
if Input.is_action_just_pressed("reload") and weapon.has_method("reload"):
@@ -190,6 +191,10 @@ func lose_machine():
machine = null
func carry_process() -> void:
+ if !is_instance_valid(carrying_object):
+ carrying_object = null
+ carrying = false
+ return
var vec = (carry_point.global_transform.origin - carrying_object.global_transform.origin)
var length = vec.length()
if length > 1:
diff --git a/godot/scripts/machines/Cannon.gd b/godot/scripts/machines/Cannon.gd
index 80b9edf..6c0b350 100644
--- a/godot/scripts/machines/Cannon.gd
+++ b/godot/scripts/machines/Cannon.gd
@@ -41,6 +41,7 @@ func _ready():
add_collision_exception_with(get_parent().get_parent())
mode = RigidBody.MODE_KINEMATIC
world_ballistics = world.get_node("BALLISTICS")
+ if loaded: controllable = true
func on_new_control():
if is_network_master(): world.cam.attach(self, "STATIC", "./YawJoint/PitchJoint/CameraPoint")
@@ -65,6 +66,7 @@ func attack1():
remotesync func fire():
loaded = false
+ controllable = false
status.set_visible(true)
$YawJoint/PitchJoint/Muzzle/explosion_sound.play()
var expl = preload("res://particles/p_Explosion.tscn").instance()
@@ -79,6 +81,11 @@ remotesync func fire():
cball.shooter = user.name + " (" + world.players_info[user.get_network_master()][0] + ")"
cball.shooter_id = user.get_network_master()
if mode == RigidBody.MODE_KINEMATIC:
- get_parent().apply_impulse($YawJoint/PitchJoint.global_transform.origin - get_parent().global_transform.origin, -1*cball.mass*ball_speed*muzzle.global_transform.basis.x)
+ get_parent().get_parent().apply_impulse($YawJoint/PitchJoint.global_transform.origin - get_parent().global_transform.origin, -1*cball.mass*ball_speed*muzzle.global_transform.basis.x)
else:
if is_network_master(): apply_impulse($YawJoint/PitchJoint.global_transform.origin - global_transform.origin, -1*cball.mass*ball_speed*muzzle.global_transform.basis.x)
+
+remotesync func load_cannonball():
+ loaded = true
+ controllable = true
+ $StatusNotifier.visible = false
diff --git a/godot/scripts/vehicles/Gunboat.gd b/godot/scripts/vehicles/Gunboat.gd
index c00479e..03252e6 100644
--- a/godot/scripts/vehicles/Gunboat.gd
+++ b/godot/scripts/vehicles/Gunboat.gd
@@ -39,12 +39,18 @@ func mp_init(init_info):
# Called when the node enters the scene tree for the first time.
func _ready():
print("adding gunboat to scene",get_tree().get_network_unique_id())
+ controllable = true
+ for sail in $SAILS.get_children():
+ sail.set_sheet(sail_out)
world = get_tree().get_root().find_node("GAMEWORLD", true, false)
if get_tree().get_network_unique_id() == 0:
print("enabling navigation for server")
$NavigationMeshInstance.set_enabled(true)
func on_no_control():
+ rpc("reset_controls")
+
+remotesync func reset_controls():
rudder = 0.0
throttle = 0.0
mainsheet = 0.0
@@ -76,7 +82,7 @@ remotesync func damage(amount, _type, _shooter, _extra = ""):
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
if is_network_master():
- if mainsheet != 0:
+ if throttle != 0:
for sail in $SAILS.get_children():
sail.set_sheet(sail_out)
$Rudder.rotation_degrees.y = rudder_turn