pretty happy with ladder movement right now

This commit is contained in:
derek
2025-01-17 16:04:03 -06:00
parent 5eb065830a
commit f74d599b64
11 changed files with 111 additions and 80 deletions

View File

@@ -210,14 +210,17 @@ func pickup_spawn(randomized):
4:
i_weight = 1.0 - clamp(float(player.ammo_reserve[str(i)]) / float(expected_ammo["rocket"]),0,1)
if i_weight > ammo_weight:
ammo_weight = i_weight + drop_chance_minimum
ammo_weight = i_weight
ammo_type_weight[i] = i_weight + drop_chance_minimum
pickup_type = HelperFuncs.weighted_random({"0" : ammo_weight, "1" : stamina_weight,"2" : health_weight,"3" : money_weight})
match pickup_type:
"0":
ammo_type = int(HelperFuncs.weighted_random(ammo_type_weight))
if ammo_type_weight.size() > 0:
ammo_type = int(HelperFuncs.weighted_random(ammo_type_weight))
else:
ammo_type = randi_range(0,4)
value = randi_range(1,20)
"1":
value = randi_range(int(player.MAX_STAMINA * .25),player.MAX_STAMINA)

View File

@@ -83,8 +83,6 @@ func reload_finished():
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
func shoot(delta):
print("GUN AMMO: ",player.gun_ammo)
print("RESERVE AMMO: ",player.ammo_reserve)
if player.gun_ammo[gun_name] > 0 and cycle_count > 0:
if !anim_player.is_playing():
player.gun_ammo[gun_name] -= 1

View File

@@ -3,6 +3,7 @@ extends RigidBody3D
var despawning = false
var despawn_time_s = 10
var mesh_activated = false
var value
@export_enum("Ammo", "Stamina", "Health", "Money","Weapon") var pickup_type: int
var ammo_type
@@ -23,7 +24,7 @@ var ammo_type
@onready var money: Node3D = $Meshes/money
var magnetable = true #false
var magnetable = false
var pickupable = false
var pick_up = false
var rand_amt
@@ -32,41 +33,21 @@ var player
# Called when the node enters the scene tree for the first time.
func _ready():
add_to_group("spawned")
add_to_group("persist")
#Enable mesh
match pickup_type:
0:
match ammo_type:
0:
light_ammo.visible = true
1:
medium_ammo.visible = true #medium
2:
heavy_ammo.visible = true #heavy
3:
shotgun_ammo.visible = true #shotgun
4:
rocket.visible = true #rocket
1:
stamina.visible = true
2:
health.visible = true
3:
money.visible = true
if despawning == true:
timer.wait_time = despawn_time_s
timer.start()
func _physics_process(delta):
if !mesh_activated:
activate_mesh()
if player_follow != null:
if !pick_up:
despawning = false
angular_velocity = lerp(angular_velocity, Vector3(0,0,0), delta)
position = lerp(position, player.item_holder.global_position, 25 * delta)
if magnetable:
despawning = false
angular_velocity = lerp(angular_velocity, Vector3(0,0,0), delta)
position = lerp(position, player.item_holder.global_position, 25 * delta)
if abs(position - player.item_holder.global_position) < Vector3(.5,.5,.5):
await get_tree().create_timer(1).timeout
@@ -91,12 +72,36 @@ func save():
"rot_x" : rotation.x,
"rot_y" : rotation.y,
"rot_z" : rotation.z,
"linear_velocity" : linear_velocity,
"angular_velocity" : angular_velocity,
"pickup_type" : pickup_type,
"ammo_type" : ammo_type,
"value" : value
}
return save_dict
func activate_mesh():
match pickup_type:
0:
match ammo_type:
0:
light_ammo.visible = true
1:
medium_ammo.visible = true #medium
2:
heavy_ammo.visible = true #heavy
3:
shotgun_ammo.visible = true #shotgun
4:
rocket.visible = true #rocket
1:
stamina.visible = true
2:
health.visible = true
3:
money.visible = true
mesh_activated = true
func _on_magnet_timer_timeout() -> void:
magnetable = true

View File

@@ -1,5 +1,7 @@
extends Area3D
@onready var collision_midpoint: Node3D = $CollisionMidpoint
# Called when the node enters the scene tree for the first time.
func _ready():
pass
@@ -11,9 +13,8 @@ func _process(delta):
func _on_body_entered(body):
if body.is_in_group("player"):
body.velocity = Vector3(0,0,0)
body.is_climbing = true
if body.global_position.y < global_position.y:
if body.global_position.y < collision_midpoint.global_position.y:
body.global_position.y += .2
@@ -21,4 +22,3 @@ func _on_body_exited(body):
if body.is_in_group("player"):
body.is_climbing = false
body.gravity = body.default_gravity
body.ladder_center = null