Beispiel #1
0
static void cheat_weapx(const void *arg)
{
   const char *buf = (const char *)arg;
   int w = *buf - '1';
   int pwstr = pw_strength;

   // WEAPON_FIXME: weap cheat

   if((w == wp_supershotgun && !enable_ssg) ||      // killough 2/28/98
      ((w == wp_bfg || w == wp_plasma) && GameModeInfo->id == shareware))
      return;

   if(w == wp_fist)           // make '1' apply beserker strength toggle
      cheat_pw(&pwstr);
   else
   {
      if(w >= 0 && w < NUMWEAPONS)
      {
         if((plyr->weaponowned[w] = !plyr->weaponowned[w]))
            doom_printf("Weapon Added");  // Ty 03/27/98 - *not* externalized
         else 
         {
            weapontype_t P_SwitchWeapon(player_t *player);
            
            doom_printf("Weapon Removed"); // Ty 03/27/98 - *not* externalized
            if(w == plyr->readyweapon)     // maybe switch if weapon removed
               plyr->pendingweapon = P_SwitchWeapon(plyr);
         }
      }
   }
}
Beispiel #2
0
OVERLAY boolean P_CheckAmmo(player_t *player)
{
  ammotype_t ammo = weaponinfo[player->readyweapon].ammo;
  int count = 1;  // Regular

  if (player->readyweapon == wp_bfg)  // Minimal amount for one shot varies.
    count = BFGCELLS;
  else
    if (player->readyweapon == wp_supershotgun)        // Double barrel.
      count = 2;

  // Some do not need ammunition anyway.
  // Return if current ammunition sufficient.

  if (ammo == am_noammo || player->ammo[ammo] >= count)
    return true;

  // Out of ammo, pick a weapon to change to.
  //
  // killough 3/22/98: for old demos we do the switch here and now;
  // for Boom games we cannot do this, and have different player
  // preferences across demos or networks, so we have to use the
  // G_BuildTiccmd() interface instead of making the switch here.

  if (demo_compatibility)
    {
      player->pendingweapon = P_SwitchWeapon(player);      // phares
      // Now set appropriate weapon overlay.
      P_SetPsprite(player,ps_weapon,
                   (statenum_t)weaponinfo[player->readyweapon].downstate);
    }

  return false;
}
Beispiel #3
0
//
// P_CheckAmmo
// Returns true if there is enough ammo to shoot.
// If not, selects the next weapon to use.
//
BOOL P_CheckAmmo (player_t *player)
{
	if (P_EnoughAmmo(player, player->readyweapon))
		return true;

	// no enough ammo with the current weapon, choose another one
	P_SwitchWeapon(player);
	return false;
}
/*
 ==================
 iphoneBuildTiccmd
 
 Use touch and tilt controls to set up a doom ticcmd_t
 ==================
 */
