Merge pull request #4019 from Ccomp5950/internals_hud_fix

Bugfix:  Internals HUD click action.
This commit is contained in:
Chinsky
2013-12-05 02:54:28 -08:00
4 changed files with 75 additions and 27 deletions
+66 -24
View File
@@ -276,37 +276,79 @@
C << "<span class='notice'>You are not wearing a mask.</span>"
return 1
else
if(istype(C.l_hand, /obj/item/weapon/tank))
C << "<span class='notice'>You are now running on internals from the [C.l_hand] on your left hand.</span>"
C.internal = C.l_hand
else if(istype(C.r_hand, /obj/item/weapon/tank))
C << "<span class='notice'>You are now running on internals from the [C.r_hand] on your right hand.</span>"
C.internal = C.r_hand
else if(ishuman(C))
var/list/nicename = null
var/list/tankcheck = null
var/breathes = "oxygen" //default, we'll check later
var/list/contents = list()
if(ishuman(C))
var/mob/living/carbon/human/H = C
if(istype(H.s_store, /obj/item/weapon/tank))
H << "<span class='notice'>You are now running on internals from the [H.s_store] on your [H.wear_suit].</span>"
H.internal = H.s_store
else if(istype(H.belt, /obj/item/weapon/tank))
H << "<span class='notice'>You are now running on internals from the [H.belt] on your belt.</span>"
H.internal = H.belt
else if(istype(H.l_store, /obj/item/weapon/tank))
H << "<span class='notice'>You are now running on internals from the [H.l_store] in your left pocket.</span>"
H.internal = H.l_store
else if(istype(H.r_store, /obj/item/weapon/tank))
H << "<span class='notice'>You are now running on internals from the [H.r_store] in your right pocket.</span>"
H.internal = H.r_store
breathes = H.species.breath_type
nicename = list ("suit", "back", "belt", "right hand", "left hand", "left pocket", "right pocket")
tankcheck = list (H.s_store, C.back, H.belt, C.r_hand, C.l_hand, H.l_store, H.r_store)
//Seperate so CO2 jetpacks are a little less cumbersome.
if(!C.internal && istype(C.back, /obj/item/weapon/tank))
C << "<span class='notice'>You are now running on internals from the [C.back] on your back.</span>"
C.internal = C.back
else
nicename = list("Right Hand", "Left Hand", "Back")
tankcheck = list(C.r_hand, C.l_hand, C.back)
for(var/i=1, i<tankcheck.len+1, ++i)
if(istype(tankcheck[i], /obj/item/weapon/tank))
var/obj/item/weapon/tank/t = tankcheck[i]
if (!isnull(t.manipulated_by) && t.manipulated_by != C.real_name && findtext(t.desc,breathes))
contents.Add(t.air_contents.total_moles) //Someone messed with the tank and put unknown gasses
continue //in it, so we're going to believe the tank is what it says it is
switch(breathes)
//These tanks we're sure of their contents
if("nitrogen") //So we're a bit more picky about them.
if(t.air_contents.nitrogen && !t.air_contents.oxygen)
contents.Add(t.air_contents.nitrogen)
else
contents.Add(0)
if ("oxygen")
if(t.air_contents.oxygen && !t.air_contents.toxins)
contents.Add(t.air_contents.oxygen)
else
contents.Add(0)
// No races breath this, but never know about downstream servers.
if ("carbon dioxide")
if(t.air_contents.carbon_dioxide && !t.air_contents.toxins)
contents.Add(t.air_contents.carbon_dioxide)
else
contents.Add(0)
else
//no tank so we set contents to 0
contents.Add(0)
//Alright now we know the contents of the tanks so we have to pick the best one.
var/best = 0
var/bestcontents = 0
for(var/i=1, i < contents.len + 1 , ++i)
if(!contents[i])
continue
if(contents[i] > bestcontents)
best = i
bestcontents = contents[i]
//We've determined the best container now we set it as our internals
if(best)
C << "<span class='notice'>You are now running on internals from [tankcheck[best]] on your [nicename[best]].</span>"
C.internal = tankcheck[best]
if(C.internal)
if(C.internals)
C.internals.icon_state = "internal1"
else
C << "<span class='notice'>You don't have an oxygen tank.</span>"
C << "<span class='notice'>You don't have a[breathes=="oxygen" ? "n oxygen" : addtext(" ",breathes)] tank.</span>"
if("act_intent")
usr.a_intent_change("right")
if("help")
@@ -255,6 +255,8 @@ Release Pressure: <A href='?src=\ref[src];pressure_adj=-1000'>-</A> <A href='?sr
if (href_list["remove_tank"])
if(holding)
if(istype(holding, /obj/item/weapon/tank))
holding.manipulated_by = usr.real_name
holding.loc = loc
holding = null
@@ -1042,6 +1042,9 @@ var/global/list/obj/item/device/pda/PDAs = list()
if(5)
if((istype(A, /obj/item/weapon/tank)) || (istype(A, /obj/machinery/portable_atmospherics)))
if(istype(A, /obj/item/weapon/tank))
var/obj/item/weapon/tank/t = A
t.manipulated_by = user.real_name
var/obj/icon = A
for (var/mob/O in viewers(user, null))
O << "\red [user] has used [src] on \icon[icon] [A]"
@@ -15,7 +15,8 @@
var/distribute_pressure = ONE_ATMOSPHERE
var/integrity = 3
var/volume = 70
var/manipulated_by = null //Used by _onclick/hud/screen_objects.dm internals to determine if someone has messed with our tank or not.
//If they have and we haven't scanned it with the PDA or gas analyzer then we might just breath whatever they put in it.
/obj/item/weapon/tank/New()
..()
@@ -86,7 +87,7 @@
O << "\red [user] has used [W] on \icon[icon] [src]"
var/pressure = air_contents.return_pressure()
manipulated_by = user.real_name //This person is aware of the contents of the tank.
var/total_moles = air_contents.total_moles()
user << "\blue Results of analysis of \icon[icon]"
@@ -261,4 +262,4 @@
integrity--
else if(integrity < 3)
integrity++
integrity++