您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BG_Class函数代码示例

51自学网 2021-06-01 19:49:47
  C++
这篇教程C++ BG_Class函数代码示例写得很实用,希望能帮到您。

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

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


示例2: G_BotNavInit

// FIXME: use nav handle instead of classesvoid 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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例16: CG_CompleteClass

static void CG_CompleteClass(){	int i = 0;	if ( cgs.clientinfo[ cg.clientNum ].team == TEAM_ALIENS )	{		// TODO: Add iterator for alien/human classes		for ( i = PCL_ALIEN_BUILDER0; i < PCL_HUMAN_NAKED; 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:Unvanquished,项目名称:Unvanquished,代码行数:18,


示例17: G_CrushAttack

/*===============G_CrushAttackShould only be called if there was an impact between a tyrant and another player===============*/void G_CrushAttack( gentity_t *ent, gentity_t *victim ){	vec3_t dir;	float  jump;	int    damage;	if ( !victim->takedamage ||	     ent->client->ps.origin[ 2 ] + ent->r.mins[ 2 ] <	     victim->s.origin[ 2 ] + victim->r.maxs[ 2 ] ||	     ( victim->client &&	       victim->client->ps.groundEntityNum == ENTITYNUM_NONE ) )	{		return;	}	// Deal velocity based damage to target	jump = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->jumpMagnitude;	damage = ( ent->client->pmext.fallVelocity + jump ) *	         -LEVEL4_CRUSH_DAMAGE_PER_V;	if ( damage < 0 )	{		damage = 0;	}	// Players also get damaged periodically	if ( victim->client &&	     ent->client->lastCrushTime + LEVEL4_CRUSH_REPEAT < level.time )	{		ent->client->lastCrushTime = level.time;		damage += LEVEL4_CRUSH_DAMAGE;	}	if ( damage < 1 )	{		return;	}	// Crush the victim over a period of time	VectorSubtract( victim->s.origin, ent->client->ps.origin, dir );	VectorNormalize( dir );	G_Damage( victim, ent, ent, dir, victim->s.origin, damage,	          DAMAGE_NO_LOCDAMAGE, MOD_LEVEL4_CRUSH );}
开发者ID:bmorel,项目名称:Unvanquished,代码行数:51,


示例18: CG_StepOffset

// this causes a compiler bug on mac MrC compilerstatic void CG_StepOffset( void ){  float         steptime;  int           timeDelta;  vec3_t        normal;  playerState_t *ps = &cg.predictedPlayerState;  BG_GetClientNormal( ps, normal );  steptime = BG_Class( ps->stats[ STAT_CLASS ] )->steptime;  // smooth out stair climbing  timeDelta = cg.time - cg.stepTime;  if( timeDelta < steptime )  {    float stepChange = cg.stepChange      * (steptime - timeDelta) / steptime;    VectorMA( cg.refdef.vieworg, -stepChange, normal, cg.refdef.vieworg );  }}
开发者ID:lepe,项目名称:trem-gpp-bots,代码行数:22,


示例19: CG_OffsetFirstPersonView

/*===============CG_OffsetFirstPersonView===============*/void CG_OffsetFirstPersonView( void ){	float         *origin;	float         *angles;	float         bob;	float         ratio;	float         delta;	float         speed;	float         f;	vec3_t        predictedVelocity;	int           timeDelta;	float         bob2;	vec3_t        normal, baseOrigin;	playerState_t *ps = &cg.predictedPlayerState;	BG_GetClientNormal( ps, normal );	if ( cg.snap->ps.pm_type == PM_INTERMISSION )	{		return;	}	origin = cg.refdef.vieworg;	angles = cg.refdefViewAngles;	VectorCopy( origin, baseOrigin );	// if dead, fix the angle and don't add any kick	if ( cg.snap->ps.stats[ STAT_HEALTH ] <= 0 )	{		angles[ ROLL ] = 40;		angles[ PITCH ] = -15;		angles[ YAW ] = cg.snap->ps.stats[ STAT_VIEWLOCK ];		origin[ 2 ] += cg.predictedPlayerState.viewheight;		return;	}	// add angles based on damage kick	if ( cg.damageTime )	{		ratio = cg.time - cg.damageTime;		if ( ratio < DAMAGE_DEFLECT_TIME )		{			ratio /= DAMAGE_DEFLECT_TIME;			angles[ PITCH ] += ratio * cg.v_dmg_pitch;			angles[ ROLL ] += ratio * cg.v_dmg_roll;		}		else		{			ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;			if ( ratio > 0 )			{				angles[ PITCH ] += ratio * cg.v_dmg_pitch;				angles[ ROLL ] += ratio * cg.v_dmg_roll;			}		}	}	// add pitch based on fall kick#if 0	ratio = ( cg.time - cg.landTime ) / FALL_TIME;	if ( ratio < 0 )	{		ratio = 0;	}	angles[ PITCH ] += ratio * cg.fall_value;#endif	// add angles based on velocity	VectorCopy( cg.predictedPlayerState.velocity, predictedVelocity );	delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 0 ] );	angles[ PITCH ] += delta * cg_runpitch.value;	delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 1 ] );	angles[ ROLL ] -= delta * cg_runroll.value;	// add angles based on bob	// bob amount is class-dependent	if ( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT )	{		bob2 = 0.0f;	}	else	{		bob2 = BG_Class( cg.predictedPlayerState.stats[ STAT_CLASS ] )->bob;	}#define LEVEL4_FEEDBACK 10.0f//.........这里部分代码省略.........
开发者ID:Foe-of-Eternity,项目名称:Unvanquished,代码行数:101,


示例20: CG_CalcFov

static int CG_CalcFov( void ){  float     y;  float     phase;  float     v;  int       contents;  float     fov_x, fov_y;  float     zoomFov;  float     f;  int       inwater;  int       attribFov;  usercmd_t cmd;  usercmd_t oldcmd;  int       cmdNum;  cmdNum = trap_GetCurrentCmdNumber( );  trap_GetUserCmd( cmdNum, &cmd );  trap_GetUserCmd( cmdNum - 1, &oldcmd );  // switch follow modes if necessary: cycle between free -> follow -> third-person follow  if( cmd.buttons & BUTTON_USE_HOLDABLE && !( oldcmd.buttons & BUTTON_USE_HOLDABLE ) )  {    if ( cg.snap->ps.pm_flags & PMF_FOLLOW )     {      if( !cg.chaseFollow )        cg.chaseFollow = qtrue;      else      {        cg.chaseFollow = qfalse;        trap_SendClientCommand( "follow/n" );      }    }    else if ( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT )      trap_SendClientCommand( "follow/n" );  }  if( cg.predictedPlayerState.pm_type == PM_INTERMISSION ||      ( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT ) ||       ( cg.renderingThirdPerson ) )  {    // if in intermission or third person, use a fixed value    fov_y = BASE_FOV_Y;  }  else  {    // don't lock the fov globally - we need to be able to change it    attribFov = BG_Class( cg.predictedPlayerState.stats[ STAT_CLASS ] )->fov * 0.75f;    fov_y = attribFov;    if ( fov_y < 1.0f )      fov_y = 1.0f;    else if ( fov_y > MAX_FOV_Y )      fov_y = MAX_FOV_Y;    if( cg.spawnTime > ( cg.time - FOVWARPTIME ) &&        BG_ClassHasAbility( cg.predictedPlayerState.stats[ STAT_CLASS ], SCA_FOVWARPS ) )    {      float fraction = (float)( cg.time - cg.spawnTime ) / FOVWARPTIME;      fov_y = MAX_FOV_WARP_Y - ( ( MAX_FOV_WARP_Y - fov_y ) * fraction );    }    // account for zooms    zoomFov = BG_Weapon( cg.predictedPlayerState.weapon )->zoomFov * 0.75f;    if ( zoomFov < 1.0f )      zoomFov = 1.0f;    else if ( zoomFov > attribFov )      zoomFov = attribFov;    // only do all the zoom stuff if the client CAN zoom    // FIXME: zoom control is currently hard coded to BUTTON_ATTACK2    if( BG_Weapon( cg.predictedPlayerState.weapon )->canZoom )    {      if ( cg.zoomed )      {        f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;        if ( f > 1.0f )          fov_y = zoomFov;        else          fov_y = fov_y + f * ( zoomFov - fov_y );        // BUTTON_ATTACK2 isn't held so unzoom next time        if( !( cmd.buttons & BUTTON_ATTACK2 ) )        {          cg.zoomed   = qfalse;          cg.zoomTime = MIN( cg.time,               cg.time + cg.time - cg.zoomTime - ZOOM_TIME );        }      }      else      {        f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;        if ( f <= 1.0f )          fov_y = zoomFov + f * ( fov_y - zoomFov );        // BUTTON_ATTACK2 is held so zoom next time        if( cmd.buttons & BUTTON_ATTACK2 )        {//.........这里部分代码省略.........
开发者ID:lepe,项目名称:trem-gpp-bots,代码行数:101,


示例21: CG_OffsetFirstPersonView

/*===============CG_OffsetFirstPersonView===============*/void CG_OffsetFirstPersonView( void ){  float         *origin;  float         *angles;  float         bob;  float         ratio;  float         delta;  float         speed;  float         f;  vec3_t        predictedVelocity;  int           timeDelta;  float         bob2;  vec3_t        normal, baseOrigin;  playerState_t *ps = &cg.predictedPlayerState;  BG_GetClientNormal( ps, normal );  if( cg.snap->ps.pm_type == PM_INTERMISSION )    return;  origin = cg.refdef.vieworg;  angles = cg.refdefViewAngles;  VectorCopy( origin, baseOrigin );  // if dead, fix the angle and don't add any kick  if( cg.snap->ps.stats[ STAT_HEALTH ] <= 0 )  {    angles[ ROLL ] = 40;    angles[ PITCH ] = -15;    angles[ YAW ] = cg.snap->ps.stats[ STAT_VIEWLOCK ];    origin[ 2 ] += cg.predictedPlayerState.viewheight;    return;  }  // camera shake effect  else if( cg.snap->ps.stats[ STAT_SHAKE ] > 0 )  {    float fac;    fac = (float) cg.snap->ps.stats[ STAT_SHAKE ] *          cg_cameraShakeMagnitude.value * 0.15f;    angles[ 0 ] += crandom() * fac;    angles[ 1 ] += crandom() * fac;    angles[ 2 ] += crandom() * fac;  }  // add angles based on damage kick  if( cg.damageTime )  {    ratio = cg.time - cg.damageTime;    if( ratio < DAMAGE_DEFLECT_TIME )    {      ratio /= DAMAGE_DEFLECT_TIME;      angles[ PITCH ] += ratio * cg.v_dmg_pitch;      angles[ ROLL ] += ratio * cg.v_dmg_roll;    }    else    {      ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;      if( ratio > 0 )      {        angles[ PITCH ] += ratio * cg.v_dmg_pitch;        angles[ ROLL ] += ratio * cg.v_dmg_roll;      }    }  }  // add pitch based on fall kick#if 0  ratio = ( cg.time - cg.landTime) / FALL_TIME;  if (ratio < 0)    ratio = 0;  angles[PITCH] += ratio * cg.fall_value;#endif  // add angles based on velocity  VectorCopy( cg.predictedPlayerState.velocity, predictedVelocity );  delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 0 ] );  angles[ PITCH ] += delta * cg_runpitch.value;  delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 1 ] );  angles[ ROLL ] -= delta * cg_runroll.value;  // add angles based on bob  // bob amount is class dependant  if( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT )    bob2 = 0.0f;  else    bob2 = BG_Class( cg.predictedPlayerState.stats[ STAT_CLASS ] )->bob;//.........这里部分代码省略.........
开发者ID:lepe,项目名称:trem-gpp-bots,代码行数:101,


示例22: G_RewardAttackers

//.........这里部分代码省略.........		enemyDamage += self->credits[ playerNum ];	}	if ( enemyDamage <= 0 )	{		return;	}	// Give individual rewards	for ( playerNum = 0; playerNum < level.maxclients; playerNum++ )	{		player = &g_entities[ playerNum ];		playerTeam = player->client->pers.teamSelection;		damageShare = self->credits[ playerNum ];		// Clear reward array		self->credits[ playerNum ] = 0;		// Player must be on the other team		if ( playerTeam == ownTeam || playerTeam <= TEAM_NONE || playerTeam >= NUM_TEAMS )		{			continue;		}		// Player must have dealt damage		if ( damageShare <= 0 )		{			continue;		}		reward = value * ( damageShare / ( float )maxHealth );		if ( reward <= 0.0f )		{			continue;		}		if ( self->s.eType == ET_BUILDABLE )		{			G_AddConfidenceToScore( player, reward );			switch ( self->s.modelindex )			{				case BA_A_OVERMIND:				case BA_H_REACTOR:					reason = CONF_REAS_DESTR_CRUCIAL;					break;				case BA_A_ACIDTUBE:				case BA_A_TRAPPER:				case BA_A_HIVE:				case BA_H_MGTURRET:				case BA_H_TESLAGEN:					reason = CONF_REAS_DESTR_AGGRESSIVE;					break;				default:					reason = CONF_REAS_DESTR_SUPPORT;			}			qualifier = CONF_QUAL_NONE;			G_AddConfidence( playerTeam, CONFIDENCE_DESTRUCTION, reason, qualifier, reward, player );		}		else		{			G_AddCreditsToScore( player, ( int )reward );			G_AddCreditToClient( player->client, ( short )reward, qtrue );			// Give confidence for killing non-naked players outside the friendly base			switch ( self->client->ps.stats[ STAT_CLASS ] )			{				case PCL_ALIEN_LEVEL0:				case PCL_ALIEN_BUILDER0:				case PCL_ALIEN_BUILDER0_UPG:					break;				case PCL_HUMAN:					// Treat a human just wearing light armor as naked					if ( ( int )value <= BG_Class( PCL_HUMAN )->value +					                     ( BG_Upgrade( UP_LIGHTARMOUR )->price / 2 ) )					{						break;					}				default:					if ( G_InsideBase( player, qtrue ) || G_InsideBase( self, qfalse ) )					{						break;					}					qualifier = CONF_QUAL_OUTSIDE_OWN_BASE;					G_AddConfidence( playerTeam, CONFIDENCE_KILLING, CONF_REAS_KILLING,					                 qualifier, reward * CONFIDENCE_PER_CREDIT, player );			}		}	}}
开发者ID:luislezcair,项目名称:Unvanquished,代码行数:101,


示例23: CG_EntityEvent

/*==============CG_EntityEventAn entity has an event valuealso called by CG_CheckPlayerstateEvents==============*/void CG_EntityEvent( centity_t *cent, vec3_t position ){    entityState_t *es;    int           event;    vec3_t        dir;    const char    *s;    int           clientNum;    clientInfo_t  *ci;    int           steptime;    if ( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT )    {        steptime = 200;    }    else    {        steptime = BG_Class( cg.snap->ps.stats[ STAT_CLASS ] )->steptime;    }    es = &cent->currentState;    event = es->event & ~EV_EVENT_BITS;    if ( cg_debugEvents.integer )    {        CG_Printf( "ent:%3i  event:%3i %s/n", es->number, event,                   BG_EventName( event ) );    }    if ( !event )    {        return;    }    clientNum = es->clientNum;    if ( clientNum < 0 || clientNum >= MAX_CLIENTS )    {        clientNum = 0;    }    ci = &cgs.clientinfo[ clientNum ];    switch ( event )    {    case EV_FOOTSTEP:        if ( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE )        {            if ( ci->footsteps == FOOTSTEP_CUSTOM )            {                trap_S_StartSound( NULL, es->number, CHAN_BODY,                                   ci->customFootsteps[ rand() & 3 ] );            }            else            {                trap_S_StartSound( NULL, es->number, CHAN_BODY,                                   cgs.media.footsteps[ ci->footsteps ][ rand() & 3 ] );            }        }        break;    case EV_FOOTSTEP_METAL:        if ( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE )        {            if ( ci->footsteps == FOOTSTEP_CUSTOM )            {                trap_S_StartSound( NULL, es->number, CHAN_BODY,                                   ci->customMetalFootsteps[ rand() & 3 ] );            }            else            {                trap_S_StartSound( NULL, es->number, CHAN_BODY,                                   cgs.media.footsteps[ FOOTSTEP_METAL ][ rand() & 3 ] );            }        }        break;    case EV_FOOTSTEP_SQUELCH:        if ( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE )        {            trap_S_StartSound( NULL, es->number, CHAN_BODY,                               cgs.media.footsteps[ FOOTSTEP_FLESH ][ rand() & 3 ] );        }        break;    case EV_FOOTSPLASH:        if ( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE )        {            trap_S_StartSound( NULL, es->number, CHAN_BODY,                               cgs.media.footsteps[ FOOTSTEP_SPLASH ][ rand() & 3 ] );//.........这里部分代码省略.........
开发者ID:Gireen,项目名称:Unvanquished,代码行数:101,


示例24: trap_GetUserinfo

//.........这里部分代码省略.........        if( revertName )        {            Q_strncpyz( client->pers.netname, *oldname ? oldname : "UnnamedPlayer",                        sizeof( client->pers.netname ) );            Info_SetValueForKey( userinfo, "name", oldname );            trap_SetUserinfo( clientNum, userinfo );        }        else        {            G_CensorString( client->pers.netname, newname,                            sizeof( client->pers.netname ), ent );            if( !forceName && client->pers.connected == CON_CONNECTED )            {                client->pers.namelog->nameChangeTime = level.time;                client->pers.namelog->nameChanges++;            }            if( *oldname )            {                G_LogPrintf( "ClientRename: %i [%s] (%s) /"%s^7/" -> /"%s^7/" /"%c%s%c^7/"/n",                             clientNum, client->pers.ip.str, client->pers.guid,                             oldname, client->pers.netname,                             DECOLOR_OFF, client->pers.netname, DECOLOR_ON );            }        }        G_namelog_update_name( client );    }    if( client->pers.classSelection == PCL_NONE )    {        //This looks hacky and frankly it is. The clientInfo string needs to hold different        //model details to that of the spawning class or the info change will not be        //registered and an axis appears instead of the player model. There is zero chance        //the player can spawn with the battlesuit, hence this choice.        Com_sprintf( buffer, MAX_QPATH, "%s/%s",  BG_ClassConfig( PCL_HUMAN_BSUIT )->modelName,                     BG_ClassConfig( PCL_HUMAN_BSUIT )->skinName );    }    else    {        Com_sprintf( buffer, MAX_QPATH, "%s/%s",  BG_ClassConfig( client->pers.classSelection )->modelName,                     BG_ClassConfig( client->pers.classSelection )->skinName );        //model segmentation        Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg",                     BG_ClassConfig( client->pers.classSelection )->modelName );        if( G_NonSegModel( filename ) )            client->ps.persistant[ PERS_STATE ] |= PS_NONSEGMODEL;        else            client->ps.persistant[ PERS_STATE ] &= ~PS_NONSEGMODEL;    }    Q_strncpyz( model, buffer, sizeof( model ) );    // wallwalk follow    s = Info_ValueForKey( userinfo, "cg_wwFollow" );    if( atoi( s ) )        client->ps.persistant[ PERS_STATE ] |= PS_WALLCLIMBINGFOLLOW;    else        client->ps.persistant[ PERS_STATE ] &= ~PS_WALLCLIMBINGFOLLOW;    // wallwalk toggle    s = Info_ValueForKey( userinfo, "cg_wwToggle" );    if( atoi( s ) )        client->ps.persistant[ PERS_STATE ] |= PS_WALLCLIMBINGTOGGLE;    else
开发者ID:GrangerHub,项目名称:tremulous,代码行数:67,


示例25: ClientSpawn

//.........这里部分代码省略.........    client->ps.eventSequence = eventSequence;    // increment the spawncount so the client will detect the respawn    client->ps.persistant[ PERS_SPAWN_COUNT ]++;    client->ps.persistant[ PERS_SPECSTATE ] = client->sess.spectatorState;    client->airOutTime = level.time + 12000;    trap_GetUserinfo( index, userinfo, sizeof( userinfo ) );    client->ps.eFlags = flags;    //Com_Printf( "ent->client->pers->pclass = %i/n", ent->client->pers.classSelection );    ent->s.groundEntityNum = ENTITYNUM_NONE;    ent->client = &level.clients[ index ];    ent->takedamage = qtrue;    ent->inuse = qtrue;    ent->classname = "player";    ent->r.contents = CONTENTS_BODY;    ent->clipmask = MASK_PLAYERSOLID;    ent->die = player_die;    ent->waterlevel = 0;    ent->watertype = 0;    ent->flags = 0;    // calculate each client's acceleration    ent->evaluateAcceleration = qtrue;    client->ps.stats[ STAT_MISC ] = 0;    client->ps.eFlags = flags;    client->ps.clientNum = index;    BG_ClassBoundingBox( ent->client->pers.classSelection, ent->r.mins, ent->r.maxs, NULL, NULL, NULL );    if( client->sess.spectatorState == SPECTATOR_NOT )        client->ps.stats[ STAT_MAX_HEALTH ] =            BG_Class( ent->client->pers.classSelection )->health;    else        client->ps.stats[ STAT_MAX_HEALTH ] = 100;    // clear entity values    if( ent->client->pers.classSelection == PCL_HUMAN )    {        BG_AddUpgradeToInventory( UP_MEDKIT, client->ps.stats );        weapon = client->pers.humanItemSelection;    }    else if( client->sess.spectatorState == SPECTATOR_NOT )        weapon = BG_Class( ent->client->pers.classSelection )->startWeapon;    else        weapon = WP_NONE;    maxAmmo = BG_Weapon( weapon )->maxAmmo;    maxClips = BG_Weapon( weapon )->maxClips;    client->ps.stats[ STAT_WEAPON ] = weapon;    client->ps.ammo = maxAmmo;    client->ps.clips = maxClips;    // We just spawned, not changing weapons    client->ps.persistant[ PERS_NEWWEAPON ] = 0;    ent->client->ps.stats[ STAT_CLASS ] = ent->client->pers.classSelection;    ent->client->ps.stats[ STAT_TEAM ] = ent->client->pers.teamSelection;    ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE;    ent->client->ps.stats[ STAT_STATE ] = 0;
开发者ID:GrangerHub,项目名称:tremulous,代码行数:67,


示例26: G_KnockbackByDir

void G_KnockbackByDir( gentity_t *target, const vec3_t direction, float strength,                              qboolean ignoreMass ){	vec3_t dir, vel;	int    mass;	float  massMod;	const classAttributes_t *ca;	// sanity check parameters	if ( !target || !target->client || VectorLength( direction ) == 0.0f || strength == 0 )	{		return;	}	// check target flags	if ( target->flags & FL_NO_KNOCKBACK )	{		return;	}	ca = BG_Class( target->client->ps.stats[ STAT_CLASS ] );	// normalize direction	VectorCopy( direction, dir );	VectorNormalize( dir );	// adjust strength according to client mass	if ( !ignoreMass )	{		if ( ca->mass <= 0 )		{			mass = KNOCKBACK_NORMAL_MASS;		}		else		{			mass = ca->mass;		}		massMod = ( float )KNOCKBACK_NORMAL_MASS / ( float )mass;		if ( massMod < 0.5f )		{			massMod = 0.5f;		}		else if ( massMod > 2.0f )		{			massMod = 2.0f;		}	}	else	{		// for debug print		massMod = 1.0f;	}	strength *= massMod;	// adjust client velocity	VectorScale( dir, strength, vel );	VectorAdd( target->client->ps.velocity, vel, target->client->ps.velocity );	// set pmove timer so that the client can't cancel out the movement immediately	if ( !target->client->ps.pm_time )	{		target->client->ps.pm_time = KNOCKBACK_PMOVE_TIME;		target->client->ps.pm_flags |= PMF_TIME_KNOCKBACK;	}	// print debug info	if ( g_debugKnockback.integer )	{		G_Printf( "%i: Knockback: client: %i, strength: %.1f (massMod: %.1f)/n",		          level.time, target->s.number, strength, massMod );	}}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:75,


示例27: G_GetPointDamageMod

float G_GetPointDamageMod( gentity_t *target, class_t pcl, float angle, float height ){	int            regionNum;	damageRegion_t *region;	qboolean       crouching;	if ( !target || !target->client )	{		return 1.0f;	}	crouching = ( target->client->ps.pm_flags & PMF_DUCKED );	for ( regionNum = 0; regionNum < g_numDamageRegions[ pcl ]; regionNum++ )	{		region = &g_damageRegions[ pcl ][ regionNum ];		// ignore nonlocational		if ( region->nonlocational )		{			continue;		}		// crouch state must match		if ( region->crouch != crouching )		{			continue;		}		// height must be within range		if ( height < region->minHeight || height > region->maxHeight )		{			continue;		}		// angle must be within range		if ( ( region->minAngle <= region->maxAngle && ( angle < region->minAngle || angle > region->maxAngle ) ) ||		     ( region->minAngle >  region->maxAngle && ( angle > region->maxAngle && angle < region->minAngle ) ) )		{			continue;		}		if ( g_debugDamage.integer > 1 )		{			G_Printf( "GetPointDamageModifier( pcl = %s, angle = %.2f, height = %.2f ): "			          S_COLOR_GREEN "FOUND:" S_COLOR_WHITE " %.2f (%s)/n",			          BG_Class( pcl )->name, angle, height, region->modifier, region->name );		}		return region->modifier;	}	if ( g_debugDamage.integer > 1 )	{		G_Printf( "GetPointDamageModifier( pcl = %s, angle = %.2f, height = %.2f ): "		          S_COLOR_YELLOW "NOT FOUND:" S_COLOR_WHITE " %.2f/n",		          BG_Class( pcl )->name, angle, height, 1.0f );	}	return 1.0f;}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:61,


示例28: G_UpdateUnlockables

void G_UpdateUnlockables(){	int              itemNum = 0, unlockableNum, unlockThreshold;	float            momentum;	unlockable_t     *unlockable;	int              unlockableType = 0;	team_t           team;	for ( unlockableNum = 0; unlockableNum < NUM_UNLOCKABLES; unlockableNum++ )	{		unlockable = &unlockables[ unlockableNum ];		// also iterate over item types, itemNum is a per-type counter		while ( unlockableType < UNLT_NUM_UNLOCKABLETYPES - 1 &&		        unlockableNum == unlockablesTypeOffset[ unlockableType + 1 ] )		{			unlockableType++;			itemNum = 0;		}		switch ( unlockableType )		{			case UNLT_WEAPON:				team            = BG_Weapon( itemNum )->team;				unlockThreshold = BG_Weapon( itemNum )->unlockThreshold;				break;			case UNLT_UPGRADE:				team            = TEAM_HUMANS;				unlockThreshold = BG_Upgrade( itemNum )->unlockThreshold;				break;			case UNLT_BUILDABLE:				team            = BG_Buildable( itemNum )->team;				unlockThreshold = BG_Buildable( itemNum )->unlockThreshold;				break;			case UNLT_CLASS:				team            = TEAM_ALIENS;				unlockThreshold = BG_Class( itemNum )->unlockThreshold;				break;			default:				Com_Error( ERR_FATAL, "G_UpdateUnlockables: Unknown unlockable type" );		}		unlockThreshold = MAX( unlockThreshold, 0 );		momentum = level.team[ team ].momentum;		unlockable->type            = unlockableType;		unlockable->num             = itemNum;		unlockable->team            = team;		unlockable->statusKnown     = true;		unlockable->unlockThreshold = unlockThreshold;		unlockable->lockThreshold   = UnlockToLockThreshold( unlockThreshold );		// calculate the item's locking state		unlockable->unlocked = (		    !unlockThreshold || momentum >= unlockThreshold ||		    ( unlockable->unlocked && momentum >= unlockable->lockThreshold )		);		itemNum++;		/*Com_Printf( "G_UpdateUnlockables: Team %s, Type %s, Item %s, Momentum %d, Threshold %d, "		            "Unlocked %d, Synchronize %d/n",		            BG_TeamName( team ), UnlockableTypeName( unlockable ), UnlockableName( unlockable ),		            momentum, unlockThreshold, unlockable->unlocked, unlockable->synchronize );*/	}	// GAME knows about all teams	unlockablesDataAvailable = true;	unlockablesTeamKnowledge = TEAM_ALL;	// generate masks for network transmission	UpdateUnlockablesMask();}
开发者ID:JacksonTech,项目名称:Unvanquished,代码行数:77,


示例29: CG_CalcFov

static int CG_CalcFov( void ){	float     y;	float     phase;	float     v;	int       contents;	float     fov_x, fov_y;	float     zoomFov;	float     f;	int       inwater;	int       attribFov;	usercmd_t cmd;	usercmd_t oldcmd;	int       cmdNum;	cmdNum = trap_GetCurrentCmdNumber();	trap_GetUserCmd( cmdNum, &cmd );	trap_GetUserCmd( cmdNum - 1, &oldcmd );	// switch follow modes if necessary: cycle between free -> follow -> third-person follow	if ( usercmdButtonPressed( cmd.buttons, BUTTON_USE_HOLDABLE ) && !usercmdButtonPressed( oldcmd.buttons, BUTTON_USE_HOLDABLE ) )	{		if ( cg.snap->ps.pm_flags & PMF_FOLLOW )		{			if ( !cg.chaseFollow )			{				cg.chaseFollow = qtrue;			}			else			{				cg.chaseFollow = qfalse;				trap_SendClientCommand( "follow/n" );			}		}		else if ( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT )		{			trap_SendClientCommand( "follow/n" );		}	}	if ( cg.predictedPlayerState.pm_type == PM_INTERMISSION ||	     ( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT ) ||	     ( cg.renderingThirdPerson ) )	{		// if in intermission or third person, use a fixed value		fov_y = BASE_FOV_Y;	}	else	{		// don't lock the fov globally - we need to be able to change it		if ( ( attribFov = trap_Cvar_VariableIntegerValue( BG_Class( cg.predictedPlayerState.stats[ STAT_CLASS ] )->fovCvar ) ) )		{			if ( attribFov < 80 )			{				attribFov = 80;			}			else if ( attribFov >= 140 )			{				attribFov = 140;			}		}		else		{			attribFov = BG_Class( cg.predictedPlayerState.stats[ STAT_CLASS ] )->fov;		}		attribFov *= 0.75;		fov_y = attribFov;		if ( fov_y < 1.0f )		{			fov_y = 1.0f;		}		else if ( fov_y > MAX_FOV_Y )		{			fov_y = MAX_FOV_Y;		}		if ( cg.spawnTime > ( cg.time - FOVWARPTIME ) &&		     BG_ClassHasAbility( cg.predictedPlayerState.stats[ STAT_CLASS ], SCA_FOVWARPS ) )		{			float fraction = ( float )( cg.time - cg.spawnTime ) / FOVWARPTIME;			fov_y = MAX_FOV_WARP_Y - ( ( MAX_FOV_WARP_Y - fov_y ) * fraction );		}		// account for zooms		zoomFov = BG_Weapon( cg.predictedPlayerState.weapon )->zoomFov * 0.75f;		if ( zoomFov < 1.0f )		{			zoomFov = 1.0f;		}		else if ( zoomFov > attribFov )		{			zoomFov = attribFov;		}		// only do all the zoom stuff if the client CAN zoom		// FIXME: zoom control is currently hard coded to WBUTTON_ATTACK2		if ( BG_Weapon( cg.predictedPlayerState.weapon )->canZoom )//.........这里部分代码省略.........
开发者ID:Foe-of-Eternity,项目名称:Unvanquished,代码行数:101,


示例30: ClientSpawn

//.........这里部分代码省略.........	client->airOutTime = level.time + 12000;	trap_GetUserinfo( index, userinfo, sizeof( userinfo ) );	client->ps.eFlags = flags;	//Log::Notice( "ent->client->pers->pclass = %i/n", ent->client->pers.classSelection );	ent->s.groundEntityNum = ENTITYNUM_NONE;	ent->client = &level.clients[ index ];	ent->classname = S_PLAYER_CLASSNAME;	if ( client->noclip )	{		client->cliprcontents = CONTENTS_BODY;	}	else	{		ent->r.contents = CONTENTS_BODY;	}	ent->clipmask = MASK_PLAYERSOLID;	ent->die = G_PlayerDie;	ent->waterlevel = 0;	ent->watertype = 0;	ent->flags &= FL_GODMODE | FL_NOTARGET;	// calculate each client's acceleration	ent->evaluateAcceleration = true;	client->ps.stats[ STAT_MISC ] = 0;	client->ps.eFlags = flags;	client->ps.clientNum = index;	BG_ClassBoundingBox( ent->client->pers.classSelection, ent->r.mins, ent->r.maxs, nullptr, nullptr, nullptr );	// clear entity values	if ( ent->client->pers.classSelection == PCL_HUMAN_NAKED )	{		BG_AddUpgradeToInventory( UP_MEDKIT, client->ps.stats );		weapon = client->pers.humanItemSelection;	}	else if ( client->sess.spectatorState == SPECTATOR_NOT )	{		weapon = BG_Class( ent->client->pers.classSelection )->startWeapon;	}	else	{		weapon = WP_NONE;	}	maxAmmo = BG_Weapon( weapon )->maxAmmo;	maxClips = BG_Weapon( weapon )->maxClips;	client->ps.stats[ STAT_WEAPON ] = weapon;	client->ps.ammo = maxAmmo;	client->ps.clips = maxClips;	// We just spawned, not changing weapons	client->ps.persistant[ PERS_NEWWEAPON ] = 0;	client->ps.persistant[ PERS_TEAM ] = client->pers.team;	// TODO: Check whether stats can be cleared at once instead of per field	client->ps.stats[ STAT_STAMINA ] = STAMINA_MAX;	client->ps.stats[ STAT_FUEL ]    = JETPACK_FUEL_MAX;	client->ps.stats[ STAT_CLASS ] = ent->client->pers.classSelection;	client->ps.stats[ STAT_BUILDABLE ] = BA_NONE;
开发者ID:t4im,项目名称:Unvanquished,代码行数:67,



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


C++ BG_EvaluateTrajectory函数代码示例
C++ BG_Buildable函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。