Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @@ -0,0 +1,34 @@
- 1 +extends Weapon
- 2 +
- 3 +func _ready():
- 4 + fire_rate = 1 #fire rate (pause between shots)
- 5 + clip_size = 6 #clip size
- 6 + reload_rate = 2 #reload time
- 7 + weapon_damage = 50 #base damage of any weapon
- 8 +
- 9 + current_ammo = 5
- 10 + can_fire = true #bool for if weapon can be fired
- 11 + reloading = false #checks if reloading
- 12 +
- 13 +func process():
- 14 + raycast.cast_to = 1000 #doesnt work yet!
- 15 +
- 16 +func fire():
- 17 + print("Fired Gun")
- 18 + can_fire = false
- 19 + current_ammo -= 1 #reduce clip size
- 20 + check_colission()
- 21 + $"/root/Level01/Player/weapon/shotgun/shotgun_shot".play()
- 22 +
- 23 + $"/root/Level01/Player/weapon/shotgun/Sprite".play("shot")
- 24 + yield(get_tree().create_timer(fire_rate), "timeout") #wait till timeout of fire_rate
- 25 + #$shotgun/Sprite.stop() #doesnt work yet
- 26 + can_fire = true #after fire_rate pause, can_fire again
- 27 +
- 28 +func reload():
- 29 + print("Reloading Gun")
- 30 + reloading = true
- 31 + yield(get_tree().create_timer(reload_rate), "timeout")
- 32 + current_ammo = clip_size #fill ammo
- 33 + reloading = false #reloading done
- 34 + print("Reload Complete")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement