void CHSAsteroid::DoCycle(void) { CHSObject *cObj; CHSUniverse *uSrc; CHSShip *Target; int idx; double dDistance; uSrc = uaUniverses.FindUniverse(GetUID()); if (!uSrc) return; // Grab all of the objects in the universe, and see if they're in the area. for (idx = 0; idx < HS_MAX_OBJECTS; idx++) { cObj = uSrc->GetUnivObject(idx); if (!cObj) continue; if (cObj->GetType() != HST_SHIP) continue; Target = (CHSShip *) cObj; dDistance = Dist3D(GetX(),GetY(),GetZ(),Target->GetX(),Target->GetY(),Target->GetZ()); if (dDistance > GetSize() * 100) continue; if (GetDensity() < getrandom(50 / Target->GetSize() * ((Target->GetSpeed() + 1) / 1000))) continue; int strength; strength = getrandom(GetDensity() * Target->GetSize() * ((Target->GetSpeed() + 1) / 1000)); Target->m_hull_points -= strength; Target->NotifySrooms("The ship shakes as asteroids impact on the hull"); // Is hull < 0? if (Target->m_hull_points < 0) { Target->ExplodeMe(); if (!hsInterface.HasFlag(m_objnum, TYPE_THING, THING_HSPACE_SIM)) Target->KillShipCrew("THE SHIP EXPLODES!!"); } } }
void CHSBlackHole::DoCycle(void) { CHSObject *cObj; CHSUniverse *uSrc; CHSShip *Target; int idx; double dDistance; uSrc = uaUniverses.FindUniverse(GetUID()); if (!uSrc) return; // Grab all of the objects in the universe, and see if they're in the area. for (idx = 0; idx < HS_MAX_OBJECTS; idx++) { cObj = uSrc->GetUnivObject(idx); if (!cObj) continue; if (cObj->GetType() != HST_SHIP) continue; Target = (CHSShip *) cObj; dDistance = Dist3D(GetX(),GetY(),GetZ(),Target->GetX(),Target->GetY(),Target->GetZ()); if (dDistance > GetSize() * 100 - 0.01) continue; int strength; strength = (GetSize() * 100) / dDistance * 100 - 100; Target->MoveTowards(m_x, m_y, m_z, strength); Target->m_hull_points -= strength; Target->NotifySrooms("The hull buckles from the black hole's gravity."); // Is hull < 0? if (Target->m_hull_points < 0) { Target->ExplodeMe(); if (!hsInterface.HasFlag(m_objnum, TYPE_THING, THING_HSPACE_SIM)) Target->KillShipCrew("THE SHIP EXPLODES!!"); } } }