//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CRotDoor::Spawn( void ) { BaseClass::Spawn(); // set the axis of rotation CBaseToggle::AxisDir(); // check for clockwise rotation if ( HasSpawnFlags(SF_DOOR_ROTATE_BACKWARDS) ) m_vecMoveAng = m_vecMoveAng * -1; //m_flWait = 2; who the hell did this? (sjb) m_vecAngle1 = GetLocalAngles(); m_vecAngle2 = GetLocalAngles() + m_vecMoveAng * m_flMoveDistance; ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal\n"); // Starting open allows a func_door to be lighted in the closed position but // spawn in the open position // // SF_DOOR_START_OPEN_OBSOLETE is an old broken way of spawning open that has // been deprecated. if ( HasSpawnFlags(SF_DOOR_START_OPEN_OBSOLETE) ) { // swap pos1 and pos2, put door at pos2, invert movement direction QAngle vecNewAngles = m_vecAngle2; m_vecAngle2 = m_vecAngle1; m_vecAngle1 = vecNewAngles; m_vecMoveAng = -m_vecMoveAng; // We've already had our physics setup in BaseClass::Spawn, so teleport to our // current position. If we don't do this, our vphysics shadow will not update. Teleport( NULL, &m_vecAngle1, NULL ); m_toggle_state = TS_AT_BOTTOM; } else if ( m_eSpawnPosition == FUNC_DOOR_SPAWN_OPEN ) { // We've already had our physics setup in BaseClass::Spawn, so teleport to our // current position. If we don't do this, our vphysics shadow will not update. Teleport( NULL, &m_vecAngle2, NULL ); m_toggle_state = TS_AT_TOP; } else { m_toggle_state = TS_AT_BOTTOM; } #ifdef HL1_DLL SetSolid( SOLID_VPHYSICS ); #endif // Slam the object back to solid - if we really want it to be solid. if ( m_bSolidBsp ) { SetSolid( SOLID_BSP ); } }
void CNetworkPlayer::SetPosition( CVector3 vecPosition, BYTE bMoveStyle, CVector3 vecEndDir ) { DEBUG_TRACE("CNetworkPlayer::SetPosition"); // Store the position m_vecPosition = vecPosition; // Is this the localplayer? if( m_bLocalPlayer ) return Teleport( vecPosition ); // Is the player ped valid? if( m_pPlayerPed && IsSpawned() ) { // Get the current ped position CVector3 vecCurrentPosition; GetPosition( &vecCurrentPosition ); // Teleport to the position if it's too far away if( (vecPosition - vecCurrentPosition).Length() > 20.0f ) return Teleport( vecPosition ); // Find the move style from the control flags M2Enums::eMoveType moveType = M2Enums::eMoveType::E_SPRINT; // Get the engine move style if( bMoveStyle == 0 ) moveType = M2Enums::eMoveType::E_WALK; else if( bMoveStyle == 1 ) moveType = M2Enums::eMoveType::E_JOG; else if( bMoveStyle == 2 ) moveType = M2Enums::eMoveType::E_SPRINT; // Is the old move object still working? /*if ( m_pMoveObject && !m_pMoveObject->IsDone () ) { // Update the target position m_pMoveObject->SetTarget ( vecPosition, E_TYPE_MOVE ); // Update the move object data m_pMoveObject->SetMoveTargetData ( vecEndDir, (BYTE)moveType ); // doesn't work due to memory protection! return; }*/ // Delete the old move object SAFE_DELETE( m_pMoveObject ); // Move the playerped m_pMoveObject = new CM2SyncObject( m_pPlayerPed->MoveVec( vecPosition, moveType, vecEndDir ) ); } }
//-------------------------------------------------------------------------------- // New Selection // -Edit Total // -Extract model to draw //-------------------------------------------------------------------------------- void CFuiMBROS::NewSelection() { char lat[32]; char lon[32]; //----Edit total objects ------------------------- wTOT->EditText("Total objects found: %d",oBOX.GetSize()); CObjLine *lin = (CObjLine*)oBOX.GetSelectedSlot(); if ((Lin == lin) || (0 == lin)) return; //----Set a new world object --------------------- Lin = lin; wObj = 0; CWobj *obj = lin->GetWOBJ(); Mod = obj->GetDayModel(); wObj = obj; globals->wObj = obj; //----Edit object position ----------------------- SPosition pos = obj->GetPosition(); EditLat2DMS(pos.lat,lat); EditLon2DMS(pos.lon,lon); mPOS->EditText("POS: %s %s at=%.0f feet",lat,lon,pos.alt); wOrg->EditText("Origin: %s",obj->GetFileOBJ()); wZbo->SetState(obj->GetZB()); //----Edit object model data --------------------- oINF->BeginPage(); obj->GetInfo(oINF); //--- Set Camera object position ----------------- SetZoom(); Teleport(); return; }
Item* Item::Create(uint16_t _type, uint16_t _subtype /*= 0xFFFF*/) { if(_type == 0) return nullptr; Item* newItem = nullptr; const ItemType& it = item_db[_type]; if(it.id != 0){ if(it.isDepot()) { newItem = newd Depot(_type); } else if(it.isContainer()) { newItem = newd Container(_type); } else if(it.isTeleport()) { newItem = newd Teleport(_type); } else if(it.isDoor()) { newItem = newd Door(_type); } else if(_subtype == 0xFFFF) { if(it.isFluidContainer()) { newItem = newd Item(_type, LIQUID_NONE); } else if(it.isSplash()) { newItem = newd Item(_type, LIQUID_WATER); } else if(it.charges > 0) { newItem = newd Item(_type, it.charges); } else { newItem = newd Item(_type, 1); } } else { newItem = newd Item(_type, _subtype); } } else { newItem = newd Item(_type, _subtype); } return newItem; }
void CPropAPC2::Materialize( void ) { //trace_t tr; //UTIL_TraceHull( m_vOriginalSpawnOrigin, m_vOriginalSpawnOrigin, Vector(-38,-38,-38),Vector(38,38,38), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); //if ( (tr.startsolid || tr.allsolid) && m_iSpawnTry<3 ) //{ // //Try again in a second. // SetContextThink(&QUA_Strider::Materialize, gpGlobals->curtime + 1.0f, "RESPAWNING" ); // SetNextThink( gpGlobals->curtime + 1.0f ); // m_iSpawnTry++; // return; //} SetAbsOrigin( InicialSpawn ); SetAbsAngles( InicialAngle ); KeyValue( "model", "models/combine_apc.mdl" ); KeyValue( "solid", "6" ); KeyValue( "targetname", "elapc" ); KeyValue( "vehiclescript", "scripts/vehicles/apc.txt" ); Teleport( &InicialSpawn, &InicialAngle, NULL ); Spawn(); Activate(); SetThink( &CPropAPC2::Think ); SetNextThink( gpGlobals->curtime); }
void CLocalPlayer::HandleSpawn( bool bRespawn ) { // Are we respawning and not dead? if( bRespawn && !IsDead() ) return; // Have we already just spawned? if( (SharedUtility::GetTime() - m_ulSpawnTime) < 500 ) return; // Set the spawn time m_ulSpawnTime = SharedUtility::GetTime(); // Reset the death time m_ulDeathTime = 0; // Set the state SetState( ePlayerState::PLAYERSTATE_ONFOOT ); // Mark as not dead SetDead( false ); // Mark as spawned SetSpawned( true ); // Are we in a vehicle? if( IsInVehicle() ) { // Handle this enter with the network vehicle m_pVehicle->HandlePlayerExit( this, m_seat, false ); // Reset the vehicle SetVehicle( NULL ); // Reset the seat SetSeat( INVALID_ENTITY_ID ); } // Reset the player position and rotation Teleport ( CVector3() ); SetRotation ( CVector3() ); // Send RPC to server pCore->GetNetworkModule()->Call( RPC_PLAYER_SPAWN, NULL, HIGH_PRIORITY, RELIABLE, true ); // Restore the camera (TODO: Use real game function to reset camera behind player!) pCore->GetCamera()->LockControl ( false ); LockControls ( false ); // Restore the camera control pCore->GetCamera()->LockControl ( bOldCameraState ); // Restore the control state LockControls ( bOldCTRLState ); }
void CGunTarget::Activate( void ) { BaseClass::Activate(); CBaseEntity *pTarg; // now find our next target pTarg = GetNextTarget(); if ( pTarg ) { m_hTargetEnt = pTarg; Vector nextPos = pTarg->GetAbsOrigin(); Teleport( &nextPos, NULL, NULL ); } }
bool SummonAction::Execute(Event event) { Player* master = GetMaster(); if (!master) return false; if (master->GetSession()->GetSecurity() < SEC_GAMEMASTER) { ai->TellMasterNoFacing("You cannot summon me"); return false; } return Teleport(); }
void CNetworkPlayer::SetModel( unsigned int uiModelIndex, bool bRebuild ) { DEBUG_TRACE("CNetworkPlayer::SetModel"); // Store the model index m_uiModelIndex = uiModelIndex; // Is the playerped valid? if( m_pPlayerPed && IsSpawned() && bRebuild ) { // Get the model name and directory String strModel, strDirectory; Game::GetPlayerModelFromId ( uiModelIndex, &strModel, &strDirectory ); // Get the player current vehicle CNetworkVehicle * pCurrentVehicle = GetVehicle (); EntityId iSeat = GetSeat (); // Remove from vehicle if we're in one if( pCurrentVehicle ) RemoveFromVehicle ( pCurrentVehicle ); // Is this the localplayer? if( IsLocalPlayer() ) { // Change the localplayer model m_pPlayerModelManager->ChangeModel ( strDirectory.Get(), strModel.Get() ); } else { // Get position and rotation CVector3 vecPosition, vecRotation; GetPosition ( &vecPosition ); GetRotation ( &vecRotation ); // Create the player ped Create (); // Restore position and rotation Teleport ( vecPosition ); SetRotation ( vecRotation ); } // Put the player back in the vehicle if ( pCurrentVehicle ) PutInVehicle ( pCurrentVehicle, iSeat ); } }
bool colObject::CollisionCallback(const colEvent &collision) { bool handled = false; if ( m_responder ) { handled = m_responder->CollisionCallback( collision ); } if ( !handled ) { SetTransform(collision.collisionTransform); Teleport(); handled = true; } return handled; }
void CAI_Hint::OnRestore() { BaseClass::OnRestore(); m_NodeData.nNodeID = g_pAINetworkManager->GetEditOps()->GetNodeIdFromWCId( m_NodeData.nWCNodeID ); FixupTargetNode(); CAI_Node *pNode = GetNode(); if ( !pNode ) { if ( m_NodeData.nWCNodeID > 0 ) DevMsg("Warning: AI hint has incorrect or no AI node\n"); } else { m_NodeData.vecPosition = pNode->GetOrigin(); Teleport( &m_NodeData.vecPosition, NULL, NULL ); pNode->SetHint( this ); } }
bool UseMeetingStoneAction::Execute(Event event) { Player* master = GetMaster(); if (!master) return false; WorldPacket p(event.getPacket()); p.rpos(0); ObjectGuid guid; p >> guid; if (master->GetSelectedPlayer() && master->GetSelectedPlayer() != bot) return false; if (!master->GetSelectedPlayer() && master->GetGroup() != bot->GetGroup()) return false; if (master->IsBeingTeleported()) return false; if (bot->IsInCombat()) { ai->TellMasterNoFacing("I am in combat"); return false; } Map* map = master->GetMap(); if (!map) return NULL; GameObject *gameObject = map->GetGameObject(guid); if (!gameObject) return false; const GameObjectTemplate* goInfo = gameObject->GetGOInfo(); if (!goInfo || goInfo->type != GAMEOBJECT_TYPE_SUMMONING_RITUAL) return false; return Teleport(); }
void LaserBeam::OnSimulate(float frametime) { BaseClass::OnSimulate(frametime); float laserLength = Camera::GetInstance()->GetWorldMaxs().x - Camera::GetInstance()->GetWorldMins().x; float gameTime = GetGameContext()->GetGameTime(); SetSize(Vector2D(laserLength, LASER_MAX_SIZE_Y)); Entity *owner = GetOwner(); if (owner == nullptr || timer < gameTime) { Remove(); } else { Vector2D center = owner->GetOrigin(); center.x -= laserLength * 0.5f; center += offset; if (!spawned) { Teleport(center); spawned = true; } else { SetOrigin(center); } } if (flashTimer < gameTime) { flashSize = fixedSize; fixedSize = qlerp(qfrand(), LASER_MIN_SIZE_Y, LASER_MAX_SIZE_Y); flashTimer = gameTime + LASER_FLASH_DURATION; } }
void CCharacter::Tick() { if(m_pPlayer->m_ForceBalanced) { char Buf[128]; str_format(Buf, sizeof(Buf), "You were moved to %s due to team balancing", GameServer()->m_pController->GetTeamName(m_pPlayer->GetTeam())); GameServer()->SendBroadcast(Buf, m_pPlayer->GetCID()); m_pPlayer->m_ForceBalanced = false; } m_Core.m_Input = m_Input; m_Core.Tick(true); // handle death-tiles and leaving gamelayer if(GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameLayerClipped(m_Pos)) { Die(m_pPlayer->GetCID(), WEAPON_WORLD); } // handle Weapons HandleWeapons(); for(int i = 0;i <= GameServer()->m_pController->m_EntryCount; i++) { if(absolute((m_Pos-GameServer()->m_pController->TeleportEntries[i]).x) <= 20.0f && absolute((m_Pos-GameServer()->m_pController->TeleportEntries[i]).y) <= 20.0f) { if(GameServer()->m_pController->GetTeleport() != i) Teleport(GameServer()->m_pController->TeleportEntries[GameServer()->m_pController->GetTeleport()]); } } // Previnput m_PrevInput = m_Input; return; }
void Space::HandleEvent( sf::Event &e ) { if( dock.IsActive() ) { dock.HandleEvent( e ); } else { if( e.Type == sf::Event::KeyPressed ) { switch( e.Key.Code ) { case sf::Key::Space: if( satellite.CanTeleport() ) { Teleport(); } break; case sf::Key::A: satellite.ChangeJunk( 10 ); satellite.ChangeCoveted( 10 ); break; default: break; } } } }
void hhHarvesterSimple::Event_ExitPassageway(hhAIPassageway *pn) { if(currPassageway == NULL) { gameLocal.Error("%s tried to EXIT a passageway but did NOT have a curr passageway!", (const char*)name); } HH_ASSERT(currPassageway != NULL); // Store this passageway so we don't jump right back into it. lastPassageway = idEntityPtr<idEntity> (pn); lastPassagewayTime = gameLocal.time; if(GetPhysics()) GetPhysics()->SetContents(CONTENTS_BODY); currPassageway = NULL; AI_ACTIVATED = true; // Sometimes this is NOT true?!?! StopSound(SND_CHANNEL_VOICE, true); // Teleport to new pos idAngles angs = pn->GetAxis().ToAngles(); idVec3 pos = pn->GetExitPos(); Teleport( pos, angs, pn ); Show(); current_yaw = angs.yaw; ideal_yaw = angs.yaw; turnVel = 0.0f; HH_ASSERT(FacingIdeal()); // Exit anim to play? idStr exitAnim = pn->spawnArgs.GetString("exit_anim"); if(exitAnim.Length() && GetAnimator()->HasAnim(exitAnim)) { GetAnimator()->ClearAllAnims(gameLocal.GetTime(), 0); torsoAnim.UpdateState(); legsAnim.UpdateState(); torsoAnim.PlayAnim( GetAnimator()->GetAnim( exitAnim ) ); legsAnim.PlayAnim( GetAnimator()->GetAnim( exitAnim ) ); } }
bool CClientVehicle::Create() { // Are we not already created? if(!IsSpawned()) { // Load the model m_pModelInfo->Load(); // Get the model hash DWORD dwModelHash = m_pModelInfo->GetHash(); // Create vehicle (TODO: Don't use natives for this) unsigned int uiVehicleHandle; InvokeNative<void *>(NATIVE_CREATE_CAR, dwModelHash, 0.0f, 0.0f, 0.0f, &uiVehicleHandle, true); // Create vehicle instance m_pVehicle = new CIVVehicle(CPools::GetVehiclePool()->AtHandle(uiVehicleHandle)); // Set initial colors SetColors(m_byteColors[0], m_byteColors[1], m_byteColors[2], m_byteColors[3]); // Add to world m_pVehicle->AddToWorld(); // Set initial health SetHealth(m_fHealth); // Set initial position Teleport(m_vecPosition); // Set initial rotation SetRotation(m_vecRotation); return true; } // Already created return false; }
void Transporter::TeleportTransport(uint32 newMapid, uint32 oldmap, float x, float y, float z) { //sEventMgr.RemoveEvents(this, EVENT_TRANSPORTER_NEXT_WAYPOINT); RemoveFromWorld(false); SetMapId(newMapid); SetPosition(x, y, z, m_position.o, false); AddToWorld(); WorldPacket packet(SMSG_TRANSFER_PENDING, 12); packet << newMapid; packet << getEntry(); packet << oldmap; for (auto passengerGuid : m_passengers) { auto passenger = objmgr.GetPlayer(passengerGuid); if (passenger == nullptr) continue; passenger->GetSession()->SendPacket(&packet); bool teleport_successful = passenger->Teleport(LocationVector(x, y, z, passenger->GetOrientation()), this->GetMapMgr()); if (!teleport_successful) { passenger->RepopAtGraveyard(passenger->GetPositionX(), passenger->GetPositionY(), passenger->GetPositionZ(), passenger->GetMapId()); } else { if (!passenger->HasUnitMovementFlag(MOVEFLAG_TRANSPORT)) { passenger->AddUnitMovementFlag(MOVEFLAG_TRANSPORT); } } } this->RespawnCreaturePassengers(); }
TeleportWidget::TeleportWidget(QGraphicsScene *scene, ControlPanelManager *control_panel_manager) : QGraphicsProxyWidget(0, Qt::Widget), internal_widget_(new QWidget()), panel_(control_panel_manager) { setupUi(internal_widget_); setWidget(internal_widget_); setZValue(100); visibility_animation_ = new QPropertyAnimation(this, "opacity", this); visibility_animation_->setDuration(500); visibility_animation_->setEasingCurve(QEasingCurve::InOutSine); visibility_animation_->setStartValue(0); visibility_animation_->setEndValue(1); connect(teleportPushButton, SIGNAL(clicked()), this, SLOT(Teleport())); connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(Cancel())); connect(visibility_animation_, SIGNAL(finished()), SLOT(AnimationsFinished())); hide(); scene->addItem(this); connect(scene, SIGNAL(sceneRectChanged(const QRectF&)), SLOT(SceneRectChanged(const QRectF&))); }
void CClientVehicle::StreamIn() { // Attempt to create the vehicle if(Create()) { // Set the position Teleport(m_vecPosition); // Set the rotation SetRotation(m_vecRotation); // Set the move speed SetMoveSpeed(m_vecMoveSpeed); // Set the turn speed SetTurnSpeed(m_vecTurnSpeed); // Set the colors SetColors(m_byteColors[0], m_byteColors[1], m_byteColors[2], m_byteColors[3]); // Set the health SetHealth(m_fHealth); } }
void CRotDoor :: Spawn( void ) { // set the axis of rotation AxisDir( pev ); if( FBitSet( pev->spawnflags, SF_DOOR_PASSABLE )) pev->solid = SOLID_NOT; else pev->solid = SOLID_BSP; Precache(); // check for clockwise rotation if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS )) pev->movedir = pev->movedir * -1; m_vecAngle1 = GetLocalAngles(); m_vecAngle2 = GetLocalAngles() + pev->movedir * m_flMoveDistance; ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal" ); pev->movetype = MOVETYPE_PUSH; SET_MODEL( edict(), GetModel() ); // NOTE: original Half-Life was contain a bug in AngularMove function // while m_flWait was equal 0 then object has stopped forever. See code from quake: /* void AngularMove( Vector vecDest, float flSpeed ) { ... ... ... if( flTravelTime < 0.1f ) { pev->avelocity = g_vecZero; pev->nextthink = pev->ltime + 0.1f; return; } } */ // this block was removed from Half-Life and there no difference // between wait = 0 and wait = -1. But in Xash this bug was fixed // and level-designer errors is now actual. I'm set m_flWait to -1 for compatibility if( m_flWait == 0.0f ) m_flWait = -1; if( pev->speed == 0 ) pev->speed = 100; // DOOR_START_OPEN is to allow an entity to be lighted in the closed position // but spawn in the open position if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN )) { // swap pos1 and pos2, put door at pos2, invert movement direction Vector vecNewAngles = m_vecAngle2; m_vecAngle2 = m_vecAngle1; m_vecAngle1 = vecNewAngles; pev->movedir = pev->movedir * -1; // We've already had our physics setup in BaseClass::Spawn, so teleport to our // current position. If we don't do this, our vphysics shadow will not update. Teleport( NULL, &m_vecAngle1, NULL ); } else { SetLocalAngles( m_vecAngle1 ); } m_iState = STATE_OFF; RelinkEntity(); m_pUserData = WorldPhysic->CreateKinematicBodyFromEntity( this ); if( FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY )) { SetTouch( NULL ); } else { // touchable button SetTouch( DoorTouch ); } }
bool CCheatMgr::Process( CheatCode nCheatCode, CParsedMsgW const& cMsg ) { if ( nCheatCode <= CHEAT_NONE || nCheatCode >= CHEAT_MAX ) return false; #ifdef _FINAL // Don't do cheats in multiplayer... if (IsMultiplayerGameClient()) { // Well, okay, let them toggle between 1st and 3rd person ;) // and, well, blood is pretty cool... switch ( nCheatCode ) { case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // boot players BootPlayer(cMsg); break; default : return false; break; } m_bPlayerCheated = true; return true; } #else // _FINAL // Only allow cheats in MP if console variable turned on. if( IsMultiplayerGameClient( )) { float fVal = 0.0f; g_pLTClient->GetSConValueFloat( "AllowMPCheats", fVal ); bool bAllowMPCheats = fVal != 0.0f; if( !bAllowMPCheats ) return false; } #endif // _FINAL // process cheat codes switch ( nCheatCode ) { case CHEAT_GOD: // god mode toggle SetGodMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_ARMOR: // full armor SetArmor(); break; case CHEAT_HEALTH: // full health SetHealth(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_VERSION: // display version info Version(); break; case CHEAT_INVISIBLE: // time to mess with the AI SetInvisible(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_BODYGOLFING: // bodies fly far //currently unimplemented... // BodyGolfing(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS: // show/hide player position SetPos(!s_CheatInfo[nCheatCode].bActive); break; #ifndef _DEMO case CHEAT_KFA: // give em everything SetKFA(); break; case CHEAT_AMMO: // full ammo SetAmmo(); break; case CHEAT_MODSQUAD: // give all mods for current weapons ModSquad(); break; case CHEAT_CONSOLE: SetConsole(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // exit the current mission BootPlayer(cMsg); break; case CHEAT_FULL_WEAPONS: // give all weapons SetFullWeapons(); break; case CHEAT_FULL_GEAR: // give all gear FullGear(); break; case CHEAT_TEARS: // toggle tears cheat Tears(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_GIMMEGUN: GimmeGun( cMsg ); break; case CHEAT_GIMMEMOD: GimmeMod( cMsg ); break; case CHEAT_GIMMEGEAR: GimmeGear( cMsg ); break; case CHEAT_GIMMEAMMO: GimmeAmmo( cMsg ); break; case CHEAT_ENDGAME: ToggleEndgameFlag(); break; #ifndef _FINAL case CHEAT_CHASETOGGLE: // toggle 3rd person view ChaseToggle(); break; case CHEAT_CLIP: // toggle clipping mode SetClipMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TELEPORT: // teleport to beginning Teleport(); break; case CHEAT_CAM_POSROT: // show/hide camera position/rotation SetCamPosRot(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON: // toggle adjust of weapon pos PosWeapon(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_REMOVEAI: // remove all ai RemoveAI(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TRIGGERBOX: // toggle trigger boxes on/off TriggerBox(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS1STCAM: // toggle 1st person camera adjust on/off Pos1stCam(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_SAVEVEHICLE: // save the vehicle tweaks to the bute file SaveVehicle( ); break; #endif // _FINAL #endif // _DEMO default: return false; // skip setting global cheat indicator for unhandled cheats } m_bPlayerCheated = true; return true; }
void CLocalPlayer::Pulse( void ) { // Are we experiencing connection trouble? if ( IsSpawned() && (SharedUtility::GetTime() - m_ulLastPingTime) > 6000 ) pCore->SetConnectionProblem ( true ); // Get our current position and rotation CVector3 vecCurrentPosition, vecCurrentRotation; GetPosition( &vecCurrentPosition ); GetRotation( &vecCurrentRotation ); // Is our position or rotation invalid? if ( !Math::IsValidVector ( vecCurrentPosition ) || !Math::IsValidVector ( vecCurrentRotation ) ) { CLogFile::Printf ( "ERROR - Player position or rotation was invalid. Warped back to the last good saved state." ); // Warp the player back to their last good saved position and rotation Teleport ( m_vecLastGoodPosition ); SetRotation ( m_vecLastGoodRotation ); // Is the last good state invalid? if ( !Math::IsValidVector ( m_vecLastGoodPosition ) || !Math::IsValidVector ( m_vecLastGoodRotation ) ) { // Fade hud and sound quickly pCore->GetHud()->FadeOut ( 0 ); pCore->GetGame()->FadeSound ( true, 0 ); // Reset position Teleport ( CVector3() ); SetRotation ( CVector3() ); // Kill the player SetHealth ( 0.0f ); } // Return so we don't overwrite the last good position with invalid positions return; } // Save this current position and rotation memcpy ( &m_vecLastGoodPosition, &vecCurrentPosition, sizeof ( CVector3 ) ); memcpy ( &m_vecLastGoodRotation, &vecCurrentRotation, sizeof ( CVector3 ) ); // Do we need a full sync? if( IsFullSyncNeeded () ) { // Are we not in a vehicle? if( !InternalIsInVehicle() ) { // Send onfoot sync data SendOnFootSync(); } else { // Are we the vehicle driver? if( GetState() == PLAYERSTATE_DRIVER ) { // Send invehicle sync data SendInVehicleSync(); } // Send passenger sync data SendPassengerSync(); } } // Are we spawned and not dead? if( IsSpawned() && ((SharedUtility::GetTime() - m_ulSpawnTime) > 5000) && !IsDead() ) { // Are we falling below the map? if( vecCurrentPosition.fZ <= -150.0f ) { // Kill ourself SetHealth( 0.0f ); } } // Have we been dead for 3 seconds? if ( (SharedUtility::GetTime() - m_ulDeathTime) > 4000 && IsDead() ) { // Deactivate the player ped m_pPlayerPed->Deactivate (); // Respawn HandleSpawn ( true ); // Fade the hud back in pCore->GetHud()->FadeIn ( 1000 ); // Fade the sound back in pCore->GetGame()->FadeSound ( false, 1 ); // Activate the player ped m_pPlayerPed->Activate (); } // Are we spawned, in a vehicle and typing? if( IsSpawned() && IsInVehicle() && pCore->GetChat()->IsInputVisible() ) { // Reset the vehicle steering (prevent car turning to sides) if( m_pVehicle->GetVehicle() ) m_pVehicle->GetVehicle()->AddSteer( 0.0f ); } // Loop over all vehicles we're syncing //for( std::list< CNetworkVehicle* >::iterator iter = m_syncingVehicles.begin(); iter != m_syncingVehicles.end(); iter++ ) //{ // Send the vehicle sync for this vehicle // SendUnoccupiedVehicleSync( *iter ); //} }
bool CCheatMgr::Process( CheatCode nCheatCode, CParsedMsg &cMsg ) { if ( nCheatCode <= CHEAT_NONE || nCheatCode >= CHEAT_MAX ) return false; #ifdef _FINAL // Don't do cheats in multiplayer... if (IsMultiplayerGame()) { // Well, okay, let them toggle between 1st and 3rd person ;) // and, well, blood is pretty cool... switch ( nCheatCode ) { case CHEAT_CHASETOGGLE: ChaseToggle(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // boot players BootPlayer(cMsg); break; default : return false; break; } m_bPlayerCheated = LTTRUE; return true; } #endif // _FINAL // process cheat codes switch ( nCheatCode ) { case CHEAT_GOD: // god mode toggle SetGodMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_SKILLZ: // give em skill points GetSkills(); break; case CHEAT_ARMOR: // full armor SetArmor(); break; case CHEAT_HEALTH: // full health SetHealth(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_VERSION: // display version info Version(); break; case CHEAT_BUILDGUID: // display build guid BuildGuid(); break; case CHEAT_INVISIBLE: // time to mess with the AI SetInvisible(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_BODYGOLFING: // bodies fly far BodyGolfing(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS: // show/hide player position SetPos(!s_CheatInfo[nCheatCode].bActive); break; #ifndef _TO2DEMO case CHEAT_KFA: // give em everything SetKFA(); break; case CHEAT_AMMO: // full ammo SetAmmo(); break; case CHEAT_MODSQUAD: // give all mods for current weapons ModSquad(); break; case CHEAT_CONSOLE: SetConsole(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // exit the current mission BootPlayer(cMsg); break; case CHEAT_FULL_WEAPONS: // give all weapons SetFullWeapons(); break; case CHEAT_SNOWMOBILE: // spawn in snowmobile Snowmobile(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_FULL_GEAR: // give all gear FullGear(); break; case CHEAT_TEARS: // toggle tears cheat Tears(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_GIMMEGUN: GimmeGun( cMsg ); break; case CHEAT_GIMMEMOD: GimmeMod( cMsg ); break; case CHEAT_GIMMEGEAR: GimmeGear( cMsg ); break; case CHEAT_GIMMEAMMO: GimmeAmmo( cMsg ); break; case CHEAT_ENDGAME: ToggleEndgameFlag(); break; #ifndef _FINAL case CHEAT_CHASETOGGLE: // toggle 3rd person view ChaseToggle(); break; case CHEAT_CLIP: // toggle clipping mode SetClipMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TELEPORT: // teleport to beginning Teleport(); break; case CHEAT_CAM_POSROT: // show/hide camera position/rotation SetCamPosRot(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON: // toggle adjust of weapon pos PosWeapon(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON_MUZZLE: // toggle adjust of weapon muzzle pos PosWeaponMuzzle(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_WEAPON_BREACHOFFSET: // toggle adjust of weapon breach offset pos WeaponBreachOffset(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_LIGHTSCALE: // toggle client light scale offset LightScale(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_LIGHTADD: // toggle client light add offset LightAdd(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_FOV: // toggle fov cheat FOV(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_REMOVEAI: // remove all ai RemoveAI(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TRIGGERBOX: // toggle trigger boxes on/off TriggerBox(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS1STCAM: // toggle 1st person camera adjust on/off Pos1stCam(!s_CheatInfo[nCheatCode].bActive); break; #endif // _FINAL #endif // _TO2DEMO default: return false; // skip setting global cheat indicator for unhandled cheats } m_bPlayerCheated = LTTRUE; return true; }
void CASW_Parasite::InfestMarine(CASW_Marine* pMarine) { if ( !pMarine ) return; pMarine->BecomeInfested(this); // attach int attachment = pMarine->LookupAttachment( "chest" ); if ( attachment ) { SetSolid( SOLID_NONE ); SetMoveType( MOVETYPE_NONE ); QAngle current(0,0,0); Vector diff = pMarine->GetAbsOrigin() - GetAbsOrigin(); float angle = UTIL_VecToYaw(diff); angle -= pMarine->GetAbsAngles()[YAW]; // get the diff between our angle from the marine and the marine's facing; current = GetAbsAngles(); Vector vAttachmentPos; pMarine->GetAttachment( attachment, vAttachmentPos ); // Make sure it's near the chest attachement before parenting Teleport( &vAttachmentPos, &vec3_angle, &vec3_origin ); SetParent( pMarine, attachment ); float flRaise = RandomFloat( 15.0f, 18.0f ); float flForward = RandomFloat( -3.0f, 0.0f ); float flSide = RandomFloat( 1.75f, 3.0f ) * ( RandomInt( 0, 1 ) == 0 ? 1.0f : -1.0f ); if ( asw_debug_alien_damage.GetBool() ) { Msg( "INFEST: flRaise = %f flForward = %f flSide = %f yaw = %f\n", flRaise, flForward, flSide, angle + asw_infest_angle.GetFloat() ); } SetLocalOrigin( Vector( flForward, flSide, flRaise ) ); SetLocalAngles( QAngle( asw_infest_pitch.GetFloat(), angle + asw_infest_angle.GetFloat(), 0 ) ); // play our infesting anim if ( asw_parasite_inside.GetBool() ) { SetActivity(ACT_RANGE_ATTACK2); } else { int iInfestAttack = LookupSequence("Infest_attack"); if (GetSequence() != iInfestAttack) { ResetSequence(iInfestAttack); } } AddFlag( FL_NOTARGET ); SetThink( &CASW_Parasite::InfestThink ); SetTouch( NULL ); m_bInfesting = true; } else { FinishedInfesting(); } }
void CASW_Parasite::InfestColonist(CASW_Colonist* pColonist) { if (m_bDefanged || !pColonist) // no infesting if we've been defanged return; if (!IsOnFire()) // don't actually infest if we're on fire, since we'll die very shortly pColonist->BecomeInfested(this); // attach int attachment = pColonist->LookupAttachment( "chest" ); if ( attachment ) { //SetAbsAngles( GetOwnerEntity()->GetAbsAngles() ); SetSolid( SOLID_NONE ); SetMoveType( MOVETYPE_NONE ); QAngle current(0,0,0); Vector diff = pColonist->GetAbsOrigin() - GetAbsOrigin(); float angle = UTIL_VecToYaw(diff); angle -= pColonist->GetAbsAngles()[YAW]; // get the diff between our angle from the marine and the marine's facing; current = GetAbsAngles(); Vector vAttachmentPos; pColonist->GetAttachment( attachment, vAttachmentPos ); Teleport( &vAttachmentPos, &vec3_angle, &vec3_origin ); SetParent( pColonist, attachment ); Vector vecPosition; float flRaise = RandomFloat( 12.0f, 15.0f ); float flForward = RandomFloat( -1.0f, 0.0f ); float flSide = RandomFloat( 0.0f, 0.2f ) * ( RandomInt( 0, 1 ) == 0 ? 1.0f : -1.0f ); SetLocalOrigin( Vector( flForward, flSide, flRaise ) ); SetLocalAngles( QAngle( asw_infest_pitch.GetFloat(), angle + asw_infest_angle.GetFloat(), 0 ) ); // play our infesting anim if ( asw_parasite_inside.GetBool() ) { SetActivity(ACT_RANGE_ATTACK2); } else { int iInfestAttack = LookupSequence("Infest_attack"); if (GetSequence() != iInfestAttack) { ResetSequence(iInfestAttack); } } // don't do anymore thinking - need to think still to animate? AddFlag( FL_NOTARGET ); SetThink( &CASW_Parasite::InfestThink ); SetTouch( NULL ); m_bInfesting = true; } else { FinishedInfesting(); } }
static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params) { static bool s_slap_supported = false; static bool s_slap_setup = false; static ICallWrapper *s_teleport = NULL; static int s_health_offs = 0; static int s_sound_count = 0; static int s_frag_offs = 0; if (!s_slap_setup) { int tries = 0; s_slap_setup = true; if (IsTeleportSupported()) { tries++; } if (IsGetVelocitySupported()) { tries++; } /* Setup health */ if (g_pGameConf->GetOffset("m_iHealth", &s_health_offs) && s_health_offs) { tries++; } if (tries == 3) { s_slap_supported = true; const char *key; if ((key = g_pGameConf->GetKeyValue("SlapSoundCount")) != NULL) { s_sound_count = atoi(key); } } } if (!s_slap_supported) { return pContext->ThrowNativeError("This function is not supported on this mod"); } /* First check if the client is valid */ int client = params[1]; IGamePlayer *player = playerhelpers->GetGamePlayer(client); if (!player) { return pContext->ThrowNativeError("Client %d is not valid", client); } else if (!player->IsInGame()) { return pContext->ThrowNativeError("Client %d is not in game", client); } edict_t *pEdict = player->GetEdict(); CBaseEntity *pEntity = pEdict->GetUnknown()->GetBaseEntity(); /* See if we should be taking away health */ bool should_slay = false; if (params[2]) { #if SOURCE_ENGINE != SE_DARKMESSIAH int *health = (int *)((char *)pEntity + s_health_offs); if (*health - params[2] <= 0) { *health = 1; should_slay = true; } else { *health -= params[2]; } #else float *health = (float *)((char *)pEntity + s_health_offs); if (*health - (float)params[2] <= 0) { *health = 1.0f; should_slay = true; } else { *health -= (float)params[2]; } #endif } /* Teleport in a random direction - thank you, Mani!*/ Vector velocity; GetVelocity(pEntity, &velocity, NULL); velocity.x += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1 : 1); velocity.y += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1 : 1); velocity.z += rand() % 200 + 100; Teleport(pEntity, NULL, NULL, &velocity); /* Play a random sound */ if (params[3] && s_sound_count > 0) { char name[48]; const char *sound_name; cell_t player_list[256], total_players = 0; int maxClients = playerhelpers->GetMaxClients(); int r = (rand() % s_sound_count) + 1; snprintf(name, sizeof(name), "SlapSound%d", r); if ((sound_name = g_pGameConf->GetKeyValue(name)) != NULL) { IGamePlayer *other; for (int i=1; i<=maxClients; i++) { other = playerhelpers->GetGamePlayer(i); if (other->IsInGame()) { player_list[total_players++] = i; } } const Vector & pos = pEdict->GetCollideable()->GetCollisionOrigin(); CellRecipientFilter rf; rf.SetToReliable(true); rf.Initialize(player_list, total_players); engsound->EmitSound(rf, client, CHAN_AUTO, sound_name, VOL_NORM, ATTN_NORM, 0, PITCH_NORM, &pos); } } if (!s_frag_offs) { const char *frag_prop = g_pGameConf->GetKeyValue("m_iFrags"); if (frag_prop) { datamap_t *pMap = gamehelpers->GetDataMap(pEntity); typedescription_t *pType = gamehelpers->FindInDataMap(pMap, frag_prop); if (pType != NULL) { s_frag_offs = pType->fieldOffset[TD_OFFSET_NORMAL]; } } if (!s_frag_offs) { s_frag_offs = -1; } } int old_frags = 0; if (s_frag_offs > 0) { old_frags = *(int *)((char *)pEntity + s_frag_offs); } /* Force suicide */ if (should_slay) { pluginhelpers->ClientCommand(pEdict, "kill\n"); } if (s_frag_offs > 0) { *(int *)((char *)pEntity + s_frag_offs) = old_frags; } return 1; }