void APuzzlePresetPlayerController::OnEndTurn() { /*UPuzzlePresetGameInstance* ppgi = Cast<UPuzzlePresetGameInstance>(GetGameInstance()); ULocalPlayer* LocalPlayer = GetLocalPlayer(); ppgi->HostSession(MakeShareable(LocalPlayer->GetControllerId()),) return;*/ IOnlineSubsystem* ion = IOnlineSubsystem::Get(FName("Steam")); if (ion != nullptr) { ULocalPlayer* LocalPlayer = GetLocalPlayer(); if (LocalPlayer && LocalPlayer->GetControllerId() != -1) { UE_LOG(LogTemp, Warning, TEXT("steam user name: %s"), *PlayerState->PlayerName); uint8 status = ion->GetIdentityInterface()->GetLoginStatus(LocalPlayer->GetControllerId()); UE_LOG(LogTemp, Warning, TEXT("steam user status: %d"), status); } /*if (ion->InitSteamworksClient(false, 480)) { UE_LOG(LogTemp, Warning, TEXT("Steam API initialized succesfully!")); } else { UE_LOG(LogTemp, Warning, TEXT("Failed to initialize Steam API :(")); }*/ } }
void ObjectManager::SetLocalPlayerLocation(int newLocation) { if (m_location == newLocation) { std::cout << "Er, setting location to current value!\n"; // We want to download new location mesh etc.... if (GetGameMode() != AMJU_MODE_EDIT) { //return; } } // Why not do this ?? if (GetLocalPlayer()) { GetLocalPlayer()->SetLocation(newLocation); } m_location = newLocation; TheGame::Instance()->ClearGameObjects(); // If using Sweep and Prune for collisions, clear list of objects ////TheSAP::Instance()->Clear(); ClearVe1SceneGraph(); // Clear the current terrain, which is the important thing the new location must have! ClearTerrain(); //std::cout << " ..old location trashed, adding game objects in new location...\n"; for (GameObjects::iterator it = m_allGameObjects.begin(); it != m_allGameObjects.end(); ++it) { PGameObject go = it->second; Ve1Object* v = dynamic_cast<Ve1Object*>(go.GetPtr()); if (v) { if (v->GetLocation() == m_location) { //std::cout << " ..Game object: " << go->GetTypeName() << ", id: " << go->GetId() << "\n"; AddGameObjectToGame(go); ////TheGame::Instance()->AddGameObject(go); ////TheSAP::Instance()->AddBox(go); v->OnLocationEntry(); } } else { std::cout << "Rather unexpected type of game object: " << go->GetTypeName() << ", id: " << go->GetId() << "\n"; AddGameObjectToGame(go); ////TheGame::Instance()->AddGameObject(go); } } // Change to waiting state: some objects required for this new location might not exist yet TheGame::Instance()->SetCurrentState(TheGSFileUpdateCheck::Instance()); //TheGSWaitForNewLocation::Instance()); }
//----------------------------------------------------------------------------- // Purpose: Draw triangle //----------------------------------------------------------------------------- void NDebugOverlay::Triangle( const Vector &p1, const Vector &p2, const Vector &p3, int r, int g, int b, int a, bool noDepthTest, float duration ) { CBasePlayer *player = GetLocalPlayer(); if ( !player ) return; // Clip triangles that are far away Vector to1 = p1 - player->GetAbsOrigin(); Vector to2 = p2 - player->GetAbsOrigin(); Vector to3 = p3 - player->GetAbsOrigin(); if ((to1.LengthSqr() > MAX_OVERLAY_DIST_SQR) && (to2.LengthSqr() > MAX_OVERLAY_DIST_SQR) && (to3.LengthSqr() > MAX_OVERLAY_DIST_SQR)) { return; } // Clip triangles that are behind the client Vector clientForward; player->EyeVectors( &clientForward ); float dot1 = DotProduct(clientForward, to1); float dot2 = DotProduct(clientForward, to2); float dot3 = DotProduct(clientForward, to3); if (dot1 < 0 && dot2 < 0 && dot3 < 0) return; if ( debugoverlay ) { debugoverlay->AddTriangleOverlay( p1, p2, p3, r, g, b, a, noDepthTest, duration ); } }
//----------------------------------------------------------------------------- // Purpose: Draws a line from one position to another //----------------------------------------------------------------------------- void NDebugOverlay::Line( const Vector &origin, const Vector &target, int r, int g, int b, bool noDepthTest, float duration ) { // -------------------------------------------------------------- // Clip the line before sending so we // don't overflow the client message buffer // -------------------------------------------------------------- CBasePlayer *player = GetLocalPlayer(); if ( player == NULL ) return; // Clip line that is far away if (((player->GetAbsOrigin() - origin).LengthSqr() > MAX_OVERLAY_DIST_SQR) && ((player->GetAbsOrigin() - target).LengthSqr() > MAX_OVERLAY_DIST_SQR) ) return; // Clip line that is behind the client Vector clientForward; player->EyeVectors( &clientForward ); Vector toOrigin = origin - player->GetAbsOrigin(); Vector toTarget = target - player->GetAbsOrigin(); float dotOrigin = DotProduct(clientForward,toOrigin); float dotTarget = DotProduct(clientForward,toTarget); if (dotOrigin < 0 && dotTarget < 0) return; if ( debugoverlay ) { debugoverlay->AddLineOverlay( origin, target, r, g, b, noDepthTest, duration ); } }
void GSAvatarMod::OnActive() { GSGui::OnActive(); m_gui = LoadGui("gui-avatarmod.txt"); Assert(m_gui); m_gui->GetElementByName("ok-button")->SetCommand(Amju::OnOkButton); m_gui->GetElementByName("cancel-button")->SetCommand(Amju::OnCancelButton); m_gui->GetElementByName("type-prev-button")->SetCommand(Amju::OnTypePrevButton); m_gui->GetElementByName("type-next-button")->SetCommand(Amju::OnTypeNextButton); // m_gui->GetElementByName("colour-prev-button")->SetCommand(Amju::OnColourPrevButton); // m_gui->GetElementByName("colour-next-button")->SetCommand(Amju::OnColourNextButton); GetGuiSceneGraph()->Clear(); GetGuiSceneGraph()->SetRootNode(SceneGraph::AMJU_OPAQUE, new SceneNode); // TODO Horribly hardcoded here, use constants m_currentChar = GetLocalPlayer()->GetVal("avatar"); if (m_currentChar.empty()) { std::cout << "No avatar set for local player ???\n"; m_currentChar = "marge"; } if (!TheAvatarManager::Instance()->GetIndex(m_currentChar, &m_current)) { std::cout << "Couldn't find name in Avatar Manager: " << m_currentChar << "\n"; Assert(0); } CreateChar(); CheckAvailable(); }
void SetShownMsg(MsgNum msgNumber) { Player* p = GetLocalPlayer(); std::string key = "shown_msg_" + ToString(msgNumber); TheObjectUpdater::Instance()->SendUpdateReq(p->GetId(), key, "y"); p->SetKeyVal(key, "y"); }
void C_MSS_Player::PreThink( void ) { QAngle vTempAngles = GetLocalAngles(); if ( GetLocalPlayer() == this ) { vTempAngles[PITCH] = EyeAngles()[PITCH]; } else { vTempAngles[PITCH] = m_angEyeAngles[PITCH]; } if ( vTempAngles[YAW] < 0.0f ) { vTempAngles[YAW] += 360.0f; } SetLocalAngles( vTempAngles ); BaseClass::PreThink(); HandleSpeedChanges(); if ( m_HL2Local.m_flSuitPower <= 0.0f ) { if( IsSprinting() ) { StopSprinting(); } } }
CGrottoCharacter* CGrottoGame::GetLocalPlayerCharacter() { CPlayer* pPlayer = GetLocalPlayer(); if (!pPlayer) return nullptr; return static_cast<CGrottoCharacter*>(pPlayer->GetCharacter()); }
std::string GameLookup(const std::string& text) { Player* p = GetLocalPlayer(); Assert(p); std::string playerName = p->GetName(); return Replace(text, "<p>", playerName); }
//----------------------------------------------------------------------------- // Purpose: Debug player by index //----------------------------------------------------------------------------- CBasePlayer *GetDebugPlayer( void ) { #if defined( CLIENT_DLL ) //NOTENOTE: This doesn't necessarily make sense on the client return GetLocalPlayer(); #else return UTIL_PlayerByIndex(CBaseEntity::m_nDebugPlayer); #endif }
bool ChangePlayerCount(const std::string& key, int delta) { Player* player = GetLocalPlayer(); if (!player) { return false; } int id = GetLocalPlayerId(); return ChangeObjCount(id, key, delta); }
void GSVe3ChooseTradeType::OnActive() { GSGui::OnActive(); m_gui = LoadGui("gui-ve3-choosetradetype.txt"); Assert(m_gui); GetElementByName(m_gui, "back-button")->SetCommand(OnBack); GetElementByName(m_gui, "give-treasure-button")->SetCommand(Amju::OnGiveTreasure); GetElementByName(m_gui, "give-food-button")->SetCommand(Amju::OnGiveFood); Assert(m_player); // the other player Player* localPlayer = GetLocalPlayer(); Assert(localPlayer); Player* PLAYER[4] = { localPlayer, m_player, localPlayer, m_player }; for (int i = 0; i < 4; i++) { LayerGroups layerGroups; // store settings for each layer layerGroups.SetFromSprite(PLAYER[i]->GetSprite()); layerGroups.SetSprite(&m_spriteNodes[i].GetSprite()); m_spriteNodes[i].Update(); } SetHomeButton(); // Set food and treasure counts for both players Assert(dynamic_cast<GuiText*>(GetElementByName(m_gui, "food-you-text"))); Assert(dynamic_cast<GuiText*>(GetElementByName(m_gui, "food-other-text"))); Assert(dynamic_cast<GuiText*>(GetElementByName(m_gui, "treasure-you-text"))); Assert(dynamic_cast<GuiText*>(GetElementByName(m_gui, "treasure-other-text"))); if (localPlayer->Exists(FOOD_STORED_KEY)) { ((GuiText*)GetElementByName(m_gui, "food-you-text"))->SetText(localPlayer->GetVal(FOOD_STORED_KEY)); } if (m_player->Exists(FOOD_STORED_KEY)) { ((GuiText*)GetElementByName(m_gui, "food-other-text"))->SetText(m_player->GetVal(FOOD_STORED_KEY)); } if (localPlayer->Exists(TREASURE_KEY)) { ((GuiText*)GetElementByName(m_gui, "treasure-you-text"))->SetText(localPlayer->GetVal(TREASURE_KEY)); } if (m_player->Exists(TREASURE_KEY)) { ((GuiText*)GetElementByName(m_gui, "treasure-other-text"))->SetText(m_player->GetVal(TREASURE_KEY)); } }
void SendGetNewMsgsReq() { if (!GetLocalPlayer()) { std::cout << "No local player yet, can't send get new msgs request\n"; return; } std::string url = TheVe1ReqManager::Instance()->MakeUrl(GET_NEW_MSGS); // TODO Add ID of last msg recved url += "&time=" + timestamp; url += "&recip="; url += ToString(GetLocalPlayer()->GetId()); #ifdef SEND_DEBUG std::cout << "Sending req to check for new msgs: " << url << "\n"; #endif // Only need one request in flight TheVe1ReqManager::Instance()->AddReq(new ReqGetNewMsgs(url), 1); }
bool GetPlayerCount(const std::string& key, int* result) { Player* p = GetLocalPlayer(); if (p) { if (p->Exists(key)) { std::string s = p->GetVal(key); *result = ToInt(s); return true; } } return false; }
//----------------------------------------------------------------------------- // Purpose: Draw a circle whose center is at a position, facing the camera //----------------------------------------------------------------------------- void NDebugOverlay::Circle( const Vector &position, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration ) { CBasePlayer *player = GetLocalPlayer(); if ( player == NULL ) return; Vector clientForward; player->EyeVectors( &clientForward ); QAngle vecAngles; VectorAngles( clientForward, vecAngles ); Circle( position, vecAngles, radius, r, g, b, a, bNoDepthTest, flDuration ); }
void Baddie::SetMenu(GuiMenu* menu) { // Don't try to shoot indestructible baddies..? if (!m_isDestructible) { return; } // No menu, but fire at this baddie Player* p = GetLocalPlayer(); if (p) { p->ShootBaddie(this); } }
void Treasure::Update() { // TODO Doesn't move, so no need to do this every frame, right? Ve1Object::Update(); if (m_sceneNode) { Matrix m; m.Translate(m_pos); m_sceneNode->SetLocalTransform(m); m_glow->SetLocalTransform(m); // ??? WHY ??? if (m_sceneNode->GetAABB()) { m_sceneNode->SetAABB(AABB( m_pos.x - XSIZE, m_pos.x + XSIZE, m_pos.y, m_pos.y + YSIZE, m_pos.z - XSIZE, m_pos.z + XSIZE)); } // Delete scene node if we have already been collected // (Extra check in case player not created yet when Load() called) std::string key = MakeTreasureKey(); Assert(GetLocalPlayer()); if (GetLocalPlayer()->Exists(key)) { // Or OnLocationExit ..? SetHidden(true); m_sceneNode = 0; } } GetAABB()->Set( m_pos.x - XSIZE, m_pos.x + XSIZE, m_pos.y, m_pos.y + YSIZE, m_pos.z - XSIZE, m_pos.z + XSIZE); }
void GSVe3ViewOtherPlayers::NextPlayer() { Player* localPlayer = GetLocalPlayer(); GameObjects* gos = TheObjectManager::Instance()->GetGameObjects(); int id = -1; if (m_player) { id = m_player->GetId(); } // Remember first player, go to if we reach the end Player* first = 0; bool found = false; for (auto it = gos->begin(); it != gos->end(); ++it) { GameObject* go = it->second; Player* p = dynamic_cast<Player*>(go); if (p == localPlayer) { continue; } if (p && !first) { first = p; } if (p && p->GetId() > id) { m_player = p; found = true; break; } } if (!found) { m_player = first; // wrap around if poss } if (m_player) { ShowPlayer(m_player, m_gui); } }
void Ve1Object::SetKeyVal(const std::string& key, const std::string& val) { m_valmap[key] = val; if (key == "hidden") { m_hidden = (val == "y"); } else if (key == HEADING_KEY) { if (this != GetLocalPlayer()) { // We sent this to server a while ago m_dir = ToFloat(val); } } }
int CHud :: MsgFunc_CamData( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); gHUD.viewEntityIndex = READ_SHORT(); gHUD.viewFlags = READ_SHORT(); if( gHUD.viewFlags ) m_iCameraMode = 1; else m_iCameraMode = m_iLastCameraMode; // update pparams->viewentity too for right hearing if( gHUD.viewEntityIndex ) gpViewParams->viewentity = gHUD.viewEntityIndex; else gpViewParams->viewentity = GetLocalPlayer()->serialnumber; END_READ(); return 1; }
void Furniture::SetMenu(GuiMenu* menu) { // If not currently carried; if you are strong enough if (m_pickupId == 0) { if (GetLocalPlayer()->GetCarrying()) { std::cout << "can't pick up, already carrying something else!\n"; } else { //// AddMenuItem("Pick up", new CommandPickUp(this, true)); } } else if (m_pickupId == GetLocalPlayerId()) { //// AddMenuItem("Put down", new CommandPickUp(this, false)); } }
void C_HL2MP_Player::PreThink( void ) { QAngle vTempAngles = GetLocalAngles(); if ( GetLocalPlayer() == this ) { vTempAngles[PITCH] = EyeAngles()[PITCH]; } else { vTempAngles[PITCH] = m_angEyeAngles[PITCH]; } if ( vTempAngles[YAW] < 0.0f ) { vTempAngles[YAW] += 360.0f; } SetLocalAngles( vTempAngles ); BaseClass::PreThink(); }
bool FirstTimeMsg(const std::string& text, MsgNum msgNumber, bool storyMode) { Player* p = GetLocalPlayer(); if (!p) { std::cout << "No player, can't show msg!\n"; Assert(0); return false; } if (HasShownMsg(msgNumber)) { // Already shown this msg return false; } // Set shown flag SetShownMsg(msgNumber); // TODO set shown flag when msg closed ? ShowText(text, storyMode); return true; }
void CreateCollect(int type, int specialId) { Player* player = GetLocalPlayer(); if (!player) { Assert(0); return; } Collect* c = new Collect; static int id = 1000000; id++; c->SetId(id); // Game obj ID c->SetSpecialId(specialId); // collect ID to validate on server // Set location (necessary ?) c->SetLocation(GetLocalPlayerLocation()); // Set position c->SetPos(player->GetPos()); // TODO TEMP TEST // Set pos first static const int NUM = 2; static const char* MESH_TEX[NUM][2] = { { "heart.obj", "heart2.png" }, { "bean.obj", "bean1.png" } }; int r = 0; // TODO rand() % NUM; c->Create(MESH_TEX[r][0], MESH_TEX[r][1]); c->OnLocationEntry(); // Add to Game - these are temp, not cached TheGame::Instance()->AddGameObject(c); }
//----------------------------------------------------------------------------- // Purpose: Draw debug text at a position //----------------------------------------------------------------------------- void NDebugOverlay::Text( const Vector &origin, const char *text, bool bViewCheck, float duration ) { CBasePlayer *player = GetLocalPlayer(); if ( !player ) return; // Clip text that is far away if ( ( player->GetAbsOrigin() - origin ).LengthSqr() > MAX_OVERLAY_DIST_SQR ) return; // Clip text that is behind the client Vector clientForward; player->EyeVectors( &clientForward ); Vector toText = origin - player->GetAbsOrigin(); float dotPr = DotProduct(clientForward,toText); if (dotPr < 0) return; // Clip text that is obscured if (bViewCheck) { trace_t tr; UTIL_TraceLine(player->GetAbsOrigin(), origin, MASK_OPAQUE, NULL, COLLISION_GROUP_NONE, &tr); if ((tr.endpos - origin).Length() > 10) return; } if ( debugoverlay ) { debugoverlay->AddTextOverlay( origin, duration, "%s", text ); } }
/** * sendet den "Bereit"-Status. * * @author FloSoft */ void GameClient::Command_ToggleReady() { send_queue.push(new GameMessage_Player_Ready(0xFF, GetLocalPlayer()->ready )); }
//========================================================= //========================================================= bool C_GameInstructor::OpenOpportunity( CBaseLesson *pLesson ) { // Get the root lesson CBaseLesson *pRootLesson = pLesson->GetRoot(); if ( !pRootLesson ) { if ( gameinstructor_verbose.GetInt() > 0 ) { ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " ); ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (because root lesson could not be found).\n" ); } delete pLesson; return false; } C_BasePlayer *pLocalPlayer = GetLocalPlayer(); if ( !pRootLesson->CanOpenWhenDead() && ( !pLocalPlayer || !pLocalPlayer->IsAlive() ) ) { // If the player is dead don't allow lessons that can't be opened when dead if ( gameinstructor_verbose.GetInt() > 0 ) { ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " ); ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (because player is dead and can_open_when_dead not set).\n" ); } delete pLesson; return false; } if ( !pRootLesson->PrerequisitesHaveBeenMet() ) { // If the prereqs haven't been met, don't open it if ( gameinstructor_verbose.GetInt() > 0 ) { ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " ); ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (because prereqs haven't been met).\n" ); } delete pLesson; return false; } if ( pRootLesson->InstanceType() == LESSON_INSTANCE_FIXED_REPLACE ) { CBaseLesson *pLessonToReplace = NULL; CBaseLesson *pLastReplacableLesson = NULL; int iInstanceCount = 0; // Check how many are already open for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i ) { CBaseLesson *pOpenOpportunity = m_OpenOpportunities[ i ]; if ( pOpenOpportunity->GetNameSymbol() == pLesson->GetNameSymbol() && pOpenOpportunity->GetReplaceKeySymbol() == pLesson->GetReplaceKeySymbol() ) { iInstanceCount++; if ( pRootLesson->ShouldReplaceOnlyWhenStopped() ) { if ( !pOpenOpportunity->IsInstructing() ) { pLastReplacableLesson = pOpenOpportunity; } } else { pLastReplacableLesson = pOpenOpportunity; } if ( iInstanceCount >= pRootLesson->GetFixedInstancesMax() ) { pLessonToReplace = pLastReplacableLesson; break; } } } if ( pLessonToReplace ) { // Take the place of the previous instance if ( gameinstructor_verbose.GetInt() > 0 ) { ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " ); ConColorMsg( CBaseLesson::m_rgbaVerboseOpen, "\"%s\" ", pLesson->GetName() ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "replacing open lesson of same type.\n" ); } pLesson->TakePlaceOf( pLessonToReplace ); CloseOpportunity( pLessonToReplace ); } else if ( iInstanceCount >= pRootLesson->GetFixedInstancesMax() ) { // Don't add another lesson of this type if ( gameinstructor_verbose.GetInt() > 0 ) { ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " ); ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (there is too many started lessons of this type).\n" ); } delete pLesson; return false; } } if ( gameinstructor_verbose.GetInt() > 0 ) { ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " ); ConColorMsg( CBaseLesson::m_rgbaVerboseOpen, "\"%s\" ", pLesson->GetName() ); ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "opened.\n" ); } m_OpenOpportunities.AddToTail( pLesson ); return true; }
void HUD_UpdateEntityVars( edict_t *ent, const entity_state_t *state, const entity_state_t *prev ) { float m_fLerp; if( state->ed_type == ED_CLIENT && state->ed_flags & ESF_NO_PREDICTION ) m_fLerp = 1.0f; else m_fLerp = GetLerpFrac(); if( state->flags & FL_PROJECTILE && state->ed_flags & ( ESF_NO_PREDICTION|ESF_NODELTA )) { // cut rocket trail, dont pass it from teleport // FIXME: don't work g_pViewRenderBeams->KillDeadBeams( ent ); } // copy state to progs ent->v.modelindex = state->modelindex; ent->v.weaponmodel = state->weaponmodel; ent->v.sequence = state->sequence; ent->v.gaitsequence = state->gaitsequence; ent->v.body = state->body; ent->v.skin = state->skin; ent->v.effects = state->effects; ent->v.velocity = state->velocity; ent->v.basevelocity = state->basevelocity; ent->v.oldorigin = ent->v.origin; // previous origin holds ent->v.mins = state->mins; ent->v.maxs = state->maxs; ent->v.framerate = state->framerate; ent->v.colormap = state->colormap; ent->v.rendermode = state->rendermode; ent->v.renderfx = state->renderfx; ent->v.fov = state->fov; ent->v.scale = state->scale; ent->v.weapons = state->weapons; ent->v.gravity = state->gravity; ent->v.health = state->health; ent->v.solid = state->solid; ent->v.movetype = state->movetype; ent->v.flags = state->flags; ent->v.ideal_pitch = state->idealpitch; ent->v.animtime = state->animtime; ent->v.ltime = state->localtime; if( state->groundent != -1 ) ent->v.groundentity = GetEntityByIndex( state->groundent ); else ent->v.groundentity = NULL; if( state->aiment != -1 ) ent->v.aiment = GetEntityByIndex( state->aiment ); else ent->v.aiment = NULL; switch( ent->v.movetype ) { case MOVETYPE_NONE: case MOVETYPE_STEP: // monster's steps will be interpolated on render-side ent->v.origin = state->origin; ent->v.angles = state->angles; ent->v.oldorigin = prev->origin; // used for lerp 'monster view' ent->v.oldangles = prev->angles; // used for lerp 'monster view' break; default: ent->v.angles = LerpAngle( prev->angles, state->angles, m_fLerp ); ent->v.origin = LerpPoint( prev->origin, state->origin, m_fLerp ); ent->v.basevelocity = LerpPoint( prev->basevelocity, state->basevelocity, m_fLerp ); break; } // interpolate scale, renderamount etc ent->v.scale = LerpPoint( prev->scale, state->scale, m_fLerp ); ent->v.rendercolor = LerpPoint( prev->rendercolor, state->rendercolor, m_fLerp ); ent->v.renderamt = LerpPoint( prev->renderamt, state->renderamt, m_fLerp ); if( ent->v.animtime ) { // use normal studio lerping ent->v.frame = state->frame; } else { // round sprite and brushmodel frames ent->v.frame = Q_rint( state->frame ); } switch( state->ed_type ) { case ED_CLIENT: ent->v.punchangle = LerpAngle( prev->punch_angles, state->punch_angles, m_fLerp ); ent->v.viewangles = LerpAngle( prev->viewangles, state->viewangles, m_fLerp ); ent->v.view_ofs = LerpPoint( prev->viewoffset, state->viewoffset, m_fLerp ); if( prev->fov != 90.0f && state->fov == 90.0f ) ent->v.fov = state->fov; // fov is reset, so don't lerping else ent->v.fov = LerpPoint( prev->fov, state->fov, m_fLerp ); ent->v.maxspeed = state->maxspeed; ent->v.iStepLeft = state->iStepLeft; ent->v.flFallVelocity = state->flFallVelocity; if( ent == GetLocalPlayer()) { edict_t *viewent = GetViewModel(); // if viewmodel has changed update sequence here if( viewent->v.modelindex != state->viewmodel ) { // ALERT( at_console, "Viewmodel changed\n" ); SendWeaponAnim( viewent->v.sequence, viewent->v.body, viewent->v.framerate ); } // setup player viewmodel (only for local player!) viewent->v.modelindex = state->viewmodel; gHUD.m_flFOV = ent->v.fov; // keep client fov an actual } break; case ED_PORTAL: case ED_MOVER: case ED_BSPBRUSH: ent->v.movedir = BitsToDir( state->body ); ent->v.oldorigin = state->oldorigin; break; case ED_SKYPORTAL: { skyportal_t *sky = &gpViewParams->skyportal; // setup sky portal sky->vieworg = ent->v.origin; sky->viewanglesOffset.x = sky->viewanglesOffset.z = 0.0f; sky->viewanglesOffset.y = gHUD.m_flTime * ent->v.angles[1]; sky->scale = (ent->v.scale ? 1.0f / ent->v.scale : 0.0f ); // critical stuff sky->fov = ent->v.fov; } break; case ED_BEAM: ent->v.oldorigin = state->oldorigin; // beam endpoint ent->v.frags = state->gaitsequence; if( state->owner != -1 ) ent->v.owner = GetEntityByIndex( state->owner ); else ent->v.owner = NULL; // add server beam now g_pViewRenderBeams->AddServerBeam( ent ); break; default: ent->v.movedir = Vector( 0, 0, 0 ); break; } int i; // copy blendings for( i = 0; i < MAXSTUDIOBLENDS; i++ ) ent->v.blending[i] = state->blending[i]; // copy controllers for( i = 0; i < MAXSTUDIOCONTROLLERS; i++ ) ent->v.controller[i] = state->controller[i]; // g-cont. moved here because we may needs apply null scale to skyportal if( ent->v.scale == 0.0f && ent->v.skin >= 0 ) ent->v.scale = 1.0f; ent->v.pContainingEntity = ent; }
bool Treasure::Load(File* f) { static int id = TREASURE_START_ID; SetId(id++); Vec3f pos; if (!LoadVec3(f, &pos)) { f->ReportError("Expected position"); return false; } SetPos(pos); std::string tex; if (!f->GetDataLine(&tex)) { f->ReportError("Expected texture filename"); return false; } Vec2i cells; if (!LoadVec2(f, &cells)) { f->ReportError("Expected num cells Vec2"); return false; } if (!f->GetInteger(&m_points)) { f->ReportError("Expected num points"); return false; } // Only if player has not collected treasure in the current room // before! Player* p = GetLocalPlayer(); // Create scene node if no local player yet OR player exists and there is no treasure key for this room if (!p || !(p->Exists(MakeTreasureKey()))) { // Size depends on points value float size = XSIZE * (float)m_points / 500.0f; SpriteNode* sn = new SpriteNode(tex, cells.x, cells.y, size * 0.5f, size * 0.5f); SetSceneNode(sn); sn->GetSprite()->SetCellRange(0, cells.x * cells.y); sn->GetSprite()->SetCell(0); m_glow = new SpriteNode("flare.png", 1, 1, size, size); sn->AddChild(m_glow.GetPtr()); File f; if (!f.OpenRead("fighteffect.txt")) { f.ReportError("Failed to load effect"); Assert(0); } m_sparkle = new AttackEffect; if (!m_sparkle->Load(&f)) { f.ReportError("Failed to load effect"); Assert(0); } sn->AddChild(m_sparkle.GetPtr()); } return true; }
bool HasShownMsg(MsgNum msgNumber) { Player* p = GetLocalPlayer(); std::string key = "shown_msg_" + ToString(msgNumber); return (p->Exists(key)); }