User talk:Critcodedtuna

From Terraria Wiki
Jump to: navigation, search

Code checking: source[edit source]

How would I get my hands on a compiled (or would that be decompiled) version of Terraria? Is there a program I could use to decompile my Terraria? I am very grateful for all the work our code-checkers do, but it would be sweet to be able to look things up myself. I have the Steam version of Terraria. I suppose I could google it, but I thought I'd check with one of our own first. -- Ferretwings (talk) 22:57, 15 July 2016 (UTC)

I use ILspy a .NET decompiler Flisch42 (talk) 23:59, 15 July 2016 (UTC)
I mostly use JetBrains dotPeek, but ILSpy works as well. I'll occasionally use snippets on Reddit posts to demonstrate mechanics, but I won't provide wholesale usable source. These reflectors work with both the Steam and GOG Windows version, but I have yet to figure out a way to get code out of the OS X or Linux binaries (Mono-based, some architecture differences I think). Critcodedtuna (talk) 00:11, 16 July 2016 (UTC)
Thank you! (both of you) -- Ferretwings (talk) 01:25, 16 July 2016 (UTC)

Code check?[edit source]

Have you come across any code that describes how the game knows you are fishing in the sky? A player was wondering exactly where the sky begins and ends. -- Ferretwings (talk) 04:33, 18 July 2016 (UTC)

It is done in Terraria.Projectile function fishingCheck(). And the query for Sky Crates is if the bobber is below 0.5 * Main.worldSurface. My problem is I do not know, what Main.worldSurface is, my guess would be the number where the height is 0 but that is just a guess. That would mean the sky begins at max height / 2. Flisch42 (talk) 11:04, 18 July 2016 (UTC)
Yep, but it's not exactly the most obvious thing and doesn't have a clear position that could be identified with a Depth Meter or related. Everything you can catch is determined by Projectile.FishingCheck(). While there are various biome checks, altitude is rigidly determined by one statement:
int num10 = (double) j1 >= Main.worldSurface * 0.5 ? ((double) j1 >= Main.worldSurface ? ((double) j1 >= Main.rockLayer ? (j1 >= Main.maxTilesY - 300 ? 4 : 3) : 2) : 1) : 0;
This breaks the world into sky (0), surface (1), underground (2), cavern (3), and underworld (4). This makes the sky region the upper half of everything above surface level. What makes this unintuitive is that Main.worldSurface varies widely from world to world, so the sky never starts at a fixed altitude. The good news is that you can calculate it on a per world basis with a bit of adventuring. With a Depth Meter equipped, make your way to the very top of the world (so that the player is all the way at the top of the screen). Note the maximum altitude in feet then add 84 (to compensate for the inaccessible margin above). Divide that by 2 and that should be about the minimum altitude in that particular world where sky loot can be caught. Caveat: I worked this calculation out by inspection, and haven't tested it in game yet, so it might be slightly off and you'd need to be a couple feet higher for sky fishing to work. Let me know if that helps. Critcodedtuna (talk) 15:41, 18 July 2016 (UTC)