forked from interstellar_development/freeftf
Milestone 5: Private Testing Release 1
Lot's of changes.
This commit is contained in:
parent
0bd1414af0
commit
40100e8fee
90 changed files with 5741 additions and 156 deletions
|
|
@ -1,16 +1,17 @@
|
|||
## Copyright (C) 2024 Patrick_Pluto
|
||||
## freeftf
|
||||
## Copyright (C) 2024 Patrick_Pluto
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
|
||||
## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
var jump_velocity = 6
|
||||
var speed = 10.0
|
||||
var speed = 7
|
||||
var zoom = 0
|
||||
var player_no
|
||||
var npc = false
|
||||
|
|
@ -30,10 +31,15 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
|||
|
||||
func _ready():
|
||||
player_no = Game.players
|
||||
$nametag.text = Server.players[Server.players_numbered[player_no]]
|
||||
Game.players += 1
|
||||
if Server.players_numbered[player_no] == multiplayer.get_unique_id():
|
||||
if Game.settings["fps_counter"] == 1:
|
||||
$fps_counter.show()
|
||||
$health.show()
|
||||
enabled = true
|
||||
$cam_y/Camera3D.current = true
|
||||
$nametag.hide()
|
||||
else:
|
||||
npc = true
|
||||
|
||||
|
|
@ -42,14 +48,24 @@ func _physics_process(delta):
|
|||
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
|
||||
|
||||
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor() and $jump_timeout.is_stopped():
|
||||
if beast:
|
||||
speed -= 6
|
||||
speed -= 5
|
||||
$jump_timeout.start()
|
||||
velocity.y = jump_velocity
|
||||
|
||||
if Input.is_action_just_pressed("crouch") and !beast:
|
||||
if $collision.rotation.x == 0:
|
||||
$collision.rotation.x = deg_to_rad(-90)
|
||||
speed -= 3
|
||||
$cam_y.position.y = 0
|
||||
else :
|
||||
$collision.rotation.x = 0
|
||||
speed += 3
|
||||
$cam_y.position.y = 0.5
|
||||
position.y += 1
|
||||
|
||||
|
||||
var input_dir = Input.get_vector("left", "right", "forwards", "backwards")
|
||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
|
|
@ -63,17 +79,11 @@ func _physics_process(delta):
|
|||
move_and_slide()
|
||||
|
||||
if !npc:
|
||||
print(hp)
|
||||
Server.sync_player.rpc(name, position, rotation)
|
||||
if $cam_y/Camera3D.position.z == 0:
|
||||
$cam_y.position.y = 1
|
||||
if mouse_locked:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
if mouse_locked:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
$cam_y.position.y = 0
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().change_scene_to_file("res://menus/main_menu.tscn")
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
|
|
@ -98,22 +108,11 @@ func _input(event):
|
|||
$cam_y.rotation.x = -1.6
|
||||
rotate(Vector3.DOWN, camera_rotation.x)
|
||||
|
||||
func _unhandled_input(event):
|
||||
if !npc and !beast:
|
||||
if event.is_action_pressed("zoom_in") && $cam_y/Camera3D.position.z > 0:
|
||||
zoom = -1
|
||||
$cam_y/Camera3D.position.z += zoom
|
||||
elif event.is_action_pressed("zoom_out") && $cam_y/Camera3D.position.z <= 20:
|
||||
zoom = 1
|
||||
$cam_y/Camera3D.position.z += zoom
|
||||
else:
|
||||
zoom = 0
|
||||
|
||||
func beast_init():
|
||||
beast = true
|
||||
speed += 1
|
||||
speed += 2
|
||||
position.y += 10
|
||||
$cam_y/Camera3D.position.z = 0
|
||||
$detect_hit.monitoring = true
|
||||
$detect_hit.monitorable = true
|
||||
$detect_hit/CollisionShape3D.disabled = false
|
||||
|
|
@ -123,14 +122,14 @@ func _on_detect_hit_body_entered(body):
|
|||
if enabled and body is CharacterBody3D and !got_person:
|
||||
Server.player_hit.rpc(body.name, name)
|
||||
|
||||
func captured(beast):
|
||||
func captured(beast2):
|
||||
if !npc:
|
||||
$in_bag.visible = true
|
||||
$time_in_bag.start()
|
||||
visible = false
|
||||
enabled = false
|
||||
caught = true
|
||||
captured_by = beast
|
||||
captured_by = beast2
|
||||
position_pre = position
|
||||
position = Vector3(10000, 10000, 10000)
|
||||
|
||||
|
|
@ -163,8 +162,9 @@ func _on_time_in_bag_timeout():
|
|||
|
||||
|
||||
func _on_show_fps_timeout():
|
||||
print("FPS: "+str(Engine.get_frames_per_second()))
|
||||
$fps_counter.text = "FPS: "+str(Engine.get_frames_per_second())
|
||||
$health.text = "HP: "+str(hp)
|
||||
|
||||
|
||||
func _on_jump_timeout_timeout():
|
||||
speed += 6
|
||||
speed += 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue