fixed doc thinker state
parent
6b29cbf8fe
commit
393091e546
|
@ -14,9 +14,6 @@ public partial class InteractionTrigger : Area2D
|
|||
[Signal]
|
||||
public delegate void UntargetEventHandler();
|
||||
|
||||
[Export]
|
||||
public string PopupText { get; set; }
|
||||
|
||||
private Control _popup;
|
||||
|
||||
public override void _Ready()
|
||||
|
@ -25,7 +22,6 @@ public partial class InteractionTrigger : Area2D
|
|||
|
||||
_popup = GetNode<Control>("Popup");
|
||||
_popup.Visible = false;
|
||||
_popup.GetNode<Label>("Label").Text = PopupText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -34,7 +34,7 @@ anchor_top = 1.0
|
|||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -128.0
|
||||
offset_top = -36.0
|
||||
offset_top = -30.0
|
||||
offset_right = 128.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
@ -51,7 +51,10 @@ offset_right = 23.0
|
|||
offset_bottom = 19.0
|
||||
grow_horizontal = 2
|
||||
theme = ExtResource("2_75ngm")
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_shadow_color = Color(0.105882, 0.0470588, 0.117647, 1)
|
||||
theme_override_constants/shadow_offset_x = 0
|
||||
theme_override_constants/shadow_offset_y = 1
|
||||
theme_override_constants/shadow_outline_size = 0
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "Okayeg"
|
||||
horizontal_alignment = 1
|
||||
|
@ -65,9 +68,9 @@ anchor_left = 0.5
|
|||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -8.0
|
||||
offset_top = -16.0
|
||||
offset_right = 8.0
|
||||
offset_left = -6.0
|
||||
offset_top = -12.0
|
||||
offset_right = 6.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
texture = SubResource("AtlasTexture_n00hm")
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using Godot;
|
||||
using SupaLidlGame.Extensions;
|
||||
using SupaLidlGame.State.Character;
|
||||
using SupaLidlGame.BoundingBoxes;
|
||||
using SupaLidlGame.State.Thinker;
|
||||
|
||||
namespace SupaLidlGame.Characters;
|
||||
|
||||
|
@ -13,10 +15,6 @@ public partial class Doc : Boss
|
|||
[Export]
|
||||
public Items.Weapons.Sword Lance { get; set; }
|
||||
|
||||
protected bool _dashedAway = false;
|
||||
protected CharacterDashState _dashState;
|
||||
protected float _originalDashModifier;
|
||||
|
||||
[Export]
|
||||
public override bool IsActive
|
||||
{
|
||||
|
@ -27,6 +25,13 @@ public partial class Doc : Boss
|
|||
var introState = BossStateMachine
|
||||
.GetNode<State.NPC.Doc.DocIntroState>("Intro");
|
||||
BossStateMachine.ChangeState(introState);
|
||||
|
||||
if (IsActive)
|
||||
{
|
||||
var trig = GetNode<InteractionTrigger>("InteractionTrigger");
|
||||
var coll = trig.GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
coll.Disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,9 +81,6 @@ public partial class Doc : Boss
|
|||
|
||||
base._Ready();
|
||||
|
||||
_dashState = StateMachine.FindChildOfType<CharacterDashState>();
|
||||
_originalDashModifier = _dashState.VelocityModifier;
|
||||
|
||||
var dialog = GD.Load<Resource>("res://Assets/Dialogue/doc.dialogue");
|
||||
|
||||
GetNode<BoundingBoxes.InteractionTrigger>("InteractionTrigger")
|
||||
|
@ -155,86 +157,14 @@ public partial class Doc : Boss
|
|||
{
|
||||
if (BossStateMachine.CurrentState is State.NPC.Doc.DocLanceState)
|
||||
{
|
||||
ThirdPhaseThink();
|
||||
if (ThinkerStateMachine.CurrentState is not DashDefensive)
|
||||
{
|
||||
ThinkerStateMachine.ChangeState<DashDefensive>(out var _);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Think();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ThirdPhaseThink()
|
||||
{
|
||||
Character bestTarget = FindBestTarget();
|
||||
if (bestTarget is not null)
|
||||
{
|
||||
Vector2 pos = bestTarget.GlobalPosition;
|
||||
Target = pos - GlobalPosition;
|
||||
Vector2 dir = GlobalPosition.DirectionTo(pos);
|
||||
float dist = GlobalPosition.DistanceSquaredTo(pos);
|
||||
UpdateWeights(pos);
|
||||
|
||||
if (CanAttack && StunTime <= 0)
|
||||
{
|
||||
bool isTargetStunned = bestTarget.StunTime > 0;
|
||||
|
||||
bool shouldDashAway = false;
|
||||
bool shouldDashTowards = false;
|
||||
|
||||
var lanceState = Lance.StateMachine.CurrentState;
|
||||
|
||||
if (Inventory.SelectedItem != Lance)
|
||||
{
|
||||
Inventory.SelectedItem = Lance;
|
||||
}
|
||||
|
||||
float dot = Direction.Normalized()
|
||||
.Dot(bestTarget.Direction.Normalized());
|
||||
|
||||
// doc will still dash if you are farther than normal but
|
||||
// moving towards him
|
||||
float distThreshold = 2500 - (dot * 400);
|
||||
|
||||
// or just directly dash towards you if you are too far
|
||||
float distTowardsThreshold = 22500;
|
||||
|
||||
// dash towards if lance in anticipate state
|
||||
shouldDashTowards = (isTargetStunned || _dashedAway) &&
|
||||
lanceState is State.Weapon.SwordAnticipateState ||
|
||||
dist > distTowardsThreshold;
|
||||
|
||||
shouldDashAway = dist < distThreshold && !isTargetStunned;
|
||||
|
||||
//if (!isTargetStunned && dist < 2500 && !_dashedAway)
|
||||
if (shouldDashAway && !shouldDashTowards)
|
||||
{
|
||||
// dash away if too close
|
||||
_dashState.VelocityModifier = _originalDashModifier;
|
||||
DashTo(-dir);
|
||||
UseCurrentItem();
|
||||
_dashedAway = true;
|
||||
}
|
||||
else if (shouldDashTowards && !shouldDashAway)
|
||||
{
|
||||
// dash to player's predicted position
|
||||
_dashState.VelocityModifier = _originalDashModifier * 1.75f;
|
||||
var dashSpeed = _dashState.VelocityModifier * Speed;
|
||||
var newPos = Utils.Physics.PredictNewPosition(
|
||||
GlobalPosition,
|
||||
dashSpeed,
|
||||
pos,
|
||||
bestTarget.Velocity,
|
||||
out float _);
|
||||
DashTo(GlobalPosition.DirectionTo(newPos));
|
||||
_dashedAway = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DashTo(Vector2 direction)
|
||||
{
|
||||
StateMachine.ChangeState<CharacterDashState>(out var state);
|
||||
state.DashDirection = direction;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=66 format=3 uid="uid://d2skjvvx6fal0"]
|
||||
[gd_scene load_steps=69 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"]
|
||||
|
@ -22,13 +22,16 @@
|
|||
[ext_resource type="Script" path="res://State/NPC/Doc/DocIntroState.cs" id="11_lt771"]
|
||||
[ext_resource type="Script" path="res://State/NPC/Doc/DocChooseAttackState.cs" id="12_45x13"]
|
||||
[ext_resource type="Script" path="res://State/NPC/Doc/DocUnwantedFrequencyState.cs" id="12_d51jv"]
|
||||
[ext_resource type="PackedScene" uid="uid://1y5r6sklwgrp" path="res://Entities/UnwantedFrequency.tscn" id="13_lpj21"]
|
||||
[ext_resource type="Script" path="res://State/NPC/Doc/DocLanceState.cs" id="15_dmd05"]
|
||||
[ext_resource type="Script" path="res://Utils/AnimationManager.cs" id="16_bsvls"]
|
||||
[ext_resource type="Texture2D" uid="uid://bd8l8kafb42dt" path="res://Assets/Sprites/Particles/circle.png" id="16_x277j"]
|
||||
[ext_resource type="PackedScene" uid="uid://1y5r6sklwgrp" path="res://Entities/UnwantedFrequency.tscn" id="17_hl6o0"]
|
||||
[ext_resource type="Material" uid="uid://bat28samf7ukd" path="res://Assets/Sprites/Particles/NPCDamageProcessMaterial.tres" id="17_iomdx"]
|
||||
[ext_resource type="Texture2D" uid="uid://c1a7lvb4uuwfy" path="res://Assets/Sprites/Particles/circle-16.png" id="19_p0p6c"]
|
||||
[ext_resource type="Material" uid="uid://rcjujd5dv7lm" path="res://Assets/Sprites/Particles/DocIntroParticles.tres" id="19_q4rt1"]
|
||||
[ext_resource type="Script" path="res://State/Thinker/DashDefensive.cs" id="20_12htp"]
|
||||
[ext_resource type="Script" path="res://State/Thinker/ThinkerStateMachine.cs" id="20_dy57x"]
|
||||
[ext_resource type="Script" path="res://State/Thinker/AttackState.cs" id="21_ij3bp"]
|
||||
[ext_resource type="Animation" uid="uid://8e8r3y1imvsx" path="res://Assets/Animations/stun.res" id="21_ixn4k"]
|
||||
[ext_resource type="PackedScene" uid="uid://p7oijq6dbvvk" path="res://Items/Weapons/DocLance.tscn" id="24_2es2r"]
|
||||
[ext_resource type="PackedScene" uid="uid://bauucuqvjwbxp" path="res://Items/Weapons/DocLanceHold.tscn" id="26_0tntj"]
|
||||
|
@ -552,7 +555,7 @@ size = Vector2(16, 19)
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_8hwat"]
|
||||
radius = 16.0
|
||||
|
||||
[node name="Doc" type="CharacterBody2D" node_paths=PackedStringArray("Lance", "BossStateMachine", "Sprite", "Inventory", "StateMachine", "Hurtbox")]
|
||||
[node name="Doc" type="CharacterBody2D" node_paths=PackedStringArray("Lance", "BossStateMachine", "ThinkerStateMachine", "Sprite", "Inventory", "StateMachine", "Hurtbox")]
|
||||
y_sort_enabled = true
|
||||
texture_filter = 3
|
||||
material = SubResource("ShaderMaterial_7n7iy")
|
||||
|
@ -563,6 +566,7 @@ Lance = NodePath("Inventory/DocLance")
|
|||
BossStateMachine = NodePath("BossStateMachine")
|
||||
BossName = "Doc, The Two-Time"
|
||||
Music = ExtResource("3_eo4lg")
|
||||
ThinkerStateMachine = NodePath("ThinkerStateMachine")
|
||||
HandTexture = ExtResource("4_8lqj6")
|
||||
Health = 900.0
|
||||
Sprite = NodePath("Sprite")
|
||||
|
@ -628,9 +632,9 @@ NPC = NodePath("../..")
|
|||
|
||||
[node name="UnwantedFrequency" type="Node" parent="BossStateMachine" node_paths=PackedStringArray("ChooseAttackState", "Doc", "NPC")]
|
||||
script = ExtResource("12_d51jv")
|
||||
Duration = 4.0
|
||||
Duration = 2.0
|
||||
AttackDuration = 1.0
|
||||
Projectile = ExtResource("13_lpj21")
|
||||
Projectile = ExtResource("17_hl6o0")
|
||||
ChooseAttackState = NodePath("../ChooseAttack")
|
||||
Doc = NodePath("../..")
|
||||
NPC = NodePath("../..")
|
||||
|
@ -661,11 +665,17 @@ TelegraphAnimationPlayer = NodePath("../../Animations/Telegraph")
|
|||
TelegraphState = NodePath("../Telegraph")
|
||||
NPC = NodePath("../..")
|
||||
|
||||
[node name="ThinkerStateMachine" type="Node" parent="."]
|
||||
[node name="ThinkerStateMachine" type="Node" parent="." node_paths=PackedStringArray("InitialState")]
|
||||
script = ExtResource("20_dy57x")
|
||||
InitialState = NodePath("Attack")
|
||||
|
||||
[node name="Attack" type="Node" parent="ThinkerStateMachine"]
|
||||
[node name="Attack" type="Node" parent="ThinkerStateMachine" node_paths=PackedStringArray("NPC")]
|
||||
script = ExtResource("21_ij3bp")
|
||||
NPC = NodePath("../..")
|
||||
|
||||
[node name="DashAttack" type="Node" parent="ThinkerStateMachine"]
|
||||
[node name="DashDefensive" type="Node" parent="ThinkerStateMachine" node_paths=PackedStringArray("NPC")]
|
||||
script = ExtResource("20_12htp")
|
||||
NPC = NodePath("../..")
|
||||
|
||||
[node name="Animations" type="Node" parent="."]
|
||||
script = ExtResource("16_bsvls")
|
||||
|
@ -758,10 +768,9 @@ Faction = 2
|
|||
position = Vector2(0, -3.5)
|
||||
shape = SubResource("RectangleShape2D_8lxmf")
|
||||
|
||||
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Items")]
|
||||
[node name="Inventory" type="Node2D" parent="."]
|
||||
y_sort_enabled = true
|
||||
script = ExtResource("8_r8ejq")
|
||||
Items = []
|
||||
|
||||
[node name="DocLance" parent="Inventory" instance=ExtResource("24_2es2r")]
|
||||
unique_name_in_owner = true
|
||||
|
@ -769,11 +778,17 @@ unique_name_in_owner = true
|
|||
[node name="DocLanceHold" parent="Inventory" instance=ExtResource("26_0tntj")]
|
||||
|
||||
[node name="InteractionTrigger" parent="." instance=ExtResource("33_08dyq")]
|
||||
PopupText = ""
|
||||
|
||||
[node name="CollisionShape2D" parent="InteractionTrigger" index="0"]
|
||||
position = Vector2(0, -6)
|
||||
shape = SubResource("CircleShape2D_8hwat")
|
||||
|
||||
[node name="Popup" parent="InteractionTrigger" index="1"]
|
||||
offset_top = -44.0
|
||||
offset_bottom = -14.0
|
||||
|
||||
[node name="Label" parent="InteractionTrigger/Popup" index="0"]
|
||||
text = "Duel"
|
||||
|
||||
[editable path="Hurtbox"]
|
||||
[editable path="InteractionTrigger"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=60 format=3 uid="uid://b2254pup8k161"]
|
||||
[gd_scene load_steps=61 format=3 uid="uid://b2254pup8k161"]
|
||||
|
||||
[ext_resource type="Script" path="res://Characters/Player.cs" id="1_flygr"]
|
||||
[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_ngsgt"]
|
||||
|
@ -281,6 +281,8 @@ states/stop/position = Vector2(438, 100)
|
|||
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_sorqc"), "idle", "move", SubResource("AnimationNodeStateMachineTransition_ujrp0"), "move", "stop", SubResource("AnimationNodeStateMachineTransition_kjkm8"), "stop", "idle", SubResource("AnimationNodeStateMachineTransition_1ywlq"), "idle", "roll", SubResource("AnimationNodeStateMachineTransition_abs7t"), "roll", "idle", SubResource("AnimationNodeStateMachineTransition_qlka8"), "roll", "move", SubResource("AnimationNodeStateMachineTransition_ql2f3"), "move", "roll", SubResource("AnimationNodeStateMachineTransition_g1yba")]
|
||||
graph_offset = Vector2(-335.315, -63.5708)
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachinePlayback" id="AnimationNodeStateMachinePlayback_lrnca"]
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_852jj"]
|
||||
particle_flag_disable_z = true
|
||||
spread = 180.0
|
||||
|
@ -391,6 +393,7 @@ libraries = {
|
|||
[node name="AnimationTree" type="AnimationTree" parent="Animations"]
|
||||
tree_root = SubResource("AnimationNodeStateMachine_0ukul")
|
||||
anim_player = NodePath("../Movement")
|
||||
parameters/playback = SubResource("AnimationNodeStateMachinePlayback_lrnca")
|
||||
parameters/conditions/idle = false
|
||||
parameters/conditions/move = false
|
||||
parameters/conditions/roll = false
|
||||
|
@ -475,10 +478,9 @@ text = "lol"
|
|||
label_settings = SubResource("LabelSettings_q5h1n")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Items")]
|
||||
[node name="Inventory" type="Node2D" parent="."]
|
||||
position = Vector2(0, -4)
|
||||
script = ExtResource("7_xyenu")
|
||||
Items = []
|
||||
InventoryMap = {
|
||||
"equip_1": 0,
|
||||
"equip_2": 1
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://73jm5qjy52vq"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://73jm5qjy52vq"]
|
||||
|
||||
[ext_resource type="Script" path="res://Dialogue/Balloon.cs" id="1_obwi7"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckvgyvclnwggo" path="res://addons/dialogue_manager/dialogue_label.tscn" id="2_a8ve6"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcy8iheoqxnjn" path="res://Assets/Sprites/UI/menu-rect.png" id="2_i5a6k"]
|
||||
[ext_resource type="Theme" uid="uid://cksjbu3vrup5" path="res://UI/Themes/supalidl.tres" id="2_kowbc"]
|
||||
[ext_resource type="FontFile" uid="uid://bo3obq6sos7lu" path="res://Assets/Fonts/compass-pro.ttf" id="4_8e5aq"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5d24i"]
|
||||
content_margin_left = 40.0
|
||||
|
@ -52,9 +51,10 @@ layout_mode = 2
|
|||
mouse_filter = 1
|
||||
theme_override_colors/font_shadow_color = Color(0.105882, 0.0470588, 0.117647, 1)
|
||||
theme_override_colors/font_outline_color = Color(0.270588, 0.160784, 0.247059, 1)
|
||||
theme_override_constants/shadow_offset_x = 2
|
||||
theme_override_constants/shadow_offset_y = 3
|
||||
theme_override_constants/outline_size = 8
|
||||
theme_override_constants/shadow_offset_x = 1
|
||||
theme_override_constants/shadow_offset_y = 2
|
||||
theme_override_constants/shadow_outline_size = 0
|
||||
theme_override_constants/outline_size = 4
|
||||
bbcode_enabled = true
|
||||
text = "Character"
|
||||
fit_content = true
|
||||
|
@ -62,9 +62,10 @@ scroll_active = false
|
|||
|
||||
[node name="DialogueLabel" parent="Balloon/Margin/VBox" instance=ExtResource("2_a8ve6")]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_outline_color = Color(0.270588, 0.160784, 0.247059, 1)
|
||||
theme_override_constants/outline_size = 4
|
||||
theme_override_fonts/normal_font = ExtResource("4_8e5aq")
|
||||
theme_override_colors/font_shadow_color = Color(0.105882, 0.0470588, 0.117647, 1)
|
||||
theme_override_constants/shadow_offset_x = 0
|
||||
theme_override_constants/shadow_offset_y = 1
|
||||
theme_override_constants/shadow_outline_size = 0
|
||||
text = "I bought a whole bunch of shungite."
|
||||
|
||||
[node name="Responses" type="VBoxContainer" parent="Balloon/Margin/VBox"]
|
||||
|
|
|
@ -22,6 +22,13 @@ hframes = 2
|
|||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_7pr7c")
|
||||
|
||||
[node name="Popup" parent="InteractionTrigger" index="1"]
|
||||
offset_top = -58.0
|
||||
offset_bottom = -28.0
|
||||
|
||||
[node name="Label" parent="InteractionTrigger/Popup" index="0"]
|
||||
text = "Enter"
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." node_paths=PackedStringArray("InteractionTrigger", "Collision")]
|
||||
script = ExtResource("3_4rsih")
|
||||
ToArea = "res://Scenes/Maps/Arena.tscn"
|
||||
|
|
|
@ -124,11 +124,10 @@ _data = {
|
|||
"open": SubResource("Animation_1nbqx")
|
||||
}
|
||||
|
||||
[node name="ArenaDoor" type="StaticBody2D" node_paths=PackedStringArray("VisibleOnToggle")]
|
||||
[node name="ArenaDoor" type="StaticBody2D"]
|
||||
collision_mask = 0
|
||||
script = ExtResource("1_t6mj1")
|
||||
MapStateKey = "b_arena_depths_door_1"
|
||||
VisibleOnToggle = [NodePath("GPUParticles2D"), NodePath("AudioStreamPlayer2D")]
|
||||
|
||||
[node name="Gate" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_kvtjv")
|
||||
|
|
|
@ -93,19 +93,22 @@ _data = {
|
|||
"on": SubResource("Animation_0yjbt")
|
||||
}
|
||||
|
||||
[node name="ArenaDoorSwitch" type="StaticBody2D"]
|
||||
[node name="ArenaDoorSwitch" type="StaticBody2D" node_paths=PackedStringArray("InteractionTrigger")]
|
||||
script = ExtResource("1_78qab")
|
||||
InteractionTrigger = NodePath("InteractionTrigger")
|
||||
|
||||
[node name="InteractionTrigger" parent="." instance=ExtResource("2_7j8p7")]
|
||||
PopupText = null
|
||||
|
||||
[node name="CollisionShape2D" parent="InteractionTrigger" index="0"]
|
||||
shape = SubResource("CircleShape2D_1i8i0")
|
||||
|
||||
[node name="Popup" parent="InteractionTrigger" index="1"]
|
||||
offset_top = -44.0
|
||||
offset_top = -38.0
|
||||
offset_bottom = -8.0
|
||||
|
||||
[node name="Label" parent="InteractionTrigger/Popup" index="0"]
|
||||
text = "Activate"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("3_pgkt4")
|
||||
centered = false
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=43 format=3 uid="uid://c72uqjjtxpi3g"]
|
||||
[gd_scene load_steps=42 format=3 uid="uid://c72uqjjtxpi3g"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://clwv2owvk6abe" path="res://Scenes/BaseMap.tscn" id="1_ci4ij"]
|
||||
[ext_resource type="TileSet" uid="uid://l61kbx31ug4p" path="res://Scenes/Maps/ArenaTileset.tres" id="2_m6h7j"]
|
||||
|
@ -154,11 +154,6 @@ size = Vector2(64, 97)
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5pcme"]
|
||||
size = Vector2(18, 6)
|
||||
|
||||
[sub_resource type="NavigationPolygon" id="NavigationPolygon_8tfjc"]
|
||||
vertices = PackedVector2Array(-35, -90, -150, -43, -212, -98, -240, -224, -10, -183, 8, -138, -46, -149, -37, -194, -24, -208, -21, -228, 14, -220, 27, -228, 86, -119, 43, -94, 38, -147, 47, -206)
|
||||
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(4, 5, 6, 7, 8), PackedInt32Array(8, 7, 9), PackedInt32Array(10, 8, 9, 11), PackedInt32Array(12, 13, 14, 15), PackedInt32Array(15, 14, 10, 11)])
|
||||
outlines = Array[PackedVector2Array]([PackedVector2Array(-240, -224, -212, -98, -150, -43, -35, -90), PackedVector2Array(-37, -194, -46, -149, 8, -138, -10, -183, -24, -208, 14, -220, 38, -147, 43, -94, 86, -119, 47, -206, 27, -228, -21, -228)])
|
||||
|
||||
[node name="ArenaExterior" instance=ExtResource("1_ci4ij")]
|
||||
tile_set = ExtResource("2_m6h7j")
|
||||
layer_0/tile_data = PackedInt32Array(-1703963, 393216, 0, -1703954, 393216, 0, -1703953, 458752, 2, -393224, 196608, 4, -262152, 196608, 4, -131080, 196608, 4, 196600, 196608, 4, 327672, 196608, 4, 458744, 196608, 4, -458759, 131072, 4, 589817, 458752, 4, -458757, 131072, 4, 589819, 458752, 4, -458755, 131072, 4, 589821, 458752, 4, -524286, 131072, 4, 524290, 458752, 4, -524284, 131072, 4, 524292, 458752, 4, -524282, 131072, 4, 524294, 458752, 4, -458744, 327680, 4, -327672, 327680, 4, -196600, 327680, 4, 131080, 327680, 4, 262152, 327680, 4, 393224, 327680, 4, -589819, 458752, 2, -524294, 458752, 2, -524292, 393216, 2, -589821, 393216, 2, 131070, 458752, 0, 131068, 458752, 0, 131066, 458752, 0, 262142, 458752, 0, 393214, 458752, 0, 327681, 458752, 0, 196609, 458752, 0, 65537, 458752, 0, 65539, 458752, 0, 65541, 458752, 0, -131067, 458752, 0, -131069, 458752, 0, -131071, 458752, 0, -262143, 458752, 0, -393215, 458752, 0, -327682, 458752, 0, -196610, 458752, 0, -65538, 458752, 0, -65540, 458752, 0, -65542, 458752, 0, -1638415, 131072, 4, -1638426, 131072, 4, -1507340, 131072, 4, -1572862, 131072, 4, -1507333, 131072, 4, -1703960, 393216, 2, 1900541, 131072, 4, 1835010, 131072, 4, 1835020, 131072, 4, 1835025, 131072, 4, 2883581, 458752, 4, 2818050, 458752, 4, 2818055, 458752, 4, 2818060, 458752, 4, 2818065, 458752, 4, 2097152, 458752, 0, 2097156, 458752, 0, 2097160, 458752, 0, 2097164, 458752, 0, 2490380, 458752, 0, 2490376, 458752, 0, 2490372, 458752, 0, 2490368, 458752, 0, 2097162, 458752, 0, 2097154, 458752, 0, 2490370, 458752, 0, 2490374, 458752, 0, 2097158, 458752, 0, 2490378, 458752, 0, 2097166, 458752, 0, 2228238, 458752, 0, 2359310, 458752, 0, 2490382, 458752, 0, 1835015, 131072, 4, 1835039, 786432, 0, 1835040, 851968, 0)
|
||||
|
@ -571,22 +566,13 @@ position = Vector2(576, 416)
|
|||
y_sort_enabled = true
|
||||
position = Vector2(-224, 41)
|
||||
MapStateKey = "b_arena_depths_1"
|
||||
DefaultState = false
|
||||
|
||||
[node name="StaticBody2D" parent="Entities" index="2" instance=ExtResource("22_ay852")]
|
||||
[node name="ArenaDoorSwitch" parent="Entities" index="2" instance=ExtResource("22_ay852")]
|
||||
position = Vector2(-257, 76)
|
||||
MapStateKey = "b_arena_depths_1"
|
||||
|
||||
[node name="BottomDoor" type="Node2D" parent="Entities" index="3"]
|
||||
|
||||
[node name="ArenaDoorSwitch" parent="Entities" index="4" instance=ExtResource("22_ay852")]
|
||||
position = Vector2(44, -6)
|
||||
|
||||
[node name="NavigationRegion2D" type="NavigationRegion2D" parent="." index="7"]
|
||||
position = Vector2(112, 96)
|
||||
navigation_polygon = SubResource("NavigationPolygon_8tfjc")
|
||||
enabled = false
|
||||
|
||||
[editable path="Props/StaticBookshelf"]
|
||||
[editable path="Props/StaticBookshelf2"]
|
||||
[editable path="Props/StaticBookshelf3"]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using SupaLidlGame.State.Thinker;
|
||||
|
||||
namespace SupaLidlGame.State.NPC.Doc;
|
||||
|
||||
|
@ -36,6 +37,7 @@ public partial class DocLanceState : DocAttackState
|
|||
{
|
||||
var state = base.Enter(previousState);
|
||||
_doc.ShouldMove = true;
|
||||
_doc.ThinkerStateMachine.ChangeState<DashDefensive>(out var _);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
using Godot;
|
||||
using SupaLidlGame.State.Character;
|
||||
using SupaLidlGame.Extensions;
|
||||
|
||||
namespace SupaLidlGame.State.Thinker;
|
||||
|
||||
public partial class DashDefensive : AttackState
|
||||
{
|
||||
protected bool _dashedAway = false;
|
||||
protected State.Character.CharacterDashState _dashState;
|
||||
protected float _originalDashModifier;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_dashState = NPC.StateMachine.FindChildOfType<CharacterDashState>();
|
||||
_originalDashModifier = _dashState.VelocityModifier;
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
public override ThinkerState Think()
|
||||
{
|
||||
Characters.Character bestTarget = NPC.FindBestTarget();
|
||||
if (bestTarget is not null)
|
||||
{
|
||||
Vector2 pos = bestTarget.GlobalPosition;
|
||||
NPC.Target = pos - NPC.GlobalPosition;
|
||||
Vector2 dir = NPC.GlobalPosition.DirectionTo(pos);
|
||||
float dist = NPC.GlobalPosition.DistanceSquaredTo(pos);
|
||||
UpdateWeights(pos);
|
||||
|
||||
if (NPC.CanAttack && NPC.StunTime <= 0)
|
||||
{
|
||||
bool isTargetStunned = bestTarget.StunTime > 0;
|
||||
|
||||
bool shouldDashAway = false;
|
||||
bool shouldDashTowards = false;
|
||||
|
||||
var currentItem = NPC.Inventory.SelectedItem;
|
||||
if (currentItem is not Items.Weapons.Sword sword)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var swordState = sword.StateMachine.CurrentState;
|
||||
|
||||
float dot = NPC.Direction.Normalized()
|
||||
.Dot(bestTarget.Direction.Normalized());
|
||||
|
||||
// doc will still dash if you are farther than normal but
|
||||
// moving towards him
|
||||
float distThreshold = 2500 - (dot * 400);
|
||||
|
||||
// or just directly dash towards you if you are too far
|
||||
float distTowardsThreshold = 22500;
|
||||
|
||||
// dash towards if lance in anticipate state
|
||||
shouldDashTowards = (isTargetStunned || _dashedAway) &&
|
||||
swordState is State.Weapon.SwordAnticipateState ||
|
||||
dist > distTowardsThreshold;
|
||||
|
||||
shouldDashAway = dist < distThreshold && !isTargetStunned;
|
||||
|
||||
//if (!isTargetStunned && dist < 2500 && !_dashedAway)
|
||||
if (shouldDashAway && !shouldDashTowards)
|
||||
{
|
||||
// dash away if too close
|
||||
_dashState.VelocityModifier = _originalDashModifier;
|
||||
DashTo(-dir);
|
||||
NPC.UseCurrentItem();
|
||||
_dashedAway = true;
|
||||
}
|
||||
else if (shouldDashTowards && !shouldDashAway)
|
||||
{
|
||||
// dash to player's predicted position
|
||||
_dashState.VelocityModifier = _originalDashModifier * 1.75f;
|
||||
var dashSpeed = _dashState.VelocityModifier * NPC.Speed;
|
||||
var newPos = Utils.Physics.PredictNewPosition(
|
||||
NPC.GlobalPosition,
|
||||
dashSpeed,
|
||||
pos,
|
||||
bestTarget.Velocity,
|
||||
out float _);
|
||||
DashTo(NPC.GlobalPosition.DirectionTo(newPos));
|
||||
_dashedAway = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void DashTo(Vector2 direction)
|
||||
{
|
||||
var stateMachine = NPC.StateMachine;
|
||||
stateMachine.ChangeState<CharacterDashState>(out var state);
|
||||
state.DashDirection = direction;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Godot.NET.Sdk/4.1.0">
|
||||
<Project Sdk="Godot.NET.Sdk/4.1.0-dev">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
|
|
|
@ -72,13 +72,13 @@ ui_down={
|
|||
}
|
||||
roll={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"pressed":false,"double_click":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
attack1={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
equip={
|
||||
|
|
Loading…
Reference in New Issue