game: add bleed
This commit is contained in:
@@ -4,6 +4,8 @@ extends Node2D
|
||||
enum WeaponTag {
|
||||
CAN_RETURN,
|
||||
CAN_BLEED,
|
||||
CAN_CHAIN,
|
||||
CAN_FORK,
|
||||
}
|
||||
|
||||
@export var attack_cd: float
|
||||
@@ -12,11 +14,19 @@ enum WeaponTag {
|
||||
@export var attack_duration: float
|
||||
@export var attack_range: float
|
||||
@export var attack_crit_chance: float = 0.05
|
||||
@export var return_chance: float = 0.0
|
||||
@export var bleed_chance: float = 0.0
|
||||
@export var bleed_duration: float = 5.0
|
||||
@export var chain_chance: float = 0.0
|
||||
@export var tags: Array[String] = []
|
||||
@export var modifiers: Array[WeaponModBase] = []
|
||||
|
||||
@onready var active_cd_timer: Timer = $ActiveCDTimer
|
||||
|
||||
var _player: Player
|
||||
|
||||
func _ready() -> void:
|
||||
_player = get_tree().get_first_node_in_group(GlobalConst.GROUP_PLAYER)
|
||||
|
||||
func _on_attack_cd_timer_timeout() -> void:
|
||||
do_attack()
|
||||
@@ -76,3 +86,19 @@ func has_property(key: String) -> bool:
|
||||
if prop.name == key:
|
||||
return true
|
||||
return false
|
||||
|
||||
func did_crit() -> bool:
|
||||
var weapon_crit = get_calculated("attack_crit_chance")
|
||||
var player_crit = _player.player_stats.get_final("crit_chance", _player.modifiers)
|
||||
|
||||
return randf() >= 1 - weapon_crit + player_crit
|
||||
|
||||
func did_bleed() -> bool:
|
||||
return randf() >= 1 - bleed_chance
|
||||
|
||||
func base_damage() -> Array[Variant]:
|
||||
var damage = get_calculated("attack_damage")
|
||||
var is_crit := did_crit()
|
||||
if is_crit:
|
||||
damage *= _player.player_stats.get_final("crit_multiplier", _player.modifiers)
|
||||
return [damage, is_crit]
|
||||
|
Reference in New Issue
Block a user