// --------------------------------------------------------------------- //called when one of these weapons is picked up //when you pick up a secondary, you always get the weapon & ammo for it // Returns true if powerup picked up, else returns false. int pick_up_secondary(int weapon_index,int count) { int max; int num_picked_up; int cutpoint; max = Secondary_ammo_max[weapon_index]; if (Players[Player_num].flags & PLAYER_FLAGS_AMMO_RACK) max *= 2; if (Players[Player_num].secondary_ammo[weapon_index] >= max) { HUD_init_message(HM_DEFAULT|HM_REDUNDANT|HM_MAYDUPL, "%s %i %ss!", TXT_ALREADY_HAVE, Players[Player_num].secondary_ammo[weapon_index],SECONDARY_WEAPON_NAMES(weapon_index)); return 0; } Players[Player_num].secondary_weapon_flags |= (1<<weapon_index); Players[Player_num].secondary_ammo[weapon_index] += count; num_picked_up = count; if (Players[Player_num].secondary_ammo[weapon_index] > max) { num_picked_up = count - (Players[Player_num].secondary_ammo[weapon_index] - max); Players[Player_num].secondary_ammo[weapon_index] = max; } if (Players[Player_num].secondary_ammo[weapon_index] == count) // only autoselect if player didn't have any { cutpoint=SOrderList (255); if (((Controls.fire_secondary_state && PlayerCfg.NoFireAutoselect)?0:1) && SOrderList (weapon_index)<cutpoint && ((SOrderList (weapon_index) < SOrderList(Secondary_weapon)) || (Players[Player_num].secondary_ammo[Secondary_weapon] == 0)) ) select_weapon(weapon_index,1, 0, 1); else { //if we don't auto-select this weapon, but it's a proxbomb or smart mine, //we want to do a mini-auto-selection that applies to the drop bomb key if ((weapon_index == PROXIMITY_INDEX || weapon_index == SMART_MINE_INDEX) && !(Secondary_weapon == PROXIMITY_INDEX || Secondary_weapon == SMART_MINE_INDEX)) { int cur; cur = Secondary_last_was_super[PROXIMITY_INDEX]?SMART_MINE_INDEX:PROXIMITY_INDEX; if (SOrderList (weapon_index) < SOrderList(cur)) Secondary_last_was_super[PROXIMITY_INDEX] = (weapon_index == SMART_MINE_INDEX); } } } //note: flash for all but concussion was 7,14,21 if (num_picked_up>1) { PALETTE_FLASH_ADD(15,15,15); HUD_init_message(HM_DEFAULT, "%d %ss (count=%i)!",num_picked_up,SECONDARY_WEAPON_NAMES(weapon_index), Players[Player_num].secondary_ammo[weapon_index]); } else { PALETTE_FLASH_ADD(10,10,10); HUD_init_message(HM_DEFAULT, "%s (count=%i)!",SECONDARY_WEAPON_NAMES(weapon_index), Players[Player_num].secondary_ammo[weapon_index]); } return 1; }
// ---------------------------------------------------------------------------------------- // Show tPlayer which weapons he has, how much ammo... // Looks like a debug screen now because it writes to mono screen, but that will change... void ShowWeaponStatus (void) { int i; #if TRACE for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) { if (LOCALPLAYER.primaryWeaponFlags & (1 << i)) con_printf (CONDBG, "HAVE"); else con_printf (CONDBG, " "); con_printf (CONDBG, " Weapon: %20s, charges: %4i\n", PRIMARY_WEAPON_NAMES(i), LOCALPLAYER.primaryAmmo [i]); } con_printf (CONDBG, "\n"); for (i = 0; i < MAX_SECONDARY_WEAPONS; i++) { if (LOCALPLAYER.secondaryWeaponFlags & (1 << i)) con_printf (CONDBG, "HAVE"); else con_printf (CONDBG, " "); con_printf (CONDBG, " Weapon: %20s, charges: %4i\n", SECONDARY_WEAPON_NAMES(i), LOCALPLAYER.secondaryAmmo [i]); } con_printf (CONDBG, "\n"); con_printf (CONDBG, "\n"); #endif }
// ------------------------------------------------------------------------------------ // Select a weapon, primary or secondary. void do_weapon_select(int weapon_num, int secondary_flag) { int weapon_num_save=weapon_num; int weapon_status,current,has_flag; ubyte last_was_super; if (!secondary_flag) { current = Primary_weapon; last_was_super = Primary_last_was_super[weapon_num]; has_flag = HAS_WEAPON_FLAG; } else { current = Secondary_weapon; last_was_super = Secondary_last_was_super[weapon_num]; has_flag = HAS_WEAPON_FLAG+HAS_AMMO_FLAG; } if (current == weapon_num || current == weapon_num+SUPER_WEAPON) { //already have this selected, so toggle to other of normal/super version weapon_num += weapon_num+SUPER_WEAPON - current; weapon_status = player_has_weapon(weapon_num, secondary_flag); } else { //go to last-select version of requested missile if (last_was_super) weapon_num += SUPER_WEAPON; weapon_status = player_has_weapon(weapon_num, secondary_flag); //if don't have last-selected, try other version if ((weapon_status & has_flag) != has_flag) { weapon_num = 2*weapon_num_save+SUPER_WEAPON - weapon_num; weapon_status = player_has_weapon(weapon_num, secondary_flag); if ((weapon_status & has_flag) != has_flag) weapon_num = 2*weapon_num_save+SUPER_WEAPON - weapon_num; } } //if we don't have the weapon we're switching to, give error & bail if ((weapon_status & has_flag) != has_flag) { if (!secondary_flag) { if (weapon_num==SUPER_LASER_INDEX) return; //no such thing as super laser, so no error HUD_init_message(HM_DEFAULT, "%s %s!", TXT_DONT_HAVE, PRIMARY_WEAPON_NAMES(weapon_num)); } else HUD_init_message(HM_DEFAULT, "%s %s%s",TXT_HAVE_NO, SECONDARY_WEAPON_NAMES(weapon_num), TXT_SX); digi_play_sample( SOUND_BAD_SELECTION, F1_0 ); return; } //now actually select the weapon select_weapon(weapon_num, secondary_flag, 1, 1); }
void DropSecondaryWeapon (int nWeapon) { int nObject, seed, nPowerup, bHoardEntropy, bMine; if (nWeapon < 0) nWeapon = gameData.weapons.nSecondary; if (LOCALPLAYER.secondaryAmmo [nWeapon] == 0) { HUDInitMessage (TXT_CANT_DROP_SEC); return; } nPowerup = secondaryWeaponToPowerup[nWeapon]; bHoardEntropy = (gameData.app.nGameMode & (GM_HOARD | GM_ENTROPY)) != 0; bMine = (nPowerup == POW_PROXMINE) || (nPowerup == POW_SMARTMINE); if (!bHoardEntropy && bMine && LOCALPLAYER.secondaryAmmo [nWeapon] < 4) { HUDInitMessage(TXT_DROP_NEED4); return; } if (bHoardEntropy) { DropOrb (); return; } if (bMine) LOCALPLAYER.secondaryAmmo [nWeapon] -= 4; else LOCALPLAYER.secondaryAmmo [nWeapon]--; seed = d_rand(); nObject = SpitPowerup (gameData.objs.consoleP, nPowerup, seed); if (nObject == -1) { if (bMine) LOCALPLAYER.secondaryAmmo [nWeapon] += 4; else LOCALPLAYER.secondaryAmmo [nWeapon]++; return; } HUDInitMessage (TXT_DROP_WEAPON, SECONDARY_WEAPON_NAMES (gameData.weapons.nSecondary)); audio.PlaySound (SOUND_DROP_WEAPON); if (gameData.app.nGameMode & GM_MULTI) { MultiSendDropWeapon (nObject, seed); MultiSendWeapons (1); } if (LOCALPLAYER.secondaryAmmo [nWeapon] == 0) { LOCALPLAYER.secondaryWeaponFlags &= (~(1<<gameData.weapons.nSecondary)); AutoSelectWeapon (1, 0); } }
// --------------------------------------------------------------------- //called when one of these weapons is picked up //when you pick up a secondary, you always get the weapon & ammo for it // Returns true if powerup picked up, else returns false. int PickupSecondary (tObject *objP, int nWeaponIndex, int nAmount, int nPlayer) { int nMaxAmount; int nPickedUp; int nCutPoint, bEmpty = 0, bSmokeGrens; tPlayer *playerP = gameData.multiplayer.players + nPlayer; if ((nWeaponIndex == PROXMINE_INDEX) && !COMPETITION && EGI_FLAG (bSmokeGrenades, 0, 0, 0)) { bSmokeGrens = 1; nMaxAmount = 4; } else { bSmokeGrens = 0; nMaxAmount = nMaxSecondaryAmmo [nWeaponIndex]; if (playerP->flags & PLAYER_FLAGS_AMMO_RACK) nMaxAmount *= 2; } if (playerP->secondaryAmmo [nWeaponIndex] >= nMaxAmount) { if (ISLOCALPLAYER (nPlayer)) HUDInitMessage("%s %i %ss!", TXT_ALREADY_HAVE, playerP->secondaryAmmo [nWeaponIndex], bSmokeGrens ? TXT_SMOKE_GRENADE : SECONDARY_WEAPON_NAMES (nWeaponIndex)); return 0; } playerP->secondaryWeaponFlags |= (1 << nWeaponIndex); playerP->secondaryAmmo [nWeaponIndex] += nAmount; nPickedUp = nAmount; if (playerP->secondaryAmmo [nWeaponIndex] > nMaxAmount) { nPickedUp = nAmount - (playerP->secondaryAmmo [nWeaponIndex] - nMaxAmount); playerP->secondaryAmmo [nWeaponIndex] = nMaxAmount; if ((nPickedUp < nAmount) && (nWeaponIndex != PROXMINE_INDEX) && (nWeaponIndex != SMARTMINE_INDEX)) { short nObject = OBJ_IDX (objP); gameData.multiplayer.leftoverPowerups [nObject].nCount = nAmount - nPickedUp; gameData.multiplayer.leftoverPowerups [nObject].nType = secondaryWeaponToPowerup [nWeaponIndex]; gameData.multiplayer.leftoverPowerups [nObject].spitterP = OBJECTS + playerP->nObject; } } if (ISLOCALPLAYER (nPlayer)) { nCutPoint = SOrderList (255); bEmpty = playerP->secondaryAmmo [gameData.weapons.nSecondary] == 0; if (gameOpts->gameplay.nAutoSelectWeapon) { if (gameOpts->gameplay.nAutoSelectWeapon == 1) { if (bEmpty) SelectWeapon (nWeaponIndex, 1, 0, 1); } else if ((SOrderList (nWeaponIndex) < nCutPoint) && (bEmpty || (SOrderList (nWeaponIndex) < SOrderList (gameData.weapons.nSecondary)))) SelectWeapon (nWeaponIndex,1, 0, 1); else { //if we don't auto-select this weapon, but it's a proxbomb or smart mine, //we want to do a mini-auto-selection that applies to the drop bomb key if ((nWeaponIndex == PROXMINE_INDEX || nWeaponIndex == SMARTMINE_INDEX) && !(gameData.weapons.nSecondary == PROXMINE_INDEX || gameData.weapons.nSecondary == SMARTMINE_INDEX)) { int cur = bLastSecondaryWasSuper [PROXMINE_INDEX] ? PROXMINE_INDEX : SMARTMINE_INDEX; if (SOrderList (nWeaponIndex) < SOrderList (cur)) bLastSecondaryWasSuper[PROXMINE_INDEX] = (nWeaponIndex == SMARTMINE_INDEX); } } } //note: flash for all but concussion was 7,14,21 if (nAmount>1) { PALETTE_FLASH_ADD (15,15,15); HUDInitMessage("%d %s%s", nPickedUp, bSmokeGrens ? TXT_SMOKE_GRENADES : SECONDARY_WEAPON_NAMES (nWeaponIndex), TXT_SX); } else { PALETTE_FLASH_ADD (10,10,10); HUDInitMessage("%s!", bSmokeGrens ? TXT_SMOKE_GRENADE : SECONDARY_WEAPON_NAMES (nWeaponIndex)); } } return 1; }
//flags whether the last time we use this weapon, it was the 'super' version // ------------------------------------------------------------------------------------ // Select a weapon, primary or secondary. void DoSelectWeapon (int nWeapon, int bSecondary) { int nWeaponSave = nWeapon; int nWeaponStatus, nCurrent, hasFlag; ubyte bLastWasSuper; if (!bSecondary) { nCurrent = gameData.weapons.nPrimary; if ((nCurrent == LASER_INDEX) && (LOCALPLAYER.laserLevel > MAX_LASER_LEVEL)) nCurrent = SUPER_LASER_INDEX; bLastWasSuper = bLastPrimaryWasSuper [nWeapon]; if ((nWeapon == LASER_INDEX) && (LOCALPLAYER.laserLevel > MAX_LASER_LEVEL)) nWeapon = SUPER_LASER_INDEX; hasFlag = HAS_WEAPON_FLAG; LOCALPLAYER.energy += gameData.fusion.xCharge; gameData.fusion.xCharge = 0; } else if (nWeapon == 2) { ToggleBomb (); return; } else { nCurrent = gameData.weapons.nSecondary; bLastWasSuper = bLastSecondaryWasSuper [nWeapon % SUPER_WEAPON]; hasFlag = HAS_WEAPON_FLAG + HAS_AMMO_FLAG; } if ((nCurrent == nWeapon) || (nCurrent == nWeapon + SUPER_WEAPON)) { //already have this selected, so toggle to other of Normal/super version if (!bSecondary && (nCurrent == SUPER_LASER_INDEX)) return; nWeapon %= SUPER_WEAPON; if (!bLastWasSuper) nWeapon += SUPER_WEAPON; nWeaponStatus = PlayerHasWeapon (nWeapon, bSecondary, -1, 0); } else { //go to last-select version of requested missile if (bLastWasSuper && (nWeapon < SUPER_WEAPON)) nWeapon += SUPER_WEAPON; nWeaponStatus = PlayerHasWeapon (nWeapon, bSecondary, -1, 0); //if don't have last-selected, try other version if ((nWeaponStatus & hasFlag) != hasFlag) { nWeapon = 2 * nWeaponSave + SUPER_WEAPON - nWeapon; nWeaponStatus = PlayerHasWeapon (nWeapon, bSecondary, -1, 0); if ((nWeaponStatus & hasFlag) != hasFlag) nWeapon = 2 * nWeaponSave + SUPER_WEAPON - nWeapon; } } //if we don't have the weapon we're switching to, give error & bail if ((nWeaponStatus & hasFlag) != hasFlag) { if (!bSecondary) { if (nWeapon == SUPER_LASER_INDEX) return; //no such thing as super laser, so no error HUDInitMessage ("%s %s!", TXT_DONT_HAVE, PRIMARY_WEAPON_NAMES (nWeapon)); } else HUDInitMessage ("%s %s%s",TXT_HAVE_NO, SECONDARY_WEAPON_NAMES (nWeapon), TXT_SX); DigiPlaySample (SOUND_BAD_SELECTION, F1_0); return; } //now actually select the weapon SelectWeapon (nWeapon, bSecondary, 1, 1); }
// ------------------------------------------------------------------------------------ //if message flag set, print message saying selected void SelectWeapon (int nWeaponNum, int bSecondary, int bPrintMessage, int bWaitForRearm) { const char *szWeaponName; if (gameData.demo.nState == ND_STATE_RECORDING) NDRecordPlayerWeapon (bSecondary, nWeaponNum); if (!bSecondary) { if (gameData.weapons.nPrimary != nWeaponNum) { if (bWaitForRearm) DigiPlaySampleOnce (SOUND_GOOD_SELECTION_PRIMARY, F1_0); if (IsMultiGame) { if (bWaitForRearm) MultiSendPlaySound (SOUND_GOOD_SELECTION_PRIMARY, F1_0); } gameData.laser.xNextFireTime = bWaitForRearm ? gameData.time.xGame + (fix) (gameStates.gameplay.slowmo [1].fSpeed * REARM_TIME) : 0; gameData.laser.nGlobalFiringCount = 0; } else { // Select super version if available. if (bWaitForRearm) { if (!bCycling) ; // -- MK, only plays when can't fire weapon anyway, fixes bug -- DigiPlaySampleOnce(SOUND_ALREADY_SELECTED, F1_0); else DigiPlaySampleOnce(SOUND_BAD_SELECTION, F1_0); } } gameData.weapons.nOverridden = nWeaponNum; if (!bSecondary && extraGameInfo [IsMultiGame].bSmartWeaponSwitch && !gameStates.app.bD1Mission) { switch (nWeaponNum) { case 1: if (LOCALPLAYER.primaryWeaponFlags & (1 << 6)) nWeaponNum = 6; break; case 2: if (LOCALPLAYER.primaryWeaponFlags & (1 << 7)) nWeaponNum = 7; break; } } gameData.weapons.nPrimary = (!bSecondary && (nWeaponNum == SUPER_LASER_INDEX)) ? LASER_INDEX : nWeaponNum; StopPrimaryFire (); szWeaponName = PRIMARY_WEAPON_NAMES (nWeaponNum); #if defined (TACTILE) TactileSetButtonJolt(); #endif //save flag for whether was super version bLastPrimaryWasSuper [nWeaponNum % SUPER_WEAPON] = (nWeaponNum >= SUPER_WEAPON); } else { if (gameData.weapons.nSecondary != nWeaponNum) { if (bWaitForRearm) DigiPlaySampleOnce (SOUND_GOOD_SELECTION_SECONDARY, F1_0); if (IsMultiGame) { if (bWaitForRearm) MultiSendPlaySound (SOUND_GOOD_SELECTION_PRIMARY, F1_0); } gameData.missiles.xNextFireTime = bWaitForRearm ? gameData.time.xGame + REARM_TIME : 0; gameData.missiles.nGlobalFiringCount = 0; } else { if (bWaitForRearm) { if (!bCycling) DigiPlaySampleOnce (SOUND_ALREADY_SELECTED, F1_0); else DigiPlaySampleOnce (SOUND_BAD_SELECTION, F1_0); } } //if (nWeaponNum % SUPER_WEAPON != PROXMINE_INDEX) gameData.weapons.nSecondary = nWeaponNum; szWeaponName = SECONDARY_WEAPON_NAMES (nWeaponNum); //save flag for whether was super version bLastSecondaryWasSuper [nWeaponNum % SUPER_WEAPON] = (nWeaponNum >= SUPER_WEAPON); } if (bPrintMessage) { if (nWeaponNum == LASER_INDEX && !bSecondary) HUDInitMessage (TXT_WPN_LEVEL, szWeaponName, LOCALPLAYER.laserLevel + 1, TXT_SELECTED); else HUDInitMessage ("%s %s", szWeaponName, TXT_SELECTED); } }
void ReorderSecondary () { newmenu_item m[MAX_SECONDARY_WEAPONS+1]; int i; for (i=0;i<MAX_SECONDARY_WEAPONS+1;i++) { nm_set_item_menu(&m[i], (PlayerCfg.SecondaryOrder[i]==255) ? "--- Never Autoselect below ---" : SECONDARY_WEAPON_NAMES(PlayerCfg.SecondaryOrder[i])); m[i].value=PlayerCfg.SecondaryOrder[i]; } i = newmenu_doreorder("Reorder Secondary","Shift+Up/Down arrow to move item", i, m, NULL, NULL); for (i=0;i<MAX_SECONDARY_WEAPONS+1;i++) PlayerCfg.SecondaryOrder[i]=m[i].value; }
// ------------------------------------------------------------------------------------ //if message flag set, print message saying selected void select_weapon(int weapon_num, int secondary_flag, int print_message, int wait_for_rearm) { const char *weapon_name; if (Newdemo_state==ND_STATE_RECORDING ) newdemo_record_player_weapon(secondary_flag, weapon_num); if (!secondary_flag) { if (Primary_weapon != weapon_num) { #ifndef FUSION_KEEPS_CHARGE //added 8/6/98 by Victor Rachels to fix fusion charge bug Fusion_charge=0; //end edit - Victor Rachels #endif if (wait_for_rearm) digi_play_sample_once( SOUND_GOOD_SELECTION_PRIMARY, F1_0 ); #ifdef NETWORK if (Game_mode & GM_MULTI) { if (wait_for_rearm) multi_send_play_sound(SOUND_GOOD_SELECTION_PRIMARY, F1_0); } #endif if (wait_for_rearm) Next_laser_fire_time = GameTime64 + REARM_TIME; else Next_laser_fire_time = 0; Global_laser_firing_count = 0; } Primary_weapon = weapon_num; weapon_name = PRIMARY_WEAPON_NAMES(weapon_num); //save flag for whether was super version Primary_last_was_super[weapon_num % SUPER_WEAPON] = (weapon_num >= SUPER_WEAPON); } else { if (Secondary_weapon != weapon_num) { if (wait_for_rearm) digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 ); #ifdef NETWORK if (Game_mode & GM_MULTI) { if (wait_for_rearm) multi_send_play_sound(SOUND_GOOD_SELECTION_PRIMARY, F1_0); } #endif if (wait_for_rearm) Next_missile_fire_time = GameTime64 + REARM_TIME; else Next_missile_fire_time = 0; Global_missile_firing_count = 0; } else { if (wait_for_rearm) { digi_play_sample_once( SOUND_ALREADY_SELECTED, F1_0 ); } } Secondary_weapon = weapon_num; weapon_name = SECONDARY_WEAPON_NAMES(weapon_num); //save flag for whether was super version Secondary_last_was_super[weapon_num % SUPER_WEAPON] = (weapon_num >= SUPER_WEAPON); } if (print_message) { const player *const plr = &Players[Player_num]; if (weapon_num == LASER_INDEX && !secondary_flag) HUD_init_message(HM_DEFAULT, "%s Level %d selected (energy=%i)!", weapon_name, plr->laser_level+1, f2i(plr->energy)); else if (!secondary_flag && (weapon_num == 1 || weapon_num == 6)) HUD_init_message(HM_DEFAULT, "%s selected (ammo=%i/%i)!", weapon_name, PRINTABLE_VULCAN_AMMO(plr->primary_ammo[1]), PRINTABLE_VULCAN_AMMO(CURRENT_VULCAN_AMMO_CAPACITY(Player_num))); else if (!secondary_flag) HUD_init_message(HM_DEFAULT, "%s selected (energy=%i)!", weapon_name, f2i(plr->energy)); else HUD_init_message(HM_DEFAULT, "%s selected (count=%i)!", weapon_name, plr->secondary_ammo[weapon_num]); } }
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); } }