void CHSSysEngines::CutPower(HS_INT32 level) { if (level == 0) { if (GetOwnerObject() && GetOwnerObject()->GetType() == HST_SHIP) { CHSShip *cShip; cShip = (CHSShip *) GetOwnerObject(); if (hsInterface.AtrGet(cShip->GetDbref(), "HSMSG_ENGINES_CUT")) { HS_DBREF idx = cShip->GetDbref(); char *msg = hsInterface.EvalExpression(hsInterface.m_buffer, idx, idx, idx); cShip->NotifySrooms(msg); } else { cShip->NotifySrooms(HSCONF.engines_cut); } } } }
void CHSSysThrusters::PowerUp(int level) { if (!GetOwnerObject()) { return; } if (GetOwnerObject()->GetType() == HST_SHIP) { CHSShip *cShip; cShip = (CHSShip *) GetOwnerObject(); if (hsInterface. AtrGet(cShip->GetDbref(), "HSMSG_THRUSTERS_ACTIVATING")) { char *msg = hsInterface.EvalExpression(hsInterface.m_buffer, cShip->GetDbref(), cShip->GetDbref(), cShip->GetDbref()); cShip->NotifySrooms(msg); } else { cShip->NotifySrooms(HSCONF.thrusters_activating); } } }
void CHSJumpDrive::CutPower(HS_INT32 level) { if (level == 0) { if (GetOwnerObject() && (GetOwnerObject()->GetType() == HST_SHIP)) { CHSShip *cShip; cShip = (CHSShip *) GetOwnerObject(); if (hsInterface.AtrGet(cShip->GetDbref(), "HSMSG_JUMPERS_CUT")) { char *msg = hsInterface.EvalExpression(hsInterface.m_buffer, cShip->GetDbref(), cShip->GetDbref(), cShip->GetDbref()); cShip->NotifySrooms(msg); } else { cShip->NotifySrooms(HSCONF.jumpers_cut); } } // Set charge level to 0. m_fChargeLevel = 0; // If jumpers are engaged and power is set to 0, then // disengage. if (GetEngaged()) { HS_INT8 tbuf[128]; m_bEngaged = false; sprintf(tbuf, "%s%s-%s Jump drive disengaged.", ANSI_HILITE, ANSI_GREEN, ANSI_NORMAL); if (GetOwnerObject()) { GetOwnerObject()->HandleMessage(tbuf, MSG_ENGINEERING); } } } }
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!!"); } } }