static void iphoneBuildTiccmd(ticcmd_t* cmd) {
	memset(cmd,0,sizeof*cmd);	
	//	cmd->consistancy = consistancy[consoleplayer][maketic & BACKUPTICMASK];
	
	if ( menuState != IPM_GAME ) {
		// if in the menus, always generate an empty event
		return;
	}
	
	// the respawn button triggers a use
	if ( respawnActive ) {
		cmd->buttons |= BT_USE;
		respawnActive = false;
	}
	
	if ( gamestate != GS_LEVEL ) {
		// at intermissions, all taps equal attack
		// FIXME: better latched value
		if ( numTouches == numPrevTouches + 1 ) {
			cmd->buttons |= BT_ATTACK;
		}
		return;
	}
	
	// don't allow movement control use during automap
	if ( automapmode & am_active ) {
		return;
	}
	
	// don't built a tic when dead, other than the respawn use
	if ( players[consoleplayer].playerstate == PST_DEAD ) {
		return;
	}
	
	//------------------------
	// No controls during weapon-select screen
	//------------------------
	boolean	weaponCycle = false;
	if ( drawWeaponSelect ) {
		// if the weaponSelect overlay is up, continue tracking held touches
		// until the are released
		for ( ibutton_t *hud = (ibutton_t *)&huds ; hud != (ibutton_t *)(&huds+1) ; hud++ ) {
			if ( hud->touch || hud == &huds.weaponSelect ) {
				UpdateHudTouch( hud );
			}
		}
		
		// Re-tapping in the weapon select area will cycle to the next weapon.
		// The action happens on initial touch.
		touch_t *t = huds.weaponSelect.touch;
		if ( t && t->down && t->stateCount == 1 ) {
			drawWeaponSelect = false;
			t->stateCount++;	// ensure it won't  bring it back up
			weaponCycle = true;
		} else {
			return;
		}
	}
	
	//------------------------
	// gameplay controls
	//------------------------
	
	// update all the hud touch states
	if ( menuState == IPM_GAME ) {
		UpdateHudTouch( &huds.forwardStick );
		UpdateHudTouch( &huds.sideStick );
		UpdateHudTouch( &huds.turnStick );
		UpdateHudTouch( &huds.turnRotor );
		UpdateHudTouch( &huds.weaponSelect );
	}
	// tap in the lower center for weapon switch
	touch_t *t = huds.weaponSelect.touch;
	if ( t && t->down && t->stateCount == 1 ) {
		drawWeaponSelect = true;
	}		
	
	// hack to let a single touch control both hud elements on combo sticks
	// This is dependent on the order in the structure, and probably not a good
	// way to do things.
	if ( huds.sideStick.x == huds.forwardStick.x &&  huds.sideStick.y == huds.forwardStick.y ) {
		huds.sideStick.touch = huds.forwardStick.touch;
		huds.sideStick.downX = huds.forwardStick.downX;
		huds.sideStick.downY = huds.forwardStick.downY;
	}
	if ( huds.turnStick.x == huds.forwardStick.x &&  huds.turnStick.y == huds.forwardStick.y ) {
		huds.turnStick.touch = huds.forwardStick.touch;
		huds.turnStick.downX = huds.forwardStick.downX;
		huds.turnStick.downY = huds.forwardStick.downY;
	}
	
	// the fire button doesn't grab touches
	{
		int x = huds.fire.x - ( huds.fire.drawWidth >> 1 );
		int y = huds.fire.y - ( huds.fire.drawHeight >> 1 );
		int w = huds.fire.drawWidth << 1;
		int h = huds.fire.drawHeight << 1;
		if ( AnyTouchInBounds( x, y, w, h ) ) {
			cmd->buttons |= BT_ATTACK;
			huds.fire.buttonFlags |= BF_DRAW_ACTIVE;	// draw with color
		} else {
			huds.fire.buttonFlags &= ~BF_DRAW_ACTIVE;
		}
	}
	int	forwardmove;
	int	sidemove;
	
	// the edge of the drawn control should give the maximum
	// legal doom movement speed
	huds.forwardStick.scale = stickMove->value / 128.0f;
	huds.sideStick.scale = stickMove->value / 128.0f;
	
	forwardmove = -TURBOTHRESHOLD * AxisHit( &huds.forwardStick );
	sidemove = TURBOTHRESHOLD * AxisHit( &huds.sideStick );
	
	huds.turnStick.scale = stickTurn->value / 128.0f;
	cmd->angleturn = -1500.0f * AxisHit( &huds.turnStick );
	
	// rotary wheel
	cmd->angleturn -= rotorTurn->value * RotorControl( &huds.turnRotor );
	
	// accelerometer tilting
	sidemove += tiltMove->value * DeadBandAdjust( tilt, tiltDeadBand->value );
	cmd->angleturn -= tiltTurn->value * DeadBandAdjust( tilt, tiltDeadBand->value );
	
	// clamp movements
	cmd->forwardmove = ClampMove( forwardmove );
	cmd->sidemove = ClampMove( sidemove );
	
	// tap in the upper center for use
	if ( TouchPressed( 140, 0, 240, 200 ) ) {
		cmd->buttons |= BT_USE;
	}
	
	// auto-use if the game thread found a usable line in front of the player
	if ( autoUse->value && autoUseActive ) {
		if ( cmd->buttons & BT_USE ) {
			// Allow a tap to briefly cancel the auto-use, which works around
			// some issues with incorrectly started auto-uses preventing
			// a real door from opening.
			cmd->buttons &= ~BT_USE;			
		} else {
			cmd->buttons |= BT_USE;
		}		
	}
	
	if ( weaponSelected != -1 ) {
		cmd->buttons |= BT_CHANGE;
		cmd->buttons |= weaponSelected<<BT_WEAPONSHIFT;
		weaponSelected = -1;
	} else {		
		// auto-cycle weapons when firing on empty
		if ( players[consoleplayer].attackdown && !P_CheckAmmo(&players[consoleplayer]) ) {
			weaponCycle = true;
		}
		
		// weapon switch
		int newweapon = wp_nochange;
		if ( weaponCycle ) {
			// witch to next weapon when out of ammo
			newweapon = P_SwitchWeapon(&players[consoleplayer]);
		}
		
		if (newweapon != wp_nochange) {
			cmd->buttons |= BT_CHANGE;
			cmd->buttons |= newweapon<<BT_WEAPONSHIFT;
		}
	}
}