-
Notifications
You must be signed in to change notification settings - Fork 1
/
Knife_Point.gd
66 lines (41 loc) · 1.29 KB
/
Knife_Point.gd
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
extends Spatial
const DAMAGE = 40
const IDLE_ANIM_NAME = "Knife_idle"
const FIRE_ANIM_NAME = "Knife_fire"
var is_weapon_enabled = false
var player_node = null
var ammo_in_weapon = 1
var spare_ammo = 1
const AMMO_IN_MAG = 1
const CAN_RELOAD = false
const CAN_REFILL = false
const RELOADING_ANIM_NAME = ""
func _ready():
pass
func fire_weapon():
var area = $Area
var bodies = area.get_overlapping_bodies()
for body in bodies:
if body == player_node:
continue
if body.has_method("bullet_hit"):
body.bullet_hit(DAMAGE, area.global_transform)
func equip_weapon():
if player_node.animation_manager.current_state == IDLE_ANIM_NAME:
is_weapon_enabled = true
return true
if player_node.animation_manager.current_state == "Idle_unarmed":
player_node.animation_manager.set_animation("Knife_equip")
return false
func unequip_weapon():
if player_node.animation_manager.current_state == IDLE_ANIM_NAME:
player_node.animation_manager.set_animation("Knife_unequip")
if player_node.animation_manager.current_state == "Idle_unarmed":
is_weapon_enabled = false
return true
return false
func reload_weapon():
return false
func reset_weapon():
ammo_in_weapon = 1
spare_ammo = 1