Skip to content

Commit d191226

Browse files
authored
Added mechanics to fox and turtle (#214)
* cyberfox mechanic added * turtle has effects, might be OP? * Added dodge, dodge added to cyberfox Dodge: 50% chance to not take damage and remove a charge/stack
1 parent 5c9e990 commit d191226

11 files changed

Lines changed: 215 additions & 3 deletions

File tree

642 Bytes
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://li36jtg8c5ao"
6+
path="res://.godot/imported/Status_Dodge.png-2abb54401cc55e9c1d845790ee310613.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://Classes/StatusEffects/Assets/Status_Dodge.png"
14+
dest_files=["res://.godot/imported/Status_Dodge.png-2abb54401cc55e9c1d845790ee310613.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

Classes/StatusEffects/StatusEffect.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,29 @@ public partial class StatusEffect : TextureRect, IBattleEvent
110110
)
111111
.SetTags(true);
112112

113+
private static readonly Action<BattleEventArgs, StatusEffect> DodgeEffect = (e, self) =>
114+
{
115+
if (e is BattleDirector.Harbinger.OnDamageInstanceArgs dmgArgs)
116+
{
117+
if (dmgArgs.Dmg.Target != self.Sufferer || dmgArgs.Dmg.Damage <= 0)
118+
return;
119+
if (StageProducer.GlobalRng.RandiRange(0, 1) == 0)
120+
return;
121+
122+
dmgArgs.Dmg.ModifyDamage(0, 0);
123+
self.DecCount();
124+
}
125+
};
126+
127+
public static readonly StatusEffect Dodge = new StatusEffect()
128+
.InitStatus(
129+
"Dodge",
130+
DodgeEffect,
131+
BattleEffectTrigger.OnDamageInstance,
132+
GD.Load<Texture2D>("res://Classes/StatusEffects/Assets/Status_Dodge.png")
133+
)
134+
.SetTags(true);
135+
113136
public static readonly Action<BattleEventArgs, StatusEffect> DisableEffect = (_, self) =>
114137
{
115138
self.DecCount();

Scenes/BattleDirector/Scripts/NotePlacementBar.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ public int GetCurrentCombo()
196196
return _currentCombo;
197197
}
198198

199+
public double GetCurrentBarValue()
200+
{
201+
return CurrentBarValue;
202+
}
203+
199204
public void ResetCurrentCombo()
200205
{
201206
_currentCombo = 0;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Glitch Effect Shader by Yui Kinomoto @arlez80
3+
4+
MIT License
5+
*/
6+
7+
shader_type canvas_item;
8+
9+
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
10+
11+
// 振動の強さ
12+
uniform float shake_power = 0.03;
13+
// 振動率
14+
uniform float shake_rate : hint_range( 0.0, 1.0 ) = 0.2;
15+
// 振動速度
16+
uniform float shake_speed = 5.0;
17+
// 振動ブロックサイズ
18+
uniform float shake_block_size = 30.5;
19+
// 色の分離率
20+
uniform float shake_color_rate : hint_range( 0.0, 1.0 ) = 0.01;
21+
22+
float random( float seed )
23+
{
24+
return fract( 543.2543 * sin( dot( vec2( seed, seed ), vec2( 3525.46, -54.3415 ) ) ) );
25+
}
26+
27+
void fragment( )
28+
{
29+
float enable_shift = float(
30+
random( trunc( TIME * shake_speed ) )
31+
< shake_rate
32+
);
33+
34+
vec2 fixed_uv = SCREEN_UV;
35+
fixed_uv.x += (
36+
random(
37+
( trunc( SCREEN_UV.y * shake_block_size ) / shake_block_size )
38+
+ TIME
39+
) - 0.5
40+
) * shake_power * enable_shift;
41+
42+
vec4 pixel_color = textureLod( SCREEN_TEXTURE, fixed_uv, 0.0 );
43+
pixel_color.r = mix(
44+
pixel_color.r
45+
, textureLod( SCREEN_TEXTURE, fixed_uv + vec2( shake_color_rate, 0.0 ), 0.0 ).r
46+
, enable_shift
47+
);
48+
pixel_color.b = mix(
49+
pixel_color.b
50+
, textureLod( SCREEN_TEXTURE, fixed_uv + vec2( -shake_color_rate, 0.0 ), 0.0 ).b
51+
, enable_shift
52+
);
53+
COLOR = pixel_color;
54+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://df5rjsuxn4o70
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using Godot;
3+
4+
public partial class GlitchScript : Node
5+
{
6+
private ShaderMaterial _glitchMaterial;
7+
private Timer _glitchTimer;
8+
9+
[Export]
10+
public Sprite2D Sprite;
11+
12+
public override void _Ready()
13+
{
14+
var shader = GD.Load<Shader>(
15+
"res://Scenes/Puppets/Enemies/CyberFox/Assets/GlitchEffect.gdshader"
16+
);
17+
_glitchMaterial = new ShaderMaterial { Shader = shader };
18+
Sprite.Material = _glitchMaterial;
19+
20+
DisableGlitch();
21+
_glitchTimer = new Timer { OneShot = true, Autostart = false };
22+
AddChild(_glitchTimer);
23+
_glitchTimer.Timeout += OnGlitchTimerTimeout;
24+
}
25+
26+
public void TriggerGlitch(float duration)
27+
{
28+
EnableGlitch();
29+
_glitchTimer.WaitTime = duration;
30+
_glitchTimer.Start();
31+
}
32+
33+
private void OnGlitchTimerTimeout()
34+
{
35+
DisableGlitch();
36+
}
37+
38+
private void EnableGlitch()
39+
{
40+
_glitchMaterial.SetShaderParameter("shake_rate", 0.8f);
41+
}
42+
43+
private void DisableGlitch()
44+
{
45+
_glitchMaterial.SetShaderParameter("shake_rate", 0.0f);
46+
}
47+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://3yclsl4kckx4

Scenes/Puppets/Enemies/CyberFox/CyberFox.tscn

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[gd_scene load_steps=7 format=3 uid="uid://2iq6mp0o5eri"]
1+
[gd_scene load_steps=8 format=3 uid="uid://2iq6mp0o5eri"]
22

33
[ext_resource type="Script" uid="uid://dnkjrr1f5up7x" path="res://Scenes/Puppets/Enemies/CyberFox/P_CyberFox.cs" id="1_e1x4p"]
44
[ext_resource type="PackedScene" uid="uid://cdoguwlxehbpg" path="res://Scenes/Puppets/StatusContainer.tscn" id="2_t5538"]
55
[ext_resource type="Texture2D" uid="uid://dy61pskhqgjoo" path="res://Scenes/Puppets/Enemies/CyberFox/Assets/CyberFox.png" id="3_e1x4p"]
66
[ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="4_lmj2w"]
7+
[ext_resource type="Script" uid="uid://3yclsl4kckx4" path="res://Scenes/Puppets/Enemies/CyberFox/Assets/GlitchScript.cs" id="5_a0uir"]
78

89
[sub_resource type="Gradient" id="Gradient_c7cx1"]
910
offsets = PackedFloat32Array(0.0227273, 1)
@@ -15,8 +16,9 @@ gradient = SubResource("Gradient_c7cx1")
1516
width = 100
1617
height = 18
1718

18-
[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("HealthBar", "Sprite", "_statusContainer")]
19+
[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_effectNode", "HealthBar", "Sprite", "_statusContainer")]
1920
script = ExtResource("1_e1x4p")
21+
_effectNode = NodePath("GlitchNode")
2022
HealthBar = NodePath("ProgressBar")
2123
Sprite = NodePath("Sprite")
2224
_statusContainer = NodePath("StatusContainer")
@@ -26,7 +28,7 @@ offset_top = -6.0
2628
offset_bottom = 30.0
2729

2830
[node name="Sprite" type="Sprite2D" parent="."]
29-
position = Vector2(0, -12)
31+
position = Vector2(10, -12)
3032
texture = ExtResource("3_e1x4p")
3133

3234
[node name="ProgressBar" parent="." instance=ExtResource("4_lmj2w")]
@@ -35,3 +37,12 @@ offset_top = 32.0
3537
offset_right = 50.0
3638
offset_bottom = 52.0
3739
texture_progress = SubResource("GradientTexture2D_c0jk6")
40+
41+
[node name="GlitchNode" type="Node2D" parent="." node_paths=PackedStringArray("Sprite")]
42+
position = Vector2(10, 0)
43+
script = ExtResource("5_a0uir")
44+
Sprite = NodePath("Sprite2D")
45+
46+
[node name="Sprite2D" type="Sprite2D" parent="GlitchNode"]
47+
position = Vector2(0, -12)
48+
texture = ExtResource("3_e1x4p")

Scenes/Puppets/Enemies/CyberFox/P_CyberFox.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ public partial class P_CyberFox : EnemyPuppet
77
public static new readonly string LoadPath =
88
"res://Scenes/Puppets/Enemies/CyberFox/CyberFox.tscn";
99

10+
[Export]
11+
private GlitchScript _effectNode;
12+
1013
public override void _Ready()
1114
{
1215
MaxHealth = 130;
@@ -26,5 +29,19 @@ public override void _Ready()
2629
enemTween.SetEase(Tween.EaseType.InOut);
2730
enemTween.SetLoops();
2831
enemTween.Play();
32+
33+
BattleEvents = new EnemyEffect[]
34+
{
35+
new EnemyEffect(
36+
this,
37+
BattleEffectTrigger.OnLoop,
38+
1,
39+
(e, eff, val) =>
40+
{
41+
e.BD.AddStatus(Targetting.First, StatusEffect.Dodge, 1);
42+
_effectNode.TriggerGlitch(1f);
43+
}
44+
),
45+
};
2946
}
3047
}

0 commit comments

Comments
 (0)