Merge pull request #16007 from SandPoot/throwing-updat

[DNM] Updates firemanning, throwing stuff
This commit is contained in:
BlueWildrose
2023-10-11 13:51:54 -06:00
committed by GitHub
23 changed files with 228 additions and 105 deletions

View File

@@ -0,0 +1,2 @@
/// a person somewhere has thrown something : (mob/living/carbon/carbon_thrower, target)
#define COMSIG_GLOB_CARBON_THROW_THING "!throw_thing"

View File

@@ -0,0 +1,2 @@
/// from mob/proc/dropItemToGround()
#define COMSIG_MOB_DROPPING_ITEM "mob_dropping_item"

View File

@@ -39,6 +39,21 @@
/datum/proc/p_es(temp_gender)
. = "es"
/datum/proc/plural_s(pluralize)
switch(copytext_char(pluralize, -2))
if ("ss")
return "es"
if ("sh")
return "es"
if ("ch")
return "es"
else
switch(copytext_char(pluralize, -1))
if("s", "x", "z")
return "es"
else
return "s"
//like clients, which do have gender.
/client/p_they(capitalized, temp_gender)
if(!temp_gender)

View File

@@ -392,3 +392,12 @@
if(rider in AM.buckled_mobs)
AM.unbuckle_mob(rider)
. = ..()
/obj/item/riding_offhand/on_thrown(mob/living/carbon/user, atom/target)
if(rider == user)
return //Piggyback user.
user.unbuckle_mob(rider)
if(HAS_TRAIT(user, TRAIT_PACIFISM))
to_chat(user, span_notice("You gently let go of [rider]."))
return
return rider

View File

