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,10 +1,11 @@
|
|||
## 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 StaticBody3D
|
||||
|
||||
|
@ -32,36 +33,36 @@ func _on_computer_tick_timeout():
|
|||
|
||||
|
||||
func _on_pc_1_area_body_entered(body):
|
||||
if pc_occupied[0] == 0 and !body.beast:
|
||||
if pc_occupied[0] == 0 and body is CharacterBody3D and !body.beast:
|
||||
pc_occupied[0] = 1
|
||||
pc_body[0] = body
|
||||
|
||||
|
||||
func _on_pc_2_area_body_entered(body):
|
||||
if pc_occupied[1] == 0 and !body.beast:
|
||||
if pc_occupied[1] == 0 and body is CharacterBody3D and !body.beast:
|
||||
pc_occupied[1] = 1
|
||||
pc_body[1] = body
|
||||
|
||||
|
||||
func _on_pc_3_area_body_entered(body):
|
||||
if pc_occupied[2] == 0 and !body.beast:
|
||||
if pc_occupied[2] == 0 and body is CharacterBody3D and !body.beast:
|
||||
pc_occupied[2] = 1
|
||||
pc_body[2] = body
|
||||
|
||||
|
||||
func _on_pc_1_area_body_exited(body):
|
||||
if pc_occupied[0] == 1 and body == pc_body[0]:
|
||||
if pc_occupied[0] == 1 and body is CharacterBody3D and body == pc_body[0]:
|
||||
pc_occupied[0] = 0
|
||||
pc_body[0] = 0
|
||||
|
||||
|
||||
func _on_pc_2_area_body_exited(body):
|
||||
if pc_occupied[1] == 1 and body == pc_body[1]:
|
||||
if pc_occupied[1] == 1 and body is CharacterBody3D and body == pc_body[1]:
|
||||
pc_occupied[1] = 0
|
||||
pc_body[1] = 0
|
||||
|
||||
|
||||
func _on_pc_3_area_body_exited(body):
|
||||
if pc_occupied[2] == 1 and body == pc_body[2]:
|
||||
if pc_occupied[2] == 1 and body is CharacterBody3D and body == pc_body[2]:
|
||||
pc_occupied[2] = 0
|
||||
pc_body[2] = 0
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
## 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 Control
|
||||
|
||||
var elevated = false
|
||||
|
||||
func _ready():
|
||||
if Server.is_server:
|
||||
$player_customization/ip.hide()
|
||||
|
@ -19,8 +22,12 @@ func _ready():
|
|||
|
||||
func _process(delta):
|
||||
if Server.is_server:
|
||||
Server.sync_playerlist.rpc($player_list/list.text)
|
||||
|
||||
Server.sync_playerlist.rpc($player_list/list.text, multiplayer.get_unique_id())
|
||||
if Server.is_server and !elevated:
|
||||
_ready()
|
||||
Server.send_playerinfo($player_customization/name.text, multiplayer.get_unique_id())
|
||||
elevated = true
|
||||
|
||||
func _on_start_pressed():
|
||||
Server.start_game.rpc(Server.players)
|
||||
|
||||
|
@ -37,7 +44,6 @@ func _on_join_pressed():
|
|||
$player_customization/join.disabled = true
|
||||
$player_customization/name.editable = false
|
||||
$player_customization/ip.editable = false
|
||||
while $player_list/list.text == "":
|
||||
await get_tree().create_timer(0.001).timeout
|
||||
await get_tree().create_timer(1).timeout
|
||||
Server.send_playerinfo.rpc($player_customization/name.text, multiplayer.get_unique_id())
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
## 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 StaticBody3D
|
||||
|
||||
|
@ -19,19 +20,18 @@ func _process(delta):
|
|||
living = false
|
||||
|
||||
func _on_area_3d_body_entered(body):
|
||||
if body is StaticBody3D:
|
||||
pass
|
||||
elif body.beast and body.got_person and !occupied:
|
||||
trapped_body = body.caught_body
|
||||
occupied = true
|
||||
living = true
|
||||
body.lost_one()
|
||||
trapped_body.frozen()
|
||||
elif !body.beast and occupied and living and body != trapped_body:
|
||||
trapped_body.unfreeze()
|
||||
trapped_body._on_time_in_bag_timeout()
|
||||
occupied = false
|
||||
trapped_body = null
|
||||
if body is CharacterBody3D:
|
||||
if body.beast and body.got_person and !occupied:
|
||||
trapped_body = body.caught_body
|
||||
occupied = true
|
||||
living = true
|
||||
body.lost_one()
|
||||
trapped_body.frozen()
|
||||
elif !body.beast and occupied and living and body != trapped_body:
|
||||
trapped_body.unfreeze()
|
||||
trapped_body._on_time_in_bag_timeout()
|
||||
occupied = false
|
||||
trapped_body = null
|
||||
|
||||
func _on_timer_timeout():
|
||||
if occupied and living:
|
||||
|
|
|
@ -1,15 +1,29 @@
|
|||
## 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 Node
|
||||
|
||||
var settings = {"save_version" = 2, "fps_counter" = 1}
|
||||
var computers = 0
|
||||
var players = 0
|
||||
var is_creating = false
|
||||
var map_name = "mansion"
|
||||
|
||||
func _ready():
|
||||
if FileAccess.file_exists("user://settings.json"):
|
||||
var temp = Load.loadJSON("user://settings.json")
|
||||
if !(temp is Dictionary) or settings["save_version"] != temp["save_version"]:
|
||||
Save.saveJSON("user://settings.json", settings)
|
||||
else:
|
||||
settings = temp
|
||||
else:
|
||||
Save.saveJSON("user://settings.json", settings)
|
||||
|
||||
func _process(delta):
|
||||
pass
|
||||
|
@ -18,4 +32,10 @@ func reset():
|
|||
computers = 0
|
||||
players = 0
|
||||
|
||||
func save_setting(setting_name, value):
|
||||
settings[setting_name] = value
|
||||
Save.saveJSON("user://settings.json", settings)
|
||||
|
||||
func apply_settings():
|
||||
pass
|
||||
|
||||
|
|
29
scripts/load.gd
Normal file
29
scripts/load.gd
Normal file
|
@ -0,0 +1,29 @@
|
|||
## 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, 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.
|
||||
##
|
||||
## 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 Node
|
||||
|
||||
func loadJSON(savePath):
|
||||
if not FileAccess.file_exists(savePath):
|
||||
return 1
|
||||
|
||||
var fileAccess = FileAccess.open(savePath, FileAccess.READ)
|
||||
|
||||
var jsonString = fileAccess.get_line()
|
||||
|
||||
fileAccess.close()
|
||||
|
||||
var json = JSON.new()
|
||||
|
||||
var error = json.parse(jsonString)
|
||||
|
||||
if error:
|
||||
return 1
|
||||
|
||||
return json.data
|
|
@ -1,30 +1,35 @@
|
|||
## 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 Control
|
||||
|
||||
func matchmaking():
|
||||
get_tree().root.get_node("./main_menu").hide()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
if !OS.is_debug_build():
|
||||
$main_content/matchmaking.hide()
|
||||
|
||||
func _on_create_pressed():
|
||||
Server.create_game()
|
||||
Server.is_server = true
|
||||
get_tree().change_scene_to_file("res://menus/create.tscn")
|
||||
|
||||
|
||||
func _on_join_pressed():
|
||||
get_tree().change_scene_to_file("res://menus/create.tscn")
|
||||
|
||||
|
||||
|
||||
func _on_settings_pressed():
|
||||
get_tree().change_scene_to_file("res://menus/settings.tscn")
|
||||
|
||||
|
||||
func _on_matchmaking_pressed():
|
||||
Server.create_game()
|
||||
matchmaking()
|
||||
|
||||
|
|
15
scripts/main_settings.gd
Normal file
15
scripts/main_settings.gd
Normal file
|
@ -0,0 +1,15 @@
|
|||
## 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, 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.
|
||||
##
|
||||
## 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 Control
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().change_scene_to_file("res://menus/main_menu.tscn")
|
|
@ -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
|
||||
|
|
23
scripts/save.gd
Normal file
23
scripts/save.gd
Normal file
|
@ -0,0 +1,23 @@
|
|||
## 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, 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.
|
||||
##
|
||||
## 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 Node
|
||||
|
||||
func saveJSON(savePath, saveData):
|
||||
var jsonString = JSON.stringify(saveData)
|
||||
|
||||
var fileAccess = FileAccess.open(savePath, FileAccess.WRITE)
|
||||
|
||||
if not fileAccess:
|
||||
print("An error happened while saving data: ", FileAccess.get_open_error())
|
||||
return 1
|
||||
|
||||
fileAccess.store_line(jsonString)
|
||||
|
||||
fileAccess.close()
|
|
@ -1,10 +1,11 @@
|
|||
## 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 Node
|
||||
|
||||
|
@ -18,6 +19,10 @@ var label
|
|||
var map
|
||||
var character = preload("res://objects/player.tscn")
|
||||
var is_server = false
|
||||
var first_joined = true
|
||||
var game_master = "debug"
|
||||
var host_announced = false
|
||||
var map_name = "mansion"
|
||||
|
||||
func reset():
|
||||
players = {}
|
||||
|
@ -43,68 +48,95 @@ func create_game():
|
|||
if error:
|
||||
return error
|
||||
multiplayer.multiplayer_peer = peer
|
||||
|
||||
func _process(delta):
|
||||
if multiplayer.is_server():
|
||||
make_host.rpc(game_master)
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func make_host(id):
|
||||
first_joined = false
|
||||
game_master = id
|
||||
if str(multiplayer.get_unique_id()) == str(game_master):
|
||||
is_server = true
|
||||
else:
|
||||
is_server = false
|
||||
|
||||
@rpc("authority", "call_remote", "reliable")
|
||||
func sync_playerlist(text):
|
||||
get_tree().root.get_node("create/player_list/list").text = text
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
func sync_playerlist(text, host):
|
||||
if !multiplayer.is_server() and (multiplayer.get_remote_sender_id() == game_master or multiplayer.get_remote_sender_id() == 0):
|
||||
get_tree().root.get_node("create/player_list/list").text = text
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func send_playerinfo(name, id):
|
||||
if Server.is_server:
|
||||
var done = 0
|
||||
players[id] = name
|
||||
label = get_tree().root.get_node("create/player_list/list")
|
||||
label.text = ""
|
||||
for w in players:
|
||||
if done == 1:
|
||||
label.text = str(label.text +"\n" + players[w])
|
||||
else:
|
||||
label.text = players[w]
|
||||
done = 1
|
||||
func send_playerinfo(player_name, id):
|
||||
if !multiplayer.is_server():
|
||||
if is_server:
|
||||
var done = 0
|
||||
players[id] = player_name
|
||||
label = get_tree().root.get_node("create/player_list/list")
|
||||
label.text = ""
|
||||
for w in players:
|
||||
if done == 1:
|
||||
label.text = str(label.text +"\n" + players[w])
|
||||
else:
|
||||
label.text = players[w]
|
||||
done = 1
|
||||
else:
|
||||
if first_joined:
|
||||
first_joined = false
|
||||
game_master = id
|
||||
is_server = true
|
||||
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func start_game(server_players):
|
||||
players = server_players
|
||||
players_numbered = players.keys()
|
||||
var success = get_tree().change_scene_to_file("res://maps/base_map.tscn")
|
||||
while !get_tree().root.has_node("./map/"):
|
||||
await get_tree().create_timer(0.001).timeout
|
||||
map = get_tree().root.get_node("./map/")
|
||||
var i = 0
|
||||
for w in players:
|
||||
var player = character.instantiate()
|
||||
player.name = "player" + str(i)
|
||||
i += 1
|
||||
player.position.z = -i*2.5
|
||||
map.add_child(player)
|
||||
if Server.is_server:
|
||||
var random = randi() % Server.players.size()
|
||||
sync_beast.rpc(random)
|
||||
if !multiplayer.is_server() and (multiplayer.get_remote_sender_id() == game_master or multiplayer.get_remote_sender_id() == 0):
|
||||
players = server_players
|
||||
players_numbered = players.keys()
|
||||
var success = get_tree().change_scene_to_file("res://maps/"+map_name+".tscn")
|
||||
while !get_tree().root.has_node("./"+map_name+"/"):
|
||||
await get_tree().create_timer(0.001).timeout
|
||||
map = get_tree().root.get_node("./"+map_name+"/")
|
||||
var i = 0
|
||||
for w in players:
|
||||
var player = character.instantiate()
|
||||
player.name = "player" + str(i)
|
||||
i += 1
|
||||
player.position.z = -i*2.5
|
||||
player.position.y = 1
|
||||
map.add_child(player)
|
||||
if Server.is_server:
|
||||
var random = randi() % Server.players.size()
|
||||
sync_beast.rpc(random)
|
||||
Game.apply_settings()
|
||||
|
||||
@rpc("any_peer", "call_remote", "unreliable")
|
||||
func sync_player(node_name, position, rotation):
|
||||
var current_character = get_tree().root.get_node("./map/"+node_name)
|
||||
current_character.position = position
|
||||
current_character.rotation = rotation
|
||||
if !multiplayer.is_server():
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/"+node_name)
|
||||
current_character.position = position
|
||||
current_character.rotation = rotation
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_computers(node_name, current):
|
||||
var current_character = get_tree().root.get_node("./map/"+node_name)
|
||||
current_character.current = current
|
||||
if !multiplayer.is_server() and (multiplayer.get_remote_sender_id() == game_master or multiplayer.get_remote_sender_id() == 0):
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/computers/"+node_name)
|
||||
current_character.current = current
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_beast(player):
|
||||
while !get_tree().root.has_node("./map/player"+str(player)):
|
||||
await get_tree().create_timer(0.001).timeout
|
||||
var current_character = get_tree().root.get_node("./map/player"+str(player))
|
||||
current_character.beast_init()
|
||||
if !multiplayer.is_server() and (multiplayer.get_remote_sender_id() == game_master or multiplayer.get_remote_sender_id() == 0):
|
||||
while !get_tree().root.has_node("./"+map_name+"/player"+str(player)):
|
||||
await get_tree().create_timer(0.001).timeout
|
||||
var current_character = get_tree().root.get_node("./"+map_name+"/player"+str(player))
|
||||
current_character.beast_init()
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func player_hit(target, beast):
|
||||
target = get_tree().root.get_node("./map/"+target)
|
||||
beast = get_tree().root.get_node("./map/"+beast)
|
||||
if !target.is_frozen:
|
||||
target.captured(beast)
|
||||
beast.got_one(target)
|
||||
if !multiplayer.is_server():
|
||||
target = get_tree().root.get_node("./"+map_name+"/"+target)
|
||||
beast = get_tree().root.get_node("./"+map_name+"/"+beast)
|
||||
if !target.is_frozen:
|
||||
target.captured(beast)
|
||||
beast.got_one(target)
|
||||
|
||||
|
|
16
scripts/settings.gd
Normal file
16
scripts/settings.gd
Normal file
|
@ -0,0 +1,16 @@
|
|||
## 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, 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.
|
||||
##
|
||||
## 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 OptionButton
|
||||
|
||||
func _ready():
|
||||
selected = Game.settings[get_parent().name]
|
||||
|
||||
func _on_item_selected(index):
|
||||
Game.save_setting(get_parent().name, selected)
|
21
scripts/win.gd
Normal file
21
scripts/win.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
## 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, 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.
|
||||
##
|
||||
## 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 Area3D
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body is CharacterBody3D and !body.beast and Game.computers == 0:
|
||||
body.free()
|
||||
$mapcam.active
|
||||
|
||||
func _process(delta):
|
||||
if Game.computers == 0:
|
||||
$CSGBox3D.show()
|
||||
else:
|
||||
$CSGBox3D.hide()
|
Loading…
Add table
Add a link
Reference in a new issue