void CHSWormHole::GateShip(CHSShip *cShip) { if (!cShip) return; BOOL succeed; if (getrandom(100) <= m_stability) succeed = TRUE; else succeed = FALSE; cShip->NotifyConsoles("The ship enters the wormhole and an infinite amount of colors can be seen.", MSG_SENSOR); cShip->NotifySrooms("The ship shakes slightly as it enters a wormhole."); CHSUniverse *uDest; uDest = uaUniverses.FindUniverse(cShip->GetUID()); if (uDest) { uDest->SendContactMessage("In the distance a ship gates a wormhole.", DETECTED, cShip); uDest->SendContactMessage( tprintf("In the distance the %s gates a wormhole.",cShip->GetName()), IDENTIFIED, cShip); } if (succeed) { if (m_destx) cShip->SetX(m_destx); if (m_desty) cShip->SetY(m_desty); if (m_destz) cShip->SetZ(m_destz); CHSUniverse *uSource; uDest = uaUniverses.FindUniverse(m_destuid); if (uDest) { // Grab the source universe uSource = uaUniverses.FindUniverse(cShip->GetUID()); // Now pull it from one, and put it in another uSource->RemoveObject(cShip); cShip->SetUID(m_destuid); uDest->AddObject(cShip); } cShip->NotifyConsoles("The ship safely emerges on the other side of the wormhole.", MSG_SENSOR); } else { cShip->NotifyConsoles("The wormhole collapses and the structural integrity is comprimised.", MSG_SENSOR); cShip->ExplodeMe(); if (!hsInterface.HasFlag(cShip->GetDbref(), TYPE_THING, THING_HSPACE_SIM)) cShip->KillShipCrew("The ship explodes as the structural integrity fails!"); } }
void CHSMissile::DoCycle() { // Do we need to delete ourselves? if (m_delete_me) { // Remove us from space CHSUniverse *cSource; cSource = GetUniverse(); if (cSource) { cSource->RemoveObject(this); } // Purge the object representing the missile prior to deallocating // memory if (hsInterface.ValidObject(GetDbref())) { hsInterface.DestroyObject(GetDbref()); } return; } // If we have no target or no parent, remove us from space. if (!m_target || !m_pData || !m_target->IsActive()) { hs_log("CHSMissile::DoCycle() Missile Data Invalid - Removing Object."); m_delete_me = true; return; } // Do we know how much time is left until we die? if (m_timeleft < 0) { CalculateTimeLeft(); } else { m_timeleft--; } // Missile depleted? if (0 == m_timeleft) { m_delete_me = true; return; } // Change the missile heading toward the target ChangeHeading(); // Move us closer to the target. MoveTowardTarget(); // The MoveTowardTarget() checks to see if the missile hits // so we just have to check our flag. if (m_target_hit) { // If we aren't designated to miss, apply damage if (m_specified_miss != true) { // BOOM! HitTarget(); } m_delete_me = true; // Delete next time around } }