Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Just some thought about code


Jabhacksoul
 Share

Recommended Posts

Good Morning,

 

Before I sk8t off to skool today, I wanted to give a little to this forum since I have learn much in the past 4 months. Yesterday I was working on my own unique version of "End of the Line" mission when it dawned on me that R* coding style is very different from how I code. Rockstar IMHO put too much into something that was very simple. For example, I went into the MAIN.SCM and pulled out the mission "End of the Line" and it runs 7000+ lines of code. I am not trying to make the exact copy of the same mission, that would be just a waste of my time. But my mission is almost finished and I barely have 900 lines of code. The biggest difference of how I code and how they code is timeline I guess would be proper word.

 

At the very beginning of this mission, Tenpenny enters a firetruck and Sweet does a leap onto the ladder that would impress Jordan. Then they put the firetruck on a path you must keep up or lose. I am sure you played it. But the way they code it is strange, they run from the beginning of the ENTIRE route to check where you are and how far or near you are and if you are close enough to this gang or a train etc.. Then the loop it all the way back to point one.

 

I do my coding in chunks, if you haven't reached check point C yet All I worry about is the stuff between B and C. I don't go back to A or beyond to D. They however seem to scan the entire thing from A to Z. All the coding questions this generates is bloating the mission. I am most certain they had different tools that caused the bloating when they created the missions. So I got to pondering this morning how many have tried to recreate a mission without the bloat.

 

Like I said my mission is not supposed to be 100% identical but I wanted it to have the same sequence of events so I am using the original as a template. It probably will never be over 1000 lines of code when complete. I will check back in after school today and read your thoughts about this topic.

 

JAB

Link to comment
Share on other sites

spaceeinstein

I think the reason why it feels "bloated" is because Rockstar has much more checks than an average player would experience. In a way it's better to do it that way if you have the correct program to keep track all the variables. Instead of constantly gosubing or looping in small loops to check if that specific event is done, you can run though the whole code to see if many events are done. The best example I can think of is 555-WE-TIP. There are so many ways you can fail that mission.

Link to comment
Share on other sites

I was asking my Dad about it. He said that we (modders) are working with more primitive tools than R* has. Just to let you know my Dad has experience with this he worked on Blizzard's Reign of Chaos. He had a difference of opinion and no longer works for them. But as he told me, some companies have what they call firmware that is created and used just to make the game. It would be like a C++ programmer compiling a game and an Assembly Language programmer compiling the same game. ASM is always smaller. He didn't look at the code but said if it looks disorganized and put together odd that most likely they used some firmware to write and code the missions.

 

I asked him what if someone leaked the firmware out? He said, A. no one at R* wants to lose their jobs and B. they don't want to go to jail just to help us. I still think it would be cool to lay my hands on the firmware. sigh.gif But for now the Sanny Builder works just fine (thank you Seemann).

 

But take for example this code from "End of the Line":

 

:FINALEC_57021if  [email protected] == 0 else_jump @FINALEC_57061 03CF: load_wav [email protected] as 1 05AA: [email protected] = [email protected] [email protected] = 1 :FINALEC_57061return :FINALEC_57063if  [email protected] == 1 else_jump @FINALEC_57117 if 03D0:   wav 1 loaded else_jump @FINALEC_57117 00BC: show_text_highpriority GXT [email protected] time 4000 flag 1 03D1: play_wav 1 [email protected] = 2 :FINALEC_57117if  [email protected] == 2 else_jump @FINALEC_57170 if 03D2:   wav 1 ended else_jump @FINALEC_57170 [email protected] += 1 040D: unload_wav 1 00BE: text_clear_all [email protected] = 0 :FINALEC_57170return 

 

 

 

And then my version:

 

:FINALEC_PLAY_A03CF: load_wav [email protected] as 1:FINALEC_PLAY_Bwait 0if 03D0:   wav 1 loaded else_jump @FINALEC_PLAY_B 00BC: show_text_highpriority GXT [email protected] time 4000 flag 1 03D1: play_wav 1 :FINALEC_PLAY_Cwait 0 if 03D2:   wav 1 ended else_jump @FINALEC_PLAY_C  040D: unload_wav 1 00BE: text_clear_all return 

 

 

Both are used to Load a wav and play it. The difference is their code works like this:

 

[email protected] is a check variable to see what stage the wav file is in 0 = unloaded 1 = Loaded 2 = playing

As it passes the first check point if it is zero it loads the wav but flies by until it is loaded then it plays the wav and flies by then when complete it unloads.

 

Mine I make sure my action is cued up to run the length of the wav or longer then I go to my subroutine of waiting on load, waiting to play, then unload.

 

