Makes NODROP work for carbons, adds sanity checks to u_equip calls.

This commit is contained in:
Miauw
2014-02-12 21:08:09 +01:00
parent 8c7ef19be6
commit 1307a9e388
15 changed files with 65 additions and 122 deletions

View File

@@ -61,21 +61,22 @@ STI KALY - blind
if(prob(chance))
if(!istype(H.head, /obj/item/clothing/head/wizard))
if(H.head)
H.u_equip(H.head)
H.u_equip(H.head, 1) //The 1 forces the hat to drop, even if it has nodrop.
H.head = new /obj/item/clothing/head/wizard(H)
H.head.layer = 20
return
if(prob(chance))
if(!istype(H.wear_suit, /obj/item/clothing/suit/wizrobe))
if(H.wear_suit)
H.u_equip(H.wear_suit)
H.u_equip(H.wear_suit, 1)
del H.wear_suit
H.wear_suit = new /obj/item/clothing/suit/wizrobe(H)
H.wear_suit.layer = 20
return
if(prob(chance))
if(!istype(H.shoes, /obj/item/clothing/shoes/sandal))
if(H.shoes)
H.u_equip(H.shoes)
H.u_equip(H.shoes, 1)
H.shoes = new /obj/item/clothing/shoes/sandal(H)
H.shoes.layer = 20
return

View File

@@ -877,7 +877,7 @@ datum/mind
switch(href_list["common"])
if("undress")
for(var/obj/item/W in current)
current.u_equip(W)
current.u_equip(W, 1) //The 1 forces all items to drop, since this is an admin undress.
if("takeuplink")
take_uplink()
memory = null//Remove any memory they may have had.

View File

@@ -35,7 +35,7 @@
magichead.voicechange = 1 //NEEEEIIGHH
target.visible_message( "<span class='danger'>[target]'s face lights up in fire, and after the event a horse's head takes its place!</span>", \
"<span class='danger'>Your face burns up, and shortly after the fire you realise you have the face of a horse!</span>")
target.u_equip(target.wear_mask)
target.u_equip(target.wear_mask, 1) //Wizard spell, so we force the mask to drop. It's not like their situation is gonna get any better.
target.equip_to_slot_if_possible(magichead, slot_wear_mask, 1, 1)
flick("e_flash", target.flash)

View File

@@ -472,10 +472,10 @@
if(istype(user, /mob/living/carbon/human))
user <<"<font size='15' color='red'><b>HOR-SIE HAS RISEN</b></font>"
var/obj/item/clothing/mask/horsehead/magichead = new /obj/item/clothing/mask/horsehead
magichead.canremove = 0 //curses!
magichead.flags |= NODROP //curses!
magichead.flags_inv = null //so you can still see their face
magichead.voicechange = 1 //NEEEEIIGHH
user.u_equip(user.wear_mask)
user.u_equip(user.wear_mask, 1)
user.equip_to_slot_if_possible(magichead, slot_wear_mask, 1, 1)
del(src)
else

View File

