void Camera::Update() { LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray; g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME,objArray); int numObjects = objArray.NumObjects(); for (int i = 0; i < numObjects; i++ ) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(objArray.GetObject(i)); if (pPlayer) { HCLIENT hClient = pPlayer->GetClient(); if (hClient) { g_pLTServer->SetClientViewPos(hClient, &vPos); } } } if (m_fActiveTime > 0.0f && g_pLTServer->GetTime() > m_fTurnOffTime) { TurnOff(); } else { SetNextUpdate(UPDATE_NEXT_FRAME); } }
void CProjectile::AddSpecialFX() { if (!g_pWeaponMgr) return; // If this is a player object, get the client id... uint8 nShooterId = -1; if (IsPlayer(m_hFiredFrom)) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(m_hFiredFrom); if (pPlayer) { nShooterId = (uint8) g_pLTServer->GetClientID(pPlayer->GetClient()); } } // Create a special fx... HMESSAGEWRITE hMessage = g_pLTServer->StartSpecialEffectMessage(this); g_pLTServer->WriteToMessageByte(hMessage, SFX_PROJECTILE_ID); g_pLTServer->WriteToMessageByte(hMessage, m_pWeaponData->nId); g_pLTServer->WriteToMessageByte(hMessage, m_pAmmoData->nId); g_pLTServer->WriteToMessageByte(hMessage, nShooterId); g_pLTServer->EndMessage(hMessage); }
void GearItem::PickedUp(ILTMessage_Read *pMsg) { // Did we really pick it up? bool bPickedUp = (pMsg ? pMsg->Readbool() : true); // If we were touched by a player, our m_hPlayerObj data member will be // set. Send a message to that player's client letting it know that an // item has been picked up... if (m_hPlayerObj) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(m_hPlayerObj); if (pPlayer && !pPlayer->IsDead()) { HCLIENT hClient = pPlayer->GetClient(); if (hClient) { CAutoMessage cMsg; cMsg.Writeuint8(MID_GEAR_PICKEDUP); cMsg.Writeuint8((uint8)m_nGearId); cMsg.Writebool(bPickedUp); g_pLTServer->SendToClient(cMsg.Read(), hClient, MESSAGE_GUARANTEED); } } } if (bPickedUp) { PickupItem::PickedUp(pMsg); if( m_bRespawn ) { GEAR const *pGear = g_pWeaponMgr->GetGear( m_nGearId ); if( !pGear ) return; // Change the skins and renderstyles to the waiting to respawn files... ObjectCreateStruct ocs; pGear->blrRespawnWaitSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 ); pGear->blrRespawnWaitRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 ); if( pGear->blrRespawnWaitRenderStyles.GetNumItems() < 1 ) LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS )); g_pCommonLT->SetObjectFilenames( m_hObject, &ocs ); // Stop playing PowerupFX and play RespawnWaitFX... SetClientFX( pGear->szRespawnWaitFX ); // Set our visibility... g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags, pGear->bRespawnWaitVisible ? FLAG_VISIBLE : 0, FLAG_VISIBLE ); g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags2, pGear->bRespawnWaitTranslucent ? FLAG2_FORCETRANSLUCENT : 0, FLAG2_FORCETRANSLUCENT ); } } }
void ScreenShake::Update() { if (--m_nNumShakes > 0) { SetNextUpdate(m_hObject, m_fFrequency); } LTVector vMyPos; g_pLTServer->GetObjectPos(m_hObject, &vMyPos); // Play sound... if (m_hstrSound) { char* pSound = g_pLTServer->GetStringData(m_hstrSound); g_pServerSoundMgr->PlaySoundFromPos(vMyPos, pSound, m_fSoundRadius, SOUNDPRIORITY_MISC_LOW); } // Time to shake. Get all the players in the area of effect... ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray; g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME, objArray); int numObjects = objArray.NumObjects(); if (!numObjects) return; for (int i = 0; i < numObjects; i++) { HOBJECT hObject = objArray.GetObject(i); if (hObject && IsPlayer(hObject)) { // Make sure object is in area of effect... LTVector vPlayerPos; g_pLTServer->GetObjectPos(hObject, &vPlayerPos); if (m_fAreaOfEffect == c_fENTIRE_LEVEL || VEC_DIST(vPlayerPos, vMyPos) <= m_fAreaOfEffect) { CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject); if (pPlayer) { HCLIENT hClient = pPlayer->GetClient(); if (hClient) { HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_SHAKE_SCREEN); g_pLTServer->WriteToMessageVector(hMessage, &m_vAmount); g_pLTServer->EndMessage(hMessage); } } } } } }
void CInvItem::SendActionMessage() { HMESSAGEWRITE hWrite; HCLIENT hClient; CPlayerObj *pObj; DBYTE nVal; if( IsPlayer( m_hOwner )) { pObj = ( CPlayerObj * )g_pServerDE->HandleToObject(m_hOwner); hClient = pObj->GetClient( ); hWrite = g_pServerDE->StartMessage( hClient, SMSG_INVITEMACTION ); nVal = GetType( ); if( m_bIsActive ) nVal |= 0x80; g_pServerDE->WriteToMessageByte( hWrite, nVal ); g_pServerDE->EndMessage2( hWrite, MESSAGE_GUARANTEED | MESSAGE_NAGGLE ); } }
void GearItem::PickedUp(HMESSAGEREAD hRead) { // If we were touched by a player, our m_hPlayerObj data member will be // set. Send a message to that player's client letting it know that an // item has been picked up... if (m_hPlayerObj) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(m_hPlayerObj); if (pPlayer && !pPlayer->IsDead()) { HCLIENT hClient = pPlayer->GetClient(); if (hClient) { HMESSAGEWRITE hWrite = g_pLTServer->StartMessage(hClient, MID_GEAR_PICKEDUP); g_pLTServer->WriteToMessageByte(hWrite, m_nGearId); g_pLTServer->EndMessage(hWrite); } } } PickupItem::PickedUp(hRead); }
void CProjectile::AddImpact(HOBJECT hObj, LTVector vFirePos, LTVector vImpactPos, LTVector vSurfaceNormal, SurfaceType eType) { // Create the client side weapon fx... CLIENTWEAPONFX fxStruct; fxStruct.hFiredFrom = m_hFiredFrom; fxStruct.vSurfaceNormal = vSurfaceNormal; fxStruct.vFirePos = vFirePos; fxStruct.vPos = vImpactPos + (m_vDir * -1.0f); fxStruct.hObj = hObj; fxStruct.nWeaponId = m_pWeaponData->nId; fxStruct.nAmmoId = m_pAmmoData->nId; fxStruct.nSurfaceType = eType; fxStruct.wIgnoreFX = g_wIgnoreFX; // Always use the flash position for the first call to AddImpact... if (m_bNumCallsToAddImpact == 0) { fxStruct.vFirePos = m_vFlashPos; } // If we do multiple calls to AddImpact, make sure we only do some // effects once :) g_wIgnoreFX |= WFX_SHELL | WFX_LIGHT | WFX_MUZZLE; // Allow exit surface fx on the next call to AddImpact... g_wIgnoreFX &= ~WFX_EXITSURFACE; if (IsMoveable(hObj)) { // Well, don't do too many exit marks...The server will add one // if necessary... g_wIgnoreFX |= WFX_EXITMARK; } // If this is a player object, get the client id... if (IsPlayer(m_hFiredFrom)) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(m_hFiredFrom); if (pPlayer) { fxStruct.nShooterId = (uint8) g_pLTServer->GetClientID(pPlayer->GetClient()); } } CreateClientWeaponFX(fxStruct); // Do the area and progressive (over time) damage... if ((m_pAmmoData->nAreaDamage > 0.0f && eType != ST_SKY) || m_pAmmoData->fProgDamageLifetime > 0.0f) { AddExplosion(vImpactPos, vSurfaceNormal); } // Update Character fire info... if (m_hFiredFrom && IsCharacter(m_hFiredFrom) && CanSetLastFireInfo()) { CCharacter* pChar = (CCharacter*)g_pLTServer->HandleToObject(m_hFiredFrom); if (pChar) { CharFireInfo info; info.hObject = hObj; info.vFiredPos = m_vFlashPos; // Use initial flash pos info.vImpactPos = vImpactPos; info.nWeaponId = m_pWeaponData->nId; info.nAmmoId = m_pAmmoData->nId; info.fTime = g_pLTServer->GetTime(); info.bSilenced = m_bSilenced; info.eSurface = eType; pChar->SetLastFireInfo(&info); } } m_bNumCallsToAddImpact++; }
void Body::Init(const BODYINITSTRUCT& bi) { if (!bi.pCharacter || !bi.pCharacter->m_hObject) return; // Get the death type etc m_eDeathType = bi.pCharacter->GetDeathType(); m_eModelId = bi.pCharacter->GetModelId(); m_eModelSkeleton = bi.pCharacter->GetModelSkeleton(); m_eModelStyle = bi.pCharacter->GetModelStyle(); // Get the body lifetime m_fLifetime = bi.fLifetime; // Create the SFX BODYCREATESTRUCT bcs; bcs.eBodyState = bi.eBodyState; if (IsPlayer(bi.pCharacter->m_hObject)) { CPlayerObj* pPlayer = (CPlayerObj*) bi.pCharacter; bcs.nClientId = (uint8) g_pLTServer->GetClientID(pPlayer->GetClient()); } HMESSAGEWRITE hMessage = g_pLTServer->StartSpecialEffectMessage(this); g_pLTServer->WriteToMessageByte(hMessage, SFX_BODY_ID); bcs.Write(g_pLTServer, hMessage); g_pLTServer->EndMessage(hMessage); // Create the death scene CreateDeathScene(bi.pCharacter); // We'll handle creating the necessary debris... m_damage.m_bCreatedDebris = LTTRUE; m_damage.SetCanDamage(LTFALSE);//bi.pCharacter->CanDamageBody()); m_damage.SetApplyDamagePhysics(LTFALSE);//bi.pCharacter->CanDamageBody()); m_damage.SetMass(g_pModelButeMgr->GetModelMass(m_eModelId)); // Let us get hit by decay powder m_damage.ClearCantDamageTypes(DamageTypeToFlag(DT_GADGET_DECAYPOWDER)); switch ( g_pModelButeMgr->GetModelType(m_eModelId) ) { case eModelTypeVehicle: { m_eDeathType = CD_GIB; } break; } CDestructible* pDest = bi.pCharacter->GetDestructible(); if (pDest) { m_eDamageType = pDest->GetDeathType(); VEC_COPY(m_vDeathDir, pDest->GetDeathDir()); VEC_NORM(m_vDeathDir); VEC_MULSCALAR(m_vDeathDir, m_vDeathDir, 1.0f + (pDest->GetDeathDamage() / pDest->GetMaxHitPoints())); } LTFLOAT fHitPts = pDest->GetMaxHitPoints(); m_damage.Reset(fHitPts, 0.0f); m_damage.SetHitPoints(fHitPts); m_damage.SetMaxHitPoints(fHitPts); m_damage.SetArmorPoints(0.0f); m_damage.SetMaxArmorPoints(0.0f); // Copy our user flags over, setting our surface type to flesh uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(m_hObject) | USRFLG_NIGHT_INFRARED; dwUsrFlags |= SurfaceToUserFlag(ST_FLESH); g_pLTServer->SetObjectUserFlags(m_hObject, dwUsrFlags); // Make sure model doesn't slide all over the place... g_pLTServer->SetFrictionCoefficient(m_hObject, 500.0f); LTVector vDims; g_pLTServer->GetObjectDims(bi.pCharacter->m_hObject, &vDims); // Set the dims. If we can't set the dims that big, set them // as big as possible... if (g_pLTServer->SetObjectDims2(m_hObject, &vDims) == LT_ERROR) { g_pLTServer->SetObjectDims2(m_hObject, &vDims); } // Create the box used for weapon impact detection... CreateHitBox(bi); LTFLOAT r, g, b, a; g_pLTServer->GetObjectColor(bi.pCharacter->m_hObject, &r, &g, &b, &a); g_pLTServer->SetObjectColor(m_hObject, r, g, b, a); LTVector vScale; g_pLTServer->GetObjectScale(bi.pCharacter->m_hObject, &vScale); g_pLTServer->ScaleObject(m_hObject, &vScale); // Copy our animation over HMODELANIM hAni = g_pLTServer->GetModelAnimation(bi.pCharacter->m_hObject); g_pLTServer->SetModelAnimation(m_hObject, hAni); g_pLTServer->SetModelLooping(m_hObject, LTFALSE); // Copy the flags from the character to us uint32 dwFlags = g_pLTServer->GetObjectFlags(bi.pCharacter->m_hObject); m_dwFlags |= FLAG_REMOVEIFOUTSIDE; g_pLTServer->SetObjectFlags(m_hObject, dwFlags); // Move the attachments aggregate from the char to us... if (!m_pAttachments && bi.eBodyState != eBodyStateLaser) { m_hWeaponItem = bi.pCharacter->TransferWeapon(m_hObject); // Make sure we're playing the correct ani... if (m_hWeaponItem) { uint32 dwAni = g_pLTServer->GetAnimIndex(m_hWeaponItem, "Hand"); if (dwAni != INVALID_ANI) { g_pLTServer->SetModelAnimation(m_hWeaponItem, dwAni); g_pLTServer->SetModelLooping(m_hWeaponItem, LTFALSE); } } } if (!m_pAttachments) { m_pAttachments = bi.pCharacter->TransferAttachments(); if (m_pAttachments) { AddAggregate(m_pAttachments); m_pAttachments->ReInit(m_hObject); } } // Set up the spears bi.pCharacter->TransferSpears(this); // Set our state SetState(bi.eBodyState); }
void CTO2GameServerShell::Update(LTFLOAT timeElapsed) { // Update the main server first CGameServerShell::Update(timeElapsed); m_VersionMgr.Update(); if (!GetServerDir()) return; //if we're hosting LANOnly game, don't publish the server if( m_ServerGameOptions.m_bLANOnly ) return; // Are we still waiting? static std::string status; switch (GetServerDir()->GetCurStatus()) { case IServerDirectory::eStatus_Processing : status =""; break; case IServerDirectory::eStatus_Waiting : if (status.empty()) status = GetServerDir()->GetLastRequestResultString(); break; case IServerDirectory::eStatus_Error : { IServerDirectory::ERequest eErrorRequest = GetServerDir()->GetLastErrorRequest(); status = GetServerDir()->GetLastRequestResultString(); GetServerDir()->ProcessRequestList(); } break; }; // Publish the server if we've waited long enough since the last directory update uint32 nCurTime = (uint32)GetTickCount(); if ((m_nLastPublishTime == 0) || ((nCurTime - m_nLastPublishTime) > k_nRepublishDelay)) { status = ""; m_nLastPublishTime = nCurTime; uint32 nMax = 0; g_pLTServer->GetMaxConnections(nMax); // If not run by a dedicated server, we need to add one connection // for the local host. if( !m_ServerGameOptions.m_bDedicated ) nMax++; GetServerDir()->SetActivePeer(0); CAutoMessage cMsg; // Update the summary info cMsg.WriteString(GetHostName()); GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Name, *cMsg.Read()); char fname[_MAX_FNAME] = ""; _splitpath( GetCurLevel(), NULL, NULL, fname, NULL ); // Update the summary info cMsg.WriteString(g_pVersionMgr->GetBuild()); cMsg.WriteString( fname ); cMsg.Writeuint8(GetNumPlayers()); cMsg.Writeuint8(nMax); cMsg.Writebool(m_ServerGameOptions.m_bUsePassword); cMsg.Writeuint8((uint8)GetGameType()); cMsg.WriteString( m_ServerGameOptions.m_sModName.c_str() ); GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Summary, *cMsg.Read()); // Update the details ServerMissionSettings sms = g_pServerMissionMgr->GetServerSettings(); cMsg.Writebool(sms.m_bUseSkills); cMsg.Writebool(sms.m_bFriendlyFire); cMsg.Writeuint8(sms.m_nMPDifficulty); cMsg.Writefloat(sms.m_fPlayerDiffFactor); CPlayerObj* pPlayer = GetFirstNetPlayer(); while (pPlayer) { //has player info cMsg.Writebool(true); cMsg.WriteString(pPlayer->GetNetUniqueName()); cMsg.Writeuint16( Min( GetPlayerPing(pPlayer), ( uint32 )65535 )); pPlayer = GetNextNetPlayer(); }; //end of player info cMsg.Writebool(false); cMsg.Writeuint8(sms.m_nRunSpeed); cMsg.Writeuint8(sms.m_nScoreLimit); cMsg.Writeuint8(sms.m_nTimeLimit); GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Details, *cMsg.Read()); // Update the port char aHostAddr[16]; uint16 nHostPort; g_pLTServer->GetTcpIpAddress(aHostAddr, sizeof(aHostAddr), nHostPort); cMsg.Writeuint16(nHostPort); GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Port, *cMsg.Read()); // Tell serverdir again about info, but in service specific manner. PeerInfo_Service_Titan peerInfo; peerInfo.m_sHostName = GetHostName( ); peerInfo.m_sCurWorld = fname; peerInfo.m_nCurNumPlayers = GetNumPlayers( ); peerInfo.m_nMaxNumPlayers = nMax; peerInfo.m_bUsePassword = m_ServerGameOptions.m_bUsePassword; peerInfo.m_sGameType = GameTypeToString( GetGameType( )); peerInfo.m_nScoreLimit = sms.m_nScoreLimit; peerInfo.m_nTimeLimit = sms.m_nTimeLimit; PeerInfo_Service_Titan::Player player; CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( ); while( iter != CPlayerObj::GetPlayerObjList( ).end( )) { CPlayerObj* pPlayerObj = *iter; player.m_sName = pPlayerObj->GetNetUniqueName( ); player.m_nScore = pPlayerObj->GetPlayerScore()->GetScore( ); float fPing; g_pLTServer->GetClientPing( pPlayerObj->GetClient( ), fPing ); player.m_nPing = ( uint16 )( fPing + 0.5f ); peerInfo.m_PlayerList.push_back( player ); iter++; } cMsg.Writeuint32(( uint32 )&peerInfo ); GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Service, *cMsg.Read()); // Tell the world about me... GetServerDir()->QueueRequest(IServerDirectory::eRequest_Publish_Server); } }
uint32 Turret::ObjectMessageFn( HOBJECT hSender, ILTMessage_Read *pMsg ) { // Reset message to begining... pMsg->SeekTo( 0 ); uint32 dwMsgId = pMsg->Readuint32( ); switch( dwMsgId ) { case MID_DAMAGE : { uint32 dwMsgPos = pMsg->Tell( ); // Process base first so the dead flag gets set... uint32 dwRet = GameBase::ObjectMessageFn( hSender, pMsg ); if( m_Damage.IsDead( )) { OnDeath( ); } else { // Determine the percentage of health left on the turret... // This will be used to create certain ClientFX based on damage states... float fHealthPercent = 0.0f; if( m_Damage.GetMaxHitPoints( ) > 0.0f ) { fHealthPercent = m_Damage.GetHitPoints( ) / m_Damage.GetMaxHitPoints( ); } HATTRIBUTE hDamageStateStruct = g_pWeaponDB->GetAttribute( m_hTurret, WDB_TURRET_DamageState ); uint32 nNumDamageStates = g_pWeaponDB->GetNumValues( hDamageStateStruct ); uint32 nDamageState; for( nDamageState = 0; nDamageState < nNumDamageStates; ++nDamageState ) { // Run through the damage states and determine which ones to display... HATTRIBUTE hAttrib = g_pWeaponDB->GetStructAttribute( hDamageStateStruct, nDamageState, WDB_TURRET_fHealthPercent ); float fDamageStatePercent = g_pWeaponDB->GetFloat( hAttrib ); if( nDamageState > m_nCurDamageState && fDamageStatePercent >= fHealthPercent ) { m_nCurDamageState = nDamageState; } } // Send damage msg to operating client... CPlayerObj *pPlayer = dynamic_cast<CPlayerObj*>(g_pLTServer->HandleToObject( m_hOperatingObject )); if( pPlayer ) { CAutoMessage cMsg; cMsg.Writeuint8( MID_SFX_MESSAGE ); cMsg.Writeuint8( SFX_TURRET_ID ); cMsg.WriteObject( m_hObject ); cMsg.Writeuint8( kTurretFXMsg_Damage ); cMsg.Writeuint32( m_nCurDamageState ); g_pLTServer->SendToClient( cMsg.Read( ), pPlayer->GetClient( ), MESSAGE_GUARANTEED ); } } return dwRet; } break; } return GameBase::ObjectMessageFn( hSender, pMsg ); }
void Lock::HandleGadgetMsg(HOBJECT hSender, ConParse & parse) { if (parse.m_nArgs < 2 || !parse.m_Args[1]) return; AMMO* pAmmo = g_pWeaponMgr->GetAmmo(atol(parse.m_Args[1])); if (!pAmmo) return; LTBOOL bProcess = LTFALSE; if (m_bWeldable && pAmmo->eInstDamageType == DT_GADGET_WELDER) { bProcess = LTTRUE; } else if (m_bLightable && pAmmo->eInstDamageType == DT_GADGET_LIGHTER) { bProcess = LTTRUE; } else if (!m_bWeldable && pAmmo->eInstDamageType == DT_GADGET_LOCK_PICK) { bProcess = LTTRUE; } if (!bProcess) return; // Pick the lock by doing lock-pick damage to it... DamageStruct damage; damage.eType = pAmmo->eInstDamageType; damage.fDamage = GetRandom(m_fMinUnlockHitPts, m_fMaxUnlockHitPts); damage.vDir.Init(0, 1, 0); damage.hDamager = m_hObject; damage.DoDamage(this, m_hObject); // Play the lock pick sound... LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); if (m_hstrPickSnd) { char* pSound = g_pLTServer->GetStringData(m_hstrPickSnd); if (pSound) { g_pServerSoundMgr->PlaySoundFromPos(vPos, pSound, m_fSndRadius, SOUNDPRIORITY_MISC_MEDIUM); } } // Do fx for welding the lock... if (m_bWeldable && pAmmo->eInstDamageType == DT_GADGET_WELDER) { WEAPON* pWeapon = g_pWeaponMgr->GetWeapon("Lighter"); if (!pWeapon) return; SURFACE* pSurf = g_pSurfaceMgr->GetSurface("Metal"); if (!pSurf) return; LTVector vHisPos; g_pLTServer->GetObjectPos(hSender, &vHisPos); LTVector vDir = vHisPos - vPos; vDir.Norm(); CLIENTWEAPONFX fxStruct; fxStruct.hFiredFrom = hSender; fxStruct.vSurfaceNormal = vDir; fxStruct.vFirePos = vHisPos; fxStruct.vPos = vPos + vDir; fxStruct.hObj = m_hObject; fxStruct.nWeaponId = pWeapon->nId; fxStruct.nAmmoId = pAmmo->nId; fxStruct.nSurfaceType = pSurf->eType; // This should be a player object, get the client id... if (IsPlayer(hSender)) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(hSender); if (pPlayer) { fxStruct.nShooterId = (uint8) g_pLTServer->GetClientID(pPlayer->GetClient()); } } CreateClientWeaponFX(fxStruct); } }
void Trigger::HandleInventoryQueryResponse(HOBJECT hSender, HMESSAGEREAD hRead) { CServerDE* pServerDE = GetServerDE(); if (!pServerDE) return; DBYTE itemType = pServerDE->ReadFromMessageByte (hRead); DBYTE itemSubType = pServerDE->ReadFromMessageByte (hRead); HSTRING itemName = pServerDE->ReadFromMessageHString (hRead); DBYTE bHaveItem = pServerDE->ReadFromMessageByte (hRead); HCLIENT hClient = NULL; if (itemType == IT_KEY && m_hstrUnlockKey && pServerDE->CompareStrings(itemName, m_hstrUnlockKey)) { pServerDE->FreeString(itemName); itemName = DNULL; // get a handle to the client if (IsPlayer (hSender)) { CPlayerObj* pPlayer = (CPlayerObj*)pServerDE->HandleToObject (hSender); if (!pPlayer) return; hClient = pPlayer->GetClient(); } else { return; } // unlock if necessary and send access granted or denied messages if (bHaveItem) { Unlock(); if (m_fAccessGrantedMsg != 0.0f) { // send text message HSTRING hstr = pServerDE->FormatString ((int)m_fAccessGrantedMsg); HMESSAGEWRITE hWrite = pServerDE->StartMessage (hClient, MID_COMMAND_SHOWGAMEMSG); pServerDE->WriteToMessageString (hWrite, pServerDE->GetStringData (hstr)); pServerDE->EndMessage (hWrite); pServerDE->FreeString (hstr); } if (m_hstrAccessGrantedSound) { char *pSound = pServerDE->GetStringData(m_hstrAccessGrantedSound); if (!pSound) return; PlaySoundFromObject(hSender, pSound, m_fSoundRadius, SOUNDPRIORITY_MISC_HIGH ); } } else { if (m_fAccessDeniedMsg != 0.0f) { // send text message HSTRING hstr = pServerDE->FormatString ((int)m_fAccessDeniedMsg); if (hstr) { HMESSAGEWRITE hWrite = pServerDE->StartMessage (hClient, MID_COMMAND_SHOWGAMEMSG); pServerDE->WriteToMessageString (hWrite, pServerDE->GetStringData (hstr)); pServerDE->EndMessage (hWrite); pServerDE->FreeString (hstr); } } if (m_hstrAccessDeniedSound) { char *pSound = pServerDE->GetStringData(m_hstrAccessDeniedSound); if (!pSound) return; PlaySoundFromObject(hSender, pSound, m_fSoundRadius, SOUNDPRIORITY_MISC_HIGH); } } } if (itemName) pServerDE->FreeString(itemName); }
void Breakable::StartBreak(HOBJECT hObj) { if (m_bStarted) return; m_bStarted = LTTRUE; // If an object caused us to break, give him a little upward // velocity... if (hObj) { m_hBreakObj = hObj; g_pLTServer->CreateInterObjectLink(m_hObject, m_hBreakObj); if (IsPlayer(hObj) && m_vShakeAmount.Mag() > 0.0f) { CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObj); if (pPlayer) { HCLIENT hClient = pPlayer->GetClient(); if (hClient) { HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_SHAKE_SCREEN); g_pLTServer->WriteToMessageVector(hMessage, &m_vShakeAmount); g_pLTServer->EndMessage(hMessage); } } } } // Play the breaking sound... if (m_hstrBreakSound) { LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); char* pSnd = g_pLTServer->GetStringData(m_hstrBreakSound); if (pSnd) { g_pServerSoundMgr->PlaySoundFromPos(vPos, pSnd, m_fBreakSoundRadius, SOUNDPRIORITY_MISC_MEDIUM); } } // Use box physics (faster)... uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); dwFlags |= FLAG_BOXPHYSICS; // Turn off the touch notify flag if we don't do crushing damage... if (!m_bCrushObjects) { dwFlags &= ~FLAG_TOUCH_NOTIFY; } g_pLTServer->SetObjectFlags(m_hObject, dwFlags); m_BreakTimer.Start(m_fBreakTime); m_vDelta.Init(); g_pLTServer->SetNextUpdate(m_hObject, 0.001f); }
void CTransitionAggregate::Load( ILTMessage_Read *pMsg, uint32 dwLoadFlags ) { if( !pMsg ) return; LOAD_HOBJECT( m_hObject ); // The rest is dependent on the load type... if( dwLoadFlags != LOAD_TRANSITION ) return; HOBJECT hTransArea = g_pTransMgr->GetTransitionArea(); if( !hTransArea ) return; TransitionArea *pTransArea = (TransitionArea*)g_pLTServer->HandleToObject( hTransArea ); if( !pTransArea ) return; LTransform tfLocal; LTransform tfObjectWorld; LTVector vVelRel; LTransform const& tfTransAreaWorld = pTransArea->GetWorldTransform( ); LTMatrix mRotation; tfTransAreaWorld.m_Rot.ConvertToMatrix( mRotation ); LOAD_VECTOR( tfLocal.m_Pos ); LOAD_ROTATION( tfLocal.m_Rot ); LOAD_VECTOR( vVelRel ); // Calc pos and rot based on offsets and current TransArea... tfObjectWorld.m_Pos = tfTransAreaWorld.m_Pos + ( mRotation * tfLocal.m_Pos ); tfObjectWorld.m_Rot = tfTransAreaWorld.m_Rot * tfLocal.m_Rot; LTVector vVel = mRotation * vVelRel; if( IsPlayer( m_hObject )) { // Since the PlayerObj is controlled by the client we need to notify the // client of the rotation. We are only worried about the Yaw since Roll doesn't // matter and Pitch can be preserved on the client. CPlayerObj *pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject( m_hObject ); if( !pPlayer ) return; LTFLOAT fYaw; LTVector vF = tfObjectWorld.m_Rot.Forward(); // We don't care about Roll... vF.y = 0.0f; vF.Normalize(); // Yaw = arctan( vF.x / vF.z ); // atan2 is well defined even for vF.z == 0 fYaw = (LTFLOAT)atan2( vF.x, vF.z ); // Inform the client of the correct camera/player orientation... LTVector vVec( 0.0f, fYaw, 0.0f ); CAutoMessage cMsg; cMsg.Writeuint8( MID_PLAYER_ORIENTATION ); cMsg.Writeuint8( MID_ORIENTATION_YAW ); cMsg.WriteLTVector( vVec ); g_pLTServer->SendToClient(cMsg.Read(), pPlayer->GetClient(), MESSAGE_GUARANTEED); } g_pLTServer->SetObjectPos( m_hObject, &tfObjectWorld.m_Pos ); g_pLTServer->SetObjectRotation( m_hObject, &tfObjectWorld.m_Rot ); g_pPhysicsLT->SetVelocity( m_hObject, &vVel ); }
void Intelligence::DoActivate(HOBJECT hSender) { // BL 10/30/00 - fix multiple photographs of items in multiplayer { if ( g_pGameServerShell->GetGameType() != SINGLE ) { uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); if ( !(dwFlags & FLAG_VISIBLE) ) { return; } } } HOBJECT hPlayer = hSender; if (!hSender || !IsPlayer(hSender)) { // Find the player if the sender isn't one... ObjArray <HOBJECT, 1> objArray; g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME, objArray); if (!objArray.NumObjects()) return; hPlayer = objArray.GetObject(0); } // Increment the player's intelligence count... CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hPlayer); if (pPlayer) { if (g_pGameServerShell->GetGameType() == COOPERATIVE_ASSAULT && m_nPlayerTeamFilter) { if (pPlayer->GetTeamID() != m_nPlayerTeamFilter) return; uint8 nScore = (uint8)g_vtNetIntelScore.GetFloat(); pPlayer->AddToScore(nScore); HCLIENT hClient = pPlayer->GetClient(); uint32 nPlayerID = g_pLTServer->GetClientID(hClient); HMESSAGEWRITE hWrite = g_pLTServer->StartMessage (LTNULL, MID_TEAM_SCORED); g_pLTServer->WriteToMessageDWord (hWrite, nPlayerID); g_pLTServer->WriteToMessageByte (hWrite, (uint8)pPlayer->GetTeamID()); g_pLTServer->WriteToMessageByte (hWrite, nScore); g_pLTServer->EndMessage (hWrite); } CPlayerSummaryMgr* pPSMgr = pPlayer->GetPlayerSummaryMgr(); if (pPSMgr) { pPSMgr->IncIntelligenceCount(); } HCLIENT hClient = pPlayer->GetClient(); if (hClient) { HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_PLAYER_INFOCHANGE); g_pLTServer->WriteToMessageByte(hMessage, IC_INTEL_PICKUP_ID); g_pLTServer->WriteToMessageByte(hMessage, 0); g_pLTServer->WriteToMessageByte(hMessage, 0); g_pLTServer->WriteToMessageFloat(hMessage, 0.0f); g_pLTServer->EndMessage(hMessage); } // Show the pop-up associated with the intelligence item, if // applicable... INTEL* pIntel = g_pIntelMgr->GetIntel(m_nIntelId); if (pIntel && m_bShowPopup) { char buf[255]; sprintf(buf, "msg %s (popup %d", DEFAULT_PLAYERNAME, m_nInfoId); // Add the scale fx... for (int i=0; i < pIntel->nNumScaleFXNames; i++) { if (pIntel->szScaleFXNames[i]) { strcat(buf, " "); strcat(buf, pIntel->szScaleFXNames[i]); } } strcat(buf, ")"); if (g_pCmdMgr->IsValidCmd(buf)) { g_pCmdMgr->Process(buf); } } // If we have a command, process it... if (m_hstrPickedUpCmd) { char* pCmd = g_pLTServer->GetStringData(m_hstrPickedUpCmd); if (pCmd && g_pCmdMgr->IsValidCmd(pCmd)) { g_pCmdMgr->Process(pCmd); } } if (g_pGameServerShell->GetGameType() == SINGLE) { g_pLTServer->RemoveObject(m_hObject); } else { uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); dwFlags &= (~FLAG_VISIBLE & ~FLAG_RAYHIT); g_pLTServer->SetObjectFlags(m_hObject, dwFlags); // Play pickup sound... LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); g_pServerSoundMgr->PlaySoundFromPos(vPos, INTEL_PICKUP_SOUND, 600.0f, SOUNDPRIORITY_MISC_HIGH); } } }