Files
Paradise/code/game/objects/devices/taperecorder.dm
johnsonmt88@gmail.com 80b15df54b ** Mob Define Cleanup: Part 1 **
I'm currently working on moving all of the vars in mob_defines.dm and some procs in mob.dm into more fitting places. For example, ghosts and simple animals can not be cloned, so they do not need a cloneloss var. Cloneloss would be better fitting to /mob/living or even /mob/living/carbon. 

By moving these defines into proper children of /mob we lower the amount of resources that must be set aside every time a mob is created and we lower the amount of data that gets transfered between mobs when we combine, transfer or transform them. In theory, this should help free up some resources and combat lag.

Due to how integrated some of these defines are in the rest of the code, I'm going to be committing this cleanup in small batches. Doing it this way instead of one massive commit means that bugs will be easier to locate and identify. It is also less likely to overwhelm players with bugs, and if it still does, it will make it easier for us to revert only the section that is causing problems. Smaller commits also means merging with existing code will be less of a nightmare and has less potential for merging mistakes.

One of my goals in this cleanup is to add a description to every single variable in mob defines. While some of them are self explanatory, there are some there that are used in horribly obscure ways on top of having no comment to describe their use.

-----------------------

Mob defines moved to living:
- last_special*
- bruteloss
- oxyloss
- toxloss
- fireloss
- cloneloss
- brainloss
- halloss
- hallucination
- hallucinations(list)

*Note: I believe this variable is not needed, but the code it is used in (the resist verb) is cluttered and messy. That chunk of code probably use a re-write. I'll put it on my TODO list and if I survive mob_defines I'll try to get around to it but if anyone wants to do it for me, that would certainly help!

-----------------------

Mob procs moved to living:
- getBruteLoss()
- adjustBruteLoss()
- getOxyLoss()
- adjustOxyLoss()
- setOxyLoss()
- getToxLoss()
- adjustToxLoss()
- setToxLoss()
- getFireLoss()
- adjustFireLoss()
- getCloneLoss()
- adjustCloneLoss()
- setCloneLoss()
- getHalLoss()
- adjustHalLoss()
- setHalLoss()
- getBrainLoss()
- adjustBrainLoss()
- setBrainLoss

Mob procs moved to carbon:
getDNA()
setDNA()

-----------------------

Mob verbs moved to carbon:
- Sleep
- Lay down / Get up

-----------------------

The : operator...

The thing that has been killing me through this whole cleanup is people using or copy/pasting the : operator everywhere. 


*** Please use obj.var_or_procname. Do not use obj:var_or_procname ***


Using obj:procname will not throw a compiler error if obj does not have that specific var or proc. This means that the coder making changes will NOT be informed of an error which will result in a proc failing, potentially being completely unusable and definatly causing a runtime error.

With that said, I fully anticipate that most bugs (if any) caused by this mob define cleanup to be the result of : operators.

I've been replacing many : operators in favour of the . operator as I've been going, most noteably I went out of my way to remove almost every : operator from the 4000+ line Chemistry-Regents.dm
Exceptions:
- Water: Turf and Atmos related vars. I'm not familiar with the members and methods in those class' hierarchy.
- Silicate: because it's commented out and I honestly dont see it returning.
- Thermite: Turf and Atmos related vars.
- Corn Oil: Turf and Atmos related vars.

Final note: While this may be the source of some mob-related bugs, there are two other revisions that have been committed between now and the last time either of the the two tgstation servers have been updated. These revisions both touch mob-related files. I'm not blaming these other revisions for anything, especially since one of them is mine anyway, I'm just listing them here for refrence to help quickly identify any problems.
- My human/life() changes in r3925 
- Carn's life() standardizations in r3933

Stuff unrelated to mob defines:
- Fixed borgs and such being able to go into DNA modifiers.
- Changelog updated and I added Sieve to the list of coders.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3934 316c924e-a436-60f5-8080-3fe189b3f50e
2012-06-28 17:06:19 +00:00

263 lines
8.1 KiB
Plaintext

