So I have been learning coding for the last few weeks by messing around with code. I often find that code from even fully functional games is designed incredibly messy. So could anyone give me pointers on what a well organized code file SHOULD look like and if/when sometimes necessary exceptions must be made for the purpose of functionality?

For example, what I am working on right now has 10 different trees at the lowest level in the object tree. And things seem defined in random locations wherever it happened to be convenient. You could take a given function such as "Attacking" and "Skills" and anything pertaining to combat and the definitions are everywhere even in random files that you wouldn't think to look for such definitions. Wouldn't a well coded file have one location with all of its relevant functions and definitions in the same place?

Basically if you were to be hired to work on a project that already has all of it's primary coding completed and you were tasked with a goal of organizing said code, how exactly would you go about it? What should a "proper" object tree look like and how could you define the code it represents as "well organized"?
Basically, it's organized code until you see it.
Can confirm.
look at ss13 and do the exact opposite
In response to Optimumtact
LOL, what are you doing here Oranges?
Do children objects match the category of their parent? If no, move them somewhere they do.

Is common code reused elegantly or just copy pasted to oblivion? Inheritance, utility modules.

Do objects with similar uses have similar names? Is it easy to guess what something does just by reading its name and path?

Is then code spaced and organized similarly across files or have the developers never agreed to a style?

Is there code which is never used? Or better yet do you have a bunch of code which got commented out long ago and has never been addressed?

Do comments state the obvious or do they provide useful information that couldn't easily be gained from a glance? I dont need to know the method adds something to your inventory if it's literally called inventory.add(). Dont bother.

Do you have modules that could probably be moved together instead of being separated? Some people go module crazy and have esoteric modules that only make sense to their developer and to no one else.

Do you have redundant code? Two things that do the exact same thing in different places? Pick one and share it.

Do you have variables that are long chains of parents and children? mob.inventory.slots[2].effects.fireResistances.max? Consider helper methods. Resistances.max(mob, 2, "fire")
See here, and click all the links:
Basically, it's organized code until you see it.
It looks like my sexy code, bb
In response to Zecronious
All of these things are the issue. Useless mobs, verbs in random places, objects that serve no function, ect. ect.
In response to Zecronious
Appreciate all the responses. Also, Zecronius, all of these are the issues. Frankly I just scoured the web for source codes of my old favorite games. I was able to find a really old version of Finale and also one for Naruto GOA. Finale is the code I mentioned here. There are not even mob types for each of the races you can pick. The definitions for the planets are in a universal "bump" proc. I've been trying to create a way to create random NPCs that share all of the stats of players but I keep hitting roadblocks. I'd like to make something my own of it all and even make my own icons. The source I got for GOA is massively broken. Obviously due to the copyright issues way back neither of these will ever go back on the hub but since I like them I'd like to understand how they did what they did. I'd be happy to share either file if anyone would be interested in looking them over and giving me some advice. Both will run, Finale only has an issue because a variable for Unlocked Potential is called UP which is a direction in BYOND. GOA however will "run" but you just spawn on a black screen and it won't let you go through the log in process or anything. Not really sure where to start there but I hoped maybe I could learn some messing with Finale that would let me get to that point.