-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMega Player script to reduce node count bacause load times are too slow
More file actions
1422 lines (1379 loc) · 47.1 KB
/
Mega Player script to reduce node count bacause load times are too slow
File metadata and controls
1422 lines (1379 loc) · 47.1 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
extends KinematicBody
#player rotation, animation and otherwise mostly visual stuff
onready var player_mesh = get_node("Mesh")
onready var an = $Mesh/AnimationPlayer
var blend = 0.25
var is_in_combat = false
var duel_wield_mode = false
var bow_mode = false
var two_handed_sword_mode = false
var one_handed_sword_mode = false
var sword_and_shield_mode = false
var crossbow_mode = false
var magic_staff_mode = false
var barehanded_mode = true
var can_move = true
#collision booleans
var has_ride = false
# movement variables
var velocity := Vector3()
export var gravity = 9.8
export var sprint_speed = 20
var teleport_distance = 35
var attack_move_speed = 4.5
export (float) var mouse_sense = 0.1
# Dodge
export var double_press_time: float = 0.4
var dash_countback: int = 0
var dash_timerback: float = 0.0
# Dodge Left
var dash_countleft: int = 0
var dash_timerleft: float = 0.0
# Dodge right
var dash_countright: int = 0
var dash_timerright: float = 0.0
# Dodge forward
var dash_countforward: int = 0
var dash_timerforward: float = 0.0
# Dodge multidirection (not in strafe mode)
var dash_count1 : int = 0
var dash_timer1 : float = 0.0
var dash_count2 : int = 0
var dash_timer2 : float = 0.0
# Condition States
var enabled_climbing = true
var is_riding = bool()
var is_falling = bool()
var is_swimming =bool()
var is_rolling = bool()
var is_walking = false
var was_walking = false
var is_running = bool()
var is_sprinting = bool()
var is_aiming = bool()
var is_cursor = false
var is_crouching = bool()
var attacking = bool()
var is_sliding = false
var is_guarding = false
var is_climbing = false
var mousemode = bool()
var staggered = false
var blocking = false
var backstep = bool()
var frontstep = bool()
var leftstep = bool()
var rightstep =bool()
var stunned = false
var injured = false
# Physics values
var direction = Vector3()
var horizontal_velocity = Vector3()
var aim_turn = float()
var movement = Vector3()
var vertical_velocity = Vector3()
var movement_speed = int()
var angular_acceleration = int()
var acceleration = int()
#preloads and loads for UI
#onready var tool_tip = load("res://player/UI/HoverText/Test.tscn")
#other UI stuff
#onready var all_ui = $AllUIHere
#onready var warden_skill_ui = $AllUIHere/Skills/WardenSkills
#onready var debugger = $AllUIHere/Debugger
#Save data
const SAVE_DIR = "user://saves/"
var save_path = SAVE_DIR + "save.dat"
#_________________________________________States and Attributes_____________________________________
var level = 0
var entity_name = "Cei"
#crude stats
var health = 100
const base_health = 100
var max_health = 100
const base_max_health = 100
var energy = 100
var max_energy = 100
const base_max_energy = 100
var resolve = 100
var max_resolve = 100
const base_max_resolve = 100
const base_weight = 60
var weight = 60
const base_walk_speed = 6
var walk_speed =6
const base_run_speed = 8
var run_speed = 15
const base_crouch_speed = 2
var crouch_speed = 2
const base_jumping_power = 20
var jumping_power = 20
const base_dash_power = 20
var dash_power = 20
var attribute = 1000
var skill_points = 1000
var defense = 10
var coordination = 1
var creativity = 1
var wisdom = 1
var memory = 1
var intelligence = 1
var willpower = 1
var power = 1
var strength = 1.5
var impact = 1
var resistance = 1
var tenacity = 1
var accuracy = 1
var dexterity = 1
var balance = 1
var focus = 1
var acrobatics = 1
var agility = 1
var athletics = 1
var flexibility = 1
var placeholder_ = 1
var endurance = 1
var stamina = 1
var vitality = 1
var vigor = 1
var recovery = 1
var charisma = 1
var loyalty = 1
var diplomacy = 1
var leadership = 1
var empathy = 1
#Leveling compounding attributes
var spent_attribute_points_cre = 0
var spent_attribute_points_wis = 0
var spent_attribute_points_mem = 0
var spent_attribute_points_int = 0
var spent_attribute_points_wil = 0
var spent_attribute_points_pow = 0
var spent_attribute_points_str = 0
var spent_attribute_points_imp = 0
var spent_attribute_points_res = 0
var spent_attribute_points_ten = 0
var spent_attribute_points_acc = 0
var spent_attribute_points_dex = 0
var spent_attribute_points_bal = 0
var spent_attribute_points_foc = 0
var spent_attribute_points_acr = 0
var spent_attribute_points_agi = 0
var spent_attribute_points_ath = 0
var spent_attribute_points_fle = 0
#var placeholder_
var spent_attribute_points_end = 0
var spent_attribute_points_sta = 0
var spent_attribute_points_vit = 0
var spent_attribute_points_vig = 0
var spent_attribute_points_rec = 0
var spent_attribute_points_cha = 0
var spent_attribute_points_loy = 0
var spent_attribute_points_dip = 0
var spent_attribute_points_lea = 0
var spent_attribute_points_emp = 0
#_______stored______
var st_charisma = charisma
var st_loyalty = loyalty
var st_diplomacy = diplomacy
var st_leadership = leadership
var st_empathy = empathy
var st_accuracy = accuracy
var st_dexterity = dexterity
var st_coordination = coordination
var st_balance = balance
var st_focus = focus
var st_endurance = endurance
var st_stamina = stamina
var st_vitality = vitality
var st_vigor = vigor
var st_recovery = recovery
var st_acrobatics = acrobatics
var st_agility = agility
var st_athletics = athletics
var st_flexibility = flexibility
var st_placeholder = placeholder_
var st_power = power
var st_strength = strength
var st_impact = impact
var st_resistance = resistance
var st_tenacity = tenacity
var st_creativity = creativity
var st_wisdom = wisdom
var st_memory = memory
var st_intelligence = intelligence
var st_willpower = willpower
#___________________________________Class Specific____________________________________________
#set1
var has_headstrong_rush_skill = false
#invested points
var headstrong_rush_ps = 0
var pomel_strike_ps = 0
var cross_parry_ps = 0
var measured_slice_ps = 0
var blood_rush_ps = 0
#headstrong rush skill
#onready var HeadstrongrushCD = $AllUIHere/Skills/WardenSkills/Set1/HeadstrongRush/HeadstrongrushCD
var headstrong_duration = 5
var headstrong_rush_toggle = false
#set3
var has_pomel_strike_skill = true
var has_entagle_skill = false
var has_disarm_skill = false
var has_expose_skill = false
var has_cripple_skill = false
#set4
var has_wallop_skill = false
var has_rising_strike_skill = false
var has_schadenfreude_skill = false
var has_eviscerate_skill = false
var has_punishing_blow_skill = false
#set5
var has_shield_bash_counter_skill = false
var has_lunge_skill = false
var has_provocation_skill = false
var has_shield_barrage_skill = false #move and attack while covered behind the shield at the same time
var has_shield_counter_skill= false #after blocking a hit, bash enemy with the shield and trust
func _ready():
#instanceui()
set_process_input(true)
direction = Vector3.BACK.rotated(Vector3.UP, camera_h.global_transform.basis.get_euler().y)
loadPlayerData()
# Load the tooltip scene
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event):
if event is InputEventKey:
if event.scancode == KEY_P: # Replace with the desired key code
resetSavedData()
if event is InputEventMouseMotion:
camrot_h += -event.relative.x * h_sensitivity
camrot_v += event.relative.y * v_sensitivity
if minimap_rotate:
minimap_camera.rotate_y(deg2rad(-event.relative.x * mouse_sense))
#Scrollwheel zoom in and out
if event is InputEventMouseButton and event.button_index == BUTTON_WHEEL_UP:
# Zoom in when scrolling up
Zoom(-1)
elif event is InputEventMouseButton and event.button_index == BUTTON_WHEEL_DOWN:
# Zoom out when scrolling down
Zoom(1)
func _physics_process(delta):
if not stunned:
jump()
dodgeBack(delta)
dodgeFront(delta)
dodgeLeft(delta)
dodgeRight(delta)
move()
movementStates()
climbing()
teleport()
minimapFollow()
MainWeapon()
SecWeapon()
ShieldManagement()
if Input.is_action_just_pressed("ui_focus_next"):
is_in_combat = !is_in_combat
if Input.is_action_just_pressed("1"):
barehanded_mode = false
#duel_wield_mode = true
sword_and_shield_mode = true
mouseMode()
stiffCamera(delta)
ridingCollision()
Gravity(delta)
interpol(delta)
gliding()
# debug()
animationsAll(delta)
cameraRotation(delta)
unstuckDisplayCD()
unstuckVisibility()
unstuckDisplayCD()
#__________________________________________Movement_________________________________
var run_toggle = false
var crouch_toggle = false
var sprint_toggle = false
func move():
var h_rot = camera_h.global_transform.basis.get_euler().y
movement_speed = 0
angular_acceleration = 3.25
acceleration = 15
movement.z = horizontal_velocity.z + vertical_velocity.z
movement.x = horizontal_velocity.x + vertical_velocity.x
movement.y = vertical_velocity.y
move_and_slide(movement, Vector3.UP)
if not is_climbing:
if Input.is_action_pressed("forward") or Input.is_action_pressed("backward") or Input.is_action_pressed("left") or Input.is_action_pressed("right"):
direction = Vector3(Input.get_action_strength("left") - Input.get_action_strength("right"),
0,
Input.get_action_strength("forward") - Input.get_action_strength("backward"))
direction = direction.rotated(Vector3.UP, h_rot).normalized()
is_walking = true
else:
is_walking = false
func movementStates():
if is_walking:
# Movement States
if Input.is_action_pressed("run") and is_walking and not is_climbing and not blocking and not is_swimming and not is_aiming:
movement_speed = run_speed
is_in_combat = false
is_running = true
enabled_climbing = false
is_crouching = false
is_aiming = false
elif Input.is_action_pressed("C") and is_walking and !is_climbing and !is_swimming:
movement_speed = crouch_speed
is_running = false
enabled_climbing = false
is_crouching = true
is_aiming = false
is_in_combat = false
elif Input.is_action_pressed("sprint") and is_walking and not is_climbing and not blocking and not is_swimming and not is_aiming:
movement_speed = sprint_speed
is_sprinting = true
enabled_climbing = false
is_crouching = false
is_aiming = false
is_in_combat = false
else: # Walk State and speed
movement_speed = walk_speed
is_sprinting = false
is_crouching = false
enabled_climbing = true
is_crouching = false
is_running = false
else: # Walk State and speed
is_sprinting = false
is_crouching = false
enabled_climbing = true
is_crouching = false
is_running = false
func dodgeBack(delta):#Doddge when in strafe mode
if dash_countback > 0:
dash_timerback += delta
if dash_timerback >= double_press_time:
dash_countback = 0
dash_timerback = 0.0
if Input.is_action_just_pressed("backward"):
dash_countback += 1
if dash_countback == 2 and dash_timerback < double_press_time:
horizontal_velocity = direction * dash_power
backstep = true
enabled_climbing = false
else:
enabled_climbing = true
backstep = false
func dodgeFront(delta):#Dodge when in strafe mode
if dash_countforward > 0:
dash_timerforward += delta
if dash_timerforward >= double_press_time:
dash_countforward = 0
dash_timerforward = 0.0
if Input.is_action_just_pressed("forward"):
dash_countforward += 1
if dash_countforward == 2 and dash_timerforward < double_press_time:
horizontal_velocity = direction * dash_power *1.5
frontstep = true
enabled_climbing = false
else:
enabled_climbing = true
frontstep = false
func dodgeLeft(delta):#Dodge when in strafe mode
if dash_countleft > 0:
dash_timerleft += delta
if dash_timerleft >= double_press_time:
dash_countleft = 0
dash_timerleft = 0.0
if Input.is_action_just_pressed("left"):
dash_countleft += 1
if dash_countleft == 2 and dash_timerleft < double_press_time:
horizontal_velocity = direction * dash_power
enabled_climbing = false
leftstep = true
else:
enabled_climbing = true
leftstep = false
func dodgeRight(delta):#Dodge when in strafe mode
if dash_countright > 0:
dash_timerright += delta
if dash_timerright >= double_press_time:
dash_countright = 0
dash_timerright = 0.0
if Input.is_action_just_pressed("right"):
dash_countright += 1
if dash_countright == 2 and dash_timerright < double_press_time :
horizontal_velocity = direction * dash_power
enabled_climbing = false
rightstep = true
else:
enabled_climbing = true
rightstep = false
func teleport():
if Input.is_action_just_pressed("X"):
var teleport_vector = direction.normalized() * teleport_distance
var teleport_position = translation + teleport_vector
var collision = move_and_collide(teleport_vector)
if collision:
teleport_position = collision.position
translation = teleport_position
#climbing section
var wall_incline
var is_wall_in_range = false
onready var head_ray =$Mesh/HeadRay
func climbing():
if not is_swimming:
if is_on_wall():
if Input.is_action_pressed("forward"):
checkWallInclination()
vertical_velocity = Vector3.UP * (strength + (agility * 0.15))
#horizontal_velocity = direction * 1
is_climbing = true
is_swimming = false
if not head_ray.is_colliding() and not is_wall_in_range:#vaulting
an.play("TPose",blend, strength)#vaulting animation placeholder
elif not is_wall_in_range:#normal climb
an.play("climb",blend, strength)
else:
an.play("crawl incline", blend, strength)
horizontal_velocity = direction * walk_speed
else:
is_climbing = false
else:
is_climbing = false
func checkWallInclination():
if get_slide_count() > 0:
var collision_info = get_slide_collision(0)
var normal = collision_info.normal
if normal.length_squared() > 0:
wall_incline = acos(normal.y) # Calculate the inclination angle in radians
wall_incline = rad2deg(wall_incline) # Convert inclination angle to degrees
if normal.x < 0:
wall_incline = -wall_incline
# Check if the wall inclination is within the specified range
is_wall_in_range = (wall_incline >= -60 and wall_incline <= 60)
else:
wall_incline = 0 # Set to 0 if the normal is not valid
is_wall_in_range = false
else:
wall_incline = 0 # Set to 0 if there is no collision
is_wall_in_range = false
func jump():
if Input.is_action_pressed("jump") and is_on_floor():
vertical_velocity = Vector3.UP * jumping_power
if Input.is_action_pressed("jump") and is_swimming:
vertical_velocity = Vector3.UP * 5
elif Input.is_action_pressed("C") and is_swimming:
vertical_velocity = Vector3.DOWN * 5
func gliding():
if is_falling:
if Input.is_action_pressed("Z"):
vertical_velocity = direction * 1
horizontal_velocity = direction * 20 * agility
vertical_velocity = Vector3.ZERO # No vertical movement while gliding
movement_speed = walk_speed
an.play("TPose")
is_in_combat = false
func interpol(delta):
horizontal_velocity = horizontal_velocity.linear_interpolate(direction.normalized() * movement_speed, acceleration * delta)
func Gravity(delta):# Gravity and stop sliding on floors
if not is_climbing:
if not is_on_floor() and not is_swimming:
vertical_velocity += Vector3.DOWN * 60 * delta
is_falling = true
else:
vertical_velocity = -get_floor_normal() * gravity / 2.5
is_falling = false
#___________________________________________Camera_______________________________________________
var camrot_h = 0
var camrot_v = 0
onready var parent = $".."
export var cam_v_max = 200 # -75 recommended
export var cam_v_min = -125 # -55 recommended
onready var camera_v =$Camroot/h/v
onready var camera_h =$Camroot/h
onready var camera = $Camroot/h/v/Camera
onready var minimap = $Minimap
onready var minimap_camera = $Minimap/Viewport/Camera
var minimap_rotate = false
var h_sensitivity = 0.1
var v_sensitivity = 0.1
var rot_speed_multiplier = .15 #reduce this to make the rotation radius larger
var h_acceleration = 10
var v_acceleration = 10
var mouse_captured = true
var touch_start_position = Vector2.ZERO
var zoom_speed = 0.1
# Add this function to handle zooming logic
func Zoom(zoom_direction):
# Adjust the camera's position based on the zoom direction
camera.translation.y += zoom_direction * zoom_speed
camera.translation.z -= zoom_direction * zoom_speed
func _on_Sensitivity_pressed():
$Minimap/sensitivity_label.text = "cam sens: " + str(h_sensitivity)
h_sensitivity += 0.025
func _on_SensitivityMin_pressed():
h_sensitivity -= 0.025
$Minimap/sensitivity_label.text = "cam sens: " + str(h_sensitivity)
func cameraRotation(delta):
if not is_cursor:
camrot_v = clamp(camrot_v, cam_v_min, cam_v_max)
#MOUSE CAMERA
camera_h.rotation_degrees.y = lerp(camera_h.rotation_degrees.y, camrot_h, delta * h_acceleration)
camera_v.rotation_degrees.x = lerp(camera_v.rotation_degrees.x, camrot_v, delta * v_acceleration)
func mouseMode():
if Input.is_action_pressed("rclick"):
is_aiming = true
else:
is_aiming = false
if Input.is_action_just_pressed("ui_cancel"): # Toggle mouse mode
is_in_combat = false
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
is_cursor = true
else:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
is_cursor = false
func stiffCamera(delta):
if is_aiming:
player_mesh.rotation.y = lerp_angle(player_mesh.rotation.y, camera_h.rotation.y, delta * angular_acceleration)
else:
player_mesh.rotation.y = lerp_angle(player_mesh.rotation.y, atan2(direction.x, direction.z) - rotation.y, delta * angular_acceleration)
func minimapFollow():# Update the position of the minimap camera
minimap_camera.translation = Vector3(translation.x, 30,translation.z)
#_______________________________________Collisions__________________________________
func ridingCollision():
if has_ride:
# If has_horse is true, change collision layers
set_collision_layer(6) # Set to the desired collision layer
set_collision_mask(6) # Set to the desired collision mask
elif not has_ride:
# If has_horse is false, reset collision layers
set_collision_layer(1) # Set to the original collision layer
set_collision_mask(1) # Set to the original collision mask
#__________________________________Animation Section_____________________________________
func animationsAll(delta):
if is_in_combat:
if barehanded_mode:
animationsBarehanded()
elif one_handed_sword_mode:
animations1HSword()
elif two_handed_sword_mode:
animations2HSword()
elif duel_wield_mode:
animationsDualWield()
elif bow_mode:
animationsBow()
elif sword_and_shield_mode:
animationsSwordAndShield(delta)
else:
if not is_swimming:
if is_aiming:
animationStrafe()
else:
animationOutOfCombat()
if is_swimming:
if is_walking:
an.play("swim",blend)
else:
an.play("swim idle",blend)
if not is_on_floor() and not is_climbing and not is_swimming:
an.play("fall loop",blend)
#____________________________________Sword and Shield Animations_______________________________________
func animationsSwordAndShield(delta):
if Input.is_action_pressed("rclick"): #block
if dash_countforward ==2:
an.play("slide",blend)
elif dash_countleft ==2:
an.play_backwards("dodge right",blend)
elif dash_countright ==2:
an.play("dodge right",blend)
elif dash_countback ==2:
an.play_backwards("backstep",blend)
elif Input.is_action_pressed("attack") and has_pomel_strike_skill:
an.play("pomel strike",blend)#placeholder counter attack
horizontal_velocity = Vector3.ZERO
elif Input.is_action_pressed("forward") and Input.is_action_pressed("left"):
an.play("block shield front left",blend)
elif Input.is_action_pressed("backward") and Input.is_action_pressed("left"):
an.play_backwards("block shield front right",blend)
elif Input.is_action_pressed("backward") and Input.is_action_pressed("right"):
an.play_backwards("block shield front left",blend)
elif Input.is_action_pressed("forward") and Input.is_action_pressed("right"):
an.play("block shield front right", blend)
elif Input.is_action_pressed("backward"):
an.play_backwards("block shield front ",blend)
elif Input.is_action_pressed("left"):
an.play("shield block left",blend)
elif Input.is_action_pressed("right"):
an.play("shield block right ",blend)
elif Input.is_action_pressed("forward"):
an.play("block shield front ",blend)
else:
an.play("block shield",blend/2)
else:
if dash_countback ==2 or dash_countleft ==2 or dash_countright ==2 or dash_countforward ==2:
an.play("slide",blend)
elif Input.is_action_pressed("E"):
an.play("fury strike cycle", blend +0.1)
moveAttack2(delta)
elif Input.is_action_pressed("attack"):
an.play("combo attack sword and shield cycle")
moveAttack(delta)
elif is_sliding and attacking:
an.play("swirl melee attack",blend)
elif is_walking:
an.play("walk combat",blend)
else:
an.play("idle combat",blend)
#_________________________________________One handed Sword animations_____________________________________________
func animations1HSword():
if Input.is_action_pressed("attack"):
an.play("combo attack 1h")
elif is_walking:
if not injured:
an.play("walk")
else:
an.play("walk injured")
elif is_crouching:
if is_running:
an.play("sneak run")
elif is_walking:
an.play("sneak walk")
else:
an.play("sneak")
else:
an.play("idle combat")
#_____________________________________________Two handed Sword_____________________________________
func animations2HSword():
if Input.is_action_pressed("attack"):
an.play("combo attack 2h")
elif is_walking:
if not injured:
an.play("walk")
else:
an.play("walk injured")
elif is_crouching:
if is_running:
an.play("sneak run")
elif is_walking:
an.play("sneak walk")
else:
an.play("sneak")
else:
an.play("idle combat 2h", blend)
#_____________________________________________Dual Wielding______________________________________________
func animationsDualWield():
if Input.is_action_pressed("attack"):
an.play("combo attack 2w", blend)
elif is_walking:
if not injured:
an.play("walk")
else:
an.play("walk injured")
elif is_crouching:
if is_running:
an.play("sneak run")
elif is_walking:
an.play("sneak walk")
else:
an.play("sneak")
else:
an.play("idle dual wield", blend)
#__________________________________________Bow______________________________________
func animationsBow():
if Input.is_action_pressed("attack") and is_walking and not is_aiming:
an.play("shoot forward", blend)
elif Input.is_action_pressed("attack") and is_aiming and Input.is_action_pressed("left"):
an.play("shoot left", blend)
elif Input.is_action_pressed("attack") and is_aiming and Input.is_action_pressed("right"):
an.play("shoot right", blend)
elif Input.is_action_pressed("attack") and is_aiming and Input.is_action_pressed("left"):
an.play("shoot back", blend)
elif Input.is_action_pressed("attack") and is_walking :
an.play("shoot forward", blend)
elif Input.is_action_pressed("attack"):
an.play("shoot arrow", blend)
elif is_walking:
if not injured:
an.play("walk")
else:
an.play("walk injured")
elif is_crouching:
if is_running:
an.play("sneak run")
elif is_walking:
an.play("sneak walk")
else:
an.play("sneak")
else:
an.play("idle combat", blend)
#___________________________________________Empty Handed_____________________________________________
func animationsBarehanded():
if Input.is_action_pressed("attack"):
an.play("kick")
elif is_walking:
if not injured:
an.play("walk")
else:
an.play("walk injured")
elif is_crouching:
if is_running:
an.play("sneak run")
elif is_walking:
an.play("sneak walk")
else:
an.play("sneak")
elif Input.is_action_just_pressed("jump"):
an.play_backwards("terrified")
else:
an.play("idle combat")
#____________________________________________Out of Combat_________________________________
func animationOutOfCombat(): #normal
#dodge section is prioritized
if dash_countback ==2 or dash_countleft ==2 or dash_countright ==2 or dash_countforward ==2 or is_sliding:
an.play("slide",blend)
#out of combat normal movement
elif !is_in_combat and !is_swimming and is_on_floor() and !is_aiming:
if is_sprinting:
an.play("run")
elif is_running:
an.play("run")
elif is_walking and Input.is_action_pressed("C"):
an.play("sneak walk")
elif is_running and Input.is_action_pressed("C"):
an.play("sneak run")
elif is_walking:
an.play("walk")
elif Input.is_action_pressed("C"):
an.play("sneak",blend)
elif Input.is_action_just_pressed("Q"):
an.play_backwards("terrified")
else:
an.play("idle", 0.25)
func animationStrafe(): #strafe
#dodge section is prioritized
if dash_countback ==2:
an.play("backstep",blend)
elif dash_countleft ==2:
an.play("TPose",blend)
elif dash_countright ==2:
an.play("TPose",blend)
elif dash_countforward ==2:
an.play_backwards("backstep",blend)
#strafing walk
elif Input.is_action_pressed("forward") and Input.is_action_pressed("left"):
an.play("left front",blend)
elif Input.is_action_pressed("backward") and Input.is_action_pressed("left"):
an.play_backwards("right front",blend)
elif Input.is_action_pressed("backward") and Input.is_action_pressed("right"):
an.play_backwards("left front",blend)
elif Input.is_action_pressed("forward") and Input.is_action_pressed("right"):
an.play("right front", blend)
elif Input.is_action_pressed("backward"):
an.play_backwards("walk",blend)
elif Input.is_action_pressed("left"):
an.play("left",blend)
elif Input.is_action_pressed("right"):
an.play("right",blend)
elif Input.is_action_pressed("forward"):
an.play("walk")
elif Input.is_action_just_pressed("jump"):
an.play_backwards("landing")
else:
an.play("idle",blend)
#Combat Stufff
func moveAttack(delta):
if can_move:
horizontal_velocity = direction * 40 * delta
else:
horizontal_velocity = direction * 10.35 * delta
func moveAttack2(delta):
if can_move:
horizontal_velocity = direction * 100 * delta
else:
horizontal_velocity = direction * 0.35 * delta
func stop():
can_move = false
func start():
can_move = true
#________________________________________Graphic User Interface____________________________________
onready var debugger = $"../RichTextLabel"
onready var coordinates = $Minimap/Coordinates
func debugText():
debugger.text = "Memory: %.3f MB" % (OS.get_static_memory_usage() / (1024.0 * 1024.0))
func roundPositionCoordinates():
var rounded_position = Vector3(
round(global_transform.origin.x * 10) / 10,
round(global_transform.origin.y * 10) / 10,
round(global_transform.origin.z * 10) / 10
)
# Use %d to format integers without decimals
coordinates.text = "%d, %d, %d" % [rounded_position.x, rounded_position.y, rounded_position.z]
onready var time_label = $Minimap/Time
func displayClock():
# Get the current date and time
var datetime = OS.get_datetime()
# Display hour and minute in the label
time_label.text = "Time: %02d:%02d" % [datetime.hour, datetime.minute]
# Include the cooldown information
#debugger.text += "\nHeadstrong Rush Cooldown: %.1f" % HeadstrongrushCD.time_left
#_________________________________________Warden Skills_____________________________________________
#func _on_WardenSkillsButton_pressed():
# warden_skill_ui.visible = true
#_______________________________________________Save Data__________________________________________
func savePlayerData():
var data = {
"position": translation,
"unstuck_cd" : unstuck_cd,
#camera stuff
"H_rotation": camera_h.rotation_degrees,
"V_rotation": camera_v.rotation_degrees,
"camera_position": camera.translation,
"camera_rotation": camera.rotation_degrees, # Save the camera's rotation
#Attributes
#leveling
"attribute": attribute,
"spent_attribute_points_int": spent_attribute_points_int,
"spent_attribute_points_wis": spent_attribute_points_wis,
"spent_attribute_points_cha": spent_attribute_points_cha,
"spent_attribute_points_vit": spent_attribute_points_vit,
#Brain attributes
"creativity": creativity,
"wisdom" : wisdom,
"memory": memory,
"intelligence": intelligence,
"willpower": willpower,
#Brute attributes
"power": power,
"strength": strength,
"impact": impact,
"resistance": resistance,
"tenacity": tenacity,
#Precision attributes
"accuracy": accuracy,
"dexterity":dexterity,
"coordination": coordination,
"balance": balance,
"focus": focus,
#Nimble attributes
"acrobatics": acrobatics,
"agility": agility,
"athletics": athletics,
"flexibility": flexibility,
"placeholder_": placeholder_,
#Toughness attributes
"endurance": endurance,
"stamina": stamina,
"vitality": vitality,
"vigor": vigor,
"recovery": recovery,
#Social attributes
"charisma":charisma,
"loyalty": loyalty,
"diplomacy": diplomacy,
"leadership": leadership,
"empathy": empathy,
#crude stats
"health": health,
"energy":energy,
"resolve": resolve,
"max_health": max_health,
"max_energy": max_energy,
"max_resolve": max_resolve,
#hair
#"hair0":has_hair0,
#"hair1": has_hair1,
#"hair2": has_hair2,
#"hair3": has_hair3,
#"hair_color": hair_color,
#skin
"skin0": skin0,
"skin1": skin1,
"skin2": skin2,
"skin3": skin3,
#skills
"headstrong_rush_ps": headstrong_rush_ps,
"pomel_strike_ps": pomel_strike_ps,
#inventory
"got_weapon": got_weapon,
"got_sec_weapon": got_sec_weapon,
# "got_shield": got_shield,
"has_sword0": has_sword0,
"has_sword1": has_sword1,
"has_sword2": has_sword2,
"has_sword3": has_sword3,
"has_sec_sword0": has_sec_sword0,
"has_sec_sword1": has_sec_sword1,
"has_sec_sword2": has_sec_sword2,
"has_sec_sword3": has_sec_sword3,
# "has_shield3": has_shield3,
}
var dir = Directory.new()
if !dir.dir_exists(SAVE_DIR):
dir.make_dir_recursive(SAVE_DIR)
var file = File.new()
var error = file.open_encrypted_with_pass(save_path, File.WRITE, "P@paB3ar6969")
if error == OK:
file.store_var(data)
file.close()
func loadPlayerData():
var file = File.new()
if file.file_exists(save_path):
var error = file.open_encrypted_with_pass(save_path, File.READ, "P@paB3ar6969")
if error == OK:
var player_data = file.get_var()
file.close()
if "position" in player_data:
translation = player_data["position"]
if "unstuck_cd" in player_data:
unstuck_cd = player_data["unstuck_cd"]
#attributes
if "attribute" in player_data:
attribute = player_data["attribute"]
if "spent_attribute_points_int" in player_data:
spent_attribute_points_int = player_data["spent_attribute_points_int"]
if "spent_attribute_points_cha" in player_data:
spent_attribute_points_cha = player_data["spent_attribute_points_cha"]
if "spent_attribute_points_wis" in player_data:
spent_attribute_points_wis = player_data["spent_attribute_points_wis"]
if "spent_attribute_points_vit" in player_data:
spent_attribute_points_vit = player_data["spent_attribute_points_vit"]
#Brute attributes
if "power" in player_data:
power = player_data["power"]
if "strength" in player_data:
strength = player_data["strength"]
if "impact" in player_data:
impact = player_data["impact"]
if "resistance" in player_data:
resistance = player_data["resistance"]
if "tenacity" in player_data:
tenacity = player_data["tenacity"]
#Brain attributes
if "creativity" in player_data:
creativity = player_data["creativity"]
if "wisdom" in player_data:
wisdom = player_data["wisdom"]
if "memory" in player_data:
memory = player_data["memory"]
if "intelligence" in player_data:
intelligence = player_data["intelligence"]
if "willpower" in player_data:
willpower = player_data["willpower"]