Modified weapon scripts and resources with a simplified spread angle
variable.
This commit is contained in:
parent
4f90c82b8f
commit
4f3839448b
7 changed files with 75 additions and 3 deletions
BIN
graphics/spread.png
Normal file
BIN
graphics/spread.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 282 B |
40
graphics/spread.png.import
Normal file
40
graphics/spread.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dwc5fjwhqikoo"
|
||||
path="res://.godot/imported/spread.png-77a3efff77439dd55f282fc699502b2f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/spread.png"
|
||||
dest_files=["res://.godot/imported/spread.png-77a3efff77439dd55f282fc699502b2f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
19
resources/player_weapon_resources/spread.tres
Normal file
19
resources/player_weapon_resources/spread.tres
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[gd_resource type="Resource" script_class="WeaponShot" format=3 uid="uid://ds53sryglmf27"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/player_weapons/weapon_stock.tscn" id="1_pn64g"]
|
||||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="2_4b7mw"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_4b7mw")
|
||||
shot_name = "spread"
|
||||
bullet_scene = ExtResource("1_pn64g")
|
||||
damage = 5
|
||||
speed = 500
|
||||
projectiles = 5
|
||||
spacing = 30.0
|
||||
origin = -15
|
||||
horizontal_offset = 8.25
|
||||
spread_angle = 15.0
|
||||
stagger_offset = 0.5
|
||||
stagger_animation = true
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="10_d2wvv"]
|
||||
[ext_resource type="Resource" uid="uid://cck3gmnhu5agc" path="res://resources/player_weapon_resources/tri.tres" id="11_3v2ag"]
|
||||
[ext_resource type="Script" uid="uid://65d3hbrpm21x" path="res://scripts/effects/effects_component.gd" id="12_effcomp"]
|
||||
[ext_resource type="Resource" uid="uid://ds53sryglmf27" path="res://resources/player_weapon_resources/spread.tres" id="13_f1ej7"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||
atlas = ExtResource("5_qlg0r")
|
||||
|
|
@ -157,7 +158,7 @@ script = ExtResource("6_y4r1p")
|
|||
unique_name_in_owner = true
|
||||
script = ExtResource("7_d2wvv")
|
||||
weapon_data = ExtResource("8_stock")
|
||||
available_weapons = Array[ExtResource("10_d2wvv")]([ExtResource("8_stock"), ExtResource("11_3v2ag"), ExtResource("9_ur7pv")])
|
||||
available_weapons = Array[ExtResource("10_d2wvv")]([ExtResource("8_stock"), ExtResource("11_3v2ag"), ExtResource("9_ur7pv"), ExtResource("13_f1ej7")])
|
||||
weapon_change_flash = SubResource("Resource_jej6c")
|
||||
metadata/_custom_type_script = "uid://ylmao2ndp22y"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ var time_offset: float = 0.5
|
|||
# When this bullet should fire (absolute time)
|
||||
var fire_time: float = 0.0
|
||||
|
||||
# Angle offset for spread shots (in degrees)
|
||||
var angle: float = 0.0
|
||||
|
||||
# Track if this bullet is currently active in the shot
|
||||
var is_active: bool = false
|
||||
|
||||
|
|
@ -20,8 +23,9 @@ func _process(delta):
|
|||
if !is_active and current_time >= fire_time:
|
||||
activate()
|
||||
|
||||
# Move the bullet
|
||||
position.y -= shot_data.speed * delta
|
||||
# Move the bullet, factoring in spread angle
|
||||
var velocity = Vector2.UP.rotated(deg_to_rad(angle)) * shot_data.speed
|
||||
position += velocity * delta
|
||||
|
||||
func activate():
|
||||
is_active = true
|
||||
|
|
|
|||
|
|
@ -34,9 +34,15 @@ func shoot():
|
|||
# Final position combines symmetrical horizontal spread with symmetrical vertical spacing
|
||||
bullet.position = player.position + Vector2(bullet_horizontal_offset, weapon_data.origin + (vertical_offset + weapon_data.origin - total_projectiles))
|
||||
|
||||
# Calculate angle for this bullet (only when projectiles >= 3)
|
||||
var bullet_angle: float = 0.0
|
||||
if total_projectiles >= 3:
|
||||
bullet_angle = (index_from_center / center_index) * (weapon_data.spread_angle / 2.0)
|
||||
|
||||
# Set timing properties on the bullet
|
||||
bullet.time_offset = time_offset
|
||||
bullet.fire_time = current_time + time_offset
|
||||
bullet.angle = bullet_angle
|
||||
|
||||
# Set the bullet data
|
||||
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ extends Resource
|
|||
@export_category("Spread")
|
||||
# Horizontal distance between projectiles
|
||||
@export var horizontal_offset: float = 6.5
|
||||
# Total spread angle in degrees (only applied when projectiles >= 3)
|
||||
@export var spread_angle: float = 0.0
|
||||
# Time delay per projectile index
|
||||
@export var stagger_offset: float = 0.25
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue