int Sentry_FindTarget_Angel( ) { gedict_t *client; gedict_t *enemy = PROG_TO_EDICT( self->s.v.enemy ); if ( enemy != world ) { if ( CheckTarget( enemy ) ) { if ( g_globalvars.time > self->height ) { Sentry_FoundTarget( ); return 1; } else return 0; } } for ( client = world; (client = trap_find( client, FOFS( s.v.classname ), "player" )); ) { if ( CheckTarget( client ) ) { self->s.v.enemy = EDICT_TO_PROG( client ); self->height = g_globalvars.time + 0.1 * ( int ) ( g_random( ) * tfset_sgppl ); // self.height = g_globalvars.time + 0.1 * Q_rint(sgppl); if ( self->height == g_globalvars.time ) { Sentry_FoundTarget( ); return 1; } return 0; } } self->s.v.enemy = EDICT_TO_PROG( world ); return 0; }
bool Update(Matrix *matrix, Player player, privateGameData* PGD, char move) { ErrorCode e; Point p = GetInputLoc(matrix, player, move); if (!CheckTarget(matrix, player, p)) { PGD->myGame->Winner =-player; return FALSE; } e = CheckFoodAndMove(matrix, player, p); if (e == ERR_BOARD_FULL) { PGD->myGame->Winner = TIE; return FALSE; } if (e == ERR_SNAKE_IS_TOO_HUNGRY) { PGD->myGame->Winner =-player; return FALSE; } // only option is that e == ERR_OK if (IsMatrixFull(matrix)) { PGD->myGame->Winner = TIE; return FALSE; } return TRUE; }
int Sentry_FindTarget( ) { gedict_t *client; float r; float gotone; float loopc; r = 0; loopc = 0; gotone = 0; while ( loopc < 6 && !gotone ) { client = checkclient( ); gotone = CheckTarget( client ); loopc = loopc + 1; } if ( !gotone ) return 0; self->s.v.enemy = EDICT_TO_PROG( client ); if ( strneq( PROG_TO_EDICT( self->s.v.enemy )->s.v.classname, "player" ) ) { self->s.v.enemy = PROG_TO_EDICT( self->s.v.enemy )->s.v.enemy; if ( strneq( PROG_TO_EDICT( self->s.v.enemy )->s.v.classname, "player" ) ) { self->s.v.enemy = EDICT_TO_PROG( world ); return 0; } } Sentry_FoundTarget( ); return 1; }
void MultiShot::Update( void ) { Attackable *temp; /* If we have Targets, check their status. */ if( pTarget != NULL || pTarget2 != NULL || pTarget3 != NULL ) CheckTarget(); /* Search for Targets. */ if( pTarget == NULL || pTarget2 == NULL || pTarget3 == NULL ) FindTarget(); /* If we found a new Target, and they are in range.. */ if( pTarget != NULL ) Attack(); /*Using a temp target to hold the pTarget. This way we don't have to override Attack().*/ if( pTarget2 != NULL ) { temp = pTarget; pTarget = pTarget2; Attack(); pTarget = temp; } if( pTarget3 != NULL ) { temp = pTarget; pTarget = pTarget3; Attack(); pTarget = temp; } }
void CSniperBlock::Attacking() { if (_hp == 0) return; if (!CheckTarget()) return; //Mục tiêu chưa vào tầm tấn công DWORD now = GetTickCount(); //Giãn cách bắn if (now - _last_time_shoot >= ENEMY_SNIPER_STAND_ELAPSED_SHOOT) { //Kiểm tra số đạn đã bắn, nếu vẫn còn bắn được thì bắn if (_queue_id_bullet.size() < _max_bullet) { //Chỉnh tọa độ bắn int x = _physical.x - 16; int y = _physical.y + 10; int id = _weapon->ShootingBulletME(D3DXVECTOR3(x, y, 0), 180, 0); if (id >= 0) { _queue_id_bullet.push(id); } _last_time_shoot = now; SetStatus(EAttack); } } }
bool AATPoint::UpdateSampleFar(const AircraftState& state, const FlatProjection &projection) { /* the orderedtaskpoint::update_sample_far does nothing for now but we are calling this in case that changes */ return OrderedTaskPoint::UpdateSampleFar(state, projection) || CheckTarget(state, true); }
bool AATPoint::UpdateSampleNear(const AircraftState& state, const FlatProjection &projection) { bool retval = OrderedTaskPoint::UpdateSampleNear(state, projection); retval |= CheckTarget(state, false); return retval; }
bool AATPoint::UpdateSampleFar(const AircraftState& state, TaskEvents *task_events, const TaskProjection &projection) { // the orderedtaskpoint::update_sample_far does nothing for now // but we are calling this in case that changes. return OrderedTaskPoint::UpdateSampleFar(state, task_events, projection) || CheckTarget(state, true); }
bool AATPoint::UpdateSampleNear(const AircraftState& state, TaskEvents *task_events, const TaskProjection &projection) { bool retval = OrderedTaskPoint::UpdateSampleNear(state, task_events, projection); retval |= CheckTarget(state, false); return retval; }
void BattleRideFighter::PreGetObject1() { UInt8 res = CheckTarget(); if(res) { UInt8 direction = GetBattleDirection(); if(res == 1) direction = 2; BattleFighter * target = static_cast<BattleFighter* >(GetField()->GetTargetForRide(!GetSideInBS(),getPosX(),getPosY(),direction)); if(target) _target = target; } }
UInt16 BattleRideFighter::GetTargetDistance() { if(!_target || !GetField()) return -2; #if 0 _target->SetNowTime(_nowTime); if(!_target->GetGone()) _target->GoForward(); #endif if(CheckTarget()) return -2; return GetField()->getDistance(this,_target); }
void AimLegit::GetBestTarget() { float maxDistance = 8192.f; float nearest; int index = -1; float fov = g_Options.legit_fov; int firedShots = g_LocalPlayer->m_iShotsFired(); for (int i = 1; i < g_GlobalVars->maxClients; i++) { auto player = C_BasePlayer::GetPlayerByIndex(i); if (!CheckTarget(player)) continue; QAngle viewangles = usercmd->viewangles; Vector targetpos; if (firedShots > g_Options.legit_aftershots) targetpos = player->GetBonePos(realAimSpot[g_Options.legit_afteraim]); else if (firedShots < g_Options.legit_aftershots) targetpos = player->GetBonePos(realAimSpot[g_Options.legit_preaim]); nearest = Math::GetFov(viewangles, Math::CalcAngle(g_LocalPlayer->GetEyePos(), targetpos)); if (nearest > fov) continue; float distance = Math::GetDistance(g_LocalPlayer->m_vecOrigin(), player->m_vecOrigin()); if (fabsf(fov - nearest) < 5) { if (distance < maxDistance) { fov = nearest; maxDistance = distance; index = i; } } else if (nearest < fov) { fov = nearest; maxDistance = distance; index = i; } } SetTarget(index); }
bool Update(Matrix *matrix, PlayerS* player, char move) { //the matrix we got is the board of the current game ErrorCode e; Point p = GetInputLoc(matrix, player->color, atoi(move)); Game* currentGame = player->myGame; //TODO: check why doesn't recognize PlayerS fields if (!CheckTarget(matrix, player->color, p)) { // if the move is illegal, out of bounds, or trying to eat a snake down(&(currentGame->isFinishedLock)); currentGame->isFinished = TRUE; up(&(currentGame->isFinishedLock)); //set winner down(&(currentGame->winnerLock)); if (player->color == WHITE) { currentGame->winner = BLACK_IS_WINNER; } else { currentGame->winner = WHITE_IS_WINNER; } up(&(currentGame->winnerLock)); return FALSE; } e = CheckFoodAndMove(matrix, player->color, p); //Rebeca's change if (e == ERR_SNAKE_IS_TOO_HUNGRY) { down(&(currentGame->isFinishedLock)); currentGame->isFinished = TRUE; up(&(currentGame->isFinishedLock)); down(&(currentGame->winnerLock)); if (player->color == WHITE) { currentGame->winner = BLACK_IS_WINNER; } else { currentGame->winner = WHITE_IS_WINNER; } up(&(currentGame->winnerLock)); return FALSE; } //probabely checks if board is full after the snake has moved if (e == ERR_BOARD_FULL || IsMatrixFull(matrix)) { down(&(currentGame->isFinishedLock)); currentGame->isFinished = TRUE; up(&(currentGame->isFinishedLock)); down(&(currentGame->winnerLock)); currentGame->winner = A_TIE; up(&(currentGame->winnerLock)); return FALSE; } return TRUE; }
bool aimbot::Think(UserCmd *ucmd) { Entity *lp = LocalPlayer(); Entity *t = nullptr; float best = 3.40282347e+38f; weaponinfo = lp->GetActiveWeapon()->GetWeaponInfo(); Vector aim, tp, sp = lp->GetShootPos(); AngleVectors(ucmd->viewangles, aim); BulletFilter bf(lp); for (int i = 1, ignore = engine->GetLocalPlayer(), players = globals->maxclients(); #ifdef NPCS i <= ents->GetMaxEntities(); #else i <= globals->maxclients(); #endif i++) { if (i == ignore) continue; if (Entity *pl = ents->GetEntity(i)) { if (pl->IsDormant()) continue; if (i > players) continue; if (!CheckTarget(lp, pl)) continue; if (!pl->GetModel()) continue; if (!pl->SetupBones()) continue; float rate = RateOf(ucmd, lp, pl, i); if (rate >= best) continue; bf.against(pl); bool next = false; int index = 0; for (int j = pl->Hitboxes() - 1; j >= 0; j--) { hitbox *box = pl->GetHitbox(j); if (box->group == HITGROUP_HEAD) { Vector pos = pl->GetBoxPos(box); if (BulletTrace(sp, pos, &bf)) { t = pl; tp = pos; best = rate; shot = i; next = true; } index = j; break; } } if (!next && 1) // menu.aimbot.hitscan { for (int j = 0; j < pl->Hitboxes(); j++) { if (j == index) continue; hitbox *box = pl->GetHitbox(j); if (box->group && box->group != HITGROUP_HEAD) { Vector pos = pl->GetBoxPos(box); if (BulletTrace(sp, pos, &bf)) { t = pl; tp = pos; best = rate; shot = i; break; } } } } } } if (t != nullptr) { VectorAngles(tp - sp, ucmd->viewangles); //if (1) // menu.aimbot.autoshot // ucmd->buttons.add(IN_ATTACK); return true; } return false; }
void TacticalAI::SelectTarget() { if (!ship) { roe = NONE; return; } // unarmed vessels should never engage an enemy: if (ship->Weapons().size() < 1) roe = NONE; SimObject* target = ship_ai->GetTarget(); SimObject* ward = ship_ai->GetWard(); // if not allowed to engage, drop and return: if (roe == NONE) { if (target) ship_ai->DropTarget(); return; } // if we have abandoned our ward, drop and return: if (ward && roe != AGRESSIVE) { double d = (ward->Location() - ship->Location()).length(); double safe_zone = 50e3; if (target) { if (ship->IsStarship()) safe_zone = 100e3; if (d > safe_zone) { ship_ai->DropTarget(); return; } } else { if (d > safe_zone) { return; } } } // already have a target, keep it: if (target) { if (target->Life()) { CheckTarget(); // frigates need to be ready to abandon ship-type targets // in favor of drone-type targets, others should just go // with what they have: if (ship->Class() != Ship::CORVETTE && ship->Class() != Ship::FRIGATE) return; // in case the check decided to drop the target: target = ship_ai->GetTarget(); } // if the old target is dead, forget it: else { ship_ai->DropTarget(); target = 0; } } // if not allowed to acquire, forget it: if (ship_ai->DropTime() > 0) return; if (roe == DIRECTED) { if (target && target->Type() == SimObject::SIM_SHIP) SelectTargetDirected((Ship*) target); else if (navpt && navpt->GetTarget() && navpt->GetTarget()->Type() == SimObject::SIM_SHIP) SelectTargetDirected((Ship*) navpt->GetTarget()); else SelectTargetDirected(); } else { SelectTargetOpportunity(); // don't switch one ship target for another... if (ship->Class() == Ship::CORVETTE || ship->Class() == Ship::FRIGATE) { SimObject* potential_target = ship_ai->GetTarget(); if (target && potential_target && target != potential_target) { if (target->Type() == SimObject::SIM_SHIP && potential_target->Type() == SimObject::SIM_SHIP) { ship_ai->SetTarget(target); } } } } }
bool PerigeeMove::DoIt() { file_list::size_type num = 0, cnt = m_files.size(); m_progress.m_Progress.SetRange32(0, cnt); m_progress.m_Progress.SetPos(0); m_progress.m_Progress.SetStep(1); for(file_list::iterator it = m_files.begin(); it != m_files.end(); ++it) { CString dest_name = PsAppendPath(it->dest, PathFindFileName(it->source)); m_progress.SetSourceDest(it->source, dest_name); // first make sure the destination isn't the source; otherwise, there's nothing to do if (0 != it->source.CompareNoCase(dest_name)) { // check whether the destination is a subfolder of the source, and skip if ( PathIsDirectory(it->source) && DestIsSubfolderOfSource(dest_name, it->source) ) { file_info fi; fi.source = it->source; fi.dest = dest_name; fi.error_code = ERROR_INVALID_PARAMETER; fi.error_type = warn_move_dest_is_subfolder_of_source; m_error_files.push_back(fi); continue; } TargetState state = CheckTarget(dest_name, it->source); if ( targetCanBeOverwritten == state ) { if ( m_options.overwrite_read_only ) PrepareOverwrite(dest_name); if ( m_options.recycle ) PsRecycle(dest_name); else DeleteFile(dest_name); } else if ( targetCannotBeOverwritten == state ) { if (m_options.overwrite == CPerigeeCopyOptions::overwrite_postpone) { // put the file in the error list for now file_info fi; fi.source = it->source; fi.dest = it->dest; fi.error_code = ERROR_FILE_EXISTS; fi.error_type = err_move; m_error_files.push_back(fi); continue; } else { // exclude the file from the job --cnt; m_progress.m_Progress.SetRange32(0, cnt); ProcessMessages(); m_cancel = m_cancel || m_progress.m_CancelRequest; if ( m_cancel ) break; continue; } } while ( !MoveFile(it->source, dest_name) ) { file_info fi; fi.source = it->source; fi.dest = it->dest; fi.error_code = GetLastError(); fi.error_type = err_move; if ( !HandleError(fi) ) break; } } m_progress.m_Progress.StepIt(); UpdateTitleBar(m_progress, IDS_MOVING_FILES, num++, cnt); ProcessMessages(); m_cancel = m_cancel || m_progress.m_CancelRequest; if ( m_cancel ) break; } return m_error_files.empty(); }