(Tutorial) Two weapon use a new ammo (my version)

View previous topic View next topic Go down

(Tutorial) Two weapon use a new ammo (my version)

Post by Officer-M. John (Admin) on Thu Jun 02, 2016 9:15 am

Do you want to use two weapons a new ammo? Now I'll explain to you. But before we begin this manual before use:

http://wolf3dfanboys.usersboard.com/t35-tutorial-adding-new-ammo-my-version

Partly that things will be. Here in these files will be changes in the code:

WL_DEF.H:

Code:

typedef enum {
    none,
    block,
    bo_gibs,
    bo_alpo,
    bo_firstaid,
    bo_key1,
    bo_key2,
    bo_key3,
    bo_key4,
    bo_cross,
    bo_chalice,
    bo_bible,
    bo_crown,
    bo_clip,
    bo_clip2,
    bo_ammo2,
    bo_machinegun,
    bo_chaingun,
    bo_food,
    bo_fullheal,
    bo_25clip,
    bo_spear
} wl_stat_t;

WL_ACT1.CPP:

Code:

        case    bo_firstaid:
        case    bo_key1:
        case    bo_key2:
        case    bo_key3:
        case    bo_key4:
        case    bo_clip:
        case    bo_25clip:    
        case    bo_ammo2:
        case    bo_machinegun:
        case    bo_chaingun:
        case    bo_food:
        case    bo_alpo:
        case    bo_gibs:
        case    bo_spear:

WL_AGENT.CPP:

Code:

/*
=============================================================================

                                CONTROL STUFF

=============================================================================
*/


// Checks to make sure you have ammo for 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.ammo2 > 0) return 1;
         break;
      case wp_chaingun:
           if (gamestate.ammo2 > 0) return 1;
         break;
   }
   return 0;
}

/*
======================
=
= CheckWeaponChange
=
= Keys 1-4 change weapons
=
======================
*/

void CheckWeaponChange (void)
{
   int   i,buttons;

   if (!gamestate.ammo && !gamestate.ammo2)      // must use knife with no ammo
   {
      gamestate.weapon = wp_knife;
      return;
   }
   if (gamestate.chosenweapon == wp_pistol && gamestate.bestweapon < wp_pistol && !gamestate.ammo2)
   {
      gamestate.chosenweapon = gamestate.weapon = wp_knife;
   }


/*  
      for (i=wp_knife ; i<=gamestate.bestweapon ; i++)
      if (buttonstate[bt_readyknife+i-wp_knife])
      {
         gamestate.weapon = gamestate.chosenweapon = i;
         DrawWeapon ();
         return;
      }
*/


    if (Keyboard[sc_1] && gamestate.bestweapon >= wp_knife)
    {
      gamestate.weapon = gamestate.chosenweapon = wp_knife;
    }
    if (Keyboard[sc_2] && gamestate.bestweapon >= wp_pistol)
    {
      gamestate.weapon = gamestate.chosenweapon = wp_pistol;
    }
    if (Keyboard[sc_3] && gamestate.bestweapon >= wp_machinegun)
    {
      gamestate.weapon = gamestate.chosenweapon = wp_machinegun;
    }
    if (Keyboard[sc_4] && gamestate.bestweapon >= wp_chaingun)
    {
      gamestate.weapon = gamestate.chosenweapon = wp_chaingun;
    }
    
   //make ammo change with ammo/ammo2
   if (gamestate.chosenweapon == wp_pistol)
   {
      gamestate.ammo;
   }
   if (gamestate.chosenweapon == wp_machinegun || gamestate.chosenweapon == wp_chaingun)
   {
      gamestate.ammo2;
   }
  
   DrawWeapon ();
   DrawAmmo ();
}

/*
==================
=
= GiveWeapon
=
==================
*/

void GiveWeapon (int weapon)
{
    if (weapon == wp_machinegun)
 GiveAmmo2 (8);
    if (weapon == wp_chaingun)
 GiveAmmo2 (25);

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

 DrawWeapon ();
}

/*
===============
=
= DrawAmmo
=
===============
*/

void DrawAmmo (void)
{
    switch (gamestate.chosenweapon)
    {
 case wp_machinegun:
 case wp_chaingun:
      LatchNumber (27,16,2,gamestate.ammo2);
              break;
        case wp_knife:
             LatchNumber(27,16,2,0);
             break;
        default:
            LatchNumber (27,16,2,gamestate.ammo);
       }
}

            case -1:
                ob->state = &s_player;
                if (!gamestate.ammo && gamestate.weapon == wp_pistol ||
                    !gamestate.ammo2 && gamestate.weapon == wp_machinegun ||
                    !gamestate.ammo2 && gamestate.weapon == wp_chaingun)
                {
                    gamestate.weapon = gamestate.chosenweapon = wp_knife;
                    DrawWeapon ();
                }
                else
                {
                //   if (gamestate.weapon != gamestate.chosenweapon)
                 //   {
                        gamestate.weapon = gamestate.chosenweapon;
                        DrawWeapon ();
                 //   }
                }
                gamestate.attackframe = gamestate.weaponframe = 0;
                return;

            case 1:
                if (!gamestate.ammo && gamestate.weapon == wp_pistol ||
                    !gamestate.ammo2 && gamestate.weapon == wp_machinegun ||
                    !gamestate.ammo2 && gamestate.weapon == wp_chaingun)
                {       // can only happen with chain gun
                    gamestate.attackframe++;
                    break;
                }
                GunAttack (ob);
                if (gamestate.chosenweapon == wp_pistol)
                {
                    gamestate.ammo--;
                    DrawAmmo ();
                }
                if (gamestate.chosenweapon == wp_machinegun)
                {
                    gamestate.ammo2--;
                    DrawAmmo ();
                }
                if (gamestate.chosenweapon == wp_chaingun)
                {
                    gamestate.ammo2--;
                    DrawAmmo ();
                }
                break;
avatar
Officer-M. John (Admin)
Admin

Posts : 328
Join date : 2015-10-02
Age : 19

View user profile http://wolf3dfanboys.usersboard.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum