project_teddy/scripts/global.gd
2023-03-28 22:32:49 -06:00

161 lines
6 KiB
GDScript

extends Node
var mouseSensitivity = 0.01 # Unless otherwise changed by user in settings
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
var playerName # Defined in the settings-file.gd script
var deathShield = 0 # Makes you unkillable for a specified amount of time. Used to prevent the kill screen from appearing twice as well
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
var selfTeddy # Defined as soon as the player script is initalized
var multiplayerCurrent = false # Whether the player is using multiplayer
var currentMapNode # Defined in map scripts
var currentMapPath # Defined in map scripts
var teddyAuthorityID # Defined from teddy.gd after object is initalized
var miniMenuResume = false # Set to true by mainmenu.gd
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
var lastPersonToHitMe = "" # 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)
var connectedPlayersByPeerID = [] # Currently connected players by their ID
var respawnTimeModifier = 1.0 # Affects how quickly the player respawns in death.gd
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
var menuLightSwitch = false # No description provided
var gamemode = "Deathmatch" # This is changed in host.gd
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
var roundTimer = 300.0 # How long each rounds goes
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
var volumeModifer = 1 # Modifies volume level
var tutorialComplete = false # Used only for tutorial
var AIHit = false # Used so the AI knows to take damage
var iAmDeadAndInnocent = false # Used to keep track of when an innocent dies in TTT
func _process(delta):
#if not spawnCoordsInitalized:
# spawnCoordsInitalized = true
spawn_locations()
if godMode:
pass
elif Input.is_action_pressed("sprint") and roundInSession:
if gamemode == "Runner" and iAmSpecial:
return
if fatigue > 0:
fatigue = fatigue - 10 * delta
elif not Input.is_action_pressed("sprint"):
if fatigue < 100:
fatigue = fatigue + 5 * delta
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)
func reset_variables():
print("Variables were reset by something")
fatigue = 100
playerHealth = 100
playerDead = false
playerAlive = true
playerPleaseRespawn = false
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 = ""
HUDPlayerDied = false
respawnTimeModifier = 1.0
menuLightSwitch = false
gamemode = "Deathmatch"
chosenPlayer = null
iAmSpecial = false
specialDead = false
roundTimer = 300.0
spawnCoordsInitalized = false
tutorialComplete = false
AIHit = false
iAmDeadAndInnocent = false
func save_data():
SettingsFile.save_data(mouseSensitivity, playerName, volumeModifer)
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
elif mapName == "Islands":
spawnCoords_x.resize(3)
spawnCoords_y.resize(3)
spawnCoords_z.resize(3)
spawnCoords_x[0] = -1.32
spawnCoords_y[0] = 20
spawnCoords_z[0] = 2.92
spawnCoords_x[1] = 92.46
spawnCoords_y[1] = 14
spawnCoords_z[1] = 47.90
spawnCoords_x[2] = 88.84
spawnCoords_y[2] = 30
spawnCoords_z[2] = -81.81