Both do the same job mine uses one less jump and one less variable. The wav plays out just the same only my mission is focused on the wav and not Sweet's moon jump. He is performing action but that animation lasts 4.5 seconds and his rant at Tenpenny lasts less than 2 seconds. Even assuming the wav got hung up for some odd reason. The action would continue because of my use of "wait 0" opcode.

 

Of course this is just one small example, there are many others that deal with cameras and actors. Well I need to get back to work finishing off the monster I only have this and one other mission before my mod is complete. Then I plan to start a new project in January.

 

JAB

Link to comment
Share on other sites

Im really interested on what you are saying, and you are rigth. The tools they created for them, just them, will never be out for us, and i dont really think we will ever create a tool taht can be exactly as they idea.

 

But Sanny is pretty good by now. Your thougth about comparing Orignial R* Coding with custome fan coding is true, when i was a beginner i used to look alot at the original code, as everybody told me so.. and i really dont understand how they made that kind of long coding for maybe somthing that could take less lines.

 

But i think that if more lines can guaranty better functionability its ok.

Yl8KS.jpg
Link to comment
Share on other sites

spaceeinstein

You can check out main.sc. Open it with NotePad.

Link to comment
Share on other sites

 

Im really interested on what you are saying, and you are rigth. The tools they created for them, just them, will never be out for us, and i dont really think we will ever create a tool taht can be exactly as they idea.

 

But Sanny is pretty good by now. Your thougth about comparing Orignial R* Coding with custome fan coding is true, when i was a beginner i used to look alot at the original code, as everybody told me so.. and i really dont understand how they made that kind of long coding for maybe somthing that could take less lines.

 

But i think that if more lines can guaranty better functionability its ok.

 

Some games that I have like XIII uses the Unreal Engine. If you have XIII for PC they packed the game editor with it which is real cool. You can see the 3D maps and it is all point and click. Quite long time ago I responded to someone posting on a forum about the sequel they never made. I told him not to wait just learn the editor and build the sequel himself. I never cared much for the ending of that game. He responded it would be too hard mad.gif ...with the professional editor.

 

Imagine if he tried what we do.

 

The closest my brother ever got to modding a game (besides Lionhead the Movies) was Elder Scrolls: Marrowind. He used the editor that came with the game and made an Island with a castle full of vampires inside it. Again another great game with the tools to mod the hell out of it. Yet I see more GTA mods - which impresses me because no tools ever shipped out for the PC versions.

 

 

You can check out main.sc. Open it with NotePad.

 

I have looked at that and it resembles BASIC language a lot. So you think they ran that script and others through a compiler?

 

JAB

Link to comment
Share on other sites

The fact that the decompiled main.scm is full of (junk) jf-if-checks and such is simple. Just like a compiler for normal programming languages compiles the high-level loops and ifs to jumps, the script compiler Rockstar uses (and the one from SB) compiles everything (repeat/until, if/then, and so on) to if/jf-type commands. The decompiler can't see the difference between the various uses for those jump commands, and makes them into if/jf in the decompiled code.

 

Try compiling a script which uses repeat/until and if/then extensively, and decompiling it. See that all those checks have changed into (a lot harder-to-read) jumps? That's exactly why the decompiled code from Rockstar is so hard to understand. wink.gif

SsZgxdL.png

Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding!

Link to comment
Share on other sites

As said above, youre both right and wrong. Many of the missions, and the code in general, do indeed appear to be bloated, BUT - they use a proprietary scripting language that compiles into something that we in turn take a best guess at decompiling. The bloat can be put down to that repetition of process.

 

Just because what we see in SAMB or Sanny is bloated does not therefore necessarily mean that it was originally written that way. To say so assumes that any decompiler exactly replicates what was originally written and the form in which it was done so.

 

The classic example of this misinterpretation is provided by your 'load wav' code above. In your code, the script is forced to stop and wait at some point until the relevant wav is loaded. In the original R* code it does not, it continues executing more instructions and tests to keep the game pace flowing, which is essential in some of the more complicated missions where many conditions need to be continually tested as space said.

 

They did not write bloated code intentionally - as you said, they dont have the time to - these are professionals who wrote code in an organised manner with the objective of maximising gameplay framerate and keeping everything running smoothly.

 

Its wrong to assume that the code displayed by a 3rd party authored decompiler is accurately representative of what was originally written. Thats like saying the Google online translation program accurately presents to you both the grammatically correct English form of the original foreign text and conveys the context and meaning with which it was originally written. If we were talking C++ code here then you may have a certain point, but we are not - we are talking about a high level proprietary scripting language that nobody outside of R* knows much about.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.