-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationCallsPlayer.gd
More file actions
184 lines (125 loc) · 4 KB
/
Copy pathAnimationCallsPlayer.gd
File metadata and controls
184 lines (125 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
extends Node
onready var parent=$".."
onready var animation=$"../character/AnimationPlayer"
onready var tween=$Tween
onready var timer=$Timer
onready var dmg_area=$"../Area"
onready var stats=$"../Stats"
var combo_stage:int=0
var combo_playing:bool=false
var can_comboB:bool=false
var can_comboC:bool=false
var locked:bool=false
"""
combo_atk()->void stops the combo attack animation
call this for press to attack otherwise the player needs to hold on the combo attack
button to keep doing base attacks, there's a modality to switch between the two
but for the people that want to do press to attack instead of hold to attack this is needed
call it at the end of every hit in the combo attack animation, during the recovery frames
"""
func combo_atk()->void:
$"../UI/Skillbar".continue_combo_atk = false
$"../UI/Skillbar".consumeCombo()
func dealDMG()->void:
stats.dealDamage()
func applyBuff()->void:
stats.selfBuff()
var speed_up_combos = {
"stone splitter": false,
"placeholder": false,
}
var speed_up_combo_until = {}
func speedUPtheNextATK(selected_atk:String):
speed_up_combo_until[selected_atk] = OS.get_ticks_msec() / 1000.0 + 4.0
var BerserkComboTimer:float = 2
func BerserkBasicCombo():
var selected_atk:String = "stone splitter"
speed_up_combo_until[selected_atk] = OS.get_ticks_msec() / 1000.0 + BerserkComboTimer
func flipDirection()->void:
parent.direction = -parent.direction
parent.player_mesh.rotation.y += PI
parent.turnable.rotation.y += PI
func disableCollisions()->void:
for body in get_tree().get_nodes_in_group("Entity"):
if body == parent:
continue
parent.add_collision_exception_with(body)
body.add_collision_exception_with(parent)
func enableCollisions()->void:
for body in get_tree().get_nodes_in_group("Entity"):
if body == parent:
continue
parent.remove_collision_exception_with(body)
body.remove_collision_exception_with(parent)
func unlockAnim():
speed_up_combo_until.erase(parent.current_skill)
if parent.current_skill != "combo attack":
for key in parent.anim_locks:
parent.anim_locks[key] = false
parent.current_skill = "none"
parent.last_active_skill = ""
parent.animation_tree.active = false
func connectUnlockAnimLastFrames():
var save_path = "res://world/player/human/animations/"
var dir = Directory.new()
if !dir.dir_exists(save_path):
dir.make_dir_recursive(save_path)
for anim_name in animation.get_animation_list():
var anim = animation.get_animation(anim_name)
if anim == null:
continue
for i in range(anim.get_track_count() - 1,-1,-1):
if anim.track_get_type(i) == Animation.TYPE_METHOD:
anim.remove_track(i)
var unlock_track = anim.add_track(Animation.TYPE_METHOD)
anim.track_set_path(
unlock_track,
NodePath("../AnimationCalls")
)
anim.track_insert_key(
unlock_track,
anim.length,
{
"method":"unlockAnim",
"args":[]
}
)
ResourceSaver.save(
"%s%s.tres" % [save_path,anim_name],
anim
)
func cleanCallTracks():
var save_path = "res://world/player/human/animations/"
var dir = Directory.new()
if !dir.dir_exists(save_path):
return
for anim_name in animation.get_animation_list():
if !(anim_name in parent.anim_locks):
continue
var anim = animation.get_animation(anim_name)
if anim == null:
continue
for i in range(anim.get_track_count() - 1,-1,-1):
if anim.track_get_type(i) == Animation.TYPE_METHOD:
anim.remove_track(i)
ResourceSaver.save(
"%s%s.tres" % [save_path,anim_name],
anim
)
func loadAnimations():
var save_path = "res://world/player/human/animations/"
var dir = Directory.new()
if dir.open(save_path) != OK:
return
dir.list_dir_begin(true,true)
var file_name = dir.get_next()
while file_name != "":
if file_name.ends_with(".tres"):
var anim_name = file_name.get_basename()
var anim = load("%s%s" % [save_path,file_name])
if anim:
if animation.has_animation(anim_name):
animation.remove_animation(anim_name)
animation.add_animation(anim_name,anim)
file_name = dir.get_next()
dir.list_dir_end()