summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--maps/Main.tscn14
-rw-r--r--project.godot2
-rw-r--r--scenes/ballistics/Cannonball.tscn9
-rw-r--r--scenes/ballistics/Rocket.gd7
-rw-r--r--scenes/machines/Cannon.tscn2
-rw-r--r--scenes/vehicles/Airplane.tscn155
-rw-r--r--scenes/vehicles/Gunboat.tscn (renamed from scenes/boats/Gunboat.tscn)3
-rw-r--r--scenes/weapons/rockets.gd4
-rw-r--r--scenes/worldprops/battery.tscn (renamed from scenes/environment/battery.tscn)0
-rw-r--r--scenes/worldprops/dockscene.tscn (renamed from scenes/environment/dockscene.tscn)0
-rw-r--r--scenes/worldprops/housescene.tscn (renamed from scenes/environment/housescene.tscn)0
-rw-r--r--scenes/worldprops/islandscene.tscn (renamed from scenes/environment/islandscene.tscn)0
-rw-r--r--scripts/Server.gd5
-rw-r--r--scripts/ballistics/Cannonball.gd2
-rw-r--r--scripts/cameras/plane_armcam.gd26
-rw-r--r--scripts/cameras/player_firstperson.gd33
-rw-r--r--scripts/characters/player_controller_new.gd21
-rw-r--r--scripts/machines/Cannon.gd64
-rw-r--r--scripts/machines/NetworkedMachine.gd54
-rw-r--r--scripts/vehicles/Airplane.gd106
-rw-r--r--scripts/vehicles/Gunboat.gd (renamed from scripts/boats/Gunboat.gd)31
-rw-r--r--work/progress_chart.xlsxbin6654 -> 6423 bytes
22 files changed, 428 insertions, 110 deletions
diff --git a/maps/Main.tscn b/maps/Main.tscn
index 5926205..73a2e45 100644
--- a/maps/Main.tscn
+++ b/maps/Main.tscn
@@ -3,13 +3,13 @@
[ext_resource path="res://scripts/World.gd" type="Script" id=1]
[ext_resource path="res://scenes/machines/Cannon.tscn" type="PackedScene" id=2]
[ext_resource path="res://textures/conc_slabs01_c.png" type="Texture" id=3]
-[ext_resource path="res://scenes/environment/battery.tscn" type="PackedScene" id=4]
+[ext_resource path="res://scenes/worldprops/battery.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/characters/PlayerRigid.tscn" type="PackedScene" id=5]
-[ext_resource path="res://scenes/environment/islandscene.tscn" type="PackedScene" id=6]
+[ext_resource path="res://scenes/worldprops/islandscene.tscn" type="PackedScene" id=6]
[ext_resource path="res://scenes/environment/Water.tscn" type="PackedScene" id=7]
-[ext_resource path="res://scenes/environment/dockscene.tscn" type="PackedScene" id=8]
-[ext_resource path="res://scenes/environment/housescene.tscn" type="PackedScene" id=9]
-[ext_resource path="res://scenes/boats/Gunboat.tscn" type="PackedScene" id=10]
+[ext_resource path="res://scenes/worldprops/dockscene.tscn" type="PackedScene" id=8]
+[ext_resource path="res://scenes/worldprops/housescene.tscn" type="PackedScene" id=9]
+[ext_resource path="res://scenes/vehicles/Gunboat.tscn" type="PackedScene" id=10]
[ext_resource path="res://scenes/environment/CaptureFlag.tscn" type="PackedScene" id=11]
[sub_resource type="NavigationMesh" id=14]
@@ -64,10 +64,10 @@ transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -30.546
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6.23753, 0.911655, -35.0974 )
[node name="Cannon" parent="MACHINES" instance=ExtResource( 2 )]
-transform = Transform( 2.98023e-08, 0, 1, 0, 1, 0, -1, 0, 2.98023e-08, -3.28944, 3.80689, -12.7869 )
+transform = Transform( 2.98023e-08, 0, 1, 0, 1, 0, -1, 0, 2.98023e-08, -3.28944, 3.51975, -13.2337 )
[node name="Cannon2" parent="MACHINES" instance=ExtResource( 2 )]
-transform = Transform( 2.98023e-08, 0, 1, 0, 1, 0, -1, 0, 2.98023e-08, 1.99678, 3.78913, -12.5537 )
+transform = Transform( 2.98023e-08, 0, 1, 0, 1, 0, -1, 0, 2.98023e-08, 1.99678, 3.51975, -13.0005 )
[node name="CaptureFlag" parent="MACHINES" instance=ExtResource( 11 )]
transform = Transform( -0.854422, 0, 0.519579, 0, 1, 0, -0.519579, 0, -0.854422, -2.70943, 2.59075, 8.79298 )
diff --git a/project.godot b/project.godot
index 1e71650..7a6c98e 100644
--- a/project.godot
+++ b/project.godot
@@ -12,6 +12,7 @@ config_version=4
config/name="boats"
run/main_scene="res://ui/MainMenu.tscn"
+boot_splash/show_image=false
config/icon="res://icon.png"
[debug]
@@ -197,7 +198,6 @@ chat={
[physics]
common/enable_pause_aware_picking=true
-3d/physics_engine="GodotPhysics"
[rendering]
diff --git a/scenes/ballistics/Cannonball.tscn b/scenes/ballistics/Cannonball.tscn
index 294548d..83c3942 100644
--- a/scenes/ballistics/Cannonball.tscn
+++ b/scenes/ballistics/Cannonball.tscn
@@ -3,11 +3,11 @@
[ext_resource path="res://scripts/ballistics/Cannonball.gd" type="Script" id=1]
[sub_resource type="SphereShape" id=1]
-radius = 0.15
+radius = 0.25
[sub_resource type="SphereMesh" id=2]
-radius = 0.15
-height = 0.3
+radius = 0.2
+height = 0.4
radial_segments = 8
rings = 8
@@ -27,12 +27,11 @@ normal_scale = 1.0
normal_texture = SubResource( 5 )
[node name="Cannonball" type="RigidBody"]
-collision_layer = 5
-collision_mask = 15
mass = 10.0
continuous_cd = true
contacts_reported = 2
contact_monitor = true
+can_sleep = false
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="."]
diff --git a/scenes/ballistics/Rocket.gd b/scenes/ballistics/Rocket.gd
index 171a49e..46ca058 100644
--- a/scenes/ballistics/Rocket.gd
+++ b/scenes/ballistics/Rocket.gd
@@ -14,18 +14,15 @@ func _ready():
func get_init_info():
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
- linear_velocity = lv
- angular_velocity = av
-
func _physics_process(delta):
+ print(global_transform.basis.x)
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:
diff --git a/scenes/machines/Cannon.tscn b/scenes/machines/Cannon.tscn
index 8126887..15f1467 100644
--- a/scenes/machines/Cannon.tscn
+++ b/scenes/machines/Cannon.tscn
@@ -49,7 +49,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.368354, 0.499951, 0 )
[node name="PitchJoint" type="Spatial" parent="YawJoint"]
-[node name="MeshInstance" type="MeshInstance" parent="YawJoint/PitchJoint"]
+[node name="Barrel" type="MeshInstance" parent="YawJoint/PitchJoint"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.355227, 0, 0 )
mesh = SubResource( 4 )
skeleton = NodePath("../..")
diff --git a/scenes/vehicles/Airplane.tscn b/scenes/vehicles/Airplane.tscn
new file mode 100644
index 0000000..2b46297
--- /dev/null
+++ b/scenes/vehicles/Airplane.tscn
@@ -0,0 +1,155 @@
+[gd_scene load_steps=14 format=2]
+
+[ext_resource path="res://scripts/vehicles/Airplane.gd" type="Script" id=1]
+[ext_resource path="res://scripts/cameras/plane_armcam.gd" type="Script" id=2]
+
+[sub_resource type="PhysicsMaterial" id=1]
+rough = true
+
+[sub_resource type="Curve" id=10]
+_data = [ Vector2( 0, 0.119632 ), 0.0, 0.0, 0, 0, Vector2( 0.172819, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.823825, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
+
+[sub_resource type="CurveTexture" id=11]
+width = 1024
+curve = SubResource( 10 )
+
+[sub_resource type="ConvexPolygonShape" id=2]
+points = PoolVector3Array( -1, 1.25, 5, 1, 1.25, -5, 1, 1.25, 5, -1, 1.25, -5, -1, -1.25, 5, 1, -1.25, -5, 1, -1.25, 5, -1, -1.25, -5, 1, 1.25, 5, -1, 1.25, -5, 1, 1.25, -5, -1, 1.25, 5, 1, -1.25, 5, -1, -1.25, -5, 1, -1.25, -5, -1, -1.25, 5, 1, 1.25, 5, -1, -1.25, 5, -1, 1.25, 5, 1, -1.25, 5, 1, 1.25, -5, -1, -1.25, -5, -1, 1.25, -5, 1, -1.25, -5 )
+
+[sub_resource type="CubeMesh" id=3]
+size = Vector3( 2, 2.5, 10 )
+
+[sub_resource type="ConvexPolygonShape" id=4]
+points = PoolVector3Array( -3.75, 0.75, 1, 3.75, 0.75, -1, 3.75, 0.75, 1, -3.75, 0.75, -1, -3.75, -0.75, 1, 3.75, -0.75, -1, 3.75, -0.75, 1, -3.75, -0.75, -1, 3.75, 0.75, 1, -3.75, 0.75, -1, 3.75, 0.75, -1, -3.75, 0.75, 1, 3.75, -0.75, 1, -3.75, -0.75, -1, 3.75, -0.75, -1, -3.75, -0.75, 1, 3.75, 0.75, 1, -3.75, -0.75, 1, -3.75, 0.75, 1, 3.75, -0.75, 1, 3.75, 0.75, -1, -3.75, -0.75, -1, -3.75, 0.75, -1, 3.75, -0.75, -1 )
+
+[sub_resource type="CubeMesh" id=5]
+size = Vector3( 7.5, 1.5, 2 )
+
+[sub_resource type="BoxShape" id=6]
+extents = Vector3( 0.1, 0.7, 0.7 )
+
+[sub_resource type="CylinderMesh" id=7]
+top_radius = 0.53
+bottom_radius = 0.53
+height = 0.2
+
+[sub_resource type="CylinderMesh" id=8]
+top_radius = 0.353
+bottom_radius = 0.353
+height = 0.2
+radial_segments = 15
+
+[sub_resource type="BoxShape" id=9]
+extents = Vector3( 0.724395, 1.80197, 2.26702 )
+
+[node name="Airplane" type="VehicleBody" groups=["units"]]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00643909, 0, 0 )
+mass = 275.0
+physics_material_override = SubResource( 1 )
+can_sleep = false
+angular_damp = 0.0
+script = ExtResource( 1 )
+roll_curve = SubResource( 11 )
+
+[node name="wings" type="CollisionShape" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.28666, 0.689653, 0 )
+shape = SubResource( 2 )
+
+[node name="MeshInstance" type="MeshInstance" parent="wings"]
+mesh = SubResource( 3 )
+
+[node name="fuselage" type="CollisionShape" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.562053, 0.213096, 0 )
+shape = SubResource( 4 )
+
+[node name="MeshInstance" type="MeshInstance" parent="fuselage"]
+mesh = SubResource( 5 )
+
+[node name="leftwheel" type="VehicleWheel" parent="."]
+transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 3.50873, -1.85594, -2.02883 )
+wheel_radius = 0.53
+wheel_rest_length = 0.1
+wheel_friction_slip = 2.0
+suspension_travel = 0.1
+suspension_stiffness = 200.0
+suspension_max_force = 400000.0
+damping_compression = 0.95
+damping_relaxation = 1.0
+
+[node name="Area" type="Area" parent="leftwheel"]
+transform = Transform( 1, -1.57356e-28, 0, 0, 1, 0, 0, -6.87825e-36, 1, 0, 0, 0 )
+
+[node name="CollisionShape" type="CollisionShape" parent="leftwheel/Area"]
+shape = SubResource( 6 )
+
+[node name="MeshInstance" type="MeshInstance" parent="leftwheel"]
+transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0 )
+mesh = SubResource( 7 )
+
+[node name="rightwheel" type="VehicleWheel" parent="."]
+transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 1.57356e-28, -4.37114e-08, 3.50873, -1.85594, 1.83604 )
+wheel_radius = 0.53
+wheel_rest_length = 0.1
+wheel_friction_slip = 2.0
+suspension_travel = 0.1
+suspension_stiffness = 200.0
+suspension_max_force = 400000.0
+damping_compression = 0.95
+damping_relaxation = 1.0
+
+[node name="Area" type="Area" parent="rightwheel"]
+
+[node name="CollisionShape" type="CollisionShape" parent="rightwheel/Area"]
+shape = SubResource( 6 )
+
+[node name="MeshInstance" type="MeshInstance" parent="rightwheel"]
+transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0 )
+mesh = SubResource( 7 )
+
+[node name="rearwheel" type="VehicleWheel" parent="."]
+transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -2.66361, -1.27391, 0 )
+wheel_radius = 0.353
+wheel_rest_length = 0.07
+wheel_friction_slip = 5.0
+suspension_travel = 0.05
+suspension_stiffness = 200.0
+suspension_max_force = 400000.0
+damping_compression = 0.95
+damping_relaxation = 1.0
+
+[node name="MeshInstance" type="MeshInstance" parent="rearwheel"]
+transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0 )
+mesh = SubResource( 8 )
+
+[node name="armcam" type="SpringArm" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.22602, 0.452069, 0 )
+spring_length = 15.0
+margin = 0.03
+script = ExtResource( 2 )
+
+[node name="ClippedCamera" type="ClippedCamera" parent="armcam"]
+current = true
+fov = 79.2
+near = 0.12
+far = 8192.0
+
+[node name="rightaileron" type="Spatial" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.02201, 0.827813, 5.17292 )
+
+[node name="wingcenter" type="Spatial" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.02202, 0.828033, 0 )
+
+[node name="leftaileron" type="Spatial" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.02201, 0.827813, -5.21093 )
+
+[node name="tail" type="Spatial" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.3164, 0.456713, 0 )
+
+[node name="TugArea" type="Area" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.58015, -0.728266, 0 )
+collision_layer = 131072
+collision_mask = 0
+
+[node name="CollisionShape" type="CollisionShape" parent="TugArea"]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.47757, 0 )
+shape = SubResource( 9 )
diff --git a/scenes/boats/Gunboat.tscn b/scenes/vehicles/Gunboat.tscn
index 6678ac8..2e81bcd 100644
--- a/scenes/boats/Gunboat.tscn
+++ b/scenes/vehicles/Gunboat.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=29 format=2]
-[ext_resource path="res://scripts/boats/Gunboat.gd" type="Script" id=1]
+[ext_resource path="res://scripts/vehicles/Gunboat.gd" type="Script" id=1]
[ext_resource path="res://scenes/machines/Cannon.tscn" type="PackedScene" id=2]
[ext_resource path="res://textures/planks.jpg" type="Texture" id=3]
[ext_resource path="res://meshes/laetine_mask.obj" type="ArrayMesh" id=4]
@@ -108,6 +108,7 @@ points = PoolVector3Array( 1, 0.174966, 1.25, 1, -0.175, 1.25, 1, 0.174966, -1.2
[node name="Gunboat" type="RigidBody"]
mass = 13500.0
physics_material_override = SubResource( 28 )
+can_sleep = false
linear_damp = 1.0
angular_damp = 1.0
script = ExtResource( 1 )
diff --git a/scenes/weapons/rockets.gd b/scenes/weapons/rockets.gd
index fedeebd..56282e1 100644
--- a/scenes/weapons/rockets.gd
+++ b/scenes/weapons/rockets.gd
@@ -22,7 +22,7 @@ func attack1():
if cooldown_time <= 0.0 and ammo >= 1:
ammo -= 1
cooldown_time = reload_time
- rpc("add_rocket_to_scene", -1*player.cam.global_transform.basis.z, get_tree().get_network_unique_id())
+ rpc("add_rocket_to_scene", player.cam.global_transform.basis, get_tree().get_network_unique_id())
remotesync func add_rocket_to_scene(dir, id):
var rocket = preload("res://scenes/ballistics/Rocket.tscn").instance()
@@ -30,7 +30,7 @@ remotesync func add_rocket_to_scene(dir, id):
rocket.shooter = player.name + " (" + world.players_info[player.get_network_master()][0] + ")"
rocket.shooter_id = id
rocket.global_transform.origin = player.cam.global_transform.origin
- rocket.global_transform.basis.x = dir
+ rocket.global_transform.basis = Basis(-1*dir.z, dir.y, dir.x)
rocket.add_collision_exception_with(player)
func attack2():
diff --git a/scenes/environment/battery.tscn b/scenes/worldprops/battery.tscn
index f21b4d9..f21b4d9 100644
--- a/scenes/environment/battery.tscn
+++ b/scenes/worldprops/battery.tscn
diff --git a/scenes/environment/dockscene.tscn b/scenes/worldprops/dockscene.tscn
index 6bf7f31..6bf7f31 100644
--- a/scenes/environment/dockscene.tscn
+++ b/scenes/worldprops/dockscene.tscn
diff --git a/scenes/environment/housescene.tscn b/scenes/worldprops/housescene.tscn
index 5a60d0d..5a60d0d 100644
--- a/scenes/environment/housescene.tscn
+++ b/scenes/worldprops/housescene.tscn
diff --git a/scenes/environment/islandscene.tscn b/scenes/worldprops/islandscene.tscn
index 6226569..6226569 100644
--- a/scenes/environment/islandscene.tscn
+++ b/scenes/worldprops/islandscene.tscn
diff --git a/scripts/Server.gd b/scripts/Server.gd
index 731663c..bf1acbb 100644
--- a/scripts/Server.gd
+++ b/scripts/Server.gd
@@ -101,9 +101,10 @@ func _client_request_change_character(arguments):
func _client_request_control_vehicle(arguments):
var dest_machine = world.get_node("MACHINES/"+arguments["machine"])
+ var name = "BOT" if arguments["id"] == 1 else connected_players[arguments["id"]][0]
if dest_machine != null and dest_machine.get_network_master() == 1 and !dest_machine.in_use:
- print_line(connected_players[arguments["id"]][0] + " is controlling " + arguments["machine"])
- dest_machine.rpc("set_net_owner", arguments["id"])
+ print_line(arguments["char_name"] + "(" + name + ") is controlling " + arguments["machine"])
+ dest_machine.rpc("set_net_owner", arguments["id"], arguments["char_name"])
func _character_death(arguments):
var victim_player = connected_players[arguments["victim_mp_id"]][0] if arguments["victim_mp_id"] != 1 else ""
diff --git a/scripts/ballistics/Cannonball.gd b/scripts/ballistics/Cannonball.gd
index 7b56577..14de00c 100644
--- a/scripts/ballistics/Cannonball.gd
+++ b/scripts/ballistics/Cannonball.gd
@@ -12,6 +12,6 @@ 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 linear_velocity.length() > 20 and !damage_exceptions.has(body) and body.has_method("damage"):
+ 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)
diff --git a/scripts/cameras/plane_armcam.gd b/scripts/cameras/plane_armcam.gd
new file mode 100644
index 0000000..edb0284
--- /dev/null
+++ b/scripts/cameras/plane_armcam.gd
@@ -0,0 +1,26 @@
+extends SpringArm
+
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+ $ClippedCamera.add_exception(get_parent())
+ add_excluded_object(get_parent().get_rid())
+
+
+#func _process(delta):
+
+
+func _input(event):
+ if $ClippedCamera.current:
+ if Input.is_action_just_pressed("menu"): #toggle mouse capture on esc
+ if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
+ Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+ else:
+ Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+
+ if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
+ if event is InputEventMouseMotion:
+ rotation_degrees.x = clamp(rotation_degrees.x-event.relative.y*0.1,-70,70)
+ rotation_degrees.y -= event.relative.x*0.1
diff --git a/scripts/cameras/player_firstperson.gd b/scripts/cameras/player_firstperson.gd
new file mode 100644
index 0000000..ace49e6
--- /dev/null
+++ b/scripts/cameras/player_firstperson.gd
@@ -0,0 +1,33 @@
+extends Camera
+
+
+var mouse_axis := Vector2()
+var mouse_sensitivity = 12.0
+
+func _ready():
+ Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+ current = false
+
+
+func _input(event):
+ if current:
+ if Input.is_action_just_pressed("menu"): #toggle mouse capture on esc
+ if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
+ Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+ else:
+ Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+ if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
+ mouse_axis = event.relative
+ if mouse_axis.length() > 0:
+ var horizontal: float = -mouse_axis.x * (mouse_sensitivity / 100)
+ var vertical: float = -mouse_axis.y * (mouse_sensitivity / 100)
+
+ mouse_axis = Vector2()
+
+ get_parent().rotate_y(deg2rad(horizontal))
+ rotate_x(deg2rad(vertical))
+
+ var temp_rot: Vector3 = rotation_degrees
+ temp_rot.x = clamp(temp_rot.x, -90, 90)
+ get_parent().animationcontroller.rpc("lean",-1*temp_rot.x/90)
+ rotation_degrees = temp_rot
diff --git a/scripts/characters/player_controller_new.gd b/scripts/characters/player_controller_new.gd
index 9c8f4ee..f58c689 100644
--- a/scripts/characters/player_controller_new.gd
+++ b/scripts/characters/player_controller_new.gd
@@ -92,16 +92,12 @@ func _process(_delta: float) -> void:
func initiate_use():
if controlling_machine:
machine.relinquish_control()
- machine = null
- controlling_machine = false
- if is_player:
- cam.current = true
return
if $Head/Camera/UseRay.is_colliding():
var area_c = $Head/Camera/UseRay.get_collider()
match area_c.name:
"SteerArea":
- world.rpc_id(1, "_call_on_server", "_client_request_control_vehicle", {"id" : world.client_id, "machine" : area_c.get_parent().name})
+ world.rpc_id(1, "_call_on_server", "_client_request_control_vehicle", {"id" : world.client_id, "machine" : area_c.get_parent().name, "char_name" : name})
#controlling_machine = true
#machine = $Head/Camera/UseRay.get_collider().get_parent().take_control(self)
#var gt = global_transform.origin
@@ -135,7 +131,13 @@ func deselect_character():
world.get_node("DEFAULTCAM").current = true
rpc("set_net_owner", 1)
-func regain_control(_gt):
+func take_control_of_machine(slave_machine):
+ machine = slave_machine
+ controlling_machine = true
+
+func lose_machine():
+ if is_player:
+ cam.current = true
controlling_machine = false
machine = null
@@ -153,10 +155,7 @@ func _physics_process(delta: float) -> void:
func on_floor_test() -> bool:
if $Feet.is_colliding():
is_on_floor = true
- if $Feet.get_collider().has_method("get_linear_velocity"):
- floorspeed = $Feet.get_collider().get_linear_velocity()
- else:
- floorspeed = Vector3.ZERO
+ floorspeed = $Feet.get_collider().get_linear_velocity() if $Feet.get_collider().has_method("get_linear_velocity") else Vector3.ZERO
return true
if player_state:
for i in range(player_state.get_contact_count()):
@@ -247,6 +246,8 @@ remotesync func damage(dmg_amt, type, shooter, extra = ""):
if shooter[0] != get_network_master(): world.rpc_id(shooter[0], "game_hitsound")
remotesync func remove_dead_character():
+ if is_network_master() and machine != null:
+ machine.relinquish_control()
deselect_character()
queue_free()
diff --git a/scripts/machines/Cannon.gd b/scripts/machines/Cannon.gd
index e7a5441..3cf6f5d 100644
--- a/scripts/machines/Cannon.gd
+++ b/scripts/machines/Cannon.gd
@@ -1,12 +1,10 @@
-extends RigidBody
-#Basis
-var in_use : bool = false
-var user = null
-var world = null
+extends "res://scripts/machines/NetworkedMachine.gd"
+
+var world_ballistics = null
var cooldown = 0
export var fire_rate = 1 #shot/s
-export var ball_speed = 500 #m/s
+export var ball_speed = 400 #m/s
var pitch :float = 0.0
var turn :float = 0.0
@@ -21,10 +19,9 @@ export var max_yaw = 15
onready var muzzle = get_node("YawJoint/PitchJoint/Muzzle")
-remote func update_phys_transform(t, lv, av):
- transform = t
- linear_velocity = lv
- angular_velocity = av
+remote func update_aim(pitch_z, yaw_y):
+ $YawJoint/PitchJoint.rotation_degrees.z = pitch_z
+ $YawJoint.rotation_degrees.y = yaw_y
func get_init_info():
return {"pitch_rot" : $YawJoint/PitchJoint.rotation_degrees.z, "turn_rot" : $YawJoint.rotation_degrees.y, "in_use" : in_use}
@@ -39,48 +36,25 @@ func _ready():
if get_parent().name != "MACHINES":
add_collision_exception_with(get_parent())
mode = RigidBody.MODE_STATIC
- world = get_tree().get_root().find_node("BALLISTICS", true, false)
-
-remotesync func set_net_owner(id, char_name):
- set_network_master(id)
- if id != 1 or char_name != "NONE":
- pass
-
-func is_in_use():
- return in_use
-
-func take_control(controller):
+ world_ballistics = world.get_node("BALLISTICS")
+
+func on_new_control():
$YawJoint/PitchJoint/Camera.current = true
- user = controller
- in_use = true
- return self
-
-func relinquish_control():
- in_use = false
- user = null
- rpc("set_owner", 1, "NONE")
func _physics_process(delta):
if cooldown > 0:
cooldown -= delta
- if in_use:
- #aim
+ if in_use and is_network_master(): #aim
$YawJoint/PitchJoint.rotation_degrees.z += pitch*pitch_speed*delta
$YawJoint.rotation_degrees.y += turn*turn_speed*delta
- if $YawJoint.rotation_degrees.y > max_yaw:
- $YawJoint.rotation_degrees.y = max_yaw
- elif $YawJoint.rotation_degrees.y < min_yaw:
- $YawJoint.rotation_degrees.y = min_yaw
- if $YawJoint/PitchJoint.rotation_degrees.z > max_pitch:
- $YawJoint/PitchJoint.rotation_degrees.z = max_pitch
- elif $YawJoint/PitchJoint.rotation_degrees.z < min_pitch:
- $YawJoint/PitchJoint.rotation_degrees.z = min_pitch
- if is_network_master() and mode == MODE_STATIC:
- rpc("update_phys_transform", transform, linear_velocity, angular_velocity)
+ $YawJoint.rotation_degrees.y = clamp($YawJoint.rotation_degrees.y, min_yaw, max_yaw)
+ $YawJoint/PitchJoint.rotation_degrees.z = clamp($YawJoint/PitchJoint.rotation_degrees.z, min_pitch, max_pitch)
+
+ rpc("update_aim", $YawJoint/PitchJoint.rotation_degrees.z, $YawJoint.rotation_degrees.y)
func direction_input(fwd,bwd,left,right,_left,_right):
pitch = fwd - bwd
- turn = left - right
+ turn = right - left
func attack1():
if cooldown > 0:
@@ -91,8 +65,9 @@ remotesync func fire():
$YawJoint/PitchJoint/Muzzle/explosion_sound.play()
var expl = preload("res://particles/p_Explosion.tscn").instance()
var cball = preload("res://scenes/ballistics/Cannonball.tscn").instance()
- world.add_child(cball)
+ world_ballistics.add_child(cball, true)
world.add_child(expl)
+ expl.scale = Vector3(0.25,0.25,0.25)
expl.init(muzzle.global_transform.origin, Vector3.ZERO)
add_collision_exception_with(cball)
cball.global_transform.origin = muzzle.global_transform.origin
@@ -102,6 +77,3 @@ remotesync func fire():
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:
apply_impulse($YawJoint/PitchJoint.global_transform.origin - global_transform.origin, -1*cball.mass*ball_speed*muzzle.global_transform.basis.x)
-
-func attack2():
- pass
diff --git a/scripts/machines/NetworkedMachine.gd b/scripts/machines/NetworkedMachine.gd
new file mode 100644
index 0000000..d4ccb61
--- /dev/null
+++ b/scripts/machines/NetworkedMachine.gd
@@ -0,0 +1,54 @@
+extends RigidBody
+
+var in_use : bool = false
+var user = null
+var world = null
+
+func _ready():
+ world = get_tree().get_root().find_node("GAMEWORLD", true, false)
+
+remote func update_phys_transform(t, lv, av):
+ transform = t
+ linear_velocity = lv
+ angular_velocity = av
+
+remotesync func net_apply_impulse(impulse_v):
+ apply_central_impulse(impulse_v)
+
+func _integrate_forces(state):
+ if is_network_master() and mode == MODE_RIGID:
+ rpc("update_phys_transform", transform, linear_velocity, angular_velocity)
+
+remotesync func set_net_owner(id, char_name):
+ set_network_master(id)
+ if id == 1 and char_name == "NONE": #not under control
+ on_no_control()
+ if user != null:
+ user.lose_machine()
+ user = null
+ in_use = false
+ else:
+ in_use = true
+ user = world.get_node("PLAYERS/"+char_name)
+ user.take_control_of_machine(self)
+ if is_network_master():
+ on_new_control()
+
+func relinquish_control():
+ rpc("set_net_owner", 1, "NONE")
+
+#TO BE OVERRIDDEN BY CHILDREN
+func on_new_control():
+ pass
+
+func on_no_control():
+ pass
+
+func attack1():
+ pass
+
+func attack2():
+ pass
+
+func direction_input(fwd,bwd,left,right,_left,_right):
+ pass
diff --git a/scripts/vehicles/Airplane.gd b/scripts/vehicles/Airplane.gd
new file mode 100644
index 0000000..cf3c21a
--- /dev/null
+++ b/scripts/vehicles/Airplane.gd
@@ -0,0 +1,106 @@
+extends VehicleBody
+
+var countdown
+var boosting = false
+const booster_force = 2500
+const brake_force = 50
+const boost_length = 8
+const turn_constant = 0.45
+const roll_constant = 0.5
+const pitch_constant = 0.9
+const drag_constant = 0.4
+const v_angle_max = 1.0472 #60 deg, also top and bottom of regular steering
+const v_angle_min = -1.45626 #-85 deg
+const roll_angle_max = 1.22173 #70 deg
+var roll_dir = 0 #right = 1, left = -1
+var pitch_dir = 0 #up = 1, down = -1
+var v_angle
+var roll_angle
+var vel_slow
+var parentvel = [Vector3.ZERO, Vector3.ZERO]
+export var roll_curve : CurveTexture
+
+
+
+func _ready():
+ countdown = boost_length
+ brake = 5
+ set_network_master(-1)
+ set_physics_process(true)
+ #mode = RigidBody.MODE_STATIC
+
+func trigger_boost():
+ if not boosting:
+ print("boosting")
+ boosting = true
+
+func _process(delta):
+ if is_network_master():
+ if boosting and countdown <= 0:
+ print("stopped boosting")
+ boosting = false
+ countdown = boost_length
+
+ if Input.is_action_just_pressed("boost"):
+ trigger_boost()
+ roll_dir = Input.get_action_strength("roll_left") - Input.get_action_strength("roll_right")
+ pitch_dir = Input.get_action_strength("pitch_up") - Input.get_action_strength("pitch_down")
+ $rearwheel.brake = lerp($rearwheel.brake, Input.get_action_strength("brake")*brake_force, 0.05)
+
+func _physics_process(delta):
+ if is_network_master():
+ v_angle = atan2(global_transform.basis.x.y,sqrt(global_transform.basis.x.z*global_transform.basis.x.z + global_transform.basis.x.x*global_transform.basis.x.x))
+ roll_angle = global_transform.basis.x.cross(Vector3.UP).angle_to($rightaileron.global_transform.origin-$wingcenter.global_transform.origin)
+ if $rightaileron.global_transform.origin.y < $leftaileron.global_transform.origin.y:
+ roll_angle *= -1
+ if boosting:
+ add_force(global_transform.basis.x*booster_force,Vector3.ZERO)
+ countdown -= delta
+
+ #print(linear_velocity.length())
+ #slow plane by drag and gravity
+ if linear_velocity.length() > 16 and linear_velocity.angle_to(global_transform.basis.x) < 0.25:
+ var v_dir = 1 if linear_velocity.y > 0 else -1
+ vel_slow = v_dir*sqrt(abs(2*9.8*linear_velocity.y*delta)) + drag_constant + Input.get_action_strength("brake")*5
+ add_force(-1*linear_velocity.normalized()*vel_slow*mass,Vector3.ZERO)
+
+
+
+ #pass #"inherit" linear and angular velocity of what plane is landed on
+
+func _integrate_forces(state):
+ if is_network_master():
+ #linear_velocity -= parentvel[0]; angular_velocity -= parentvel[1]
+# if $rightwheel.get_rpm() < 60 and $rightwheel.is_in_contact():
+# if $rightwheel/Area.get_overlapping_bodies()[0].has_method("get_linear_velocity"):
+# var ulv = $rightwheel/Area.get_overlapping_bodies()[0].linear_velocity
+# var uav = $rightwheel/Area.get_overlapping_bodies()[0].angular_velocity
+# var upos = $rightwheel/Area.get_overlapping_bodies()[0].global_transform.origin
+# ulv += (global_transform.origin - upos).rotated(uav.normalized(),uav.length()*state.get_step()) + global_transform.origin
+# parentvel = [ulv,uav]
+# else:
+# parentvel = [Vector3.ZERO, Vector3.ZERO]
+ if linear_velocity.length() > 25:
+ #linear_velocity = linear_velocity.normalized()*(linear_velocity.length()-vel_slow)
+ var ang_vel_target = Vector3.ZERO
+ #pitch plane
+ if pitch_dir == 1: #up, rotate toward maximum vertical angle
+ ang_vel_target += pitch_constant*(v_angle_max-v_angle)*global_transform.basis.z
+ elif pitch_dir == -1: #down, rotate toward minimum vertical angle
+ ang_vel_target += pitch_constant*(v_angle_min-v_angle)*global_transform.basis.z
+
+ #roll (rotate around lengthwise axis)
+ var is_returning = 3 if roll_dir == 0 else 1 #return to flat quicker
+ ang_vel_target -= roll_constant*is_returning*(roll_dir*roll_curve.curve.interpolate(roll_angle_max-roll_angle))*global_transform.basis.x
+
+ #turn (based on how much the plane is rolled (need to add
+ ang_vel_target += turn_constant*Vector3.UP*roll_angle
+
+ #apply angular velocity
+ angular_velocity = ang_vel_target#lerp(angular_velocity,ang_vel_target,0.1)
+ if linear_velocity.angle_to(global_transform.basis.x) < 0.25:
+ set_linear_velocity(get_linear_velocity().slerp(transform.basis.x*linear_velocity.length(),0.1))
+ #linear_velocity += parentvel[0]; angular_velocity += parentvel[1]
+ rpc("_set_position", global_transform, linear_velocity)
+ elif get_network_master() == -1 and get_tree().get_network_unique_id() == 1:
+ rpc("_set_position", global_transform, linear_velocity)
diff --git a/scripts/boats/Gunboat.gd b/scripts/vehicles/Gunboat.gd
index 6f4f807..2d9731f 100644
--- a/scripts/boats/Gunboat.gd
+++ b/scripts/vehicles/Gunboat.gd
@@ -1,12 +1,4 @@
-extends RigidBody
-
-
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
-var in_use : bool = false
-var user = null
-var world = null
+extends "res://scripts/machines/NetworkedMachine.gd"
export var team = 0
@@ -46,20 +38,10 @@ func _ready():
mass = 13500
weight = mass * 9.8
-func is_in_use():
- return in_use
-
-func take_control(controller):
- user = controller
- in_use = true
- return self
-
-func relinquish_control():
- in_use = false
+func on_no_control():
rudder = 0.0
throttle = 0.0
mainsheet = 0.0
- user = null
func auto_sail(delta):
var in_range = global_transform.basis.x.dot(world.winddir) >= 0
@@ -74,12 +56,6 @@ func auto_sail(delta):
else:
sail_turn += sail_turn_speed*delta
-func attack1():
- pass
-
-func attack2():
- pass
-
func direction_input(fwd,bwd,left,right,_left,_right):
throttle = fwd - bwd
rudder = left - right
@@ -89,9 +65,6 @@ remotesync func damage(amount, _type, shooter, extra = ""):
health -= amount
print(health)
-remotesync func net_apply_impulse(impulse_v):
- apply_central_impulse(impulse_v)
-
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
$Mast/Sail.scale.y = sail_out
diff --git a/work/progress_chart.xlsx b/work/progress_chart.xlsx
index 7e99b9a..e60239a 100644
--- a/work/progress_chart.xlsx
+++ b/work/progress_chart.xlsx
Binary files differ