NODROP flag addition & handling

- Purges canremove
- Implements functionality for NODROP flag, replaces canremove
- Refactors mob inventory unequipping.
This commit is contained in:
DZD
2015-02-18 13:22:41 -05:00
parent 723dc2ad98
commit fbd9c367c0
128 changed files with 618 additions and 659 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
if (contents.len >= max_butts)
user << "This ashtray is full."
return
user.u_equip(W)
user.unEquip(W)
W.loc = src
if (istype(W,/obj/item/clothing/mask/cigarette))
+2 -1
View File
@@ -59,7 +59,8 @@
if(!wax)
new/obj/item/trash/candle(src.loc)
if(istype(src.loc, /mob))
src.dropped()
var/mob/M = src.loc
M.unEquip(src, 1) //src is being deleted anyway
del(src)
update_icon()
if(istype(loc, /turf)) //start a fire if possible
+2 -2
View File
@@ -23,7 +23,7 @@
if(!parts)
user << "<span class='warning'>This kit has no parts for this modification left.</span>"
user.drop_from_inventory(src)
user.unEquip(src)
del(src)
return
@@ -59,7 +59,7 @@
parts &= ~MODKIT_SUIT
if(!parts)
user.drop_from_inventory(src)
user.unEquip(src)
del(src)
/obj/item/device/modkit/examine()
@@ -35,18 +35,22 @@
var/obj/item/assembly/shock_kit/A = new /obj/item/assembly/shock_kit( user )
A.icon = 'icons/obj/assemblies.dmi'
user.drop_from_inventory(W)
if(!user.unEquip(W))
user << "<span class='notice'>\the [W] is stuck to your hand, you cannot attach it to \the [src]!</span>"
return
W.loc = A
W.master = A
A.part1 = W
user.drop_from_inventory(src)
user.unEquip(src)
loc = A
master = A
A.part2 = src
user.put_in_hands(A)
A.add_fingerprint(user)
if(src.flags & NODROP)
A.flags |= NODROP
/obj/item/device/radio/electropack/Topic(href, href_list)
//..()
+1 -1
View File
@@ -109,7 +109,7 @@
user << "You armed the robot frame"
W:use(1)
if (user.get_inactive_hand()==src)
user.before_take_item(src)
user.unEquip(src)
user.put_in_inactive_hand(B)
del(src)
if(istype(W, /obj/item/robot_parts/l_leg))
@@ -19,17 +19,17 @@
amount--
new/obj/item/stack/sheet/glass(user.loc)
if(amount <= 0)
user.drop_from_inventory(src)
user.unEquip(src, 1)
del(src)
if(istype(O,/obj/item/stack/sheet/metal))
var/obj/item/stack/sheet/metal/M = O
M.amount--
if(M.amount <= 0)
user.drop_from_inventory(M)
user.unEquip(src, 1)
del(M)
amount--
new/obj/item/stack/tile/light(user.loc)
if(amount <= 0)
user.drop_from_inventory(src)
user.unEquip(src, 1)
del(src)
+3 -3
View File
@@ -145,7 +145,7 @@
if (src.amount<=0)
var/oldsrc = src
src = null //dont kill proc after del()
usr.before_take_item(oldsrc)
usr.unEquip(oldsrc, 1)
del(oldsrc)
if (istype(O,/obj/item))
usr.put_in_hands(O)
@@ -167,7 +167,7 @@
amount -= used
if (amount <= 0)
if(usr)
usr.before_take_item(src, 1)
usr.unEquip(src, 1)
qdel(src)
return 1
@@ -185,7 +185,7 @@
usr << "You add new [item.singular_name] to the stack. It now contains [item.amount] [item.singular_name]\s."
if(!oldsrc)
break
/obj/item/stack/proc/get_amount()
return amount
@@ -32,5 +32,5 @@
amount--
new/obj/item/stack/light_w(user.loc)
if(amount <= 0)
user.drop_from_inventory(src)
user.unEquip(src, 1)
del(src)
+19 -14
View File
@@ -384,9 +384,13 @@
user << "<span class='notice'>You try to attach the end of the plastic sword to... itself. You're not very smart, are you?</span>"
if(ishuman(user))
user.adjustBrainLoss(10)
else if((W.flags & NODROP) || (flags & NODROP))
user << "<span class='notice'>\the [flags & NODROP ? src : W] is stuck to your hand, you can't attach it to \the [flags & NODROP ? W : src]!</span>"
else
user << "<span class='notice'>You attach the ends of the two plastic swords, making a single double-bladed toy! You're fake-cool.</span>"
new /obj/item/weapon/twohanded/dualsaber/toy(user.loc)
user.unEquip(W)
user.unEquip(src)
del(W)
del(src)
@@ -703,8 +707,10 @@ obj/item/toy/cards/deck/attackby(obj/item/toy/cards/singlecard/C, mob/living/use
..()
if(istype(C))
if(C.parentdeck == src)
if(!user.unEquip(C))
user << "<span class='notice'>The card is stuck to your hand, you can't add it to the deck!</span>"
return
src.cards += C.cardname
user.u_equip(C)
user.visible_message("<span class='notice'>[user] adds a card to the bottom of the deck.</span>","<span class='notice'>You add the card to the bottom of the deck.</span>")
del(C)
else
@@ -721,8 +727,10 @@ obj/item/toy/cards/deck/attackby(obj/item/toy/cards/cardhand/C, mob/living/user)
..()
if(istype(C))
if(C.parentdeck == src)
if(!user.unEquip(C))
user << "<span class='notice'>The hand of cards is stuck to your hand, you can't add it to the deck!</span>"
return
src.cards += C.currenthand
user.u_equip(C)
user.visible_message("<span class='notice'>[user] puts their hand of cards in the deck.</span>", "<span class='notice'>You put the hand of cards in the deck.</span>")
del(C)
else
@@ -739,22 +747,19 @@ obj/item/toy/cards/deck/MouseDrop(atom/over_object)
if(usr.stat || !ishuman(usr) || !usr.canmove || usr.restrained())
return
if(Adjacent(usr))
if(over_object == M)
if(over_object == M && loc != M)
M.put_in_hands(src)
usr << "<span class='notice'>You pick up the deck.</span>"
else if(istype(over_object, /obj/screen))
switch(over_object.name)
if("r_hand")
M.u_equip(src)
M.put_in_r_hand(src)
usr << "<span class='notice'>You pick up the deck.</span>"
if("l_hand")
M.u_equip(src)
M.put_in_l_hand(src)
usr << "<span class='notice'>You pick up the deck.</span>"
else if("r_hand")
M.put_in_r_hand(src)
usr << "<span class='notice'>You pick up the deck.</span>"
else
usr<< "<span class='notice'>You can't reach it from here.</span>"
usr << "<span class='notice'>You can't reach it from here.</span>"
@@ -814,7 +819,7 @@ obj/item/toy/cards/cardhand/Topic(href, href_list)
N.parentdeck = src.parentdeck
N.cardname = src.currenthand[1]
N.apply_card_vars(N,O)
cardUser.u_equip(src)
cardUser.unEquip(src)
N.pickup(cardUser)
cardUser.put_in_any_hand_if_possible(N)
cardUser << "<span class='notice'>You also take [currenthand[1]] and hold it.</span>"
@@ -826,7 +831,7 @@ obj/item/toy/cards/cardhand/attackby(obj/item/toy/cards/singlecard/C, mob/living
if(istype(C))
if(C.parentdeck == src.parentdeck)
src.currenthand += C.cardname
user.u_equip(C)
user.unEquip(C)
user.visible_message("<span class='notice'>[user] adds a card to their hand.</span>", "<span class='notice'>You add the [C.cardname] to your hand.</span>")
interact(user)
if(currenthand.len > 4)
@@ -902,7 +907,7 @@ obj/item/toy/cards/singlecard/attackby(obj/item/I, mob/living/user)
H.currenthand += src.cardname
H.parentdeck = C.parentdeck
H.apply_card_vars(H,C)
user.u_equip(C)
user.unEquip(C)
H.pickup(user)
user.put_in_active_hand(H)
user << "<span class='notice'>You combine the [C.cardname] and the [src.cardname] into a hand.</span>"
@@ -915,7 +920,7 @@ obj/item/toy/cards/singlecard/attackby(obj/item/I, mob/living/user)
var/obj/item/toy/cards/cardhand/H = I
if(H.parentdeck == parentdeck)
H.currenthand += cardname
user.u_equip(src)
user.unEquip(src)
user.visible_message("<span class='notice'>[user] adds a card to \his hand.</span>", "<span class='notice'>You add the [cardname] to your hand.</span>")
H.interact(user)
if(H.currenthand.len > 4)
@@ -44,11 +44,11 @@
item_state = "chronogun"
icon_override = 'icons/mob/in-hand/guns.dmi'
w_class = 3.0
canremove = 0
projectile_type = "/obj/item/projectile/energy/chrono_beam"
fire_sound = 'sound/weapons/Laser.ogg'
charge_cost = 0
fire_delay = 50
flags = NODROP
var/obj/item/weapon/chrono_eraser/TED = null
var/obj/effect/chrono_field/field = null
var/turf/startpos = null
@@ -137,12 +137,18 @@ CIGARETTE PACKETS ARE IN FANCY.DM
var/datum/effect/effect/system/reagents_explosion/e = new()
e.set_up(round(reagents.get_reagent_amount("plasma") / 2.5, 1), get_turf(src), 0, 0)
e.start()
if(ismob(loc))
var/mob/M = loc
M.unEquip(src, 1)
del(src)
return
if(reagents.get_reagent_amount("fuel")) // the fuel explodes, too, but much less violently
var/datum/effect/effect/system/reagents_explosion/e = new()
e.set_up(round(reagents.get_reagent_amount("fuel") / 5, 1), get_turf(src), 0, 0)
e.start()
if(ismob(loc))
var/mob/M = loc
M.unEquip(src, 1)
del(src)
return
flags &= ~NOREACT // allowing reagents to react after being lit
@@ -193,8 +199,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
if(ismob(loc))
var/mob/living/M = loc
M << "<span class='notice'>Your [name] goes out.</span>"
M.u_equip(src) //un-equip it so the overlays can update
M.update_inv_wear_mask(0)
M.unEquip(src, 1) //Force the un-equip so the overlays update
processing_objects.Remove(src)
del(src)
@@ -524,10 +529,10 @@ obj/item/weapon/rollingpaperpack/attack_self(mob/user)
else if(istype(over_object, /obj/screen))
switch(over_object.name)
if("r_hand")
M.u_equip(src)
M.unEquip(src)
M.put_in_r_hand(src)
if("l_hand")
M.u_equip(src)
M.unEquip(src)
M.put_in_l_hand(src)
/obj/item/weapon/rollingpaperpack/examine()
+3 -3
View File
@@ -160,7 +160,7 @@
/obj/item/weapon/defibrillator/proc/remove_paddles(mob/user)
var/mob/living/carbon/human/M = user
if(paddles in get_both_hands(M))
M.u_equip(paddles)
M.unEquip(paddles)
update_icon()
return
@@ -196,7 +196,7 @@
paddles.cooldown = 0
paddles.update_icon()
update_icon()
/obj/item/weapon/defibrillator/compact
name = "compact defibrillator"
desc = "A belt-equipped defibrillator that can be rapidly deployed."
@@ -292,7 +292,7 @@
/obj/item/weapon/twohanded/shockpaddles/proc/check_defib_exists(mainunit, var/mob/living/carbon/human/M, var/obj/O)
if (!mainunit || !istype(mainunit, /obj/item/weapon/defibrillator)) //To avoid weird issues from admin spawns
M.u_equip(O)
M.unEquip(O)
qdel(O)
return 0
else
@@ -93,7 +93,7 @@
spawn(0)//this prevents the collapse of space-time continuum
if (user)
user.drop_from_inventory(src)
user.unEquip(src)
del(src)
return uses
@@ -109,7 +109,7 @@
if(!ispath(gift_type,/obj/item)) return
var/obj/item/I = new gift_type(M)
M.u_equip(src)
M.unEquip(src, 1)
M.put_in_hands(I)
I.add_fingerprint(M)
del(src)
@@ -49,7 +49,7 @@ var/turf/T
if(istype(I, /obj/item/weapon/screwdriver))
if(fillamt)
var/obj/item/weapon/grenade/bananade/G = new /obj/item/weapon/grenade/bananade
user.before_take_item(src)
user.unEquip(src)
user.put_in_hands(G)
G.deliveryamt = src.fillamt
user << "<span class='notice'>You lock the assembly shut, readying it for HONK.</span>"
@@ -5,8 +5,8 @@
if(istype(I, /obj/item/device/assembly/igniter))
var/obj/item/device/assembly/igniter/G = I
var/obj/item/weapon/grenade/iedcasing/W = new /obj/item/weapon/grenade/iedcasing
user.before_take_item(G)
user.before_take_item(src)
user.unEquip(G)
user.unEquip(src)
user.put_in_hands(W)
user << "<span class='notice'>You stuff the [I] in the [src], emptying the contents beforehand.</span>"
W.underlays += image(src.icon, icon_state = src.icon_state)
@@ -78,7 +78,7 @@
/obj/item/weapon/grenade/proc/update_mob()
if(ismob(loc))
var/mob/M = loc
M.drop_from_inventory(src)
M.unEquip(src)
/obj/item/weapon/grenade/attackby(obj/item/weapon/W as obj, mob/user as mob)
+1 -1
View File
@@ -143,7 +143,7 @@ var/last_chew = 0
var/obj/item/stack/rods/R = I
if (R.use(1))
var/obj/item/weapon/wirerod/W = new /obj/item/weapon/wirerod
user.u_equip(src)
user.unEquip(src)
user.put_in_hands(W)
user << "<span class='notice'>You wrap the cable restraint around the top of the rod.</span>"
del(src)
@@ -145,7 +145,7 @@
user << "\red Something is already scanned inside the implant!"
return
if(user)
user.u_equip(I)
user.unEquip(I)
user.update_icons() //update our overlays
c.scanned = I
c.scanned.loc = c
@@ -208,7 +208,7 @@
break
if(!inserted || !S.amount)
usr.u_equip(S)
usr.unEquip(S)
usr.update_icons() //update our overlays
if (usr.client && usr.s_active != src)
usr.client.screen -= S
@@ -20,10 +20,10 @@
if (!M.restrained() && !M.stat && can_use())
switch(over_object.name)
if("r_hand")
M.u_equip(src)
M.unEquip(src)
M.put_in_r_hand(src)
if("l_hand")
M.u_equip(src)
M.unEquip(src)
M.put_in_l_hand(src)
src.add_fingerprint(usr)
return
@@ -12,7 +12,7 @@
name = "first-aid kit"
desc = "It's an emergency medical kit for those serious boo-boos."
icon_state = "firstaid"
icon_override = 'icons/mob/in-hand/medkits.dmi'
icon_override = 'icons/mob/in-hand/medkits.dmi'
throw_speed = 2
throw_range = 8
var/empty = 0
@@ -154,10 +154,10 @@
if ((!( M.restrained() ) && !( M.stat ) /*&& M.pocket == src*/))
switch(over_object.name)
if("r_hand")
M.u_equip(src)
M.unEquip(src)
M.put_in_r_hand(src)
if("l_hand")
M.u_equip(src)
M.unEquip(src)
M.put_in_l_hand(src)
src.add_fingerprint(usr)
return
@@ -37,19 +37,19 @@
if (!( istype(over_object, /obj/screen) ))
return 1
//makes sure master_item is equipped before putting it in hand, so that we can't drag it into our hand from miles away.
//there's got to be a better way of doing this...
if (!(master_item.loc == user) || (master_item.loc && master_item.loc.loc == user))
if (!(master_item.loc == user) || (master_item.loc && master_item.loc.loc == user))
return 0
if (!( user.restrained() ) && !( user.stat ))
switch(over_object.name)
if("r_hand")
user.u_equip(master_item)
user.unEquip(master_item)
user.put_in_r_hand(master_item)
if("l_hand")
user.u_equip(master_item)
user.unEquip(master_item)
user.put_in_l_hand(master_item)
master_item.add_fingerprint(user)
return 0
@@ -70,12 +70,12 @@
H.put_in_hands(master_item)
H.r_store = null
return 0
src.add_fingerprint(user)
if (master_item.loc == user)
src.open(user)
return 0
for(var/mob/M in range(1, master_item.loc))
if (M.s_active == src)
src.close(M)
@@ -46,10 +46,12 @@
if (!( M.restrained() ) && !( M.stat ))
switch(over_object.name)
if("r_hand")
M.u_equip(src)
if(!M.unEquip(src))
return
M.put_in_r_hand(src)
if("l_hand")
M.u_equip(src)
if(!M.unEquip(src))
return
M.put_in_l_hand(src)
src.add_fingerprint(usr)
return
@@ -250,15 +252,21 @@
usr << "<span class='notice'>[src] cannot hold [W] as it's a storage item of the same size.</span>"
return 0 //To prevent the stacking of same sized storage items.
if(W.flags & NODROP) //SHOULD be handled in unEquip, but better safe than sorry.
usr << "<span class='notice'>\the [W] is stuck to your hand, you can't put it in \the [src]</span>"
return 0
return 1
//This proc handles items being inserted. It does not perform any checks of whether an item can or can't be inserted. That's done by can_be_inserted()
//The stop_warning parameter will stop the insertion message from being displayed. It is intended for cases where you are inserting multiple items at once,
//such as when picking up all the items on a tile with one click.
/obj/item/weapon/storage/proc/handle_item_insertion(obj/item/W as obj, prevent_warning = 0)
if(!istype(W)) return 0
if(!istype(W))
return 0
if(usr)
usr.u_equip(W)
if(!usr.unEquip(W))
return 0
usr.update_icons() //update our overlays
W.loc = src
W.on_enter_storage(src)
@@ -118,7 +118,7 @@
if ((!F.status)||(F.ptank)) return
src.master = F
F.ptank = src
user.before_take_item(src)
user.unEquip(src)
src.loc = F
return
@@ -63,7 +63,7 @@
/obj/item/weapon/watertank/proc/remove_noz(mob/user)
var/mob/living/carbon/human/M = user
if(noz in get_both_hands(M))
M.u_equip(noz)
M.unEquip(noz)
return
/obj/item/weapon/watertank/Destroy()
@@ -108,7 +108,7 @@
/proc/check_tank_exists(parent_tank, var/mob/living/carbon/human/M, var/obj/O)
if (!parent_tank || !istype(parent_tank, /obj/item/weapon/watertank)) //To avoid weird issues from admin spawns
M.u_equip(O)
M.unEquip(O)
qdel(0)
return 0
else
+3 -3
View File
@@ -194,12 +194,12 @@
if (user.client)
user.client.screen -= src
if (user.r_hand == src)
user.u_equip(src)
user.unEquip(src)
else
user.u_equip(src)
user.unEquip(src)
src.master = F
src.layer = initial(src.layer)
user.u_equip(src)
user.unEquip(src)
if (user.client)
user.client.screen -= src
src.loc = F
+4 -4
View File
@@ -170,8 +170,8 @@ obj/item/weapon/wirerod/attackby(var/obj/item/I, mob/user as mob)
if(istype(I, /obj/item/weapon/shard))
var/obj/item/weapon/twohanded/spear/S = new /obj/item/weapon/twohanded/spear
user.u_equip(I)
user.u_equip(src)
user.unEquip(I)
user.unEquip(src)
user.put_in_hands(S)
user << "<span class='notice'>You fasten the glass shard to the top of the rod with the cable.</span>"
@@ -181,8 +181,8 @@ obj/item/weapon/wirerod/attackby(var/obj/item/I, mob/user as mob)
else if(istype(I, /obj/item/weapon/wirecutters))
var/obj/item/weapon/melee/baton/cattleprod/P = new /obj/item/weapon/melee/baton/cattleprod
user.u_equip(I)
user.u_equip(src)
user.unEquip(I)
user.unEquip(src)
user.put_in_hands(P)
user << "<span class='notice'>You fasten the wirecutters to the top of the rod with the cable, prongs outward.</span>"