[Image]

 Created By:                                       QuakeGod of TeleFragged
 E-Mail                                            quakegod@telefragged.com
 Difficulty Scale                                  Easy

 [Image]Step 1
        This is the first part of a two part tutorial on making and defining classes. This
        first chapter will be the simplest and will just allow you to choose 2 different
        classes but the classes won't do anything different, that's being saved until the next
        chapter. Here are two simple things to remember when looking at the code :
        Add the code in blue.
        Delete the code in red.
        Leave the code alone in white.

 [Image]Step 2
        The first thing you will want to do if open up the weapons.qc file. Scroll down to where you see the ImpulseCommands
        function. This is where you will add the code to change classes and to show what class you have.

        void() ImpulseCommands =
        {
                if (self.impulse >= 1 && self.impulse = 8)
                        W_ChangeWeapon ();

                if (self.impulse == 9)
                        CheatCommand ();
                if (self.impulse == 10)
                        CycleWeaponCommand ();
                if (self.impulse == 11)
                        ServerflagsCommand ();
                if (self.impulse == 12)
                        CycleWeaponReverseCommand ();

                if (self.impulse == 100)
                        classpick();                                    //calls the function that changes the class
                if (self.impulse == 200)
                        showclass();                                    //calls the function that shows you what class you have

                if (self.impulse == 255)
                        QuadCheat ();

                self.impulse = 0;
        };

 [Image]Step 3
        Ok, now right after the ImpulseCommands function, you will want to add the classtype function and the
        showclass function. This function will allow you to choose between two classes and it also will set you
        up so it automatically calls the showclass function. The showclass function will actually show you what
        class you have.

                if (self.impulse == 100)
                        classtype();

                if (self.impulse == 255)
                        QuadCheat ();

                self.impulse = 0;
        };                                                              //end of the ImpulseCommands function

        void() classpick =
        {

                if (self.classtype == 0)
                        {
                        self.classtype = 1;                     //the variable is now set to the old guy class
                        showclass();
                        }


                else if (self.classtype == 1)
                        {
                        self.classtype = 0;                     //the variable is now set to the Quake guy class
                        showclass();
                        }

        };

        void() showclass =
        {

                if (self.classtype == 0)
                        {
                        centerprint(self, "You are the Quake Soldier");
                        }

                else if (self.classtype == 1)
                        {
                        centerprint(self, "You are an old soldier");
                        }

        };

 [Image]Step 4
        Now all you have to do is add the variables and functions to the defs.qc. First open
        the defs.qc file. Then add the variables and functions as shown here.

        //================================================
        void            end_sys_fields;                 // flag for structure dumping
        //================================================

        //put the new variables after this

        .float classtype;
        void() classpick;
        void() showclass;

 [Image]Step 5
        Wow! We're done with lesson 1! Well, compile this code now and run it. Impulse 100 will
        switch between classes and impulse 200 will show you what class you currently are, not
        like it matters what class you are though. Tune in next time to find out how to
        actually make the classes different.
