209 lines
7.6 KiB
GDScript
209 lines
7.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 AIKilled = false # Used to add a score to the person that killed the AI
|
|
var iAmDeadAndInnocent = false # Used to keep track of when an innocent dies in TTT
|
|
var spawnCotton = false # bullet will change this to true
|
|
var addedMenuScene = false # Used for teddy.gd, fixes multiple menu bug
|
|
var tutorialCompleted = false # Used in the save file, to know if a play should go to tutorial first
|
|
var tutorialTimerCompleted = false # Used for after the timer goes off in the tutorial
|
|
var playerDisable = false # Can be used to disable the player
|
|
var playerDeathHealth = 100 # Can be changed by death.gd
|
|
var kickAllPlayers = false # Can be set to true to kick all players in-game
|
|
|
|
func _process(delta):
|
|
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 = playerDeathHealth
|
|
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
|
|
tutorialTimerCompleted = false
|
|
AIHit = false
|
|
AIKilled = false
|
|
iAmDeadAndInnocent = false
|
|
addedMenuScene = false
|
|
playerDisable = false
|
|
playerDeathHealth = 100
|
|
kickAllPlayers = false
|
|
|
|
func save_data():
|
|
SettingsFile.save_data()
|
|
|
|
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] = -4.15
|
|
spawnCoords_y[0] = 1.84
|
|
spawnCoords_z[0] = 24.36
|
|
elif mapName == "Islands":
|
|
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
|
|
elif mapName == "Forrest":
|
|
spawnCoords_x.resize(4)
|
|
spawnCoords_y.resize(4)
|
|
spawnCoords_z.resize(4)
|
|
spawnCoords_x[0] = -83.39
|
|
spawnCoords_y[0] = -4.93
|
|
spawnCoords_z[0] = 5.77
|
|
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
|
|
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
|
|
|