void Siege::SiegeAudioCalc(uint basehash, uint iSystemID, Vector pos, int level) { // For all players in system... struct PlayerData *pPD = 0; while(pPD = Players.traverse_active(pPD)) { // Get the this player's current system and location in the system. uint iClientID = HkGetClientIdFromPD(pPD); uint iClientSystem = 0; pub::Player::GetSystem(iClientID, iClientSystem); if (iSystemID != iClientSystem) continue; uint iShip; pub::Player::GetShip(iClientID, iShip); Vector vShipLoc; Matrix mShipDir; pub::SpaceObj::GetLocation(iShip, vShipLoc, mShipDir); // Is player within (15K) of the sending char. float fDistance = HkDistance3D(vShipLoc, pos); if (fDistance>15000) continue; SiegeAudioNotification(iClientID, level); } return; }
/// Return true if this player is within the specified distance of any other player. bool IsInRange(uint client, float fDistance) { list<GROUP_MEMBER> lstMembers; HkGetGroupMembers((const wchar_t*) Players.GetActiveCharacterName(client), lstMembers); uint iShip; pub::Player::GetShip(client, iShip); Vector pos; Matrix rot; pub::SpaceObj::GetLocation(iShip, pos, rot); uint iSystem; pub::Player::GetSystem(client, iSystem); // For all players in system... struct PlayerData *pPD = 0; while(pPD = Players.traverse_active(pPD)) { // Get the this player's current system and location in the system. uint client2 = HkGetClientIdFromPD(pPD); uint iSystem2 = 0; pub::Player::GetSystem(client2, iSystem2); if (iSystem != iSystem2) continue; uint iShip2; pub::Player::GetShip(client2, iShip2); Vector pos2; Matrix rot2; pub::SpaceObj::GetLocation(iShip2, pos2, rot2); // Ignore players who are in your group. bool bGrouped = false; foreach (lstMembers, GROUP_MEMBER, gm) { if (gm->iClientID==client2) { bGrouped = true; break; } } if (bGrouped) continue; // Is player within the specified range of the sending char. if (HkDistance3D(pos, pos2) < fDistance) return true; } return false; }
/// Print message to all ships within the specific number of meters of the player. void PrintLocalUserCmdText(uint client, const wstring &wscMsg, float fDistance) { uint iShip; pub::Player::GetShip(client, iShip); Vector pos; Matrix rot; pub::SpaceObj::GetLocation(iShip, pos, rot); uint iSystem; pub::Player::GetSystem(client, iSystem); // For all players in system... struct PlayerData *pPD = 0; while(pPD = Players.traverse_active(pPD)) { // Get the this player's current system and location in the system. uint client2 = HkGetClientIdFromPD(pPD); uint iSystem2 = 0; pub::Player::GetSystem(client2, iSystem2); if (iSystem != iSystem2) continue; uint iShip2; pub::Player::GetShip(client2, iShip2); Vector pos2; Matrix rot2; pub::SpaceObj::GetLocation(iShip2, pos2, rot2); // Is player within the specified range of the sending char. if (HkDistance3D(pos, pos2) > fDistance) continue; PrintUserCmdText(client2, L"%s", wscMsg.c_str()); } }