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
+1 -1
View File
@@ -7,7 +7,7 @@
suit_adjusted = 1
blood_overlay_type = "coat"
body_parts_covered = UPPER_TORSO|LOWER_TORSO|ARMS
allowed = list(/obj/item/device/analyzer,/obj/item/device/antibody_scanner,/obj/item/stack/medical,/obj/item/weapon/dnainjector,/obj/item/weapon/reagent_containers/dropper,/obj/item/weapon/reagent_containers/syringe,/obj/item/weapon/reagent_containers/hypospray,/obj/item/device/healthanalyzer,/obj/item/device/flashlight/pen,/obj/item/weapon/reagent_containers/glass/bottle,/obj/item/weapon/reagent_containers/glass/beaker,/obj/item/weapon/reagent_containers/pill,/obj/item/weapon/storage/pill_bottle,/obj/item/weapon/paper,/obj/item/device/rad_laser)
allowed = list(/obj/item/device/analyzer,/obj/item/device/antibody_scanner,/obj/item/stack/medical,/obj/item/weapon/dnainjector,/obj/item/weapon/reagent_containers/dropper,/obj/item/weapon/reagent_containers/syringe,/obj/item/weapon/reagent_containers/hypospray,/obj/item/device/healthanalyzer,/obj/item/device/flashlight/pen,/obj/item/weapon/reagent_containers/glass/bottle,/obj/item/weapon/reagent_containers/glass/beaker,/obj/item/weapon/reagent_containers/food/pill,/obj/item/weapon/storage/pill_bottle,/obj/item/weapon/paper,/obj/item/device/rad_laser)
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 50, rad = 0)
species_fit = list("Vox")
sprite_sheets = list(
+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
+3 -3
View File
@@ -583,7 +583,7 @@
return
name = reject_bad_text(name)
while (count--)
var/obj/item/weapon/reagent_containers/pill/P = new/obj/item/weapon/reagent_containers/pill(src.loc)
var/obj/item/weapon/reagent_containers/food/pill/P = new/obj/item/weapon/reagent_containers/food/pill(src.loc)
if(!name) name = reagents.get_master_reagent_name()
P.name = "[name] pill"
P.pixel_x = rand(-7, 7) //random position
@@ -623,7 +623,7 @@
return
name = reject_bad_text(name)
while (count--)
var/obj/item/weapon/reagent_containers/pill/patch/P = new/obj/item/weapon/reagent_containers/pill/patch(src.loc)
var/obj/item/weapon/reagent_containers/food/pill/patch/P = new/obj/item/weapon/reagent_containers/food/pill/patch(src.loc)
if(!name) name = reagents.get_master_reagent_name()
P.name = "[name] patch"
P.pixel_x = rand(-7, 7) //random position
@@ -828,7 +828,7 @@
//All types that you can put into the grinder to transfer the reagents to the beaker. !Put all recipes above this.!
/obj/item/weapon/reagent_containers/pill = list(),
/obj/item/weapon/reagent_containers/food/pill = list(),
/obj/item/weapon/reagent_containers/food = list()
)
+7 -7
View File
@@ -1,4 +1,4 @@
/obj/item/weapon/reagent_containers/pill/patch
/obj/item/weapon/reagent_containers/food/pill/patch
name = "chemical patch"
desc = "A chemical patch for touch based applications."
icon = 'icons/obj/chemical.dmi'
@@ -10,35 +10,35 @@
apply_method = "apply"
transfer_efficiency = 0.5 //patches aren't as effective at getting chemicals into the bloodstream.
/obj/item/weapon/reagent_containers/pill/patch/New()
/obj/item/weapon/reagent_containers/food/pill/patch/New()
..()
icon_state = "bandaid"
/obj/item/weapon/reagent_containers/pill/patch/afterattack(obj/target, mob/user , proximity)
/obj/item/weapon/reagent_containers/food/pill/patch/afterattack(obj/target, mob/user , proximity)
return // thanks inheritance again
/obj/item/weapon/reagent_containers/pill/patch/styptic
/obj/item/weapon/reagent_containers/food/pill/patch/styptic
name = "healing patch"
desc = "Helps with brute injuries."
New()
..()
reagents.add_reagent("styptic_powder", 40)
/obj/item/weapon/reagent_containers/pill/patch/silver_sulf
/obj/item/weapon/reagent_containers/food/pill/patch/silver_sulf
name = "burn patch"
desc = "Helps with burn injuries."
New()
..()
reagents.add_reagent("silver_sulfadiazine", 40)
/obj/item/weapon/reagent_containers/pill/patch/synthflesh
/obj/item/weapon/reagent_containers/food/pill/patch/synthflesh
name = "syntheflesh patch"
desc = "Helps with burn injuries."
New()
..()
reagents.add_reagent("synthflesh", 20)
/obj/item/weapon/reagent_containers/pill/patch/nicotine
/obj/item/weapon/reagent_containers/food/pill/patch/nicotine
name = "nicotine patch"
desc = "Helps temporarily curb the cravings of nicotine dependency."
New()
@@ -65,7 +65,7 @@
if(ishuman(M))
var/mob/living/carbon/human/H = M
if (H.get_int_organ(/obj/item/organ/internal/liver))
var/obj/item/organ/internal/liver/L = /obj/item/organ/internal/liver
var/obj/item/organ/internal/liver/L = H.get_int_organ(/obj/item/organ/internal/liver)
L.take_damage(0.1, 1)
H.adjustToxLoss(0.1)
..()
@@ -5,6 +5,11 @@
possible_transfer_amounts = null
volume = 50 //Sets the default container amount for all food items.
var/filling_color = "#FFFFFF" //Used by sandwiches.
var/bitesize = 1
var/consume_sound = 'sound/items/eatfood.ogg'
var/apply_type = INGEST
var/apply_method = "swallow"
var/transfer_efficiency = 1.0
/obj/item/weapon/reagent_containers/food/New()
..()
@@ -7,164 +7,116 @@
icon = 'icons/obj/drinks.dmi'
icon_state = null
flags = OPENCONTAINER
var/gulp_size = 5 //This is now officially broken ... need to think of a nice way to fix it.
consume_sound = 'sound/items/drink.ogg'
possible_transfer_amounts = list(5,10,25)
volume = 50
on_reagent_change()
if (gulp_size < 5) gulp_size = 5
else gulp_size = max(round(reagents.total_volume / 5), 5)
/obj/item/weapon/reagent_containers/food/drinks/New()
..()
bitesize = amount_per_transfer_from_this
if(bitesize < 5)
bitesize = 5
attack_self(mob/user as mob)
return
/obj/item/weapon/reagent_containers/food/drinks/attack_self(mob/user as mob)
return
attack(mob/M as mob, mob/user as mob, def_zone)
var/datum/reagents/R = src.reagents
var/fillevel = gulp_size
if(!R.total_volume || !R)
user << "<span class='warning'> None of [src] left, oh no!</span>"
return 0
if(M == user)
if(istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(!H.check_has_mouth())
if(!H.get_species() == "Machine")
user << "Where do you intend to put \the [src]? You don't have a mouth!"
return
else
M << "<span class='notice'> You pour a bit of liquid from [src] into your connection port.</span>"
else
M << "<span class='notice'> You swallow a gulp of [src].</span>"
if(reagents.total_volume)
reagents.reaction(M, INGEST)
spawn(0)
reagents.trans_to(M, gulp_size)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
return 1
else if( istype(M, /mob/living/carbon/human) )
var/mob/living/carbon/human/H = M
if(!H.check_has_mouth() && !H.get_species() == "Machine")
user << "Where do you intend to put \the [src]? \The [H] doesn't have a mouth!"
return
for(var/mob/O in viewers(world.view, user))
O.show_message("<span class='warning'> [user] attempts to feed [M] [src].</span>", 1)
if(!do_mob(user, M)) return
for(var/mob/O in viewers(world.view, user))
O.show_message("<span class='warning'> [user] feeds [M] [src].</span>", 1)
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been fed [src.name] by [key_name(user)] Reagents: [reagentlist(src)]</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Fed [M.name] by [key_name(M)] Reagents: [reagentlist(src)]</font>")
log_attack("[key_name_admin(user)] fed [key_name_admin(M)] with [src.name] Reagents: [reagentlist(src)] (INTENT: [uppertext(user.a_intent)])")
if(!iscarbon(user))
M.LAssailant = null
else
M.LAssailant = user
if(reagents.total_volume)
reagents.reaction(M, INGEST)
spawn(0)
reagents.trans_to(M, gulp_size)
/obj/item/weapon/reagent_containers/food/drinks/attack(mob/M as mob, mob/user as mob, def_zone)
if(!reagents || !reagents.total_volume)
user << "<span class='warning'> None of [src] left, oh no!</span>"
return 0
if(istype(M, /mob/living/carbon))
var/mob/living/carbon/C = M
if(C.eat(src, user))
if(isrobot(user)) //Cyborg modules that include drinks automatically refill themselves, but drain the borg's cell
var/mob/living/silicon/robot/borg = user
borg.cell.use(30)
var/refill = R.get_master_reagent_id()
var/refill = reagents.get_master_reagent_id()
if(refill in drinks) // Only synthesize drinks
spawn(600)
R.add_reagent(refill, fillevel)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
reagents.add_reagent(refill, bitesize)
return 1
return 0
return 0
/obj/item/weapon/reagent_containers/food/drinks/afterattack(obj/target, mob/user, proximity)
if(!proximity) return
// Moved from the can code; not necessary since closed cans aren't open containers now, but, eh.
if (istype(target, /obj/item/weapon/reagent_containers/food/drinks/cans))
var/obj/item/weapon/reagent_containers/food/drinks/cans/cantarget = target
if(cantarget.canopened == 0)
user << "<span class='notice'>You need to open the drink you want to pour into!</span>"
return
afterattack(obj/target, mob/user, proximity)
if(!proximity) return
if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us.
// Moved from the can code; not necessary since closed cans aren't open containers now, but, eh.
if (istype(target, /obj/item/weapon/reagent_containers/food/drinks/cans))
var/obj/item/weapon/reagent_containers/food/drinks/cans/cantarget = target
if(cantarget.canopened == 0)
user << "<span class='notice'>You need to open the drink you want to pour into!</span>"
return
if(!target.reagents.total_volume)
user << "<span class='warning'> [target] is empty.</span>"
return
if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us.
if(reagents.total_volume >= reagents.maximum_volume)
user << "<span class='warning'> [src] is full.</span>"
return
if(!target.reagents.total_volume)
user << "<span class='warning'> [target] is empty.</span>"
return
var/trans = target.reagents.trans_to(src, target:amount_per_transfer_from_this)
user << "<span class='notice'> You fill [src] with [trans] units of the contents of [target].</span>"
if(reagents.total_volume >= reagents.maximum_volume)
user << "<span class='warning'> [src] is full.</span>"
return
else if(target.is_open_container()) //Something like a glass. Player probably wants to transfer TO it.
if(!reagents.total_volume)
user << "<span class='warning'> [src] is empty.</span>"
return
var/trans = target.reagents.trans_to(src, target:amount_per_transfer_from_this)
user << "<span class='notice'> You fill [src] with [trans] units of the contents of [target].</span>"
else if(target.is_open_container()) //Something like a glass. Player probably wants to transfer TO it.
if(!reagents.total_volume)
user << "<span class='warning'> [src] is empty.</span>"
return
if(target.reagents.total_volume >= target.reagents.maximum_volume)
user << "<span class='warning'> [target] is full.</span>"
return
if(target.reagents.total_volume >= target.reagents.maximum_volume)
user << "<span class='warning'> [target] is full.</span>"
return
var/datum/reagent/refill
var/datum/reagent/refillName
if(isrobot(user))
refill = reagents.get_master_reagent_id()
refillName = reagents.get_master_reagent_name()
var/datum/reagent/refill
var/datum/reagent/refillName
if(isrobot(user))
refill = reagents.get_master_reagent_id()
refillName = reagents.get_master_reagent_name()
var/trans = src.reagents.trans_to(target, amount_per_transfer_from_this)
user << "<span class='notice'> You transfer [trans] units of the solution to [target].</span>"
var/trans = src.reagents.trans_to(target, amount_per_transfer_from_this)
user << "<span class='notice'> You transfer [trans] units of the solution to [target].</span>"
if(isrobot(user)) //Cyborg modules that include drinks automatically refill themselves, but drain the borg's cell
if(refill in drinks) // Only synthesize drinks
var/mob/living/silicon/robot/bro = user
var/chargeAmount = max(30,4*trans)
bro.cell.use(chargeAmount)
user << "Now synthesizing [trans] units of [refillName]..."
if(isrobot(user)) //Cyborg modules that include drinks automatically refill themselves, but drain the borg's cell
if(refill in drinks) // Only synthesize drinks
var/mob/living/silicon/robot/bro = user
var/chargeAmount = max(30,4*trans)
bro.cell.use(chargeAmount)
user << "Now synthesizing [trans] units of [refillName]..."
spawn(300)
reagents.add_reagent(refill, trans)
user << "Cyborg [src] refilled."
spawn(300)
reagents.add_reagent(refill, trans)
user << "Cyborg [src] refilled."
return
/obj/item/weapon/reagent_containers/food/drinks/attackby(var/obj/item/I, mob/user as mob, params)
if(istype(I, /obj/item/clothing/mask/cigarette)) //ciggies are weird
return
if(is_hot(I))
if(src.reagents)
src.reagents.chem_temp += 15
user << "<span class='notice'>You heat [src] with [I].</span>"
src.reagents.handle_reactions()
attackby(var/obj/item/I, mob/user as mob, params)
if(istype(I, /obj/item/clothing/mask/cigarette)) //ciggies are weird
return
if(is_hot(I))
if(src.reagents)
src.reagents.chem_temp += 15
user << "<span class='notice'>You heat [src] with [I].</span>"
src.reagents.handle_reactions()
examine(mob/user)
if(!..(user, 1))
return
if(!reagents || reagents.total_volume==0)
user << "<span class='notice'> \The [src] is empty!</span>"
else if (reagents.total_volume<=src.volume/4)
user << "<span class='notice'> \The [src] is almost empty!</span>"
else if (reagents.total_volume<=src.volume*0.66)
user << "<span class='notice'> \The [src] is half full!</span>" // We're all optimistic, right?!
else if (reagents.total_volume<=src.volume*0.90)
user << "<span class='notice'> \The [src] is almost full!</span>"
else
user << "<span class='notice'> \The [src] is full!</span>"
/obj/item/weapon/reagent_containers/food/drinks/examine(mob/user)
if(!..(user, 1))
return
if(!reagents || reagents.total_volume==0)
user << "<span class='notice'> \The [src] is empty!</span>"
else if (reagents.total_volume<=src.volume/4)
user << "<span class='notice'> \The [src] is almost empty!</span>"
else if (reagents.total_volume<=src.volume*0.66)
user << "<span class='notice'> \The [src] is half full!</span>" // We're all optimistic, right?!
else if (reagents.total_volume<=src.volume*0.90)
user << "<span class='notice'> \The [src] is almost full!</span>"
else
user << "<span class='notice'> \The [src] is full!</span>"
////////////////////////////////////////////////////////////////////////////////
/// Drinks. END
@@ -4,7 +4,7 @@
desc = "yummy"
icon = 'icons/obj/food/food.dmi'
icon_state = null
var/bitesize = 1
bitesize = 1
var/bitecount = 0
var/trash = null
var/slice_path
@@ -18,19 +18,20 @@
//Placeholder for effect that trigger on eating that aren't tied to reagents.
/obj/item/weapon/reagent_containers/food/snacks/proc/On_Consume(var/mob/M)
if(!usr) return
if(!reagents.total_volume)
if(M == usr)
usr << "<span class='notice'>You finish eating \the [src].</span>"
usr.visible_message("<span class='notice'>[usr] finishes eating \the [src].</span>")
usr.unEquip(src) //so icons update :[
spawn(0)
if(!reagents.total_volume)
if(M == usr)
usr << "<span class='notice'>You finish eating \the [src].</span>"
usr.visible_message("<span class='notice'>[usr] finishes eating \the [src].</span>")
usr.unEquip(src) //so icons update :[
if(trash)
if(ispath(trash,/obj/item))
var/obj/item/TrashItem = new trash(usr)
usr.put_in_hands(TrashItem)
else if(istype(trash,/obj/item))
usr.put_in_hands(trash)
qdel(src)
if(trash)
if(ispath(trash,/obj/item))
var/obj/item/TrashItem = new trash(usr)
usr.put_in_hands(TrashItem)
else if(istype(trash,/obj/item))
usr.put_in_hands(trash)
qdel(src)
return
/obj/item/weapon/reagent_containers/food/snacks/attack_self(mob/user as mob)
@@ -38,83 +39,17 @@
/obj/item/weapon/reagent_containers/food/snacks/attack(mob/M as mob, mob/user as mob, def_zone)
if(reagents && !reagents.total_volume) //Shouldn't be needed but it checks to see if it has anything left in it.
user << "\red None of [src] left, oh no!"
user << "<span class='warning'>None of [src] left, oh no!</span>"
M.unEquip(src) //so icons update :[
qdel(src)
return 0
if(istype(M, /mob/living/carbon))
var/fullness = M.nutrition + (M.reagents.get_reagent_amount("nutriment") * 20) + (M.reagents.get_reagent_amount("protein") * 25) + (M.reagents.get_reagent_amount("plantmatter") * 25)
if(M == user) //If you're eating it yourself
if(istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(!H.check_has_mouth())
user << "Where do you intend to put \the [src]? You don't have a mouth!"
return
if (fullness <= 50)
M << "\red You hungrily chew out a piece of [src] and gobble it!"
if (fullness > 50 && fullness <= 150)
M << "\blue You hungrily begin to eat [src]."
if (fullness > 150 && fullness <= 350)
M << "\blue You take a bite of [src]."
if (fullness > 350 && fullness <= 550)
M << "\blue You unwillingly chew a bit of [src]."
if (fullness > (550 * (1 + M.overeatduration / 2000))) // The more you eat - the more you can eat
M << "\red You cannot force any more of [src] to go down your throat."
return 0
else
if(istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(!H.check_has_mouth())
user << "Where do you intend to put \the [src]? \The [H] doesn't have a mouth!"
return
if(!istype(M, /mob/living/carbon/slime)) //If you're feeding it to someone else.
if (fullness <= (550 * (1 + M.overeatduration / 1000)))
for(var/mob/O in viewers(world.view, user))
O.show_message("\red [user] attempts to feed [M] [src].", 1)
else
for(var/mob/O in viewers(world.view, user))
O.show_message("\red [user] cannot force anymore of [src] down [M]'s throat.", 1)
return 0
if(!do_mob(user, M)) return
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been fed [src.name] by [user.name] ([user.ckey]) Reagents: [reagentlist(src)]</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Fed [src.name] by [M.name] ([M.ckey]) Reagents: [reagentlist(src)]</font>")
log_attack("[user.name] ([user.ckey]) fed [M.name] ([M.ckey]) with [src.name] Reagents: [reagentlist(src)] (INTENT: [uppertext(user.a_intent)])")
if(!iscarbon(user))
M.LAssailant = null
else
M.LAssailant = user
for(var/mob/O in viewers(world.view, user))
O.show_message("\red [user] feeds [M] [src].", 1)
else
user << "This creature does not seem to have a mouth!"
return
if(reagents) //Handle ingestion of the reagent.
playsound(M.loc,'sound/items/eatfood.ogg', rand(10,50), 1)
if(reagents.total_volume)
reagents.reaction(M, INGEST)
spawn(0)
if(reagents.total_volume > bitesize)
/*
* I totally cannot understand what this code supposed to do.
* Right now every snack consumes in 2 bites, my popcorn does not work right, so I simplify it. -- rastaf0
var/temp_bitesize = max(reagents.total_volume /2, bitesize)
reagents.trans_to(M, temp_bitesize)
*/
reagents.trans_to(M, bitesize)
else
reagents.trans_to(M, reagents.total_volume)
bitecount++
On_Consume(M)
var/mob/living/carbon/C = M
if(C.eat(src, user))
bitecount++
On_Consume(C)
return 1
return 0
/obj/item/weapon/reagent_containers/food/snacks/afterattack(obj/target, mob/user, proximity)
@@ -145,30 +80,30 @@
var/obj/item/weapon/kitchen/utensil/U = W
if(!U.reagents)
U.create_reagents(5)
if (U.reagents.total_volume > 0)
user << "\red You already have something on your [U]."
if(U.contents.len >= U.max_contents)
user << "<span class='warning'>You cannot fit anything else on your [U]."
return
user.visible_message( \
"[user] scoops up some [src] with \the [U]!", \
"\blue You scoop up some [src] with \the [U]!" \
"<span class='notice'>You scoop up some [src] with \the [U]!" \
)
src.bitecount++
U.overlays.Cut()
U.loaded = "[src]"
var/image/I = new(U.icon, "loadedfood")
I.color = src.filling_color
U.overlays += I
reagents.trans_to(U,min(reagents.total_volume,5))
if (reagents.total_volume <= 0)
var/obj/item/weapon/reagent_containers/food/snacks/collected = new type
collected.loc = U
collected.reagents.remove_any(collected.reagents.total_volume)
if(reagents.total_volume > bitesize)
reagents.trans_to(collected, bitesize)
else
reagents.trans_to(collected, reagents.total_volume)
qdel(src)
return
return 1
if((slices_num <= 0 || !slices_num) || !slice_path)
return 0
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
/// Pills.
////////////////////////////////////////////////////////////////////////////////
/obj/item/weapon/reagent_containers/pill
/obj/item/weapon/reagent_containers/food/pill
name = "pill"
desc = "a pill."
icon = 'icons/obj/chemical.dmi'
@@ -9,107 +9,59 @@
item_state = "pill"
possible_transfer_amounts = null
volume = 50
var/apply_type = INGEST
var/apply_method = "swallow"
var/transfer_efficiency = 1.0
consume_sound = null
New()
..()
if(!icon_state)
icon_state = "pill[rand(1,20)]"
attack_self(mob/user as mob)
/obj/item/weapon/reagent_containers/food/pill/attack_self(mob/user as mob)
return
attack(mob/M as mob, mob/user as mob, def_zone)
if(M == user)
if(istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(!H.check_has_mouth())
user << "Where do you intend to put \the [src]? You don't have a mouth!"
return
M << "<span class='notify'>You [apply_method] [src].</span>"
M.unEquip(src) //icon update
if(reagents.total_volume)
reagents.reaction(M, apply_type)
spawn(0)
reagents.trans_to(M, reagents.total_volume*transfer_efficiency)
qdel(src)
else
qdel(src)
return 1
else if(istype(M, /mob/living/carbon/human) )
var/mob/living/carbon/human/H = M
if(!H.check_has_mouth())
user << "Where do you intend to put \the [src]? \The [H] doesn't have a mouth!"
return
for(var/mob/O in viewers(world.view, user))
O.show_message("<span class='warning'>[user] attempts to force [M] to [apply_method] [src].</span>", 1)
if(!do_mob(user, M)) return
user.unEquip(src) //icon update
for(var/mob/O in viewers(world.view, user))
O.show_message("<span class='warning'>[user] forces [M] to [apply_method] [src].</span>", 1)
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been fed [src.name] by [key_name(user)] Reagents: [reagentlist(src)]</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Fed [src.name] to [key_name(M)]) Reagents: [reagentlist(src)]</font>")
if(M.ckey)
msg_admin_attack("[key_name_admin(user)] fed [key_name_admin(M)] with [src.name] Reagents: [reagentlist(src)] (INTENT: [uppertext(user.a_intent)])")
if(!iscarbon(user))
M.LAssailant = null
else
M.LAssailant = user
if(reagents.total_volume)
reagents.reaction(M, apply_type)
spawn(0)
reagents.trans_to(M, reagents.total_volume*transfer_efficiency)
qdel(src)
else
qdel(src)
return 1
/obj/item/weapon/reagent_containers/food/pill/attack(var/mob/living/carbon/M, mob/user as mob, def_zone)
if(!istype(M))
return 0
bitesize = reagents.total_volume
if(M.eat(src, user))
spawn(0)
qdel(src)
return 1
return 0
afterattack(obj/target, mob/user, proximity)
if(!proximity) return
/obj/item/weapon/reagent_containers/food/pill/afterattack(obj/target, mob/user, proximity)
if(!proximity) return
if(target.is_open_container() != 0 && target.reagents)
if(!target.reagents.total_volume)
user << "<span class='warning'>[target] is empty. Cant dissolve [src].</span>"
return
if(target.is_open_container() != 0 && target.reagents)
if(!target.reagents.total_volume)
user << "<span class='warning'>[target] is empty. Cant dissolve [src].</span>"
return
// /vg/: Logging transfers of bad things
if(target.reagents_to_log.len)
var/list/badshit=list()
for(var/bad_reagent in target.reagents_to_log)
if(reagents.has_reagent(bad_reagent))
badshit += reagents_to_log[bad_reagent]
if(badshit.len)
var/hl="\red <b>([english_list(badshit)])</b> \black"
message_admins("[user.name] ([user.ckey]) added [reagents.get_reagent_ids(1)] to \a [target] with [src].[hl] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
log_game("[user.name] ([user.ckey]) added [reagents.get_reagent_ids(1)] to \a [target] with [src].")
// /vg/: Logging transfers of bad things
if(target.reagents_to_log.len)
var/list/badshit=list()
for(var/bad_reagent in target.reagents_to_log)
if(reagents.has_reagent(bad_reagent))
badshit += reagents_to_log[bad_reagent]
if(badshit.len)
var/hl="\red <b>([english_list(badshit)])</b> \black"
message_admins("[user.name] ([user.ckey]) added [reagents.get_reagent_ids(1)] to \a [target] with [src].[hl] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
log_game("[user.name] ([user.ckey]) added [reagents.get_reagent_ids(1)] to \a [target] with [src].")
user << "<span class='notify'>You dissolve [src] in [target].</span>"
reagents.trans_to(target, reagents.total_volume)
for(var/mob/O in viewers(2, user))
O.show_message("<span class='warning'>[user] puts something in [target].</span>", 1)
spawn(5)
qdel(src)
user << "<span class='notify'>You dissolve [src] in [target].</span>"
reagents.trans_to(target, reagents.total_volume)
for(var/mob/O in viewers(2, user))
O.show_message("<span class='warning'>[user] puts something in [target].</span>", 1)
spawn(5)
qdel(src)
return
return
////////////////////////////////////////////////////////////////////////////////
/// Pills. END
////////////////////////////////////////////////////////////////////////////////
//Pills
/obj/item/weapon/reagent_containers/pill/tox
/obj/item/weapon/reagent_containers/food/pill/tox
name = "Toxins pill"
desc = "Highly toxic."
icon_state = "pill5"
@@ -117,7 +69,7 @@
..()
reagents.add_reagent("toxin", 50)
/obj/item/weapon/reagent_containers/pill/initropidril
/obj/item/weapon/reagent_containers/food/pill/initropidril
name = "initropidril pill"
desc = "Don't swallow this."
icon_state = "pill5"
@@ -125,7 +77,7 @@
..()
reagents.add_reagent("initropidril", 50)
/obj/item/weapon/reagent_containers/pill/adminordrazine
/obj/item/weapon/reagent_containers/food/pill/adminordrazine
name = "Adminordrazine pill"
desc = "It's magic. We don't have to explain it."
icon_state = "pill16"
@@ -133,7 +85,7 @@
..()
reagents.add_reagent("adminordrazine", 50)
/obj/item/weapon/reagent_containers/pill/methamphetamine
/obj/item/weapon/reagent_containers/food/pill/methamphetamine
name = "Methamphetamine pill"
desc = "Helps improve the ability to concentrate."
icon_state = "pill8"
@@ -141,7 +93,7 @@
..()
reagents.add_reagent("methamphetamine", 5)
/obj/item/weapon/reagent_containers/pill/haloperidol
/obj/item/weapon/reagent_containers/food/pill/haloperidol
name = "Haloperidol pill"
desc = "Haloperidol is an anti-psychotic use to treat psychiatric problems."
icon_state = "pill8"
@@ -149,7 +101,7 @@
..()
reagents.add_reagent("haloperidol", 15)
/obj/item/weapon/reagent_containers/pill/paroxetine
/obj/item/weapon/reagent_containers/food/pill/paroxetine
name = "Paroxetine pill"
desc = "Heavy anti-depressant."
icon_state = "pill8"
@@ -158,7 +110,7 @@
reagents.add_reagent("paroxetine", 15)
/obj/item/weapon/reagent_containers/pill/happy
/obj/item/weapon/reagent_containers/food/pill/happy
name = "Happy pill"
desc = "Happy happy joy joy!"
icon_state = "pill18"
@@ -167,7 +119,7 @@
reagents.add_reagent("space_drugs", 15)
reagents.add_reagent("sugar", 15)
/obj/item/weapon/reagent_containers/pill/zoom
/obj/item/weapon/reagent_containers/food/pill/zoom
name = "Zoom pill"
desc = "Zoooom!"
icon_state = "pill18"
@@ -176,7 +128,7 @@
reagents.add_reagent("synaptizine", 5)
reagents.add_reagent("methamphetamine", 5)
/obj/item/weapon/reagent_containers/pill/charcoal
/obj/item/weapon/reagent_containers/food/pill/charcoal
name = "Charcoal pill"
desc = "Neutralizes many common toxins."
icon_state = "pill17"
@@ -184,7 +136,7 @@
..()
reagents.add_reagent("charcoal", 25)
/obj/item/weapon/reagent_containers/pill/salicylic
/obj/item/weapon/reagent_containers/food/pill/salicylic
name = "Salicylic Acid pill"
desc = "Commonly used to treat moderate pain and fevers."
icon_state = "pill4"
@@ -192,7 +144,7 @@
..()
reagents.add_reagent("sal_acid", 20)
/obj/item/weapon/reagent_containers/pill/salbutamol
/obj/item/weapon/reagent_containers/food/pill/salbutamol
name = "Salbutamol pill"
desc = "Used to treat respiratory distress."
icon_state = "pill8"