这篇教程C++ AngleNormalize360函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中AngleNormalize360函数的典型用法代码示例。如果您正苦于以下问题:C++ AngleNormalize360函数的具体用法?C++ AngleNormalize360怎么用?C++ AngleNormalize360使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了AngleNormalize360函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ImperialProbe_Wait/*-------------------------ImperialProbe_Wait-------------------------*/void ImperialProbe_Wait(void){ if ( NPCInfo->localState == LSTATE_DROP ) { vec3_t endPos; trace_t trace; NPCInfo->desiredYaw = AngleNormalize360( NPCInfo->desiredYaw + 25 ); VectorSet( endPos, NPC->r.currentOrigin[0], NPC->r.currentOrigin[1], NPC->r.currentOrigin[2] - 32 ); trap_Trace( &trace, NPC->r.currentOrigin, NULL, NULL, endPos, NPC->s.number, MASK_SOLID ); if ( trace.fraction != 1.0f ) { G_Damage(NPC, NPC->enemy, NPC->enemy, NULL, NULL, 2000, 0,MOD_UNKNOWN); } } NPC_UpdateAngles( qtrue, qtrue );}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:25,
示例2: R2D2_PartsMovevoid R2D2_PartsMove( void ) { // Front 'eye' lense if ( TIMER_Done( NPC, "eyeDelay" ) ) { NPC->pos1.yaw = AngleNormalize360( NPC->pos1.yaw ); NPC->pos1.pitch += Q_irand( -20, 20 ); // Roll NPC->pos1.yaw = Q_irand( -20, 20 ); NPC->pos1.roll = Q_irand( -20, 20 ); /* if (NPC->genericBone1) { gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL ); } */ NPC_SetBoneAngles( NPC, "f_eye", &NPC->pos1 ); TIMER_Set( NPC, "eyeDelay", Q_irand( 100, 1000 ) ); }}
开发者ID:Arcadiaprime,项目名称:japp,代码行数:21,
示例3: assert// TODO: Use new vector math library for all calculations.void ArmorComponent::HandleApplyDamageModifier(float& damage, Util::optional<Vec3> location,Util::optional<Vec3> direction, int flags, meansOfDeath_t meansOfDeath) { vec3_t origin, bulletPath, bulletAngle, locationRelativeToFloor, floor, normal; // TODO: Remove dependency on client. assert(entity.oldEnt->client); // Use non-regional damage where appropriate. if (flags & DAMAGE_NO_LOCDAMAGE || !location) { // TODO: Move G_GetNonLocDamageMod to ArmorComponent. damage *= GetNonLocationalDamageMod(); return; } // Get hit location relative to the floor beneath. if (g_unlagged.integer && entity.oldEnt->client->unlaggedCalc.used) { VectorCopy(entity.oldEnt->client->unlaggedCalc.origin, origin); } else { VectorCopy(entity.oldEnt->r.currentOrigin, origin); } BG_GetClientNormal(&entity.oldEnt->client->ps, normal); VectorMA(origin, entity.oldEnt->r.mins[2], normal, floor); VectorSubtract(location.value().Data(), floor, locationRelativeToFloor); // Get fraction of height where the hit landed. float height = entity.oldEnt->r.maxs[2] - entity.oldEnt->r.mins[2]; if (!height) height = 1.0f; float hitRatio = Math::Clamp(DotProduct(normal, locationRelativeToFloor) / VectorLength(normal), 0.0f, height) / height; // Get the yaw of the attack relative to the target's view yaw VectorSubtract(location.value().Data(), origin, bulletPath); vectoangles(bulletPath, bulletAngle); int hitRotation = AngleNormalize360(entity.oldEnt->client->ps.viewangles[YAW] - bulletAngle[YAW]); // Use regional modifier. // TODO: Move G_GetPointDamageMod to ArmorComponent. damage *= GetLocationalDamageMod(hitRotation, hitRatio);}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:40,
示例4: G_CallSpawn/*===============G_CallSpawnFinds the spawn function for the entity and calls it,returning qfalse if not found===============*/qboolean G_CallSpawn( gentity_t *ent ){ spawn_t *s; buildable_t buildable; if ( !ent->classname ) { G_Printf( "G_CallSpawn: NULL classname/n" ); return qfalse; } //check buildable spawn functions if ( ( buildable = BG_FindBuildNumForEntityName( ent->classname ) ) != BA_NONE ) { if ( buildable == BA_A_SPAWN || buildable == BA_H_SPAWN ) { ent->s.angles[ YAW ] += 180.0f; AngleNormalize360( ent->s.angles[ YAW ] ); } G_SpawnBuildable( ent, buildable ); return qtrue; } // check normal spawn functions for ( s = spawns; s->name; s++ ) { if ( !strcmp( s->name, ent->classname ) ) { // found it s->spawn( ent ); return qtrue; } } G_Printf( "%s doesn't have a spawn function/n", ent->classname ); return qfalse;}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:46,
示例5: G_CallSpawn/*===============G_CallSpawnFinds the spawn function for the entity and calls it,returning qfalse if not found=============== */qboolean G_CallSpawn(gentity_t *ent) { spawn_t *s; buildable_t buildable; if (!ent->classname) { G_Printf("G_CallSpawn: NULL classname/n"); return qfalse; } //check buildable spawn functions if ((buildable = BG_FindBuildNumForEntityName(ent->classname)) != BA_NONE) { // don't spawn built-in buildings if we are using a custom layout if (level.layout[ 0 ] && Q_stricmp(level.layout, "*BUILTIN*")) return qtrue; if (buildable == BA_A_SPAWN || buildable == BA_H_SPAWN) { ent->s.angles[ YAW ] += 180.0f; AngleNormalize360(ent->s.angles[ YAW ]); } G_SpawnBuildable(ent, buildable, ent->biteam, level.survivalStage); return qtrue; } // check normal spawn functions for (s = spawns; s->name; s++) { if (!strcmp(s->name, ent->classname)) { // found it s->spawn(ent); return qtrue; } } G_Printf("%s doesn't have a spawn function/n", ent->classname); return qfalse;}
开发者ID:diegomichel,项目名称:zombiemodtremulous,代码行数:44,
示例6: NPC_BSJumpvoid NPC_BSJump (void){ vec3_t dir, angles, p1, p2, apex; float time, height, forward, z, xy, dist, yawError, apexHeight; if( !NPCInfo->goalEntity ) {//Should have task completed the navgoal return; } if ( NPCInfo->jumpState != JS_JUMPING && NPCInfo->jumpState != JS_LANDING ) { //Face navgoal VectorSubtract(NPCInfo->goalEntity->currentOrigin, NPC->currentOrigin, dir); vectoangles(dir, angles); NPCInfo->desiredPitch = NPCInfo->lockedDesiredPitch = AngleNormalize360(angles[PITCH]); NPCInfo->desiredYaw = NPCInfo->lockedDesiredYaw = AngleNormalize360(angles[YAW]); } NPC_UpdateAngles ( qtrue, qtrue ); yawError = AngleDelta ( NPC->client->ps.viewangles[YAW], NPCInfo->desiredYaw ); //We don't really care about pitch here switch ( NPCInfo->jumpState ) { case JS_FACING: if ( yawError < MIN_ANGLE_ERROR ) {//Facing it, Start crouching NPC_SetAnim(NPC, SETANIM_LEGS, BOTH_CROUCH1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD); NPCInfo->jumpState = JS_CROUCHING; } break; case JS_CROUCHING: if ( NPC->client->ps.legsAnimTimer > 0 ) {//Still playing crouching anim return; } //Create a parabola if ( NPC->currentOrigin[2] > NPCInfo->goalEntity->currentOrigin[2] ) { VectorCopy( NPC->currentOrigin, p1 ); VectorCopy( NPCInfo->goalEntity->currentOrigin, p2 ); } else if ( NPC->currentOrigin[2] < NPCInfo->goalEntity->currentOrigin[2] ) { VectorCopy( NPCInfo->goalEntity->currentOrigin, p1 ); VectorCopy( NPC->currentOrigin, p2 ); } else { VectorCopy( NPC->currentOrigin, p1 ); VectorCopy( NPCInfo->goalEntity->currentOrigin, p2 ); } //z = xy*xy VectorSubtract( p2, p1, dir ); dir[2] = 0; //Get xy and z diffs xy = VectorNormalize( dir ); z = p1[2] - p2[2]; apexHeight = APEX_HEIGHT/2; /* //Determine most desirable apex height apexHeight = (APEX_HEIGHT * PARA_WIDTH/xy) + (APEX_HEIGHT * z/128); if ( apexHeight < APEX_HEIGHT * 0.5 ) { apexHeight = APEX_HEIGHT*0.5; } else if ( apexHeight > APEX_HEIGHT * 2 ) { apexHeight = APEX_HEIGHT*2; } */ //FIXME: length of xy will change curve of parabola, need to account for this //somewhere... PARA_WIDTH z = (sqrt(apexHeight + z) - sqrt(apexHeight)); assert(z >= 0);// gi.Printf("apex is %4.2f percent from p1: ", (xy-z)*0.5/xy*100.0f); xy -= z; xy *= 0.5; assert(xy > 0); VectorMA( p1, xy, dir, apex ); apex[2] += apexHeight; VectorCopy(apex, NPC->pos1); //Now we have the apex, aim for it height = apex[2] - NPC->currentOrigin[2]; time = sqrt( height / ( .5 * NPC->client->ps.gravity ) );//.........这里部分代码省略.........
开发者ID:Chedo,项目名称:OpenJK,代码行数:101,
示例7: Pilot_Steer_Vehicle//.........这里部分代码省略.........// APPLY RESULTS//======================= // Decide Turbo //-------------- if (ActorDoTurbo || ActorInTurbo) { ucmd.buttons |= BUTTON_ALT_ATTACK; } else { ucmd.buttons &=~BUTTON_ALT_ATTACK; } // Decide Acceleration //--------------------- ucmd.forwardmove = (ActorAccelerate)?(127):(0); // Decide To Shoot //----------------- ucmd.buttons &=~BUTTON_ATTACK; ucmd.rightmove = 0; if (AimDistance<2000 && !EnemyDead) { // If Doing A Ram Attack //----------------------- if (ActorYawOffset!=0) { if (NPC->client->ps.weapon!=WP_NONE) { NPC_ChangeWeapon(WP_NONE); } ucmd.buttons &=~BUTTON_ATTACK; } else if (AimAccuracy>ATTACK_FWD) { if (NPC->client->ps.weapon!=WP_NONE) { NPC_ChangeWeapon(WP_NONE); } ucmd.buttons |= BUTTON_ATTACK; } else if (AimAccuracy<AIM_SIDE && AimAccuracy>-AIM_SIDE) { if (NPC->client->ps.weapon!=WP_BLASTER) { NPC_ChangeWeapon(WP_BLASTER); } if (AimAccuracy<ATTACK_SIDE && AimAccuracy>-ATTACK_SIDE) { //if (!TIMER_Done(NPC, "RiderAltAttack")) //{ // ucmd.buttons |= BUTTON_ALT_ATTACK; //} //else //{ ucmd.buttons |= BUTTON_ATTACK; /* if (TIMER_Done(NPC, "RiderAltAttackCheck")) { TIMER_Set(NPC, "RiderAltAttackCheck", Q_irand(1000, 3000)); if (Q_irand(0, 2)==0) { TIMER_Set(NPC, "RiderAltAttack", 300); } }*/ //} WeaponThink(true); } ucmd.rightmove = (EnemySide==Side_Left)?( 127):(-127); } else { if (NPC->client->ps.weapon!=WP_NONE) { NPC_ChangeWeapon(WP_NONE); } } } else { if (NPC->client->ps.weapon!=WP_NONE) { NPC_ChangeWeapon(WP_NONE); } } // Aim At Target //--------------- if (ActorAimAtTarget) { MoveDirection.VecToAng(); NPCInfo->desiredPitch = AngleNormalize360(MoveDirection[PITCH]); NPCInfo->desiredYaw = AngleNormalize360(MoveDirection[YAW] + ActorYawOffset); } NPC_UpdateAngles(qtrue, qtrue);}
开发者ID:matthewvdz,项目名称:joja,代码行数:101,
示例8: Interrogator_PartsMove/*-------------------------Interrogator_PartsMove-------------------------*/void Interrogator_PartsMove(void){ // Syringe if ( TIMER_Done(NPC,"syringeDelay") ) { NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]); if ((NPC->pos1[1] < 60) || (NPC->pos1[1] > 300)) { NPC->pos1[1]+=Q_irand( -20, 20 ); // Pitch } else if (NPC->pos1[1] > 180) { NPC->pos1[1]=Q_irand( 300, 360 ); // Pitch } else { NPC->pos1[1]=Q_irand( 0, 60 ); // Pitch } // gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL ); NPC_SetBoneAngles(NPC, "left_arm", NPC->pos1); TIMER_Set( NPC, "syringeDelay", Q_irand( 100, 1000 ) ); } // Scalpel if ( TIMER_Done(NPC,"scalpelDelay") ) { // Change pitch if ( NPCInfo->localState == LSTATE_BLADEDOWN ) // Blade is moving down { NPC->pos2[0]-= 30; if (NPC->pos2[0] < 180) { NPC->pos2[0] = 180; NPCInfo->localState = LSTATE_BLADEUP; // Make it move up } } else // Blade is coming back up { NPC->pos2[0]+= 30; if (NPC->pos2[0] >= 360) { NPC->pos2[0] = 360; NPCInfo->localState = LSTATE_BLADEDOWN; // Make it move down TIMER_Set( NPC, "scalpelDelay", Q_irand( 100, 1000 ) ); } } NPC->pos2[0] = AngleNormalize360( NPC->pos2[0]); // gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone2, NPC->pos2, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL ); NPC_SetBoneAngles(NPC, "right_arm", NPC->pos2); } // Claw NPC->pos3[1] += Q_irand( 10, 30 ); NPC->pos3[1] = AngleNormalize360( NPC->pos3[1]); //gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone3, NPC->pos3, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL ); NPC_SetBoneAngles(NPC, "claw", NPC->pos3);}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:69,
示例9: Sniper_FaceEnemyvoid Sniper_FaceEnemy( void ){ //FIXME: the ones behind kill holes are facing some arbitrary direction and not firing //FIXME: If actually trying to hit enemy, don't fire unless enemy is at least in front of me? //FIXME: need to give designers option to make them not miss first few shots if ( NPC->enemy ) { vec3_t muzzle, target, angles, forward, right, up; //Get the positions AngleVectors( NPC->client->ps.viewangles, forward, right, up ); CalcMuzzlePoint( NPC, forward, right, up, muzzle, 0 ); //CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); CalcEntitySpot( NPC->enemy, SPOT_ORIGIN, target ); if ( enemyDist > 65536 && NPCInfo->stats.aim < 5 )//is 256 squared, was 16384 (128*128) { if ( NPC->count < (5-NPCInfo->stats.aim) ) {//miss a few times first if ( shoot && TIMER_Done( NPC, "attackDelay" ) && level.time >= NPCInfo->shotTime ) {//ready to fire again qboolean aimError = qfalse; qboolean hit = qtrue; int tryMissCount = 0; trace_t trace; GetAnglesForDirection( muzzle, target, angles ); AngleVectors( angles, forward, right, up ); while ( hit && tryMissCount < 10 ) { tryMissCount++; if ( !Q_irand( 0, 1 ) ) { aimError = qtrue; if ( !Q_irand( 0, 1 ) ) { VectorMA( target, NPC->enemy->maxs[2]*Q_flrand(1.5, 4), right, target ); } else { VectorMA( target, NPC->enemy->mins[2]*Q_flrand(1.5, 4), right, target ); } } if ( !aimError || !Q_irand( 0, 1 ) ) { if ( !Q_irand( 0, 1 ) ) { VectorMA( target, NPC->enemy->maxs[2]*Q_flrand(1.5, 4), up, target ); } else { VectorMA( target, NPC->enemy->mins[2]*Q_flrand(1.5, 4), up, target ); } } gi.trace( &trace, muzzle, vec3_origin, vec3_origin, target, NPC->s.number, MASK_SHOT, G2_NOCOLLIDE, 0 ); hit = Sniper_EvaluateShot( trace.entityNum ); } NPC->count++; } else { if ( !enemyLOS ) { NPC_UpdateAngles( qtrue, qtrue ); return; } } } else {//based on distance, aim value, difficulty and enemy movement, miss //FIXME: incorporate distance as a factor? int missFactor = 8-(NPCInfo->stats.aim+g_spskill->integer) * 3; if ( missFactor > ENEMY_POS_LAG_STEPS ) { missFactor = ENEMY_POS_LAG_STEPS; } else if ( missFactor < 0 ) {//??? missFactor = 0 ; } VectorCopy( NPCInfo->enemyLaggedPos[missFactor], target ); } GetAnglesForDirection( muzzle, target, angles ); } else { target[2] += Q_flrand( 0, NPC->enemy->maxs[2] ); //CalcEntitySpot( NPC->enemy, SPOT_HEAD_LEAN, target ); GetAnglesForDirection( muzzle, target, angles ); } NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); NPCInfo->desiredPitch = AngleNormalize360( angles[PITCH] ); } NPC_UpdateAngles( qtrue, qtrue );}
开发者ID:kikili,项目名称:OpenJK,代码行数:96,
示例10: ClientSpawn//.........这里部分代码省略......... ent->health = client->ps.stats[ STAT_HEALTH ] = client->ps.stats[ STAT_MAX_HEALTH ]; //* 1.25; //if evolving scale health if( ent == spawn ) { ent->health *= ent->client->pers.evolveHealthFraction; client->ps.stats[ STAT_HEALTH ] *= ent->client->pers.evolveHealthFraction; } //clear the credits array for( i = 0; i < MAX_CLIENTS; i++ ) ent->credits[ i ] = 0; client->ps.stats[ STAT_STAMINA ] = STAMINA_MAX; G_SetOrigin( ent, spawn_origin ); VectorCopy( spawn_origin, client->ps.origin );#define UP_VEL 150.0f#define F_VEL 50.0f //give aliens some spawn velocity if( client->sess.spectatorState == SPECTATOR_NOT && client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) { if( ent == spawn ) { //evolution particle system G_AddPredictableEvent( ent, EV_ALIEN_EVOLVE, DirToByte( up ) ); } else { spawn_angles[ YAW ] += 180.0f; AngleNormalize360( spawn_angles[ YAW ] ); if( spawnPoint->s.origin2[ 2 ] > 0.0f ) { vec3_t forward, dir; AngleVectors( spawn_angles, forward, NULL, NULL ); VectorScale( forward, F_VEL, forward ); VectorAdd( spawnPoint->s.origin2, forward, dir ); VectorNormalize( dir ); VectorScale( dir, UP_VEL, client->ps.velocity ); } G_AddPredictableEvent( ent, EV_PLAYER_RESPAWN, 0 ); } } else if( client->sess.spectatorState == SPECTATOR_NOT && client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) { spawn_angles[ YAW ] += 180.0f; AngleNormalize360( spawn_angles[ YAW ] ); } // the respawned flag will be cleared after the attack and jump keys come up client->ps.pm_flags |= PMF_RESPAWNED; trap_GetUsercmd( client - level.clients, &ent->client->pers.cmd ); G_SetClientViewAngle( ent, spawn_angles ); if( client->sess.spectatorState == SPECTATOR_NOT ) { trap_LinkEntity( ent );
开发者ID:GrangerHub,项目名称:tremulous,代码行数:67,
示例11: NPC_MoveToGoalqboolean NPC_MoveToGoal( qboolean tryStraight ) { float distance; vec3_t dir;#if AI_TIMERS int startTime = GetTime(0);#endif// AI_TIMERS //If taking full body pain, don't move if ( PM_InKnockDown( &NPC->client->ps ) || ( ( NPC->s.legsAnim >= BOTH_PAIN1 ) && ( NPC->s.legsAnim <= BOTH_PAIN18 ) ) ) { return qtrue; } /* if( NPC->s.eFlags & EF_LOCKED_TO_WEAPON ) {//If in an emplaced gun, never try to navigate! return qtrue; } */ //rwwFIXMEFIXME: emplaced support //FIXME: if can't get to goal & goal is a target (enemy), try to find a waypoint that has line of sight to target, at least? //Get our movement direction#if 1 if ( NPC_GetMoveDirectionAltRoute( dir, &distance, tryStraight ) == qfalse )#else if ( NPC_GetMoveDirection( dir, &distance ) == qfalse )#endif return qfalse; NPCInfo->distToGoal = distance; //Convert the move to angles vectoangles( dir, NPCInfo->lastPathAngles ); if ( (ucmd.buttons&BUTTON_WALKING) ) { NPC->client->ps.speed = NPCInfo->stats.walkSpeed; } else { NPC->client->ps.speed = NPCInfo->stats.runSpeed; } //FIXME: still getting ping-ponging in certain cases... !!! Nav/avoidance error? WTF???!!! //If in combat move, then move directly towards our goal if ( NPC_CheckCombatMove() ) {//keep current facing G_UcmdMoveForDir( NPC, &ucmd, dir ); } else {//face our goal //FIXME: strafe instead of turn if change in dir is small and temporary NPCInfo->desiredPitch = 0.0f; NPCInfo->desiredYaw = AngleNormalize360( NPCInfo->lastPathAngles[YAW] ); //Pitch towards the goal and also update if flying or swimming if ( (NPC->client->ps.eFlags2&EF2_FLYING) )//moveType == MT_FLYSWIM ) { NPCInfo->desiredPitch = AngleNormalize360( NPCInfo->lastPathAngles[PITCH] ); if ( dir[2] ) { float scale = (dir[2] * distance); if ( scale > 64 ) { scale = 64; } else if ( scale < -64 ) { scale = -64; } NPC->client->ps.velocity[2] = scale; //NPC->client->ps.velocity[2] = (dir[2] > 0) ? 64 : -64; } } //Set any final info ucmd.forwardmove = 127; }#if AI_TIMERS navTime += GetTime( startTime );#endif// AI_TIMERS return qtrue;}
开发者ID:jwginge,项目名称:ojpa,代码行数:86,
示例12: NAVNEW_SidestepBlocker/*-------------------------NAVNEW_SidestepBlocker-------------------------*/qboolean NAVNEW_SidestepBlocker( gentity_t *self, gentity_t *blocker, vec3_t blocked_dir, float blocked_dist, vec3_t movedir, vec3_t right ){//trace to sides of blocker and see if either is clear trace_t tr; vec3_t avoidAngles; vec3_t avoidRight_dir, avoidLeft_dir, block_pos, mins; float rightSucc, leftSucc, yaw, avoidRadius, arcAngle; VectorCopy( self->r.mins, mins ); mins[2] += STEPSIZE; //Get the blocked direction yaw = vectoyaw( blocked_dir ); //Get the avoid radius avoidRadius = sqrt( ( blocker->r.maxs[0] * blocker->r.maxs[0] ) + ( blocker->r.maxs[1] * blocker->r.maxs[1] ) ) + sqrt( ( self->r.maxs[0] * self->r.maxs[0] ) + ( self->r.maxs[1] * self->r.maxs[1] ) ); //See if we're inside our avoidance radius arcAngle = ( blocked_dist <= avoidRadius ) ? 135 : ( ( avoidRadius / blocked_dist ) * 90 ); /* float dot = DotProduct( blocked_dir, right ); //Go right on the first try if that works better if ( dot < 0.0f ) arcAngle *= -1; */ VectorClear( avoidAngles ); //need to stop it from ping-ponging, so we have a bit of a debounce time on which side you try if ( self->NPC->sideStepHoldTime > level.time ) { if ( self->NPC->lastSideStepSide == -1 )//left { arcAngle *= -1; }//else right avoidAngles[YAW] = AngleNormalize360( yaw + arcAngle ); AngleVectors( avoidAngles, movedir, NULL, NULL ); VectorMA( self->r.currentOrigin, blocked_dist, movedir, block_pos ); trap->Trace( &tr, self->r.currentOrigin, mins, self->r.maxs, block_pos, self->s.number, self->clipmask|CONTENTS_BOTCLIP, qfalse, 0, 0 ); return (tr.fraction==1.0&&!tr.allsolid&&!tr.startsolid); } //test right avoidAngles[YAW] = AngleNormalize360( yaw + arcAngle ); AngleVectors( avoidAngles, avoidRight_dir, NULL, NULL ); VectorMA( self->r.currentOrigin, blocked_dist, avoidRight_dir, block_pos ); trap->Trace( &tr, self->r.currentOrigin, mins, self->r.maxs, block_pos, self->s.number, self->clipmask|CONTENTS_BOTCLIP, qfalse, 0, 0 ); if ( !tr.allsolid && !tr.startsolid ) { if ( tr.fraction >= 1.0f ) {//all clear, go for it (favor the right if both are equal) VectorCopy( avoidRight_dir, movedir ); self->NPC->lastSideStepSide = 1; self->NPC->sideStepHoldTime = level.time + 2000; return qtrue; } rightSucc = tr.fraction; } else { rightSucc = 0.0f; } //now test left arcAngle *= -1; avoidAngles[YAW] = AngleNormalize360( yaw + arcAngle ); AngleVectors( avoidAngles, avoidLeft_dir, NULL, NULL ); VectorMA( self->r.currentOrigin, blocked_dist, avoidLeft_dir, block_pos ); trap->Trace( &tr, self->r.currentOrigin, mins, self->r.maxs, block_pos, self->s.number, self->clipmask|CONTENTS_BOTCLIP, qfalse, 0, 0 ); if ( !tr.allsolid && !tr.startsolid ) { if ( tr.fraction >= 1.0f ) {//all clear, go for it (right side would have already succeeded if as good as this) VectorCopy( avoidLeft_dir, movedir ); self->NPC->lastSideStepSide = -1; self->NPC->sideStepHoldTime = level.time + 2000; return qtrue; } leftSucc = tr.fraction; } else { leftSucc = 0.0f; } if ( leftSucc == 0.0f && rightSucc == 0.0f )//.........这里部分代码省略.........
开发者ID:Almightygir,项目名称:OpenJK,代码行数:101,
示例13: CG_Democam_CalcView//.........这里部分代码省略......... lerpspline = A * pow( lerpfrac, 2 ) + B * lerpfrac; } else if( previouscam && nextcam && !secondnextcam ) { n2 = currentcam->timeStamp - previouscam->timeStamp; n3 = nextcam->timeStamp - currentcam->timeStamp; A = n3 * ( n2 - n3 ) / ( -n2 - n3 + n2 * n3 + pow( n3, 2 ) ); B = -1 / ( -n2 - n3 + n2 * n3 + pow( n3, 2 ) ) * ( n2 + n3 - 2 * pow( n3, 2 ) ); lerpfrac = (float)( demo_time - currentcam->timeStamp ) / (float)( nextcam->timeStamp - currentcam->timeStamp ); lerpspline = A * pow( lerpfrac, 2 ) + B * lerpfrac; } else if( previouscam && nextcam && secondnextcam ) { n1 = currentcam->timeStamp - previouscam->timeStamp; n2 = nextcam->timeStamp - currentcam->timeStamp; n3 = secondnextcam->timeStamp - nextcam->timeStamp; A = -2 * pow( n2, 2 ) * ( -pow( n2, 2 ) + n1 * n3 ) / ( 2 * n2 * n3 + pow( n2, 3 ) * n3 - 3 * pow( n2, 2 ) * n1 + n1 * pow( n2, 3 ) + 2 * n1 * n2 - 3 * pow( n2, 2 ) * n3 - 3 * pow( n2, 3 ) + 2 * pow( n2, 2 ) + pow( n2, 4 ) + n1 * pow( n2, 2 ) * n3 - 3 * n1 * n2 * n3 + 2 * n1 * n3 ); B = pow( n2, 2 ) * ( -2 * n1 - 3 * pow( n2, 2 ) - n2 * n3 + 2 * n3 + 3 * n1 * n3 + n1 * n2 ) / ( 2 * n2 * n3 + pow( n2, 3 ) * n3 - 3 * pow( n2, 2 ) * n1 + n1 * pow( n2, 3 ) + 2 * n1 * n2 - 3 * pow( n2, 2 ) * n3 - 3 * pow( n2, 3 ) + 2 * pow( n2, 2 ) + pow( n2, 4 ) + n1 * pow( n2, 2 ) * n3 - 3 * n1 * n2 * n3 + 2 * n1 * n3 ); C = -( pow( n2, 2 ) * n1 - 2 * n1 * n2 + 3 * n1 * n2 * n3 - 2 * n1 * n3 - 2 * pow( n2, 4 ) + 3 * pow( n2, 3 ) - 2 * pow( n2, 3 ) * n3 + 5 * pow( n2, 2 ) * n3 - 2 * pow( n2, 2 ) - 2 * n2 * n3 ) / ( 2 * n2 * n3 + pow( n2, 3 ) * n3 - 3 * pow( n2, 2 ) * n1 + n1 * pow( n2, 3 ) + 2 * n1 * n2 - 3 * pow( n2, 2 ) * n3 - 3 * pow( n2, 3 ) + 2 * pow( n2, 2 ) + pow( n2, 4 ) + n1 * pow( n2, 2 ) * n3 - 3 * n1 * n2 * n3 + 2 * n1 * n3 ); lerpfrac = (float)( demo_time - currentcam->timeStamp ) / (float)( nextcam->timeStamp - currentcam->timeStamp ); lerpspline = A * pow( lerpfrac, 3 ) + B * pow( lerpfrac, 2 ) + C * lerpfrac; } else { lerpfrac = 0; lerpspline = 0; } VectorHermiteInterp( currentcam->origin, currentcam->tangent, nextcam->origin, nextcam->tangent, lerpspline, cam_origin ); if( !CG_DemoCam_LookAt( currentcam->trackEnt, cam_origin, cam_angles ) ) { VectorHermiteInterp( currentcam->angles, currentcam->angles_tangent, nextcam->angles, nextcam->angles_tangent, lerpspline, cam_angles ); } cam_fov = (float)currentcam->fov + (float)( nextcam->fov - currentcam->fov ) * lerpfrac;#undef VectorHermiteInterp } // set velocity VectorSubtract( cam_origin, v, cam_velocity ); VectorScale( cam_velocity, 1.0f / (float)cg.frameTime, cam_velocity ); break; case DEMOCAM_ORBITAL: viewType = VIEWDEF_DEMOCAM; cam_POVent = 0; cam_fov = currentcam->fov; VectorCopy( cam_origin, v ); if( !currentcam->trackEnt || currentcam->trackEnt >= MAX_EDICTS ) { CG_Printf( "Warning: CG_DemoCam: orbital cam needs a track entity set/n" ); VectorCopy( currentcam->origin, cam_origin ); VectorClear( cam_angles ); VectorClear( cam_velocity ); } else { vec3_t center, forward; struct cmodel_s *cmodel; const float ft = (float)cg.frameTime * 0.001f; // find the trackEnt origin VectorLerp( cg_entities[currentcam->trackEnt].prev.origin, cg.lerpfrac, cg_entities[currentcam->trackEnt].current.origin, center ); // if having a bounding box, look to its center if( ( cmodel = CG_CModelForEntity( currentcam->trackEnt ) ) != NULL ) { vec3_t mins, maxs; trap_CM_InlineModelBounds( cmodel, mins, maxs ); for( i = 0; i < 3; i++ ) center[i] += ( mins[i] + maxs[i] ); } if( !cam_orbital_radius ) { // cam is just started, find distance from cam to trackEnt and keep it as radius VectorSubtract( currentcam->origin, center, forward ); cam_orbital_radius = VectorNormalize( forward ); VecToAngles( forward, cam_orbital_angles ); } for( i = 0; i < 3; i++ ) { cam_orbital_angles[i] += currentcam->angles[i] * ft; cam_orbital_angles[i] = AngleNormalize360( cam_orbital_angles[i] ); } AngleVectors( cam_orbital_angles, forward, NULL, NULL ); VectorMA( center, cam_orbital_radius, forward, cam_origin ); // lookat VectorInverse( forward ); VecToAngles( forward, cam_angles ); } // set velocity VectorSubtract( cam_origin, v, cam_velocity ); VectorScale( cam_velocity, 1.0f / ( cg.frameTime * 1000.0f ), cam_velocity ); break; default: break; } if( currentcam->type != DEMOCAM_ORBITAL ) { VectorClear( cam_orbital_angles ); cam_orbital_radius = 0; } } return viewType;}
开发者ID:Picmip,项目名称:qfusion,代码行数:101,
示例14: turretG2_aim//-----------------------------------------------------static void turretG2_aim( gentity_t *self )//-----------------------------------------------------{ vec3_t enemyDir, org, org2; vec3_t desiredAngles, setAngle; float diffYaw = 0.0f, diffPitch = 0.0f; float maxYawSpeed = (self->spawnflags&SPF_TURRETG2_TURBO)?30.0f:14.0f; float maxPitchSpeed = (self->spawnflags&SPF_TURRETG2_TURBO)?15.0f:3.0f; // move our gun base yaw to where we should be at this time.... BG_EvaluateTrajectory( &self->s.apos, level.time, self->r.currentAngles ); self->r.currentAngles[YAW] = AngleNormalize360( self->r.currentAngles[YAW] ); self->speed = AngleNormalize360( self->speed ); if ( self->enemy ) { mdxaBone_t boltMatrix; // ...then we'll calculate what new aim adjustments we should attempt to make this frame // Aim at enemy if ( self->enemy->client ) { VectorCopy( self->enemy->client->renderInfo.eyePoint, org ); } else { VectorCopy( self->enemy->r.currentOrigin, org ); } if ( self->spawnflags & 2 ) { org[2] -= 15; } else { org[2] -= 5; } if ( (self->spawnflags&SPF_TURRETG2_LEAD_ENEMY) ) { //we want to lead them a bit vec3_t diff, velocity; float dist; VectorSubtract( org, self->s.origin, diff ); dist = VectorNormalize( diff ); if ( self->enemy->client ) { VectorCopy( self->enemy->client->ps.velocity, velocity ); } else { VectorCopy( self->enemy->s.pos.trDelta, velocity ); } VectorMA( org, (dist/self->mass), velocity, org ); } // Getting the "eye" here trap_G2API_GetBoltMatrix( self->ghoul2, 0, (self->alt_fire?self->genericValue12:self->genericValue11), &boltMatrix, self->r.currentAngles, self->s.origin, level.time, NULL, self->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, org2 ); VectorSubtract( org, org2, enemyDir ); vectoangles( enemyDir, desiredAngles ); diffYaw = AngleSubtract( self->r.currentAngles[YAW], desiredAngles[YAW] ); diffPitch = AngleSubtract( self->speed, desiredAngles[PITCH] ); } else { // no enemy, so make us slowly sweep back and forth as if searching for a new one// diffYaw = sin( level.time * 0.0001f + self->count ) * 5.0f; // don't do this for now since it can make it go into walls. } if ( diffYaw ) { // cap max speed.... if ( fabs(diffYaw) > maxYawSpeed ) { diffYaw = ( diffYaw >= 0 ? maxYawSpeed : -maxYawSpeed ); } // ...then set up our desired yaw VectorSet( setAngle, 0.0f, diffYaw, 0.0f ); VectorCopy( self->r.currentAngles, self->s.apos.trBase ); VectorScale( setAngle,- 5, self->s.apos.trDelta ); self->s.apos.trTime = level.time; self->s.apos.trType = TR_LINEAR; } if ( diffPitch ) { if ( fabs(diffPitch) > maxPitchSpeed ) {//.........这里部分代码省略.........
开发者ID:Atlas-zz,项目名称:SDK-JKA-ACADEMIE-HCF,代码行数:101,
示例15: GCam_Updatevoid GCam_Update( void ){ int i; qboolean checkFollow = qfalse; qboolean checkTrack = qfalse; //Check for roffing angles if ( (client_camera.info_state & CAMERA_ROFFING) && !(client_camera.info_state & CAMERA_FOLLOWING) ) { if (client_camera.info_state & CAMERA_CUT) { // we're doing a cut, so just go to the new angles. none of this hifalutin lerping business. for ( i = 0; i < 3; i++ ) { cameraang[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) ); } } else { for ( i = 0; i < 3; i++ ) { cameraang[i] = client_camera.angles[i] + ( client_camera.angles2[i] / client_camera.pan_duration ) * ( level.time - client_camera.pan_time ); } } } else if ( client_camera.info_state & CAMERA_PANNING ) { if (client_camera.info_state & CAMERA_CUT) { // we're doing a cut, so just go to the new angles. none of this hifalutin lerping business. for ( i = 0; i < 3; i++ ) { cameraang[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) ); } } else { //Note: does not actually change the camera's angles until the pan time is done! if ( client_camera.pan_time + client_camera.pan_duration < level.time ) {//finished panning for ( i = 0; i < 3; i++ ) { cameraang[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) ); } client_camera.info_state &= ~CAMERA_PANNING; VectorCopy(client_camera.angles, cameraang ); } else {//still panning for ( i = 0; i < 3; i++ ) { //NOTE: does not store the resultant angle in client_camera.angles until pan is done cameraang[i] = client_camera.angles[i] + ( client_camera.angles2[i] / client_camera.pan_duration ) * ( level.time - client_camera.pan_time ); } } } } else { checkFollow = qtrue; } //Check for movement if ( client_camera.info_state & CAMERA_MOVING ) { //NOTE: does not actually move the camera until the movement time is done! if ( client_camera.move_time + client_camera.move_duration < level.time ) { VectorCopy( client_camera.origin2, client_camera.origin ); client_camera.info_state &= ~CAMERA_MOVING; VectorCopy( client_camera.origin, camerapos ); } else { if (client_camera.info_state & CAMERA_CUT) { // we're doing a cut, so just go to the new origin. none of this fancypants lerping stuff. for ( i = 0; i < 3; i++ ) { camerapos[i] = client_camera.origin2[i]; } } else { for ( i = 0; i < 3; i++ ) { camerapos[i] = client_camera.origin[i] + (( ( client_camera.origin2[i] - client_camera.origin[i] ) ) / client_camera.move_duration ) * ( level.time - client_camera.move_time ); } } } } else { checkTrack = qtrue; } if ( checkFollow ) { if ( client_camera.info_state & CAMERA_FOLLOWING )//.........这里部分代码省略.........
开发者ID:jwginge,项目名称:ojpa,代码行数:101,
示例16: NPC_GetMoveDirectionqboolean NPC_GetMoveDirection( vec3_t out, float *distance ){ vec3_t angles; //Clear the struct memset( &frameNavInfo, 0, sizeof( frameNavInfo ) ); //Get our movement, if any if ( NPC_GetMoveInformation( frameNavInfo.direction, &frameNavInfo.distance ) == qfalse ) return qfalse; //Setup the return value *distance = frameNavInfo.distance; //For starters VectorCopy( frameNavInfo.direction, frameNavInfo.pathDirection ); //If on a ladder, move appropriately if ( NPC->watertype & CONTENTS_LADDER ) { NPC_LadderMove( frameNavInfo.direction ); return qtrue; } //Attempt a straight move to goal if ( NPC_ClearPathToGoal( frameNavInfo.direction, NPCInfo->goalEntity ) == qfalse ) { //See if we're just stuck if ( NAV_MoveToGoal( NPC, &frameNavInfo ) == WAYPOINT_NONE ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; } frameNavInfo.flags |= NIF_MACRO_NAV; } //Avoid any collisions on the way if ( NAV_AvoidCollision( NPC, NPCInfo->goalEntity, &frameNavInfo ) == qfalse ) { //FIXME: Emit a warning, this is a worst case scenario //FIXME: if we have a clear path to our goal (exluding bodies), but then this // check (against bodies only) fails, shouldn't we fall back // to macro navigation? Like so: if ( !(frameNavInfo.flags&NIF_MACRO_NAV) ) {//we had a clear path to goal and didn't try macro nav, but can't avoid collision so try macro nav here //See if we're just stuck if ( NAV_MoveToGoal( NPC, &frameNavInfo ) == WAYPOINT_NONE ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; } frameNavInfo.flags |= NIF_MACRO_NAV; } } //Setup the return values VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qtrue;}
开发者ID:jwginge,项目名称:ojpa,代码行数:71,
示例17: NPC_GetMoveDirectionAltRouteqboolean NPC_GetMoveDirectionAltRoute( vec3_t out, float *distance, qboolean tryStraight ){ vec3_t angles; NPCInfo->aiFlags &= ~NPCAI_BLOCKED; //Clear the struct memset( &frameNavInfo, 0, sizeof( frameNavInfo ) ); //Get our movement, if any if ( NPC_GetMoveInformation( frameNavInfo.direction, &frameNavInfo.distance ) == qfalse ) return qfalse; //Setup the return value *distance = frameNavInfo.distance; //For starters VectorCopy( frameNavInfo.direction, frameNavInfo.pathDirection ); //If on a ladder, move appropriately if ( NPC->watertype & CONTENTS_LADDER ) { NPC_LadderMove( frameNavInfo.direction ); return qtrue; } //Attempt a straight move to goal if ( !tryStraight || NPC_ClearPathToGoal( frameNavInfo.direction, NPCInfo->goalEntity ) == qfalse ) {//blocked //Can't get straight to goal, use macro nav if ( NAVNEW_MoveToGoal( NPC, &frameNavInfo ) == WAYPOINT_NONE ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; } //else we are on our way frameNavInfo.flags |= NIF_MACRO_NAV; } else {//we have no architectural problems, see if there are ents inthe way and try to go around them //not blocked if ( d_altRoutes.integer ) {//try macro nav navInfo_t tempInfo; memcpy( &tempInfo, &frameNavInfo, sizeof( tempInfo ) ); if ( NAVNEW_AvoidCollision( NPC, NPCInfo->goalEntity, &tempInfo, qtrue, 5 ) == qfalse ) {//revert to macro nav //Can't get straight to goal, dump tempInfo and use macro nav if ( NAVNEW_MoveToGoal( NPC, &frameNavInfo ) == WAYPOINT_NONE ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; } //else we are on our way frameNavInfo.flags |= NIF_MACRO_NAV; } else {//otherwise, either clear or can avoid memcpy( &frameNavInfo, &tempInfo, sizeof( frameNavInfo ) ); } } else {//OR: just give up if ( NAVNEW_AvoidCollision( NPC, NPCInfo->goalEntity, &frameNavInfo, qtrue, 30 ) == qfalse ) {//give up return qfalse; } } } //Setup the return values VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qtrue;}
开发者ID:jwginge,项目名称:ojpa,代码行数:84,
示例18: Droid_Patrol/*-------------------------Droid_Patrol-------------------------*/void Droid_Patrol( void ){ NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]); if ( NPC->client && NPC->client->NPC_class != CLASS_GONK ) { if (NPC->client->NPC_class != CLASS_R5D2) { //he doesn't have an eye. R2D2_PartsMove(); // Get his eye moving. } R2D2_TurnAnims(); } //If we have somewhere to go, then do that if ( UpdateGoal() ) { ucmd.buttons |= BUTTON_WALKING; NPC_MoveToGoal( qtrue ); if( NPC->client && NPC->client->NPC_class == CLASS_MOUSE ) { NPCInfo->desiredYaw += sin(level.time*.5) * 25; // Weaves side to side a little if (TIMER_Done(NPC,"patrolNoise")) { G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/mouse/misc/mousego%d.wav", Q_irand(1, 3)) ); TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) ); } } else if( NPC->client && NPC->client->NPC_class == CLASS_R2D2 ) { if (TIMER_Done(NPC,"patrolNoise")) { G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/r2d2/misc/r2d2talk0%d.wav", Q_irand(1, 3)) ); TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) ); } } else if( NPC->client && NPC->client->NPC_class == CLASS_R5D2 ) { if (TIMER_Done(NPC,"patrolNoise")) { G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/r5d2/misc/r5talk%d.wav", Q_irand(1, 4)) ); TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) ); } } if( NPC->client && NPC->client->NPC_class == CLASS_GONK ) { if (TIMER_Done(NPC,"patrolNoise")) { G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/gonk/misc/gonktalk%d.wav", Q_irand(1, 2)) ); TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) ); } }// else// {// R5D2_LookAround();// } } NPC_UpdateAngles( qtrue, qtrue );}
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:72,
示例19: CalcDamageModifierstatic float CalcDamageModifier( vec3_t point, gentity_t *target, class_t pcl, int damageFlags ){ vec3_t targOrigin, bulletPath, bulletAngle, pMINUSfloor, floor, normal; float clientHeight, hitRelative, hitRatio, modifier; int hitRotation; // handle nonlocational damage if ( damageFlags & DAMAGE_NO_LOCDAMAGE ) { return G_GetNonLocDamageMod( pcl ); } // need a valid point for point damage if ( point == NULL ) { return 1.0f; } // Get the point location relative to the floor under the target if ( g_unlagged.integer && target->client && target->client->unlaggedCalc.used ) { VectorCopy( target->client->unlaggedCalc.origin, targOrigin ); } else { VectorCopy( target->r.currentOrigin, targOrigin ); } BG_GetClientNormal( &target->client->ps, normal ); VectorMA( targOrigin, target->r.mins[ 2 ], normal, floor ); VectorSubtract( point, floor, pMINUSfloor ); // Get the proportion of the target height where the hit landed clientHeight = target->r.maxs[ 2 ] - target->r.mins[ 2 ]; if ( !clientHeight ) { clientHeight = 1.0f; } hitRelative = DotProduct( normal, pMINUSfloor ) / VectorLength( normal ); if ( hitRelative < 0.0f ) { hitRelative = 0.0f; } if ( hitRelative > clientHeight ) { hitRelative = clientHeight; } hitRatio = hitRelative / clientHeight; // Get the yaw of the attack relative to the target's view yaw VectorSubtract( point, targOrigin, bulletPath ); vectoangles( bulletPath, bulletAngle ); hitRotation = AngleNormalize360( target->client->ps.viewangles[ YAW ] - bulletAngle[ YAW ] ); // Get damage region modifier modifier = G_GetPointDamageMod( target, pcl, hitRotation, hitRatio ); return modifier;}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:64,
示例20: CGCam_Update//.........这里部分代码省略......... } client_camera.FOV = actualFOV_X; } CG_CalcFOVFromX( actualFOV_X ); } else if ( client_camera.info_state & CAMERA_ZOOMING ) { float actualFOV_X; if ( client_camera.FOV_time + client_camera.FOV_duration < cg.time ) { actualFOV_X = client_camera.FOV = client_camera.FOV2; client_camera.info_state &= ~CAMERA_ZOOMING; } else { actualFOV_X = client_camera.FOV + (( ( client_camera.FOV2 - client_camera.FOV ) ) / client_camera.FOV_duration ) * ( cg.time - client_camera.FOV_time ); } CG_CalcFOVFromX( actualFOV_X ); } else { CG_CalcFOVFromX( client_camera.FOV ); } //Check for roffing angles if ( (client_camera.info_state & CAMERA_ROFFING) && !(client_camera.info_state & CAMERA_FOLLOWING) ) { if (client_camera.info_state & CAMERA_CUT) { // we're doing a cut, so just go to the new angles. none of this hifalutin lerping business. for ( i = 0; i < 3; i++ ) { cg.refdefViewAngles[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) ); } } else { for ( i = 0; i < 3; i++ ) { cg.refdefViewAngles[i] = client_camera.angles[i] + ( client_camera.angles2[i] / client_camera.pan_duration ) * ( cg.time - client_camera.pan_time ); } } } else if ( client_camera.info_state & CAMERA_PANNING ) { if (client_camera.info_state & CAMERA_CUT) { // we're doing a cut, so just go to the new angles. none of this hifalutin lerping business. for ( i = 0; i < 3; i++ ) { cg.refdefViewAngles[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) ); } } else { //Note: does not actually change the camera's angles until the pan time is done! if ( client_camera.pan_time + client_camera.pan_duration < cg.time ) {//finished panning for ( i = 0; i < 3; i++ ) { client_camera.angles[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) ); } client_camera.info_state &= ~CAMERA_PANNING; VectorCopy(client_camera.angles, cg.refdefViewAngles );
开发者ID:Aura15,项目名称:OpenJK,代码行数:67,
示例21: G_CallSpawnFunction/*===============G_CallSpawnFunctionFinds the spawn function for the entity and calls it,returning qfalse if not found===============*/qboolean G_CallSpawnFunction( gentity_t *spawnedEntity ){ entityClassDescriptor_t *spawnedClass; buildable_t buildable; if ( !spawnedEntity->classname ) { //don't even warn about spawning-errors with -2 (maps might still work at least partly if we ignore these willingly) if ( g_debugEntities.integer > -2 ) G_Printf( S_ERROR "Entity " S_COLOR_CYAN "#%i" S_COLOR_WHITE " is missing classname C++ AngleSubtract函数代码示例 C++ AngleNormalize函数代码示例
|