## Trigger ambient sounds
scoreboard players add @s vb.timer.ambient_sound 1
execute store result score #VB vb.dummy1 run random value 1..110
execute if score @s vb.timer.ambient_sound matches 80.. if score #VB vb.dummy1 matches 1 run function vb:tick_entity/custom_mob/duck/ambient_sound {pitch:1}

## Bonus quacking if tempted by seeds
scoreboard players set #VB vb.dummy1 0
execute as @a[distance=..40] if items entity @s weapon.* #minecraft:chicken_food store result score #VB vb.dummy1 run random value 1..20
execute if score #VB vb.dummy1 matches 1 if score @s vb.timer.ambient_sound matches 8.. run function vb:tick_entity/custom_mob/duck/ambient_sound {pitch:1.2}
execute if score #VB vb.dummy1 matches 1 if score @s vb.timer.ambient_sound matches 8.. run scoreboard players set @s vb.timer.ambient_sound 0

## Hurt
execute store result score #VB vb.dummy1 run data get entity @s HurtTime
execute if score #VB vb.dummy1 matches 1.. run function vb:tick_entity/custom_mob/duck/hurt