Skip to content

Commit

Permalink
Merge pull request tgstation#14450 from AnturK/mechboots
Browse files Browse the repository at this point in the history
Fixes mechs using occupant spacemove
  • Loading branch information
duncathan committed Jan 8, 2016
2 parents c594d2d + 8b1b752 commit 6fcb780
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
20 changes: 20 additions & 0 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,23 @@
if(buckled_mob == mover)
return 1
return ..()


/atom/movable/proc/get_spacemove_backup()
var/atom/movable/dense_object_backup
for(var/A in orange(1, get_turf(src)))
if(isarea(A))
continue
else if(isturf(A))
var/turf/turf = A
if(!turf.density)
continue
return turf
else
var/atom/movable/AM = A
if(!AM.CanPass(src) || AM.density)
if(AM.anchored)
return AM
dense_object_backup = AM
break
. = dense_object_backup
14 changes: 11 additions & 3 deletions code/game/mecha/mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,17 @@
events.fireEvent("onMove",get_turf(src))

/obj/mecha/Process_Spacemove(var/movement_dir = 0)
if(occupant)
return occupant.Process_Spacemove(movement_dir) //We'll just say you used the clamp to grab the wall
return ..()
. = ..()
if(.)
return 1

var/atom/movable/backup = get_spacemove_backup()
if(backup)
if(istype(backup) && movement_dir && !!backup.anchored)
if(backup.newtonian_move(turn(movement_dir, 180)))
if(occupant)
occupant << "<span class='info'>You push off of [backup] to propel yourself.</span>"
return 1

/obj/mecha/relaymove(mob/user,direction)
if(!direction)
Expand Down
29 changes: 13 additions & 16 deletions code/modules/mob/mob_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -305,43 +305,40 @@
///For moving in space
///Return 1 for movement 0 for none
/mob/Process_Spacemove(movement_dir = 0)

if(..())
return 1
var/atom/movable/backup = get_spacemove_backup()
if(backup)
if(istype(backup) && movement_dir && !backup.anchored)
if(backup.newtonian_move(turn(movement_dir, 180))) //You're pushing off something movable, so it moves
src << "<span class='info'>You push off of [backup] to propel yourself.</span>"
return 1
return 0

/mob/get_spacemove_backup()
var/atom/movable/dense_object_backup
for(var/atom/A in orange(1, get_turf(src)))
for(var/A in orange(1, get_turf(src)))
if(isarea(A))
continue

else if(isturf(A))
var/turf/turf = A
if(istype(turf,/turf/space))
continue

if(!turf.density && !mob_negates_gravity())
continue

return 1

return A
else
var/atom/movable/AM = A
if(AM == buckled) //Kind of unnecessary but let's just be sure
continue
if(!AM.CanPass(src) || AM.density)
if(AM.anchored)
return 1
return AM
if(pulling == AM)
continue
dense_object_backup = AM

if(movement_dir && dense_object_backup)
if(dense_object_backup.newtonian_move(turn(movement_dir, 180))) //You're pushing off something movable, so it moves
src << "<span class='info'>You push off of [dense_object_backup] to propel yourself.</span>"


return 1
return 0
break
. = dense_object_backup

/mob/proc/mob_has_gravity(turf/T)
return has_gravity(src, T)
Expand Down

0 comments on commit 6fcb780

Please sign in to comment.