forked from Baystation12/Baystation12
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] rapid service fabricator gets correct ammo from cartridges
- Loading branch information
1 parent
a70322d
commit 90d2196
Showing
1 changed file
with
76 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,106 @@ | ||
/* | ||
CONTAINS: | ||
RSF | ||
*/ | ||
|
||
/obj/item/rsf | ||
name = "rapid service fabricator" | ||
desc = "A device used to rapidly deploy service items." | ||
icon = 'icons/obj/tools/rcd.dmi' | ||
icon_state = "rcd" | ||
opacity = 0 | ||
density = FALSE | ||
anchored = FALSE | ||
var/stored_matter = 30 | ||
var/mode = MODE_CIGARETTE | ||
w_class = ITEM_SIZE_NORMAL | ||
|
||
var/const/MODE_CIGARETTE = "Cigarette" | ||
var/const/MODE_GLASS = "Drinking Glass" | ||
var/const/MODE_PAPER = "Paper" | ||
var/const/MODE_PEN = "Pen" | ||
var/const/MODE_DICE = "Dice Pack" | ||
|
||
/// The current mode of the RSF. One of the MODE_* constants. | ||
var/mode = MODE_CIGARETTE | ||
|
||
/// The maximum amount of matter the RSF can hold when not a robot RSF. | ||
var/max_stored_matter = 30 | ||
|
||
/// The current amount of matter the RSF holds. | ||
var/stored_matter | ||
|
||
|
||
/obj/item/rsf/Initialize() | ||
. = ..() | ||
stored_matter = max_stored_matter | ||
|
||
|
||
/obj/item/rsf/examine(mob/user, distance) | ||
. = ..() | ||
if(distance <= 0) | ||
to_chat(user, "It currently holds [stored_matter]/30 fabrication-units.") | ||
if (distance <= 0) | ||
to_chat(user, "It currently holds [stored_matter]/[max_stored_matter] fabrication units.") | ||
|
||
/obj/item/rsf/attackby(obj/item/W as obj, mob/user as mob) | ||
..() | ||
if (istype(W, /obj/item/rcd_ammo)) | ||
|
||
if ((stored_matter + 10) > 30) | ||
/obj/item/rsf/attackby(obj/item/item, mob/living/user) | ||
if (istype(item, /obj/item/rcd_ammo)) | ||
var/obj/item/rcd_ammo/ammo = item | ||
if (stored_matter >= max_stored_matter) | ||
to_chat(user, "The RSF can't hold any more matter.") | ||
return | ||
|
||
qdel(W) | ||
return TRUE | ||
var/use_amount = min(ammo.remaining, max_stored_matter - stored_matter) | ||
stored_matter += use_amount | ||
ammo.remaining -= use_amount | ||
if (ammo.remaining <= 0) | ||
qdel(ammo) | ||
playsound(loc, 'sound/machines/click.ogg', 10, TRUE) | ||
to_chat(user, "The RSF now holds [stored_matter]/[max_stored_matter] fabrication units.") | ||
return TRUE | ||
return ..() | ||
|
||
stored_matter += 10 | ||
playsound(src.loc, 'sound/machines/click.ogg', 10, 1) | ||
to_chat(user, "The RSF now holds [stored_matter]/30 fabrication-units.") | ||
return | ||
|
||
/obj/item/rsf/attack_self(mob/user as mob) | ||
var/list/options = list( | ||
"Cigarette" = mutable_appearance('icons/screen/radial.dmi', "cigarette"), | ||
"Drinking Glass" = mutable_appearance('icons/screen/radial.dmi', "glass"), | ||
"Paper" = mutable_appearance('icons/screen/radial.dmi', "paper"), | ||
"Pen" = mutable_appearance('icons/screen/radial.dmi', "pen"), | ||
"Dice Pack" = mutable_appearance('icons/screen/radial.dmi', "dicebag") | ||
) | ||
/obj/item/rsf/attack_self(mob/living/user) | ||
var/list/options = list() | ||
options[MODE_CIGARETTE] = mutable_appearance('icons/screen/radial.dmi', "cigarette") | ||
options[MODE_GLASS] = mutable_appearance('icons/screen/radial.dmi', "glass") | ||
options[MODE_PAPER] = mutable_appearance('icons/screen/radial.dmi', "paper") | ||
options[MODE_PEN] = mutable_appearance('icons/screen/radial.dmi', "pen") | ||
options[MODE_DICE] = mutable_appearance('icons/screen/radial.dmi', "dicebag") | ||
var/choice = show_radial_menu(user, user, options, require_near = TRUE, radius = 42, tooltips = TRUE, check_locs = list(src)) | ||
if (!choice || !user.use_sanity_check(src)) | ||
return | ||
|
||
mode = choice | ||
to_chat(user, SPAN_NOTICE("Changed dispending mode to \the [choice].")) | ||
playsound(src.loc, 'sound/effects/pop.ogg', 50, 0) | ||
playsound(loc, 'sound/effects/pop.ogg', 50, FALSE) | ||
|
||
/obj/item/rsf/use_before(atom/A, mob/living/user, click_parameters) | ||
if(istype(user,/mob/living/silicon/robot)) | ||
var/mob/living/silicon/robot/R = user | ||
if(R.stat || !R.cell || R.cell.charge <= 0) | ||
to_chat(user, SPAN_WARNING("You are unable to use \the [src].")) | ||
return TRUE | ||
else | ||
if(stored_matter <= 0) | ||
to_chat(user, SPAN_WARNING("\The [src] is empty!")) | ||
return TRUE | ||
|
||
if(!istype(A, /obj/structure/table) && !istype(A, /turf/simulated/floor)) | ||
/obj/item/rsf/use_before(atom/target, mob/living/user, list/click_parameters) | ||
if (!istype(target, /obj/structure/table) && !istype(target, /turf/simulated/floor)) | ||
return FALSE | ||
|
||
playsound(src.loc, 'sound/machines/click.ogg', 10, 1) | ||
var/used_energy = 0 | ||
var/turf/into = get_turf(target) | ||
if (!into) | ||
return FALSE | ||
var/required_energy | ||
var/obj/product | ||
|
||
switch(mode) | ||
if(MODE_CIGARETTE) | ||
product = new /obj/item/clothing/mask/smokable/cigarette() | ||
used_energy = 10 | ||
if(MODE_GLASS) | ||
product = new /obj/item/reagent_containers/food/drinks/glass2() | ||
used_energy = 50 | ||
if(MODE_PAPER) | ||
product = new /obj/item/paper() | ||
used_energy = 10 | ||
if(MODE_PEN) | ||
product = new /obj/item/pen() | ||
used_energy = 50 | ||
if(MODE_DICE) | ||
product = new /obj/item/storage/pill_bottle/dice() | ||
used_energy = 200 | ||
|
||
to_chat(user, "Dispensing [product ? product : "product"]...") | ||
if (isturf(A)) | ||
product.dropInto(A) | ||
else | ||
product.dropInto(A.loc) | ||
|
||
if(isrobot(user)) | ||
var/mob/living/silicon/robot/R = user | ||
if(R.cell) | ||
R.cell.use(used_energy) | ||
switch (mode) | ||
if (MODE_CIGARETTE) | ||
product = new /obj/item/clothing/mask/smokable/cigarette | ||
required_energy = 10 | ||
if (MODE_GLASS) | ||
product = new /obj/item/reagent_containers/food/drinks/glass2 | ||
required_energy = 50 | ||
if (MODE_PAPER) | ||
product = new /obj/item/paper | ||
required_energy = 10 | ||
if (MODE_PEN) | ||
product = new /obj/item/pen | ||
required_energy = 50 | ||
if (MODE_DICE) | ||
product = new /obj/item/storage/pill_bottle/dice | ||
required_energy = 200 | ||
if (isrobot(user)) | ||
var/mob/living/silicon/robot/robot = user | ||
if (robot.stat || !robot.cell) | ||
to_chat(user, SPAN_WARNING("You're in no condition to do that.")) | ||
return TRUE | ||
if (!robot.cell.checked_use(required_energy)) | ||
to_chat(user, SPAN_WARNING("You don't have enough energy to do that.")) | ||
return TRUE | ||
else if (stored_matter < 1) | ||
to_chat(user, SPAN_WARNING("\The [src] is empty.")) | ||
return TRUE | ||
else | ||
stored_matter-- | ||
to_chat(user, "The RSF now holds [stored_matter]/30 fabrication-units.") | ||
playsound(loc, 'sound/machines/click.ogg', 10, TRUE) | ||
to_chat(user, "Dispensing [product ? product : "product"]...") | ||
product.dropInto(into) | ||
return TRUE |