@@ -232,7 +232,8 @@ var/global/list/autolathe_recipes_hidden = list( \
flick("autolathe_r",src)//plays glass insertion animation
stack.use(amount)
else
usr.u_equip(O)
if(!user.u_equip(O))
user << "<span class='notice'>/the [O] is stuck to your hand, you put it in \the [src]!</span>"
O.loc = src
icon_state = "autolathe"
busy = 1

View File

@@ -200,8 +200,7 @@
if(isobj(obj))
var/mob/M = obj.loc
if(ismob(M))
M.u_equip(obj)
M.update_icons() //so their overlays update
M.u_equip(obj, 1) //Holoweapons should always drop.
if(!silent)
var/obj/oldobj = obj

View File

@@ -36,8 +36,9 @@
if(ispath(T,/obj/item/weapon/reagent_containers/food/snacks/grown))
if(P.dry == 0)
P.reagents.trans_to(src, P.reagents.total_volume)
user.u_equip(I)
user << "You add the [I] to the drying rack."
if(!user.u_equip(I))
user << "<span class='notice'>\the [I] is stuck to your hand, you cannot put it in \the [src]</span>"
user << "<span class='notice'>You add the [I] to the drying rack.</span class='notice'>"
del(I)
src.running = 1
use_power = 2
@@ -56,8 +57,9 @@
else
user << "<span class='warning'>That has already been dried.</span>"
else
user.u_equip(I)
user << "You add [I] to the drying rack."
if(!user.u_equip(I))
user << "<span class='notice'>\the [I] is stuck to your hand, you cannot put it in \the [src]</span>"
user << "<span class='notice'>You add the [I] to the drying rack.</span class='notice'>"
del(I)
src.running = 1
use_power = 2
@@ -69,8 +71,9 @@
src.running = 0
else
var/N = S.dried_type
user.u_equip(I)
user << "You add [I] to the drying rack."
if(!user.u_equip(I))
user << "<span class='notice'>\the [I] is stuck to your hand, you cannot put it in \the [src]</span>"
user << "<span class='notice'>You add the [I] to the drying rack.</span class='notice'>"
del(I)
src.running = 1
use_power = 2

View File

@@ -40,7 +40,9 @@
if (beaker)
return 1
else
user.u_equip(O)
if(!user.u_equip(O))
user << "<span class='notice'>\the [O] is stuck to your hand, you cannot put it in \the [src]</span>"
return 0
O.loc = src
beaker = O
src.verbs += /obj/machinery/juicer/verb/detach
@@ -50,7 +52,9 @@
if (!is_type_in_list(O, allowed_items))
user << "It looks as not containing any juice."
return 1
user.u_equip(O)
if(!user.u_equip(O))
user << "<span class='notice'>\the [O] is stuck to your hand, you cannot put it in \the [src]</span>"
return 0
O.loc = src
src.updateUsrDialog()
return 0

View File

@@ -147,7 +147,9 @@
"\blue You add one of [O] to \the [src].")
else
// user.u_equip(O) //This just causes problems so far as I can tell. -Pete
user.drop_item()
if(!user.drop_item())
user << "<span class='notice'>\the [O] is stuck to your hand, you cannot put it in \the [src]</span>"
return 0
O.loc = src
user.visible_message( \
"\blue [user] has added \the [O] to \the [src].", \

View File

@@ -101,7 +101,9 @@
/obj/machinery/smartfridge/proc/load(var/obj/item/O as obj)
if(istype(O.loc,/mob))
var/mob/M = O.loc
M.u_equip(O)
if(!M.u_equip(O))
user << "<span class='notice'>\the [O] is stuck to your hand, you cannot put it in \the [src]</span>"
return
else if(istype(O.loc,/obj/item/weapon/storage))
var/obj/item/weapon/storage/S = O.loc
S.remove_from_storage(O,src)

View File

@@ -650,14 +650,15 @@
if(1)
if(istype(I, /obj/item/stack/sheet/metal))
if(I:amount>=2) //requires 2 metal sheets
var/obj/item/stack/sheet/metal/M = I
if(M.amount>=2) //requires 2 metal sheets
user << "<span class='notice'>You add some metal armor to the interior frame.</span>"
build_step = 2
I:amount -= 2
M:amount -= 2
icon_state = "turret_frame2"
if(I:amount <= 0)
user.u_equip(I)
del(I)
if(M.amount <= 0)
user.u_equip(M, 1) //We're deleting it anyway, so no point in having NODROP fuck shit up.
del(M)
else
user << "<span class='warning'>You need two sheets of metal for that.</span>"
return
@@ -704,7 +705,9 @@
gun_charge = E.power_supply.charge //the gun's charge is stored in gun_charge
user << "<span class='notice'>You add [I] to the turret.</span>"
build_step = 4
user.u_equip(I)
if(!user.u_equip(I))
user << "<span class='notice'>\the [I] is stuck to your hand, you cannot put it in \the [src]</span>"
return
del(I) //delete the gun :(
return
@@ -718,7 +721,9 @@
if(isprox(I))
build_step = 5
user << "<span class='notice'>You add the prox sensor to the turret.</span>"
user.u_equip(I)
if(!user.u_equip(I))
user << "<span class='notice'>\the [I] is stuck to your hand, you cannot put it in \the [src]</span>"
return
del(I)
return
@@ -735,13 +740,14 @@
if(6)
if(istype(I, /obj/item/stack/sheet/metal))
if(I:amount>=2)
var/obj/item/stack/sheet/metal/M = I
if(M.amount>=2)
user << "<span class='notice'>You add some metal armor to the exterior frame.</span>"
build_step = 7
I:amount -= 2
if(I:amount <= 0)
user.u_equip(I)
del(I)
M.amount -= 2
if(M.amount <= 0)
user.u_equip(M, 1)
del(M)
else
user << "<span class='warning'>You need two sheets of metal for that.</span>"
return

View File

@@ -97,13 +97,11 @@
//Here lie drop_from_inventory and before_item_take, already forgotten and not missed.
/mob/proc/u_equip(obj/item/I)
/mob/proc/u_equip(obj/item/I, force) //Force overrides NODROP for things like wizarditis and admin undress.
if(!I) //If there's nothing to drop, the drop is automatically succesfull. If(u_equip) should generally be used to check for NODROP.
world << "nothing here u fage"
return 1
if(I.flags & NODROP)
world << "cant drop this fucking shit"
if((I.flags & NODROP) && !force)
return 0
if(I == r_hand)
@@ -120,7 +118,6 @@
I.dropped(src)
if(I)
I.layer = initial(I.layer)
world << "grats u did it m8 u happy now hahaha"
return 1

View File

@@ -1,31 +1,14 @@
/mob/living/carbon/alien/humanoid/u_equip(obj/item/I)
if(!I) return 0
. = ..()
if(!.)
return
var/success = 1
if(I == r_hand)
r_hand = null
update_inv_r_hand(0)
else if(I == l_hand)
l_hand = null
update_inv_l_hand(0)
else if(I == r_store)
if(I == r_store)
r_store = null
update_inv_pockets(0)
else if(I == l_store)
l_store = null
update_inv_pockets(0)
else
success = 0
if(success)
if(I)
if(client)
client.screen -= I
I.loc = loc
I.dropped(src)
if(I)
I.layer = initial(I.layer)
//yaaaaaaay snowflakes

View File

@@ -414,19 +414,17 @@
return
/mob/living/carbon/u_equip(obj/item/I)
if(!I) return 0
/mob/living/carbon/u_equip(obj/item/I) //THIS PROC DID NOT CALL ..() AND THAT COST ME AN ENTIRE DAY OF DEBUGGING.
. = ..() //Sets the default return value to what the parent returns.
if(!.) //We don't want to set anything to null if the parent returned 0.
return
if(I == r_hand)
r_hand = null
update_inv_r_hand(0)
else if(I == l_hand)
l_hand = null
update_inv_l_hand(0)
if(I == back)
back = null
update_inv_back(0)
else if(I == wear_mask)
if(istype(src, /mob/living/carbon/human)) //If we don't do this hair won't be properly rebuilt.
return
wear_mask = null
update_inv_wear_mask(0)
else if(I == handcuffed)
@@ -436,14 +434,6 @@
legcuffed = null
update_inv_legcuffed(0)
if(I)
if(client)
client.screen -= I
I.loc = loc
I.dropped(src)
if(I)
I.layer = initial(I.layer)
/mob/living/carbon/proc/get_temperature(var/datum/gas_mixture/environment)
var/loc_temp = T0C

View File

@@ -82,15 +82,14 @@
/mob/living/carbon/human/u_equip(obj/item/I)
if(!I) return 0
. = ..() //See mob.dm for an explanation on this and some rage about people copypasting instead of calling ..() like they should.
if(!.)
return
var/success = 0
if(I == wear_suit)
if(s_store)
u_equip(s_store)
if(I)
success = 1
wear_suit = null
update_inv_wear_suit(0)
else if(I == w_uniform)
@@ -103,37 +102,29 @@
if(belt)
u_equip(belt)
w_uniform = null
success = 1
update_inv_w_uniform(0)
else if(I == gloves)
gloves = null
success = 1
update_inv_gloves(0)
else if(I == glasses)
glasses = null
success = 1
update_inv_glasses(0)
else if(I == head)
head = null
if(I.flags & BLOCKHAIR)
update_hair(0) //rebuild hair
success = 1
update_inv_head(0)
else if(I == ears)
ears = null
success = 1
update_inv_ears(0)
else if(I == shoes)
shoes = null
success = 1
update_inv_shoes(0)
else if(I == belt)
belt = null
success = 1
update_inv_belt(0)
else if(I == wear_mask)
wear_mask = null
success = 1
if(I.flags & BLOCKHAIR)
update_hair(0) //rebuild hair
if(internal)
@@ -143,54 +134,18 @@
update_inv_wear_mask(0)
else if(I == wear_id)
wear_id = null
success = 1
update_inv_wear_id(0)
else if(I == r_store)
r_store = null
success = 1
update_inv_pockets(0)
else if(I == l_store)
l_store = null
success = 1
update_inv_pockets(0)
else if(I == s_store)
s_store = null
success = 1
update_inv_s_store(0)
else if(I == back)
back = null
success = 1
update_inv_back(0)
else if(I == handcuffed)
handcuffed = null
success = 1
update_inv_handcuffed(0)
else if(I == legcuffed)
legcuffed = null
success = 1
update_inv_legcuffed(0)
else if(I == r_hand)
r_hand = null
success = 1
update_inv_r_hand(0)
else if(I == l_hand)
l_hand = null
success = 1
update_inv_l_hand(0)
else
return 0
if(success)
if(I)
if(client)
client.screen -= I
I.loc = loc
I.dropped(src)
if(I)
I.layer = initial(I.layer)
update_action_buttons()
return 1
//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()