コード例 #1
0
ファイル: vlcnfire.c プロジェクト: btb/d1x
void vulcanframe()
{
 int i;

   for(i=0;i<MAX_NUM_NET_PLAYERS;i++)
    if(Players[i].connected && VulcanPlayers[i].vulcanon)
     {
        if((i!=Player_num) && ((VulcanPlayers[i].lastvulcaninfo + VULCAN_NEED_INTERVAL) <= GameTime))
         VulcanPlayers[i].vulcanon=0;
        else if((VulcanPlayers[i].lastvulcanfired + VULCAN_FIRE_INTERVAL) <= GameTime)
         {
           VulcanPlayers[i].lastvulcanfired = GameTime;
           do_laser_firing(Players[i].objnum,VULCAN_INDEX,0,0,1);

            if(VulcanPlayers[Player_num].vulcanon)
             {
                if(i==Player_num)
                 {
                  int ammo_used;
                   ammo_used = Weapon_info[Primary_weapon_to_weapon_info[VULCAN_INDEX]].ammo_usage;

                     if(ammo_used > Players[Player_num].primary_ammo[VULCAN_INDEX])
                      {
                        Players[Player_num].primary_ammo[VULCAN_INDEX] = 0;
                        VulcanPlayers[Player_num].vulcanon = 0;
                        auto_select_weapon(0);
                      }
                     else
                      {
                        Players[Player_num].primary_ammo[VULCAN_INDEX] -= ammo_used;
                         if(Laser_drop_vulcan_ammo && ((vulcan_ammo_used += ammo_used) >= VULCAN_AMMO_AMOUNT*2))
                          {
                            vulcan_ammo_used = 0;
                             if(Players[Player_num].primary_ammo[VULCAN_INDEX] >= VULCAN_AMMO_AMOUNT*2)
                              maybe_drop_net_powerup(POW_VULCAN_AMMO);
                          }
                      }
                   Network_laser_fired = 0;
                 }
                else if(Net_D1xPlayer[i].iver < D1X_ALT_VULCAN_IVER)
                 {
                   //send normal vulcanfire info to player i
                   Network_laser_fired = 1;
                   Network_laser_gun = VULCAN_INDEX;
                   multi_send_fire(i);
                 }
             }
         }
     }

   if(VulcanPlayers[Player_num].vulcanon && ((LastVulcanSent + VULCAN_SEND_INTERVAL) <= GameTime))
    {
      LastVulcanSent = GameTime;
      send_vulcan_info(MULTI_ALT_VULCAN_ON);
    }
}
コード例 #2
0
ファイル: weapon.cpp プロジェクト: Foran/dxx-rebirth
void DropCurrentWeapon ()
{
	int ammo=0,seed;
	objnum_t objnum;

	if (num_objects >= MAX_USED_OBJECTS)
		return;

	if (Primary_weapon==0)
	{
		HUD_init_message(HM_DEFAULT, "You cannot drop your base weapon!");
		return;
	}

	HUD_init_message(HM_DEFAULT, "%s dropped!",PRIMARY_WEAPON_NAMES(Primary_weapon));
	digi_play_sample (SOUND_DROP_WEAPON,F1_0);

	seed = d_rand();

	objnum = spit_powerup(ConsoleObject,Primary_weapon_to_powerup[Primary_weapon],seed);

   if (objnum==object_none)
		return;

	if (Primary_weapon == VULCAN_INDEX || Primary_weapon == GAUSS_INDEX) {

		//if it's one of these, drop some ammo with the weapon

		ammo = Players[Player_num].primary_ammo[VULCAN_INDEX];

		if ((Players[Player_num].primary_weapon_flags & HAS_FLAG(VULCAN_INDEX)) && (Players[Player_num].primary_weapon_flags & HAS_FLAG(GAUSS_INDEX)))
			ammo /= 2;		//if both vulcan & gauss, drop half

		Players[Player_num].primary_ammo[VULCAN_INDEX] -= ammo;

		if (objnum!=object_none)
			Objects[objnum].ctype.powerup_info.count = ammo;
	}

	if (Primary_weapon == OMEGA_INDEX) {

		//dropped weapon has current energy

		if (objnum!=object_none)
			Objects[objnum].ctype.powerup_info.count = Omega_charge;
	}

#ifdef NETWORK
	if ((Game_mode & GM_MULTI) && objnum!=object_none)
		multi_send_drop_weapon(objnum,seed);
#endif

	Players[Player_num].primary_weapon_flags &= (~(1<<Primary_weapon));
	auto_select_weapon (0);
}
コード例 #3
0
ファイル: weapon.cpp プロジェクト: Foran/dxx-rebirth
void DropSecondaryWeapon ()
{
	objnum_t objnum;
	int seed;
	ubyte weapon_drop_id=(ubyte)-1;
	ushort sub_ammo=0;

	if (num_objects >= MAX_USED_OBJECTS)
		return;

	if (Players[Player_num].secondary_ammo[Secondary_weapon] ==0)
	{
		HUD_init_message(HM_DEFAULT, "No secondary weapon to drop!");
		return;
	}

	weapon_drop_id = Secondary_weapon_to_powerup[Secondary_weapon];

	// see if we drop single or 4-pack
	switch (Secondary_weapon_to_powerup[Secondary_weapon])
	{
		case POW_MISSILE_1:
		case POW_HOMING_AMMO_1:
		case POW_SMISSILE1_1:
		case POW_GUIDED_MISSILE_1:
		case POW_MERCURY_MISSILE_1:
			if (Players[Player_num].secondary_ammo[Secondary_weapon]%4)
			{
				sub_ammo = 1;
			}
			else
			{
				sub_ammo = 4;
				weapon_drop_id++; //4-pack always is next index
			}
			break;
		case POW_PROXIMITY_WEAPON:
		case POW_SMART_MINE:
			if (Players[Player_num].secondary_ammo[Secondary_weapon]<4)
			{
				HUD_init_message(HM_DEFAULT, "You need at least 4 to drop!");
				return;
			}
			else
			{
				sub_ammo = 4;
			}
			break;
		case POW_SMARTBOMB_WEAPON:
		case POW_MEGA_WEAPON:
		case POW_EARTHSHAKER_MISSILE:
			sub_ammo = 1;
			break;
	}

	HUD_init_message(HM_DEFAULT, "%s dropped!",SECONDARY_WEAPON_NAMES(Secondary_weapon));
	digi_play_sample (SOUND_DROP_WEAPON,F1_0);

	seed = d_rand();

	objnum = spit_powerup(ConsoleObject,weapon_drop_id,seed);

   if (objnum==object_none)
		return;


#ifdef NETWORK
	if ((Game_mode & GM_MULTI) && objnum!=object_none)
		multi_send_drop_weapon(objnum,seed);
#endif

	Players[Player_num].secondary_ammo[Secondary_weapon]-=sub_ammo;

	if (Players[Player_num].secondary_ammo[Secondary_weapon]==0)
	{
		Players[Player_num].secondary_weapon_flags &= (~(1<<Secondary_weapon));
		auto_select_weapon (1);
	}
}