Import r1263, accuracy improvements to functions

r1263 | svkaiser | 2014-02-02 17:02:53 -0800 (Sun, 02 Feb 2014)

+ Modifying some functions to match more closely to the original game's
behavior