@@ -61,7 +61,7 @@
return FALSE
source.visible_message("<span class='warning'>[user] starts picking up [source].</span>", \
"<span class='userdanger'>[user] starts picking you up!</span>")
if(!do_after(user, 20, target = source) || source.buckled)
if(!do_after(user, 2 SECONDS, target = source) || source.buckled)
return FALSE
source.visible_message("<span class='warning'>[user] picks up [source]!</span>", \
@@ -95,6 +95,7 @@
dynamic_hair_suffix = ""
var/mob/living/held_mob
var/escape_on_find
var/destroying = FALSE
/obj/item/clothing/head/mob_holder/Initialize(mapload, mob/living/target, worn_state, alt_worn, right_hand, left_hand, slots = NONE)
. = ..()
@@ -134,45 +135,54 @@
w_class = WEIGHT_CLASS_HUGE
/obj/item/clothing/head/mob_holder/Destroy()
destroying = TRUE
if(held_mob)
release()
release(FALSE)
return ..()
/obj/item/clothing/head/mob_holder/examine(mob/user)
return held_mob?.examine(user) || ..()
/obj/item/clothing/head/mob_holder/Exited(atom/movable/AM, atom/newloc)
. = ..()
if(AM == held_mob)
held_mob.reset_perspective()
held_mob = null
QDEL_IN(src, 1) //To avoid a qdel loop.
/obj/item/clothing/head/mob_holder/on_thrown(mob/living/carbon/user, atom/target)
if((item_flags & ABSTRACT) || HAS_TRAIT(src, TRAIT_NODROP))
return
if(HAS_TRAIT(user, TRAIT_PACIFISM))
to_chat(user, span_notice("You set [src] down gently on the ground."))
release()
return
/obj/item/clothing/head/mob_holder/Entered(atom/movable/AM, atom/newloc)
. = ..()
if(AM != held_mob)
var/destination = loc
if(isliving(loc)) //the mob is held or worn, drop things on the floor
destination = get_turf(loc)
AM.forceMove(destination)
var/mob/living/throw_mob = held_mob
release()
return throw_mob
/obj/item/clothing/head/mob_holder/dropped(mob/user)
. = ..()
if(held_mob && !ismob(loc) && !istype(loc,/obj/item/storage))//don't release on soft-drops
if(held_mob && isturf(loc))
release()
/obj/item/clothing/head/mob_holder/proc/release()
if(held_mob)
var/mob/living/L = held_mob
held_mob = null
L.forceMove(get_turf(L))
L.reset_perspective()
L.setDir(SOUTH)
if(!QDELETED(src))
/obj/item/clothing/head/mob_holder/proc/release(del_on_release = TRUE, display_messages = TRUE)
if(!held_mob)
if(del_on_release && !destroying)
qdel(src)
return FALSE
var/mob/living/released_mob = held_mob
held_mob = null // stops the held mob from being release()'d twice.
if(isliving(loc))
var/mob/living/L = loc
if(display_messages)
to_chat(L, span_warning("[released_mob] wriggles free!"))
L.dropItemToGround(src)
released_mob.forceMove(drop_location())
released_mob.reset_perspective()
released_mob.setDir(SOUTH)
if(display_messages)
released_mob.visible_message(span_warning("[released_mob] uncurls!"))
if(del_on_release && !destroying)
qdel(src)
return TRUE
/obj/item/clothing/head/mob_holder/relaymove(mob/user)
return
/obj/item/clothing/head/mob_holder/relaymove(mob/living/user, direction)
container_resist()
/obj/item/clothing/head/mob_holder/container_resist()
if(isliving(loc))
@@ -180,6 +190,11 @@
L.visible_message("<span class='warning'>[held_mob] escapes from [L]!</span>", "<span class='warning'>[held_mob] escapes your grip!</span>")
release()
/obj/item/clothing/head/mob_holder/Exited(atom/movable/gone, direction)
. = ..()
if(held_mob && held_mob == gone)
release()
/obj/item/clothing/head/mob_holder/mob_can_equip(M, equipper, slot, disable_warning, bypass_equip_delay_self)
if(M == held_mob || !ishuman(M)) //monkeys holding monkeys holding monkeys...
return FALSE
@@ -232,7 +247,9 @@
return location.transfer_air(taker, ratio)
// escape when found if applicable
/obj/item/clothing/head/mob_holder/on_found(mob/living/finder)
/obj/item/clothing/head/mob_holder/on_found(mob/finder)
if(escape_on_find)
finder.visible_message("[finder] accidentally releases the [held_mob]!")
release()
to_chat(finder, span_warning("\A [held_mob.name] pops out! "))
finder.visible_message(span_warning("\A [held_mob.name] pops out of the container [finder] is opening!"), ignored_mobs = finder)
release(TRUE, FALSE)
return

View File

@@ -25,11 +25,32 @@
if(user_unbuckle_mob(buckled_mobs[1],user))
return 1
/atom/movable/attackby(obj/item/attacking_item, mob/user, params)
if(!can_buckle || !istype(attacking_item, /obj/item/riding_offhand) || !user.Adjacent(src))
return ..()
var/obj/item/riding_offhand/riding_item = attacking_item
var/mob/living/carried_mob = riding_item.rider
if(carried_mob == user) //Piggyback user.
return
user.unbuckle_mob(carried_mob)
carried_mob.forceMove(get_turf(src))
return mouse_buckle_handling(carried_mob, user)
/atom/movable/MouseDrop_T(mob/living/M, mob/living/user)
. = ..()
return mouse_buckle_handling(M, user)
/**
* Does some typechecks and then calls user_buckle_mob
*
* Arguments:
* M - The mob being buckled to src
* user - The mob buckling M to src
*/
/atom/movable/proc/mouse_buckle_handling(mob/living/M, mob/living/user)
if(can_buckle && istype(M) && istype(user))
if(user_buckle_mob(M, user))
return 1
return user_buckle_mob(M, user, check_loc = FALSE)
/atom/movable/proc/has_buckled_mobs()
if(!buckled_mobs)

View File

@@ -177,6 +177,8 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
var/canMouseDown = FALSE
/// Used if we want to have a custom verb text for throwing. "John Spaceman flicks the ciggerate" for example.
var/throw_verb
/obj/item/Initialize(mapload)
@@ -1116,6 +1118,16 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
QDEL_NULL(src)
return TRUE
///Called by the carbon throw_item() proc. Returns null if the item negates the throw, or a reference to the thing to suffer the throw else.
/obj/item/proc/on_thrown(mob/living/carbon/user, atom/target)
if((item_flags & ABSTRACT) || HAS_TRAIT(src, TRAIT_NODROP))
return
user.dropItemToGround(src, silent = TRUE)
if(throwforce && HAS_TRAIT(user, TRAIT_PACIFISM))
to_chat(user, span_notice("You set [src] down gently on the ground."))
return
return src
/**

View File

@@ -108,6 +108,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
w_class = WEIGHT_CLASS_TINY
body_parts_covered = null
grind_results = list()
throw_verb = "flick"
var/lit = FALSE
var/starts_lit = FALSE
var/icon_on = "cigon" //Note - these are in masks.dmi not in cigarette.dmi

View File

@@ -48,7 +48,7 @@
unbuckle_mob(M)
add_fingerprint(user)
/obj/structure/bed/nest/user_buckle_mob(mob/living/M, mob/living/carbon/user)
/obj/structure/bed/nest/user_buckle_mob(mob/living/M, mob/living/carbon/user, check_loc)
if ( !ismob(M) || (get_dist(src, user) > 1) || (M.loc != src.loc) || !user.cuff_resist_check() || M.buckled )
return

View File

@@ -97,7 +97,7 @@
/obj/structure/kitchenspike/user_buckle_mob(mob/living/M, mob/living/user) //Don't want them getting put on the rack other than by spiking
/obj/structure/kitchenspike/user_buckle_mob(mob/living/M, mob/living/user, check_loc) //Don't want them getting put on the rack other than by spiking
return
/obj/structure/kitchenspike/user_unbuckle_mob(mob/living/buckled_mob, mob/living/carbon/human/user)

View File

@@ -43,7 +43,7 @@
. = ..()
STOP_PROCESSING(SSfastprocess, src)
/obj/machinery/manned_turret/user_buckle_mob(mob/living/M, mob/living/carbon/user)
/obj/machinery/manned_turret/user_buckle_mob(mob/living/M, mob/living/carbon/user, check_loc)
if(user.incapacitated() || !istype(user))
return
M.forceMove(get_turf(src))

View File

@@ -330,6 +330,17 @@ GLOBAL_LIST_EMPTY(crematoriums)
else
to_chat(user, "<span class='warning'>That's not connected to anything!</span>")
/obj/structure/tray/attackby(obj/P, mob/user, params)
if(!istype(P, /obj/item/riding_offhand))
return ..()
var/obj/item/riding_offhand/riding_item = P
var/mob/living/carried_mob = riding_item.rider
if(carried_mob == user) //Piggyback user.
return
user.unbuckle_mob(carried_mob)
MouseDrop_T(carried_mob, user)
/obj/structure/tray/MouseDrop_T(atom/movable/O as mob|obj, mob/user)
if(!ismovable(O) || O.anchored || !Adjacent(user) || !user.Adjacent(O) || O.loc == user)
return

View File

@@ -124,11 +124,11 @@
. = . || (caller.pass_flags & PASSTABLE)
/obj/structure/table/proc/tableplace(mob/living/user, mob/living/pushed_mob)
pushed_mob.forceMove(src.loc)
pushed_mob.set_resting(TRUE, FALSE)
pushed_mob.visible_message("<span class='notice'>[user] places [pushed_mob] onto [src].</span>", \
"<span class='notice'>[user] places [pushed_mob] onto [src].</span>")
log_combat(user, pushed_mob, "placed")
pushed_mob.forceMove(loc)
pushed_mob.set_resting(TRUE, TRUE)
pushed_mob.visible_message(span_notice("[user] places [pushed_mob] onto [src]."), \
span_notice("[user] places [pushed_mob] onto [src]."))
log_combat(user, pushed_mob, "places", null, "onto [src]")
/obj/structure/table/proc/tablepush(mob/living/user, mob/living/pushed_mob)
if(HAS_TRAIT(user, TRAIT_PACIFISM))
@@ -205,6 +205,30 @@
return
// If the tray IS empty, continue on (tray will be placed on the table like other items)
if(istype(I, /obj/item/riding_offhand))
var/obj/item/riding_offhand/riding_item = I
var/mob/living/carried_mob = riding_item.rider
if(carried_mob == user) //Piggyback user.
return
if(user.a_intent == INTENT_HARM)
user.unbuckle_mob(carried_mob)
tablelimbsmash(user, carried_mob)
else
var/tableplace_delay = 3.5 SECONDS
var/skills_space = ""
if(HAS_TRAIT(user, TRAIT_QUICKER_CARRY))
tableplace_delay = 2 SECONDS
skills_space = " expertly"
else if(HAS_TRAIT(user, TRAIT_QUICK_CARRY))
tableplace_delay = 2.75 SECONDS
skills_space = " quickly"
carried_mob.visible_message(span_notice("[user] begins to[skills_space] place [carried_mob] onto [src]..."),
span_userdanger("[user] begins to[skills_space] place [carried_mob] onto [src]..."))
if(do_after(user, tableplace_delay, target = carried_mob))
user.unbuckle_mob(carried_mob)
tableplace(user, carried_mob)
return TRUE
if(user.a_intent != INTENT_HARM && !(I.item_flags & ABSTRACT))
if(user.transferItemToLoc(I, drop_location()))
var/list/click_params = params2list(params)

View File

@@ -81,7 +81,7 @@
density = TRUE //Skewers are one-use only
desc = "A vicious brass spike protruding from the ground like a stala[pick("gm", "ct")]ite. It makes you sick to look at." //is stalagmite the ground one? or the ceiling one? who can ever remember?
/obj/structure/destructible/clockwork/trap/brass_skewer/user_buckle_mob()
/obj/structure/destructible/clockwork/trap/brass_skewer/user_buckle_mob(check_loc)
return
/obj/structure/destructible/clockwork/trap/brass_skewer/post_buckle_mob(mob/living/L)

View File

@@ -1,4 +1,4 @@
/mob/living/carbon/true_devil/doUnEquip(obj/item/I, force, silent = FALSE)
/mob/living/carbon/true_devil/doUnEquip(obj/item/I, force, invdrop, silent = FALSE)
if(..())
update_inv_hands()
return 1

View File

@@ -292,10 +292,18 @@
//The following functions are the same save for one small difference
//for when you want the item to end up on the ground
//will force move the item to the ground and call the turf's Entered
/mob/proc/dropItemToGround(obj/item/I, force = FALSE)
return doUnEquip(I, force, drop_location(), FALSE)
/**
* Used to drop an item (if it exists) to the ground.
* * Will pass as TRUE is successfully dropped, or if there is no item to drop.
* * Will pass FALSE if the item can not be dropped due to TRAIT_NODROP via doUnEquip()
* If the item can be dropped, it will be forceMove()'d to the ground and the turf's Entered() will be called.
*/
/mob/proc/dropItemToGround(obj/item/I, force = FALSE, silent = FALSE, invdrop = TRUE)
if (isnull(I))
return TRUE
SEND_SIGNAL(src, COMSIG_MOB_DROPPING_ITEM)
. = doUnEquip(I, force, drop_location(), FALSE, invdrop = invdrop, silent = silent)
//for when the item will be immediately placed in a loc other than the ground
/mob/proc/transferItemToLoc(obj/item/I, newloc = null, force = FALSE, silent = TRUE)

View File

@@ -1,3 +1,3 @@
//can't unequip since it can't equip anything
/mob/living/carbon/alien/larva/doUnEquip(obj/item/W, silent = FALSE)
/mob/living/carbon/alien/larva/doUnEquip(obj/item/W, invdrop, silent = FALSE)
return

View File

@@ -141,26 +141,28 @@
/mob/living/carbon/proc/throw_mode_off()
in_throw_mode = 0
in_throw_mode = FALSE
if(client && hud_used)
hud_used.throw_icon.icon_state = "act_throw_off"
/mob/living/carbon/proc/throw_mode_on()
in_throw_mode = 1
in_throw_mode = TRUE
if(client && hud_used)
hud_used.throw_icon.icon_state = "act_throw_on"
/mob/proc/throw_item(atom/target)
SEND_SIGNAL(src, COMSIG_MOB_THROW, target)
return
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CARBON_THROW_THING, src, target)
return TRUE
/mob/living/carbon/throw_item(atom/target)
. = ..()
throw_mode_off()
if(!target || !isturf(loc))
return
return FALSE
if(istype(target, /atom/movable/screen))
return
return FALSE
//CIT CHANGES - makes it impossible to throw while in stamina softcrit
if(IS_STAMCRIT(src))
@@ -170,59 +172,56 @@
var/random_turn = a_intent == INTENT_HARM
//END OF CIT CHANGES
var/obj/item/I = get_active_held_item()
var/atom/movable/thrown_thing
var/mob/living/throwable_mob
var/obj/item/held_item = get_active_held_item()
var/verb_text = pick("throw", "toss", "hurl", "chuck", "fling")
if(prob(0.5))
verb_text = "yeet"
if(istype(I, /obj/item/clothing/head/mob_holder))
var/obj/item/clothing/head/mob_holder/holder = I
if(holder.held_mob)
throwable_mob = holder.held_mob
holder.release()
if(!I || throwable_mob)
if(!throwable_mob && pulling && isliving(pulling) && grab_state >= GRAB_AGGRESSIVE)
throwable_mob = pulling
if(throwable_mob && !throwable_mob.buckled)
thrown_thing = throwable_mob
if(pulling)
var/neckgrab_throw = FALSE
if(!held_item)
if(pulling && isliving(pulling) && grab_state >= GRAB_AGGRESSIVE)
var/mob/living/throwable_mob = pulling
if(!throwable_mob.buckled)
thrown_thing = throwable_mob
if(grab_state >= GRAB_NECK)
neckgrab_throw = TRUE
stop_pulling()
if(HAS_TRAIT(src, TRAIT_PACIFISM))
to_chat(src, "<span class='notice'>You gently let go of [throwable_mob].</span>")
return
if(!UseStaminaBuffer(STAM_COST_THROW_MOB * ((throwable_mob.mob_size+1)**2), TRUE))
return
var/turf/start_T = get_turf(loc) //Get the start and target tile for the descriptors
var/turf/end_T = get_turf(target)
if(start_T && end_T)
log_combat(src, throwable_mob, "thrown", addition="grab from tile in [AREACOORD(start_T)] towards tile at [AREACOORD(end_T)]")
else if(!(I.item_flags & ABSTRACT) && !HAS_TRAIT(I, TRAIT_NODROP))
thrown_thing = I
dropItemToGround(I)
if(HAS_TRAIT(src, TRAIT_PACIFISM) && I.throwforce)
to_chat(src, "<span class='notice'>You set [I] down gently on the ground.</span>")
return
if(!UseStaminaBuffer(I.getweight(src, STAM_COST_THROW_MULT, SKILL_THROW_STAM_COST), warn = TRUE))
return
if(thrown_thing)
var/power_throw = 0
if(HAS_TRAIT(src, TRAIT_HULK))
power_throw++
if(pulling && grab_state >= GRAB_NECK)
power_throw++
visible_message("<span class='danger'>[src] throws [thrown_thing][power_throw ? " really hard!" : "."]</span>", \
"<span class='danger'>You throw [thrown_thing][power_throw ? " really hard!" : "."]</span>")
log_message("has thrown [thrown_thing] [power_throw ? "really hard" : ""]", LOG_ATTACK)
do_attack_animation(target, no_effect = 1)
playsound(loc, 'sound/weapons/punchmiss.ogg', 50, 1, -1)
newtonian_move(get_dir(target, src))
thrown_thing.safe_throw_at(target, thrown_thing.throw_range, thrown_thing.throw_speed + power_throw, src, null, null, null, move_force, random_turn)
if(HAS_TRAIT(src, TRAIT_PACIFISM))
to_chat(src, span_notice("You gently let go of [throwable_mob]."))
return FALSE
if(!UseStaminaBuffer(STAM_COST_THROW_MOB * ((throwable_mob.mob_size+1)**2), TRUE))
return FALSE
else
thrown_thing = held_item.on_thrown(src, target)
if(!thrown_thing)
return FALSE
if(isliving(thrown_thing))
var/turf/start_T = get_turf(loc) //Get the start and target tile for the descriptors
var/turf/end_T = get_turf(target)
if(start_T && end_T)
log_combat(src, thrown_thing, "thrown", addition="grab from tile in [AREACOORD(start_T)] towards tile at [AREACOORD(end_T)]")
var/power_throw = 0
if(HAS_TRAIT(src, TRAIT_HULK))
power_throw++
if(HAS_TRAIT(src, TRAIT_DWARF))
power_throw--
if(HAS_TRAIT(thrown_thing, TRAIT_DWARF))
power_throw++
if(neckgrab_throw)
power_throw++
if(isitem(thrown_thing))
var/obj/item/thrown_item = thrown_thing
if(thrown_item.throw_verb)
verb_text = thrown_item.throw_verb
visible_message(span_danger("[src] [verb_text][plural_s(verb_text)] [thrown_thing][power_throw ? " really hard!" : "."]"), \
span_danger("You [verb_text] [thrown_thing][power_throw ? " really hard!" : "."]"))
log_message("has thrown [thrown_thing] [power_throw > 0 ? "really hard" : ""]", LOG_ATTACK)
do_attack_animation(target, no_effect = 1)
var/extra_throw_range = 0 // HAS_TRAIT(src, TRAIT_THROWINGARM) ? 2 : 0
playsound(loc, 'sound/weapons/punchmiss.ogg', 50, 1, -1)
newtonian_move(get_dir(target, src))
thrown_thing.safe_throw_at(target, thrown_thing.throw_range + extra_throw_range, max(1,thrown_thing.throw_speed + power_throw), src, null, null, null, move_force, random_turn)
/mob/living/carbon/restrained(ignore_grab)
. = (handcuffed || (!ignore_grab && pulledby && pulledby.grab_state >= GRAB_AGGRESSIVE))

