|
143 | 143 |
|
144 | 144 |
|
145 | 145 | //Returns if a certain item can be equipped to a certain slot.
|
146 |
| -// Currently invalid for two-handed items - call obj/item/mob_can_equip() instead. |
147 | 146 | /mob/proc/can_equip(obj/item/I, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE)
|
148 | 147 | return FALSE
|
149 | 148 |
|
150 |
| -/mob/proc/can_put_in_hand(I, hand_index) |
151 |
| - if(hand_index > held_items.len) |
152 |
| - return FALSE |
153 |
| - if(!put_in_hand_check(I)) |
154 |
| - return FALSE |
155 |
| - if(!has_hand_for_held_index(hand_index)) |
156 |
| - return FALSE |
157 |
| - return !held_items[hand_index] |
| 149 | +/mob/proc/can_put_in_hand(obj/item/I, hand_index) |
| 150 | + return FALSE |
| 151 | + |
| 152 | +/// A helper for picking up an item. |
| 153 | +/mob/proc/pickup_item(obj/item/I, hand_index = active_hand_index, ignore_anim) |
| 154 | + if(QDELETED(I)) |
| 155 | + return |
| 156 | + |
| 157 | + if(!can_put_in_hand(I, hand_index)) |
| 158 | + return |
| 159 | + |
| 160 | + I.pickup(src) |
| 161 | + . = put_in_hand(I, hand_index, ignore_anim = ignore_anim) |
| 162 | + |
| 163 | + if(!.) |
| 164 | + stack_trace("Somehow, someway, pickup_item failed put_in_hand().") |
| 165 | + dropItemToGround(I, silent = TRUE) |
158 | 166 |
|
159 | 167 | /mob/proc/put_in_hand(obj/item/I, hand_index, forced = FALSE, ignore_anim = TRUE)
|
160 |
| - if(hand_index == null || (!forced && !can_put_in_hand(I, hand_index))) |
| 168 | + if(hand_index == null) |
| 169 | + return FALSE |
| 170 | + |
| 171 | + if(!forced && !can_put_in_hand(I, hand_index)) |
161 | 172 | return FALSE
|
162 | 173 |
|
163 | 174 | if(isturf(I.loc) && !ignore_anim)
|
164 | 175 | I.do_pickup_animation(src)
|
| 176 | + |
165 | 177 | if(get_item_for_held_index(hand_index))
|
166 | 178 | dropItemToGround(get_item_for_held_index(hand_index), force = TRUE)
|
| 179 | + |
167 | 180 | I.forceMove(src)
|
168 | 181 | held_items[hand_index] = I
|
169 | 182 | I.plane = ABOVE_HUD_PLANE
|
|
191 | 204 | /mob/proc/put_in_r_hand(obj/item/I)
|
192 | 205 | return put_in_hand(I, get_empty_held_index_for_side(RIGHT_HANDS))
|
193 | 206 |
|
194 |
| -/mob/proc/put_in_hand_check(obj/item/I) |
195 |
| - return FALSE //nonliving mobs don't have hands |
| 207 | +/mob/living/can_put_in_hand(obj/item/I, hand_index) |
| 208 | + if(!istype(I)) |
| 209 | + return FALSE |
196 | 210 |
|
197 |
| -/mob/living/put_in_hand_check(obj/item/I) |
198 |
| - if(istype(I) && ((mobility_flags & MOBILITY_PICKUP) || (I.item_flags & ABSTRACT)) \ |
199 |
| - && !(SEND_SIGNAL(src, COMSIG_LIVING_TRY_PUT_IN_HAND, I) & COMPONENT_LIVING_CANT_PUT_IN_HAND)) |
200 |
| - return TRUE |
201 |
| - return FALSE |
| 211 | + if(hand_index > held_items.len) |
| 212 | + return FALSE |
| 213 | + |
| 214 | + if(!((mobility_flags & MOBILITY_PICKUP) || (I.item_flags & ABSTRACT))) |
| 215 | + return FALSE |
| 216 | + |
| 217 | + if(SEND_SIGNAL(src, COMSIG_LIVING_TRY_PUT_IN_HAND, I) & COMPONENT_LIVING_CANT_PUT_IN_HAND) |
| 218 | + return FALSE |
| 219 | + |
| 220 | + if(!has_hand_for_held_index(hand_index)) |
| 221 | + return FALSE |
| 222 | + |
| 223 | + return !held_items[hand_index] |
| 224 | + |
| 225 | +/mob/living/carbon/human/can_put_in_hand(obj/item/I, hand_index) |
| 226 | + . = ..() |
| 227 | + if(!.) |
| 228 | + return |
| 229 | + |
| 230 | + return dna.species.can_equip(I, ITEM_SLOT_HANDS, TRUE, src) |
202 | 231 |
|
203 | 232 | //Puts the item into our active hand if possible. returns TRUE on success.
|
204 | 233 | /mob/proc/put_in_active_hand(obj/item/I, forced = FALSE, ignore_animation = TRUE)
|
|
0 commit comments