added realtime day night cycle based on system time
This commit is contained in:
@@ -5,11 +5,7 @@ class_name level
|
||||
@export var gamemode : gamemode
|
||||
@export var player : Node
|
||||
@export var MAX_PARTICLES = 100
|
||||
@export_group("Drops")
|
||||
@export var drop_chance_minimum = .1
|
||||
@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
|
||||
@export var time_based_sun : DirectionalLight3D
|
||||
|
||||
const ITEM_PICKUP = preload("res://assets/item_pickup.tscn")
|
||||
const CROWN = preload("res://assets/crown.tscn")
|
||||
@@ -208,22 +204,22 @@ func pickup_spawn(randomized):
|
||||
else:
|
||||
var health_weight
|
||||
if gamemode.health_drop_enabled:
|
||||
health_weight = (1.0 - (GameGlobals.health / gamemode.start_health)) + drop_chance_minimum
|
||||
health_weight = (1.0 - (GameGlobals.health / gamemode.start_health)) + gamemode.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
|
||||
if gamemode.stamina_drop_enabled:
|
||||
stamina_weight = (1.0 - (player.remaining_stamina / gamemode.max_stamina)) + gamemode.drop_chance_minimum
|
||||
else:
|
||||
stamina_weight = 0
|
||||
var money_weight
|
||||
if money_drop_enabled:
|
||||
money_weight = 1 + drop_chance_minimum #fix this logic later once the economy makes sense
|
||||
if gamemode.money_drop_enabled:
|
||||
money_weight = 1 + gamemode.drop_chance_minimum #fix this logic later once the economy makes sense
|
||||
else:
|
||||
money_weight = 0
|
||||
var ammo_weight
|
||||
if gamemode.ammo_drop_enabled:
|
||||
ammo_weight = drop_chance_minimum
|
||||
ammo_weight = gamemode.drop_chance_minimum
|
||||
else: ammo_weight = 0
|
||||
var ammo_type_weight = {}
|
||||
|
||||
@@ -247,7 +243,7 @@ func pickup_spawn(randomized):
|
||||
if i_weight > ammo_weight:
|
||||
ammo_weight = i_weight
|
||||
ammo_type_weight.erase(5)
|
||||
ammo_type_weight[i] = i_weight + drop_chance_minimum
|
||||
ammo_type_weight[i] = i_weight + gamemode.drop_chance_minimum
|
||||
|
||||
pickup_type = HelperFuncs.weighted_random({"0" : ammo_weight, "1" : stamina_weight,"2" : health_weight,"3" : money_weight})
|
||||
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
extends RigidBody3D
|
||||
extends Projectile
|
||||
|
||||
@export var collision_shape : Node
|
||||
|
||||
var bullet_speed
|
||||
var bullet_drop
|
||||
var random_spread_amt
|
||||
var bullet_damage
|
||||
var instance_bullethole
|
||||
var bullet_force_mod = 1.0
|
||||
var distance_from_player
|
||||
var player_position
|
||||
var player_velocity
|
||||
var bullet_active = true
|
||||
var bullet_target : Node
|
||||
var hold_cam_pos = null
|
||||
var camera_start
|
||||
|
||||
@@ -2,5 +2,7 @@ extends Resource
|
||||
class_name bullet_resource
|
||||
|
||||
@export var asset : Resource
|
||||
@export_enum("Light", "Medium", "Heavy", "Shotgun", "Rocket") var ammo_type: int
|
||||
@export var price : int = 1
|
||||
@export_enum("Light", "Medium", "Heavy", "Shotgun", "Rocket","Special") var ammo_type: int #Special ammo is stored by bullet name
|
||||
@export var special_bullet_name : String
|
||||
@export var bullet_hole : Resource
|
||||
|
||||
@@ -647,28 +647,8 @@ func holster_gun(holster):
|
||||
if holstered_gun_id != null:
|
||||
weapon_select(holstered_gun_id)
|
||||
|
||||
func add_ammo(new_gun,gun_name,ammo_type,max_ammo,start_mags):
|
||||
if new_gun:
|
||||
if ammo_type != 5: #if ammo is not melee
|
||||
GameGlobals.gun_ammo[gun_name] = max_ammo
|
||||
else:
|
||||
GameGlobals.gun_ammo[gun_name] = null
|
||||
if GameGlobals.ammo_reserve.has(str(ammo_type)):
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] += start_mags * max_ammo
|
||||
else:
|
||||
#if melee weapon don't do max ammo calc
|
||||
if ammo_type == 5:
|
||||
pass
|
||||
#otherwise calculate starting ammo
|
||||
else:
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] = start_mags * max_ammo
|
||||
|
||||
print("GUN AMMO ",GameGlobals.gun_ammo)
|
||||
print("RESERVE AMMO ", GameGlobals.ammo_reserve)
|
||||
|
||||
## MISC
|
||||
|
||||
|
||||
func _on_pick_up_detection_body_entered(body):
|
||||
|
||||
if body.is_in_group("item_pickup"):
|
||||
|
||||
17
scripts/realtime_day_night_cycle.gd
Normal file
17
scripts/realtime_day_night_cycle.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var sun: DirectionalLight3D = $Sun
|
||||
@export var sun_energy_over_time : Curve
|
||||
|
||||
func _ready() -> void:
|
||||
var sun_details = sun_angle_from_time()
|
||||
sun.rotation.x = sun_details["angle"]
|
||||
sun.light_energy = sun_details["energy"]
|
||||
|
||||
func sun_angle_from_time():
|
||||
var time_dict = Time.get_time_dict_from_system()
|
||||
var current_time = float(time_dict["hour"]) + (float(time_dict["minute"]) / 60)
|
||||
print("current time: ", current_time)
|
||||
var angle : float = deg_to_rad((current_time/24.0) * 360.0 + 90.0)
|
||||
var energy = sun_energy_over_time.sample(current_time)
|
||||
return {"angle" : angle, "energy" : energy}
|
||||
1
scripts/realtime_day_night_cycle.gd.uid
Normal file
1
scripts/realtime_day_night_cycle.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dl780dimuvcms
|
||||
@@ -6,7 +6,6 @@ extends RigidBody3D
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
var pickupable = true
|
||||
var gun_already_held = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -18,14 +17,17 @@ func _process(delta):
|
||||
pass
|
||||
|
||||
func picked_up():
|
||||
var spawn_gun = gun_resource.instantiate()
|
||||
var gun_held = false
|
||||
#check if gun is owned
|
||||
for i in GameGlobals.held_guns:
|
||||
if i == gun_resource:
|
||||
gun_already_held = true
|
||||
gun_held = true
|
||||
|
||||
if !gun_already_held:
|
||||
var spawn_gun = gun_resource.instantiate()
|
||||
if spawn_gun.weapon_info.weapon_type == 0:
|
||||
level_control.player.add_ammo(true,spawn_gun.weapon_info.gun_name,spawn_gun.weapon_info.bullet.ammo_type,spawn_gun.weapon_info.max_ammo,spawn_gun.weapon_info.start_mags)
|
||||
if spawn_gun.weapon_info.weapon_type == 0:
|
||||
add_ammo(gun_held,spawn_gun.weapon_info.gun_name,spawn_gun.weapon_info.bullet.ammo_type,spawn_gun.weapon_info.bullet.special_bullet_name,spawn_gun.weapon_info.max_ammo,spawn_gun.weapon_info.start_mags)
|
||||
|
||||
if !gun_held:
|
||||
GameGlobals.held_guns.append(gun_resource)
|
||||
var instance_gun = gun_resource.instantiate()
|
||||
var weapon_id = GameGlobals.held_guns.size() - 1
|
||||
@@ -35,6 +37,17 @@ func picked_up():
|
||||
SignalBus.emit_signal("weapon_list_changed")
|
||||
queue_free()
|
||||
|
||||
func add_ammo(new_gun,gun_name,ammo_type,special_bullet_name,max_ammo,start_mags):
|
||||
if new_gun:
|
||||
GameGlobals.gun_ammo[gun_name] = max_ammo
|
||||
if GameGlobals.ammo_reserve.has(str(ammo_type)):
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] += start_mags * max_ammo
|
||||
else:
|
||||
GameGlobals.ammo_reserve[str(ammo_type)] = start_mags * max_ammo
|
||||
|
||||
print("GUN AMMO ",GameGlobals.gun_ammo)
|
||||
print("RESERVE AMMO ", GameGlobals.ammo_reserve)
|
||||
|
||||
func save():
|
||||
var save_dict = {
|
||||
"filename" : get_scene_file_path(),
|
||||
|
||||
@@ -26,7 +26,7 @@ class_name weapon_resource
|
||||
@export var vibration_strong_magnitude : float = .5
|
||||
@export var vibration_duration = .1
|
||||
@export_group("Revolver Settings")
|
||||
@export var chamber_rot_amount = 60.0
|
||||
@export var chamber_rot_amount = 60.0 ## In degrees per bullet fired
|
||||
@export_group("Shotgun Settings")
|
||||
@export var shotgun_spread : Vector3 = Vector3(.1,.1,.1)
|
||||
@export var pellets_per_shot : int = 20
|
||||
|
||||
Reference in New Issue
Block a user