mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
* Butchering component * auto-butchering based on toolspeed * Gives drills their butchering back * redoes toggles
53 lines
2.1 KiB
Plaintext
53 lines
2.1 KiB
Plaintext
/datum/component/butchering
|
|
var/speed = 80 //time in deciseconds taken to butcher something
|
|
var/effectiveness = 100 //percentage effectiveness; numbers above 100 yield extra drops
|
|
var/bonus_modifier = 0 //percentage increase to bonus item chance
|
|
var/butcher_sound = 'sound/weapons/slice.ogg' //sound played when butchering
|
|
var/butchering_enabled = TRUE
|
|
|
|
/datum/component/butchering/Initialize(_speed, _effectiveness, _bonus_modifier, _butcher_sound, disabled)
|
|
if(_speed)
|
|
speed = _speed
|
|
if(_effectiveness)
|
|
effectiveness = _effectiveness
|
|
if(_bonus_modifier)
|
|
bonus_modifier = _bonus_modifier
|
|
if(_butcher_sound)
|
|
butcher_sound = _butcher_sound
|
|
if(disabled)
|
|
butchering_enabled = FALSE
|
|
|
|
/datum/component/butchering/proc/Butcher(mob/living/butcher, mob/living/meat)
|
|
var/turf/T = meat.drop_location()
|
|
var/final_effectiveness = effectiveness - meat.butcher_difficulty
|
|
var/bonus_chance = max(0, (final_effectiveness - 100) + bonus_modifier) //so 125 total effectiveness = 25% extra chance
|
|
for(var/V in meat.butcher_results)
|
|
var/obj/bones = V
|
|
var/amount = meat.butcher_results[bones]
|
|
for(var/_i in 1 to amount)
|
|
if(!prob(final_effectiveness))
|
|
if(butcher)
|
|
to_chat(butcher, "<span class='warning'>You fail to harvest some of the [initial(bones.name)] from [meat].</span>")
|
|
else if(prob(bonus_chance))
|
|
if(butcher)
|
|
to_chat(butcher, "<span class='info'>You harvest some extra [initial(bones.name)] from [meat]!</span>")
|
|
for(var/i in 1 to 2)
|
|
new bones (T)
|
|
else
|
|
new bones (T)
|
|
meat.butcher_results.Remove(bones) //in case you want to, say, have it drop its results on gib
|
|
for(var/V in meat.guaranteed_butcher_results)
|
|
var/obj/sinew = V
|
|
var/amount = meat.guaranteed_butcher_results[sinew]
|
|
for(var/i in 1 to amount)
|
|
new sinew (T)
|
|
meat.guaranteed_butcher_results.Remove(sinew)
|
|
if(butcher)
|
|
meat.visible_message("<span class='notice'>[butcher] butchers [meat].</span>")
|
|
ButcherEffects(meat)
|
|
meat.harvest(butcher)
|
|
meat.gib(FALSE, FALSE, TRUE)
|
|
|
|
/datum/component/butchering/proc/ButcherEffects(mob/living/meat) //extra effects called on butchering, override this via subtypes
|
|
return
|