2023-01-26 12:17:54 -07:00
|
|
|
extends Node
|
2023-07-15 20:45:16 -06:00
|
|
|
var consoleEnabled = false # Change this to enable console
|
2023-01-26 12:17:54 -07:00
|
|
|
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-03-18 01:11:03 -06:00
|
|
|
var currentMapPath # 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-18 12:47:09 -06:00
|
|
|
var lastPersonToHitMe = "" # Defined in the Bullet RPC
|
2023-03-06 00:35:22 -07:00
|
|
|
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
|
2023-03-28 22:32:49 -06:00
|
|
|
var chosenPlayer # Changed in HUD.gd
|
|
|
|
var iAmSpecial = false # Defines whether you're the special player or not. Used in HUD.gd
|
|
|
|
var specialDead = false # When the special person is dead, this goes true
|
2023-03-16 21:42:32 -06:00
|
|
|
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-03-19 01:35:35 -06:00
|
|
|
var tutorialComplete = false # Used only for tutorial
|
2023-03-19 01:56:03 -06:00
|
|
|
var AIHit = false # Used so the AI knows to take damage
|
2023-05-27 16:49:09 -06:00
|
|
|
var AIKilled = false # Used to add a score to the person that killed the AI
|
2023-03-28 22:32:49 -06:00
|
|
|
var iAmDeadAndInnocent = false # Used to keep track of when an innocent dies in TTT
|
2023-04-06 13:27:41 -06:00
|
|
|
var spawnCotton = false # bullet will change this to true
|
2023-04-15 13:02:34 -06:00
|
|
|
var addedMenuScene = false # Used for teddy.gd, fixes multiple menu bug
|
2023-04-15 15:04:16 -06:00
|
|
|
var tutorialCompleted = false # Used in the save file, to know if a play should go to tutorial first
|
2023-05-27 16:49:09 -06:00
|
|
|
var tutorialTimerCompleted = false # Used for after the timer goes off in the tutorial
|
2023-05-05 13:05:54 -06:00
|
|
|
var playerDisable = false # Can be used to disable the player
|
2023-05-16 10:00:28 -06:00
|
|
|
var playerDeathHealth = 100 # Can be changed by death.gd
|
2023-05-23 13:03:06 -06:00
|
|
|
var kickAllPlayers = false # Can be set to true to kick all players in-game
|
2023-07-03 23:21:16 -06:00
|
|
|
var respawnLocationChosen = false # When set to false, the game will be allowed to select a spawnpoint for the player
|
2023-09-10 02:39:31 -06:00
|
|
|
var lastEnteredIP = "" # For keeping track of the last IP Address that was used
|
|
|
|
var lastEnteredPort = "28000" # For keeping track of the last port that was used
|
2023-01-31 13:34:11 -07:00
|
|
|
|
|
|
|
func _process(delta):
|
2023-03-16 22:59:05 -06:00
|
|
|
spawn_locations()
|
2023-02-02 13:28:14 -07:00
|
|
|
if godMode:
|
|
|
|
pass
|
2023-03-28 22:32:49 -06:00
|
|
|
elif Input.is_action_pressed("sprint") and roundInSession:
|
|
|
|
if gamemode == "Runner" and iAmSpecial:
|
|
|
|
return
|
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:
|
2023-07-03 17:06:54 -06:00
|
|
|
respawnLocationChosen = false
|
2023-01-31 13:34:11 -07:00
|
|
|
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
|
2023-05-16 10:00:28 -06:00
|
|
|
playerHealth = playerDeathHealth
|
2023-02-07 13:22:31 -07:00
|
|
|
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 = ""
|
2023-03-18 12:47:09 -06:00
|
|
|
lastPersonToHitMe = ""
|
2023-03-17 12:11:47 -06:00
|
|
|
HUDPlayerDied = false
|
|
|
|
respawnTimeModifier = 1.0
|
|
|
|
menuLightSwitch = false
|
|
|
|
gamemode = "Deathmatch"
|
2023-03-28 22:32:49 -06:00
|
|
|
chosenPlayer = null
|
|
|
|
iAmSpecial = false
|
|
|
|
specialDead = false
|
2023-03-17 12:11:47 -06:00
|
|
|
roundTimer = 300.0
|
|
|
|
spawnCoordsInitalized = false
|
2023-03-19 14:04:07 -06:00
|
|
|
tutorialComplete = false
|
2023-05-27 16:49:09 -06:00
|
|
|
tutorialTimerCompleted = false
|
2023-03-19 14:04:07 -06:00
|
|
|
AIHit = false
|
2023-05-27 16:49:09 -06:00
|
|
|
AIKilled = false
|
2023-03-28 22:32:49 -06:00
|
|
|
iAmDeadAndInnocent = false
|
2023-04-18 12:46:33 -06:00
|
|
|
addedMenuScene = false
|
2023-05-15 12:42:36 -06:00
|
|
|
playerDisable = false
|
2023-05-16 10:00:28 -06:00
|
|
|
playerDeathHealth = 100
|
2023-05-23 13:03:06 -06:00
|
|
|
kickAllPlayers = false
|
2023-07-03 23:21:16 -06:00
|
|
|
respawnLocationChosen = false
|
2023-03-17 12:11:47 -06:00
|
|
|
|
2023-03-17 00:20:54 -06:00
|
|
|
func save_data():
|
2023-04-15 15:04:16 -06:00
|
|
|
SettingsFile.save_data()
|
2023-03-17 00:20:54 -06:00
|
|
|
|
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)
|
2023-05-28 22:59:41 -06:00
|
|
|
spawnCoords_x[0] = -4.15
|
|
|
|
spawnCoords_y[0] = 1.84
|
|
|
|
spawnCoords_z[0] = 24.36
|
2023-03-18 01:11:03 -06:00
|
|
|
elif mapName == "Islands":
|
2023-05-27 14:57:15 -06:00
|
|
|
spawnCoords_x.resize(4)
|
|
|
|
spawnCoords_y.resize(4)
|
|
|
|
spawnCoords_z.resize(4)
|
|
|
|
spawnCoords_x[0] = 38.66
|
|
|
|
spawnCoords_y[0] = 22.68
|
|
|
|
spawnCoords_z[0] = 77.73
|
|
|
|
spawnCoords_x[1] = -40.33
|
|
|
|
spawnCoords_y[1] = 16.72
|
|
|
|
spawnCoords_z[1] = 112.09
|
|
|
|
spawnCoords_x[2] = -7.77
|
|
|
|
spawnCoords_y[2] = 14.34
|
|
|
|
spawnCoords_z[2] = 42.74
|
|
|
|
spawnCoords_x[3] = 3.03
|
|
|
|
spawnCoords_y[3] = 13.46
|
|
|
|
spawnCoords_z[3] = 83.22
|
2023-04-11 13:31:11 -06:00
|
|
|
elif mapName == "Forrest":
|
2023-04-13 13:24:38 -06:00
|
|
|
spawnCoords_x.resize(4)
|
|
|
|
spawnCoords_y.resize(4)
|
|
|
|
spawnCoords_z.resize(4)
|
2023-04-11 13:31:11 -06:00
|
|
|
spawnCoords_x[0] = -83.39
|
|
|
|
spawnCoords_y[0] = -4.93
|
|
|
|
spawnCoords_z[0] = 5.77
|
2023-04-13 13:24:38 -06:00
|
|
|
spawnCoords_x[1] = -31.92
|
|
|
|
spawnCoords_y[1] = 5.71
|
|
|
|
spawnCoords_z[1] = -52.45
|
|
|
|
spawnCoords_x[2] = 79.92
|
|
|
|
spawnCoords_y[2] = -4.36
|
|
|
|
spawnCoords_z[2] = -72.71
|
|
|
|
spawnCoords_x[3] = 78.49
|
|
|
|
spawnCoords_y[3] = -7.78
|
|
|
|
spawnCoords_z[3] = -7.87
|
2023-05-04 11:29:32 -06:00
|
|
|
elif mapName == "toyfactory":
|
|
|
|
spawnCoords_x.resize(4)
|
|
|
|
spawnCoords_y.resize(4)
|
|
|
|
spawnCoords_z.resize(4)
|
|
|
|
spawnCoords_x[0] = -17.42
|
|
|
|
spawnCoords_y[0] = 2.88
|
|
|
|
spawnCoords_z[0] = 3.11
|
|
|
|
spawnCoords_x[1] = -8.02
|
|
|
|
spawnCoords_y[1] = 5.91
|
|
|
|
spawnCoords_z[1] = 35.21
|
|
|
|
spawnCoords_x[2] = 12.05
|
|
|
|
spawnCoords_y[2] = 6.38
|
|
|
|
spawnCoords_z[2] = 45.06
|
|
|
|
spawnCoords_x[3] = -5.13
|
|
|
|
spawnCoords_y[3] = -11.01
|
|
|
|
spawnCoords_z[3] = -2.91
|
2023-04-04 13:13:53 -06:00
|
|
|
|