void AMurphysLawCharacter::Fire() { // check if we have a weapon equipped if (HasWeaponEquipped()) { // if the weapon has been able to fire if (GetEquippedWeapon()->Fire(this)) { // Stop the character from running SetIsRunning(false); // try and play a firing animation if specified if (FireAnimation != nullptr) { // Get the animation object for the arms mesh UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance(); if (AnimInstance != nullptr) { AnimInstance->Montage_Play(FireAnimation, 1.f); } } // check for bullet collisions ComputeBulletCollisions(); } // We reload the weapon if it is empty and we have bullets left in our inventory if (ShouldReload()) { Reload(); } } }
// Called when the player press the Reload key void AMurphysLawCharacter::Reload() { // Checks if we have a weapon equipped if (HasWeaponEquipped()) { // If the weapon has been able to reload if (GetEquippedWeapon()->Reload()) { SetIsRunning(false); } } }
// Called when the character jumps void AMurphysLawCharacter::Jump() { // Only jump when the character has enough stamina or isn't already in the air if (GetCurrentStaminaLevel() - JumpStaminaDecayAmount <= 0.f || IsInAir()) return; // Stop the character from running first SetIsRunning(false); Super::Jump(); UpdateStaminaLevel(-JumpStaminaDecayAmount); }
void AMurphysLawCharacter::MoveForward(float Value) { if (Value != 0.0f && CanPlayerMove()) { // If the character is going backward, he can't be running if (Value < 0.f) { SetIsRunning(false); } // add movement in that direction AddMovementInput(GetActorForwardVector(), Value); } }
void AMurphysLawCharacter::ToggleCrouch() { // If the character is not crouched if (CanCrouch()) { IsCrouched = true; Crouch(); // Stop the player from running SetIsRunning(false); } else { IsCrouched = false; UnCrouch(); } }
void Computer::InfectWithRevelation ( float version ) { isinfected_revelation = version; infectiondate.SetDate ( &game->GetWorld ()->date ); if ( version <= 1.0 ) { // Destroy the computer immediately SetIsRunning ( false ); databank.Format (); logbank.Empty (); } }
void CGame::Initialize(HWND hWnd, HINSTANCE hInstance, int nScreenWidth, int nScreenHeight, bool bIsWindowed) { //Get pointers to singletons: m_pD3D = CSGD_Direct3D::GetInstance(); m_pTM = CSGD_TextureManager::GetInstance(); m_pDI = CSGD_DirectInput::GetInstance(); // Initialize the singletons m_pD3D->InitDirect3D(hWnd, nScreenWidth, nScreenHeight, bIsWindowed, false); m_pTM->InitTextureManager(m_pD3D->GetDirect3DDevice(), m_pD3D->GetSprite()); m_pAssets = CAssets::GetInstance(); m_pDI->InitDirectInput(hWnd, hInstance, DI_KEYBOARD, 0); // m_pDI->InitDirectInput(hWnd, hInstance, DI_MOUSE, 1); // m_pDI->AcquireAll(); SetIsRunning(true); m_nScreenWidth = nScreenWidth; m_nScreenHeight = nScreenHeight; //m_pAssets->LoadAssets(); m_pBattleMap = new CBattleMap("Resources/MapInfo/VG_MyMap.dat"); }
///Do a modular part of the task. For example, if the task is to load the entire file, load one BlockFile. ///Relies on DoSomeInternal(), which is the subclasses must implement. ///@param amountWork the percent amount of the total job to do. 1.0 represents the entire job. the default of 0.0 /// will do the smallest unit of work possible void ODTask::DoSome(float amountWork) { SetIsRunning(true); mBlockUntilTerminateMutex.Lock(); // printf("%s %i subtask starting on new thread with priority\n", GetTaskName(),GetTaskNumber()); mDoingTask=mTaskStarted=true; float workUntil = amountWork+PercentComplete(); //check periodically to see if we should exit. mTerminateMutex.Lock(); if(mTerminate) { mTerminateMutex.Unlock(); SetIsRunning(false); mBlockUntilTerminateMutex.Unlock(); return; } mTerminateMutex.Unlock(); Update(); if(UsesCustomWorkUntilPercentage()) workUntil = ComputeNextWorkUntilPercentageComplete(); if(workUntil<PercentComplete()) workUntil = PercentComplete(); //Do Some of the task. mTerminateMutex.Lock(); while(PercentComplete() < workUntil && PercentComplete() < 1.0 && !mTerminate) { wxThread::This()->Yield(); //release within the loop so we can cut the number of iterations short DoSomeInternal(); //keep the terminate mutex on so we don't remo mTerminateMutex.Unlock(); //check to see if ondemand has been called if(GetNeedsODUpdate() && PercentComplete() < 1.0) ODUpdate(); //But add the mutex lock back before we check the value again. mTerminateMutex.Lock(); } mTerminateMutex.Unlock(); mDoingTask=false; mTerminateMutex.Lock(); //if it is not done, put it back onto the ODManager queue. if(PercentComplete() < 1.0&& !mTerminate) { ODManager::Instance()->AddTask(this); //we did a bit of progress - we should allow a resave. AudacityProject::AllProjectsDeleteLock(); for(unsigned i=0; i<gAudacityProjects.GetCount(); i++) { if(IsTaskAssociatedWithProject(gAudacityProjects[i])) { //mark the changes so that the project can be resaved. gAudacityProjects[i]->GetUndoManager()->SetODChangesFlag(); break; } } AudacityProject::AllProjectsDeleteUnlock(); // printf("%s %i is %f done\n", GetTaskName(),GetTaskNumber(),PercentComplete()); } else { //for profiling, uncomment and look in audacity.app/exe's folder for AudacityProfile.txt //static int tempLog =0; //if(++tempLog % 5==0) //END_TASK_PROFILING("On Demand Drag and Drop 5 80 mb files into audacity, 5 wavs per task"); //END_TASK_PROFILING("On Demand open an 80 mb wav stereo file"); wxCommandEvent event( EVT_ODTASK_COMPLETE ); AudacityProject::AllProjectsDeleteLock(); for(unsigned i=0; i<gAudacityProjects.GetCount(); i++) { if(IsTaskAssociatedWithProject(gAudacityProjects[i])) { //this assumes tasks are only associated with one project. gAudacityProjects[i]->GetEventHandler()->AddPendingEvent(event); //mark the changes so that the project can be resaved. gAudacityProjects[i]->GetUndoManager()->SetODChangesFlag(); break; } } AudacityProject::AllProjectsDeleteUnlock(); // printf("%s %i complete\n", GetTaskName(),GetTaskNumber()); } mTerminateMutex.Unlock(); SetIsRunning(false); mBlockUntilTerminateMutex.Unlock(); }
void AMurphysLawCharacter::StopRunning() { SetIsRunning(false); }
void AMurphysLawCharacter::Run() { SetIsRunning(true); }
void AMurphysLawCharacter::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); if (FirstPersonCameraComponent != nullptr) { // Gets the camera angle for the mini-map (to rotate it as the player rotates the player) Bearing = FirstPersonCameraComponent->GetComponentRotation().Yaw; } // Calculate the current regeneration rate according on character's movement const bool IsMoving = GetVelocity().Size() != 0.f; const float CurrentRegenerationRate = IsMoving ? StaminaRegenerationRate : StaminaRegenerationRate * 2; // Raise the level of stamina overtime UpdateStaminaLevel(CurrentRegenerationRate * DeltaSeconds * GetMaxStaminaLevel()); // If the character is not moving, we deactivate his running so he doesn't lose stamina if (!IsMoving) { SetIsRunning(false); } // But lower the stamina if the player is running if (IsRunning) { UpdateStaminaLevel(-RunningStaminaDecayRate * DeltaSeconds * GetMaxStaminaLevel()); // If the character is out of breath, it stops running if (GetCurrentStaminaLevel() <= 0.f) { SetIsRunning(false); } } if (this->GetMovementComponent()->IsFalling()) { SetIsInAir(true); HighestZ = FMath::Max(HighestZ, GetActorLocation().Z); } else { float DeltaZ = (HighestZ - GetActorLocation().Z) / 10.f; //On ne veut pas de dégât pour les petits sauts... //Pour calculer le dégât fait en sautant de la tour if (DeltaZ > 100) { FHitResult HitResult; float Damage = DeltaZ * 0.35f; FVector HurtDirection = GetActorLocation(); FPointDamageEvent CollisionDamageEvent(Damage, HitResult, HurtDirection, UDamageType::StaticClass()); if (Role == ROLE_Authority) { TakeDamage(Damage, CollisionDamageEvent, GetController(), this); } } //Pour calculer le dégât fait en sautant du balcon else if (DeltaZ > 30) { FHitResult HitResult; float Damage = DeltaZ * 0.5f; FVector HurtDirection = GetActorLocation(); FPointDamageEvent CollisionDamageEvent(Damage, HitResult, HurtDirection, UDamageType::StaticClass()); if (Role == ROLE_Authority) { TakeDamage(Damage, CollisionDamageEvent, GetController(), this); } } HighestZ = 0; SetIsInAir(false); } /** [PS] DO NOT REMOVE - Trying to make it work */ //ACharacter* myCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0); //if (myCharacter) //Maybe check character //{ // FVector charLocation = myCharacter->GetActorLocation(); // FVector sceneLocation = SceneComponent->GetComponentLocation(); // // FRotator PlayerRot = UKismetMathLibrary::FindLookAtRotation(sceneLocation, charLocation); // float X, Y, Z; // UKismetMathLibrary::BreakRotator(PlayerRot, X, Y, Z); // FRotator Result = UKismetMathLibrary::MakeRotator(0.f, 0.f, Z); // //UKismetMathLibrary::BreakRotIntoAxes(PlayerRot, X, Y, Z); // // SceneComponent->SetWorldLocationAndRotation(sceneLocation, Result); // /*SceneComponent->SetWorldRotation(FRotationMatrix::MakeFromXY(X, Y).ToQuat());*/ //} }
void Computer::Update () { if ( !isrunning ) return; if ( isinfected_revelation > 1.0 ) { Date damagedate; damagedate.SetDate ( &infectiondate ); damagedate.AdvanceMinute ( TIME_REVELATIONREPRODUCE ); if ( game->GetWorld ()->date.After ( &damagedate ) ) { // // Spread to two other computers Computer *comp1 = WorldGenerator::GetRandomComputer ( COMPUTER_TYPE_INTERNALSERVICESMACHINE ); Computer *comp2 = WorldGenerator::GetRandomComputer ( COMPUTER_TYPE_INTERNALSERVICESMACHINE | COMPUTER_TYPE_CENTRALMAINFRAME ); UplinkAssert (comp1); UplinkAssert (comp2); game->GetWorld ()->plotgenerator.RunRevelation ( comp1->ip, isinfected_revelation, false ); game->GetWorld ()->plotgenerator.RunRevelation ( comp2->ip, isinfected_revelation, false ); // // Shut down this computer SetIsRunning ( false ); databank.Format (); logbank.Empty (); game->GetWorld ()->plotgenerator.Disinfected ( ip ); // // Disconnect the player if he is connected if ( strcmp ( game->GetWorld ()->GetPlayer ()->GetRemoteHost ()->ip, ip ) == 0 ) { game->GetWorld ()->GetPlayer ()->connection.Disconnect (); game->GetWorld ()->GetPlayer ()->connection.Reset (); game->GetInterface ()->GetRemoteInterface ()->RunNewLocation (); game->GetInterface ()->GetRemoteInterface ()->RunScreen ( 2 ); } } } // // Generate some new files // if ( databank.NumDataFiles () > 0 && NumberGenerator::RandomNumber ( 1000 ) == 0 ) { Data *data = new Data (); data->SetTitle ( NameGenerator::GenerateDataName ( "companyname", DATATYPE_DATA ) ); data->SetDetails ( DATATYPE_DATA, NumberGenerator::RandomNumber ( 10 ) + 1, 0, 0 ); if ( !databank.PutData ( data ) ) delete data; } // // Generate some new logs // if ( NumberGenerator::RandomNumber ( 1000 ) == 0 ) { AccessLog *al = new AccessLog (); al->SetProperties ( &(game->GetWorld ()->date), WorldGenerator::GetRandomLocation ()->ip, " " ); al->SetData1 ( "Accessed File" ); logbank.AddLog (al); } }
void Computer::CheckForSecurityBreaches () { bool timetochangeunderware = false; // // Has someone f****d this computer over? // if ( !isrunning ) { if ( !isinfected_revelation ) { if ( databank.formatted ) NewsGenerator::ComputerDestroyed ( this, true ); else NewsGenerator::ComputerDestroyed ( this, false ); } SetIsRunning ( true ); DisinfectRevelation (); databank.formatted = false; return; } // // Check for suspect logs // for ( int i = 0; i < logbank.logs.Size (); ++i ) { if ( logbank.logs.ValidIndex (i) ) { AccessLog *al = logbank.logs.GetData (i); AccessLog *internallog = NULL; if ( logbank.internallogs.ValidIndex (i) ) internallog = logbank.internallogs.GetData (i); if ( al->SUSPICIOUS == LOG_SUSPICIOUS ) { // Now noticed - they have another 3 hours before trace // Special case - don't trace if this is the player, and he is performing // a Trace Hacker mission for this company bool ignoreme = false; if ( strcmp ( al->fromname, "PLAYER" ) == 0 ) { for ( int l = 0; l < game->GetWorld ()->GetPlayer ()->missions.Size (); ++l ) { Mission *m = game->GetWorld ()->GetPlayer ()->missions.GetData (l); UplinkAssert (m); if ( m->TYPE == MISSION_TRACEUSER && strcmp ( m->completionB, ip ) == 0 ) ignoreme = true; } } if ( !ignoreme ) { al->SetSuspicious ( LOG_SUSPICIOUSANDNOTICED ); if ( internallog ) internallog->SetSuspicious ( LOG_SUSPICIOUSANDNOTICED ); timetochangeunderware = true; } else { al->SetSuspicious ( LOG_NOTSUSPICIOUS ); } } else if ( al->SUSPICIOUS == LOG_SUSPICIOUSANDNOTICED ) { // Noticed and time up - pass this onto the consequence generator ConsequenceGenerator::ComputerHacked ( this, al ); // No longer suspicious - now under investigation al->SetSuspicious ( LOG_UNDERINVESTIGATION ); if ( internallog ) internallog->SetSuspicious ( LOG_UNDERINVESTIGATION ); } } } // // Have all our files been wiped? // if ( databank.formatted ) { char *softwaretype [4] = { "SCIENTIFIC", "CORPORATE", "CUSTOMER", "SOFTWARE" }; int softwareindex = NumberGenerator::RandomNumber ( 4 ); NewsGenerator::AllFilesDeleted ( this, softwaretype [softwareindex] ); databank.formatted = false; timetochangeunderware = true; } // // Reset our defenses if they have been compromised // if ( security.IsAnythingDisabled () || timetochangeunderware ) { ChangeSecurityCodes (); } }