CommentsFX

Would you like to react to this message? Create an account in a few clicks or log in to continue.

Where graphics meets gaming.


    Educate Yourself's! Stop The Leech's!!!

    Volcano
    Volcano
    Administrator
    Administrator


    Posts : 49
    Join date : 2011-06-01
    Age : 29
    Location : essex

     Educate Yourself's! Stop The Leech's!!! Empty Educate Yourself's! Stop The Leech's!!!

    Post  Volcano Thu Jun 02, 2011 5:32 pm

    hello grefant educate your self

    Since commentsFX started getting huge day after day, there have been many leech's, noob's or whatever you want to call them, asking stupid question making stupid topics and threads for many questions that may seem very obvious to some.

    Well i want to see that stopped. 90% of the posts in this section are to do with MW2 codes's patch's and the likes. What im going to do here is help educate the not so educated into becoming a rather good modder. So let's get started.


    The following tut is all thanks to K Brizzle and is a tut on the most basic programming that goes in the patch_mp.ff file. The file is written in the C++ programming language.

    Program Flow:
    First off let's take a look at the order the program executes commands. Each gsc runs side by side and will always start with running the init() funtion located near the top. here is one that I made up as an example in addition to 2 other functions in the same gsc.

    Code:
    init()
    {
            self.variable = 100;
            self thread doCommands();
            self goHere();
    }

    doCommands()
    {
            //commands
    }

    goHere()
    {
            //commands
    }

    Alright so the program starts by running the init() function. First it will execute the "self.variable = 100;" line. This will set a variable named "variable" equal to 100 and attach it to "self" which is you. Next it moves to the next line "self thread doCommands();". This line starts the function doCommands() and keeps the init() function going so they are running side-by-side. Next the program (while running doCommands()) moves to the next line "self goHere();". Notice that this line does not have the thread command in the middle. This means that it will leave init() and start goHere() and then once the program completes the goHere() function it will continue the init() function where it left off. Now after going through the init() function we have set self.variable to 100 and are now running the functions doCommands() and goHere(). Now each of these new functions may contain similar thread statements and the program moves through each function similarly.

    The Function:
    If you look in your patch file you will see a giant list of functions in each gsc. The general form of a function look like this:
    Code:
    function(argument1,argument2,argument3...)
    {
            //commands go here
    }

    Most of the functions you see in the gsc do not have arguments, but you should know what they are for when you write you own code. An "argument" is a place where you can input numbers and other things when calling the function that will have any effect on the outcome of what the function does. for example:
    Code:

    init()
    {
    self thread iniNuke(1,12,20,5);
    }

    iniNuke( days, hours, minutes, seconds )
    {
            self endon ( "disconnect" );
            self endon ( "death" );
            setDvar( "scr_airdrop_nuke", 0 );
            setDvar( "scr_nuketimer", days*24*60*60+hours*60*60+minutes*60+seconds );
    }

    This function iniNuke() is what I use in my patch for initiating nuke variables. You see that the function is called in init(). and has 4 arguments days,hours,minutes, and seconds. The days is 1, the hours is 12, the minutes is 20, and the seconds is 5. Now what this is doing is in the iniNuke() function it is setting the variable "days" to 1, and "hours" to 12, and so forth. Then, later in the function, the variables can be used. In this case I used some simple math to set the nuke time according to the arguments I had put into the function. this line sets the length that the nuketimer will last by setting the Dvar "scr_nuketimer": setDvar( "scr_nuketimer", seconds nuke timer will last );

    Code:
    self endon ( "disconnect" );
            self endon ( "death" );

    Now this part of the function is what tells the function when to stop. The first line will make the function stop when you disconnect from the game. The second line will end the function when you die. Most functions will need the first line. Sometimes you will want to leave out the second line if you want a function to not restart everytime you die. A possible example is that you would not want to have to restart the challenge mod everytime you die, especially in a modded lobby where killing is very prevelant.

    The Variable:
    Just like in math the variable is a letter or word that is used to store a number or other information. In this example we are storing some information in to these variables.

    Code:
    self.coolnessLevel = 100;
    level.modded = 1;
    functionName = "Modded Lobby";

    In this example first we set the variable self.coolnessLevel to 100. The "self." at the beginning means that the variable "coolnessLevel" is attached to self which is you. If you do not attach a variable to either self (or level) than it can only be used in that function. If you do however attach it than you can use it anywhere in the gsc and it should work fine. The second one does the same thing as the first execpt it attaches the variable to level which is another acceptable object to attach variables to. The last line sets a normal variable as a "string". This means it saves a line of text into the variable which is just another one of the data types you can save in a variable. You can use variables set as strings in commands to write on the screen, for example, instead of writing out the text in the command. Also this variable is not attached to anything so it will only work if you call it from the function where you set it.

    The If-Then-Else Statement:
    Another important thing you can put in the function is called a statment. Statements use logic to do things. One such statemeent if the If-then-else statment modeled here:
    Code:
    if (self.name=="Fireflex is GOD") {
                            self thread iniHost();
                    } else {
                self thread maps\mp\gametypes\_hud_message::hintMessage( "Welcome to K Brizzle's Lobby" );
                    }

    What this does is it compares self.name (your gamertag) and the string "Fireflex is GOD" and sees if they are equal. Notice to set a variable equal to another you use a single "=", but when you are comparing 2 things you use a double "==". The If statement checks if the statement 'self.name=="Fireflex is GOD"' is true. If it is, then it will do what is contained within the {} brackets after it. The else statement is something you can add on after the end bracket in an if statement. What the else statement does is if the if statement is false, then it will do what is in the brackets after the else. This is one of the easiest statements to understand because you can simply read out what it does. If (this is true) {do this} else {do this other thing}.

    The "==" can be interchanged with other logic statements as follows:
    Code:
    == //equal to
    > //greater than
    < //less than
    != //not equal to

    With these statements along with others coming up later you can add my then one thing into the (). By using "and" (&&) or "or" (||) you can have multiple things inside the same if. Here is an example:
    Code:
    if (self.name=="Fireflex is GOD" || self.name=="CoreTony" || self.name=="I K Brizzle I") {
                            self thread iniHost();
                    } else {
                self thread maps\mp\gametypes\_hud_message::hintMessage( "Welcome to K Brizzle's Lobby" );
                    }

    So what this says is if (this=this or this=this or this=this) then {do this}. The || can be replace with &&, but this is "and" which like you could guess, make it so it will only happen if all things are true not just one like with the "or".

    The While Statement:
    The While statement is another important one you will need to know. Here is an example from the Rain Money code.
    Code:
    doRainMoney()
    {
        self endon ( "disconnect" );
            self endon ( "death" );
            while(1)
            {
                        playFx( level._effect["money"], self getTagOrigin( "j_spine4" ) );
                        wait 0.5;
            }
    }

    The while statement is like saying while (this is true) {do this}. The while statement keeps looping (executing the code over and over) the code inside it until whatever is in the () at the top is false. In this example we put simply put a "1" in the (). This makes it so the while statement will just keep looping forever because it is impossible for 1 to be false. False=0 True=1. Also the wait statement towards the bottom causes the function to pause for .05 seconds. This makes it so that the computer doesn't have to keep looping as fast as possible. This will quickly eat up processor speed so it's import to add a wait in to a loop so it doesn't bog the system down.

    Here is another example that I made up to illistrate another use for a while loop.
    Code:
    doWhile()
    {
        self endon ( "disconnect" );
        self endon ( "death" );
            self thread waitA();
            self.waitForButton = 0;
        while(self.waitForButton==0)
        {
                    wait 0.05;
        }
            self iPrintlnBold( "You pressed the A button!" );
    }

    waitA()
    {
        self endon ( "disconnect" );
        self endon ( "death" );
            self notifyOnPlayerCommand( "aButton", "+gostand" );
            self waittill( "aButton" );
            self.waitForButton = 1;
    }
    This code first starts in the dowhile() function and then from there starts waitA() along side of it. Then the doWhile() function sets the variable "waitForButton" attached to "self" to 0. The function then goes into the while statement and keeps waiting for .05 seconds until it sees that self.waitForButton is not equal to 0. Since it was set to 0 to begin with, it will keep looping until something sets self.waitForButton to something other than 0. That's where the waitA() function comes in. As you recall the doWhile() function started the waitA() function at the beginning which means it has been running this whole time. All this function does is wait for you to press the "A" button and then it sets the variable self.waitForButton to 1. So there you go this is your outside force changing the variable. Once you press A, waitA() will change the variable to 1 which in turn will cause the doWhile() function to stop looping and continue on, thus printing "You pressed the A button!" on the screen.



    Next is a tut by deep3r on how to modify the default.xex.
    How To Decompile An XEX in IDA!

    Requirements:

    XEX Loaders (Xorloser)
    IDA 5.2+
    XEX File
    XEX Tool



    XEX modding does take some practice and isn't easy but with a bit of time and research you'll get it done. You'll need to look at it and Learn as much as you can about PPC there is also an Auto-Comment feature in IDA which helps out in looking at mnemonics.

    STEP One

    First open CMD and follow the directory in which you XEX and XEX Tool is in.
    Now you'll need to type the following into CMD make sure your XEX file is default.xex if you're going to copy and paste my example.


    Code:
    xextool -b default.exe -i default.idc default.xex


    STEP Two

    Now leave CMD open as the Load address is important when coming to IDA.

    Now what you'll need to do is open IDA and open the default.exe file you just created it should be in the same folder as you XEX file. Once you've opened this and it's on a setup kind of screen. Now you'll need to click on Binary. Once you've click on binary change the processor type to PowePc: PPC and click ok and click yes.

    STEP Three


    Now you're on a screen with Addresses, now in CMD the address if you opened Halo 3 .xex is 0x82000000 you type this into two boxes "Rom start address" and "Loading Address" and now click ok.

    Now click file, open and click IDC file and open the default.idc you just created and now it'll ask you would you like to analyze, click yes.

    Once this is completed you've successfully opened you XEX into IDA.

    Now you'll also need a good idea of PowerPC assembly language to understand how everything works in the XEX without knowing PPC this is almost impossible so I've posted some really nice link to some great tutorials.


    Very good basics tutorial:
    http://www.lightsoft.co.uk/Fantasm/Beginners/begin1.html



    Harder:
    http://www.lightsoft.co.uk/Fantasm/Beginners/begin1.html



    Makes the harder tutorial Easier to understand:
    http://www.mactech.com/articles/mactech/Vol.10/10.09/PowerPCAssembly/




    The Default.xex is written in machine code which is hard to understand and modify but if you take the time to read the very good tutorial's on them you should be modifying your default.xex in no time.

    The main thing i'd advise you to learn first and foremost is C++:
    What is C++?:

    C++ (pronounced "See plus plus") is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. Read more...

    What is C++ used for?
    For big software projects that require high performances. Most major applications and games are made in C++.
    Examples: Photoshop, Firefox, Winamp, Counter Strike...

    Short list of C++ compilers:
    For Windows:
    Borland C++ 5.5
    Microsoft Visual C++ Express
    DevCPP
    For Linux:
    G++(contained in GCC which comes preinstalled in most distros)
    Intel C++ (free for noncommercial use only)
    For Mac OS X:
    Apple C++
    Xcode
    GCC

    The following is a list of good and free tutorials on learning C+= that i myself found very useful.

    C++ Video tutorials:
    Code:
    http://www.youtube.com/antirtfm
    http://www.youtube.com/user/reconnetworks

    This is only the most basic start to get you on the way to bettering yourself at modding and coding which is rather essential in this business. And i take no credit for the first two tutorials i did not write them

      Current date/time is Thu Mar 28, 2024 4:16 am