Announcement

Collapse
No announcement yet.

How do i add new weapons and ammo?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do i add new weapons and ammo?

    I want to add some new weapons by editing the QC Includes models and ammo but i don't know how, any help?
    I was thinking of turning these
    into weapons the player can use.
    I am like a stray dog, lost in between what I do and what I should do.
    But sometimes, all you need is Imagination.


  • #2
    looks like we are both up to the same thing. i am working on adding a crossbow. it seems like the weapons tutorials at i3d have you change a weapon and not add one... something tells me this is not going to be easy!

    my crossbow is mostly based off of the nail gun and the animation is in time with the rocket launcher.

    so far what i have done is doubled the code for the nail gun and changed some names and and models and i am getting a lot of errors when compiling.

    i know one thing that is not right that im confused on is in the
    def qc

    // items
    float IT_AXE = 4096;
    float IT_SHOTGUN = 1;
    float IT_SUPER_SHOTGUN = 2;
    float IT_NAILGUN = 4;
    float IT_SUPER_NAILGUN = 8;
    float IT_GRENADE_LAUNCHER = 16;
    float IT_ROCKET_LAUNCHER = 32;
    float IT_LIGHTNING = 64;
    float IT_EXTRA_WEAPON = 128;
    float IT_CROSSBOW = 128; //CROSSBOW

    float IT_SHELLS = 256;
    float IT_NAILS = 512;
    float IT_ROCKETS = 1024;
    float IT_CELLS = 2048;
    float IT_ARROW = 2048; //CROSSBOW
    i was not sure what number to give IT_CROSSBOW AND IT_ARROW

    I think it has something to do with tossing penny's in the air and having them land at random but still be doubled. (MG should understand what im saying hear rogenotic )

    I think it would help if we find a QC mod where it has all the quake weapons pulse one more that we can use as a guide.

    if you do not mind Shambler234 i would like to post on your thread with you and we can learn this together. and hopefully one of our quake one qc GODS will help us out!
    Last edited by JDSTONE; 06-13-2013, 07:15 PM.

    Comment


    • #3
      Sure thing, but what about ammo?
      I am like a stray dog, lost in between what I do and what I should do.
      But sometimes, all you need is Imagination.

      Comment


      • #4
        IT_ARROW is the ammo i think? there a qc post at inside3d with a 25 gun add but i cant find it right now...

        hopefully we can get some community help from one of our grate qc people out there... PLEASE!
        BUT THE WIFE IS CALLING for now...

        Comment


        • #5
          LOL! JD I want to give you an award. It's imaginary, but here ya go (hands JD an award). Now, you may be thinking WTF? The award is for trying super hard. I don't know, well, any copy and paste stoners that would just jump into coding up weapons and ammo. for that you get my lil imaginary award (it is genuine)

          OK, lets knock this out.

          1) I just wrote the tutorial on bitmasks and constants so you shouldn't be making the first mistake. Which is, reusing same numbers for new flags. All those flags are powers of 2. Which to keep this uber simple, means that the next number is always double the prior one.

          2) Even though that group had a line break, it did not make it some new group

          Code:
          float IT_AXE = 4096;
          float IT_SHOTGUN = 1;
          float IT_SUPER_SHOTGUN = 2;
          float IT_NAILGUN = 4;
          float IT_SUPER_NAILGUN = 8;
          float IT_GRENADE_LAUNCHER = 16;
          float IT_ROCKET_LAUNCHER = 32;
          float IT_LIGHTNING = 64;
          float IT_EXTRA_WEAPON = 128;
          float IT_SHELLS = 256;
          float IT_NAILS = 512;
          float IT_ROCKETS = 1024;
          float IT_CELLS = 2048;
          float IT_CROSSBOW = 8192; //4096 is used by axe
          float IT_ARROW = 16384;
          That will certainly "work" but you have a lot more to do. Open weapons QC...



          yeah I know you thought I was going to keep going but then I would have to take away your award. There's a start, keep trying.

          hopefully one of our quake one qc GODS will help us out!
          I am certainly no QC god, but you know I'm always gonna help you, bro.
          Last edited by MadGypsy; 06-13-2013, 10:23 PM.
          http://www.nextgenquake.com

          Comment


          • #6
            128 ('super lightning') is completely unused.
            8192 is used for IT_ARMOR1. Attempting to reuse it will mess up the hud and/or get confused by grabbing green armor.
            65536 ('superhealth') is unused by the engine. I don't recall the qc needing it either (though it probably should, but that can easily enough be implemented some other way).

            you don't actually need an IT_ARROW. You're better off leaving it as 0 or using some combination of shells/nails/rockets/cells just to distinguish it and ignore whatever the hud randomly picks.

            you could also use .items2 and override the rune display, but that requires a load of code and will end up a bit... crap.
            Some Game Thing

            Comment


            • #7
              ooooh right, I forgot about the other IT's, DOH! Imma leave my post anyway, there's still probably some stuff in there to be understood.
              http://www.nextgenquake.com

              Comment


              • #8
                wife is asleep

                GYPSY AND SPIKE Thank you for posting. i have made a mess of my weapons QC also but i did not post everything i have done. its been a lot but i knew the number were not right on that and did not know why they were there or why they were used. this is just one bite out of a big pie. can you think of a qc where there is a full add of a new weapon, ammo, and ammo box pick up that we can look at to find all the places to update?

                Comment


                • #9
                  Ya, it's called rogue or is it hipnotic - whichever one added some guns
                  http://www.nextgenquake.com

                  Comment


                  • #10
                    im looking at the doe qc looks like the lava nail gun would be a good one to look at. i cant recall where i found it at but Shambler234 if you cant find it and want to see it i can upload it for you.

                    Comment


                    • #11
                      DOE
                      http://www.nextgenquake.com

                      Comment


                      • #12
                        Here's my take on it.

                        Scout's Journey is actually not a good example in this case, because it doesn't use "self.items" at all, nor does it use IT_AXE and friends.

                        However, RemakeQuake can serve as an example, since we added new weapons to that (chainsaw etc) and I used the .items2 method to implement it (which is also used in Chapters and Quoth).

                        .items2

                        You can't just keep adding new entries to .items because there is a limit to how many bits you can store in a float. Although as Spike said, 128 is unused so you can just do IT_CROSSBOW = 128; if you only want to add one new weapon.

                        Basically you add a .float items2, and define your new weapons like this:

                        IT_NEW_WEAPON_1 = 1;
                        IT_NEW_WEAPON_2 = 2;
                        IT_NEW_WEAPON_3 = 4;

                        and so on, just like it's done for (self).items. (side note: you can use .items2 for new keys or ammo as well, RMQ used this to add bronze and platinum keys to key doors)

                        Then you go through the code and wherever something is added to .items (such as in weapon_touch) you do the same for .items2. It helps if you know how to search for something in your entire source code; on Linux you can use "grep", I'm not sure if there's an equivalent for Windows.

                        Same for any other places where .items is used - just add the same thing for .items2. Look at the RMQ code if you're stuck; it is well commented.

                        You need to add the .items2 stuff to the spawn parms at the top of client.qc as well if you want it to travel across levels.

                        Replace vanilla weapons

                        The last problem is that there is a limited amount of number keys available; hence, you probably want to make your new weapon replace one of the old ones. For example, in Quoth the hammer will replace the axe; in RMQ, the chainsaw also replaces the axe, and the blaster replaces the nailgun, and so forth. This is purely to save on the amount of keyboard keys needed.

                        This is accomplished (in W_Attack) by still checking what's in self.weapons, but also checking self.items2 and overriding the corresponding "slot" from self.items.

                        The RMQ sourcecode is here; you might want to take a look at it, especially items.qc, weapons.qc, defs.qc and client.qc.

                        New viewmodel and player animations

                        Of course you will need a new animated viewmodel for your new weapon (the hands and weapon) and you'll also need to add animation frames to your player model (the same amount of frames for both). The viewmodel is set in W_SetCurrentAmmo; self.weaponmodel is the viewmodel, self.weaponframe is the viewmodel's current animation frame. The player model animation is added to player.qc in the same way as all the other animations there; you might be able to just reuse one of the other shooting animations.

                        Pay attention to how the player's shooting animation (player.qc) increments self.weaponframe every frame! This is how the viewmodel animation is synched to the player model's.

                        Firing function

                        You'll probably need to write a W_FireCrossbow() or whatever your new weapon is, for actually firing a projectile etc. I suggest you start by copying one of the other weapon fire functions. You can probably re-use the launch_spike function for a crossbow bolt, just need to replace the model (if self.items2 & IT_CROSSBOW setmodel (newmis, "progs/bolt.mdl"); else...) I'm sure you'll figure that part out.

                        Custom ammo

                        Having custom ammo is a bit of a bitch, because the status bar would need to display the custom ammo icon. I'm not sure if this can be done with a vanilla Quake engine; Spike would be the one to ask since the engine is involved here.

                        HUD

                        Finally, you might want to edit the status bar and weapon graphics to have your new weapon show up in the inventory, just like the plasma gun in Quoth does. This is pretty advanced stuff though and I've written enough already. You should look at the Scourge of Armagon code / assets to see how this is done, I believe (luckily Scout's Journey uses a completely new HUD, so I don't need to subject myself to this kind of torture).

                        That should be about it.
                        Last edited by golden_boy; 06-14-2013, 01:08 AM.
                        Scout's Journey
                        Rune of Earth Magic

                        Comment


                        • #13
                          Originally posted by JDSTONER View Post
                          im looking at the doe qc looks like the lava nail gun would be a good one to look at. i cant recall where i found it at but Shambler234 if you cant find it and want to see it i can upload it for you.
                          sure thing.
                          I am like a stray dog, lost in between what I do and what I should do.
                          But sometimes, all you need is Imagination.

                          Comment


                          • #14
                            Hello Josh and Shambler234

                            I think you have read enough in this thread already, that will most probably help you.

                            Nevertheless, I would like to mention my suggestion how to add a new weapon into your mod. If you already have a good idea how to do it, you can skip this whole post.
                            Adding a new weapon is, compared to the mission packs editing�s, of course much much less work.

                            You basically only need one new float var per weapon (if you keep on using the same existing ammotypes. I would use the nails for your crossbow !). Using the existing ammotypes has several advantages: You can use your mod together with existing maps and it saves you work and trouble. You can add them later into your mod if you feel the need to...

                            So, in my opinion, the easiest way to do this small mod is to compare these 2 sources:
                            - Quake 1.06
                            - Hipnotic

                            You do not need to use a new .items2 float because the regular .items float still has enough free bits for your weapon.
                            Basically, Hipnotic also uses the free bits from original .items for their new weapons.
                            Hipnotic add much more new stuff, so they had to start using .items2 only for their new powerups because they ran out of free bits.
                            Rogue only used .items2, so I would not look into this source, as Rogue did many things very differently.

                            The big big advantage of the Hipnotic source is, that it is very good commented !
                            It uses the Quake source and adds their weapons into the existing functions like:
                            - W_ChangeWeapon
                            - W_Attack
                            - W_BestWeapon
                            - W_SetCurrentAmmo

                            If you use a comparism program, like winmerge or beyond compare, you will see the new lines from Hipnotic
                            very easily (highlighted in a different color) and you will have no issues to follow the exactly same modifications for your new weapon implementation.

                            You can add your new crossbow weapon between any existing id1 weapon (maybe between ssg and ng is a good place)
                            You can use this for your new crossbow:
                            float IT_EXTRA_WEAPON = 128;
                            (Hipnotic adds its Mjolnir weapon to this var as far as I know).
                            You can even add a second weapon that replaces the megahealth (which doesn�t need a var, like Spike explained) in 65536.
                            (Hipnotic adds its Proximity gun to this var as far as I know).

                            So, the main interesting qc files to look into / compare for your new weapon (reason is in bracket) are:
                            - defs.qc (define weapon var)
                            - hippdefs.qc (define weapon var)
                            - weapons.qc (new crossbow weapon functions and extending change weapons functions)
                            - player.qc (for the new animations)

                            You should use commented version of the sources of course.
                            Josh, you will find the commented original sources inside the SMC downloads as well.
                            I am sure that you will be able to implement your new crossbow without much trouble, when following the way it was done in Hipnotic.
                            It is also always very easy to add SMC codes from id1 into Hipnotic, due to this reason.
                            Hipnotic�s main coder Jim Dose used the existing id1 functions as often as possible and commented every entry/edit he did into their functions really good and clear.
                            All the extra features (beside weapons) are put into complete extra .qc files which kept the overview really nice and makes Hipnotic very modular.

                            Have fun with your coding

                            Best wishes,
                            Seven


                            PS: If you want to add new HUD icons, you should start your mod with this extension: -hipnotic and you have access to additional HUD/weapon icons. You need to use Hipnotic�s naming for them, but you can use replacement icons that shows a picture of your weapon.
                            It is not perfect, but it should work.

                            Comment


                            • #15
                              be careful with .items2, it is special and can be used to override the serverflags-based rune display on a per-player basis, which is how both hipnotic and rogue get their extra item bits.

                              if its just one new weapon then things are obvious - just replace the IT_EXTRA_WEAPON with your own weapon and hook it up in the various weapon switching/cycling code.

                              if you want more than one weapon, I personally favour no longer using .items or even .weapon for weapons. use some other fields and update these two system fields as required for correct/appropriate hud display each time you change your current weapon.
                              you can get 23 different weapons that way before things get vile again.
                              Some Game Thing

                              Comment

                              Working...
                              X