2023-01-26 12:17:54 -07:00
|
|
|
extends Node
|
|
|
|
var mouseSensitivity = 0.01 # Unless otherwise changed by user in settings
|
2023-01-31 22:21:21 -07:00
|
|
|
var playingGame = false # Should be true while in a map, set by menus
|
|
|
|
var fatigue = 100 # Makes it so you can't run forever, you have limited energy
|
|
|
|
var playerHealth = 100 # If zero, the player dies. Bullets cause damage
|
|
|
|
var playerDead = false # Defined by Global.player_dead()
|
|
|
|
var playerAlive = true # Gets set to false by death.tscn then to true after the death timer is up
|
|
|
|
var playerPleaseRespawn = false # When true, this executes the apporiate commands to respawn the player. Controlled by death.tscn
|
|
|
|
var playerYDeath = -20 # The point in which the player will die from falling off the map, defined in map scripts
|
2023-02-16 13:27:34 -07:00
|
|
|
var playerName # Defined in the settings-file.gd script
|
2023-01-31 22:21:21 -07:00
|
|
|
var deathShield = 0 # Makes you unkillable for a specified amount of time. Used to prevent the kill screen from appearing twice as well
|
2023-02-02 13:28:14 -07:00
|
|
|
var goScene # This is used for the sceneChangerConfirm window. Initalized by a different script prior to sceneChangerConfirm
|
|
|
|
var consoleOpen = false # This specifies whether or not the console is open
|
|
|
|
var consoleCommand # Defined by console.gd
|
|
|
|
var consoleOutput # Defined by console.gd
|
|
|
|
var godMode = false # Defined by console.gd
|
2023-02-14 11:40:02 -07:00
|
|
|
var selfTeddy # Defined as soon as the player script is initalized
|
2023-02-22 21:31:22 -07:00
|
|
|
var multiplayerCurrent = false # Whether the player is using multiplayer
|
|
|
|
var currentMapNode # Defined in map scripts
|
2023-02-25 14:31:15 -07:00
|
|
|
var teddyAuthorityID # Defined from teddy.gd after object is initalized
|
2023-03-02 12:52:49 -07:00
|
|
|
var miniMenuResume = false # Set to true by mainmenu.gd
|
2023-03-05 22:08:14 -07:00
|
|
|
var roundInSession = false # Goes true once the round is started in Teddy.gd
|
|
|
|
var HUDStartLabelText = "" # The text displayed at the bottom of the screen of the server
|
2023-03-06 00:35:22 -07:00
|
|
|
var lastPersonToHitMe = 0 # Defined in the Bullet RPC
|
|
|
|
var HUDPlayerDied = false # Tells the HUD.gd script that a point should be added or deducted
|
|
|
|
var connectedPlayers = [] # Currently connected players by their name (NOT THEIR ID)
|
2023-03-16 13:37:17 -06:00
|
|
|
var connectedPlayersByPeerID = [] # Currently connected players by their ID
|
2023-03-06 19:07:22 -07:00
|
|
|
var respawnTimeModifier = 1.0 # Affects how quickly the player respawns in death.gd
|
2023-03-11 18:50:43 -07:00
|
|
|
var musicName = "" # Name of music for HUD.gd
|
|
|
|
var musicAuthor = "" # Name of music author for HUD.gd
|
|
|
|
var musicUpdated = false # Tells HUD.gd to update labels and change visibility
|
2023-03-12 00:43:49 -07:00
|
|
|
var menuLightSwitch = false # No description provided
|
2023-03-16 13:37:17 -06:00
|
|
|
var gamemode = "Deathmatch" # This is changed in host.gd
|
|
|
|
var chosenRunner # Changed in HUD.gd
|
|
|
|
var iAmRunner = false # Defines whether you're the runner or not. Used in HUD.gd
|
2023-03-16 21:42:32 -06:00
|
|
|
var runnerDead = false # When the runner is dead, this goes true
|
|
|
|
var roundTimer = 300.0 # How long each rounds goes
|
2023-03-16 22:59:05 -06:00
|
|
|
var mapName # Defined from host.gd, name of map
|
|
|
|
var spawnCoords_x: Array[float] = [] # Used locally in spawn_locations() function
|
|
|
|
var spawnCoords_y: Array[float] = [] # Used locally in spawn_locations() function
|
|
|
|
var spawnCoords_z: Array[float] = [] # Used locally in spawn_locations() function
|
|
|
|
var spawnCoordsInitalized = false # Used locally
|
2023-03-17 00:20:54 -06:00
|
|
|
var volumeModifer = 1 # Modifies volume level
|
2023-01-31 13:34:11 -07:00
|
|
|
|
|
|
|
func _process(delta):
|
2023-03-16 22:59:05 -06:00
|
|
|
#if not spawnCoordsInitalized:
|
|
|
|
# spawnCoordsInitalized = true
|
|
|
|
spawn_locations()
|
2023-02-02 13:28:14 -07:00
|
|
|
if godMode:
|
|
|
|
pass
|
2023-03-16 13:37:17 -06:00
|
|
|
elif Input.is_action_pressed("sprint") and not iAmRunner and roundInSession:
|
2023-01-31 13:34:11 -07:00
|
|
|
if fatigue > 0:
|
|
|
|
fatigue = fatigue - 10 * delta
|
|
|
|
elif not Input.is_action_pressed("sprint"):
|
|
|
|
if fatigue < 100:
|
2023-03-12 00:43:49 -07:00
|
|
|
fatigue = fatigue + 5 * delta
|
2023-01-31 13:34:11 -07:00
|
|
|
if playerAlive:
|
|
|
|
deathShield = deathShield - 10 * delta # Make player not killable until the value falls below 0
|
|
|
|
|
|
|
|
func player_dead():
|
|
|
|
playerDead = true
|
|
|
|
if deathShield <= 0:
|
|
|
|
deathShield = 50
|
|
|
|
if playerAlive:
|
|
|
|
print("Player be deaddddd brooooooo")
|
|
|
|
var scene_trs =load("res://scenes/death.tscn")
|
|
|
|
var scene=scene_trs.instantiate()
|
|
|
|
add_child(scene)
|
2023-02-07 13:22:31 -07:00
|
|
|
|
|
|
|
func reset_variables():
|
|
|
|
print("Variables were reset by something")
|
|
|
|
fatigue = 100
|
|
|
|
playerHealth = 100
|
|
|
|
playerDead = false
|
|
|
|
playerAlive = true
|
|
|
|
playerPleaseRespawn = false
|
2023-02-15 23:41:14 -07:00
|
|
|
|
2023-03-17 12:11:47 -06:00
|
|
|
func reset_variables_hard():
|
|
|
|
print("Variables were HARD reset")
|
|
|
|
fatigue = 100
|
|
|
|
playerHealth = 100
|
|
|
|
playerDead = false
|
|
|
|
playerAlive = true
|
|
|
|
playerPleaseRespawn = false
|
|
|
|
connectedPlayers = []
|
|
|
|
Networking.connected_peers = []
|
|
|
|
connectedPlayersByPeerID = []
|
|
|
|
roundInSession = false
|
|
|
|
playingGame = false
|
|
|
|
consoleOpen = false
|
|
|
|
godMode = false
|
|
|
|
multiplayerCurrent = false
|
|
|
|
teddyAuthorityID = null
|
|
|
|
miniMenuResume = false
|
|
|
|
HUDStartLabelText = ""
|
|
|
|
lastPersonToHitMe = 0
|
|
|
|
HUDPlayerDied = false
|
|
|
|
respawnTimeModifier = 1.0
|
|
|
|
menuLightSwitch = false
|
|
|
|
gamemode = "Deathmatch"
|
|
|
|
chosenRunner = null
|
|
|
|
iAmRunner = false
|
|
|
|
runnerDead = false
|
|
|
|
roundTimer = 300.0
|
|
|
|
spawnCoordsInitalized = false
|
|
|
|
|
2023-03-17 00:20:54 -06:00
|
|
|
func save_data():
|
|
|
|
SettingsFile.save_data(mouseSensitivity, playerName, volumeModifer)
|
|
|
|
|
2023-03-16 22:59:05 -06:00
|
|
|
func spawn_locations():
|
|
|
|
if mapName == "Toyland":
|
|
|
|
spawnCoords_x.resize(6)
|
|
|
|
spawnCoords_y.resize(6)
|
|
|
|
spawnCoords_z.resize(6)
|
|
|
|
spawnCoords_x[0] = 9.95
|
|
|
|
spawnCoords_y[0] = 4.15
|
|
|
|
spawnCoords_z[0] = -11.88
|
|
|
|
spawnCoords_x[1] = -12.38
|
|
|
|
spawnCoords_y[1] = 2.57
|
|
|
|
spawnCoords_z[1] = -41.53
|
|
|
|
spawnCoords_x[2] = -12.15
|
|
|
|
spawnCoords_y[2] = 4.19
|
|
|
|
spawnCoords_z[2] = -83.06
|
|
|
|
spawnCoords_x[3] = -50.54
|
|
|
|
spawnCoords_y[3] = 0.57
|
|
|
|
spawnCoords_z[3] = -58.60
|
|
|
|
spawnCoords_x[4] = -28.56
|
|
|
|
spawnCoords_y[4] = 6.55
|
|
|
|
spawnCoords_z[4] = -46.37
|
|
|
|
spawnCoords_x[5] = -43.08
|
|
|
|
spawnCoords_y[5] = 0.57
|
|
|
|
spawnCoords_z[5] = -12.74
|
|
|
|
elif mapName == "Tutorial":
|
|
|
|
spawnCoords_x.resize(1)
|
|
|
|
spawnCoords_y.resize(1)
|
|
|
|
spawnCoords_z.resize(1)
|
|
|
|
spawnCoords_x[0] = -17.65
|
|
|
|
spawnCoords_y[0] = 2.85
|
|
|
|
spawnCoords_z[0] = 11.41
|