more hub world tweaking
This commit is contained in:
@@ -7,7 +7,6 @@ class_name map
|
||||
@export var MAX_PARTICLES = 100
|
||||
@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 money_drop_enabled = true
|
||||
@@ -198,13 +197,13 @@ func pickup_spawn(randomized):
|
||||
else:
|
||||
money_weight = 0
|
||||
var ammo_weight
|
||||
if ammo_drop_enabled:
|
||||
if gamemode.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:
|
||||
if gamemode.ammo_drop_enabled:
|
||||
for i in GameGlobals.ammo_reserve.keys():
|
||||
var i_weight
|
||||
match int(i):
|
||||
|
||||
@@ -74,17 +74,17 @@ func _process(_delta):
|
||||
|
||||
|
||||
func reload_finished():
|
||||
if player.ammo_reserve[str(ammo_type)] >= max_ammo:
|
||||
player.gun_ammo[gun_name] += max_ammo
|
||||
player.ammo_reserve[str(ammo_type)] -= max_ammo
|
||||
if GameGlobals.ammo_reserve[str(ammo_type)] >= max_ammo:
|
||||
GameGlobals.gun_ammo[gun_name] += max_ammo
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] -= max_ammo
|
||||
|
||||
else:
|
||||
player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)]
|
||||
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
|
||||
GameGlobals.gun_ammo[gun_name] += GameGlobals.ammo_reserve[str(ammo_type)]
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] -= GameGlobals.ammo_reserve[str(ammo_type)]
|
||||
|
||||
|
||||
func shoot(delta):
|
||||
if player.gun_ammo[gun_name] > 0:
|
||||
if GameGlobals.gun_ammo[gun_name] > 0:
|
||||
if !anim_player.is_playing():
|
||||
anim_player.play("shoot")
|
||||
elif !anim_player.is_playing() and cycle_count != 0:
|
||||
@@ -92,7 +92,7 @@ func shoot(delta):
|
||||
audio_empty.play()
|
||||
|
||||
func fire():
|
||||
player.gun_ammo[gun_name] -= 1
|
||||
GameGlobals.gun_ammo[gun_name] -= 1
|
||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||
audio_fire.play()
|
||||
pellet_spawn()
|
||||
@@ -106,15 +106,15 @@ func fire():
|
||||
SignalBus.emit_signal("shot_fired")
|
||||
|
||||
func reload():
|
||||
if player.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and player.ammo_reserve[str(ammo_type)] > 0:
|
||||
if GameGlobals.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and GameGlobals.ammo_reserve[str(ammo_type)] > 0:
|
||||
#player.reloading = true
|
||||
anim_player.play("reload")
|
||||
audio_reload.play()
|
||||
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||
if player.gun_ammo[gun_name] == 0:
|
||||
player.gun_ammo[gun_name] = 0
|
||||
if GameGlobals.gun_ammo[gun_name] == 0:
|
||||
GameGlobals.gun_ammo[gun_name] = 0
|
||||
else:
|
||||
player.gun_ammo[gun_name] = 1
|
||||
GameGlobals.gun_ammo[gun_name] = 1
|
||||
|
||||
func pellet_spawn():
|
||||
var pellets_remaining = pellets_per_shot
|
||||
|
||||
@@ -5,7 +5,6 @@ extends Node3D
|
||||
@export var TIMER_MIN = 0.0
|
||||
@export var TIMER_MAX = 20.0
|
||||
|
||||
@onready var item_pickup = preload("res://assets/item_pickup.tscn")
|
||||
@onready var timer = $Timer
|
||||
@onready var cannonparticles = $cannonparticles
|
||||
@onready var cannon_dir = $RayCast3D
|
||||
@@ -14,7 +13,6 @@ extends Node3D
|
||||
|
||||
var fire = true
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
@@ -33,7 +31,7 @@ func _on_timer_timeout():
|
||||
timer.wait_time = rand_timer #rand_timer
|
||||
|
||||
# Shoot that shit
|
||||
var pickup_spawn = item_pickup.instantiate()
|
||||
var pickup_spawn = level_control.item_pickup.instantiate()
|
||||
var item_stats = level_control.pickup_spawn(false)
|
||||
##SET VARIABLES
|
||||
pickup_spawn.pickup_type = item_stats["pickup_type"]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
extends StaticBody3D
|
||||
|
||||
@onready var amount: Label3D = $Amount
|
||||
@onready var currently_held_money: Label3D = $"Currently Held Money"
|
||||
@onready var deposited: Label3D = $Deposited
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@@ -9,7 +10,8 @@ func _ready() -> void:
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
currently_held_money.text = "cash on hand: $" + str(int(GameGlobals.money))
|
||||
deposited.text = "deposited: $" + str(GameGlobals.deposited_money)
|
||||
|
||||
func interact():
|
||||
SignalBus.emit_signal("money_deposited")
|
||||
|
||||
@@ -2,6 +2,7 @@ extends Node
|
||||
|
||||
var game_loaded = false
|
||||
var high_score : int = 0
|
||||
var deposited_money
|
||||
var money : int = 0
|
||||
var health
|
||||
var held_guns = []
|
||||
@@ -13,18 +14,16 @@ func _ready() -> void:
|
||||
SignalBus.money_deposited.connect(deposit_money)
|
||||
|
||||
func deposit_money():
|
||||
if money > high_score:
|
||||
high_score = money
|
||||
deposited_money = money
|
||||
if deposited_money > high_score:
|
||||
high_score = deposited_money
|
||||
|
||||
func money_penalty():
|
||||
var level_control = get_tree().current_scene
|
||||
|
||||
#Save High Scores
|
||||
if money >= high_score:
|
||||
high_score = money
|
||||
|
||||
#Do money penalty
|
||||
money = money * level_control.gamemode.money_lost_multiplier
|
||||
deposited_money = money
|
||||
|
||||
func weapon_penalty():
|
||||
var level_control = get_tree().current_scene
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
|
||||
@export var portal_node : Node
|
||||
|
||||
@onready var level_name: Label3D = $"Level Name"
|
||||
@onready var gamemode_label: Label3D = $Gamemode
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
level_name.text = portal_node.scene_name
|
||||
gamemode_label.text = portal_node.gamemode.gamemode_name
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
||||
@@ -105,9 +105,9 @@ func _process(delta):
|
||||
|
||||
func reload_finished():
|
||||
#if max ammo in reserve fill all the way
|
||||
if player.ammo_reserve[str(ammo_type)] >= max_ammo:
|
||||
player.gun_ammo[gun_name] += max_ammo
|
||||
player.ammo_reserve[str(ammo_type)] -= max_ammo
|
||||
if GameGlobals.ammo_reserve[str(ammo_type)] >= max_ammo:
|
||||
GameGlobals.gun_ammo[gun_name] += max_ammo
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] -= max_ammo
|
||||
casings_chamber_last = max_ammo
|
||||
for i in casing_array:
|
||||
i.visible = true
|
||||
@@ -116,10 +116,10 @@ func reload_finished():
|
||||
player.reloading = false
|
||||
#if not max ammo in reserve add remaining ammo
|
||||
else:
|
||||
player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)]
|
||||
var casings_in_chamber = player.ammo_reserve[str(ammo_type)]
|
||||
casings_chamber_last = player.ammo_reserve[str(ammo_type)]
|
||||
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
|
||||
GameGlobals.gun_ammo[gun_name] += GameGlobals.ammo_reserve[str(ammo_type)]
|
||||
var casings_in_chamber = GameGlobals.ammo_reserve[str(ammo_type)]
|
||||
casings_chamber_last = GameGlobals.ammo_reserve[str(ammo_type)]
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] -= GameGlobals.ammo_reserve[str(ammo_type)]
|
||||
|
||||
while casings_in_chamber > 0:
|
||||
casing_array[casings_in_chamber].visible = true
|
||||
@@ -129,9 +129,9 @@ func reload_finished():
|
||||
player.reloading = false
|
||||
|
||||
func shoot(delta):
|
||||
if player.gun_ammo[gun_name] > 0 and cycle_count > 0:
|
||||
if GameGlobals.gun_ammo[gun_name] > 0 and cycle_count > 0:
|
||||
if !anim_player.is_playing():
|
||||
player.gun_ammo[gun_name] -= 1
|
||||
GameGlobals.gun_ammo[gun_name] -= 1
|
||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||
audio_fire.play()
|
||||
anim_player.play("shoot") #actual bullet spawn triggered by animation
|
||||
@@ -166,13 +166,13 @@ func fire(delta):
|
||||
Input.start_joy_vibration(0,.5,.9,.2)
|
||||
|
||||
func reload():
|
||||
if player.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and player.ammo_reserve[str(ammo_type)] > 0:
|
||||
if GameGlobals.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and GameGlobals.ammo_reserve[str(ammo_type)] > 0:
|
||||
anim_player.play("reload")
|
||||
audio_reload.play()
|
||||
for i in bullet_array:
|
||||
i.visible = false
|
||||
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||
player.gun_ammo[gun_name] = 0
|
||||
GameGlobals.gun_ammo[gun_name] = 0
|
||||
|
||||
func spawn_casings():
|
||||
for i in casing_array:
|
||||
|
||||
@@ -19,10 +19,10 @@ func _process(delta: float) -> void:
|
||||
|
||||
func _on_body_entered(body: Node3D) -> void:
|
||||
if active:
|
||||
SignalBus.emit_signal("player_exiting_tree")
|
||||
if get_tree().current_scene.gamemode.load_save == true:
|
||||
SaveLoad.save_game_data(get_tree().current_scene.get_name())
|
||||
SaveLoad.save_persistent_data()
|
||||
SignalBus.emit_signal("player_exiting_tree")
|
||||
get_tree().change_scene_to_file(scene_path)
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
extends Node3D
|
||||
|
||||
@export var item : Resource
|
||||
@export var is_pickup : bool = false
|
||||
@export var is_random : bool = false
|
||||
@export_enum("Ammo", "Stamina", "Health", "Money","Weapon") var pickup_type: int
|
||||
@export var pickup_amount : int
|
||||
@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 price_label = $Price
|
||||
@onready var item_label: Label3D = $Item
|
||||
@onready var item_label: Label3D = $"Item"
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
var active = true
|
||||
@@ -33,7 +37,21 @@ func interact():
|
||||
price_label.text = original_text
|
||||
|
||||
func vend():
|
||||
var item_vend = item.instantiate()
|
||||
var item_vend
|
||||
if is_pickup:
|
||||
item_vend = level_control.item_pickup.instantiate()
|
||||
var item_stats
|
||||
item_stats = level_control.pickup_spawn(is_random)
|
||||
##SET VARIABLES
|
||||
item_vend.pickup_type = pickup_type
|
||||
if level_control.player.gun != null:
|
||||
item_vend.ammo_type = level_control.player.gun.ammo_type
|
||||
else:
|
||||
item_vend.ammo_type = item_stats["ammo_type"]
|
||||
item_vend.value = pickup_amount
|
||||
print("ITEM : ",item_vend.pickup_type,item_vend.ammo_type,item_vend.value)
|
||||
else:
|
||||
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)
|
||||
@@ -41,6 +59,7 @@ func vend():
|
||||
active = false
|
||||
price_label.text = "offline"
|
||||
get_parent().add_child(item_vend)
|
||||
price_label.text = str("$",item_price)
|
||||
|
||||
func save():
|
||||
var save_dict = {
|
||||
|
||||
Reference in New Issue
Block a user