/obj/item/device/taperecorder
desc = "A device that can record up to an hour of dialogue and play it back. It automatically translates the content in playback."
name = "universal recorder"
icon_state = "taperecorderidle"
item_state = "analyzer"
w_class = 1.0
m_amt = 60
g_amt = 30
var/emagged = 0.0
var/recording = 0.0
var/playing = 0.0
var/timerecorded = 0.0
var/playsleepseconds = 0.0
var/list/storedinfo = new/list()
var/list/timestamp = new/list()
var/canprint = 1
flags = FPRINT | TABLEPASS| CONDUCT
throwforce = 2
throw_speed = 4
throw_range = 20
/obj/item/device/taperecorder/hear_talk(mob/living/M as mob, msg)
if (recording)
var/ending = copytext(msg, length(msg))
src.timestamp+= src.timerecorded
if (M.stuttering)
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] [M.name] stammers, \"[msg]\""
return
if (M.getBrainLoss() >= 60)
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] [M.name] gibbers, \"[msg]\""
return
if (ending == "?")
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] [M.name] asks, \"[msg]\""
return
else if (ending == "!")
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] [M.name] exclaims, \"[msg]\""
return
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] [M.name] says, \"[msg]\""
return
/obj/item/device/taperecorder/attackby(obj/item/weapon/W as obj, mob/user as mob)
..()
if (istype(W, /obj/item/weapon/card/emag))
if (src.emagged == 0)
src.emagged = 1
src.recording = 0
user << "\red PZZTTPFFFT"
src.icon_state = "taperecorderidle"
else
user << "\red That is already emagged!"
/obj/item/device/taperecorder/proc/explode()
var/turf/T = get_turf(src.loc)
if (ismob(src.loc))
var/mob/M = src.loc
M.show_message("\red The [src] explodes!", 1)
if(T)
T.hotspot_expose(700,125)
explosion(T, -1, -1, 0, 4)
del(src)
return
/obj/item/device/taperecorder/verb/record()
set name = "Start Recording"
set category = "Object"
if(usr.stat)
usr << "Not when you're incapacitated."
return
if(src.emagged == 1)
usr << "\red The tape recorder makes a scratchy noise."
return
src.icon_state = "taperecorderrecording"
if(src.timerecorded < 3600 && src.playing == 0)
usr << "\blue Recording started."
src.recording = 1
src.timestamp+= src.timerecorded
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] Recording started."
for(src.timerecorded, src.timerecorded<3600)
if(src.recording == 0)
break
src.timerecorded++
sleep(10)
src.recording = 0
src.icon_state = "taperecorderidle"
return
else
usr << "\red Either your tape recorder's memory is full, or it is currently playing back its memory."
/obj/item/device/taperecorder/verb/stop()
set name = "Stop"
set category = "Object"
if(usr.stat)
usr << "Not when you're incapacitated."
return
if (src.recording == 1)
src.recording = 0
src.timestamp+= src.timerecorded
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] Recording stopped."
usr << "\blue Recording stopped."
src.icon_state = "taperecorderidle"
return
else if (src.playing == 1)
src.playing = 0
var/turf/T = get_turf(src)
for(var/mob/O in hearers(world.view-1, T))
O.show_message("<font color=Maroon><B>Tape Recorder</B>: Playback stopped.</font>",2)
src.icon_state = "taperecorderidle"
return
else
usr << "\red Stop what?"
return
/obj/item/device/taperecorder/verb/clear_memory()
set name = "Clear Memory"
set category = "Object"
if(usr.stat)
usr << "Not when you're incapicated."
return
if(src.emagged == 1)
usr << "\red The tape recorder makes a scratchy noise."
return
if (src.recording == 1 || src.playing == 1)
usr << "\red You can't clear the memory while playing or recording!"
return
else
src.storedinfo -= src.storedinfo
src.timestamp -= src.timestamp
src.timerecorded = 0
usr << "\blue Memory cleared."
return
/obj/item/device/taperecorder/verb/playback_memory()
set name = "Playback Memory"
set category = "Object"
if(usr.stat)
usr << "Not when you're incapicated."
return
if (src.recording == 1)
usr << "\red You can't playback when recording!"
return
if (src.playing == 1)
usr << "\red You're already playing!"
return
src.playing = 1
src.icon_state = "taperecorderplaying"
usr << "\blue Playing started."
for(var/i=1,src.timerecorded<3600,sleep(10 * (src.playsleepseconds) ))
if (src.playing == 0)
break
if (src.storedinfo.len < i)
break
var/turf/T = get_turf(src)
for(var/mob/O in hearers(world.view-1, T))
O.show_message("<font color=Maroon><B>Tape Recorder</B>: [src.storedinfo[i]]</font>",2)
if (src.storedinfo.len < i+1)
src.playsleepseconds = 1
sleep(10)
T = get_turf(src)
for(var/mob/O in hearers(world.view-1, T))
O.show_message("<font color=Maroon><B>Tape Recorder</B>: End of recording.</font>",2)
else
src.playsleepseconds = src.timestamp[i+1] - src.timestamp[i]
if (src.playsleepseconds > 19)
sleep(10)
T = get_turf(src)
for(var/mob/O in hearers(world.view-1, T))
O.show_message("<font color=Maroon><B>Tape Recorder</B>: Skipping [src.playsleepseconds] seconds of silence</font>",2)
src.playsleepseconds = 1
i++
src.icon_state = "taperecorderidle"
src.playing = 0
if (src.emagged == 1.0)
for(var/mob/O in hearers(world.view-1, get_turf(src)))
O.show_message("Tape Recorder: This tape recorder will self destruct in <B>5</B>",2)
sleep(10)
for(var/mob/O in hearers(world.view-1, get_turf(src)))
O.show_message("<B>4</B>",2)
sleep(10)
for(var/mob/O in hearers(world.view-1, get_turf(src)))
O.show_message("<B>3</B>",2)
sleep(10)
for(var/mob/O in hearers(world.view-1, get_turf(src)))
O.show_message("<B>2</B>",2)
sleep(10)
for(var/mob/O in hearers(world.view-1, get_turf(src)))
O.show_message("<B>1</B>",2)
sleep(10)
src.explode()
/obj/item/device/taperecorder/verb/print_transcript()
set name = "Print Transcript"
set category = "Object"
if (!canprint)
usr << "\red The recorder can't print that fast!"
return
if (src.recording == 1 || src.playing == 1)
usr << "\red You can't print the transcript while playing or recording!"
return
usr << "\blue Transcript printed."
var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(get_turf(src))
var/t1 = "<B>Transcript:</B><BR><BR>"
for(var/i=1,src.storedinfo.len >= i,i++)
t1 += "[src.storedinfo[i]]<BR>"
P.info = t1
P.name = "paper- 'Transcript'"
canprint = 0
sleep(300)
canprint = 1
/obj/item/device/taperecorder/attack_self(mob/user)
if(src.recording == 0 && src.playing == 0)
if(usr.stat)
usr << "Not when you're incapacitated."
return
if(src.emagged == 1)
usr << "\red The tape recorder makes a scratchy noise."
return
src.icon_state = "taperecorderrecording"
if(src.timerecorded < 3600 && src.playing == 0)
usr << "\blue Recording started."
src.recording = 1
src.timestamp+= src.timerecorded
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] Recording started."
for(src.timerecorded, src.timerecorded<3600)
if(src.recording == 0)
break
src.timerecorded++
sleep(10)
src.recording = 0
src.icon_state = "taperecorderidle"
return
else
usr << "\red Either your tape recorder's memory is full, or it is currently playing back its memory."
else
if(usr.stat)
usr << "Not when you're incapacitated."
return
if (src.recording == 1)
src.recording = 0
src.timestamp+= src.timerecorded
src.storedinfo += "\[[time2text(src.timerecorded*10,"mm:ss")]\] Recording stopped."
usr << "\blue Recording stopped."
src.icon_state = "taperecorderidle"
return
else if (src.playing == 1)
src.playing = 0
var/turf/T = get_turf(src)
for(var/mob/O in hearers(world.view-1, T))
O.show_message("<font color=Maroon><B>Tape Recorder</B>: Playback stopped.</font>",2)
src.icon_state = "taperecorderidle"
return
else
usr << "\red Stop what?"
return