当前位置: 首页>>代码示例>>C++>>正文


C++ BG_Class函数代码示例

本文整理汇总了C++中BG_Class函数的典型用法代码示例。如果您正苦于以下问题:C++ BG_Class函数的具体用法?C++ BG_Class怎么用?C++ BG_Class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了BG_Class函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: G_GetNonLocDamageMod

float G_GetNonLocDamageMod( class_t pcl )
{
	int            regionNum;
	damageRegion_t *region;

	for ( regionNum = 0; regionNum < g_numDamageRegions[ pcl ]; regionNum++ )
	{
		region = &g_damageRegions[ pcl ][ regionNum ];

		if ( !region->nonlocational )
		{
			continue;
		}

		if ( g_debugDamage.integer > 1 )
		{
			Com_Printf( "GetNonLocDamageModifier( pcl = %s ): "
			            S_COLOR_GREEN "FOUND:" S_COLOR_WHITE " %.2f\n",
			            BG_Class( pcl )->name, region->modifier );
		}

		return region->modifier;
	}

	if ( g_debugDamage.integer > 1 )
	{
		Com_Printf( "GetNonLocDamageModifier( pcl = %s ): "
		            S_COLOR_YELLOW "NOT FOUND:" S_COLOR_WHITE " %.2f.\n",
		            BG_Class( pcl )->name, 1.0f );
	}

	return 1.0f;
}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:33,代码来源:g_combat.c

示例2: G_BotNavInit

