Files
Paradise/code/game/objects/buckling.dm
Tigercat2000 258f477eb3 /tg/ mecha - Part 1
Start of porting the /tg/station mecha update.
This commit only cleans up the code and adds the proper dependencies for
the mecha.

 - Removes relative pathing from /datum/events
 - Updated Process_Spacemove() to use
   atom/movable/proc/get_spacemove_backup()
   - Basically just makes launching off of unanchored objects in space an
     OOP behaviour
 - Removed styling atrocities and relative pathing from most of the mecha files.
  - Notable exceptions:
   - code/game/mecha/mech_bay.dm
   - code/game/mecha/mech_fabricator.dm
   - code/game/mecha/mecha_construction_paths.dm
   - code/game/mecha/mecha_parts.dm
   - code/game/mecha/mecha_wreckage.dm
   - code/game/mecha/paintkits.dm
 - Removed dyndomove/dyndoattackby/dyndobulletact. No more icky dynamic
   calls. Replaced by specific code for the 3 modules that used it.
 - Refactored module cooldown. It now uses addtimer, and power usage is
   hooked directly into the cooldown calls.
 - Added atom/movable/proc/has_buckled_mobs(). Currently not that useful,
   but, necessary for porting the multi-buckling system from /tg/.
 - Split code/game/mecha/equipment/tools/tools.dm into multiple files.
 - Removed snowflake behaviour from exosuit drill. It now calls
   turf.drill_act(src).
  - Different from /tg/: Allows you to drill any wall/floor normally.
 - Drill no longer gibs mobs. It deals 80 organ damage instead.
 - Drill can be used to harvest dead mobs.
 - Removed all global_iterator systems from mecha and mecha equipment.
   Everything now uses object processing.
 - Mecha now have a turn sound variable and step sound variable. Updated
   all subtypes to use these instead of snowflake domove procs.
 - Removed mecha_do_after, mecha now uses the normal do_after.
 - Removed enter_after, same as above.
 - /obj/mecha/Process_Spacemove no longer strangely calls the user's
   spacemove.
 - /obj/mecha/return_pressure now uses return_air instead of copypasted
   cabin air detection.
 - Same for /obj/mecha/return_temperature
 - Added /obj/mecha/Exited. Basically, properly clears occupant refs,
   even if they teleport out/otherwise exit improperly.
 - Added hooks for mecha action buttons; Didn't implement them yet.
 - Moved mecha UI to code/game/mecha/mecha_topic.dm
 - Fixed turfs not updating atmos when ChangeTurf(/turf/space) is used.
 - Updated visible_message and audible_message. Both now use
   get_mobs_in_view() to ensure that mobs inside containers can see
   messages.
 - Removed /obj/item/mecha_parts/mecha_equipment/tool subtype. It had no
   use. Any subtypes are now just subtypes of
   /obj/item/mecha_parts/mecha_equipment.
2016-08-12 06:14:00 -07:00

117 lines
3.5 KiB
Plaintext

/atom/movable
var/can_buckle = 0
var/buckle_lying = -1 //bed-like behaviour, forces mob.lying = buckle_lying if != -1 //except -1 actually means "rotate 90 degrees to the left" as it is used by 1*buckle_lying.
var/buckle_requires_restraints = 0 //require people to be handcuffed before being able to buckle. eg: pipes
var/mob/living/buckled_mob = null
//Interaction
/atom/movable/attack_hand(mob/living/user)
. = ..()
if(can_buckle && buckled_mob)
return user_unbuckle_mob(user)
/atom/movable/attack_robot(mob/living/user)
. = ..()
if(can_buckle && buckled_mob && Adjacent(user)) // attack_robot is called on all ranges, so the Adjacent check is needed
return user_unbuckle_mob(user)
/atom/movable/MouseDrop_T(mob/living/M, mob/living/user)
. = ..()
if(can_buckle && istype(M))
return user_buckle_mob(M, user)
//Cleanup
/atom/movable/Destroy()
. = ..()
unbuckle_mob()
/atom/movable/proc/has_buckled_mobs()
if(buckled_mob)
return TRUE
return FALSE
//procs that handle the actual buckling and unbuckling
/atom/movable/proc/buckle_mob(mob/living/M)
if(!can_buckle || !istype(M) || (M.loc != loc) || M.buckled || M.buckled_mob || buckled_mob || (buckle_requires_restraints && !M.restrained()) || M == src)
return 0
if(isslime(M) || isAI(M))
if(M == usr)
to_chat(M, "<span class='warning'>You are unable to buckle yourself to the [src]!</span>")
else
to_chat(usr, "<span class='warning'>You are unable to buckle [M] to the [src]!</span>")
return 0
M.buckled = src
M.dir = dir
buckled_mob = M
M.update_canmove()
post_buckle_mob(M)
M.throw_alert("buckled", /obj/screen/alert/restrained/buckled, new_master = src)
return 1
/obj/buckle_mob(mob/living/M)
. = ..()
if(.)
if(burn_state == ON_FIRE) //Sets the mob on fire if you buckle them to a burning atom/movableect
M.adjust_fire_stacks(1)
M.IgniteMob()
/atom/movable/proc/unbuckle_mob()
if(buckled_mob && buckled_mob.buckled == src && buckled_mob.can_unbuckle(usr))
. = buckled_mob
buckled_mob.buckled = null
buckled_mob.anchored = initial(buckled_mob.anchored)
buckled_mob.update_canmove()
buckled_mob.clear_alert("buckled")
buckled_mob = null
post_buckle_mob(.)
//Handle any extras after buckling/unbuckling
//Called on buckle_mob() and unbuckle_mob()
/atom/movable/proc/post_buckle_mob(mob/living/M)
return
//Wrapper procs that handle sanity and user feedback
/atom/movable/proc/user_buckle_mob(mob/living/M, mob/user)
if(!in_range(user, src) || user.stat || user.restrained())
return
add_fingerprint(user)
if(buckle_mob(M))
if(M == user)
M.visible_message(\
"<span class='notice'>[M] buckles themself to [src].</span>",\
"<span class='notice'>You buckle yourself to [src].</span>",\
"<span class='italics'>You hear metal clanking.</span>")
else
M.visible_message(\
"<span class='warning'>[user] buckles [M] to [src]!</span>",\
"<span class='warning'>[user] buckles you to [src]!</span>",\
"<span class='italics'>You hear metal clanking.</span>")
return 1
/atom/movable/proc/user_unbuckle_mob(mob/user)
var/mob/living/M = unbuckle_mob()
if(M)
if(M != user)
M.visible_message(\
"<span class='notice'>[user] unbuckles [M] from [src].</span>",\
"<span class='notice'>[user] unbuckles you from [src].</span>",\
"<span class='italics'>You hear metal clanking.</span>")
else
M.visible_message(\
"<span class='notice'>[M] unbuckles themselves from [src].</span>",\
"<span class='notice'>You unbuckle yourself from [src].</span>",\
"<span class='italics'>You hear metal clanking.</span>")
add_fingerprint(user)
return M