Skip to content

Commit

Permalink
Merge pull request #150 from nezvers/gamepad_direction
Browse files Browse the repository at this point in the history
spread and aim fix
  • Loading branch information
nezvers authored Nov 23, 2024
2 parents 791f6c0 + 48328d3 commit ab15731
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion addons/top_down/scenes/weapons/shotgun.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://ghnv48d18ftl"]

[ext_resource type="PackedScene" uid="uid://bxf4p5yoajpdu" path="res://addons/top_down/scenes/weapons/gun.tscn" id="1_xioje"]
[ext_resource type="Texture2D" uid="uid://dob8uix80gqww" path="res://addons/top_down/assets/images/weapon/gun_1.png" id="2_hrbvp"]
[ext_resource type="Texture2D" uid="uid://clee3ikfa1g11" path="res://addons/top_down/assets/images/weapon/gun_1.png" id="2_hrbvp"]
[ext_resource type="Resource" uid="uid://dlkgtlk8nau36" path="res://addons/top_down/resources/DamageResource/shotgun_damage.tres" id="2_te3cg"]
[ext_resource type="Resource" uid="uid://f7qtvi0nk5sx" path="res://addons/top_down/resources/InstanceResources/projectiles/shotgun_bullet_instance_resource.tres" id="5_yypu2"]

Expand Down
20 changes: 0 additions & 20 deletions addons/top_down/scripts/damage/DamageResource.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ extends TransmissionResource
@export var report_callback:Callable


func _init()->void:
pass

func _notification(what: int) -> void:
if what == NOTIFICATION_PREDELETE:
print("DamageResource [INFO]: predelete - ", resource_name)
pass

## final value applied in HealthResource
## Projectiles can influence resulting value
func get_total_damage()->float:
Expand Down Expand Up @@ -58,15 +50,8 @@ func new_generation()->DamageResource:
func new_split()->DamageResource:
var data:DamageResource = self.duplicate()
data.resource_name += "_split"
#data._print_info()
return data

func _print_info()->void:
print("DamageResource [INFO]: self - ", resource_name)
print("DamageResource [INFO]: callable method - ", report_callback.get_method())
print("DamageResource [INFO]: callable valid - ", report_callback.is_valid())
print("DamageResource [INFO]: callable object - ", report_callback.get_object().resource_name)


## Receiving end should trigger this function
func process(resource_node:ResourceNode)->void:
Expand Down Expand Up @@ -101,10 +86,5 @@ func process(resource_node:ResourceNode)->void:

success()

# Sends a report through resources self was duplicated from
# TODO: Test if still works
print("DamageResource [INFO]: self - ", resource_name)
#print("DamageResource [INFO]: callable object - ", report_callback.get_object().resource_name)
print("DamageResource [INFO]: callable object - ", report_callback.get_method())
if report_callback.is_valid:
report_callback.call(self)
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ func start()->void:
func timeout()->void:
weapon_trigger.can_shoot = true
if weapon_trigger.can_retrigger():
#weapon_trigger.on_shoot()
pass
weapon_trigger.on_shoot()
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ func spawn()->void:

for angle:float in projectile_angles:
var _config_callback:Callable = func (inst:Projectile2D)->void:
inst.direction = (direction.rotated(deg_to_rad(angle)) * axis_multiplication_resource.value).normalized()
# TODO: maybe there's better solution
var _angle_delta:Vector2 = (direction.rotated(deg_to_rad(angle)) - direction) * axis_multiplication_resource.value

inst.direction = (direction + _angle_delta).normalized()
inst.damage_resource = new_damage_resource.new_split()
inst.collision_mask = Bitwise.append_flags(inst.collision_mask, collision_mask)
inst.global_position = initial_distance * direction * axis_multiplication_resource.value + projectile_position
Expand Down

0 comments on commit ab15731

Please sign in to comment.