added functionality for various game modes
This commit is contained in:
34
GameModes/cookie_mode.tres
Normal file
34
GameModes/cookie_mode.tres
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_resource type="Resource" script_class="gamemode" load_steps=2 format=3 uid="uid://bs8yvpq65yh3w"]
|
||||
|
||||
[ext_resource type="Script" path="res://gamemode.gd" id="1_8tp85"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_8tp85")
|
||||
gamemode_name = "Cookie Mode"
|
||||
win_conditions = 0
|
||||
survival_time = 160.0
|
||||
walk_speed = 5.0
|
||||
jump_velocity = 5
|
||||
dash_speed = 5
|
||||
gravity = -18.0
|
||||
time_slowed_speed = 3.0
|
||||
stamina_regen = true
|
||||
max_stamina = 100.0
|
||||
stamina_drain = 20.0
|
||||
air_dash_max = 1
|
||||
load_save = true
|
||||
money = 0
|
||||
start_health = 3
|
||||
drop_chance_minimum = 0.1
|
||||
random_drops = false
|
||||
ammo_drop_enabled = true
|
||||
expected_ammo = {
|
||||
"heavy": 25,
|
||||
"light": 200,
|
||||
"medium": 50,
|
||||
"rocket": 3,
|
||||
"shotgun": 20
|
||||
}
|
||||
stamina_drop_enabled = true
|
||||
health_drop_enabled = true
|
||||
money_drop_enabled = true
|
||||
32
GameModes/do_not_get_hit.tres
Normal file
32
GameModes/do_not_get_hit.tres
Normal file
@@ -0,0 +1,32 @@
|
||||
[gd_resource type="Resource" script_class="gamemode" load_steps=2 format=3 uid="uid://dlvhtdmtln3bb"]
|
||||
|
||||
[ext_resource type="Script" path="res://gamemode.gd" id="1_lcpua"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_lcpua")
|
||||
gamemode_name = "DO NOT GET HIT"
|
||||
walk_speed = 12.0
|
||||
jump_velocity = 5
|
||||
dash_speed = 40
|
||||
gravity = -18.0
|
||||
time_slowed_speed = 0.1
|
||||
stamina_regen = true
|
||||
max_stamina = 100.0
|
||||
stamina_drain = 20.0
|
||||
air_dash_max = 1
|
||||
load_save = true
|
||||
money = 250
|
||||
start_health = 1
|
||||
drop_chance_minimum = 0.1
|
||||
random_drops = false
|
||||
ammo_drop_enabled = true
|
||||
expected_ammo = {
|
||||
"heavy": 25,
|
||||
"light": 200,
|
||||
"medium": 50,
|
||||
"rocket": 3,
|
||||
"shotgun": 20
|
||||
}
|
||||
stamina_drop_enabled = true
|
||||
health_drop_enabled = true
|
||||
money_drop_enabled = true
|
||||
34
GameModes/nostaminaregen.tres
Normal file
34
GameModes/nostaminaregen.tres
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_resource type="Resource" script_class="gamemode" load_steps=2 format=3 uid="uid://65tl6q463gxl"]
|
||||
|
||||
[ext_resource type="Script" path="res://gamemode.gd" id="1_d71ib"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_d71ib")
|
||||
win_conditions = 0
|
||||
gamemode_name = "no stamina regen, no health drops"
|
||||
survival_time = 160.0
|
||||
walk_speed = 12.0
|
||||
jump_velocity = 5
|
||||
dash_speed = 40
|
||||
gravity = -9.8
|
||||
time_slowed_speed = 0.1
|
||||
stamina_regen = false
|
||||
max_stamina = 100.0
|
||||
stamina_drain = 5.0
|
||||
air_dash_max = 1
|
||||
load_save = false
|
||||
money = 10
|
||||
start_health = 10
|
||||
drop_chance_minimum = 0.1
|
||||
random_drops = false
|
||||
ammo_drop_enabled = true
|
||||
expected_ammo = {
|
||||
"heavy": 25,
|
||||
"light": 200,
|
||||
"medium": 50,
|
||||
"rocket": 3,
|
||||
"shotgun": 20
|
||||
}
|
||||
stamina_drop_enabled = true
|
||||
health_drop_enabled = true
|
||||
money_drop_enabled = true
|
||||
34
GameModes/standard.tres
Normal file
34
GameModes/standard.tres
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_resource type="Resource" script_class="gamemode" load_steps=2 format=3 uid="uid://dn3t7wcoumlm3"]
|
||||
|
||||
[ext_resource type="Script" path="res://gamemode.gd" id="1_litni"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_litni")
|
||||
gamemode_name = "Standard"
|
||||
win_conditions = 0
|
||||
survival_time = 160.0
|
||||
walk_speed = 12.0
|
||||
jump_velocity = 5
|
||||
dash_speed = 40
|
||||
gravity = -9.8
|
||||
time_slowed_speed = 0.1
|
||||
stamina_regen = true
|
||||
max_stamina = 100.0
|
||||
stamina_drain = 20.0
|
||||
air_dash_max = 1
|
||||
load_save = true
|
||||
money = 0
|
||||
start_health = 10
|
||||
drop_chance_minimum = 0.1
|
||||
random_drops = false
|
||||
ammo_drop_enabled = true
|
||||
expected_ammo = {
|
||||
"heavy": 25,
|
||||
"light": 200,
|
||||
"medium": 50,
|
||||
"rocket": 3,
|
||||
"shotgun": 20
|
||||
}
|
||||
stamina_drop_enabled = true
|
||||
health_drop_enabled = true
|
||||
money_drop_enabled = true
|
||||
@@ -292,6 +292,11 @@ script = ExtResource("12_u0mbp")
|
||||
transform = Transform3D(0.999998, 1.10134e-12, 1.01328e-06, 1.68754e-13, 1, -2.62013e-13, -1.01328e-06, 2.4869e-14, 0.999998, -0.00144234, 6.34256e-09, 0.143659)
|
||||
shape = SubResource("BoxShape3D_idjup")
|
||||
|
||||
[node name="blade_ray" type="RayCast3D" parent="MacheteHandle"]
|
||||
transform = Transform3D(-0.284734, 0.0187224, 0.958423, 0.28306, -0.953586, 0.102721, 0.915862, 0.300539, 0.266218, 0, -0.135443, 0.144432)
|
||||
target_position = Vector3(0, -1.5, 0)
|
||||
collision_mask = 249
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_gmno4")
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
[node name="Stats" type="Node3D"]
|
||||
script = ExtResource("1_q47is")
|
||||
|
||||
[node name="Gamemode" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.66069, 0)
|
||||
text = "Test"
|
||||
font = ExtResource("2_mtulh")
|
||||
horizontal_alignment = 0
|
||||
|
||||
[node name="Kills" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.423311, 0)
|
||||
text = "Test"
|
||||
|
||||
30
gamemode.gd
Normal file
30
gamemode.gd
Normal file
@@ -0,0 +1,30 @@
|
||||
extends Resource
|
||||
class_name gamemode
|
||||
|
||||
@export var gamemode_name : String = "My Custom Game Mode"
|
||||
@export_enum("Kill 'em All","Extraction","Survival_Time") var win_conditions
|
||||
@export_group("Win Conditions")
|
||||
@export var survival_time : float = 160 #in seconds
|
||||
@export_group("Player Movement")
|
||||
@export var walk_speed = 12.0
|
||||
@export var jump_velocity = 5
|
||||
@export var dash_speed = 40
|
||||
@export var gravity : float = -9.8
|
||||
@export var time_slowed_speed : float = .1
|
||||
@export var stamina_regen = true
|
||||
@export var max_stamina : float = 100
|
||||
@export var stamina_drain : float = 20
|
||||
@export var air_dash_max : int = 1
|
||||
@export var load_save : = true
|
||||
@export var money = 0
|
||||
@export var start_health = 10
|
||||
@export var gun_1 : Resource
|
||||
@export var gun_2 : Resource
|
||||
@export_group("Drops")
|
||||
@export var drop_chance_minimum = .1
|
||||
@export var random_drops : bool = false
|
||||
@export var ammo_drop_enabled = true
|
||||
@export var expected_ammo = {"light" : 200, "medium" : 50, "heavy" : 25,"shotgun" : 20, "rocket" : 3} #light, medium,heavy,shotgun,rocket
|
||||
@export var stamina_drop_enabled = true
|
||||
@export var health_drop_enabled = true
|
||||
@export var money_drop_enabled = true
|
||||
@@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="First Person Test"
|
||||
run/main_scene="res://scenes/test_level_2v2.tscn"
|
||||
run/main_scene="res://scenes/enemy_working_scene.tscn"
|
||||
config/features=PackedStringArray("4.3", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
|
||||
426
scenes/ene6663.tmp
Normal file
426
scenes/ene6663.tmp
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,10 +1,10 @@
|
||||
extends Label3D
|
||||
|
||||
@onready var vendingmachine = $".."
|
||||
@onready var vending_machine: StaticBody3D = $".."
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
text = "$" + str(vendingmachine.item_price)
|
||||
text = "$" + str(vending_machine.item_price)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
extends Node3D
|
||||
|
||||
@export var load_save : = true
|
||||
@export var gamemode : gamemode
|
||||
@export var player : Node
|
||||
@export var money = 250
|
||||
@export var start_health = 3
|
||||
@export var MAX_PARTICLES = 100
|
||||
@export var gun_1 : Resource
|
||||
@export var gun_2 : Resource
|
||||
@export_group("Drops")
|
||||
@export var drop_chance_minimum = .1
|
||||
@export var ammo_drop_enabled = true
|
||||
@export var expected_ammo = {"light" : 200, "medium" : 50, "heavy" : 25,"shotgun" : 20, "rocket" : 3} #light, medium,heavy,shotgun,rocket
|
||||
@export var stamina_drop_enabled = true
|
||||
@export var health_drop_enabled = true
|
||||
@export var money_drop_enabled = true
|
||||
|
||||
@onready var item_pickup = preload("res://assets/item_pickup.tscn")
|
||||
@@ -23,7 +18,8 @@ const DEAD_ANNOUNCE = preload("res://assets/dead_announce.tscn")
|
||||
|
||||
var level_name
|
||||
var paused = false
|
||||
var health = start_health
|
||||
var health
|
||||
var money
|
||||
var pickups = []
|
||||
var held_guns = []
|
||||
var ammo_current = [0]
|
||||
@@ -48,10 +44,14 @@ func _ready():
|
||||
#connect to signals
|
||||
SignalBus.enemy_count_changed.connect(enemy_count)
|
||||
|
||||
health = gamemode.start_health
|
||||
money = gamemode.money
|
||||
|
||||
|
||||
#LOAD DATA
|
||||
SaveLoad.load_persistent_data()
|
||||
|
||||
if SaveLoad.data_cleared or !load_save:
|
||||
if SaveLoad.data_cleared or !gamemode.load_save:
|
||||
refresh_scene()
|
||||
GameGlobals.game_loaded = true
|
||||
SignalBus.emit_signal("game_loaded")
|
||||
@@ -83,25 +83,25 @@ func _ready():
|
||||
enemy_count()
|
||||
|
||||
func refresh_scene():
|
||||
health = start_health
|
||||
health = gamemode.start_health
|
||||
|
||||
respawn_position = player.camera.global_position
|
||||
respawn_cam_rotation = player.global_transform.basis
|
||||
|
||||
if player:
|
||||
#Set up starting guns and ammo
|
||||
if gun_1 != null:
|
||||
held_guns = [gun_1]
|
||||
if gamemode.gun_1 != null:
|
||||
held_guns = [gamemode.gun_1]
|
||||
var instance_gun = held_guns[0].instantiate()
|
||||
player.add_ammo(true,instance_gun.gun_name,instance_gun.ammo_type,instance_gun.max_ammo,instance_gun.start_mags)
|
||||
|
||||
if gun_2 != null:
|
||||
held_guns.append(gun_2)
|
||||
if gamemode.gun_2 != null:
|
||||
held_guns.append(gamemode.gun_2)
|
||||
var instance_gun_2 = held_guns[1].instantiate()
|
||||
player.add_ammo(true,instance_gun_2.gun_name,instance_gun_2.ammo_type,instance_gun_2.max_ammo,instance_gun_2.start_mags)
|
||||
|
||||
# Spawn first gun
|
||||
if gun_1 != null:
|
||||
if gamemode.gun_1 != null:
|
||||
current_gun_index = 0
|
||||
gun_spawn(0)
|
||||
|
||||
@@ -189,13 +189,29 @@ func pickup_spawn(randomized):
|
||||
#random value of pickup
|
||||
value = randi_range(1,50)
|
||||
else:
|
||||
var health_weight = (1.0 - (health / start_health)) + drop_chance_minimum
|
||||
var stamina_weight = (1.0 - (player.remaining_stamina / player.MAX_STAMINA)) + drop_chance_minimum
|
||||
var money_weight = (1.0 - clamp(float(money) / float(500),0,1)) + drop_chance_minimum #fix this logic later once the economy makes sense
|
||||
var ammo_weight = drop_chance_minimum
|
||||
var health_weight
|
||||
if gamemode.health_drop_enabled:
|
||||
health_weight = (1.0 - (health / gamemode.start_health)) + drop_chance_minimum
|
||||
else:
|
||||
health_weight = 0
|
||||
var stamina_weight
|
||||
if stamina_drop_enabled:
|
||||
stamina_weight = (1.0 - (player.remaining_stamina / gamemode.max_stamina)) + drop_chance_minimum
|
||||
else:
|
||||
stamina_weight = 0
|
||||
var money_weight
|
||||
if money_drop_enabled:
|
||||
money_weight = (1.0 - clamp(float(money) / float(500),0,1)) + drop_chance_minimum #fix this logic later once the economy makes sense
|
||||
else:
|
||||
money_weight = 0
|
||||
var ammo_weight
|
||||
if ammo_drop_enabled:
|
||||
ammo_weight = drop_chance_minimum
|
||||
else: ammo_weight = 0
|
||||
var ammo_type_weight = {}
|
||||
|
||||
# weight ammo player owns against expected ammo values
|
||||
if ammo_drop_enabled:
|
||||
for i in player.ammo_reserve.keys():
|
||||
var i_weight
|
||||
match int(i):
|
||||
@@ -225,9 +241,9 @@ func pickup_spawn(randomized):
|
||||
ammo_type = randi_range(0,4)
|
||||
value = randi_range(1,20)
|
||||
"1":
|
||||
value = randi_range(int(player.MAX_STAMINA * .25),player.MAX_STAMINA)
|
||||
value = randi_range(int(gamemode.max_stamina * .25),gamemode.max_stamina)
|
||||
"2":
|
||||
value = randi_range(int(start_health * .25),start_health)
|
||||
value = randi_range(int(gamemode.start_health * .25),gamemode.start_health)
|
||||
"3":
|
||||
var bill_denoms = [5,10,20,50,100]
|
||||
value = bill_denoms.pick_random()
|
||||
|
||||
@@ -50,7 +50,7 @@ func _ready() -> void:
|
||||
SignalBus.player_hit.connect(player_hit)
|
||||
SignalBus.shot_fired.connect(crosshair_size_change)
|
||||
|
||||
health_bar.max_value = level_control.start_health
|
||||
health_bar.max_value = level_control.gamemode.start_health
|
||||
|
||||
health_bar_start_pos = health_bar.position
|
||||
|
||||
@@ -88,7 +88,7 @@ func _process(delta: float) -> void:
|
||||
if level_control.health <= 2:
|
||||
change_color(health_bar,RED_COLOR,10,delta)
|
||||
health_bar.position = health_bar_start_pos + shake_element(15)
|
||||
elif level_control.health < ((level_control.start_health / 2) + 1):
|
||||
elif level_control.health < ((level_control.gamemode.start_health / 2) + 1):
|
||||
change_color(health_bar,ORANGE_COLOR,10,delta)
|
||||
else:
|
||||
change_color(health_bar,FULL_WHITE,10,delta)
|
||||
@@ -104,7 +104,7 @@ func _process(delta: float) -> void:
|
||||
change_color(money,FULL_WHITE,10,delta)
|
||||
|
||||
money.text = "$" + str(money_count)
|
||||
if player.remaining_stamina/player.MAX_STAMINA >= .99:
|
||||
if player.remaining_stamina/level_control.gamemode.max_stamina >= .99:
|
||||
stam_bar_visible = false
|
||||
else:
|
||||
stam_bar_visible = true
|
||||
|
||||
@@ -4,6 +4,7 @@ extends Area3D
|
||||
|
||||
var player
|
||||
var player_on_ladder = false
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -32,7 +33,6 @@ func _on_body_exited(body):
|
||||
body.is_climbing = false
|
||||
player_on_ladder = false
|
||||
body.velocity.y = .1
|
||||
body.gravity = body.default_gravity
|
||||
|
||||
func hold_player():
|
||||
var direction_to_ladder = player.global_position.direction_to(self.global_position)
|
||||
|
||||
@@ -19,6 +19,7 @@ extends Node3D
|
||||
@onready var player = get_tree().current_scene.player
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var muzzle_smoke = preload("res://assets/muzzle_smoke.tscn")
|
||||
@onready var blade_ray: RayCast3D = $MacheteHandle/blade_ray
|
||||
|
||||
var max_ammo = 0
|
||||
var start_mags = 0
|
||||
@@ -36,7 +37,10 @@ func _ready():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
if blade_ray.is_colliding():
|
||||
var body = blade_ray.get_collider()
|
||||
if body.has_method("hit"):
|
||||
body.hit(bullet_damage)
|
||||
|
||||
func shoot(delta):
|
||||
if !anim_player.is_playing():
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
const JUMP_VELOCITY = 5
|
||||
const JUMP_WEAPON_DIP = Vector3(0,-5,0)
|
||||
const AIR_TRANSITION_SPEED = 7
|
||||
const GROUND_TRANSITION_SPEED = 4
|
||||
|
||||
const MAX_AIR_DASH = 1
|
||||
const GROUND_TRANSITION_SPEED = 7
|
||||
const FLASHLIGHT_BRIGHTNESS = 30
|
||||
const KICK_AMOUNT = 20
|
||||
const LAND_CAMERA_TILT : Vector3 = Vector3(-1,0,0)
|
||||
const WALK_SPEED = 12.0
|
||||
|
||||
const CROUCH_SPEED = 3.0
|
||||
const SPRINT_SPEED = 15.0
|
||||
const DASH_SPEED = 40
|
||||
const CROUCHED_POS = Vector3(0,-.1,0)
|
||||
const STAND_POS = Vector3(0,0.889,0)
|
||||
const SLOWSPEED = .1
|
||||
const MAX_STAMINA : float = 100
|
||||
const STAMINA_DRAIN = 20
|
||||
const HEAD_TILT_AMT = .06
|
||||
const BOB_FREQ = 1.7
|
||||
const BOB_AMP = 0.1
|
||||
@@ -34,11 +27,10 @@ const L_JOYSTICK_SENSITIVITY = .1
|
||||
var speed
|
||||
var walk_transition_speed
|
||||
var double_jump = true
|
||||
var air_dash = MAX_AIR_DASH
|
||||
var gravity = 9.8
|
||||
var air_dash
|
||||
var gravity
|
||||
var is_climbing = false
|
||||
var ladder_center
|
||||
var default_gravity = gravity
|
||||
var moving_fast = false
|
||||
var moving_fast_top_speed = 0.0
|
||||
var mouse_input : Vector2
|
||||
@@ -113,7 +105,7 @@ var weapon_start_pos
|
||||
var held_key_check = 0.0
|
||||
|
||||
# Slow Down Variables
|
||||
var remaining_stamina : float = MAX_STAMINA
|
||||
@onready var remaining_stamina : float = level_control.gamemode.max_stamina
|
||||
|
||||
# Wall Jump
|
||||
var can_wall_jump = true
|
||||
@@ -164,12 +156,13 @@ var controlled_elsewhere = false
|
||||
@onready var weapon_select_menu: Control = $Head/Recoil/Camera3D/WeaponSelect
|
||||
@onready var wall_jump_timer: Timer = $WallJumpTimer
|
||||
|
||||
|
||||
func _ready():
|
||||
level_control.player = self
|
||||
SignalBus.enemy_hit.connect(enemy_hit)
|
||||
SignalBus.enemy_killed.connect(enemy_killed)
|
||||
|
||||
air_dash = level_control.gamemode.air_dash_max
|
||||
|
||||
weapon_holder_start_rot = weapon_holder.rotation
|
||||
weapon_holder_start_pos = weapon_holder.position
|
||||
|
||||
@@ -181,7 +174,7 @@ func _ready():
|
||||
health_indicator.size = Vector2(viewportWidth,viewportHeight)
|
||||
health_indicator.color = Color(0.471, 0, 0, 0)
|
||||
|
||||
speed = WALK_SPEED
|
||||
speed = level_control.gamemode.walk_speed
|
||||
|
||||
motion_lines.visible = false
|
||||
|
||||
@@ -218,9 +211,9 @@ func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
if is_on_floor():
|
||||
double_jump = true
|
||||
air_dash = MAX_AIR_DASH
|
||||
air_dash = level_control.gamemode.air_dash_max
|
||||
else:
|
||||
velocity.y -= gravity * delta
|
||||
velocity.y += level_control.gamemode.gravity * delta
|
||||
if abs(velocity.y) >= .1:
|
||||
moving_fast = true
|
||||
|
||||
@@ -228,13 +221,13 @@ func _physics_process(delta):
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
if is_on_floor() and !is_climbing:
|
||||
velocity.y += JUMP_VELOCITY
|
||||
velocity.y += level_control.gamemode.jump_velocity
|
||||
weapon_dip_pos += JUMP_WEAPON_DIP
|
||||
crouched = false
|
||||
elif wall_jump():
|
||||
velocity += Vector3(velocity.x * 5,12,velocity.z * 5)
|
||||
elif double_jump == true and !is_climbing:
|
||||
velocity.y += JUMP_VELOCITY
|
||||
velocity.y += level_control.gamemode.jump_velocity
|
||||
double_jump = false
|
||||
|
||||
## HANDLE MOVEMENT DIRECTION
|
||||
@@ -252,8 +245,8 @@ func _physics_process(delta):
|
||||
# Handle Sprint
|
||||
if Input.is_action_just_pressed("sprint") and !is_on_floor():
|
||||
if air_dash > 0:
|
||||
velocity.x += direction.x * DASH_SPEED
|
||||
velocity.z += direction.z * DASH_SPEED
|
||||
velocity.x += direction.x * level_control.gamemode.dash_speed
|
||||
velocity.z += direction.z * level_control.gamemode.dash_speed
|
||||
air_dash -= 1
|
||||
|
||||
if Input.is_action_pressed("move_left"):
|
||||
@@ -286,13 +279,12 @@ func _physics_process(delta):
|
||||
|
||||
#walking
|
||||
if is_on_floor() and !is_climbing:
|
||||
walk_transition_speed = AIR_TRANSITION_SPEED
|
||||
if direction:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * walk_transition_speed)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * walk_transition_speed)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * GROUND_TRANSITION_SPEED)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * GROUND_TRANSITION_SPEED)
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5) + (direction.x * DASH_SPEED)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5) + (direction.z * DASH_SPEED)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5) + (direction.x * level_control.gamemode.dash_speed)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5) + (direction.z * level_control.gamemode.dash_speed)
|
||||
#ladder movement
|
||||
elif is_climbing and !is_on_floor():
|
||||
gravity = 0.0
|
||||
@@ -304,8 +296,8 @@ func _physics_process(delta):
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
|
||||
#movement in air
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * AIR_TRANSITION_SPEED)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * AIR_TRANSITION_SPEED)
|
||||
## Wall Running
|
||||
if wall_ray_1.is_colliding() or wall_ray_2.is_colliding():
|
||||
if abs(Vector2(velocity.x,velocity.z)) >= Vector2(5.0,5.0):
|
||||
@@ -322,9 +314,11 @@ func _physics_process(delta):
|
||||
camera.fov = lerp(camera.fov, target_fov, delta * 8)
|
||||
|
||||
# Health Indicator
|
||||
var health_opacity = 1.5 - level_control.health / level_control.start_health
|
||||
if level_control.health < (level_control.start_health/2):
|
||||
var health_opacity = 1.5 - level_control.health / level_control.gamemode.start_health
|
||||
if level_control.health < (level_control.gamemode.start_health/2):
|
||||
health_indicator.color = lerp(Color(0.471, 0, 0, 0), Color(0.471, 0, 0, .25),health_opacity)
|
||||
else:
|
||||
health_indicator.color = Color(0.471, 0, 0, 0)
|
||||
|
||||
# Moving Fast Sound
|
||||
var wind_volume = clamp(velocity.length()/20,0,1) #expected max velocity for effect
|
||||
@@ -356,14 +350,14 @@ func _physics_process(delta):
|
||||
if Input.is_action_pressed("slow_down") and remaining_stamina > 0 :
|
||||
ads = true
|
||||
if !gamespeed_controlled:
|
||||
Engine.time_scale = lerp(Engine.time_scale, SLOWSPEED, (delta * 50) / Engine.time_scale)
|
||||
Engine.time_scale = lerp(Engine.time_scale, level_control.gamemode.time_slowed_speed, (delta * 50) / Engine.time_scale)
|
||||
#gun.random_spread_amt = 0
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
clock_sound.play()
|
||||
if sensitivity_shift == true:
|
||||
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, (delta * 100) / Engine.time_scale)
|
||||
if remaining_stamina > 0:
|
||||
remaining_stamina = clamp(remaining_stamina - ((delta * STAMINA_DRAIN) / Engine.time_scale),0,MAX_STAMINA)
|
||||
remaining_stamina = clamp(remaining_stamina - ((delta * level_control.gamemode.stamina_drain) / Engine.time_scale),0,level_control.gamemode.max_stamina)
|
||||
else:
|
||||
ads = false
|
||||
if !gamespeed_controlled:
|
||||
@@ -372,8 +366,9 @@ func _physics_process(delta):
|
||||
clock_sound.stop()
|
||||
AudioServer.set_bus_effect_enabled(0,0,false)
|
||||
SENSITIVITY = start_sensitivity
|
||||
if remaining_stamina < MAX_STAMINA and !Input.is_action_pressed("slow_down"):
|
||||
remaining_stamina = clamp(remaining_stamina + (delta * STAMINA_DRAIN/Engine.time_scale), 0, MAX_STAMINA)
|
||||
if remaining_stamina < level_control.gamemode.max_stamina and !Input.is_action_pressed("slow_down"):
|
||||
if level_control.gamemode.stamina_regen == true:
|
||||
remaining_stamina = clamp(remaining_stamina + (delta * level_control.gamemode.stamina_drain/Engine.time_scale), 0, level_control.gamemode.max_stamina)
|
||||
|
||||
|
||||
# Reloading
|
||||
@@ -562,7 +557,7 @@ func crouch(delta):
|
||||
crouching_collision.disabled = true
|
||||
if head.position != STAND_POS:
|
||||
head.position = lerp(head.position, STAND_POS, delta * 8)
|
||||
speed = WALK_SPEED
|
||||
speed = level_control.gamemode.walk_speed
|
||||
|
||||
func _headbob(time) -> Vector3:
|
||||
var pos = Vector3.ZERO
|
||||
@@ -578,7 +573,7 @@ func ladder_collide():
|
||||
if is_climbing == true:
|
||||
gravity = 0.0
|
||||
else:
|
||||
gravity = default_gravity
|
||||
gravity = level_control.gamemode.gravity
|
||||
|
||||
func wall_jump():
|
||||
print("CAN JUMP? ",can_wall_jump)
|
||||
@@ -724,7 +719,7 @@ func pickup_apply(type,ammo_type,value):
|
||||
1: #STAMINA
|
||||
remaining_stamina = clamp(remaining_stamina + value,0,100)
|
||||
2: #HEALTH
|
||||
level_control.health = clamp(level_control.health + value,0,level_control.start_health)
|
||||
level_control.health = clamp(level_control.health + value,0,level_control.gamemode.start_health)
|
||||
3: #MONEY
|
||||
level_control.money += value
|
||||
|
||||
@@ -764,7 +759,7 @@ func weapon_bob(vel : float, delta):
|
||||
if gun != null and !ads and !gun.ads:
|
||||
weapon_holder.global_position.y += -clamp(velocity.y * .15,-1,1) * delta
|
||||
if vel > 2 and is_on_floor():
|
||||
var speed_adjust = speed/WALK_SPEED
|
||||
var speed_adjust = speed/level_control.gamemode.walk_speed
|
||||
var bob_amount : float = 0.05
|
||||
var bob_freq : float = 0.01 * speed_adjust
|
||||
weapon_holder.position.y = lerp(weapon_holder.position.y, def_weapon_holder_pos.y + sin(Time.get_ticks_msec() * bob_freq) * bob_amount, speed * delta)
|
||||
@@ -807,6 +802,7 @@ func hit(damage, fired_by, target_type):
|
||||
await get_tree().create_timer(.15).timeout
|
||||
health_indicator.color = Color(0.471, 0, 0, 0)
|
||||
|
||||
|
||||
func save():
|
||||
var save_dict = {
|
||||
"filename" : get_scene_file_path(),
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var gamemode: Label3D = $Gamemode
|
||||
@onready var kills: Label3D = $Kills
|
||||
@onready var deaths: Label3D = $Deaths
|
||||
@onready var shots_fired: Label3D = $"Shots Fired"
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
@@ -11,6 +14,7 @@ func _ready() -> void:
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
gamemode.text = str(level_control.gamemode.gamemode_name)
|
||||
kills.text = "Kills : " + str(SaveLoad.enemies_killed)
|
||||
deaths.text = "Deaths : " + str(SaveLoad.player_deaths)
|
||||
shots_fired.text = "Shots Fired : " + str(SaveLoad.shots_fired)
|
||||
|
||||
@@ -3,9 +3,11 @@ extends Node3D
|
||||
@export var item : Resource
|
||||
@export var item_name : String
|
||||
@export var item_price : int
|
||||
@export var number_uses = 1
|
||||
@onready var anim_player = $AnimationPlayer
|
||||
@onready var vend_ray = $VendRay
|
||||
@onready var label_3d = $Label3D
|
||||
@onready var price_label = $Price
|
||||
@onready var item_label: Label3D = $Item
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
var active = true
|
||||
@@ -13,29 +15,31 @@ var active = true
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if active == true:
|
||||
label_3d.text = str(item_price)
|
||||
price_label.text = str("$",item_price)
|
||||
item_label.text = str(item_name)
|
||||
else:
|
||||
label_3d.text = "offline"
|
||||
price_label.text = "offline"
|
||||
|
||||
func interact():
|
||||
if active == true:
|
||||
if level_control.money >= item_price:
|
||||
level_control.money -= item_price
|
||||
anim_player.play("vend")
|
||||
label_3d.text = "vending..."
|
||||
price_label.text = "vending..."
|
||||
else:
|
||||
var original_text = label_3d.text
|
||||
label_3d.text = "too poor"
|
||||
var original_text = price_label.text
|
||||
price_label.text = "too poor"
|
||||
await get_tree().create_timer(2.0).timeout
|
||||
label_3d.text = original_text
|
||||
price_label.text = original_text
|
||||
|
||||
func vend():
|
||||
var item_vend = item.instantiate()
|
||||
item_vend.position = vend_ray.global_position
|
||||
item_vend.transform.basis = vend_ray.global_transform.basis
|
||||
item_vend.linear_velocity += vend_ray.global_transform.basis * Vector3(0,0,3)
|
||||
if number_uses <= 1:
|
||||
active = false
|
||||
label_3d.text = "offline"
|
||||
price_label.text = "offline"
|
||||
get_parent().add_child(item_vend)
|
||||
|
||||
func save():
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user