Exemple #1
0
        public override bool OnFrameImpl()
        {
            if (IsDone)
            {
                return(false);
            }

            if (warp != null)
            {
                warp.OnFrame();
                if (warp.IsDone)
                {
                    warp = null;
                }
                else
                {
                    return(true);
                }
            }

            if (!started)
            {
                // check if we're already in warp
                if (g.me.ToEntity.Mode == 3)
                {
                    SetDone("can't dock in warp");
                    return(false);
                }

                List <Entity> entities = g.eve.QueryEntities("ID = {0}".Format(entity_id));
                if (entities.Count == 0)
                {
                    SetDone("entity not found");
                    return(false);
                }

                if (entities.Count > 1)
                {
                    SetDone("entity ambiguous");
                    return(false);
                }

                Entity entity = entities[0];

                if (entity.Distance > 150000.0)
                {
                    warp = new WarpState(entity_id);
                    warp.OnFrame();
                    if (warp.IsDone)
                    {
                        SetDone(warp.Result);
                    }
                }
                else
                {
                    entity.Dock();
                    started = true;
                }
                return(true);
            }
            else if (waiting)
            {
                if (DateTime.Now - wait_start > TimeSpan.FromSeconds(5.0))
                {
                    SetDone("Success");
                    return(false);
                }
            }
            else
            {
                if (!g.me.InSpace &&
                    g.me.InStation &&
                    g.me.StationID > 0 &&
                    g.me.Ship.GetCargo() != null)
                {
                    waiting    = true;
                    wait_start = DateTime.Now;
                    return(true);
                }
            }

            return(true);
        }
Exemple #2
0
        void RunCommand(string command)
        {
            if (command == "clear")
            {
                states.Clear();
            }
            else if (command == "exit")
            {
                InnerSpace.Echo("Exiting...");
                // set up the handler for events coming back from InnerSpace
                LavishScript.Events.DetachEventTarget("OnFrame", OnFrame);
                LavishScript.Commands.RemoveCommand("ee");

                lock (lock_) {
                    Monitor.Pulse(lock_);
                }
            }
            else if (command == "update")
            {
                LavishScript.ExecuteCommand("execute evecmd_update woot");
            }
            else if (command == "undock")
            {
                State state = new UndockState();
                TryToEnterState(state);
            }
            else if (command == "gates")
            {
                List <Entity> entities = g.eve.QueryEntities("GroupID = 10");
                g.Print("Found {0} Stargates:", entities.Count);
                int i = 0;
                foreach (Entity entity in entities)
                {
                    g.Print("#{0}: [{2}] {1}", i, entity.Name, entity.ID);
                    i++;
                }
            }
            else if (command == "agents")
            {
                var agents = g.eve.GetAgents();
                if (agents == null)
                {
                    g.Print("EVE.GetAgents() return null");
                }
                else
                {
                    g.Print("Found {0} Agents:", agents.Count);
                }
            }
            else if (command == "stations")
            {
                List <Entity> entities = g.eve.QueryEntities("GroupID = 15");
                g.Print("Found {0} Stations:", entities.Count);
                int i = 0;
                foreach (Entity entity in entities)
                {
                    g.Print("#{0}: [{2}] {1}", i, entity.Name, entity.ID);
                    i++;
                }
            }
            else if (command == "missions")
            {
                List <AgentMission> missions = g.eve.GetAgentMissions();
                if (missions != null && missions.Count != 0)
                {
                    g.Print("Found {0} Missions:", missions.Count);
                    int i = 0;
                    foreach (AgentMission mission in missions)
                    {
                        g.Print("#{0}: {1}", i, mission.Name);
                        g.Print("    AgentID={0}", mission.AgentID);
                        g.Print("    Expires={0}", mission.Expires);
                        g.Print("    State={0}", mission.State);
                        g.Print("    Type={0}", mission.Type);
                        mission.GetDetails(); //opens details window
                        List <BookMark> bookmarks = mission.GetBookmarks();
                        int             j         = 0;
                        g.Print("    {0} Bookmarks:", bookmarks.Count);
                        foreach (BookMark bookmark in bookmarks)
                        {
                            g.Print("    Bookmark #{0}: [{2}] {1}", j, bookmark.Label, bookmark.ID);
                            g.Print("        Type: [{0}] {1}", bookmark.TypeID, bookmark.TypeID);
                            g.Print("        LocationType: {0}", bookmark.LocationType);
                            g.Print("        SolarSystemID: {0}", bookmark.SolarSystemID);
                            j++;
                        }
                        i++;
                    }
                }
                else if (missions == null)
                {
                    g.Print("Getting missions failed");
                }
                else
                {
                    g.Print("No missions found");
                }
            }
            else if (command.StartsWith("printwindow "))
            {
                string    window_name = command.Substring(12);
                EVEWindow window      = EVEWindow.GetWindowByName(window_name);
                if (window == null || !window.IsValid)
                {
                    window = EVEWindow.GetWindowByCaption(window_name);
                }

                if (window != null && window.IsValid)
                {
                    g.Print(window.Caption);
                    g.Print(window.HTML);

                    try // to parse some basics
                    {
                        MissionPage page = new MissionPage(window.HTML);
                        g.Print("Title: {0}", page.Title);
                        g.Print("CargoID: {0}", page.CargoID);
                        g.Print("Volume: {0}", page.CargoVolume);
                    }
                    catch { }
                }
                else
                {
                    g.Print("window \"{0}\" not found", window_name);
                }
            }
            else if (command == "printitems")
            {
                // print the items in station
                if (!g.me.InStation)
                {
                    g.Print("Not in station...");
                }
                else
                {
                    List <Item> items = g.me.GetHangarItems();
                    if (items == null)
                    {
                        g.Print("Failed to GetHangerItems");
                    }
                    else
                    {
                        int i = 0;
                        g.Print("Found {0} Items:", items.Count);
                        foreach (Item item in items)
                        {
                            g.Print("#{0}: [{2}] {1} x{3}", i, item.Name, item.ID, item.Quantity);
                            g.Print("    Description={0}", item.Description);
                            g.Print("    Type=[{0}] {1}", item.TypeID, item.Type);
                            g.Print("    Category=[{0}] {1}", item.CategoryID, item.Category);
                            g.Print("    BasePrice={0}", item.BasePrice);
                            g.Print("    UsedCargoCapacity={0}", item.UsedCargoCapacity);
                            i++;
                        }
                    }
                }
            }
            else if (command.StartsWith("printagent "))
            {
                int   id    = Int32.Parse(command.Substring(11));
                Agent agent = new Agent("ByID", id);
                if (agent != null && agent.IsValid)
                {
                    g.Print("Name: {0}", agent.Name);
                    g.Print("Station: [{0}] {1}", agent.StationID, agent.Station);
                    g.Print("Division: [{0}] {1}", agent.DivisionID, agent.Division);
                    g.Print("StandingTo: {0}", agent.StandingTo);
                    g.Print("SolarSystemID: {0}", agent.Solarsystem.ID);
                    List <DialogString> responses = agent.GetDialogResponses();
                    int i = 0;
                    g.Print("{0} Dialog Responses:", responses.Count);
                    foreach (DialogString response in responses)
                    {
                        g.Print("    Response #{0}: {1}", i, response.Text);
                        i++;
                    }
                }
                else
                {
                    g.Print("Agent not found");
                }
            }
            else if (command == "printcargo")
            {
                List <Item> items = g.me.Ship.GetCargo();

                g.Print("Found {0} Items:", items.Count);
                int i = 0;
                foreach (Item item in items)
                {
                    g.Print("#{0} {1}", i, item.Name);
                    g.Print("    Category: [{0}] {1} ({2})", item.CategoryID, item.Category, item.CategoryType.ToString());
                    g.Print("    Description: {0}", item.Description);
                    g.Print("    Group: [{0}] {1}", item.GroupID, item.Group);
                    i++;
                }
            }
            else if (command == "printroids")
            {
                List <Entity> roids = g.eve.QueryEntities("CategoryID = 25");
                g.Print("Found {0} Asteroids:", roids.Count);
                int i = 0;
                foreach (Entity roid in roids)
                {
                    if (i >= 10)
                    {
                        break;
                    }
                    g.Print("#{0} {1}", i, roid.Name);
                    g.Print("    Distance: {0}", roid.Distance);
                    g.Print("    Type: [{0}] {1}", roid.TypeID, roid.Type);
                    g.Print("    Category: [{0}] {1} ({2})", roid.CategoryID, roid.Category, roid.CategoryType);
                    g.Print("    Location: {0},{1},{2}", roid.X, roid.Y, roid.Z);
                    g.Print("    IsActiveTarget: {0} IsLockedTarget: {1}", roid.IsActiveTarget ? "Yes" : "No", roid.IsLockedTarget ? "Yes" : "No");
                    i++;
                }
            }
            else if (command.StartsWith("warp "))
            {
                State state = new WarpState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "dock")
            {
                State state = new DockState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "goto")
            {
                State state = new GotoState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "domission")
            {
                State state = new MissionState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "dodropoff")
            {
                State state = new DoDropoffState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "mineloop")
            {
                State state = new MineLoopState(command);
                TryToEnterState(state);
            }
            else if (command == "unloadore")
            {
                State state = new UnloadOreState();
                TryToEnterState(state);
            }
            else if (command.StartsWith("travel "))
            {
                State state = new TravelToStationState(command);
                TryToEnterState(state);
            }
            else if (command == "runlasers")
            {
                TryToEnterState(new RunMiningLasersState());
            }
        }
Exemple #3
0
        public override bool OnFrameImpl()
        {
            if (warp_state != null)
            {
                warp_state.OnFrame();
                if (warp_state.IsDone)
                {
                    warp_state = null;
                }
                else
                {
                    return(true);
                }
            }

            List <Entity> entities = g.eve.QueryEntities();

            if (entities == null || entities.Count <= 0)
            {
                // we're probably jumping right now - just chill
                return(true);
            }

            if (g.me.InSpace && g.me.SolarSystemID == solarsystem_id)
            {
                SetDone("Success");
                return(false);
            }

            entities = g.eve.QueryEntities("ID = {0}".Format(entity_id));
            if (entities.Count == 0)
            {
                SetDone("stargate not found");
                return(false);
            }

            if (entities.Count > 1)
            {
                SetDone("stargate id ambiguous");
                return(false);
            }

            Entity stargate = entities[0];

            if (stargate.Distance > 150000.0)
            {
                warp_state = new WarpState(entity_id);
                warp_state.OnFrame();
                return(true);
            }
            else if (stargate.Distance < 2500.0)
            {
                if (!jumped)
                {
                    stargate.Jump();
                    jumped = true;
                }
                return(true);
            }
            else if (!approached)
            {
                stargate.Approach();
                approached = true;
            }

            return(true);
        }