Disclaimer: This isn't necessarily a better way to do things. It's all strictly my own opinion. I just needed a catchy title folks ;p...
Now onto the post!
Alright, I'd say about 75% of everything I've learned programming wise was more or less because of epiphanies. Well, literally just now I had one.
For years I've created a central death control system as followed:
mob/proc/Death()
if(src.key)
src.deaths++
return ..()
if(istype(src,/mob/Monster/))
del(src)
if(istype(src,/mob/Turret/))
del(src)
..()
Now, as far as I'm concerned this way is pretty decent and works alright(note that I didn't take into consideration the one killing because I felt it wasn't necessary).
However, I today realized there is a different [arguably better] way...
It plays off the fancy smancy ..() function.
If you are not formilar with the ..() function. More or less what it does is causes the proc/verb to do it's parent function.
Any who... Here is how I now think a Death proc should be made...
world/mob = /mob/Player/ //Set the clients default mob to mob/Player
mob/proc/Death()
..()
mob/Player
Death()
src.deaths++
..()
mob/Monster
Death()
del(src)
mob/Turret
Death()
del(src)
I don't know. Just to me this little feature seems like it could potential help save a lot of unneeded checking...
It also turns out that it gets a little more indef than just this.
Say for instance your path doesn't contain one item but several. It actually goes down the tree from top to bottom. Here is my script I used to test.
mob/Player
world/mob = /mob/Player/
mob/proc/Test()
src << "Root"
..()
mob/Test()
src << "mob base"
return ..()
mob/Player/Test()
src << "player base"
..()
mob/verb/TestThisProc()
src.Test()
It displays player base then mob base then root base... As state, I just really thought this was neat and practical..
Lastly, an even closer look at how this could all help you... You can also use . to control the ..()'s return value.. Yet another example...
mob/proc/TestProc()
.="root value"
..()
mob/Player/TestProc()
var/parent_return = ..()
src << parent_return
Honestly, I can't really think of anything too too good for this at the moment. However, I am very sure I will take advantage of this system in the future..