这篇教程C++ Distance函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Distance函数的典型用法代码示例。如果您正苦于以下问题:C++ Distance函数的具体用法?C++ Distance怎么用?C++ Distance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Distance函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: NPC_BSHowler_Default/*-------------------------NPC_BSHowler_Default-------------------------*/void NPC_BSHowler_Default( void ){ if ( NPC->client->ps.legsAnim != BOTH_GESTURE1 ) { NPC->count = 0; } //FIXME: if in jump, do damage in front and maybe knock them down? if ( !TIMER_Done( NPC, "attacking" ) ) { if ( NPC->enemy ) { //NPC_FaceEnemy( qfalse ); Howler_Attack( Distance( NPC->enemy->currentOrigin, NPC->currentOrigin ) ); } else { //NPC_UpdateAngles( qfalse, qtrue ); Howler_Attack( 0.0f ); } NPC_UpdateAngles( qfalse, qtrue ); return; } if ( NPC->enemy ) { if ( NPCInfo->stats.aggression > 0 ) { if ( TIMER_Done( NPC, "aggressionDecay" ) ) { NPCInfo->stats.aggression--; TIMER_Set( NPC, "aggressionDecay", 500 ); } } if ( !TIMER_Done( NPC, "flee" ) && NPC_BSFlee() ) //this can clear ENEMY {//successfully trying to run away return; } if ( NPC->enemy == NULL) { NPC_UpdateAngles( qfalse, qtrue ); return; } if ( NPCInfo->localState == LSTATE_FLEE ) {//we were fleeing, now done (either timer ran out or we cannot flee anymore if ( NPC_ClearLOS( NPC->enemy ) ) {//if enemy is still around, go berzerk NPCInfo->localState = LSTATE_BERZERK; } else {//otherwise, lick our wounds? NPCInfo->localState = LSTATE_CLEAR; TIMER_Set( NPC, "standing", Q_irand( 3000, 10000 ) ); } } else if ( NPCInfo->localState == LSTATE_BERZERK ) {//go nuts! } else if ( NPCInfo->stats.aggression >= Q_irand( 75, 125 ) ) {//that's it, go nuts! NPCInfo->localState = LSTATE_BERZERK; } else if ( !TIMER_Done( NPC, "retreating" ) ) {//trying to back off NPC_FaceEnemy( qtrue ); if ( NPC->client->ps.speed > NPCInfo->stats.walkSpeed ) { NPC->client->ps.speed = NPCInfo->stats.walkSpeed; } ucmd.buttons |= BUTTON_WALKING; if ( Distance( NPC->enemy->currentOrigin, NPC->currentOrigin ) < HOWLER_RETREAT_DIST ) {//enemy is close vec3_t moveDir; AngleVectors( NPC->currentAngles, moveDir, NULL, NULL ); VectorScale( moveDir, -1, moveDir ); if ( !NAV_DirSafe( NPC, moveDir, 8 ) ) {//enemy is backing me up against a wall or ledge! Start to get really mad! NPCInfo->stats.aggression += 2; } else {//back off ucmd.forwardmove = -127; } //enemy won't leave me alone, get mad... NPCInfo->stats.aggression++; } return; } else if ( TIMER_Done( NPC, "standing" ) ) {//not standing around if ( !(NPCInfo->last_ucmd.forwardmove) && !(NPCInfo->last_ucmd.rightmove) ) {//stood last frame if ( TIMER_Done( NPC, "walking" ) && TIMER_Done( NPC, "running" ) )//.........这里部分代码省略.........
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:101,
示例2: Maxfloat Ray::Distance(const Capsule &capsule) const{ return Max(0.f, Distance(capsule.l) - capsule.r);}
开发者ID:d0n3val,项目名称:Edu-Game-Engine,代码行数:4,
示例3: Index Index(const Matrix<ElementType>& features, const IndexParams& params, Distance distance = Distance() ) : index_params_(params) { flann_algorithm_t index_type = get_param<flann_algorithm_t>(params,"algorithm"); loaded_ = false; if (index_type == FLANN_INDEX_SAVED) { nnIndex_ = load_saved_index<Distance>(features, get_param<cv::String>(params,"filename"), distance); loaded_ = true; } else { nnIndex_ = create_index_by_type<Distance>(features, params, distance); } }
开发者ID:ryuxin,项目名称:cbuf-composite,代码行数:14,
示例4: Distancefloat Ray::Distance(const Ray &ray) const{ return Distance(ray, 0, 0);}
开发者ID:d0n3val,项目名称:Edu-Game-Engine,代码行数:4,
示例5: Rancor_Combat//----------------------------------void Rancor_Combat( void ){ if ( NPC->count ) {//holding my enemy if ( TIMER_Done2( NPC, "takingPain", qtrue )) { NPCInfo->localState = LSTATE_CLEAR; } else { Rancor_Attack( 0, qfalse ); } NPC_UpdateAngles( qtrue, qtrue ); return; } // If we cannot see our target or we have somewhere to go, then do that if ( !NPC_ClearLOS4( NPC->enemy ) )//|| UpdateGoal( )) { NPCInfo->combatMove = qtrue; NPCInfo->goalEntity = NPC->enemy; NPCInfo->goalRadius = MIN_DISTANCE;//MAX_DISTANCE; // just get us within combat range if ( !NPC_MoveToGoal( qtrue ) ) {//couldn't go after him? Look for a new one TIMER_Set( NPC, "lookForNewEnemy", 0 ); NPCInfo->consecutiveBlockedMoves++; } else { NPCInfo->consecutiveBlockedMoves = 0; } return; } // Sometimes I have problems with facing the enemy I'm attacking, so force the issue so I don't look dumb NPC_FaceEnemy( qtrue ); { float distance; qboolean advance; qboolean doCharge; distance = Distance( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin ); advance = (qboolean)( distance > (NPC->r.maxs[0]+MIN_DISTANCE) ? qtrue : qfalse ); doCharge = qfalse; if ( advance ) {//have to get closer vec3_t yawOnlyAngles; VectorSet( yawOnlyAngles, 0, NPC->r.currentAngles[YAW], 0 ); if ( NPC->enemy->health > 0 && fabs(distance-250) <= 80 && InFOV3( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin, yawOnlyAngles, 30, 30 ) ) { if ( !Q_irand( 0, 9 ) ) {//go for the charge doCharge = qtrue; advance = qfalse; } } } if (( advance /*|| NPCInfo->localState == LSTATE_WAITING*/ ) && TIMER_Done( NPC, "attacking" )) // waiting monsters can't attack { if ( TIMER_Done2( NPC, "takingPain", qtrue )) { NPCInfo->localState = LSTATE_CLEAR; } else { Rancor_Move( 1 ); } } else { Rancor_Attack( distance, doCharge ); } }}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:80,
示例6: returnvec3f Plane::Projection( const vec3f& point ) const{ return ( point - normal_ * Distance( point ) );}
开发者ID:alexa-infra,项目名称:negine,代码行数:4,
示例7: returnbool PlaneGeometry::IsOnPlane( const PlaneGeometry *plane ) const { return ( IsParallel( plane ) && (Distance( plane->GetOrigin() ) < eps) );}
开发者ID:robotdm,项目名称:MITK,代码行数:5,
示例8: RewindToMark/** * Resets current offset position of input stream to marked position. * This allows us to back up to this point if the need should arise, * such as when tokenization gets interrupted. * NOTE: IT IS REALLY BAD FORM TO CALL RELEASE WITHOUT CALLING MARK FIRST! * * @update gess 5/12/98 * @param * @return */void nsScanner::RewindToMark(void){ if (mSlidingBuffer) { mCountRemaining += (Distance(mMarkPosition, mCurrentPosition)); mCurrentPosition = mMarkPosition; }}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:16,
示例9: DistanceboolPlaneGeometry::IsOnPlane( const Point3D &point ) const{ return Distance(point) < eps;}
开发者ID:robotdm,项目名称:MITK,代码行数:5,
示例10: Team_TouchEnemyFlagint Team_TouchEnemyFlag( gentity_t *ent, gentity_t *other, int team ) { gclient_t *cl = other->client; vec3_t mins, maxs; int num, j, ourFlag; int touch[MAX_GENTITIES]; gentity_t* enemy; float enemyDist, dist; VectorSubtract( ent->s.pos.trBase, minFlagRange, mins ); VectorAdd( ent->s.pos.trBase, maxFlagRange, maxs ); num = trap->EntitiesInBox( mins, maxs, touch, MAX_GENTITIES ); dist = Distance(ent->s.pos.trBase, other->client->ps.origin); if (other->client->sess.sessionTeam == TEAM_RED){ ourFlag = PW_REDFLAG; } else { ourFlag = PW_BLUEFLAG; } for(j = 0; j < num; ++j){ enemy = (g_entities + touch[j]); if (!enemy || !enemy->inuse || !enemy->client){ continue; } //ignore specs if (enemy->client->sess.sessionTeam == TEAM_SPECTATOR) continue; //check if its alive if (enemy->health < 1) continue; // dead people can't pick up items //lets check if he has our flag if (!enemy->client->ps.powerups[ourFlag]) continue; //check if enemy is closer to our flag than us enemyDist = Distance(ent->s.pos.trBase,enemy->client->ps.origin); if (enemyDist < dist){ // possible recursion is hidden in this, but // infinite recursion wont happen, because we cant // have a < b and b < a at the same time return Team_TouchOurFlag( ent, enemy, team ); } } //PrintMsg (NULL, "%s" S_COLOR_WHITE " got the %s flag!/n", // other->client->pers.netname, TeamName(team)); PrintCTFMessage(other->s.number, team, CTFMESSAGE_PLAYER_GOT_FLAG); if (team == TEAM_RED) cl->ps.powerups[PW_REDFLAG] = INT_MAX; // flags never expire else cl->ps.powerups[PW_BLUEFLAG] = INT_MAX; // flags never expire Team_SetFlagStatus( team, FLAG_TAKEN ); AddScore(other, ent->r.currentOrigin, CTF_FLAG_BONUS); cl->pers.teamState.flagsince = level.time; Team_TakeFlagSound( ent, team ); return -1; // Do not respawn this automatically, but do delete it if it was FL_DROPPED}
开发者ID:Mauii,项目名称:Rend2,代码行数:67,
示例11: Team_TouchOurFlagint Team_TouchOurFlag( gentity_t *ent, gentity_t *other, int team ) { int i, num, j, enemyTeam; gentity_t *player; gclient_t *cl = other->client; int enemy_flag; vec3_t mins, maxs; int touch[MAX_GENTITIES]; gentity_t* enemy; float enemyDist, dist; if (cl->sess.sessionTeam == TEAM_RED) { enemy_flag = PW_BLUEFLAG; } else { enemy_flag = PW_REDFLAG; } if ( ent->flags & FL_DROPPED_ITEM ) { // hey, its not home. return it by teleporting it back //PrintMsg( NULL, "%s" S_COLOR_WHITE " returned the %s flag!/n", // cl->pers.netname, TeamName(team)); PrintCTFMessage(other->s.number, team, CTFMESSAGE_PLAYER_RETURNED_FLAG); AddScore(other, ent->r.currentOrigin, CTF_RECOVERY_BONUS); other->client->pers.teamState.flagrecovery++; other->client->pers.teamState.lastreturnedflag = level.time; //ResetFlag will remove this entity! We must return zero Team_ReturnFlagSound(Team_ResetFlag(team), team); return 0; } // the flag is at home base. if the player has the enemy // flag, he's just won! if (!cl->ps.powerups[enemy_flag]) return 0; // We don't have the flag // fix: captures after timelimit hit could // cause game ending with tied score if (level.intermissionQueued) return 0; // check for enemy closer to grab the flag VectorSubtract( ent->s.pos.trBase, minFlagRange, mins ); VectorAdd( ent->s.pos.trBase, maxFlagRange, maxs ); num = trap->EntitiesInBox( mins, maxs, touch, MAX_GENTITIES ); dist = Distance( ent->s.pos.trBase, other->client->ps.origin ); if (other->client->sess.sessionTeam == TEAM_RED) enemyTeam = TEAM_BLUE; else enemyTeam = TEAM_RED; for (j = 0; j < num; j++) { enemy = (g_entities + touch[j]); if (!enemy || !enemy->inuse || !enemy->client) continue; if (enemy->client->pers.connected != CON_CONNECTED) continue; //check if its alive if (enemy->health < 1) continue; // dead people can't pickup //ignore specs if (enemy->client->sess.sessionTeam == TEAM_SPECTATOR) continue; //check if this is enemy if ((enemy->client->sess.sessionTeam != TEAM_RED && enemy->client->sess.sessionTeam != TEAM_BLUE) || enemy->client->sess.sessionTeam != enemyTeam){ continue; } //check if enemy is closer to our flag than us enemyDist = Distance(ent->s.pos.trBase, enemy->client->ps.origin); if (enemyDist < dist) { // possible recursion is hidden in this, but // infinite recursion wont happen, because we cant // have a < b and b < a at the same time return Team_TouchEnemyFlag( ent, enemy, team ); } } //PrintMsg( NULL, "%s" S_COLOR_WHITE " captured the %s flag!/n", cl->pers.netname, TeamName(OtherTeam(team))); PrintCTFMessage(other->s.number, team, CTFMESSAGE_PLAYER_CAPTURED_FLAG); cl->ps.powerups[enemy_flag] = 0; teamgame.last_flag_capture = level.time; teamgame.last_capture_team = team; // Increase the team's score AddTeamScore(ent->s.pos.trBase, other->client->sess.sessionTeam, 1); other->client->pers.teamState.captures++; other->client->rewardTime = level.time + REWARD_SPRITE_TIME; other->client->ps.persistant[PERS_CAPTURES]++;//.........这里部分代码省略.........
开发者ID:Mauii,项目名称:Rend2,代码行数:101,
示例12: DelaunayClusteringstatic int DelaunayClustering(int MaxClusterSize){ int Count = 0, Count1, Count2 = 0, i, j = 0; Edge *EdgeSet, Key; Node *From, *To, *N, *F, *T; point *u, *v; edge *e_start, *e; delaunay(Dimension); for (i = 0; i < Dimension; i++) { u = &p_array[i]; e_start = e = u->entry_pt; do { v = Other_point(e, u); if (u->id < v->id) Count++; } while ((e = Next(e, u)) != e_start); } assert(EdgeSet = (Edge *) malloc(Count * sizeof(Edge))); for (i = 0; i < Dimension; i++) { u = &p_array[i]; e_start = e = u->entry_pt; do { v = Other_point(e, u); if (u->id < v->id) { EdgeSet[j].From = From = &NodeSet[u->id]; EdgeSet[j].To = To = &NodeSet[v->id]; EdgeSet[j++].Cost = FixedOrCommon(From, To) ? INT_MIN : Distance(From, To) * Precision + From->Pi + To->Pi; } } while ((e = Next(e, u)) != e_start); } free_memory(); if (WeightType == GEO || WeightType == GEOM || WeightType == GEO_MEEUS || WeightType == GEOM_MEEUS) { N = FirstNode; while ((N = N->Suc) != FirstNode) if ((N->Y > 0) != (FirstNode->Y > 0)) break; if (N != FirstNode) { N = FirstNode; do N->Zc = N->Y; while ((N = N->Suc) != FirstNode); /* Transform longitude (180 and -180 map to 0) */ From = FirstNode; do { From->Zc = From->Y; if (WeightType == GEO || WeightType == GEO_MEEUS) From->Y = (int) From->Y + 5.0 * (From->Y - (int) From->Y) / 3.0; From->Y += From->Y > 0 ? -180 : 180; if (WeightType == GEO || WeightType == GEO_MEEUS) From->Y = (int) From->Y + 3.0 * (From->Y - (int) From->Y) / 5.0; } while ((From = From->Suc) != FirstNode); delaunay(Dimension); do From->Y = From->Zc; while ((From = From->Suc) != FirstNode); qsort(EdgeSet, Count, sizeof(Edge), compareFromTo); for (i = 0; i < Dimension; i++) { u = &p_array[i]; e_start = e = u->entry_pt; do { v = Other_point(e, u); if (u->id < v->id) Count2++; } while ((e = Next(e, u)) != e_start); } Count1 = Count; assert(EdgeSet = (Edge *) realloc(EdgeSet, (Count1 + Count2) * sizeof(Edge))); for (i = 0; i < Dimension; i++) { u = &p_array[i]; e_start = e = u->entry_pt; do { v = Other_point(e, u); if (u->id > v->id) continue; Key.From = From = &NodeSet[u->id]; Key.To = To = &NodeSet[v->id]; if (!bsearch (&Key, EdgeSet, Count1, sizeof(Edge), compareFromTo)) { EdgeSet[Count].From = From; EdgeSet[Count].To = To; EdgeSet[Count].Cost = FixedOrCommon(From, To) ? INT_MIN : Distance(From, To) * Precision + From->Pi + To->Pi; Count++; } } while ((e = Next(e, u)) != e_start); } free_memory();//.........这里部分代码省略.........
开发者ID:PQYPLZXHGF,项目名称:elkai,代码行数:101,
示例13: CG_CalculateBeamNodeProperties/*===============CG_CalculateBeamNodePropertiesFills in trailBeamNode_t.textureCoord===============*/static void CG_CalculateBeamNodeProperties( trailBeam_t *tb ){ trailBeamNode_t *i = nullptr; trailSystem_t *ts; baseTrailBeam_t *btb; float nodeDistances[ MAX_TRAIL_BEAM_NODES ]; float totalDistance = 0.0f, position = 0.0f; int j, numNodes = 0; float TCRange, widthRange, alphaRange; vec3_t colorRange; float fadeAlpha = 1.0f; if ( !tb || !tb->nodes ) { return; } ts = tb->parent; btb = tb->class_; if ( ts->destroyTime > 0 && btb->fadeOutTime ) { fadeAlpha -= ( float )( cg.time - ts->destroyTime ) / btb->fadeOutTime; if ( fadeAlpha < 0.0f ) { fadeAlpha = 0.0f; } } TCRange = tb->class_->backTextureCoord - tb->class_->frontTextureCoord;widthRange = tb->class_->backWidth - tb->class_->frontWidth;alphaRange = tb->class_->backAlpha - tb->class_->frontAlpha; VectorSubtract( tb->class_->backColor, tb->class_->frontColor, colorRange ); for ( i = tb->nodes; i && i->next; i = i->next ){ nodeDistances[ numNodes++ ] = Distance( i->position, i->next->position ); } for ( j = 0; j < numNodes; j++ ) { totalDistance += nodeDistances[ j ]; } for ( j = 0, i = tb->nodes; i; i = i->next, j++ ) { if ( tb->class_->textureType == TBTT_STRETCH ) { i->textureCoord = tb->class_->frontTextureCoord + ( ( position / totalDistance ) * TCRange ); } else if ( tb->class_->textureType == TBTT_REPEAT ) { if ( tb->class_->clampToBack ) { i->textureCoord = ( totalDistance - position ) / tb->class_->repeatLength; } else { i->textureCoord = position / tb->class_->repeatLength; } } i->halfWidth = ( tb->class_->frontWidth + ( ( position / totalDistance ) * widthRange ) ) / 2.0f; i->alpha = ( byte )( ( float ) 0xFF * ( tb->class_->frontAlpha + ( ( position / totalDistance ) * alphaRange ) ) * fadeAlpha ); VectorMA( tb->class_->frontColor, ( position / totalDistance ), colorRange, i->color ); position += nodeDistances[ j ]; }}
开发者ID:Unvanquished,项目名称:Unvanquished,代码行数:87,
示例14: getUndoTextBufferIntgetUndoTextBuffer(TextBuffer tb){ long caret = -1; if ( tb->undo_buffer != NULL ) { UndoBuffer ub = tb->undo_buffer; UndoCell cell; if ( (cell = ub->current) == NULL ) /* No further undo's */ fail; while(cell != NULL) { DEBUG(NAME_undo, Cprintf("Undo using cell %d: ", Distance(cell, ub->buffer))); switch( cell->type ) { case UNDO_DELETE: { UndoDelete d = (UndoDelete) cell; string s; s.size = d->len; s.iswide = d->iswide; if ( d->iswide ) s.s_textA = d->text.A; else s.s_textW = d->text.W; DEBUG(NAME_undo, Cprintf("Undo delete at %ld, len=%ld/n", d->where, d->len)); insert_textbuffer(tb, d->where, 1, &s); caret = max(caret, d->where + d->len); break; } case UNDO_INSERT: { UndoInsert i = (UndoInsert) cell; DEBUG(NAME_undo, Cprintf("Undo insert at %ld, len=%ld/n", i->where, i->len)); delete_textbuffer(tb, i->where, i->len); caret = max(caret, i->where); break; } case UNDO_CHANGE: { UndoChange c = (UndoChange) cell; string s; s.size = c->len; s.iswide = c->iswide; if ( c->iswide ) s.s_textA = c->text.A; else s.s_textW = c->text.W; DEBUG(NAME_undo, Cprintf("Undo change at %ld, len=%ld/n", c->where, c->len)); change_textbuffer(tb, c->where, &s); caret = max(caret, c->where + c->len); break; } } cell = cell->previous; if ( cell == NULL || cell->marked == TRUE ) { ub->current = cell; if ( cell == ub->checkpoint ) /* reached non-modified checkpoint */ { DEBUG(NAME_undo, Cprintf("Reset modified to @off/n")); CmodifiedTextBuffer(tb, OFF); } changedTextBuffer(tb); ub->undone = TRUE; answer(toInt(caret)); } } } fail;}
开发者ID:brayc0,项目名称:nlfetdb,代码行数:80,
示例15: AIFunc_DefaultStartconst char *AIFunc_Heinrich_Earthquake( cast_state_t *cs ) { gentity_t *ent = &g_entities[cs->entityNum]; gentity_t *enemy; cast_state_t *ecs; vec3_t enemyVec; float enemyDist, scale; trace_t *tr; cs->aiFlags |= AIFL_SPECIAL_FUNC; if ( cs->enemyNum < 0 ) { if ( !ent->client->ps.torsoTimer ) { return AIFunc_DefaultStart( cs ); } return NULL; } enemy = &g_entities[cs->enemyNum]; ecs = AICast_GetCastState( cs->enemyNum ); VectorMA( enemy->r.currentOrigin, HEINRICH_STOMP_DELAY, enemy->client->ps.velocity, enemyVec ); enemyDist = VectorDistance( ent->r.currentOrigin, enemyVec ); if ( ent->client->ps.torsoTimer < 500 ) { int rnd; aicast_predictmove_t move; vec3_t vec; AICast_PredictMovement( ecs, 2, 0.5, &move, &g_entities[cs->enemyNum].client->pers.cmd, -1 ); VectorSubtract( move.endpos, cs->bs->origin, vec ); vec[2] = 0; enemyDist = VectorLength( vec ); enemyDist -= g_entities[cs->enemyNum].r.maxs[0]; enemyDist -= ent->r.maxs[0]; // if ( enemyDist < 140 ) { // combo attack rnd = rand() % 3; switch ( rnd ) { case 0: return AIFunc_Heinrich_SwordSideSlashStart( cs ); case 1: return AIFunc_Heinrich_SwordKnockbackStart( cs ); case 2: return AIFunc_Heinrich_SwordLungeStart( cs ); } } else { // back to roaming ent->client->ps.legsTimer = 0; ent->client->ps.torsoTimer = 0; cs->castScriptStatus.scriptNoMoveTime = 0; AICast_Heinrich_Taunt( cs ); return AIFunc_DefaultStart( cs ); } } // time for the thump? if ( !( cs->aiFlags & AIFL_MISCFLAG1 ) ) { // face them AICast_AimAtEnemy( cs ); // ready for damage? if ( cs->thinkFuncChangeTime < level.time - HEINRICH_STOMP_DELAY ) { cs->aiFlags |= AIFL_MISCFLAG1; // play the stomp sound G_AddEvent( ent, EV_GENERAL_SOUND, G_SoundIndex( aiDefaults[ent->aiCharacter].soundScripts[ORDERSDENYSOUNDSCRIPT] ) ); // check for striking the player tr = CheckMeleeAttack( ent, 70, qfalse ); // do melee damage if ( tr && ( tr->entityNum == cs->enemyNum ) ) { G_Damage( &g_entities[tr->entityNum], ent, ent, vec3_origin, tr->endpos, HEINRICH_STOMP_DAMAGE, 0, MOD_GAUNTLET ); } // call the debris trigger AICast_ScriptEvent( cs, "trigger", "quake" ); } } enemyDist = Distance( enemy->s.pos.trBase, ent->s.pos.trBase ); // do the earthquake effects if ( cs->thinkFuncChangeTime < level.time - HEINRICH_STOMP_DELAY ) { // throw the player into the air, if they are on the ground if ( ( enemy->s.groundEntityNum != ENTITYNUM_NONE ) && enemyDist < HEINRICH_STOMP_RANGE ) { scale = 0.5 + 0.5 * ( (float)ent->client->ps.torsoTimer / 1000.0 ); if ( scale > 1.0 ) { scale = 1.0; } VectorSubtract( ent->s.pos.trBase, enemy->s.pos.trBase, enemyVec ); VectorScale( enemyVec, 2.0 * ( 0.6 + 0.5 * random() ) * scale * ( 0.6 + 0.6 * ( 1.0 - ( enemyDist / HEINRICH_STOMP_RANGE ) ) ), enemyVec ); enemyVec[2] = scale * HEINRICH_STOMP_VELOCITY_Z * ( 1.0 - 0.5 * ( enemyDist / HEINRICH_STOMP_RANGE ) ); // bounce the player using this velocity VectorAdd( enemy->client->ps.velocity, enemyVec, enemy->client->ps.velocity ); } } return NULL;}
开发者ID:bibendovsky,项目名称:rtcw,代码行数:95,
示例16: CircleCollision bool CircleCollision(const Vector2& v2lhs, const float& radiuslhs, const Vector2& v2rhs, const float& radiusrhs) { if (Distance(v2lhs, v2rhs) <= powf(radiuslhs + radiusrhs, 2)) return true; return false; }
开发者ID:danbudworthmead,项目名称:MathLib,代码行数:6,
示例17: Explodevoid TKlingonBC::Do_ai(){ // Destruction rules if (m_lstHealth[HLT_HULL]<=0) { Explode(); } else { double tsx,tsy; m_blPhaserOn = false; if (m_lstHealth[HLT_SENSOR]<30) { m_pTarget=NULL; } else { if ((m_nTask==TSK_CONTACT)||(m_nTask==TSK_STRIKE)) { m_pTarget=(TShip *) m_pEngine->Seek(ID_PLAYER,m_dViewDistance,m_dX,m_dY); } else { m_pTarget = (TShip *) m_pEngine->Seek(MEM_KLINGON,true,m_dViewDistance,m_dX,m_dY); } if ((m_pTarget!=NULL)&&(m_pTarget->m_blDestroyed)) m_pTarget=NULL; } if (((m_pTarget!=NULL)&&((m_pTarget->m_blDestroyed)||(m_pTarget->m_CloakState == CS_CLOAKED)))||(m_lstHealth[HLT_SENSOR]<30)||(m_lstHealth[HLT_COMPUTER]<30)) m_pTarget=NULL; if ((m_pTarget==NULL)||(m_pTarget->m_blDocked==true)) { if ((m_AI==AI_CHASE)||(m_AI==AI_EVADE)) { m_AI=AI_WANDER; } } else { m_dTargetDistance = Distance(m_dX,m_dY,m_pTarget->GetX(),m_pTarget->GetY()); if (m_AI==AI_WANDER) m_AI=AI_CHASE; if (m_nTask==TSK_STANDARD) { if ((m_lstHealth[HLT_PHOTON]<50)&&(m_lstHealth[HLT_PHASER]<=20)) m_AI=AI_EVADE; } }if ((m_lstHealth[HLT_PHOTON]<40)||(m_nTorpedoes==0)) { if (! TryEnterDocking()) { m_AI=AI_EVADE; } } else if (m_pTarget==NULL) { bool blShouldDock = false; for (size_t i=0;i<m_lstHealth.size();i++) { if (m_lstHealth[i] < (m_nMaxHealth-50)) blShouldDock = true; if (m_nTorpedoes<50) blShouldDock = true; } if (blShouldDock) { if(! TryEnterDocking()) { m_dWaypointX=rand() % SECTORSIZE; m_dWaypointY=rand() % SECTORSIZE; m_AI=AI_WANDER; } } }switch(m_AI) { case AI_WANDER: { SetSpeed(100); m_dAngleSeek=WayPoint(m_dWaypointX,m_dWaypointY); double dDistance = Distance(m_dX,m_dY,m_dWaypointX,m_dWaypointY); if (dDistance<40) { m_dWaypointX=rand() % SECTORSIZE; m_dWaypointY=rand() % SECTORSIZE; } if ((m_nCloakCharge>=CLOAK_DELAY)&&((m_lstHealth[HLT_CLOAK]>60)||(m_nEnergy>500))&&((m_CloakState == CS_UNCLOAKED)||(m_CloakState == CS_DECLOAKING))) { m_CloakState = CS_CLOAKING; } } break; case AI_CHASE://.........这里部分代码省略.........
开发者ID:EdwinMartens,项目名称:star_trek,代码行数:101,
示例18: CG_AddParticleToScene/*=====================CG_AddParticleToScene=====================*/void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha){ vec3_t point; polyVert_t verts[4]; float width; float height; float time, time2; float ratio; float invratio; vec3_t color; polyVert_t TRIverts[3]; vec3_t rright2, rup2; if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY || p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) {// create a front facing polygon if (p->type != P_WEATHER_FLURRY) { if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) { if (org[2] > p->end) { p->time = cg.time; VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground p->org[2] = ( p->start + crandom () * 4 ); if (p->type == P_BUBBLE_TURBULENT) { p->vel[0] = crandom() * 4; p->vel[1] = crandom() * 4; } } } else { if (org[2] < p->end) { p->time = cg.time; VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground while (p->org[2] < p->end) { p->org[2] += (p->start - p->end); } if (p->type == P_WEATHER_TURBULENT) { p->vel[0] = crandom() * 16; p->vel[1] = crandom() * 16; } } } // Rafael snow pvs check if (!p->link) return; p->alpha = 1; } // Ridah, had to do this or MAX_POLYS is being exceeded in village1.bsp if (Distance( cg.snap->ps.origin, org ) > 1024) { return; } // done. if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) { VectorMA (org, -p->height, pvup, point); VectorMA (point, -p->width, pvright, point); VectorCopy (point, verts[0].xyz); verts[0].st[0] = 0; verts[0].st[1] = 0; verts[0].modulate[0] = 255; verts[0].modulate[1] = 255; verts[0].modulate[2] = 255; verts[0].modulate[3] = 255 * p->alpha; VectorMA (org, -p->height, pvup, point); VectorMA (point, p->width, pvright, point); VectorCopy (point, verts[1].xyz); verts[1].st[0] = 0; verts[1].st[1] = 1; verts[1].modulate[0] = 255; verts[1].modulate[1] = 255; verts[1].modulate[2] = 255; verts[1].modulate[3] = 255 * p->alpha; //.........这里部分代码省略.........
开发者ID:mecwerks,项目名称:quake3-ios,代码行数:101,
示例19: InitializeAttackBoards//.........这里部分代码省略......... rook_attacks[i]=0; for(j=0;j<4;j++) { sq=i; lastsq=sq; sq=sq+rooksq[j]; while((((abs(sq/8-lastsq/8)==1) && (abs((sq&7)-(lastsq&7))==0)) || ((abs(sq/8-lastsq/8)==0) && (abs((sq&7)-(lastsq&7))==1))) && (sq < 64) && (sq > -1)) { rook_attacks[i]=Or(rook_attacks[i],Shiftr(mask_1,sq)); queen_attacks[i]=Or(queen_attacks[i],Shiftr(mask_1,sq)); if(rooksq[j]==1) plus1dir[i]=Or(plus1dir[i],Shiftr(mask_1,sq)); else if(rooksq[j]==8) plus8dir[i]=Or(plus8dir[i],Shiftr(mask_1,sq)); else if(rooksq[j]==-1) minus1dir[i]=Or(minus1dir[i],Shiftr(mask_1,sq)); else minus8dir[i]=Or(minus8dir[i],Shiftr(mask_1,sq)); lastsq=sq; sq=sq+rooksq[j]; } } }/* initialize king attack board */ for(i=0;i<64;i++) { king_attacks[i]=0; king_attacks_1[i]=0; king_attacks_2[i]=0; for (j=0;j<64;j++) { if (Distance(i,j) == 1) king_attacks[i]=Or(king_attacks[i],set_mask[j]); if (Distance(i,j) <= 1) king_attacks_1[i]=Or(king_attacks_1[i],set_mask[j]); if (Distance(i,j) <= 2) king_attacks_2[i]=Or(king_attacks_2[i],set_mask[j]); } }/* direction[sq1][sq2] gives the "move direction" to move from sq1 to sq2. obstructed[sq1][sq2] gives a bit vector that indicates which squares must be unoccupied in order for <sq1> to attack <sq2>, assuming a sliding piece is involved. to use this, you simply have to Or(obstructed[sq1][sq2],occupied_squares) and if the result is "0" then a sliding piece on sq1 would attack sq2 and vice-versa.*/ for (i=0;i<64;i++) { for (j=0;j<64;j++) obstructed[i][j]=(BITBOARD) -1; sqs=plus1dir[i]; while (sqs) { j=FirstOne(sqs); directions[i][j]=1; obstructed[i][j]=Xor(plus1dir[i],plus1dir[j-1]); Clear(j,sqs); } sqs=plus7dir[i]; while (sqs) { j=FirstOne(sqs); directions[i][j]=7; obstructed[i][j]=Xor(plus7dir[i],plus7dir[j-7]); Clear(j,sqs); }
开发者ID:shivgarg,项目名称:SPEC_CPU_BENCH-2000-Android-APP,代码行数:67,
示例20: _declspecextern "C" _declspec(dllexport) void __cdecl BrakeWindMouse( float xs, float ys, float xe, float ye, float gravity, float wind, float minWait, float maxWait, float targetArea ){ float veloX = 0.0, veloY = 0.0, windX = 0.0, windY = 0.0, veloMag = 0.0, dist = 0.0, randomDist = 0.0; int lastX = 0, lastY = 0, MSP = 0, W = 0, maxStep = 0, D = 0, TDist = 0; float sqrt2 = 0.0, sqrt3 = 0.0, sqrt5 = 0.0, PDist = 0.0; veloX = 0; veloY = 0; windX = 0; windY = 0; MSP = MouseSpeed; sqrt2 = sqrt( 2 ); sqrt3 = sqrt( 3 ); sqrt5 = sqrt( 5 ); srand(time(NULL)); TDist = Distance( rnd( xs ), rnd( ys ), rnd( xe ), rnd( ye ) ); if ( TDist < 1 ) TDist = 1; do { dist = hypot( xs - xe, ys - ye ); wind = Min( wind, dist ); if ( dist < 1 ) dist = 1; PDist = ( dist / TDist ); if ( PDist < 0.01 ) PDist = 0.01; /* These constants seem smooth to me, but feel free to modify these settings however you wish. */ if ( PDist >= 0.15 ) //15% (or higher) dist to destination { D = rnd( rnd( ( rnd( dist ) * 0.3 ) ) / 5 ); if ( D < 20 ) D = 20; //D := RandomRange(15, 25); {Original} } else if ( PDist < 0.15 ) { if ( ( PDist <= 0.15 ) && ( PDist >= 0.10 ) ) //10%-15% D = RandomRange( 8, 13 ); else if ( PDist < 0.10 ) //< 10% D = RandomRange( 4, 7 ); } if ( D <= rnd( dist ) ) maxStep = D; else maxStep = rnd( dist ); if ( dist >= targetArea ) { windX = windX / sqrt3 + ( rand()% rnd( wind ) * 2 + 1 - wind ) / sqrt5; windY = windY / sqrt3 + ( rand()% rnd( wind ) * 2 + 1 - wind ) / sqrt5; } else { windX = windX / sqrt2; windY = windY / sqrt2; } veloX = veloX + windX; veloY = veloY + windY; veloX = veloX + gravity * ( xe - xs ) / dist; veloY = veloY + gravity * ( ye - ys ) / dist; if ( hypot( veloX, veloY ) > maxStep ) { randomDist = maxStep / 2.0 + rand()% rnd( maxStep ) / 2 ; veloMag = sqrt( veloX * veloX + veloY * veloY ); veloX = ( veloX / veloMag ) * randomDist; veloY = ( veloY / veloMag ) * randomDist; } lastX = rnd( xs ); lastY = rnd( ys ); xs = xs + veloX; ys = ys + veloY; if ( ( lastX != rnd( xs ) ) || ( lastY != rnd( ys ) ) ) MoveMouse( rnd( xs ), rnd( ys ) ); W = ( rand()% rnd( 100 / MSP ) ) * 6; if ( W < 5 ) W = 5; W = rnd( W * 1.2 ); Sleep( W );// lastDist = dist; } while ( ! ( hypot( xs - xe, ys - ye ) < 1 ) ); if ( ( rnd( xe ) != rnd( xs ) ) || ( rnd( ye ) != rnd( ys ) ) ) MoveMouse( rnd( xe ), rnd( ye ) ); MouseSpeed = MSP;}
开发者ID:CynicRus,项目名称:HumanMouse,代码行数:91,
示例21: DistancecxFloat cxPoint2F::Distance(const cxPoint2F &d) const{ return Distance(*this, d);}
开发者ID:cxuhua,项目名称:cxengine,代码行数:4,
示例22: Normalizedouble cPEDetection<_DataType>::ComputeAveRadius(double *CurrPt, double *NextPt, _DataType MatMin, _DataType MatMax){ int i, k, loc[3], DataCoor_i[3], NumBoundaryVoxels_i; double StartPt_d[3], VesselDirection_d[3], VesselDirOrg_d[3], Rays_d[8*3], CurrLoc_d[3]; double GradVec_d[3], ZeroCrossingLoc_Ret[3], FirstDAtTheLoc_Ret, DataPosFromZeroCrossingLoc_Ret; double Radius_d[16], CurrCenterPt_d[3], NextCenterPt_d[3], AveRadius_d, Step_d, Increase_d; Increase_d = 0.5; for (k=0; k<3; k++) VesselDirOrg_d[k] = NextPt[k] - CurrPt[k]; Normalize(VesselDirOrg_d); for (k=0; k<3; k++) VesselDirection_d[k] = VesselDirOrg_d[k]; for (k=0; k<3; k++) StartPt_d[k] = CurrPt[k]; ComputePerpendicular8Rays(StartPt_d, VesselDirection_d, Rays_d); for (k=0; k<3; k++) CurrCenterPt_d[k] = 0.0; NumBoundaryVoxels_i = 0; for (i=0; i<8; i++) { for (Step_d=-0.2; Step_d<=0.2+1e-6; Step_d+=0.4) { loc[0] = getANearestBoundary(StartPt_d, &Rays_d[i*3], Step_d, MatMin, MatMax); if (loc[0]>0) NumBoundaryVoxels_i++; else continue; DataCoor_i[2] = (int)(loc[0]/this->WtimesH_mi); DataCoor_i[1] = (int)((loc[0] - DataCoor_i[2]*this->WtimesH_mi)/this->Width_mi); DataCoor_i[0] = (int)(loc[0] % this->Width_mi); for (k=0; k<3; k++) CurrLoc_d[k] = (double)DataCoor_i[k]; for (k=0; k<3; k++) GradVec_d[k] = (double)this->GradientVec_mf[loc[0]*3 + k]; this->FindZeroCrossingLocation(CurrLoc_d, GradVec_d, ZeroCrossingLoc_Ret, FirstDAtTheLoc_Ret, DataPosFromZeroCrossingLoc_Ret, 0.2); for (k=0; k<3; k++) CurrCenterPt_d[k] += ZeroCrossingLoc_Ret[k]; } } for (k=0; k<3; k++) CurrCenterPt_d[k] /= (double)NumBoundaryVoxels_i; for (k=0; k<3; k++) StartPt_d[k] = CurrPt[k] + VesselDirection_d[k]*Increase_d; ComputePerpendicular8Rays(StartPt_d, VesselDirection_d, Rays_d); for (k=0; k<3; k++) NextCenterPt_d[k] = 0.0; NumBoundaryVoxels_i = 0; for (i=0; i<8; i++) { for (Step_d=-0.2; Step_d<=0.2+1e-6; Step_d+=0.4) { loc[0] = getANearestBoundary(StartPt_d, &Rays_d[i*3], Step_d, MatMin, MatMax); if (loc[0]>0) NumBoundaryVoxels_i++; else continue; DataCoor_i[2] = (int)(loc[0]/this->WtimesH_mi); DataCoor_i[1] = (int)((loc[0] - DataCoor_i[2]*this->WtimesH_mi)/this->Width_mi); DataCoor_i[0] = (int)(loc[0] % this->Width_mi); for (k=0; k<3; k++) CurrLoc_d[k] = (double)DataCoor_i[k]; for (k=0; k<3; k++) GradVec_d[k] = (double)this->GradientVec_mf[loc[0]*3 + k]; this->FindZeroCrossingLocation(CurrLoc_d, GradVec_d, ZeroCrossingLoc_Ret, FirstDAtTheLoc_Ret, DataPosFromZeroCrossingLoc_Ret, 0.2); for (k=0; k<3; k++) NextCenterPt_d[k] += ZeroCrossingLoc_Ret[k]; } } for (k=0; k<3; k++) NextCenterPt_d[k] /= (double)NumBoundaryVoxels_i; for (k=0; k<3; k++) VesselDirection_d[k] = VesselDirOrg_d[k];#ifdef DEBUG_PED printf ("/n");#endif double Tempd; int NumRepeat = 0; Step_d = 0.0; AveRadius_d = 0.0; while (NumRepeat<(int)((1.0/Increase_d)*2.0+1e-6)) { NumRepeat++; ComputePerpendicular8Rays(CurrCenterPt_d, VesselDirection_d, Rays_d); for (i=0; i<16; i++) Radius_d[i] = -1.0; NumBoundaryVoxels_i = 0; for (i=0; i<8; i++) { for (Step_d=-0.2; Step_d<=0.2+1e-5; Step_d+=0.4) { loc[0] = getANearestBoundary(StartPt_d, &Rays_d[i*3], Step_d, MatMin, MatMax); if (loc[0]>0) NumBoundaryVoxels_i++; else continue; DataCoor_i[2] = (int)(loc[0]/this->WtimesH_mi); DataCoor_i[1] = (int)((loc[0] - DataCoor_i[2]*this->WtimesH_mi)/this->Width_mi); DataCoor_i[0] = (int)(loc[0] % this->Width_mi); for (k=0; k<3; k++) CurrLoc_d[k] = (double)DataCoor_i[k]; for (k=0; k<3; k++) GradVec_d[k] = (double)this->GradientVec_mf[loc[0]*3 + k]; this->FindZeroCrossingLocation(CurrLoc_d, GradVec_d, ZeroCrossingLoc_Ret, FirstDAtTheLoc_Ret, DataPosFromZeroCrossingLoc_Ret, 0.2); Radius_d[NumBoundaryVoxels_i-1] = Distance (CurrCenterPt_d, ZeroCrossingLoc_Ret); } } Tempd = 0.0; NumBoundaryVoxels_i=0; for (i=0; i<16; i++) { if (Radius_d[i]>0.0) { Tempd += Radius_d[i]; NumBoundaryVoxels_i++; }//.........这里部分代码省略.........
开发者ID:SoumyajitG,项目名称:VolRoverN,代码行数:101,
示例23: CG_AddParticleToScene/** * @brief CG_AddParticleToScene * @param[in,out] p * @param[in] org * @param alpha - unused */void CG_AddParticleToScene(cparticle_t *p, vec3_t org, float alpha){ polyVert_t verts[4]; polyVert_t TRIverts[3]; switch (p->type) { case P_WEATHER: case P_WEATHER_TURBULENT: case P_WEATHER_FLURRY: case P_BUBBLE: case P_BUBBLE_TURBULENT: // create a front facing polygon { if (p->type != P_WEATHER_FLURRY) { if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) { if (org[2] > p->end) { p->time = cg.time; VectorCopy(org, p->org); // fixes rare snow flakes that flicker on the ground p->org[2] = (p->start + crandom() * 4); if (p->type == P_BUBBLE_TURBULENT) { p->vel[0] = crandom() * 4; p->vel[1] = crandom() * 4; } } } else { if (org[2] < p->end) { p->time = cg.time; VectorCopy(org, p->org); // fixes rare snow flakes that flicker on the ground while (p->org[2] < p->end) { p->org[2] += (p->start - p->end); } if (p->type == P_WEATHER_TURBULENT) { p->vel[0] = crandom() * 16; p->vel[1] = crandom() * 16; } } } // snow pvs check if (!p->link) { return; } p->alpha = 1; } // had to do this or MAX_POLYS is being exceeded in village1.bsp if (VectorDistanceSquared(cg.snap->ps.origin, org) > Square(1024)) { return; } if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) { vec3_t point; VectorMA(org, -p->height, vup, point); VectorMA(point, -p->width, vright, point); VectorCopy(point, verts[0].xyz); verts[0].st[0] = 0; verts[0].st[1] = 0; verts[0].modulate[0] = 255; verts[0].modulate[1] = 255; verts[0].modulate[2] = 255; verts[0].modulate[3] = (byte)(255 * p->alpha); VectorMA(org, -p->height, vup, point); VectorMA(point, p->width, vright, point); VectorCopy(point, verts[1].xyz); verts[1].st[0] = 0; verts[1].st[1] = 1; verts[1].modulate[0] = 255; verts[1].modulate[1] = 255; verts[1].modulate[2] = 255; verts[1].modulate[3] = (byte)(255 * p->alpha); VectorMA(org, p->height, vup, point); VectorMA(point, p->width, vright, point); VectorCopy(point, verts[2].xyz); verts[2].st[0] = 1;//.........这里部分代码省略.........
开发者ID:etlegacy,项目名称:etlegacy,代码行数:101,
示例24: 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 qfalse; }#ifdef __DOMINANCE_NPC__ if (NPC->enemy && NPC->s.weapon == WP_SABER && (!NPC_EnemyVisible( NPC, NPC->enemy ) || (Distance(NPC->r.currentOrigin, NPC->enemy->r.currentOrigin) > 96 || NPC->genericValue15 < level.time))) { // Enemy is visible, but out of range for lghtsaber... Move closer... NPC->client->ps.speed = NPCInfo->stats.runSpeed; if (!NPC_FollowRoutes()) { //trap->Print("NPC_FollowRoutes failed!/n"); return qfalse; } return qtrue; } else if (NPC->enemy && NPC_EnemyVisible( NPC, NPC->enemy )) { // Enemy is visible and in range, no need to move at the moment... return qfalse; } else if (NPC->enemy) {// Have an enemy that is not currently visible... if (NPC->s.weapon == WP_SABER && (Distance(NPC->r.currentOrigin, NPC->enemy->r.currentOrigin) > 96 || NPC->genericValue15 < level.time)) { if (NPC->genericValue14 < level.time) { // Give up... NPC->enemy = NULL; NPCInfo->goalEntity = NULL; NPC->longTermGoal = -1; } } else if (NPC->enemy && NPC->genericValue15 < level.time) { if (NPC->genericValue14 < level.time) { // Give up... NPC->enemy = NULL; NPCInfo->goalEntity = NULL; NPC->longTermGoal = -1; } } NPC->client->ps.speed = NPCInfo->stats.runSpeed; if (!NPC_FollowRoutes()) { //trap->Print("NPC_FollowRoutes failed!/n"); return qfalse; } return qtrue; } else {// Dominance: Use bot waypointing AI if it is available! - Unique1 NPC->enemy = NULL; NPCInfo->goalEntity = NULL; NPC->client->ps.speed = NPCInfo->stats.walkSpeed; if (!NPC_FollowRoutes()) { //trap->Print("NPC_FollowRoutes failed!/n"); return qfalse; } return qtrue; }#endif //__DOMINANCE_NPC__ /* 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 )//.........这里部分代码省略.........
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:101,
注:本文中的Distance函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ DistanceBearing函数代码示例 C++ Dist函数代码示例 |