// FIXME: use nav handle instead of classes
void G_BotNavInit()
{
	int i;

	Log::Notice( "==== Bot Navigation Initialization ==== \n" );

	for ( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )
	{
		classModelConfig_t *model;
		botClass_t bot;
		bot.polyFlagsInclude = POLYFLAGS_WALK;
		bot.polyFlagsExclude = POLYFLAGS_DISABLED;

		model = BG_ClassModelConfig( i );
		if ( model->navMeshClass )
		{
			if ( BG_ClassModelConfig( model->navMeshClass )->navMeshClass )
			{
				Log::Warn( "class '%s': navmesh reference target class '%s' must have its own navmesh",
				            BG_Class( i )->name, BG_Class( model->navMeshClass )->name );
				return;
			}

			continue;
		}

		Q_strncpyz( bot.name, BG_Class( i )->name, sizeof( bot.name ) );

		if ( !trap_BotSetupNav( &bot, &model->navHandle ) )
		{
			return;
		}
	}
	navMeshLoaded = true;
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:36,代码来源:sg_bot_nav.cpp

示例3: CG_GetColorCharForHealth

/*
=================
CG_GetColorCharForHealth
=================
*/
char CG_GetColorCharForHealth( int clientnum )
{
	char health_char = '2';
	int  healthPercent;
	int  maxHealth;
	int  curWeaponClass = cgs.clientinfo[ clientnum ].curWeaponClass;

	if ( cgs.clientinfo[ clientnum ].team == TEAM_ALIENS )
	{
		maxHealth = BG_Class( curWeaponClass )->health;
	}
	else
	{
		maxHealth = BG_Class( PCL_HUMAN )->health;
	}

	healthPercent = ( int )( 100.0f * ( float ) cgs.clientinfo[ clientnum ].health /
	                         ( float ) maxHealth );

	if ( healthPercent < 33 )
	{
		health_char = '1';
	}
	else if ( healthPercent < 67 )
	{
		health_char = '3';
	}

	return health_char;
}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:35,代码来源:cg_drawtools.c

示例4: G_WeightAttack

void G_WeightAttack( gentity_t *self, gentity_t *victim )
{
	float  weightDPS;
	int    attackerMass, victimMass, weightDamage;

	// weigth damage is only dealt between clients
	if ( !self->client || !victim->client )
	{
		return;
	}

	// don't do friendly fire
	if ( G_OnSameTeam( self, victim ) )
	{
		return;
	}

	// ignore invincible targets
	if ( !victim->takedamage )
	{
		return;
	}

	// attacker must be above victim
	if ( self->client->ps.origin[ 2 ] + self->r.mins[ 2 ] <
	     victim->s.origin[ 2 ] + victim->r.maxs[ 2 ] )
	{
		return;
	}

	// victim must be on the ground
	if ( victim->client->ps.groundEntityNum == ENTITYNUM_NONE )
	{
		return;
	}

	// check timer
	if ( victim->client->nextCrushTime > level.time )
	{
		return;
	}

	attackerMass = BG_Class( self->client->pers.classSelection )->mass;
	victimMass = BG_Class( victim->client->pers.classSelection )->mass;
	weightDPS = WEIGHTDMG_DMG_MODIFIER * MAX( attackerMass - victimMass, 0 );

	if ( weightDPS > WEIGHTDMG_DPS_THRESHOLD )
	{
		weightDamage = ( int )( weightDPS * ( WEIGHTDMG_REPEAT / 1000.0f ) );

		if ( weightDamage > 0 )
		{
			G_Damage( victim, self, self, NULL, victim->s.origin, weightDamage,
					  DAMAGE_NO_LOCDAMAGE, ModWeight( self ) );
		}
	}

	victim->client->nextCrushTime = level.time + WEIGHTDMG_REPEAT;
}
开发者ID:Xecantur,项目名称:Unvanquished,代码行数:59,代码来源:g_weapon.cpp

示例5: G_WeightAttack

void G_WeightAttack( gentity_t *self, gentity_t *victim )
{
	float  weightDPS, weightDamage;
	int    attackerMass, victimMass;

	// weigth damage is only dealt between clients
	if ( !self->client || !victim->client )
	{
		return;
	}

	// don't do friendly fire
	if ( G_OnSameTeam( self, victim ) )
	{
		return;
	}

	// attacker must be above victim
	if ( self->client->ps.origin[ 2 ] + self->r.mins[ 2 ] <
	     victim->s.origin[ 2 ] + victim->r.maxs[ 2 ] )
	{
		return;
	}

	// victim must be on the ground
	if ( victim->client->ps.groundEntityNum == ENTITYNUM_NONE )
	{
		return;
	}

	// check timer
	if ( victim->client->nextCrushTime > level.time )
	{
		return;
	}

	attackerMass = BG_Class( self->client->pers.classSelection )->mass;
	victimMass = BG_Class( victim->client->pers.classSelection )->mass;
	weightDPS = WEIGHTDMG_DMG_MODIFIER * std::max( attackerMass - victimMass, 0 );

	if ( weightDPS > WEIGHTDMG_DPS_THRESHOLD )
	{
		weightDamage = weightDPS * ( WEIGHTDMG_REPEAT / 1000.0f );

		victim->entity->Damage(weightDamage, self, Vec3::Load(victim->s.origin), Util::nullopt,
		                       DAMAGE_NO_LOCDAMAGE, ModWeight(self));
	}

	victim->client->nextCrushTime = level.time + WEIGHTDMG_REPEAT;
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:50,代码来源:sg_weapon.cpp

示例6: BotMoveToGoal

void BotMoveToGoal( gentity_t *self )
{
	int    staminaJumpCost;
	vec3_t dir;
	VectorCopy( self->botMind->nav.dir, dir );

	if ( dir[ 2 ] < 0 )
	{
		dir[ 2 ] = 0;
		VectorNormalize( dir );
	}

	BotAvoidObstacles( self, dir );
	BotSeek( self, dir );

	staminaJumpCost = BG_Class( self->client->ps.stats[ STAT_CLASS ] )->staminaJumpCost;

	//dont sprint or dodge if we dont have enough stamina and are about to slow
	if ( self->client->pers.team == TEAM_HUMANS
	     && self->client->ps.stats[ STAT_STAMINA ] < staminaJumpCost )
	{
		usercmd_t *botCmdBuffer = &self->botMind->cmdBuffer;

		usercmdReleaseButton( botCmdBuffer->buttons, BUTTON_SPRINT );
		usercmdReleaseButton( botCmdBuffer->buttons, BUTTON_DODGE );

		// walk to regain stamina
		BotWalk( self, true );
	}
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:30,代码来源:sg_bot_nav.cpp

示例7: BotSprint

bool BotSprint( gentity_t *self, bool enable )
{
	usercmd_t *botCmdBuffer = &self->botMind->cmdBuffer;
	int       staminaJumpCost;

	if ( !enable )
	{
		usercmdReleaseButton( botCmdBuffer->buttons, BUTTON_SPRINT );
		return false;
	}

	staminaJumpCost = BG_Class( self->client->ps.stats[ STAT_CLASS ] )->staminaJumpCost;

	if ( self->client->pers.team == TEAM_HUMANS
	     && self->client->ps.stats[ STAT_STAMINA ] > staminaJumpCost
	     && self->botMind->botSkill.level >= 5 )
	{
		usercmdPressButton( botCmdBuffer->buttons, BUTTON_SPRINT );
		BotWalk( self, false );
		return true;
	}
	else
	{
		usercmdReleaseButton( botCmdBuffer->buttons, BUTTON_SPRINT );
		return false;
	}
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:27,代码来源:sg_bot_nav.cpp

示例8: G_ImpactAttack

void G_ImpactAttack( gentity_t *self, gentity_t *victim )
{
	float  impactVelocity, impactEnergy;
	vec3_t knockbackDir;
	int    attackerMass, impactDamage;

	// self must be a client
	if ( !self->client )
	{
		return;
	}

	// ignore invincible targets
	if ( !victim->takedamage )
	{
		return;
	}

	// don't do friendly fire
	if ( G_OnSameTeam( self, victim ) )
	{
		return;
	}

	// attacker must be above victim
	if ( self->client->ps.origin[ 2 ] + self->r.mins[ 2 ] <
	     victim->s.origin[ 2 ] + victim->r.maxs[ 2 ] )
	{
		return;
	}

	// allow the granger airlifting ritual
	if ( victim->client && victim->client->ps.stats[ STAT_STATE2 ] & SS2_JETPACK_ACTIVE &&
	     ( self->client->pers.classSelection == PCL_ALIEN_BUILDER0 ||
	       self->client->pers.classSelection == PCL_ALIEN_BUILDER0_UPG ) )
	{
		return;
	}

	// calculate impact damage
	attackerMass = BG_Class( self->client->pers.classSelection )->mass;
	impactVelocity = fabs( self->client->pmext.fallImpactVelocity[ 2 ] ) * IMPACTDMG_QU_TO_METER; // in m/s
	impactEnergy = attackerMass * impactVelocity * impactVelocity; // in J
	impactDamage = ( int )( impactEnergy * IMPACTDMG_JOULE_TO_DAMAGE );

	// deal impact damage to both clients and structures, use a threshold for friendly fire
	if ( impactDamage > 0 )
	{
		// calculate knockback direction
		VectorSubtract( victim->s.origin, self->client->ps.origin, knockbackDir );
		VectorNormalize( knockbackDir );

		G_Damage( victim, self, self, knockbackDir, victim->s.origin, impactDamage,
		          DAMAGE_NO_LOCDAMAGE, ModWeight( self ) );
	}
}
开发者ID:Xecantur,项目名称:Unvanquished,代码行数:56,代码来源:g_weapon.cpp

示例9: BotShouldJump

bool BotShouldJump( gentity_t *self, gentity_t *blocker, const vec3_t dir )
{
	vec3_t playerMins;
	vec3_t playerMaxs;
	float jumpMagnitude;
	trace_t trace;
	const int TRACE_LENGTH = BOT_OBSTACLE_AVOID_RANGE;
	vec3_t end;

	//blocker is not on our team, so ignore
	if ( BotGetEntityTeam( self ) != BotGetEntityTeam( blocker ) )
	{
		return false;
	}

	//already normalized

	BG_ClassBoundingBox( ( class_t ) self->client->ps.stats[STAT_CLASS], playerMins, playerMaxs, nullptr, nullptr, nullptr );

	playerMins[2] += STEPSIZE;
	playerMaxs[2] += STEPSIZE;

	//Log::Debug(vtos(self->movedir));
	VectorMA( self->s.origin, TRACE_LENGTH, dir, end );

	//make sure we are moving into a block
	trap_Trace( &trace, self->s.origin, playerMins, playerMaxs, end, self->s.number, MASK_SHOT, 0 );
	if ( trace.fraction >= 1.0f || blocker != &g_entities[trace.entityNum] )
	{
		return false;
	}

	jumpMagnitude = BG_Class( ( class_t )self->client->ps.stats[STAT_CLASS] )->jumpMagnitude;

	//find the actual height of our jump
	jumpMagnitude = Square( jumpMagnitude ) / ( self->client->ps.gravity * 2 );

	//prepare for trace
	playerMins[2] += jumpMagnitude;
	playerMaxs[2] += jumpMagnitude;

	//check if jumping will clear us of entity
	trap_Trace( &trace, self->s.origin, playerMins, playerMaxs, end, self->s.number, MASK_SHOT, 0 );

	//if we can jump over it, then jump
	//note that we also test for a blocking barricade because barricades will collapse to let us through
	if ( blocker->s.modelindex == BA_A_BARRICADE || trace.fraction == 1.0f )
	{
		return true;
	}
	else
	{
		return false;
	}
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:55,代码来源:sg_bot_nav.cpp

示例10: G_ImpactAttack

void G_ImpactAttack( gentity_t *self, gentity_t *victim )
{
	float  impactVelocity, impactEnergy, impactDamage;
	vec3_t knockbackDir;
	int    attackerMass;

	// self must be a client
	if ( !self->client )
	{
		return;
	}

	// don't do friendly fire
	if ( G_OnSameTeam( self, victim ) )
	{
		return;
	}

	// attacker must be above victim
	if ( self->client->ps.origin[ 2 ] + self->r.mins[ 2 ] <
	     victim->s.origin[ 2 ] + victim->r.maxs[ 2 ] )
	{
		return;
	}

	// allow the granger airlifting ritual
	if ( victim->client && victim->client->ps.stats[ STAT_STATE2 ] & SS2_JETPACK_ACTIVE &&
	     ( self->client->pers.classSelection == PCL_ALIEN_BUILDER0 ||
	       self->client->pers.classSelection == PCL_ALIEN_BUILDER0_UPG ) )
	{
		return;
	}

	// calculate impact damage
	impactVelocity = fabs( self->client->pmext.fallImpactVelocity[ 2 ] ) * QU_TO_METER; // in m/s

	if (!impactVelocity) return;

	attackerMass = BG_Class( self->client->pers.classSelection )->mass;
	impactEnergy = attackerMass * impactVelocity * impactVelocity; // in J
	impactDamage = impactEnergy * IMPACTDMG_JOULE_TO_DAMAGE;

	// calculate knockback direction
	VectorSubtract( victim->s.origin, self->client->ps.origin, knockbackDir );
	VectorNormalize( knockbackDir );

	victim->entity->Damage((float)impactDamage, self, Vec3::Load(victim->s.origin),
						   Vec3::Load(knockbackDir), DAMAGE_NO_LOCDAMAGE, ModWeight(self));
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:49,代码来源:sg_weapon.cpp

示例11: CG_CalculateWeaponPosition

/*
==============
CG_CalculateWeaponPosition
==============
*/
static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles )
{
  float         scale;
  int           delta;
  float         fracsin;
  float         bob;
  weaponInfo_t  *weapon;

  weapon = &cg_weapons[ cg.predictedPlayerState.weapon ];

  VectorCopy( cg.refdef.vieworg, origin );
  VectorCopy( cg.refdefViewAngles, angles );

  // on odd legs, invert some angles
  if( cg.bobcycle & 1 )
    scale = -cg.xyspeed;
  else
    scale = cg.xyspeed;

  // gun angles from bobbing
  // bob amount is class dependant
  bob = BG_Class( cg.predictedPlayerState.stats[ STAT_CLASS ] )->bob;

  if( bob != 0 )
  {
    angles[ ROLL ] += scale * cg.bobfracsin * 0.005;
    angles[ YAW ] += scale * cg.bobfracsin * 0.01;
    angles[ PITCH ] += cg.xyspeed * cg.bobfracsin * 0.005;
  }

  // drop the weapon when landing
  if( !weapon->noDrift )
  {
    delta = cg.time - cg.landTime;
    if( delta < LAND_DEFLECT_TIME )
      origin[ 2 ] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME;
    else if( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME )
      origin[ 2 ] += cg.landChange*0.25 *
        ( LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta ) / LAND_RETURN_TIME;

    // idle drift
    scale = cg.xyspeed + 40;
    fracsin = sin( cg.time * 0.001 );
    angles[ ROLL ] += scale * fracsin * 0.01;
    angles[ YAW ] += scale * fracsin * 0.01;
    angles[ PITCH ] += scale * fracsin * 0.01;
  }
}
开发者ID:ZdrytchX,项目名称:cuboid,代码行数:53,代码来源:cg_weapons.c

示例12: assert

// TODO: Consider location as well as direction when both given.
void KnockbackComponent::HandleDamage(float amount, gentity_t* source, Util::optional<Vec3> location,
                                      Util::optional<Vec3> direction, int flags, meansOfDeath_t meansOfDeath) {
	if (!(flags & DAMAGE_KNOCKBACK)) return;
	if (amount <= 0.0f) return;

	if (!direction) {
		knockbackLogger.Warn("Received damage message with knockback flag set but no direction.");
		return;
	}

	if (Math::Length(direction.value()) == 0.0f) {
		knockbackLogger.Warn("Attempt to do knockback with null vector direction.");
		return;
	}

	// TODO: Remove dependency on client.
	gclient_t *client = entity.oldEnt->client;
	assert(client);

	// Check for immunity.
	if (client->noclip) return;
	if (client->sess.spectatorState != SPECTATOR_NOT) return;

	float mass = (float)BG_Class(client->ps.stats[ STAT_CLASS ])->mass;

	if (mass <= 0.0f) {
		knockbackLogger.Warn("Attempt to do knockback against target with no mass, assuming normal mass.");
		mass = KNOCKBACK_NORMAL_MASS;
	}

	float massMod  = Math::Clamp(KNOCKBACK_NORMAL_MASS / mass, KNOCKBACK_MIN_MASSMOD, KNOCKBACK_MAX_MASSMOD);
	float strength = amount * DAMAGE_TO_KNOCKBACK * massMod;

	// Change client velocity.
	Vec3 clientVelocity = Vec3::Load(client->ps.velocity);
	clientVelocity += Math::Normalize(direction.value()) * strength;
	clientVelocity.Store(client->ps.velocity);

	// Set pmove timer so that the client can't cancel out the movement immediately.
	if (!client->ps.pm_time) {
		client->ps.pm_time = KNOCKBACK_PMOVE_TIME;
		client->ps.pm_flags |= PMF_TIME_KNOCKBACK;
	}

	knockbackLogger.Debug("Knockback: client: %i, strength: %.1f (massMod: %.1f).",
	                      entity.oldEnt->s.number, strength, massMod);
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:48,代码来源:KnockbackComponent.cpp

示例13: BotJump

bool BotJump( gentity_t *self )
{
	int staminaJumpCost;

	if ( self->client->pers.team == TEAM_HUMANS )
	{
		staminaJumpCost = BG_Class( self->client->ps.stats[ STAT_CLASS ] )->staminaJumpCost;

		if ( self->client->ps.stats[STAT_STAMINA] < staminaJumpCost )
		{
			return false;
		}
	}

	self->botMind->cmdBuffer.upmove = 127;
	return true;
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:17,代码来源:sg_bot_nav.cpp

示例14: BotTargetRank

/**
 * Return common rank
 * @param self
 * @param target
 * @return 
 */
int BotTargetRank( gentity_t *self, gentity_t *target ) {
	float distance;
	float rank = 0;
	float damage;
	float damage_pct;
	distance = botGetDistanceBetweenPlayer(self, target);
	rank += 3000 / distance;
	//--- Add some rand chance (not so high)
	rank += G_Rand_Range(0, 10);
	//If we are attacking this target, increase the chance to stick to it (unless we haven't hit it within 5 secs):
	if(self->bot->Enemy == target) {
		if(!botHitTarget( self, 5000 )) {
			rank -= 30;
		} else {
			rank += 30;
		}
	}
	//If its attacking you
	if(self->client->lasthurt_client == target->s.number) {
		rank += 10;
	}
	if(target->client) {
		damage = self->credits[ target->client->ps.clientNum ];
		//How much it has damaged you
		damage_pct = (damage / (float)BG_Class( self->client->ps.stats[ STAT_CLASS ] )->health) * 100;
		if(damage_pct > 50) {
			rank += 20;
		} else if(damage_pct > 25) {
			rank += 10;
		}
	}
	//If target health is critical, increase its chances
	if(target->health < 50) { //First Sound warning
		rank += 25;
	}
	if(target->health < 25) { //Second Sound warning
		rank += 50;
	}
	//The enemies or my friends are my enemies!
	if(self->bot->Friend) {
		if(self->bot->Friend->bot && self->bot->Friend->bot->Enemy == target) {
			rank += 30;
		}
	}
	return rank;
}
开发者ID:lepe,项目名称:trem-gpp-bots,代码行数:52,代码来源:g_bot_common.c

示例15: CG_CompleteClass

static void CG_CompleteClass( void )
{
	int i = 0;

	if ( cgs.clientinfo[ cg.clientNum ].team == TEAM_ALIENS )
	{
		for ( i = PCL_ALIEN_BUILDER0; i < PCL_HUMAN; i++ )
		{
			trap_CompleteCallback( BG_Class( i )->name );
		}
	}
	else if ( cgs.clientinfo[ cg.clientNum ].team == TEAM_HUMANS )
	{
		trap_CompleteCallback( BG_Weapon( WP_HBUILD )->name );
		trap_CompleteCallback( BG_Weapon( WP_MACHINEGUN )->name );
	}
}
开发者ID:Sixthly,项目名称:Unvanquished,代码行数:17,代码来源:cg_consolecmds.c


注:本文中的BG_Class函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。