From c82f66110261cd2c4f1053b4069045394881d4d6 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Wed, 20 May 2015 14:53:37 -0700 Subject: [PATCH 1/2] Refactor, Light colors for Spacepods. This commit makes a major refactor to spacepod code, mostly just cleaning up the huge mess I left behind with the two-seater code. This commit also adds a small feature: Based on their icon_state, spacepods will have different headlight colors. --- code/game/vehicles/spacepods/spacepod.dm | 368 ++++++++--------------- 1 file changed, 132 insertions(+), 236 deletions(-) diff --git a/code/game/vehicles/spacepods/spacepod.dm b/code/game/vehicles/spacepods/spacepod.dm index d7a070bd49c..20c830cfa06 100644 --- a/code/game/vehicles/spacepods/spacepod.dm +++ b/code/game/vehicles/spacepods/spacepod.dm @@ -7,30 +7,48 @@ icon = 'icons/48x48/pods.dmi' density = 1 //Dense. To raise the heat. opacity = 0 + anchored = 1 unacidable = 1 + layer = 3.9 infra_luminosity = 15 + var/mob/living/carbon/occupant var/mob/living/carbon/occupant2 //two seaters + var/datum/spacepod/equipment/equipment_system + var/battery_type = "/obj/item/weapon/stock_parts/cell/high" var/obj/item/weapon/stock_parts/cell/battery + var/datum/gas_mixture/cabin_air var/obj/machinery/portable_atmospherics/canister/internal_tank - var/datum/effect/effect/system/ion_trail_follow/space_trail/ion_trail var/use_internal_tank = 0 var/datum/global_iterator/pr_int_temp_processor //normalizes internal air mixture temperature var/datum/global_iterator/pr_give_air //moves air from tank to cabin + + var/datum/effect/effect/system/ion_trail_follow/space_trail/ion_trail var/inertia_dir = 0 + var/hatch_open = 0 + var/next_firetime = 0 + var/list/pod_overlays var/health = 250 + var/empcounter = 0 //Used for disabling movement when hit by an EMP + var/lights = 0 var/lights_power = 6 + var/list/icon_light_color = list("pod_civ" = LIGHT_COLOR_WHITE, \ + "pod_mil" = "#BBF093", \ + "pod_synd" = LIGHT_COLOR_RED, \ + "pod_gold" = LIGHT_COLOR_WHITE, \ + "pod_black" = "#3B8FE5", \ + "pod_industrial" = "#CCCC00") + var/allow2enter = 1 - var/empcounter = 0 //Used for disabling movement when hit by an EMP /obj/spacepod/New() . = ..() @@ -77,6 +95,8 @@ if(health <= round(initial(health)/4)) overlays += pod_overlays[FIRE] + light_color = icon_light_color[src.icon_state] + /obj/spacepod/bullet_act(var/obj/item/projectile/P) if(P.damage && !P.nodamage) deal_damage(P.damage) @@ -101,7 +121,7 @@ user.changeNext_move(CLICK_CD_MELEE) deal_damage(15) playsound(src.loc, 'sound/weapons/slash.ogg', 50, 1, -1) - user << "\red You slash at the armored suit!" + user << "\red You slash at \the [src]!" visible_message("\red The [user] slashes at [src.name]'s armor!") return @@ -127,19 +147,16 @@ occupant2 << S if(!health) spawn(0) - if(occupant) - if(occupant2) - occupant2 << "Critical damage to the vessel detected, core explosion imminent!" - occupant << "Critical damage to the vessel detected, core explosion imminent!" - for(var/i = 10, i >= 0; --i) - if(occupant) - occupant << "[i]" - if(occupant2) - occupant2 << "[i]" - if(i == 0) - explosion(loc, 2, 4, 8) - qdel(src) - sleep(10) + if(occupant) occupant << "Critical damage to the vessel detected, core explosion imminent!" + if(occupant2) occupant2 << "Critical damage to the vessel detected, core explosion imminent!" + + for(var/i = 10, i >= 0; --i) + if(occupant) occupant << "[i]" + if(occupant2) occupant2 << "[i]" + if(i == 0) + explosion(loc, 2, 4, 8) + qdel(src) + sleep(10) update_icons() @@ -173,10 +190,8 @@ /obj/spacepod/emp_act(severity) switch(severity) if(1) - if(src.occupant) - src.occupant << "The pod console flashes 'Heavy EMP WAVE DETECTED'." //warn the occupants - if(src.occupant2) - src.occupant2 << "The pod console flashes 'EMP WAVE DETECTED'." //warn the occupants + if(src.occupant) src.occupant << "The pod console flashes 'Heavy EMP WAVE DETECTED'." //warn the occupants + if(src.occupant2) src.occupant2 << "The pod console flashes 'Heavy EMP WAVE DETECTED'." //warn the occupants if(battery) battery.charge = max(0, battery.charge - 5000) //Cell EMP act is too weak, this pod needs to be sapped. @@ -186,10 +201,8 @@ processing_objects.Add(src) if(2) - if(src.occupant) - src.occupant << "The pod console flashes 'EMP WAVE DETECTED'." //warn the occupants - if(src.occupant2) - src.occupant2 << "The pod console flashes 'EMP WAVE DETECTED'." //warn the occupants + if(src.occupant) src.occupant << "The pod console flashes 'EMP WAVE DETECTED'." //warn the occupants + if(src.occupant2) src.occupant2 << "The pod console flashes 'EMP WAVE DETECTED'." //warn the occupants src.deal_damage(40) if(battery) @@ -198,8 +211,6 @@ src.empcounter = 20 //Disable movement for 20 ticks. processing_objects.Add(src) - - /obj/spacepod/attackby(obj/item/W as obj, mob/user as mob, params) if(iscrowbar(W)) hatch_open = !hatch_open @@ -331,6 +342,7 @@ /obj/spacepod/civilian icon_state = "pod_civ" desc = "A sleek civilian space pod." + /obj/spacepod/random icon_state = "pod_civ" // placeholder @@ -370,6 +382,7 @@ desc = "A civilian space pod with a gold body, must have cost somebody a pretty penny" if("pod_industrial") desc = "A rough looking space pod meant for industrial work" + update_icons() /obj/spacepod/verb/toggle_internal_tank() set name = "Toggle internal airtank usage" @@ -446,50 +459,26 @@ return if(src.occupant && !src.occupant2) - if(src.occupant.ckey == H.ckey) + if(src.occupant == H) H.visible_message("You climb over the console and drop down into the secondary seat.") - H.reset_view(src) - /* - H.client.perspective = EYE_PERSPECTIVE - H.client.eye = src - */ - H.stop_pulling() - H.forceMove(src) - src.occupant = null - src.occupant2 = H - src.add_fingerprint(H) - src.forceMove(src.loc) - //dir = dir_in - playsound(src, 'sound/machines/windowdoor.ogg', 50, 1) - return 1 - else - H.reset_view(src) - /* - H.client.perspective = EYE_PERSPECTIVE - H.client.eye = src - */ - H.stop_pulling() - H.forceMove(src) - src.occupant2 = H - src.add_fingerprint(H) - src.forceMove(src.loc) - //dir = dir_in - playsound(src, 'sound/machines/windowdoor.ogg', 50, 1) - return 1 + H.reset_view(src) + H.stop_pulling() + H.forceMove(src) + if(src.occupant == H) occupant = null + src.occupant2 = H + src.add_fingerprint(H) + src.forceMove(src.loc) + playsound(src, 'sound/machines/windowdoor.ogg', 50, 1) + return 1 else if(!src.occupant) H.reset_view(src) - /* - H.client.perspective = EYE_PERSPECTIVE - H.client.eye = src - */ H.stop_pulling() H.forceMove(src) src.occupant = H src.add_fingerprint(H) src.forceMove(src.loc) - //dir = dir_in playsound(src, 'sound/machines/windowdoor.ogg', 50, 1) return 1 else @@ -513,203 +502,119 @@ /obj/spacepod/MouseDrop_T(mob/M as mob, mob/user as mob) if(!isliving(M)) return - if(M != user) - if(M.stat != 0) - if(allow2enter) - if(!src.occupant2) - visible_message("\red [user.name] starts loading [M.name] into the pod!") - sleep(10) - moved_other_inside(M) - else if(src.occupant2 && !src.occupant) - usr << "\red You can't put a corpse into the driver's seat!" - return - else + + if(M != user && M.stat == DEAD && allow2enter) + if(src.occupant2 && !src.occupant) + usr << "You can't put a corpse into the driver's seat!" return - else - move_inside(M, user) + if(!src.occupant2) + visible_message("[user.name] starts loading [M.name] into the pod!") + sleep(10) + moved_other_inside(M) + + if(M == user) + move_inside(user) -/obj/spacepod/verb/move_inside() +/obj/spacepod/verb/move_inside(var/mob/user) set category = "Object" set name = "Enter Pod" set src in oview(1) var/fukkendisk = usr.GetTypeInAllContents(/obj/item/weapon/disk/nuclear) - if(usr.restrained() || usr.stat || usr.weakened || usr.stunned || usr.paralysis || usr.resting) //are you cuffed, dying, lying, stunned or other - return - - if (usr.stat || !ishuman(usr)) + if(user.restrained() || user.stat || user.weakened || user.stunned || user.paralysis || user.resting) //are you cuffed, dying, lying, stunned or other return + if (!ishuman(user)) return if(fukkendisk) - usr << "\red The nuke-disk is locking the door every time you try to open it. You get the feeling that it doesn't want to go into the spacepod." + user << "The nuke-disk is locking the door every time you try to open it. You get the feeling that it doesn't want to go into the spacepod." return - for(var/mob/living/carbon/slime/M in range(1,usr)) - if(M.Victim == usr) - usr << "You're too busy getting your life sucked out of you." + for(var/mob/living/carbon/slime/S in range(1,usr)) + if(S.Victim == user) + user << "You're too busy getting your life sucked out of you." return - if(src.occupant) - if(allow2enter) - if(!src.occupant2) - usr << "\blue You start climbing into the secondary seat." - visible_message("\blue [usr] starts to climb into [src.name].") - if(enter_after(40,usr)) - moved_inside(usr) - else - usr << "You stop entering the spacepod." - return - else - usr << "\red You can't fit!" - else - usr << "\red The door is locked!" + try_user_enter(user) - else if(!src.occupant && src.occupant2) - if(allow2enter) - usr << "\blue You start climbing into the primary seat." - visible_message("\blue [usr] starts to climb into [src.name].") - if(enter_after(40,usr)) - moved_inside(usr) - else - usr << "You stop entering the spacepod." - return - else - usr << "\red The door is locked!" - - else if(!src.occupant && !src.occupant2) - visible_message("\blue [usr] starts to climb into [src.name].") - if(enter_after(40,usr)) +/obj/spacepod/proc/try_user_enter(var/mob/user) + if(!src.occupant && !src.occupant2) + visible_message("[user] starts to climb into [src.name]") + if(enter_after(40,user)) if(!src.occupant) - moved_inside(usr) - else if(src.occupant!=usr) - usr << "[src.occupant] was faster. Try better next time, loser." - else - usr << "You stop entering the spacepod." + moved_inside(user) + else if(src.occupant != user) + user << "[src.occupant] was faster. Try better next time, loser." + else user << "You stop entering the spacepod." return - -/* !!OLD BROKEN SYSTEM!! - tiger - -/obj/spacepod/verb/move_inside() - set category = "Object" - set name = "Enter Pod" - set src in oview(1) - var/fukkendisk = usr.GetTypeInAllContents(/obj/item/weapon/disk/nuclear) - - if(fukkendisk) - usr << "\red The nuke-disk is locking the door every time you try to open it. You get the feeling that it doesn't want to go into the spacepod." + if(!allow2enter) + user << "The door is locked!" return - if(usr.restrained() || usr.stat || usr.weakened || usr.stunned || usr.paralysis || usr.resting) //are you cuffed, dying, lying, stunned or other - return - if (usr.stat || !ishuman(usr)) + if(occupant && occupant2) + user << "You can't fit in \the [src], it's full!" return - if (src.occupant) - if(allow2enter) - if(src.occupant2) - usr << "\blue You can't fit!You starts climbing into the secondary seat." - visible_message("\blue [usr] starts to climb into [src.name]") - if(enter_after(40,usr)) - moved_inside(usr) - else - usr << "You stop entering the spacepod." - return - else - usr << "\red The [src.name]'s doors are locked." - return + if(occupant && !occupant2) + user << "You start climbing into the passenger bay." + user_enter(user) - if(src.occupant2) - if(src.occupant) - usr << "\red The spacepod is full! Are you going to sit on [src.occupant2.name]'s lap?" - return - else - for(var/mob/living/carbon/slime/M in range(1,usr)) - if(M.Victim == usr) - usr << "You're too busy getting your life sucked out of you." - return - // usr << "You start climbing into [src.name]" + if(!occupant && occupant2) + user << "You start climbing into the pilot's seat." + user_enter(user) - visible_message("\blue [usr] starts to climb into [src.name]") - - if(enter_after(40,usr)) - if(!src.occupant) - moved_inside(usr) - else if(src.occupant!=usr) - usr << "[src.occupant] was faster. Try better next time, loser." - else - usr << "You stop entering the exosuit." - return -/* - if (usr.abiotic()) - usr << "\blue Subject cannot have abiotic items on." - return -*/ - for(var/mob/living/carbon/slime/M in range(1,usr)) - if(M.Victim == usr) - usr << "You're too busy getting your life sucked out of you." - return -// usr << "You start climbing into [src.name]" - - visible_message("\blue [usr] starts to climb into [src.name]") - - if(enter_after(40,usr)) - if(!src.occupant) - moved_inside(usr) - else if(src.occupant!=usr) - usr << "[src.occupant] was faster. Try better next time, loser." +/obj/spacepod/proc/user_enter(var/mob/user) + visible_message("[user] starts to climb into \the [src.name].") + if(enter_after(40,user)) + moved_inside(user) else - usr << "You stop entering the exosuit." - return - -*/ + user << "You stop entering the spacepod." /obj/spacepod/verb/exit_pod() set name = "Exit pod" set category = "Spacepod" set src = usr.loc - if(CheckIfOccupant2(usr)) - if(src.occupant) - src.occupant.visible_message("[src.occupant2.name] climbs out of the pod!") //Inform the remaining occupant that someone ejected. - inertia_dir = 0 // engage reverse thruster and power down pod - src.occupant2.loc = src.loc - src.occupant2 = null - usr << "You climb out of the pod." + var/mob/user = usr + var/spos = 0 + if(!ismob(user)) return - else - if(src.occupant2) - src.occupant2.visible_message("[src.occupant2.name] climbs out of the pod!") //Inform the remaining occupant that someone ejected. - inertia_dir = 0 // engage reverse thruster and power down pod - src.occupant.loc = src.loc - src.occupant = null - usr << "You climb out of the pod." - return + if(occupant == user) spos = 1 + if(occupant2 == user) spos = 2 + + switch(spos) + if(0) return + if(1) + if(occupant2) occupant2 << "[occupant.name] climbs out of the pod!" + occupant.loc = src.loc + occupant = null + user << "You climb out of \the [src]." + if(2) + if(occupant) occupant << "[occupant2.name] climbs out of the pod!" + occupant2.loc = src.loc + occupant2 = null + user << "You climb out of \the [src]." /obj/spacepod/verb/exit_pod2() - if(!src.occupant2) - set hidden = 1 + set name = "Eject Secondary Seat" + set category = "Spacepod" + set src = usr.loc + + if(!occupant2) + usr << "There is no one in the second seat." return - else - set name = "Eject Secondary Seat" - set category = "Spacepod" - set src = usr.loc - set hidden = 0 - - if(usr == src.occupant2) - usr << "Use 'Exit Pod'" - return - else - usr << "You eject [src.occupant2.name]." - src.occupant2.visible_message("You were ejected from the pod!") - inertia_dir = 0 // engage reverse thruster and power down pod - src.occupant2.loc = src.loc - src.occupant2 = null + if(usr == occupant2) + usr << "How do you plan to do that? The eject button is out of reach." + return + if(usr == occupant) + usr << "You eject [occupant2.name]." + occupant2 << "\The [src] ejects you forcefully!" + inertia_dir = 0 + occupant2.loc = src.loc + occupant2 = null /obj/spacepod/verb/locksecondseat() set name = "Lock Doors" @@ -718,18 +623,12 @@ if(CheckIfOccupant2(usr)) if(!allow2enter) - usr << "You can't unlock the doors from your seat." - return - else - usr << "You can't lock the doors from your seat." + usr << "You can't [allow2enter ? "lock" : "unlock"] the doors from your seat." return - if(src.allow2enter) - src.allow2enter = 0 - usr << "You lock the doors." - else - src.allow2enter = 1 - usr << "You unlock the doors." + allow2enter = !allow2enter + usr << "You [allow2enter ? "unlock" : "lock"] the doors." + /obj/spacepod/verb/toggleDoors() set name = "Toggle Nearby Pod Doors" @@ -779,10 +678,10 @@ obj/spacepod/verb/toggleLights() /obj/spacepod/proc/lightsToggle() lights = !lights if(lights) - set_light(luminosity + lights_power) + set_light(lights_power) else - set_light(luminosity - lights_power) - occupant << "Toggled lights [lights?"on":"off"]." + set_light(0) + occupant << "Toggled lights [lights ? "on" : "off"]." return /obj/spacepod/proc/enter_after(delay as num, var/mob/user as mob, var/numticks = 5) @@ -843,6 +742,7 @@ obj/spacepod/verb/toggleLights() ..() if(dir == 1 || dir == 4) src.loc.Entered(src) + /obj/spacepod/proc/Process_Spacemove(var/check_drift = 0, mob/user) var/dense_object = 0 if(!user) @@ -861,9 +761,6 @@ obj/spacepod/verb/toggleLights() if(!CheckIfOccupant2(user)) handlerelaymove(user, direction) - else - return - /obj/spacepod/proc/handlerelaymove(mob/user, direction) var/moveship = 1 if(battery && battery.charge >= 3 && health && empcounter == 0) @@ -912,7 +809,6 @@ obj/spacepod/verb/toggleLights() else return 0 - /obj/effect/landmark/spacepod/random name = "spacepod spawner" invisibility = 101 From 367812c77d48086d608bf407154f674644d429cc Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Wed, 20 May 2015 15:31:46 -0700 Subject: [PATCH 2/2] Spacepod: loc = -> forceMove() This commit changes a few "loc =" definitions in spacepod code that should really be forceMove() as forceMove() --- code/game/vehicles/spacepods/spacepod.dm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/code/game/vehicles/spacepods/spacepod.dm b/code/game/vehicles/spacepods/spacepod.dm index 20c830cfa06..14bc5b8e413 100644 --- a/code/game/vehicles/spacepods/spacepod.dm +++ b/code/game/vehicles/spacepods/spacepod.dm @@ -172,11 +172,11 @@ var/mob/living/carbon/human/H = occupant var/mob/living/carbon/human/H2 = occupant2 if(H) - H.loc = get_turf(src) + H.forceMove(get_turf(src)) H.ex_act(severity + 1) H << "You are forcefully thrown from \the [src]!" if(H2) - H2.loc = get_turf(src) + H2.forceMove(get_turf(src)) H2.ex_act(severity + 1) H2 << "You are forcefully thrown from \the [src]!" del(ion_trail) @@ -225,7 +225,7 @@ return user.drop_item(W) battery = W - W.loc = src + W.forceMove(src) return if(istype(W, /obj/item/device/spacepod_equipment)) if(!hatch_open) @@ -241,7 +241,7 @@ else user << "You insert \the [W] into the equipment system." user.drop_item(W) - W.loc = equipment_system + W.forceMove(equipment_system) equipment_system.weapon_system = W equipment_system.weapon_system.my_atom = src return @@ -253,7 +253,7 @@ else user << "You insert \the [W] into the equipment system." user.drop_item(W) - W.loc = equipment_system + W.forceMove(equipment_system) equipment_system.misc_system = W equipment_system.misc_system.my_atom = src return @@ -587,12 +587,12 @@ if(0) return if(1) if(occupant2) occupant2 << "[occupant.name] climbs out of the pod!" - occupant.loc = src.loc + occupant.forceMove(src.loc) occupant = null user << "You climb out of \the [src]." if(2) if(occupant) occupant << "[occupant2.name] climbs out of the pod!" - occupant2.loc = src.loc + occupant2.forceMove(src.loc) occupant2 = null user << "You climb out of \the [src]." @@ -613,7 +613,7 @@ usr << "You eject [occupant2.name]." occupant2 << "\The [src] ejects you forcefully!" inertia_dir = 0 - occupant2.loc = src.loc + occupant2.forceMove(src.loc) occupant2 = null /obj/spacepod/verb/locksecondseat()