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...


2 posters

    Change weapon problem SDL

    Milanor
    Milanor
    Bring em' On!
    Bring em' On!


    Number of posts : 127
    Age : 35
    Registration date : 2014-05-23

    Change weapon problem SDL Empty Change weapon problem SDL

    Post by Milanor Sun Jun 01, 2014 7:50 am

    Hey all,

    so I've decided to add two new weapons in my mod and I have defined everything along with adding additional keybinds to the source code, but what is strange is that when I pick up one of the weapons, it wouldn't allow me to go there when I pressed that key.
    (e.g. keys 1-6 changes weapons, 1-knife, 2-pistol, 3-machine gun, 4-chaingun, 5-silent pistol, 6-stg 44) When I pick up other weapons from 1-4 there was no problem, but when I picked up 5 or 6, I couldn't switch to them (unless I pressed the grave accent '`' key on the keyboard).  I'm not sure what the problem is, because I went through my check weapon change code and didn't see any problem with it, I added the new weapon definitions in the wl_def.h header file, and also in wl_play.cpp I added the additional key binds.  If there is something missing or an oversight, I would like to know since I can't track down the root of the problem.   Crying or Very sad 

    From Wl_play.cpp
    Code:
    //
    // control info
    //
    boolean mouseenabled, joystickenabled;
    int dirscan[4] = { sc_UpArrow, sc_RightArrow, sc_DownArrow, sc_LeftArrow };
    int buttonscan[NUMBUTTONS] = { sc_Control, sc_Alt, sc_LShift, sc_Space, sc_1, sc_2, sc_3, sc_4, sc_5, sc_6 }; //sc_5 and sc_6 for silent pistol and stg 44.
    int buttonmouse[4] = { bt_attack, bt_strafe, bt_use, bt_nobutton };
    int buttonjoy[32] = {
    #ifdef _arch_dreamcast
        bt_attack, bt_strafe, bt_use, bt_run, bt_esc, bt_prevweapon, bt_nobutton, bt_nextweapon,
        bt_pause, bt_strafeleft, bt_straferight, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton,
    #else
        bt_attack, bt_strafe, bt_use, bt_run, bt_strafeleft, bt_straferight, bt_esc, bt_pause,
        bt_prevweapon, bt_nextweapon, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton,
    #endif
        bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton,
        bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton
    };

    From Wl_agent.cpp
    Code:
    /*
    ======================
    =
    = CheckWeaponChange
    =
    = Keys 1-6 change weapons
    =
    ======================
    */

    void CheckWeaponChange (void)
    {
        int newWeapon = -1;
        
        if (!gamestate.ammo)            // must use knife with no ammo
            return;

    #ifdef _arch_dreamcast
        int joyx, joyy;
        IN_GetJoyFineDelta (&joyx, &joyy);
        if(joyx < -64)
            buttonstate[bt_prevweapon] = true;
        else if(joyx > 64)
            buttonstate[bt_nextweapon] = true;
    #endif
        
       
       
        //
        if(buttonstate[bt_nextweapon] && !buttonheld[bt_nextweapon])
        {
            newWeapon = gamestate.weapon + 1;
            if(newWeapon > gamestate.bestweapon) newWeapon = 0;
        }
        else if(buttonstate[bt_prevweapon] && !buttonheld[bt_prevweapon])
        {
            newWeapon = gamestate.weapon - 1;
            if(newWeapon < 0) newWeapon = gamestate.bestweapon;
        }
        else
        {
            for(int i = wp_knife; i <= gamestate.bestweapon; i++)
            {
                if (buttonstate[bt_readyknife + i - wp_knife])
                {
                    newWeapon = i;
                    break;
                }
            }
        }

        if(newWeapon != -1)
        {
            gamestate.weapon = gamestate.chosenweapon = (weapontype) newWeapon;
            DrawWeapon();
        }
    }

    From wl_def.h
    Code:
    enum
    {
        bt_nobutton=-1,
        bt_attack=0,
        bt_strafe,
        bt_run,
        bt_use,
        bt_readyknife,
        bt_readypistol,
        bt_readymachinegun,
        bt_readychaingun,
        bt_readyspistol, //ready silent pistol.
        bt_readystg44, //ready stg44.
        bt_nextweapon,
        bt_prevweapon,
        bt_esc,
        bt_pause,
        bt_strafeleft,
        bt_straferight,
        bt_moveforward,
        bt_movebackward,
        bt_turnleft,
        bt_turnright,
        NUMBUTTONS
    };


    #define NUMWEAPONS      6 //added more weapons
    typedef enum
    {
        wp_knife,
        wp_pistol,
        wp_machinegun,
        wp_chaingun,
        wp_spistol,
        wp_stg44
    } weapontype;

    AlumiuN
    AlumiuN
    Don't Hurt Me!
    Don't Hurt Me!


    Number of posts : 52
    Age : 32
    Location : Christchurch, New Zealand
    Registration date : 2013-08-31

    Change weapon problem SDL Empty Re: Change weapon problem SDL

    Post by AlumiuN Sun Jun 01, 2014 5:16 pm

    Have you tried deleting your mod's config file?
    Milanor
    Milanor
    Bring em' On!
    Bring em' On!


    Number of posts : 127
    Age : 35
    Registration date : 2014-05-23

    Change weapon problem SDL Empty Re: Change weapon problem SDL

    Post by Milanor Sun Jun 01, 2014 8:27 pm

    Nope, but after I did that, the weapon selection keys work now! Smile Now I just have to clean up the graphical glitches with the new max health (happens when health is over 100%, since I decide to raise the original max health for my mod.) as well as the ammo (if I get more than 99 ammo).  Razz

    Sponsored content


    Change weapon problem SDL Empty Re: Change weapon problem SDL

    Post by Sponsored content


      Current date/time is Fri Nov 22, 2024 11:57 pm