feat: add plasma gun weapon implementation and new pause menu system with loadout management
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
extends BaseProjectileWeapon
|
||||
class_name PlasmaGun
|
||||
|
||||
func _init() -> void:
|
||||
weapon_name = "Plasma Gun"
|
||||
fire_rate = 0.15 # Moderate
|
||||
max_ammo = 25
|
||||
reload_time = 1.8
|
||||
base_damage = 50.0
|
||||
min_damage = 50.0 # No falloff
|
||||
falloff_start = 0.0 # Unused because min=base
|
||||
max_range = 300.0
|
||||
automatic = true
|
||||
spread_angle = 0.005 # Highly accurate
|
||||
|
||||
projectile_speed = 80.0
|
||||
projectile_gravity = 0.0
|
||||
|
||||
func _build_model() -> void:
|
||||
position = Vector3(0.3, -0.3, -0.6)
|
||||
|
||||
var white_mat = StandardMaterial3D.new()
|
||||
white_mat.albedo_color = Color(0.8, 0.8, 0.9)
|
||||
var glow_mat = StandardMaterial3D.new()
|
||||
glow_mat.albedo_color = Color(0.2, 0.5, 1.0)
|
||||
glow_mat.emission_enabled = true
|
||||
glow_mat.emission = Color(0.2, 0.5, 1.0)
|
||||
glow_mat.emission_energy_multiplier = 4.0
|
||||
|
||||
# Body
|
||||
var body = MeshInstance3D.new()
|
||||
var b_mesh = BoxMesh.new()
|
||||
b_mesh.size = Vector3(0.08, 0.14, 0.35)
|
||||
b_mesh.material = white_mat
|
||||
body.mesh = b_mesh
|
||||
body.position = Vector3(0, 0, 0.05)
|
||||
model_root.add_child(body)
|
||||
|
||||
# Glow Core
|
||||
var core = MeshInstance3D.new()
|
||||
var c_mesh = CylinderMesh.new()
|
||||
c_mesh.top_radius = 0.02
|
||||
c_mesh.bottom_radius = 0.02
|
||||
c_mesh.height = 0.4
|
||||
c_mesh.material = glow_mat
|
||||
core.mesh = c_mesh
|
||||
core.rotation.x = deg_to_rad(90)
|
||||
core.position = Vector3(0, 0.02, -0.15)
|
||||
model_root.add_child(core)
|
||||
|
||||
# Muzzle Flash
|
||||
muzzle_flash = OmniLight3D.new()
|
||||
muzzle_flash.light_color = Color(0.2, 0.5, 1.0)
|
||||
muzzle_flash.light_energy = 0.0
|
||||
muzzle_flash.omni_range = 6.0
|
||||
muzzle_flash.position = Vector3(0, 0.02, -0.4)
|
||||
model_root.add_child(muzzle_flash)
|
||||
|
||||
# Audio
|
||||
fire_sound = AudioStreamPlayer3D.new()
|
||||
fire_sound.stream = load("res://assets/sounds/plasma_fire.wav")
|
||||
fire_sound.position = muzzle_flash.position
|
||||
fire_sound.volume_db = -5.0
|
||||
model_root.add_child(fire_sound)
|
||||
|
||||
reload_sound = AudioStreamPlayer3D.new()
|
||||
reload_sound.stream = load("res://assets/sounds/shotgun_reload.wav")
|
||||
model_root.add_child(reload_sound)
|
||||
|
||||
func _spawn_custom_projectile(origin: Vector3, fire_dir: Vector3) -> void:
|
||||
var proj = load("res://weapons/projectile.gd").new()
|
||||
|
||||
# Give it a glowing blue mesh
|
||||
var mesh_instance = MeshInstance3D.new()
|
||||
var p_mesh = SphereMesh.new()
|
||||
p_mesh.radius = 0.08
|
||||
p_mesh.height = 0.16
|
||||
var mat = StandardMaterial3D.new()
|
||||
mat.albedo_color = Color(0.2, 0.6, 1.0)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = Color(0.2, 0.6, 1.0)
|
||||
mat.emission_energy_multiplier = 5.0
|
||||
p_mesh.material = mat
|
||||
mesh_instance.mesh = p_mesh
|
||||
proj.add_child(mesh_instance)
|
||||
|
||||
var light = OmniLight3D.new()
|
||||
light.light_color = Color(0.2, 0.6, 1.0)
|
||||
light.light_energy = 2.0
|
||||
light.omni_range = 4.0
|
||||
proj.add_child(light)
|
||||
|
||||
proj.global_position = muzzle_flash.global_position if muzzle_flash else origin
|
||||
proj.velocity = fire_dir * projectile_speed
|
||||
proj.damage = base_damage
|
||||
proj.min_damage = min_damage
|
||||
proj.falloff_start = falloff_start
|
||||
proj.max_range = max_range
|
||||
proj.drop_gravity = projectile_gravity
|
||||
proj.owner_player = player
|
||||
|
||||
# Spawn in the world
|
||||
get_tree().current_scene.add_child(proj)
|
||||
Reference in New Issue
Block a user