Wolf3d Haven Forum

Please log in or register. Smile

Join the forum, it's quick and easy

Wolf3d Haven Forum

Please log in or register. Smile

Wolf3d Haven Forum

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

A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...


3 posters

    [Help] Adding a new ammotype

    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty [Help] Adding a new ammotype

    Post by kkk911 Sun Dec 28, 2014 1:27 am

    So i've recently tried to add a new ammotype (rocktes for a rocket launcher), but got run into troubles, and after several attempts, i gave it up.
    Is there any tutorial for this (except Poet's one, which is writen for DOS), or can anyone write a step-by-step tutorial?
    Because i didn't seem to find a proper one.
    avatar
    Guest
    Guest


    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Guest Sun Dec 28, 2014 4:33 pm

    .


    Last edited by    on Sat Jan 24, 2015 2:59 am; edited 1 time in total
    Andy
    Andy
    Seasoned Wolfer
    Seasoned Wolfer


    Number of posts : 280
    Registration date : 2007-12-22

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Andy Sun Dec 28, 2014 7:30 pm

    Another suggestion: try Poet's tutorial again. I think it should work in SDL, but now you have to specify (weapontype) in SDL. Compare the CheckWeaponChange and GiveWeapon functions between the vanilla DOS and SDL source code for an idea of how/when to use it.

    And when you run across any errors, post them here as you encounter them so we can help debug them.
    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by kkk911 Mon Dec 29, 2014 8:38 am

    "but now you have to specify (weapontype) in SDL" What does this exactly means?
    Also: sorry for being like a newcomer (I'm in coding for 4 years now), but honestly i never applied new ammo type in any of my mods.  And a Rocket launcher that uses regular ammo just looks odd.
    Andy
    Andy
    Seasoned Wolfer
    Seasoned Wolfer


    Number of posts : 280
    Registration date : 2007-12-22

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Andy Mon Dec 29, 2014 9:08 am

    I was merely saying that Poet's DOS tutorial should work in SDL. The only difference that I recall is that you have to add "(weapontype)" in some places.

    If you compare the DOS and SDL WL_AGENT routine CheckWeaponChange (or GiveWeapon), you will see how "(weapontype)" is used. If it's not added, the compiler complains about a type mismatch and won't create an EXE file.

    In your new code, you'll have to add the "(weapontype)" (without quotation marks of course) to where the compiler complains about the type mismatch. Use either of the above SDL example routines to figure out the correct placement.

    In SDL, some things must be explicitly stated, where in the DOS it wasn't necessary (I guess it was assumed by the compiler). Another example of this is the "(statefunc)" that must be added in SDL in WL_ACT2's statetypes when referencing one of those T_Chase or A_DeathScream routines.

    Hope this helps,
    Andy
    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by kkk911 Mon Dec 29, 2014 9:27 am

    Okay, i've experimenting with Poet's code a little bit, and in GiveWeapon function:

    Code:
    void GiveWeapon (int weapon)

    {
       if (weapon != wp_rocket) {
          switch (weapon) {
             case wp_pistol: GiveAmmo (4); break;
             case wp_machinegun: GiveAmmo (6); break;
             case wp_chaingun: GiveAmmo (12); break;
             case wp_rifle: GiveAmmo (6); break;
          }
       }
       else { // weapon == wp_mlauncher
    /**
          if (!gamestate.gotmlauncher) {
             gamestate.extraammo = 1;
    //         GiveAmmo (1);
             gamestate.ammo++ ;
          }
    **/
          gamestate.gotmlauncher = -1;
          GiveAmmo2 (2);
          if (gamestate.weapon != weapon /* wp_mlauncher */) {
             gamestate.weapon = gamestate.chosenweapon = weapontype;
             if (!gamestate.ammo) {
                gamestate.extraammo = 1 ;
                gamestate.ammo++ ;
             }
          }
          return;
       }

       if (gamestate.bestweapon<weapon)
          gamestate.bestweapon = gamestate.weapon
          = gamestate.chosenweapon = weapontype;

       DrawWeapon ();
    }
    I ran into these errors:


    wl_agent.cpp In function `void GiveWeapon(int)': 

    Line: 643 wl_agent.cpp expected primary-expression before ';' token 

    Line: 654 wl_agent.cpp expected primary-expression before ';' token 

    Makefile.win [Build Error]  [wl_agent.o] Error 1 
    Andy
    Andy
    Seasoned Wolfer
    Seasoned Wolfer


    Number of posts : 280
    Registration date : 2007-12-22

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Andy Mon Dec 29, 2014 11:49 am

    your

    "= weapontype;"

    should be

    "= (weapontype) weapon;"

    in both cases.
    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by kkk911 Mon Dec 29, 2014 12:22 pm

    Ohh, i get it. That fixed it!

    Now there is another problem: When i shoot with the rocket launcher, it not just uses the new ammo, but also the regular ammo, even if i run out of new ammo.
    What does causes that?
    Andy
    Andy
    Seasoned Wolfer
    Seasoned Wolfer


    Number of posts : 280
    Registration date : 2007-12-22

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Andy Mon Dec 29, 2014 2:02 pm

    Make sure when you use the rocketlauncher (probably in GunAttack), you're not allowing  gamestate.ammo-- to happen.

    Here's a code snippet that illustrates this.

    In the case of the missile launcher the return after the MissileAttack(ob) statement means we leave the GunAttack routine completely so we never process gamestate.ammo--, which is C++ equivalent to gamestate.ammo = gamestate.ammo - 1.


    Code:
    void    GunAttack (objtype *ob)
    {
        objtype *check,*closest,*oldclosest;
        int      damage;
        int      dx,dy,dist;
        int32_t  viewdist;

        if (gamestate.weapon == wp_mlauncher)  
            {
               MissileAttack (ob);
               return;                    // return to calling routine, stop processing GunAttack
            }

        switch (gamestate.weapon)
        {
            case wp_pistol:
                SD_PlaySound (ATKPISTOLSND);
                break;
            case wp_machinegun:
                SD_PlaySound (ATKMACHINEGUNSND);
                break;
            case wp_chaingun:
                SD_PlaySound (ATKGATLINGSND);
                break;
        }

        gamestate.ammo--;            // decrease regular ammo by 1
        madenoise = true;

        //
        // find potential targets
        //
        viewdist = 0x7fffffffl;
        closest = NULL;
    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by kkk911 Thu Jan 01, 2015 5:54 am

    I've recently found an old new ammo type tutorial, done by Luke Strauman (hope i writed his name down correctly). Tried it out and these errors came in:
    [Help] Adding a new ammotype Ammotype_www.kepfeltoltes.hu_
    Been trying to apply new ammotype for a week now with no luck.....didn't thought that it's that complicated.
    (just wondering why no one has been written a single tutorial about adding new ammotypes in SDL.)

    Edit: Here is the link for the tutorial: http://boytoy31.tripod.com/addanewammotype/
    avatar
    Guest
    Guest


    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Guest Sat Jan 03, 2015 10:45 am

    .


    Last edited by    on Sat Jan 24, 2015 2:59 am; edited 1 time in total
    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by kkk911 Sat Jan 03, 2015 12:37 pm

    The problem is that i barely understand how that thing works at all. (wich doesn't happen often though)
    And that's why i've started this topic in the first place.

    Anyway i nearly succeeded with Poet's tutorial, as i wrote some posts ago, but still have the same problems with it.
    Officer-Michael John
    Officer-Michael John
    Seasoned Wolfer
    Seasoned Wolfer


    Male
    Number of posts : 332
    Age : 26
    Hobbie : Video and Wolf 3D mode making
    Registration date : 2014-08-04

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Officer-Michael John Sat Jan 03, 2015 2:14 pm

    KKK911XD So try it:

    WL:AGENT.CPP:

    #include "wl_def.h"
    #pragma hdrstop

    Code:
    extern   statetype s_rocket;

     { {6,0,1},{6,2,2},{6,0,3},{6,-1,4} },
     { {6,0,1},{6,1,2},{6,0,3},{6,-1,4} },
     { {6,0,1},{6,1,2},{6,3,3},{6,-1,4} },
     { {6,0,1},{6,1,2},{6,4,3},{6,-1,4} },

    Code:
    { {6,0,1},{6,1,2},{6,0,3},{6,-1,4} },    //  missile launcher

    Control Stuff:

    Code:


    // MAC6 77  BrotherTank routine
    // Checks to make sure you have ammo for weapon
    // APN: and that you also have the weapon
    // returns "true" if yes and "false" if no

    int ChkAtkAmmo (int weapon)
    {
      switch (weapon)
      {   
          case wp_knife: return 1;
          case wp_pistol:
              if (gamestate.ammo > 0) return 1;
            break;
          case wp_machinegun:
              if (gamestate.gotmachinegun && gamestate.ammo > 0) return 1;
            break;
          case wp_chaingun:
              if (gamestate.gotgatgun && gamestate.ammo > 0) return 1;
            break;
          case wp_mlauncher:
              if (gamestate.gotmlauncher && gamestate.missile > 0) return 1;
            break;
      }
      return 0;
    }


    CheckWeaponChange:

    Code:

    void CheckWeaponChange (void)     
    {
          int    i,buttons;
          int    j; 

            if (Keyboard[sc_5] && gamestate.gotmlauncher && (gamestate.missile > 0))
                {
                gamestate.chosenweapon = gamestate.weapon = wp_mlauncher ;
                if (!extraammo)
                    extraammo = 1;
                DrawAmmo ();
                return ;   
                }

            if (Keyboard[sc_1] && gamestate.weapon == wp_knife ||
                Keyboard[sc_2] && gamestate.weapon == wp_pistol||
                Keyboard[sc_3] && gamestate.weapon == wp_machinegun && gamestate.gotmachinegun ||
                Keyboard[sc_4] && gamestate.weapon == wp_chaingun && gamestate.gotgatgun)
                if (extraammo)
                    extraammo = 0 ;


            // APN: get best weapon (with ammo) when out of particular ammo


            if ((gamestate.weapon == wp_mlauncher) && (gamestate.missile<1))
                {
                for (j=gamestate.bestweapon; j>=0; j--)
                  if (ChkAtkAmmo(j))
                      {
                        gamestate.weapon = (weapontype) j;
                        break;
                      }
                }
            else if ((gamestate.weapon <= wp_chaingun) && (gamestate.chosenweapon
                      != wp_knife) && (gamestate.ammo < 1))
                {
                for (j=gamestate.bestweapon; j>=0; j--)
                  if (ChkAtkAmmo(j))
                      {
                        gamestate.weapon = (weapontype) j;
                        break;
                      }
                }
            else if ((gamestate.weapon == wp_knife) && (gamestate.chosenweapon
                      != wp_knife) && (gamestate.ammo > 0 || gamestate.missile > 0))
                {
                for (j=gamestate.bestweapon; j>=0; j--)
                  if (ChkAtkAmmo(j))
                      {
                        gamestate.chosenweapon = gamestate.weapon = (weapontype) j;
                        break;
                      }
                }
                // must use knife with no ammo
            else if (!gamestate.ammo && !gamestate.missile)
                gamestate.weapon = wp_knife;  // APN: knife is not "chosen" here
            else if (Keyboard[sc_1] && gamestate.bestweapon >= wp_knife && ChkAtkAmmo(0))
                gamestate.weapon = gamestate.chosenweapon = wp_knife;
            else if (Keyboard[sc_2] && gamestate.bestweapon >= wp_pistol && ChkAtkAmmo(1))
                gamestate.weapon = gamestate.chosenweapon = wp_pistol;
            else if (Keyboard[sc_3] && gamestate.bestweapon >= wp_machinegun && ChkAtkAmmo(2))
                gamestate.weapon = gamestate.chosenweapon = wp_machinegun;
            else if (Keyboard[sc_4] && gamestate.bestweapon >= wp_chaingun && ChkAtkAmmo(3))
                gamestate.weapon = gamestate.chosenweapon = wp_chaingun;
            else if (Keyboard[sc_5] && gamestate.bestweapon >= wp_mlauncher && ChkAtkAmmo(4))
                gamestate.weapon = gamestate.chosenweapon = wp_mlauncher;

            DrawWeapon();
            DrawAmmo ();



    }

    GiveWeapon:

    Code:

    void GiveWeapon (int weapon)
    {

            if (weapon != wp_mlauncher)
            {           
              switch (weapon)
              {
                  case wp_machinegun:
                      GiveAmmo (6);
                      if ((!gamestate.gotmachinegun && !gamestate.gotgatgun &&
                            gamestate.weapon != wp_mlauncher) ||
                            (!gamestate.gotmachinegun && gamestate.weapon <= wp_pistol))
                              gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;

                      gamestate.gotmachinegun = 1;
                      break;

                  case wp_chaingun:
                      GiveAmmo (8);
                      if (!gamestate.gotgatgun && gamestate.weapon != wp_mlauncher)
                            gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;

                      gamestate.gotgatgun = 1;
                      break;

              }
            }
            else    // weapon == wp_mlauncher
            {
            if (!gamestate.gotmlauncher)
                  {
                  gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
                  extraammo = 1;
                  gamestate.gotmlauncher = 1;      // APN: Poet had -1 here
                  }
            GiveMissile (2);        // APN: Missile launcher gives 2 ammo
            }

     
       if (gamestate.bestweapon<weapon)
          gamestate.bestweapon = gamestate.weapon
          = gamestate.chosenweapon = (weapontype) weapon;
          
        DrawWeapon ();      

    }

    GiveMissile:

    Code:
    /*
    ==================
    =
    = GiveMissile
    =
    ==================
    */

    void GiveMissile (int missile)
    {
        gamestate.missile += missile;

        if (gamestate.missile > 30)
            gamestate.missile = 30;

        DrawAmmo ();
    }


    DrawAmmo:

    Code:
    void DrawAmmo (void)
    {
        if(viewsize == 21 && ingame) return;

        if (gamestate.weapon == wp_mlauncher)
            LatchNumber (26,16,3,gamestate.missile);
        else
            LatchNumber (26,16,3,gamestate.ammo);
    }

    GetBonus:
    (Adding Rocket Launcher)

    Code:
    case    bo_mlauncher:
                SD_PlaySound (GETGATLINGSND);
                facetimes = 38;
                GiveWeapon (wp_mlauncher);

                if(viewsize != 21)
                    StatusDrawFace (GOTGATLINGPIC);
                facecount = 0;
                break;

    Adding Rocket:

    Code:
    case    bo_missile:
                if (gamestate.missile >= 30)
                    return;

                SD_PlaySound (GETAMMOSND);
                GiveMissile (1)
                break;

    Player Control:

    Code:
    /*
    ===============
    =
    = MissileAttack    // MAC6 67
    =
    = Poet: adding a missile launcher. This is a new function.
    =
    ===============
    */

    void MissileAttack (objtype *ob)
    {
        if (gamestate.missile<1)
        {
    //      SD_PlaySound (DONOTHINGSND);
          return;
        }
     
        SD_PlaySound (MISSILEFIRESND);

        GetNewActor ();

        newobj->state = &s_rocket;
        newobj->ticcount = 1;

        newobj->x = ob->x ;
        newobj->y = ob->y ;
        newobj->tilex = newobj->x >> TILESHIFT;
        newobj->tiley = newobj->y >> TILESHIFT;
     
        newobj->obclass = rocketobj;
        newobj->dir = nodir;
        newobj->angle = ob->angle;
        newobj->speed = 0x4200l;
    //    new->flags = FL_NONMARK | FL_BONUS; 
    // MAC6 75  APN: fix for door held open
        newobj->flags = 10000110;    // FL_NONMARK | FL_NEVERMARK | FL_BONUS
        newobj->active = ac_yes;

        madenoise = true;

        GiveMissile (-1);
    }

    Code:
    void    GunAttack (objtype *ob)
    {
        objtype *check,*closest,*oldclosest;
        int      damage;
        int      dx,dy,dist;
        int32_t  viewdist;
       
        if (gamestate.weapon == wp_mlauncher)
        {
            MissileAttack (ob);
            GiveAmmo (1);
           
            return;
        }

    Code:
    case 1:
                    if (!gamestate.ammo && gamestate.weapon < wp_mlauncher)
                    {      // can only happen with chain gun
                        gamestate.attackframe++;
                        break;
                    }
                    GunAttack (ob);
                    if (!ammocheat)
                        gamestate.ammo--;
                    DrawAmmo ();
                    break;
    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by kkk911 Sat Jan 03, 2015 3:19 pm

    Hmmm...that sounds good so far, i give it a try!
    ------------------------------------
    Kösz szépen, lehet, hogy ezzel tényleg meg tudom oldani a több, mint egy hete tartó problémát! Smile
    Officer-Michael John
    Officer-Michael John
    Seasoned Wolfer
    Seasoned Wolfer


    Male
    Number of posts : 332
    Age : 26
    Hobbie : Video and Wolf 3D mode making
    Registration date : 2014-08-04

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Officer-Michael John Sun Jan 04, 2015 1:19 am

    Okay. You`re welcome.
    kkk911
    kkk911
    Don't Hurt Me!
    Don't Hurt Me!


    Male
    Number of posts : 62
    Age : 27
    Location : Hungary
    Hobbie : Modding, Photography, Gaming, collecting scale modells
    Registration date : 2012-03-25

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by kkk911 Sun Jan 04, 2015 2:23 am

    Just tried it out and it worked!!!!
    Finally!

    The only problem left is that there is a minor GFX glitch. When i ran out of missiles and the i use the chaingun, when the chaingun animation reaches it's last "frame" (sprite actually), it turns to the first "frame" of the missile launcher for a split second.

    Edit: Oh noes, there is another one....
    When i shoot with the missile launcher directly to an enemy, the rocket instantly disappear and hits it, just like the normal bullet weapons. But when i shoot elsewhere, the missile flies like supposed. Wierd.
    Officer-Michael John
    Officer-Michael John
    Seasoned Wolfer
    Seasoned Wolfer


    Male
    Number of posts : 332
    Age : 26
    Hobbie : Video and Wolf 3D mode making
    Registration date : 2014-08-04

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Officer-Michael John Sun Jan 04, 2015 10:06 am

    Add the graphic so:

     GOTGATLINGPIC,                     // 131
     MUTANTBJPIC,                        // 132
     PAUSEDPIC,                           // 133
     GETPSYCHEDPIC,                    // 134

    Code:
    MLAUNCHER,                // 135

    Change:
    Code:
        ORDERSCREEN=137,
        ERRORSCREEN,                        // 136
        T_HELPART,                          // 137
        T_DEMO0,                            // 138
        T_DEMO1,                            // 139
        T_DEMO2,                            // 140
        T_DEMO3,                            // 141
        T_ENDART1,                          // 142
        T_ENDART2,                          // 143
        T_ENDART3,                          // 144
        T_ENDART4,                          // 145
        T_ENDART5,                          // 146
        T_ENDART6,                          // 147


    #define LEVELEND_LUMP_START 43
    #define LEVELEND_LUMP_END 85

    #define LATCHPICS_LUMP_START 91

    Code:
    #define LATCHPICS_LUMP_END      135

    Code:
    #define NUMCHUNKS    152

    Code:
    #define NUMPICS      133

    Code:
    #define STARTPICM    135
    #define STARTSPRITES 135
    #define STARTTILE8  135
    #define STARTTILE8M  136
    #define STARTTILE16  136
    #define STARTTILE16M 136
    #define STARTTILE32  136
    #define STARTTILE32M 136
    #define STARTEXTERNS 136
    Officer-Michael John
    Officer-Michael John
    Seasoned Wolfer
    Seasoned Wolfer


    Male
    Number of posts : 332
    Age : 26
    Hobbie : Video and Wolf 3D mode making
    Registration date : 2014-08-04

    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Officer-Michael John Sun May 10, 2015 1:53 am

    Hey KKK911XD. Adding Rocket Launcher these files are code changes:WL_DEF.H, WL_ACT1.CPP, WL_AGENT.CPP, WL_DRAW.CPP, WL_PLAY.CPP.

    Adding rocket these files are code changes:WL_DEF.H, WL_ACT1.CPP, WL_AGENT.CPP, WL_MAIN.CPP, WL_GAME.CPP.

    Sponsored content


    [Help] Adding a new ammotype Empty Re: [Help] Adding a new ammotype

    Post by Sponsored content


      Current date/time is Thu Nov 21, 2024 6:43 am