Example #1
0
        private void myView_ThingCreated(
            float x, float y, float z,
            float nx, float ny, float nz)
        {
            ThingMap selectedMap = null;

            for (int i = 0; i < myMaps.Count; ++i)
            {
                if (myMaps[i].IsOver(x, y, z))
                {
                    selectedMap = myMaps[i];
                    break;
                }
            }

            if (selectedMap == null)
            {
                FormMain.Instance.ErrorMessage("Click over a map, please.");
                return;
            }

            if (myCreateMode == CreateMode.SelectTeleporterDst)
            {
                float dstx = x - myTeleporterMap.X;
                float dsty = y - myTeleporterMap.Y;

                CTCBlock block =
                    myTeleporter.get_CTCs("CTCPhysicsStandard");

                if (MessageBox.Show(
                        "Create a two-way teleporter?",
                        "ChocolateBox",
                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FableMod.TNG.Thing myOriginal = myCreatedThing;

                    if (SetupForTeleporter())
                    {
                        selectedMap.AddThing(
                            myController,
                            myCreatedThing,
                            "NULL",
                            x, y, z,
                            nx, ny, nz);

                        CTCBlock blockSrc =
                            myOriginal.get_CTCs("CTCPhysicsStandard");

                        CTCBlock blockDst =
                            myTeleporter.get_CTCs("CTCPhysicsStandard");

                        blockDst.get_Variables("PositionX").Value =
                            (myTeleporterMap.X +
                             (float)blockSrc.get_Variables("PositionX").Value) -
                            selectedMap.X;

                        blockDst.get_Variables("PositionY").Value =
                            (myTeleporterMap.Y +
                             (float)blockSrc.get_Variables("PositionY").Value) -
                            selectedMap.Y;

                        blockDst.get_Variables("PositionZ").Value =
                            ((float)blockSrc.get_Variables(
                                 "PositionZ").Value) + 0.5f;

                        selectedMap.AddThing(
                            myController,
                            myTeleporter,
                            "NULL");

                        // So we spawn over the thing.
                        z += 0.5f;
                    }
                }
                else if (MessageBox.Show(
                             "Create a teleportation platform?\r\n" +
                             "This object is a visual que only.",
                             "ChocolateBox",
                             MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FableMod.TNG.Thing platform =
                        new FableMod.TNG.Thing("Object");

                    platform.Create(
                        FileDatabase.Instance.TNGDefinitions,
                        "OBJECT_GUILD_PEDESTAL_TELEPORT_01");

                    platform.UID    = FableMod.TNG.UIDManager.Generate();
                    platform.Player = 4;

                    selectedMap.AddThing(
                        myController,
                        platform,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);

                    // So we spawn over the thing.
                    z += 0.5f;
                }

                // Set the jump coordinates.
                block.get_Variables("PositionX").Value = dstx;
                block.get_Variables("PositionY").Value = dsty;
                block.get_Variables("PositionZ").Value = z;

                FormMain.Instance.InfoMessage(string.Format(
                                                  "Teleporter created from map \"{0}\" to map \"{1}\".",
                                                  myTeleporterMap.Name,
                                                  selectedMap.Name));

                myCreateMode = CreateMode.None;
                myView.Mode  = EditorMode.Normal;

                //Close();

                return;
            }
            else if (myCreateMode == CreateMode.SelectTeleporterSrc)
            {
                try
                {
                    selectedMap.AddThing(
                        myController,
                        myCreatedThing,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);

                    selectedMap.AddThing(
                        myController,
                        myTeleporter,
                        "NULL");
                }
                catch (Exception ex)
                {
                    FormMain.Instance.ErrorMessage(ex.Message);
                    return;
                }

                WLDFileController wldc =
                    FileDatabase.Instance.GetWLD();
                FableMod.WLD.WLDFile wld = wldc.WLD;

                FormRegionSelect form = new FormRegionSelect();

                form.Text = "Select Destination Region";

                for (int i = 0; i < wld.RegionCount; ++i)
                {
                    form.listBoxRegions.Items.Add(
                        wld.GetRegion(i).RegionName);
                }

                if (form.ShowDialog() == DialogResult.OK)
                {
                    FableMod.WLD.Region region = wld.GetRegion(
                        form.listBoxRegions.Items[
                            form.listBoxRegions.SelectedIndex].
                        ToString());

                    if (region.RegionName != myRegion)
                    {
                        FormEditor formEditor = new FormEditor(
                            region,
                            myCreatedThing,
                            myTeleporter,
                            selectedMap);

                        FormMain.Instance.AddMDI(formEditor);
                    }
                    else
                    {
                        // Use this window.
                        SelectTeleporterDestination(
                            myCreatedThing, myTeleporter, selectedMap);

                        return;
                    }
                }
                else
                {
                    myController.RemoveThing(myCreatedThing);
                    myController.RemoveThing(myTeleporter);
                }

                form.Dispose();

                myCreatedThing = null;

                // Reset variable.
                myTeleporter = null;
            }
            else if (myCreateMode == CreateMode.CreateNew)
            {
                try
                {
                    selectedMap.AddThing(
                        myController,
                        myCreatedThing,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);
                }
                catch (Exception ex)
                {
                    FormMain.Instance.ErrorMessage(ex.Message);
                }

                myCreatedThing = null;
            }
            else if (myCreateMode == CreateMode.Import)
            {
                for (int i = 0; i < myImports.Count; ++i)
                {
                    FableMod.TNG.Thing thing = myImports[i];

                    selectedMap.AddThing(
                        myController, thing, "NULL");
                }
            }

            myImports.Clear();
            myCreateMode = CreateMode.None;
            myView.Mode  = EditorMode.Normal;
        }
Example #2
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object obj =
                ContentManager.Instance.SelectEntry(
                    new Link(
                        LinkDestination.GameBINEntryName,
                        null),
                    myLastNewEntry);

            if (obj != null)
            {
                ContentObject o = ContentManager.Instance.FindEntry(
                    LinkDestination.GameBINEntryName, obj);

                if (o == null)
                {
                    FormMain.Instance.ErrorMessage(
                        "Object could not be retrieved");
                    return;
                }

                BINEntry entry = (BINEntry)o.Object;

                string thingName = "Object";

                if (entry.Definition == "BUILDING")
                {
                    thingName = "Building";
                }
                else if (entry.Definition == "CREATURE")
                {
                    thingName = "AICreature";
                }
                else if (entry.Definition == "MARKER")
                {
                    thingName = "Marker";
                }
                else if (entry.Definition == "HOLY_SITE")
                {
                    thingName = "Holy Site";
                }
                else if (entry.Definition == "VILLAGE")
                {
                    thingName = "Village";
                }

                myCreatedThing = new FableMod.TNG.Thing(thingName);

                myCreatedThing.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    entry.Name);

                myLastNewEntry = entry.Name;

                myCreatedThing.UID    = FableMod.TNG.UIDManager.Generate();
                myCreatedThing.Player = 4;

                entry = null;
                o     = null;

                // Change to creation mode.
                myView.Mode  = EditorMode.Create;
                myCreateMode = CreateMode.CreateNew;
            }
        }
