(Tutorial) Weapon use the Infinate ammo

View previous topic View next topic Go down

(Tutorial) Weapon use the Infinate ammo

Post by Officer-M. John (Admin) on Tue Sep 20, 2016 4:55 pm

Hi members! I test a new my routine and work. My newer routine:Weapon use the Infinate ammo

WL_DEF.H:

Code:

//#define STARTAMMO      8

//    bo_clip,
//    bo_clip2,

//    short      ammo;

//void    GiveAmmo (int ammo);

WL_MAIN.CPP:

Code:

//    gamestate.ammo = STARTAMMO;

//        gamestate.ammo = 8;

WL_GAME.CPP:

Code:

//        gamestate.ammo = STARTAMMO;

WL_ACT1.CPP:

Code:

//    {SPR_STAT_26,bo_clip},                  // Clip            "

//    {SPR_STAT_26,bo_clip2},                // Clip            "

//        case    bo_clip:

WL_AGENT.CPP:

Code:

// 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:                 
      case wp_pistol:
      case wp_machinegun:
      case wp_chaingun:
          return 1;     
  }
  return 0;
}

//    if (!gamestate.ammo)            // must use knife with no ammo
//        return;

//    GiveAmmo (6);

void DrawAmmo (void)
{
//    if(viewsize == 21 && ingame) return;
//    LatchNumber (27,16,2,gamestate.ammo);
   
    switch (gamestate.chosenweapon)
    {
    case wp_knife:
      LatchNumber (27,16,2,0);
      break;   
    case wp_chaingun:
   case wp_machinegun:
   case wp_pistol:
      LatchNumber (27,16,2,99);
}
}

/*
===============
=
= GiveAmmo
=
===============
*/

/*
void GiveAmmo (int ammo)
{
    if (!gamestate.ammo)                            // knife was out
    {
        if (!gamestate.attackframe)
        {
            gamestate.weapon = gamestate.chosenweapon;
            DrawWeapon ();
        }
    }
    gamestate.ammo += ammo;
    if (gamestate.ammo > 99)
        gamestate.ammo = 99;
    DrawAmmo ();
}
*/

//        case    bo_clip:
//            if (gamestate.ammo == 99)
//                return;

//            SD_PlaySound (GETAMMOSND);
//            GiveAmmo (8);
//            break;
//        case    bo_clip2:
//            if (gamestate.ammo == 99)
//                return;

//            SD_PlaySound (GETAMMOSND);
//            GiveAmmo (4);
//            break;

#ifdef SPEAR
        case    bo_25clip:
//            if (gamestate.ammo == 99)
//                return;

            SD_PlaySound (GETAMMOBOXSND);
//            GiveAmmo (25);
            break;
#endif


            case -1:
                ob->state = &s_player;
                if (!ChkAtkAmmo(gamestate.weapon))
                {
                    gamestate.weapon = wp_knife;
                    DrawWeapon ();
                }
                else
                {
                    if (gamestate.weapon != gamestate.chosenweapon)
                    {
                        gamestate.weapon = gamestate.chosenweapon;
                        DrawWeapon ();
                    }
                }
                gamestate.attackframe = gamestate.weaponframe = 0;
                return;

            case 4:
                if (!ChkAtkAmmo(gamestate.weapon))
                    break;
                if (buttonstate[bt_attack])
                    gamestate.attackframe -= 2;
            case 1:
                if (!ChkAtkAmmo(gamestate.weapon))
                {      // can only happen with chain gun
                    gamestate.attackframe++;
                    break;
                }
                GunAttack (ob);
                if (!ammocheat)
//                    gamestate.ammo--;
                DrawAmmo ();
                break;

            case 2:
                KnifeAttack (ob);
                break;

            case 3:
                if (ChkAtkAmmo(gamestate.weapon) && buttonstate[bt_attack])
                    gamestate.attackframe -= 2;
                break;

WL_STATE.CPP:

Code:

        case guardobj:
            GivePoints (100);
            NewState (ob,&s_grddie1);
//            PlaceItemType (bo_clip2,tilex,tiley);
            break;

        case officerobj:
            GivePoints (400);
            NewState (ob,&s_ofcdie1);
//            PlaceItemType (bo_clip2,tilex,tiley);
            break;

        case mutantobj:
            GivePoints (700);
            NewState (ob,&s_mutdie1);
//            PlaceItemType (bo_clip2,tilex,tiley);
            break;

        case ssobj:
            GivePoints (500);
            NewState (ob,&s_ssdie1);
//            if (gamestate.bestweapon < wp_machinegun)
                PlaceItemType (bo_machinegun,tilex,tiley);
//            else
//                PlaceItemType (bo_clip2,tilex,tiley);
            break;

It comes in handy for those who like this tutorial code the unlimited ammo.

avatar
Officer-M. John (Admin)
Admin

Posts : 323
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