Player fairness, AI adjustments
This commit is contained in:
parent
49fd5c0d65
commit
3ecd6c3e1b
5 changed files with 56 additions and 19 deletions
|
|
@ -43,11 +43,14 @@ shape = SubResource("CircleShape2D_uwrxv")
|
||||||
|
|
||||||
[node name="Hitbox" type="Area2D" parent="."]
|
[node name="Hitbox" type="Area2D" parent="."]
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape2D" parent="Hitbox"]
|
[node name="Large" type="CollisionShape2D" parent="Hitbox"]
|
||||||
shape = SubResource("CircleShape2D_lnu2h")
|
shape = SubResource("CircleShape2D_lnu2h")
|
||||||
debug_color = Color(0.9686392, 0, 0.4696517, 0.41960785)
|
debug_color = Color(0.9686392, 0, 0.4696517, 0.41960785)
|
||||||
|
|
||||||
[node name="SightCast" type="RayCast2D" parent="."]
|
[node name="SightCast" type="RayCast2D" parent="."]
|
||||||
target_position = Vector2(0, -256)
|
target_position = Vector2(0, -256)
|
||||||
|
|
||||||
|
[node name="FireCast" type="RayCast2D" parent="."]
|
||||||
|
target_position = Vector2(0, -1024)
|
||||||
|
|
||||||
[connection signal="body_shape_entered" from="Hitbox" to="." method="_on_hitbox_body_shape_entered"]
|
[connection signal="body_shape_entered" from="Hitbox" to="." method="_on_hitbox_body_shape_entered"]
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,12 @@ debug_color = Color(0.9686392, 0, 0.4696517, 0.41960785)
|
||||||
[node name="Enemy" parent="." instance=ExtResource("11_dinhu")]
|
[node name="Enemy" parent="." instance=ExtResource("11_dinhu")]
|
||||||
position = Vector2(0, -418)
|
position = Vector2(0, -418)
|
||||||
|
|
||||||
|
[node name="Enemy2" parent="." instance=ExtResource("11_dinhu")]
|
||||||
|
position = Vector2(362, 397)
|
||||||
|
|
||||||
|
[node name="Enemy3" parent="." instance=ExtResource("11_dinhu")]
|
||||||
|
position = Vector2(362, 397)
|
||||||
|
|
||||||
[node name="Unloadables" type="Node2D" parent="."]
|
[node name="Unloadables" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="UI" type="CanvasLayer" parent="."]
|
[node name="UI" type="CanvasLayer" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://dgj3hd5wlaoc0"]
|
[gd_scene load_steps=8 format=3 uid="uid://dgj3hd5wlaoc0"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b7te10evkqwhy" path="res://scripts/laser.gd" id="1_a7dhc"]
|
[ext_resource type="Script" uid="uid://b7te10evkqwhy" path="res://scripts/laser.gd" id="1_a7dhc"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bb0v0jtreyba3" path="res://textures/laser.png" id="2_jjj73"]
|
[ext_resource type="Texture2D" uid="uid://bb0v0jtreyba3" path="res://textures/laser.png" id="2_jjj73"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_trtic"]
|
|
||||||
radius = 12.0
|
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_ir15t"]
|
[sub_resource type="Curve" id="Curve_ir15t"]
|
||||||
_data = [Vector2(0, 0.5393259), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
_data = [Vector2(0, 0.5393259), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||||
point_count = 2
|
point_count = 2
|
||||||
|
|
@ -17,23 +14,34 @@ curve = SubResource("Curve_ir15t")
|
||||||
gravity = Vector3(0, 98, 0)
|
gravity = Vector3(0, 98, 0)
|
||||||
alpha_curve = SubResource("CurveTexture_ca42v")
|
alpha_curve = SubResource("CurveTexture_ca42v")
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_trtic"]
|
||||||
|
radius = 12.0
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_a7dhc"]
|
||||||
|
radius = 2.0
|
||||||
|
height = 20.0
|
||||||
|
|
||||||
[node name="Laser" type="RigidBody2D"]
|
[node name="Laser" type="RigidBody2D"]
|
||||||
linear_damp = 6.247
|
linear_damp = 6.247
|
||||||
script = ExtResource("1_a7dhc")
|
script = ExtResource("1_a7dhc")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
|
||||||
texture = ExtResource("2_jjj73")
|
|
||||||
|
|
||||||
[node name="Hitbox" type="Area2D" parent="."]
|
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape2D" parent="Hitbox"]
|
|
||||||
shape = SubResource("CircleShape2D_trtic")
|
|
||||||
debug_color = Color(1, 0, 0, 0.41960785)
|
|
||||||
|
|
||||||
[node name="Trail" type="GPUParticles2D" parent="."]
|
[node name="Trail" type="GPUParticles2D" parent="."]
|
||||||
amount = 24
|
amount = 24
|
||||||
texture = ExtResource("2_jjj73")
|
texture = ExtResource("2_jjj73")
|
||||||
lifetime = 0.05
|
lifetime = 0.05
|
||||||
process_material = SubResource("ParticleProcessMaterial_rysoc")
|
process_material = SubResource("ParticleProcessMaterial_rysoc")
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("2_jjj73")
|
||||||
|
|
||||||
|
[node name="Hitbox" type="Area2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Large" type="CollisionShape2D" parent="Hitbox"]
|
||||||
|
shape = SubResource("CircleShape2D_trtic")
|
||||||
|
debug_color = Color(1, 0, 0, 0.41960785)
|
||||||
|
|
||||||
|
[node name="Small" type="CollisionShape2D" parent="Hitbox"]
|
||||||
|
shape = SubResource("CapsuleShape2D_a7dhc")
|
||||||
|
debug_color = Color(0.77871144, 0.126396, 0.9999997, 0.41960785)
|
||||||
|
|
||||||
[connection signal="body_shape_entered" from="Hitbox" to="." method="_on_hitbox_body_shape_entered"]
|
[connection signal="body_shape_entered" from="Hitbox" to="." method="_on_hitbox_body_shape_entered"]
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,9 @@ func _process(delta: float) -> void:
|
||||||
modulate.g = health / 1000.0
|
modulate.g = health / 1000.0
|
||||||
modulate.b = health / 1000.0
|
modulate.b = health / 1000.0
|
||||||
|
|
||||||
|
if health <= 0:
|
||||||
|
queue_free()
|
||||||
|
|
||||||
ai_tick -= delta
|
ai_tick -= delta
|
||||||
|
|
||||||
if boosting:
|
if boosting:
|
||||||
|
|
@ -112,7 +115,7 @@ func _process(delta: float) -> void:
|
||||||
time_since_last_collision += delta
|
time_since_last_collision += delta
|
||||||
|
|
||||||
if ai_tick < 0:
|
if ai_tick < 0:
|
||||||
ai_tick = 0.1
|
ai_tick = 0.25
|
||||||
|
|
||||||
movement_axis = -1
|
movement_axis = -1
|
||||||
|
|
||||||
|
|
@ -130,10 +133,14 @@ func _process(delta: float) -> void:
|
||||||
$SightCast.position.x = 0
|
$SightCast.position.x = 0
|
||||||
|
|
||||||
if ai_mode == AI_MODE_ATTACK:
|
if ai_mode == AI_MODE_ATTACK:
|
||||||
|
firing = false
|
||||||
|
|
||||||
if !front_cast and (player_distance > 480):
|
if !front_cast and (player_distance > 480):
|
||||||
boost_pressed = true
|
boost_pressed = true
|
||||||
elif front_cast == player:
|
elif $FireCast.get_collider() == player:
|
||||||
if player_distance > 480: boost_pressed = true
|
if player_distance > 480: boost_pressed = true
|
||||||
|
|
||||||
|
firing = true
|
||||||
else:
|
else:
|
||||||
boost_pressed = false
|
boost_pressed = false
|
||||||
|
|
||||||
|
|
@ -142,14 +149,21 @@ func _process(delta: float) -> void:
|
||||||
if ai_state == AI_STATE_TRACK_ENEMY:
|
if ai_state == AI_STATE_TRACK_ENEMY:
|
||||||
target_rotation = direction_to_player
|
target_rotation = direction_to_player
|
||||||
|
|
||||||
|
if (player.linear_velocity.length() < 256) and (player_distance < 256):
|
||||||
|
ai_state = AI_STATE_STATIONARY_ENEMY
|
||||||
|
|
||||||
if ai_state == AI_STATE_STATIONARY_ENEMY:
|
if ai_state == AI_STATE_STATIONARY_ENEMY:
|
||||||
target_rotation = direction_to_player
|
target_rotation = direction_to_player
|
||||||
movement_axis = 0
|
movement_axis = 0
|
||||||
|
boost_pressed = false
|
||||||
|
|
||||||
|
if (player.linear_velocity.length() > 256) or (player_distance > 320):
|
||||||
|
ai_state = AI_STATE_TRACK_ENEMY
|
||||||
|
|
||||||
if front_cast:
|
if front_cast:
|
||||||
var front_cast_distance = ($SightCast.get_collision_point() - position).length()
|
var front_cast_distance = ($SightCast.get_collision_point() - position).length()
|
||||||
|
|
||||||
if (front_cast_distance < 160 * (speed / 300.0)) and (front_cast_distance < player_distance):
|
if (front_cast_distance < 160 * (speed / 300.0)) and (front_cast_distance < player_distance) and (ai_state != AI_STATE_STATIONARY_ENEMY):
|
||||||
if ai_state != AI_STATE_EVADE_OBJECT: last_ai_state_before_evasion = ai_state
|
if ai_state != AI_STATE_EVADE_OBJECT: last_ai_state_before_evasion = ai_state
|
||||||
|
|
||||||
ai_state = AI_STATE_EVADE_OBJECT
|
ai_state = AI_STATE_EVADE_OBJECT
|
||||||
|
|
@ -157,7 +171,7 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
object_to_evade = front_cast
|
object_to_evade = front_cast
|
||||||
|
|
||||||
target_rotation_speed = 1
|
target_rotation_speed = 0.8
|
||||||
|
|
||||||
if ai_state == AI_STATE_EVADE_OBJECT:
|
if ai_state == AI_STATE_EVADE_OBJECT:
|
||||||
if not front_cast:
|
if not front_cast:
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@ var creator = null
|
||||||
var lifetime = 0
|
var lifetime = 0
|
||||||
var has_collided = false
|
var has_collided = false
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if creator.get_name() == "Player":
|
||||||
|
$Hitbox/Small.free()
|
||||||
|
else:
|
||||||
|
$Hitbox/Large.free()
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if has_collided: return
|
if has_collided: return
|
||||||
|
|
||||||
|
|
@ -20,7 +26,7 @@ func _on_hitbox_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index
|
||||||
$Trail.visible = false
|
$Trail.visible = false
|
||||||
|
|
||||||
if "health" in body:
|
if "health" in body:
|
||||||
body.health -= 100
|
body.health -= 75
|
||||||
|
|
||||||
await get_tree().create_timer(1.0).timeout
|
await get_tree().create_timer(1.0).timeout
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue