// NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted void VehicleAI::UpdateAI(uint32 diff) { CheckConditions(diff); if (m_DoDismiss) { if (m_DismissTimer < diff) { m_DoDismiss = false; me->DespawnOrUnsummon(); } else m_DismissTimer -= diff; } }
//NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted void VehicleAI::UpdateAI(const uint32 diff) { CheckConditions(diff); if (m_DoDismiss) { if (m_DismissTimer < diff) { m_DoDismiss = false; me->SetVisible(false); me->ForcedDespawn(); } else m_DismissTimer -= diff; } }
void SmartAI::UpdateAI(uint32 diff) { CheckConditions(diff); GetScript()->OnUpdate(diff); UpdatePath(diff); UpdateFollow(diff); UpdateDespawn(diff); if (!IsAIControlled()) return; if (!UpdateVictim()) return; if (mCanAutoAttack) DoMeleeAttackIfReady(); }
/** * GetPointInfo builds the PvlGroup containing all the important * information derived from the Camera. * * @return PvlGroup* Data taken directly from the Camera and * drived from Camera information. Ownership passed. */ PvlGroup * CameraPointInfo::GetPointInfo() { CheckConditions(); Brick b(3,3,1,currentCube->PixelType()); int intSamp = (int)(camera->Sample() + 0.5); int intLine = (int)(camera->Line() + 0.5); b.SetBasePosition(intSamp, intLine, 1); currentCube->Read(b); double pB[3], spB[3], sB[3]; string utc; double ssplat, ssplon, sslat, sslon, pwlon, oglat; // Create group with ground position PvlGroup * gp = new PvlGroup("GroundPoint"); { gp->AddKeyword(PvlKeyword("Filename",currentCube->Filename())); gp->AddKeyword(PvlKeyword("Sample",camera->Sample())); gp->AddKeyword(PvlKeyword("Line",camera->Line())); gp->AddKeyword(PvlKeyword("PixelValue",PixelToString(b[0]))); gp->AddKeyword(PvlKeyword("RightAscension",camera->RightAscension())); gp->AddKeyword(PvlKeyword("Declination",camera->Declination())); gp->AddKeyword(PvlKeyword("PlanetocentricLatitude", camera->UniversalLatitude())); // Convert lat to planetographic double radii[3]; camera->Radii(radii); oglat = Isis::Projection::ToPlanetographic(camera->UniversalLatitude(), radii[0],radii[2]); gp->AddKeyword(PvlKeyword("PlanetographicLatitude",oglat)); gp->AddKeyword(PvlKeyword("PositiveEast360Longitude", camera->UniversalLongitude())); //Convert lon to -180 - 180 range gp->AddKeyword(PvlKeyword("PositiveEast180Longitude", Isis::Projection::To180Domain( camera->UniversalLongitude()))); //Convert lon to positive west pwlon = Isis::Projection::ToPositiveWest(camera->UniversalLongitude(), 360); gp->AddKeyword(PvlKeyword("PositiveWest360Longitude",pwlon)); //Convert pwlon to -180 - 180 range gp->AddKeyword(PvlKeyword("PositiveWest180Longitude", Isis::Projection::To180Domain(pwlon))); camera->Coordinate(pB); PvlKeyword coord("BodyFixedCoordinate"); coord.AddValue(pB[0],"km"); coord.AddValue(pB[1],"km"); coord.AddValue(pB[2],"km"); gp->AddKeyword(coord); gp->AddKeyword(PvlKeyword("LocalRadius",camera->LocalRadius(),"m")); gp->AddKeyword(PvlKeyword("SampleResolution",camera->SampleResolution(),"m")); gp->AddKeyword(PvlKeyword("LineResolution",camera->LineResolution(),"m")); camera->InstrumentPosition(spB); PvlKeyword spcoord("SpacecraftPosition"); spcoord.AddValue(spB[0],"km"); spcoord.AddValue(spB[1],"km"); spcoord.AddValue(spB[2],"km"); spcoord.AddComment("Spacecraft Information"); gp->AddKeyword(spcoord); gp->AddKeyword(PvlKeyword("SpacecraftAzimuth",camera->SpacecraftAzimuth())); gp->AddKeyword(PvlKeyword("SlantDistance",camera->SlantDistance(),"km")); gp->AddKeyword(PvlKeyword("TargetCenterDistance",camera->TargetCenterDistance(),"km")); camera->SubSpacecraftPoint(ssplat,ssplon); gp->AddKeyword(PvlKeyword("SubSpacecraftLatitude",ssplat)); gp->AddKeyword(PvlKeyword("SubSpacecraftLongitude",ssplon)); gp->AddKeyword(PvlKeyword("SpacecraftAltitude",camera->SpacecraftAltitude(),"km")); gp->AddKeyword(PvlKeyword("OffNadirAngle",camera->OffNadirAngle())); double subspcgrdaz; subspcgrdaz = camera->GroundAzimuth(camera->UniversalLatitude(),camera->UniversalLongitude(), ssplat,ssplon); gp->AddKeyword(PvlKeyword("SubSpacecraftGroundAzimuth",subspcgrdaz)); camera->SunPosition(sB); PvlKeyword scoord("SunPosition"); scoord.AddValue(sB[0],"km"); scoord.AddValue(sB[1],"km"); scoord.AddValue(sB[2],"km"); scoord.AddComment("Sun Information"); gp->AddKeyword(scoord); gp->AddKeyword(PvlKeyword("SubSolarAzimuth",camera->SunAzimuth())); gp->AddKeyword(PvlKeyword("SolarDistance",camera->SolarDistance(),"AU")); camera->SubSolarPoint(sslat,sslon); gp->AddKeyword(PvlKeyword("SubSolarLatitude",sslat)); gp->AddKeyword(PvlKeyword("SubSolarLongitude",sslon)); double subsolgrdaz; subsolgrdaz = camera->GroundAzimuth(camera->UniversalLatitude(),camera->UniversalLongitude(), sslat,sslon); gp->AddKeyword(PvlKeyword("SubSolarGroundAzimuth",subsolgrdaz)); PvlKeyword phase("Phase",camera->PhaseAngle()); phase.AddComment("Illumination and Other"); gp->AddKeyword(phase); gp->AddKeyword(PvlKeyword("Incidence",camera->IncidenceAngle())); gp->AddKeyword(PvlKeyword("Emission",camera->EmissionAngle())); gp->AddKeyword(PvlKeyword("NorthAzimuth",camera->NorthAzimuth())); PvlKeyword et("EphemerisTime",camera->EphemerisTime(),"seconds"); et.AddComment("Time"); gp->AddKeyword(et); iTime t(camera->EphemerisTime()); utc = t.UTC(); gp->AddKeyword(PvlKeyword("UTC",utc)); gp->AddKeyword(PvlKeyword("LocalSolarTime",camera->LocalSolarTime(),"hour")); gp->AddKeyword(PvlKeyword("SolarLongitude",camera->SolarLongitude())); } return gp; }