Merge pull request #6963 from mwerezak/sliceable

Rewrites food slicing, energy weapons
This commit is contained in:
Chinsky
2014-11-08 11:07:34 +03:00
8 changed files with 223 additions and 218 deletions

View File

@@ -159,6 +159,8 @@
matter = list("metal" = 50)
origin_tech = "materials=1;engineering=1"
attack_verb = list("bashed", "bludgeoned", "thrashed", "whacked")
sharp = 0
edge = 1
/obj/item/weapon/shovel/spade
name = "spade"

View File

@@ -71,7 +71,7 @@
name = lowertext("[fullname] sandwich")
if(length(name) > 80) name = "[pick(list("absurd","colossal","enormous","ridiculous"))] sandwich"
w_class = n_ceil(Clamp((ingredients.len/2),1,3))
w_class = n_ceil(Clamp((ingredients.len/2),2,4))
/obj/item/weapon/reagent_containers/food/snacks/csandwich/Del()
for(var/obj/item/O in ingredients)
@@ -98,4 +98,4 @@
if(H && shard && M == user) //This needs a check for feeding the food to other people, but that could be abusable.
H << "\red You lacerate your mouth on a [shard.name] in the sandwich!"
H.adjustBruteLoss(5) //TODO: Target head if human.
..()
..()

View File

@@ -10,6 +10,7 @@
var/slice_path
var/slices_num
center_of_mass = list("x"=15, "y"=15)
w_class = 2
//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)
@@ -125,11 +126,10 @@
/obj/item/weapon/reagent_containers/food/snacks/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W,/obj/item/weapon/storage))
..() // -> item/attackby()
if(istype(W,/obj/item/weapon/storage))
..() // -> item/attackby()
return
// Eating with forks
if(istype(W,/obj/item/weapon/kitchen/utensil))
var/obj/item/weapon/kitchen/utensil/U = W
if(!U.reagents)
@@ -156,65 +156,46 @@
if (reagents.total_volume <= 0)
del(src)
return
if (is_sliceable())
//these are used to allow hiding edge items in food that is not on a table/tray
var/can_slice_here = isturf(src.loc) && ((locate(/obj/structure/table) in src.loc) || (locate(/obj/machinery/optable) in src.loc) || (locate(/obj/item/weapon/tray) in src.loc))
var/hide_item = !has_edge(W) || !can_slice_here
if (hide_item)
if (W.w_class >= src.w_class || W.is_robot_module())
return
user << "\red You slip [W] inside [src]."
user.u_equip(W)
if ((user.client && user.s_active != src))
user.client.screen -= W
W.dropped(user)
add_fingerprint(user)
contents += W
return
if (has_edge(W))
if (!can_slice_here)
user << "\red You cannot slice [src] here! You need a table or at least a tray to do it."
return
var/slices_lost = 0
if (W.w_class > 3)
user.visible_message("\blue [user] crudely slices \the [src] with [W]!", "\blue You crudely slice \the [src] with your [W]!")
slices_lost = rand(1,min(1,round(slices_num/2)))
else
user.visible_message("\blue [user] slices \the [src]!", "\blue You slice \the [src]!")
var/reagents_per_slice = reagents.total_volume/slices_num
for(var/i=1 to (slices_num-slices_lost))
var/obj/slice = new slice_path (src.loc)
reagents.trans_to(slice,reagents_per_slice)
del(src)
return
if((slices_num <= 0 || !slices_num) || !slice_path)
return 0
var/inaccurate = 0
if( \
istype(W, /obj/item/weapon/kitchenknife) || \
istype(W, /obj/item/weapon/butch) || \
istype(W, /obj/item/weapon/scalpel) || \
istype(W, /obj/item/weapon/kitchen/utensil/knife) \
)
else if( \
istype(W, /obj/item/weapon/circular_saw) || \
istype(W, /obj/item/weapon/melee/energy/sword) && W:active || \
istype(W, /obj/item/weapon/melee/energy/blade) || \
istype(W, /obj/item/weapon/shovel) || \
istype(W, /obj/item/weapon/hatchet) \
)
inaccurate = 1
else if(W.w_class <= 2 && istype(src,/obj/item/weapon/reagent_containers/food/snacks/sliceable))
if(!iscarbon(user))
return 1
user << "\red You slip [W] inside [src]."
user.u_equip(W)
if ((user.client && user.s_active != src))
user.client.screen -= W
W.dropped(user)
add_fingerprint(user)
contents += W
return
else
return 1
if ( \
!isturf(src.loc) || \
!(locate(/obj/structure/table) in src.loc) && \
!(locate(/obj/machinery/optable) in src.loc) && \
!(locate(/obj/item/weapon/tray) in src.loc) \
)
user << "\red You cannot slice [src] here! You need a table or at least a tray to do it."
return 1
var/slices_lost = 0
if (!inaccurate)
user.visible_message( \
"\blue [user] slices \the [src]!", \
"\blue You slice \the [src]!" \
)
else
user.visible_message( \
"\blue [user] crudely slices \the [src] with [W]!", \
"\blue You crudely slice \the [src] with your [W]!" \
)
slices_lost = rand(1,min(1,round(slices_num/2)))
var/reagents_per_slice = reagents.total_volume/slices_num
for(var/i=1 to (slices_num-slices_lost))
var/obj/slice = new slice_path (src.loc)
reagents.trans_to(slice,reagents_per_slice)
del(src)
return
/obj/item/weapon/reagent_containers/food/snacks/proc/is_sliceable()
return (slices_num <= 0 || !slices_num || !slice_path)
/obj/item/weapon/reagent_containers/food/snacks/Del()
if(contents)
@@ -241,7 +222,6 @@
//N.emote("nibbles away at the [src]")
N.health = min(N.health + 1, N.maxHealth)
////////////////////////////////////////////////////////////////////////////////
/// FOOD END
////////////////////////////////////////////////////////////////////////////////
@@ -2153,6 +2133,9 @@
// sliceable is just an organization type path, it doesn't have any additional code or variables tied to it.
/obj/item/weapon/reagent_containers/food/snacks/sliceable
w_class = 3 //Whole pizzas and cakes shouldn't fit in a pocket, you can slice them if you want to do that.
/obj/item/weapon/reagent_containers/food/snacks/sliceable/meatbread
name = "meatbread loaf"
desc = "The culinary base of every self-respecting eloquen/tg/entleman."