eating refactor (#3733) + bugfixes

Ok, messed up resolving the merge conflicts (first try), so doing a
fresh pr. This turned out to be a good thing, as after I put the changes
back I tested again, and found 2 bugs (not due to my code)

Firstly, the organ refactor had introduced a bug when taking liver
damage from being drunk. It wasn't getting the liver correctly, leaving
it with null, and was then trying to damage it.

The second was related to the amount you took in when drinking
This commit is contained in:
VampyrBytes
2016-03-05 08:03:39 +00:00
parent ab490f7fd9
commit 1148bde3a6
25 changed files with 381 additions and 440 deletions
+77 -1
View File
@@ -737,4 +737,80 @@ var/list/ventcrawl_machinery = list(/obj/machinery/atmospherics/unary/vent_pump,
return 1
/mob/living/carbon/proc/can_eat(flags = 255)
return 1
return 1
/mob/living/carbon/proc/eat(var/obj/item/weapon/reagent_containers/food/toEat, mob/user)
if(!istype(toEat))
return 0
var/fullness = 0
if(istype(toEat, /obj/item/weapon/reagent_containers/food/snacks))
fullness = nutrition + (reagents.get_reagent_amount("nutriment") * 20) + (reagents.get_reagent_amount("protein") * 25) + (reagents.get_reagent_amount("plantmatter") * 25)
if(user == src)
if(istype(toEat, /obj/item/weapon/reagent_containers/food/drinks))
if(!selfDrink(toEat))
return 0
else
if(!selfFeed(toEat, fullness))
return 0
else
if(!forceFed(toEat, user, fullness))
return 0
consume(toEat)
return 1
/mob/living/carbon/proc/selfFeed(var/obj/item/weapon/reagent_containers/food/toEat, fullness)
if(istype(toEat, /obj/item/weapon/reagent_containers/food/pill))
src << "<span class='notify'>You [toEat.apply_method] [toEat].</span>"
else
if (fullness <= 50)
src << "<span class='warning'>You hungrily chew out a piece of [toEat] and gobble it!</span>"
else if (fullness > 50 && fullness <= 150)
src << "<span class='notice'>You hungrily begin to eat [toEat].</span>"
else if (fullness > 150 && fullness <= 350)
src << "<span class='notice'>You take a bite of [toEat].</span>"
else if (fullness > 350 && fullness <= 550)
src << "<span class='notice'>You unwillingly chew a bit of [toEat].</span>"
else if (fullness > (550 * (1 + overeatduration / 2000))) // The more you eat - the more you can eat
src << "<span class='warning'>You cannot force any more of [toEat] to go down your throat.</span>"
return 0
return 1
/mob/living/carbon/proc/selfDrink(var/obj/item/weapon/reagent_containers/food/drinks/toDrink, mob/user)
return 1
/mob/living/carbon/proc/forceFed(var/obj/item/weapon/reagent_containers/food/toEat, mob/user, fullness)
if (fullness <= (550 * (1 + overeatduration / 1000)))
visible_message("<span class='warning'>[user] attempts to force [src] to [toEat.apply_method] [toEat].</span>")
else
visible_message("<span class='warning'>[user] cannot force anymore of [toEat] down [src]'s throat.</span>")
return 0
if(!do_mob(user, src))
return 0
forceFedAttackLog(toEat, user)
visible_message("<span class='warning'>[user] forces [src] to [toEat.apply_method] [toEat].</span>")
return 1
/mob/living/carbon/proc/forceFedAttackLog(var/obj/item/weapon/reagent_containers/food/toEat, mob/user)
attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been fed [toEat.name] by [user.name] ([user.ckey]) Reagents: [toEat.reagentlist(toEat)]</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Fed [toEat.name] to [name] ([ckey]) Reagents: [toEat.reagentlist(toEat)]</font>")
log_attack("[user.name] ([user.ckey]) fed [name] ([ckey]) with [toEat.name] Reagents: [toEat.reagentlist(toEat)] (INTENT: [uppertext(user.a_intent)])")
if(!iscarbon(user))
LAssailant = null
else
LAssailant = user
/*TO DO - If/when stomach organs are introduced, override this at the human level sending the item to the stomach
so that different stomachs can handle things in different ways VB*/
/mob/living/carbon/proc/consume(var/obj/item/weapon/reagent_containers/food/toEat)
if(!toEat.reagents)
return
if(toEat.consume_sound)
playsound(loc, toEat.consume_sound, rand(10,50), 1)
if(toEat.reagents.total_volume)
toEat.reagents.reaction(src, toEat.apply_type)
spawn(0)
if(toEat.reagents.total_volume > toEat.bitesize)
toEat.reagents.trans_to(src, toEat.bitesize*toEat.transfer_efficiency)
else
toEat.reagents.trans_to(src, toEat.reagents.total_volume*toEat.transfer_efficiency)
@@ -1882,3 +1882,27 @@
/mob/living/carbon/human/can_eat(flags = 255)
return species && (species.dietflags & flags)
/mob/living/carbon/human/selfFeed(var/obj/item/weapon/reagent_containers/food/toEat, fullness)
if(!check_has_mouth())
src << "Where do you intend to put \the [toEat]? You don't have a mouth!"
return 0
return ..()
/mob/living/carbon/human/forceFed(var/obj/item/weapon/reagent_containers/food/toEat, mob/user, fullness)
if(!check_has_mouth())
if(!((istype(toEat, /obj/item/weapon/reagent_containers/food/drinks) && (get_species() == "Machine"))))
user << "Where do you intend to put \the [toEat]? \The [src] doesn't have a mouth!"
return 0
return ..()
/mob/living/carbon/human/selfDrink(var/obj/item/weapon/reagent_containers/food/drinks/toDrink)
if(!check_has_mouth())
if(!get_species() == "Machine")
src << "Where do you intend to put \the [src]? You don't have a mouth!"
return 0
else
src << "<span class='notice'>You pour a bit of liquid from [toDrink] into your connection port.</span>"
else
src << "<span class='notice'>You swallow a gulp of [toDrink].</span>"
return 1
@@ -583,4 +583,10 @@ mob/living/carbon/slime/var/temperature_resistance = T0C+75
/mob/living/carbon/slime/can_use_vents()
if(Victim)
return "You cannot ventcrawl while feeding."
..()
..()
/mob/living/carbon/slime/forceFed(var/obj/item/weapon/reagent_containers/food/toEat, mob/user, fullness)
if(istype(toEat, /obj/item/weapon/reagent_containers/food/drinks))
return 1
user << "This creature does not seem to have a mouth!"
return 0