|
116 | 116 | if(now_pushing)
|
117 | 117 | return TRUE
|
118 | 118 |
|
119 |
| - var/they_can_move = TRUE |
120 |
| - var/their_combat_mode = FALSE |
121 | 119 |
|
122 | 120 | if(isliving(M))
|
123 | 121 | var/mob/living/L = M
|
124 |
| - their_combat_mode = L.combat_mode |
125 |
| - they_can_move = L.mobility_flags & MOBILITY_MOVE |
126 | 122 | //Also spread diseases
|
127 | 123 | for(var/thing in diseases)
|
128 | 124 | var/datum/disease/D = thing
|
|
154 | 150 | return TRUE
|
155 | 151 |
|
156 | 152 | if(!M.buckled && !M.has_buckled_mobs())
|
157 |
| - var/mob_swap = FALSE |
158 |
| - var/too_strong = (M.move_resist > move_force) //can't swap with immovable objects unless they help us |
159 |
| - if(!they_can_move) //we have to physically move them |
160 |
| - if(!too_strong) |
161 |
| - mob_swap = TRUE |
162 |
| - else |
163 |
| - //You can swap with the person you are dragging on grab intent, and restrained people in most cases |
164 |
| - if(is_grabbing(M) && !too_strong) |
165 |
| - mob_swap = TRUE |
166 |
| - else if( |
167 |
| - !(HAS_TRAIT(M, TRAIT_NOMOBSWAP) || HAS_TRAIT(src, TRAIT_NOMOBSWAP))&&\ |
168 |
| - ((HAS_TRAIT(M, TRAIT_ARMS_RESTRAINED) && !too_strong) || !their_combat_mode) &&\ |
169 |
| - (HAS_TRAIT(src, TRAIT_ARMS_RESTRAINED) || !combat_mode) |
170 |
| - ) |
171 |
| - mob_swap = TRUE |
172 |
| - |
173 |
| - if(mob_swap) |
| 153 | + if(can_mobswap_with(M)) |
174 | 154 | //switch our position with M
|
175 | 155 | if(loc && !loc.MultiZAdjacent(M.loc))
|
176 | 156 | return TRUE
|
|
213 | 193 | if(I.try_block_attack(M, src, "the push", 0, LEAP_ATTACK)) //close enough?
|
214 | 194 | return TRUE
|
215 | 195 |
|
| 196 | +/mob/living/proc/can_mobswap_with(mob/other) |
| 197 | + if (HAS_TRAIT(other, TRAIT_NOMOBSWAP) || HAS_TRAIT(src, TRAIT_NOMOBSWAP)) |
| 198 | + return FALSE |
| 199 | + |
| 200 | + var/they_can_move = TRUE |
| 201 | + var/their_combat_mode = FALSE |
| 202 | + |
| 203 | + if(isliving(other)) |
| 204 | + var/mob/living/other_living = other |
| 205 | + their_combat_mode = other_living.combat_mode |
| 206 | + they_can_move = other_living.mobility_flags & MOBILITY_MOVE |
| 207 | + |
| 208 | + var/too_strong = other.move_resist > move_force |
| 209 | + |
| 210 | + // They cannot move, see if we can push through them |
| 211 | + if (!they_can_move) |
| 212 | + return !too_strong |
| 213 | + |
| 214 | + // We are pulling them and can move through |
| 215 | + if (is_grabbing(other) && !too_strong) |
| 216 | + return TRUE |
| 217 | + |
| 218 | + // If we're in combat mode and not restrained we don't try to pass through people |
| 219 | + if (combat_mode && !HAS_TRAIT(src, TRAIT_ARMS_RESTRAINED)) |
| 220 | + return FALSE |
| 221 | + |
| 222 | + // Nor can we pass through non-restrained people in combat mode (or if they're restrained but still too strong for us) |
| 223 | + if (their_combat_mode && (!HAS_TRAIT(other, TRAIT_ARMS_RESTRAINED) || too_strong)) |
| 224 | + return FALSE |
| 225 | + |
| 226 | + if (isnull(other.client) || isnull(client)) |
| 227 | + return TRUE |
| 228 | + |
| 229 | + // If both of us are trying to move in the same direction, let the fastest one through first |
| 230 | + if (client.intended_direction == other.client.intended_direction) |
| 231 | + return movement_delay < other.movement_delay |
| 232 | + |
| 233 | + // Else, sure, let us pass |
| 234 | + return TRUE |
| 235 | + |
216 | 236 | /mob/living/get_photo_description(obj/item/camera/camera)
|
217 | 237 | var/list/mob_details = list()
|
218 | 238 | var/list/holding = list()
|
|
0 commit comments