Skip to content

Commit

Permalink
Lets you empty sandbags (#16298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturlang authored Jul 10, 2024
1 parent dd13e0e commit 3951ac8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions code/game/objects/items/stacks/sandbags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,42 @@
merge_type = /obj/item/stack/sandbags


/obj/item/stack/sandbags/examine(mob/user)
. = ..()
. += span_notice("Right click while selected to empty [src].")

/obj/item/stack/sandbags/large_stack
amount = 25

/obj/item/stack/sandbags/attack_self(mob/living/user)
. = ..()
var/building_time = LERP(2 SECONDS, 1 SECONDS, user.skills.getPercent(SKILL_CONSTRUCTION, SKILL_ENGINEER_EXPERT))
create_object(user, new/datum/stack_recipe("sandbag barricade", /obj/structure/barricade/sandbags, 5, time = building_time, crafting_flags = CRAFT_CHECK_DENSITY | CRAFT_CHECK_DIRECTION | CRAFT_ON_SOLID_GROUND), 1)

/obj/item/stack/sandbags/attack_self_alternate(mob/user)
. = ..()
if(get_amount() < 1)
return
if(LAZYLEN(user.do_actions))
user.balloon_alert(user, "You are already busy.")
return

user.balloon_alert(user, "You start emptying [src].")
while(get_amount() > 0)
if(!do_after(user, 0.5 SECONDS, IGNORE_USER_LOC_CHANGE|IGNORE_TARGET_LOC_CHANGE, user))
user.balloon_alert(user, "You stop emptying [src].")
break
// check if we can stuff it into the user's hands
if(!use(1))
break
if(amount < 1)
user.balloon_alert(user, "You finish emptying [src].")
break
var/obj/item/stack/sandbag = user.get_inactive_held_item()
if(istype(sandbag, /obj/item/stack/sandbags_empty) && sandbag.add(1))
continue
var/obj/item/stack/sandbags_empty/E = new(get_turf(user))
if(!sandbag && user.put_in_hands(E))
continue
E.add_to_stacks(user)

0 comments on commit 3951ac8

Please sign in to comment.