View File

@@ -41,7 +41,7 @@
..() //lose items, then return
//SLOT HANDLING BULLSHIT FOR INTERNAL STORAGE
/mob/living/simple_animal/hostile/guardian/dextrous/doUnEquip(obj/item/I, force, silent = FALSE)
/mob/living/simple_animal/hostile/guardian/dextrous/doUnEquip(obj/item/I, force, invdrop, silent = FALSE)
if(..())
update_inv_hands()
if(I == internal_storage)

View File

@@ -587,7 +587,7 @@
//ANIMAL RIDING
/mob/living/simple_animal/user_buckle_mob(mob/living/M, mob/user)
/mob/living/simple_animal/user_buckle_mob(mob/living/M, mob/user, check_loc)
var/datum/component/riding/riding_datum = GetComponent(/datum/component/riding)
if(riding_datum)
if(user.incapacitated())

View File

@@ -252,7 +252,7 @@
Feedon(Food)
return ..()
/mob/living/simple_animal/slime/doUnEquip(obj/item/W, silent = FALSE)
/mob/living/simple_animal/slime/doUnEquip(obj/item/W, invdrop, silent = FALSE)
return
/mob/living/simple_animal/slime/start_pulling(atom/movable/AM, state, force = move_force, supress_message = FALSE)

View File

@@ -383,7 +383,7 @@
auto.Remove(buckled_mob)
. = ..()
/obj/machinery/power/emitter/prototype/user_buckle_mob(mob/living/M, mob/living/carbon/user)
/obj/machinery/power/emitter/prototype/user_buckle_mob(mob/living/M, mob/living/carbon/user, check_loc)
if(user.incapacitated() || !istype(user))
return
for(var/atom/movable/A in get_turf(src))