waited far too long for an initial commit but here we are
This commit is contained in:
20
PCs/Universal/ClassCards/BombLauncher/bomb.gd
Normal file
20
PCs/Universal/ClassCards/BombLauncher/bomb.gd
Normal file
@ -0,0 +1,20 @@
|
||||
extends RigidBody3D
|
||||
class_name Bomb
|
||||
|
||||
@export var max_bounces := 1
|
||||
@export var damage := 10.0
|
||||
@export var explosion_range := 3.0
|
||||
var bounces := 0
|
||||
|
||||
func _on_body_entered(_body: Node) -> void:
|
||||
bounces += 1
|
||||
var collided_body = get_colliding_bodies()[0].get_collision_layer_value(3)
|
||||
if bounces > max_bounces or collided_body:
|
||||
explode()
|
||||
|
||||
|
||||
func explode():
|
||||
for enemy in get_tree().get_nodes_in_group("Enemies"):
|
||||
if global_position.distance_to(enemy.global_position) <= explosion_range:
|
||||
enemy.damage(damage)
|
||||
queue_free()
|
29
PCs/Universal/ClassCards/BombLauncher/bomb.tscn
Normal file
29
PCs/Universal/ClassCards/BombLauncher/bomb.tscn
Normal file
@ -0,0 +1,29 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d147iwg2wcqc5"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b54d5dc4jmlau" path="res://Assets/Textures/bomb.png" id="1_u615o"]
|
||||
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/bomb.gd" id="1_vekqm"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_whkhx"]
|
||||
bounce = 0.6
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_mi0in"]
|
||||
radius = 0.2
|
||||
|
||||
[node name="RigidBody3D" type="RigidBody3D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
physics_material_override = SubResource("PhysicsMaterial_whkhx")
|
||||
max_contacts_reported = 1
|
||||
contact_monitor = true
|
||||
script = ExtResource("1_vekqm")
|
||||
|
||||
[node name="Node3D" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(1.4, 0, 0, 0, 1.4, 0, 0, 0, 1.4, 0, 0, 0)
|
||||
billboard = 1
|
||||
texture_filter = 0
|
||||
texture = ExtResource("1_u615o")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("SphereShape3D_mi0in")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
30
PCs/Universal/ClassCards/BombLauncher/bombtower.gd
Normal file
30
PCs/Universal/ClassCards/BombLauncher/bombtower.gd
Normal file
@ -0,0 +1,30 @@
|
||||
extends Tower
|
||||
class_name BombTower
|
||||
|
||||
@export var bomb_scene: PackedScene
|
||||
var firing_velocity
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
firing_velocity = sqrt((stats.fire_range * ProjectSettings.get_setting("physics/3d/default_gravity")) / sin(2 * 45))
|
||||
|
||||
|
||||
func shoot():
|
||||
var bomb = bomb_scene.instantiate() as Bomb
|
||||
bomb.position = model.global_position
|
||||
bomb.damage = stats.damage
|
||||
get_tree().root.add_child(bomb)
|
||||
bomb.apply_impulse(-model.global_transform.basis.z * firing_velocity)
|
||||
|
||||
|
||||
func aim():
|
||||
var pos = Vector2(global_position.x, global_position.z)
|
||||
var t_pos = Vector2(targeted_enemy.global_position.x, targeted_enemy.global_position.z)
|
||||
var x = pos.distance_to(t_pos)
|
||||
var y = targeted_enemy.global_position.y - global_position.y
|
||||
var v = firing_velocity
|
||||
var g = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
var v2 = pow(v, 2)
|
||||
var angle = atan((v2 + sqrt(pow(v, 4) - g * ((g * pow(x, 2)) + (2 * y * v2)))) / (g * x))
|
||||
model.look_at(Vector3(t_pos.x, model.global_position.y, t_pos.y))
|
||||
model.rotate(model.global_transform.basis.x.normalized(), angle)
|
21
PCs/Universal/ClassCards/BombLauncher/bombweapon.gd
Normal file
21
PCs/Universal/ClassCards/BombLauncher/bombweapon.gd
Normal file
@ -0,0 +1,21 @@
|
||||
extends Weapon
|
||||
class_name BombWeapon
|
||||
|
||||
@export var bomb_scene: PackedScene
|
||||
var firing_velocity
|
||||
|
||||
func _ready() -> void:
|
||||
cooldown = 1.0 / stats.fire_rate
|
||||
firing_velocity = sqrt((stats.fire_range * ProjectSettings.get_setting("physics/3d/default_gravity")) / sin(2 * 45))
|
||||
$RayCast3D.target_position = Vector3(0, 0, -stats.fire_range)
|
||||
|
||||
|
||||
func shoot():
|
||||
if other_cooldown <= 0 and stats != null:
|
||||
other_cooldown = cooldown
|
||||
$AnimationPlayer.play("shoot")
|
||||
var bomb = bomb_scene.instantiate() as Bomb
|
||||
bomb.position = $RayCast3D.global_position
|
||||
bomb.damage = stats.damage
|
||||
get_tree().root.add_child(bomb)
|
||||
bomb.apply_impulse(-global_transform.basis.z * firing_velocity)
|
@ -0,0 +1,19 @@
|
||||
[gd_resource type="Resource" script_class="Card" load_steps=7 format=3 uid="uid://bvpkvmda845o5"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/card.gd" id="1_bscy2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bwufgga1pjyt" path="res://Assets/TextureAtlases/g_grenade_launcher.tres" id="2_xtrq2"]
|
||||
[ext_resource type="Resource" uid="uid://crmsk6lvp5i4e" path="res://Resources/TurretStats/bomblauncher.tres" id="3_c1c3t"]
|
||||
[ext_resource type="PackedScene" uid="uid://6ckryuql3bh8" path="res://PCs/Universal/ClassCards/BombLauncher/weapon_bomb_launcher.tscn" id="4_iaadg"]
|
||||
[ext_resource type="PackedScene" uid="uid://cwc8y1nv53btu" path="res://PCs/Universal/ClassCards/BombLauncher/tower_bomb_launcher.tscn" id="4_ux0v3"]
|
||||
[ext_resource type="Resource" uid="uid://kbaiy5u6imtu" path="res://Resources/WeaponStats/bomblauncher.tres" id="5_mhhrq"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_bscy2")
|
||||
title = "Grenade Launcher"
|
||||
rarity = 1
|
||||
faction = 0
|
||||
sprite = ExtResource("2_xtrq2")
|
||||
turret = ExtResource("4_ux0v3")
|
||||
weapon = ExtResource("4_iaadg")
|
||||
weapon_stats = ExtResource("5_mhhrq")
|
||||
tower_stats = ExtResource("3_c1c3t")
|
@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cwc8y1nv53btu"]
|
||||
|
||||
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/bombtower.gd" id="1_u2hyk"]
|
||||
[ext_resource type="PackedScene" uid="uid://d147iwg2wcqc5" path="res://PCs/Universal/ClassCards/BombLauncher/bomb.tscn" id="2_n307r"]
|
||||
[ext_resource type="Resource" uid="uid://crmsk6lvp5i4e" path="res://Resources/TurretStats/bomblauncher.tres" id="3_xv5rx"]
|
||||
|
||||
[node name="Node3D" type="Node3D" node_paths=PackedStringArray("model")]
|
||||
script = ExtResource("1_u2hyk")
|
||||
bomb_scene = ExtResource("2_n307r")
|
||||
stats = ExtResource("3_xv5rx")
|
||||
model = NodePath("Model")
|
||||
|
||||
[node name="Model" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.13842, 0)
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="Model"]
|
||||
|
||||
[node name="CSGBox3D2" type="CSGBox3D" parent="Model"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.65)
|
||||
size = Vector3(0.596453, 0.632841, 0.539216)
|
@ -0,0 +1,59 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://6ckryuql3bh8"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bwufgga1pjyt" path="res://Assets/TextureAtlases/g_grenade_launcher.tres" id="1_n7mif"]
|
||||
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/bombweapon.gd" id="2_4iyo6"]
|
||||
[ext_resource type="PackedScene" uid="uid://d147iwg2wcqc5" path="res://PCs/Universal/ClassCards/BombLauncher/bomb.tscn" id="3_506dv"]
|
||||
[ext_resource type="Resource" uid="uid://kbaiy5u6imtu" path="res://Resources/WeaponStats/bomblauncher.tres" id="4_45cu2"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_n8b32"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:texture:region")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Rect2(0, 0, 64, 64)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_g0h8q"]
|
||||
resource_name = "shoot"
|
||||
length = 0.15
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:texture:region")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.15),
|
||||
"transitions": PackedFloat32Array(0, 0),
|
||||
"update": 0,
|
||||
"values": [Rect2(64, 0, 64, 64), Rect2(0, 0, 64, 64)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ntl6p"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_n8b32"),
|
||||
"shoot": SubResource("Animation_g0h8q")
|
||||
}
|
||||
|
||||
[node name="Weapon" type="Sprite3D"]
|
||||
layers = 2
|
||||
billboard = 1
|
||||
texture_filter = 0
|
||||
texture = ExtResource("1_n7mif")
|
||||
script = ExtResource("2_4iyo6")
|
||||
bomb_scene = ExtResource("3_506dv")
|
||||
stats = ExtResource("4_45cu2")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_ntl6p")
|
||||
}
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
Reference in New Issue
Block a user