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


    GiveWeapon problem

    ToMi
    ToMi
    Freshmen
    Freshmen

    Male
    Number of posts : 23
    Age : 13
    Location : Czech Republic
    Registration date : 2021-03-29

    GiveWeapon problem Empty GiveWeapon problem

    Post by ToMi Wed Mar 31, 2021 11:00 am

    Hello members!

    I'm currently trying to add a new ammo type (namely fuel for the Flamethrower) into my Wolf4SDL mod. I'm now defining the fuel into GiveWeapon. I was trying to compile it with Code::Blocks, but it displays an error in the log saying:


    Code:
    -------------- Build: default in Wolf4SDL (compiler: GNU GCC Compiler)---------------

    gcc.exe -Dmain=SDL_main -IC:\Dev-Cpp\include\SDL -IC:\Dev-Cpp\include\SDL_mixer -I"C:\Program Files (x86)\CodeBlocks\MinGW\include\SDL" -c D:\Abandonware\Games\Wolfenstein\Project\Code\Wolf4SDL-master\wl_agent.c -o obj\wl_agent.o
    D:\Abandonware\Games\Wolfenstein\Project\Code\Wolf4SDL-master\wl_agent.c: In function 'GiveWeapon':
    D:\Abandonware\Games\Wolfenstein\Project\Code\Wolf4SDL-master\wl_agent.c:1096:14: error: invalid storage class for function 'FixedByFracOrig'
     static fixed FixedByFracOrig(fixed a, fixed b)
                  ^
    D:\Abandonware\Games\Wolfenstein\Project\Code\Wolf4SDL-master\wl_agent.c:1642:1: error: expected declaration or statement at end of input
     }
     ^
    Process terminated with status 1 (0 minute(s), 0 second(s))
    2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

    It appears there is some "{" or "}" missing in my code, but I'm not sure where.


    This is my WL_AGENT definition:

    Code:
    /*
    ==================
    =
    = GiveWeapon
    =
    ==================
    */

    void GiveWeapon (int weapon)
    {
        {
        if (weapon == wp_machinegun)
            {
            GiveAmmo (6);
            if (gamestate.weapon != weapon /*machine gun*/)
                {
                gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
                if (!gamestate.ammo) {
                    gamestate.ammo = 1 ;
                    gamestate.ammo++ ;
                }
            }
            return;
        }
        else if (weapon == wp_chaingun)
            {
            GiveAmmo (6);
            if (gamestate.weapon != weapon /*gatling */)
                {
                gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
                if (!gamestate.ammo) {
                    gamestate.ammo = 1 ;
                    gamestate.ammo++ ;
                }
            }
            return;
        }
        else if (weapon == wp_flame)
            {
            GiveFuel (6);
            if (gamestate.weapon != weapon /* flamethrower */)
                {
                gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
                if (!gamestate.ammo) {
                    gamestate.fuel = 1 ;
                    gamestate.ammo++ ;
                }
            }
            return;
        }

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

        DrawWeapon ();
    }
    Nexion
    Nexion
    Seasoned Wolfer
    Seasoned Wolfer

    Number of posts : 266
    Age : 111
    Location : Dimension of Anti-Time
    Hobbie : bringing chaos & madness into universe
    Message : Planet N
    Registration date : 2008-02-27

    GiveWeapon problem Empty Re: GiveWeapon problem

    Post by Nexion Wed Mar 31, 2021 12:56 pm

    Hi and sure it's in the GiveWeapon part? 1642 seems like at the bottom of the file somewhere.
    ToMi
    ToMi
    Freshmen
    Freshmen

    Male
    Number of posts : 23
    Age : 13
    Location : Czech Republic
    Registration date : 2021-03-29

    GiveWeapon problem Empty Re: GiveWeapon problem

    Post by ToMi Thu Apr 01, 2021 1:27 am

    Well, the log says "In function 'GiveWeapon':", and I didn't any modified the lines at the bottom. so I assume some "{"/"}" is missing, and it counts that the rest of the file content is assigned to the "GiveWeapon" function. But the problem is that I don't know where the problem is.
    Nexion
    Nexion
    Seasoned Wolfer
    Seasoned Wolfer

    Number of posts : 266
    Age : 111
    Location : Dimension of Anti-Time
    Hobbie : bringing chaos & madness into universe
    Message : Planet N
    Registration date : 2008-02-27

    GiveWeapon problem Empty Re: GiveWeapon problem

    Post by Nexion Thu Apr 01, 2021 4:13 am

    Thought i counted it well with your bracket style and went with the message but guess was too tired. Remove the second { from the top.
    Code:
    void GiveWeapon (int weapon)
    {
        //{
    ToMi
    ToMi
    Freshmen
    Freshmen

    Male
    Number of posts : 23
    Age : 13
    Location : Czech Republic
    Registration date : 2021-03-29

    GiveWeapon problem Empty Re: GiveWeapon problem

    Post by ToMi Thu Apr 01, 2021 10:50 am

    Thanks, it worked.

    Also, when I pick-up the Flamethrower and switch to pistol, it disappears and I can't reach it again by pressing "5'". It also doesn't work with other weapons, do someone know how to fix it? I'm a complete noob on coding this function so...


    Last edited by ToMi on Thu Apr 01, 2021 10:50 am; edited 1 time in total (Reason for editing : Grammar)
    Nexion
    Nexion
    Seasoned Wolfer
    Seasoned Wolfer

    Number of posts : 266
    Age : 111
    Location : Dimension of Anti-Time
    Hobbie : bringing chaos & madness into universe
    Message : Planet N
    Registration date : 2008-02-27

    GiveWeapon problem Empty Re: GiveWeapon problem

    Post by Nexion Fri Apr 02, 2021 4:17 am

    Depends on what you did and plan to do. You probably need to rework the CheckWeaponChange on top of wl_agent.c. I assume you only want that you can change to weapons you actually picked up.
    You would need put checks like "if gotweapon5 == true" and "weapon5ammo > 0" into the keyboard check and make sure the game puts it to true or so when you pick up the weapon first time.

    Here is something that might help though it's still for DOS. Other idea would be checking some source codes of other mods to see how they did it.
    http://dhw.wolfenstein3d.com/viewtopic.php?t=2656

    Sponsored content

    GiveWeapon problem Empty Re: GiveWeapon problem

    Post by Sponsored content


      Current date/time is Sat Jul 24, 2021 10:58 am