Example #3
0
        private bool SetupForTeleporter()
        {
            object obj =
                ContentManager.Instance.SelectEntry(
                    new Link(LinkDestination.GameBINEntryName, "OBJECT"),
                    "OBJECT_GUILD_PEDESTAL_TELEPORT_01");

            if (obj != null)
            {
                ContentObject o = ContentManager.Instance.FindEntry(
                    LinkDestination.GameBINEntryName, obj);

                BINEntry entry = (BINEntry)o.Object;

                if (entry.Definition != "OBJECT")
                {
                    FormMain.Instance.ErrorMessage(
                        "Invalid object selected.");
                    return(false);
                }

                myCreatedThing = new FableMod.TNG.Thing("Object");

                myCreatedThing.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    entry.Name);

                myCreatedThing.UID    = FableMod.TNG.UIDManager.Generate();
                myCreatedThing.Player = 4;
                myCreatedThing.get_Variables("ScriptData").Value =
                    "Teleport?";

                entry = null;
                o     = null;

                CTCBlock block = (CTCBlock)myCreatedThing.ApplyCTC(
                    FileDatabase.Instance.TNGDefinitions,
                    "CTCActionUseScriptedHook");

                block.get_Variables("Usable").Value                   = true;
                block.get_Variables("ForceConfirmation").Value        = true;
                block.get_Variables("TeleportToRegionEntrance").Value =
                    true;

                ElementArray arr = (ElementArray)
                                   myCreatedThing.Find("CreateTC");

                Variable var = (Variable)arr.Add();
                var.Value = "CTCActionUseScriptedHook";

                // Create the teleporter marker.

                FableMod.TNG.Thing marker = new FableMod.TNG.Thing("Marker");

                marker.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    "MARKER_BASIC");

                marker.UID    = FableMod.TNG.UIDManager.Generate();
                marker.Player = 4;

                // Set the teleport connector.
                block.get_Variables("EntranceConnectedToUID").Value =
                    marker.UID;

                // We're creating a teleporter...
                myTeleporter = marker;

                return(true);
            }

            return(false);
        }