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,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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue