Bugfix: Internals HUD click action.

Before:  If you had a tank on your back full of nice precious oxygen, and a tank of plasma in your hand and thought "I'll play it safe and turn on internals" and click the internals icon you would start sucking down plasma like you weren't really qualified to handle such things, how do you even get those two mixed up you big dummy!  Code was hardcoded junk.

After:  A check of what your species prefers to breath, you are an adult, I'm pretty sure you can remember if the tank on your back is oxygen or not, and you will turn on the fullest tank.
Code is now nolonger hardcoded junk, and is expandable by editing a couple of variables instead of hardcoding everything.  Double Rainbow, All The Way Across The Sky!

Also coded in a check for "Carbon Dioxide" in the event a downstream server uses a race that breathes that or we move dionaea to breathing it in the future.
This commit is contained in:
Ccomp5950
2013-12-03 00:06:08 -06:00
parent 47c5261ade
commit af11500762

View File

@@ -276,37 +276,74 @@
C << "<span class='notice'>You are not wearing a mask.</span>" C << "<span class='notice'>You are not wearing a mask.</span>"
return 1 return 1
else else
if(istype(C.l_hand, /obj/item/weapon/tank)) var/list/nicename = null
C << "<span class='notice'>You are now running on internals from the [C.l_hand] on your left hand.</span>" var/list/tankcheck = null
C.internal = C.l_hand var/breathes = "oxygen" //default, we'll check later
else if(istype(C.r_hand, /obj/item/weapon/tank)) var/list/contents = list()
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 if(ishuman(C))
else if(ishuman(C))
var/mob/living/carbon/human/H = C var/mob/living/carbon/human/H = C
if(istype(H.s_store, /obj/item/weapon/tank)) breathes = H.species.breath_type
H << "<span class='notice'>You are now running on internals from the [H.s_store] on your [H.wear_suit].</span>" nicename = list ("suit", "back", "belt", "right hand", "left hand", "left pocket", "right pocket")
H.internal = H.s_store tankcheck = list (H.s_store, C.back, H.belt, C.r_hand, C.l_hand, H.l_store, H.r_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
//Seperate so CO2 jetpacks are a little less cumbersome. else
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
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]
switch(breathes)
if("nitrogen")
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.internal)
if(C.internals) if(C.internals)
C.internals.icon_state = "internal1" C.internals.icon_state = "internal1"
else 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") if("act_intent")
usr.a_intent_change("right") usr.a_intent_change("right")
if("help") if("help")