Add handcannon; need inventory system and the like to get it working properly

This commit is contained in:
toasterpanic 2026-05-16 17:22:56 -04:00
parent adc96042a3
commit c6da8d31ea
6 changed files with 113 additions and 26 deletions

View file

@ -0,0 +1,15 @@
[gd_scene format=3 uid="uid://ckfc4q1dbtli8"]
[ext_resource type="Texture2D" uid="uid://5mkyjoxmci5a" path="res://textures/weapons/inhands/basic_handcannon.png" id="1_fig3b"]
[node name="Handcannon" type="Node3D" unique_id=523683834]
transform = Transform3D(1, -7.642742e-15, -8.7422784e-08, 0, 1, -8.742278e-08, 8.7422784e-08, 8.742278e-08, 1, 0, 0, 0)
[node name="Handcannon" type="Sprite3D" parent="." unique_id=1764590626]
transform = Transform3D(4.3711374e-08, -1, 8.7422755e-08, -1, -4.371136e-08, 1.748456e-07, -1.7484558e-07, -8.742276e-08, -1, 0, 0, 0)
offset = Vector2(-6, 5)
pixel_size = 0.03
shaded = true
alpha_cut = 2
texture_filter = 0
texture = ExtResource("1_fig3b")

View file

@ -0,0 +1,15 @@
[gd_scene format=3 uid="uid://ufm8kssdh8vx"]
[node name="Bullet" type="Node3D" unique_id=1536641450]
[node name="MeshInstance3D" type="CSGCylinder3D" parent="." unique_id=1706082204]
transform = Transform3D(4.371139e-08, -1, 8.742278e-08, -1, -4.371139e-08, 0, 3.821371e-15, -8.742278e-08, -1, 0, 0, 0)
radius = 0.05
sides = 5
smooth_faces = false
[node name="Hit" type="RayCast3D" parent="." unique_id=10285465]
transform = Transform3D(-4.371139e-08, 1, -2.9802322e-08, 0, 2.9802322e-08, 1, 1, 4.371139e-08, -1.3027009e-15, 0, 0, 0)
target_position = Vector3(0, -500, 0)
collision_mask = 19
debug_shape_custom_color = Color(0, 1, 0, 1)

View file

@ -76,13 +76,25 @@ const weapons = {
"attack_swooshy": "pierce",
"attack_swooshy_scale": Vector3(1.5, 1, 1),
},
"basic_handcannon": {
"ranged_weapon": true,
"damage": 100,
"max_pierces": 3,
"knockback": 2.5,
"recharge_time": 15,
"bullet": preload("res://scenes/projectiles/bullet.tscn"),
"attack_swooshy": "pierce",
"attack_swooshy_scale": Vector3(1.5, 1, 1),
}
}
const inhands = {
"basic_sword": preload("res://scenes/inhands/basic_sword.tscn"),
"basic_hammer": preload("res://scenes/inhands/basic_hammer.tscn"),
"basic_knife": preload("res://scenes/inhands/basic_knife.tscn"),
"basic_spear": preload("res://scenes/inhands/basic_spear.tscn")
"basic_spear": preload("res://scenes/inhands/basic_spear.tscn"),
"basic_handcannon": preload("res://scenes/inhands/basic_handcannon.tscn")
}
const effects = {

View file

@ -63,7 +63,9 @@ func set_weapon(weapon_name: String = "basic_sword") -> void:
$DreamerBody.set_inhand(current_weapon)
var range = get_weapon_info(current_weapon, "range")
if not range: range = 1
var width = get_weapon_info(current_weapon, "width")
if not width: width = 1
$HitCollision/Shape.shape.size = Vector3(range, 1.0, width)
@ -229,34 +231,37 @@ func _process(delta: float) -> void:
combo_hits = 0
for body in hits:
if body == self: continue
if get_my_weapon_info("ranged_weapon"):
pass
else:
for body in hits:
if body == self: continue
if ("health" in body) and (body.health > 0):
body.health -= damage
if ("health" in body) and (body.health > 0):
body.health -= damage
var knockback_pos = global_position
knockback_pos.y = 0
var knockback_body_pos = $HitCollision/Shape.global_position
knockback_body_pos.y = 0
var knockback_pos = global_position
knockback_pos.y = 0
var knockback_body_pos = $HitCollision/Shape.global_position
knockback_body_pos.y = 0
body.position.y += 0.2
body.velocity.y = 0.4
body.velocity += knockback_pos.direction_to(knockback_body_pos) * knockback
body.position.y += 0.2
body.velocity.y = 0.4
body.velocity += knockback_pos.direction_to(knockback_body_pos) * knockback
if body.velocity.length() > knockback:
body.velocity = body.velocity.normalized() * knockback
if body.velocity.length() > knockback:
body.velocity = body.velocity.normalized() * knockback
if "mid_knockback" in body:
body.mid_knockback = true
if "mid_knockback" in body:
body.mid_knockback = true
if "on_knockback" in body:
body.on_knockback()
if "on_knockback" in body:
body.on_knockback()
var damage_text = preload("res://scenes/effects/damage_text.tscn").instantiate()
game.add_child(damage_text)
damage_text.global_position = body.global_position
damage_text.get_node("Label").text = str(floor(damage))
var damage_text = preload("res://scenes/effects/damage_text.tscn").instantiate()
game.add_child(damage_text)
damage_text.global_position = body.global_position
damage_text.get_node("Label").text = str(floor(damage))
var direction = (camera.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if dodging and (knockback_time <= 0):

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5mkyjoxmci5a"
path="res://.godot/imported/basic_handcannon.png-c376938e89f18e9233b6832e9644fa6c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/weapons/inhands/basic_handcannon.png"
dest_files=["res://.godot/imported/basic_handcannon.png-c376938e89f18e9233b6832e9644fa6c.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=0