//------------------------------------------------------------------------- void CPlayerFeature::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char *setup) { if(m_notPickUp) OnPickedUp(pickerId,true); else CItem::PickUp(pickerId,sound,select,keepHistory, setup); }
void AShooterPickup::OnRep_IsActive() { if (bIsActive) { OnRespawned(); } else { OnPickedUp(); } }
void AAPickupActor::OnUsed(APawn* InstigatorPawn) { Super::OnUsed(InstigatorPawn); UGameplayStatics::PlaySoundAtLocation(this, PickupSound, GetActorLocation()); bIsActive = false; OnPickedUp(); if (bAllowRespawn) { FTimerHandle RespawnTimerHandle; GetWorld()->GetTimerManager().SetTimer(RespawnTimerHandle, this, &AAPickupActor::RespawnPickup, RespawnDelay + FMath::RandHelper(RespawnDelayRange), false); } else { /* Delete from level if respawn is not allowed */ Destroy(); } }
void AShooterPickup::PickupOnTouch(class AShooterCharacter* Pawn) { if (bIsActive && Pawn && Pawn->IsAlive() && !IsPendingKill()) { if (CanBePickedUp(Pawn)) { GivePickupTo(Pawn); PickedUpBy = Pawn; if (!IsPendingKill()) { bIsActive = false; OnPickedUp(); if (RespawnTime > 0.0f) { GetWorldTimerManager().SetTimer(TimerHandle_RespawnPickup, this, &AShooterPickup::RespawnPickup, RespawnTime, false); } } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseCombatWeapon::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBasePlayer *pPlayer = ToBasePlayer( pActivator ); if ( pPlayer ) { m_OnPlayerUse.FireOutput( pActivator, pCaller ); // // Bump the weapon to try equipping it before picking it up physically. This is // important in a few spots in the game where the player could potentially +use pickup // and then THROW AWAY a vital weapon, rendering them unable to continue the game. // if ( pPlayer->BumpWeapon( this ) ) { OnPickedUp( pPlayer ); } else { pPlayer->PickupObject( this ); } } }
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select/* =true */, bool keepHistory/* =true */, const char *setup /*= NULL*/) { CActor *pActor=GetActor(pickerId); if (!pActor) return; TriggerRespawn(); GetEntity()->EnablePhysics(false); Physicalize(false, false); bool soundEnabled = IsSoundEnabled(); EnableSound(sound); SetViewMode(0); SetOwnerId(pickerId); CopyRenderFlags(GetOwner()); Hide(true); m_stats.dropped = false; m_stats.detached = false; m_stats.brandnew = false; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) { GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName()); return; } if (!pActor->IsPlayer() || pActor->IsClient() || gEnv->bMultiplayer) { bool hasAccessory = pInventory->HasAccessory(GetEntity()->GetClass()); bool hasAccessoryForThisWeapon = pInventory->HasAccessory(GetEntity()->GetClass()); if (!hasAccessoryForThisWeapon) pInventory->AddAccessory(GetEntity()->GetClass()); if (!hasAccessory) ProcessAccessoryAmmoCapacities(pInventory, true); if (!hasAccessoryForThisWeapon) ProcessAccessoryAmmo(pInventory); } OnPickedUp(pickerId, m_sharedparams->params.unique); if (select) { PlayAction(GetFragmentIds().pickedup); } EnableSound(soundEnabled); bool isLocalEntity = GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY) ? true : false; if (IsServer() && !IsDemoPlayback()) { if(!gEnv->bMultiplayer || isLocalEntity) RemoveEntity(); else if(g_pGame->GetGameRules()) g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg } if (IsServer()) { GetGameObject()->SetNetworkParent(pickerId); if (!isLocalEntity) { pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId()); } } }
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char *setup) { CActor *pActor=GetActor(pickerId); if (!pActor) return; if(!CheckAmmoRestrictions(pickerId)) { if (IsServer()) g_pGame->GetGameRules()->SendTextMessage(eTextMessageCenter, "@ammo_maxed_out", eRMI_ToClientChannel, pActor->GetChannelId(), (string("@")+GetEntity()->GetClass()->GetName()).c_str()); return; } TriggerRespawn(); GetEntity()->EnablePhysics(false); Physicalize(false, false); bool soundEnabled = IsSoundEnabled(); EnableSound(sound); SetViewMode(0); SetOwnerId(pickerId); CopyRenderFlags(GetOwner()); Hide(true); m_stats.dropped = false; m_stats.brandnew = false; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) { GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName()); return; } if(!pInventory->HasAccessory(GetEntity()->GetClass())) { pInventory->AddAccessory(GetEntity()->GetClass()); } OnPickedUp(pickerId, m_sharedparams->params.unique); PlayAction(g_pItemStrings->pickedup); EnableSound(soundEnabled); if (IsServer() && !IsDemoPlayback()) { if(!gEnv->bMultiplayer) RemoveEntity(); else if(g_pGame->GetGameRules()) g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg } if (IsServer()) { GetGameObject()->SetNetworkParent(pickerId); if ((GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY)) == 0) { pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId()); const char *displayName=GetDisplayName(); } } }