added projectile class and tweaked weapon uberscript

This commit is contained in:
derek
2025-03-04 12:01:14 -06:00
parent 8fbd79eac3
commit cc1500e7fd
16 changed files with 922 additions and 166 deletions

View File

@@ -73,19 +73,7 @@ func shoot(delta):
if !anim_player.is_playing():
GameGlobals.gun_ammo[weapon_info.gun_name] -= 1
#audio and anims
audio_fire.play()
anim_player.play("shoot")
vibration()
if chamber != null:
revolver_chamber_rot_amt += 60
if weapon_info.smoke_enabled:
spawn_muzzle_smoke()
player.recoil.add_recoil(Vector3(0,weapon_info.recoil_amount.y,weapon_info.recoil_amount.z),10,10)
player.recoil.add_gun_recoil(weapon_info.recoil_amount.x)
#player.velocity += player.bullet_ray.global_basis * Vector3(0,0, kick_amount)
SignalBus.emit_signal("shot_fired")
if weapon_info.fire_mode != 0:
cycle_count -= 1
elif !anim_player.is_playing() and cycle_count != 0:
anim_player.play("empty")
@@ -145,8 +133,6 @@ func spawn_revolver_casings():
casings_chamber_last -= 1
func shotgun_pellet_spawn():
GameGlobals.gun_ammo[weapon_info.gun_name] -= 1
audio_fire.play()
var pellets_remaining = weapon_info.pellets_per_shot
@@ -154,11 +140,8 @@ func shotgun_pellet_spawn():
var lv_x = rng.randf_range(-weapon_info.shotgun_spread.x,weapon_info.shotgun_spread.x)
var lv_y = rng.randf_range(-weapon_info.shotgun_spread.y,weapon_info.shotgun_spread.y)
# instance bullet
var instance_bullet = weapon_info.bullet.asset.instantiate()
instance_bullet.position = player.bullet_ray.global_position
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
var instance_bullet = projectile_initialize()
instance_bullet.linear_velocity += instance_bullet.transform.basis * Vector3(lv_x, lv_y, -weapon_info.bullet_speed) + player.velocity
instance_bullet.player_position = player.global_position
get_tree().get_root().add_child(instance_bullet)
pellets_remaining -= 1
@@ -178,7 +161,7 @@ func spawn_muzzle_smoke():
add_child(instance_smoke)
func bullet_fire():
func projectile_initialize():
var instance_bullet = weapon_info.bullet.asset.instantiate()
instance_bullet.position = player.bullet_ray.global_position
#shoot bullet from real gun if gun is folded up
@@ -189,10 +172,30 @@ func bullet_fire():
instance_bullet.bullet_speed = weapon_info.bullet_speed
instance_bullet.player_velocity = player.velocity * transform.basis
instance_bullet.bullet_damage = weapon_info.bullet_damage
instance_bullet.blast_power = weapon_info.blast_power
instance_bullet.bullet_force_mod = weapon_info.bullet_force_mod
instance_bullet.instance_bullethole = weapon_info.bullet.bullet_hole.instantiate()
if weapon_info.bullet.bullet_hole != null:
instance_bullet.instance_bullethole = weapon_info.bullet.bullet_hole.instantiate()
instance_bullet.player_position = player.global_position
get_tree().current_scene.add_child(instance_bullet)
return instance_bullet
func bullet_fire():
audio_fire.play()
get_tree().current_scene.add_child(projectile_initialize())
vibration()
if chamber != null:
revolver_chamber_rot_amt += 60
if weapon_info.smoke_enabled:
spawn_muzzle_smoke()
player.recoil.add_recoil(Vector3(0,weapon_info.recoil_amount.y,weapon_info.recoil_amount.z),10,10)
player.recoil.add_gun_recoil(weapon_info.recoil_amount.x)
SignalBus.emit_signal("shot_fired")
if weapon_info.fire_mode != 0:
cycle_count -= 1
func swapped_out():
queue_free()