👽 interstellar delivery

This commit is contained in:
anyreso 2024-10-16 21:43:01 +00:00
parent 547c97bfba
commit 97c8292858
257 changed files with 7309 additions and 4637 deletions

View file

@ -12,33 +12,44 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name ChainGun extends Node3D
class_name ChainGun extends AutomaticWeapon
@export_range(0, 250) var ammo : int = 250
@export var fire_rate : float = .1 # seconds
@export var reload_time : float = 0. # seconds
@export var _PROJECTILE : PackedScene
## The factor of velocity from the owner of this [Weapon] inherited by this [Projectile].
@export_range(0., 1., .01) var inheritance : float = 1.
@export_category("Animations")
@export var anim_player : AnimationPlayer
## The angular deviation from ideal line of fire in degrees
@export var min_spread: float
## The maximum angle the spread will increase to during heatup.
@export var max_spread: float
## The amount of time it takes for the chaingun to spin up or spin down.
@export var spin_period: float
## The amount of time it takes for the chaingun to overheat.
@export var heat_period: float
#@export var heat_time: float
## The fraction of the [member heat_period] at which the gun can start firing again
@export var cooldown_threshold: float
## Multiplier for the speed when calculating cooldown/heatup
@export var speed_cooldown_factor: float
## The [Shader] responsible for rendering heat while firing.
@export var heat_shader: Shader
# heat flag
var overheated: bool
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func trigger() -> void:
func _on_triggered() -> void:
# play the fire animation
anim_player.play("fire")
# init projectile
var projectile : Node3D = $ProjectileSpawner.new_projectile(
ChainGunProjectile,
owner.linear_velocity,
owner.match_participant
)
# add to owner of player for now
Global.type.add_child(projectile)
var projectile : ChainGunProjectile = _PROJECTILE.instantiate()
projectile.velocity = projectile.speed * $Nozzle.global_basis.z.normalized() + owner.linear_velocity * inheritance
projectile.source = owner
owner.add_child(projectile)
projectile.global_transform = $Nozzle.global_transform
projectile.shape_cast.add_exception(owner)
func _on_visibility_changed() -> void:
if self.visible:
anim_player.play("equip")
#anim_player.play("equip")
#self.sounds.play("equip")
pass

View file

@ -1,19 +1,23 @@
[gd_scene load_steps=5 format=3 uid="uid://b0xql5hi0b52y"]
[gd_scene load_steps=4 format=3 uid="uid://b0xql5hi0b52y"]
[ext_resource type="PackedScene" uid="uid://cumv8wij5uufk" path="res://entities/weapons/chaingun/assets/chaingun.glb" id="1_d8tdv"]
[ext_resource type="Script" path="res://entities/weapons/chaingun/chaingun.gd" id="2_qsqeh"]
[ext_resource type="Script" path="res://entities/components/projectile_spawner.gd" id="3_knyrc"]
[ext_resource type="PackedScene" uid="uid://b0sfwgilfbpx5" path="res://entities/weapons/chaingun/projectile.tscn" id="4_p63ts"]
[node name="ChainGun" node_paths=PackedStringArray("anim_player") instance=ExtResource("1_d8tdv")]
script = ExtResource("2_qsqeh")
_PROJECTILE = ExtResource("4_p63ts")
anim_player = NodePath("AnimationPlayer")
[node name="ProjectileSpawner" type="Marker3D" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.124544, 0.476417)
script = ExtResource("3_knyrc")
PROJECTILE = ExtResource("4_p63ts")
inheritance = 1.0
min_spread = 1.0
max_spread = 4.0
spin_period = 0.5
heat_period = 3.0
cooldown_threshold = 1.7
speed_cooldown_factor = 0.001
ammo = 150
max_ammo = 150
ammo_usage = 1
cooldown = 0.1
[node name="Skeleton3D" parent="Armature" index="0"]
bones/1/rotation = Quaternion(3.09086e-08, 0.707107, 0.707107, 3.09086e-08)
@ -32,14 +36,18 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Grip" parent="Armature/Skeleton3D" index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="AnimationPlayer" parent="." index="2"]
[node name="AnimationPlayer" parent="." index="1"]
autoplay = "idle"
[node name="Barrels" type="BoneAttachment3D" parent="." index="3"]
[node name="Barrels" type="BoneAttachment3D" parent="." index="2"]
transform = Transform3D(-1, 0, 8.74227e-08, 8.74227e-08, 0, 1, 0, 1, 0, -2.32831e-10, 0.692504, 0.756307)
bone_name = "barrels"
bone_idx = 1
use_external_skeleton = true
external_skeleton = NodePath("../Armature/Skeleton3D")
[node name="Nozzle" type="Marker3D" parent="." index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.98023e-08, 0.123522, 0.477262)
[connection signal="triggered" from="." to="." method="_on_triggered"]
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]

View file

@ -12,44 +12,19 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name ChainGunProjectile extends Node3D
class_name ChainGunProjectile extends Projectile
@export var speed : float = 180. # m/s
@export var lifespan : float = .5 # in seconds
@export var build_up_time : float = .6 # seconds
var shooter : MatchParticipant
var velocity : Vector3 = Vector3.ZERO
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$Timer.wait_time = lifespan
func _on_timer_timeout() -> void:
queue_free()
func _physics_process(delta : float) -> void:
func _physics_process(delta: float) -> void:
var previous_global_position: Vector3 = global_position
global_position += velocity * delta
if shape_cast.is_colliding():
for collision_id in shape_cast.get_collision_count():
var collider : Object = shape_cast.get_collider(collision_id)
# handle collision
if shape_cast:
var local_global_position: Vector3 = to_local(previous_global_position)
shape_cast.target_position = Vector3(
local_global_position.x, -local_global_position.z, local_global_position.y)
shape_cast.target_position = shape_cast.target_position
if shape_cast.is_colliding():
var collider: Node = shape_cast.get_collider(0)
if collider is Player:
if is_multiplayer_authority():
assert(shooter)
collider.health_component.damage.rpc(25, shooter.player_id, shooter.team_id)
queue_free()
## This method is a parameterized constructor for the [ChainGunProjectile] scene of the [ChainGun]
static func new_projectile(
origin : Marker3D,
inherited_velocity : Vector3,
_shooter : MatchParticipant,
scene : PackedScene
) -> ChainGunProjectile:
var projectile : ChainGunProjectile = scene.instantiate()
projectile.shooter = _shooter
projectile.transform = origin.global_transform
projectile.velocity = origin.global_basis.z.normalized() * projectile.speed + inherited_velocity
return projectile
collider.damage.emit(source, collider, damage)
destroy(shape_cast.collision_result[0].point)

View file

@ -9,17 +9,15 @@ height = 2.5
[node name="ChainGunProjectile" instance=ExtResource("1_p7mmn")]
script = ExtResource("2_jjfwk")
speed = 128.0
lifespan = 3.0
damage = 15
[node name="ShapeCast3D" type="ShapeCast3D" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 4.29628)
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 1.25)
shape = SubResource("CapsuleShape3D_dbodg")
target_position = Vector3(0, -3, 0)
target_position = Vector3(0, 0, 0)
collision_mask = 2147483653
[node name="tracerinner" parent="." index="1"]
transform = Transform3D(0.0505494, 0, 0, 0, 0.0505494, 0, 0, 0, 0.0505494, 0, 0, 2.49628)
[node name="Timer" type="Timer" parent="." index="2"]
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
transform = Transform3D(0.0505494, 0, 0, 0, 0.0505494, 0, 0, 0, 0.0505494, 0, 0, 2.5)