Adding loads of icons and starting refactor of weapons and mods
This commit is contained in:
parent
1a959fbc0c
commit
f97521decc
4411 changed files with 74792 additions and 42 deletions
|
|
@ -7,7 +7,7 @@ signal on_destroyed(projectile)
|
|||
|
||||
@export var speed: float = 500.0
|
||||
@export var damage: float = 10.0
|
||||
@export var lifetime: float = 5.0
|
||||
@export var lifetime: float = 2
|
||||
@export var direction: Vector2 = Vector2.RIGHT
|
||||
@export var target_position: Vector2
|
||||
@export var is_friendly: bool = true
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ func _on_body_entered(body):
|
|||
return
|
||||
|
||||
# Check if the colliding body is an enemy or object
|
||||
if body.is_in_group("enemies") or body.is_in_group("objects"):
|
||||
if body.is_in_group("enemies"):
|
||||
Log.pr("Hit enemy: ", body.name)
|
||||
if not has_collided: # Only process the first collision
|
||||
# Set collision state and point
|
||||
has_collided = true
|
||||
|
|
@ -114,6 +115,7 @@ func _on_body_entered(body):
|
|||
var direction_to_body = (body.global_position - global_position).normalized()
|
||||
var body_radius = 10.0 # Adjust for your game
|
||||
collision_point = body.global_position - (direction_to_body * body_radius)
|
||||
Log.pr("Collision point updated to: ", collision_point)
|
||||
|
||||
# Debug output
|
||||
Log.pr("Lightning hit: " + body.name + " at point: " + str(collision_point))
|
||||
|
|
@ -121,9 +123,7 @@ func _on_body_entered(body):
|
|||
# IMPORTANT: Immediately update the collision shape to stop at collision point
|
||||
update_collision_shape()
|
||||
|
||||
_trigger_explosion()
|
||||
|
||||
#super._on_body_entered(body)
|
||||
#_trigger_explosion()
|
||||
|
||||
|
||||
if body.is_in_group("enemies") and is_friendly:
|
||||
|
|
@ -131,32 +131,24 @@ func _on_body_entered(body):
|
|||
# Deal damage to enemy
|
||||
if body.has_method("take_damage"):
|
||||
body.take_damage(damage)
|
||||
|
||||
# Emit signal for modifiers to react to
|
||||
emit_signal("on_hit", self, body)
|
||||
|
||||
# Handle piercing
|
||||
if pierce_count > 0:
|
||||
pierce_count -= 1
|
||||
else:
|
||||
# Handle explosive impact
|
||||
if has_explosive_impact:
|
||||
# Store the target that triggered the explosion
|
||||
ignore_target.append(body)
|
||||
_trigger_explosion()
|
||||
|
||||
# Handle piercing
|
||||
if pierce_count > 0:
|
||||
pierce_count -= 1
|
||||
else:
|
||||
# Handle explosive impact
|
||||
if has_explosive_impact:
|
||||
# Store the target that triggered the explosion
|
||||
ignore_target.append(body)
|
||||
#_trigger_explosion()
|
||||
self.call_deferred("_trigger_explosion")
|
||||
|
||||
# Emit signal for modifiers to react to
|
||||
emit_signal("on_hit", self, body)
|
||||
|
||||
|
||||
func _spawn_explosion_projectiles():
|
||||
for i in range(explosion_projectile_count):
|
||||
# Create a new projectile
|
||||
Log.pr("Spawning explosion projectile")
|
||||
var new_proj = (load(scene_file_path) as PackedScene).instantiate()
|
||||
Log.pr("New projectile: ", new_proj)
|
||||
new_proj.global_position = collision_point
|
||||
|
||||
var min_distance = 50
|
||||
var max_distance = 125
|
||||
|
||||
# Generate a random angle
|
||||
var max_target_distance = 200 # Maximum distance to look for enemies
|
||||
|
||||
# Get all enemies in the scene
|
||||
|
|
@ -177,14 +169,16 @@ func _spawn_explosion_projectiles():
|
|||
var random_enemy = valid_targets[randi() % valid_targets.size()]
|
||||
random_point = random_enemy.global_position
|
||||
else:
|
||||
# Fallback if no enemies in range - use the original random point logic
|
||||
var random_angle = randf_range(0, TAU)
|
||||
var random_distance = randf_range(50, max_target_distance)
|
||||
random_point = collision_point + Vector2(
|
||||
cos(random_angle) * random_distance,
|
||||
sin(random_angle) * random_distance
|
||||
)
|
||||
return
|
||||
|
||||
Log.pr("Spawning explosion projectile")
|
||||
var new_proj = (load(scene_file_path) as PackedScene).instantiate()
|
||||
Log.pr("New projectile: ", new_proj)
|
||||
|
||||
new_proj.global_position = collision_point
|
||||
Log.pr("New projectile spawn: ", new_proj.global_position)
|
||||
|
||||
|
||||
new_proj.target_position = random_point
|
||||
|
||||
new_proj.damage = damage * explosion_projectile_damage_mult
|
||||
|
|
@ -203,5 +197,4 @@ func _spawn_explosion_projectiles():
|
|||
get_tree().root.call_deferred("add_child", new_proj)
|
||||
|
||||
func _on_lifetime_timeout():
|
||||
Log.pr("ProjectileLightning _on_lifetime_timeout")
|
||||
super._on_lifetime_timeout()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ signal projectile_spawned(projectile)
|
|||
# Base stats - will be modified by modifiers
|
||||
var base_stats = {
|
||||
"damage": 10.0,
|
||||
"fire_rate": 2.0,
|
||||
"fire_rate": 3.0,
|
||||
"projectile_speed": 500.0,
|
||||
"projectile_size": 1.0,
|
||||
"projectile_lifetime": 1.0,
|
||||
|
|
@ -44,10 +44,12 @@ func fire(direction: Vector2, target_position: Vector2):
|
|||
if !can_fire:
|
||||
return
|
||||
|
||||
Log.pr("Firing weapon")
|
||||
_spawn_projectile(global_position, direction, target_position)
|
||||
|
||||
can_fire = false
|
||||
fire_timer.start(1.0 / stats.get_stat("fire_rate"))
|
||||
Log.pr("Cooldown", stats.get_stat("fire_rate"))
|
||||
fire_timer.start(stats.get_stat("fire_rate"))
|
||||
|
||||
func _spawn_projectile(spawn_position: Vector2, spawn_direction: Vector2, target_position: Vector2):
|
||||
# Get projectile quantity and spread from stats
|
||||
|
|
@ -111,4 +113,5 @@ func _on_stats_updated():
|
|||
pass
|
||||
|
||||
func _on_fire_timer_timeout():
|
||||
Log.pr("Fire timer timeout")
|
||||
can_fire = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue