Ejemplo n.º 1
0
// ------------------------------------------------------------------
// hud_shield_equalize()
//
// Equalize the four shield quadrants for an object
//
void hud_shield_equalize(object* objp, player* pl)
{
	float strength;
	int idx;
	int all_equal;

	Assert(objp != NULL);
	if (objp == NULL)
		return;

	Assert(pl != NULL);
	if (pl == NULL)
		return;

	Assert(objp->type == OBJ_SHIP);
	if (objp->type != OBJ_SHIP)
		return;

	// Goober5000 - quick out if we have no shields
	if (objp->flags & OF_NO_SHIELDS)
		return;

	// are all quadrants equal?
	all_equal = 1;
	for (idx = 0; idx < MAX_SHIELD_SECTIONS - 1; idx++)
	{
		if (objp->shield_quadrant[idx] != objp->shield_quadrant[idx + 1])
		{
			all_equal = 0;
			break;
		}
	}

	if (all_equal)
		return;

	strength = shield_get_strength(objp);
	if (strength == 0.0f)
		return;

	// maybe impose a 2% penalty - server side and single player only
	if (!MULTIPLAYER_CLIENT && (pl->shield_penalty_stamp < 0) || timestamp_elapsed_safe(pl->shield_penalty_stamp,
		1000))
	{
		strength *= 0.98f;

		// reset the penalty timestamp
		pl->shield_penalty_stamp = timestamp(1000);
	}

	shield_set_strength(objp, strength);

	// beep
	if (objp == Player_obj)
	{
		snd_play(&Snds[SND_SHIELD_XFER_OK]);
	}
}
Ejemplo n.º 2
0
// ------------------------------------------------------------------
// hud_shield_equalize()
//
// Equalize the four shield quadrants for an object
//
void hud_shield_equalize(object *objp, player *pl)
{
	float	strength;
	int idx;
	int all_equal = 1;

	Assert(objp != NULL);
	if(objp == NULL){
		return;
	}
	Assert(pl != NULL);
	if(pl == NULL){
		return;
	}
	Assert(objp->type == OBJ_SHIP);
	if(objp->type != OBJ_SHIP){
		return;
	}

	// are all quadrants equal?
	for(idx=0; idx<MAX_SHIELD_SECTIONS-1; idx++){
		if(objp->shields[idx] != objp->shields[idx+1]){
			all_equal = 0;
			break;
		}
	}

	// not all equal
	if(!all_equal){
		strength = get_shield_strength(objp);
		if ( strength != 0 ) {
			// maybe impose a 2% penalty - server side and single player only
			if(!MULTIPLAYER_CLIENT &&  (pl->shield_penalty_stamp < 0) || timestamp_elapsed_safe(pl->shield_penalty_stamp, 1000) ){
				strength *= 0.98f;

				// reset the penalty timestamp
				pl->shield_penalty_stamp = timestamp(1000);
			}
			
			set_shield_strength(objp, strength);					
		}
	}

	// beep
	if ( objp == Player_obj ){
		snd_play( &Snds[SND_SHIELD_XFER_OK] );
	}
}
Ejemplo n.º 3
0
// ------------------------------------------------------------------
// hud_shield_equalize()
//
// Equalize all shield quadrants for an object
//
void hud_shield_equalize(object *objp, player *pl)
{
	float penalty;

	Assert(objp != NULL);
	if (objp == NULL)
		return;

	Assert(pl != NULL);
	if (pl == NULL)
		return;

	Assert(objp->type == OBJ_SHIP);
	if (objp->type != OBJ_SHIP)
		return;

	// Goober5000 - quick out if we have no shields
	if (objp->flags[Object::Object_Flags::No_shields])
		return;

	// maybe impose a 2% penalty - server side and single player only
	if (!MULTIPLAYER_CLIENT && ((pl->shield_penalty_stamp < 0) || timestamp_elapsed_safe(pl->shield_penalty_stamp, 1000)) ) {
		penalty = 0.02f;

		// reset the penalty timestamp
		pl->shield_penalty_stamp = timestamp(1000);

	} else {
		penalty = 0.0f;
	}

	shield_balance(objp, 1, penalty);

	// beep
	if (objp == Player_obj) {
		snd_play(&Snds[SND_SHIELD_XFER_OK]);
	}
}