Make Doc dodge projectiles during lance state
parent
b54ce905ab
commit
feec74fa65
|
@ -10,9 +10,6 @@ public partial class Doc : Boss
|
|||
|
||||
public AnimationPlayer MiscAnimation { get; set; }
|
||||
|
||||
[Export]
|
||||
public Items.Weapons.Sword Lance { get; set; }
|
||||
|
||||
[Export]
|
||||
public override bool IsActive
|
||||
{
|
||||
|
@ -109,7 +106,7 @@ public partial class Doc : Boss
|
|||
if (name == "Doc")
|
||||
{
|
||||
IsActive = true;
|
||||
Inventory.SelectedItem = Lance;
|
||||
Inventory.SelectedItem = GetNode<Items.Item>("%DocLance");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -122,7 +119,7 @@ public partial class Doc : Boss
|
|||
if (this.GetWorld().CurrentPlayer.IsAlive && !IsActive)
|
||||
{
|
||||
IsActive = true;
|
||||
Inventory.SelectedItem = Lance;
|
||||
Inventory.SelectedItem = GetNode<Items.Item>("%DocLance");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=71 format=3 uid="uid://d2skjvvx6fal0"]
|
||||
[gd_scene load_steps=72 format=3 uid="uid://d2skjvvx6fal0"]
|
||||
|
||||
[ext_resource type="Script" path="res://Characters/Doc.cs" id="2_3elet"]
|
||||
[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_5jxom"]
|
||||
|
@ -568,14 +568,16 @@ size = Vector2(16, 19)
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_8hwat"]
|
||||
radius = 16.0
|
||||
|
||||
[node name="Doc" type="CharacterBody2D" node_paths=PackedStringArray("Lance", "BossStateMachine", "DefaultSelectedItem", "ThinkerStateMachine", "Stats", "Sprite", "Inventory", "StateMachine", "Hurtbox")]
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_kap5k"]
|
||||
radius = 48.0
|
||||
|
||||
[node name="Doc" type="CharacterBody2D" node_paths=PackedStringArray("BossStateMachine", "DefaultSelectedItem", "ThinkerStateMachine", "Stats", "Sprite", "Inventory", "StateMachine", "Hurtbox")]
|
||||
y_sort_enabled = true
|
||||
texture_filter = 3
|
||||
material = SubResource("ShaderMaterial_7n7iy")
|
||||
collision_layer = 10
|
||||
collision_mask = 17
|
||||
script = ExtResource("2_3elet")
|
||||
Lance = NodePath("Inventory/DocLance")
|
||||
BossStateMachine = NodePath("BossStateMachine")
|
||||
BossName = "Doc, The Two-Time"
|
||||
Music = ExtResource("3_qnxmu")
|
||||
|
@ -698,8 +700,9 @@ InitialState = NodePath("Attack")
|
|||
script = ExtResource("21_ij3bp")
|
||||
NPC = NodePath("../..")
|
||||
|
||||
[node name="DashDefensive" type="Node" parent="ThinkerStateMachine" node_paths=PackedStringArray("NPC")]
|
||||
[node name="DashDefensive" type="Node" parent="ThinkerStateMachine" node_paths=PackedStringArray("ProjectileDetection", "NPC")]
|
||||
script = ExtResource("20_12htp")
|
||||
ProjectileDetection = NodePath("../../ProjectileDetection")
|
||||
MaxDistanceToTarget = 256.0
|
||||
UseItemDistance = 64.0
|
||||
NPC = NodePath("../..")
|
||||
|
@ -820,5 +823,13 @@ offset_bottom = -14.0
|
|||
[node name="Label" parent="InteractionTrigger/Popup" index="0"]
|
||||
text = "Duel"
|
||||
|
||||
[node name="ProjectileDetection" type="Area2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 0
|
||||
collision_mask = 256
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="ProjectileDetection"]
|
||||
shape = SubResource("CircleShape2D_kap5k")
|
||||
|
||||
[editable path="Hurtbox"]
|
||||
[editable path="InteractionTrigger"]
|
||||
|
|
|
@ -9,14 +9,49 @@ public partial class DashDefensive : AttackState
|
|||
protected bool _dashedAway = false;
|
||||
protected State.Character.CharacterDashState _dashState;
|
||||
protected float _originalDashModifier;
|
||||
private Callable _dodgeCallable;
|
||||
|
||||
[Export]
|
||||
public Area2D ProjectileDetection { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_dashState = NPC.StateMachine.FindChildOfType<CharacterDashState>();
|
||||
_originalDashModifier = _dashState.VelocityModifier;
|
||||
_dodgeCallable = new Callable(this, MethodName.DodgeProjectile);
|
||||
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
public override IState<ThinkerState> Enter(IState<ThinkerState> prev)
|
||||
{
|
||||
ProjectileDetection?.Connect(Area2D.SignalName.AreaEntered,
|
||||
_dodgeCallable);
|
||||
|
||||
return base.Enter(prev);
|
||||
}
|
||||
|
||||
public override void Exit(IState<ThinkerState> prev)
|
||||
{
|
||||
ProjectileDetection?.Disconnect(Area2D.SignalName.AreaEntered,
|
||||
_dodgeCallable);
|
||||
|
||||
base.Exit(prev);
|
||||
}
|
||||
|
||||
private void DodgeProjectile(Area2D area)
|
||||
{
|
||||
if (area is BoundingBoxes.Hitbox hitbox)
|
||||
{
|
||||
if (hitbox.GetOwner() is Entities.Projectile projectile)
|
||||
{
|
||||
GD.Print("changing direction");
|
||||
var direction = projectile.Direction;
|
||||
DashTo(direction.Rotated(Mathf.Pi / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override ThinkerState Think()
|
||||
{
|
||||
Characters.Character bestTarget = NPC.FindBestTarget();
|
||||
|
|
Loading…
Reference in New Issue