コード例 #1
0
        public UInt32 GenerateZoneSQL(SQLDestination SQLOut)
        {
            UInt16 ZoneID = PatchDecoder.GetZoneNumber();

            NewZoneStruct NewZone = PatchDecoder.GetZoneData();

            SQLOut("--");
            SQLOut("-- Zone Config");
            SQLOut("--");
            string InsertFormat = "UPDATE zone set `short_name` = '{0}', `file_name` = '', `long_name` = '{1}', `safe_x` = {2}, `safe_y` = {3}, `safe_z` = {4}, ";
            InsertFormat += "`underworld` = {6}, `minclip` = {7}, `maxclip` = {8}, `fog_minclip` = {9}, `fog_maxclip` = {10}, ";
            InsertFormat += "`fog_blue` = {11}, `fog_red` = {12}, `fog_green` = {13}, `sky` = {14}, `ztype` = {15}, `time_type` = {16}, ";
            InsertFormat += "`fog_red2` = {17}, `fog_green2` = {18}, `fog_blue2` = {19}, `fog_minclip2` = {20}, `fog_maxclip2` = {21}, ";
            InsertFormat += "`fog_red3` = {22}, `fog_green3` = {23}, `fog_blue3` = {24}, `fog_minclip3` = {25}, `fog_maxclip3` = {26}, ";
            InsertFormat += "`fog_red4` = {27}, `fog_green4` = {28}, `fog_blue4` = {29}, `fog_minclip4` = {30}, `fog_maxclip4` = {31} WHERE zoneidnumber = {5};";

            SQLOut(String.Format(InsertFormat, NewZone.ShortName2, NewZone.LongName, NewZone.SafeX, NewZone.SafeY, NewZone.SafeZ,
                                               ZoneID, NewZone.UnderWorld, NewZone.MinClip, NewZone.MaxClip, NewZone.FogMinClip[0], NewZone.FogMaxClip[0],
                                               NewZone.FogBlue[0], NewZone.FogRed[0], NewZone.FogGreen[0], NewZone.Sky, NewZone.Type, NewZone.TimeType,
                                               NewZone.FogRed[1], NewZone.FogGreen[1], NewZone.FogBlue[1], NewZone.FogMinClip[1], NewZone.FogMaxClip[1],
                                               NewZone.FogRed[2], NewZone.FogGreen[2], NewZone.FogBlue[2], NewZone.FogMinClip[2], NewZone.FogMaxClip[2],
                                               NewZone.FogRed[3], NewZone.FogGreen[3], NewZone.FogBlue[3], NewZone.FogMinClip[3], NewZone.FogMaxClip[3]));

            SQLOut(String.Format("UPDATE zone set fog_density = {0} WHERE zoneidnumber = {1};", NewZone.FogDensity, ZoneID));
            SQLOut("--");

            return ZoneID;
        }
コード例 #2
0
        public void GenerateZonePointSQL(string ZoneName, SQLDestination SQLOut)
        {
            foreach (ZonePoint zp in ZonePointList)
            {
                string Insert = String.Format("REPLACE into zone_points(`zone`, `number`, `y`, `x`, `z`, `heading`, `target_y`, `target_x`, `target_z`, `target_heading`, `zoneinst`, `target_zone_id`, `buffer`) VALUES('{0}', {1}, 0, 0, 0, 0, {2}, {3}, {4}, {5}, {6}, {7}, 0);", ZoneName, zp.Number, zp.y, zp.x, zp.z, zp.Heading, zp.Instance, zp.ZoneID);

                SQLOut(Insert);
            }
        }
コード例 #3
0
        public void GenerateSpawnSQL(bool GenerateSpawns, bool GenerateGrids, bool GenerateMerchants,
            string ZoneName, UInt32 ZoneID, UInt32 SpawnVersion,
            bool UpdateExistingNPCTypes, bool UseNPCTypesTint, string SpawnNameFilter,
            bool CoalesceWaypoints, bool IncludeInvisibleMen, SQLDestination SQLOut)
        {
            UInt32 NPCTypeDBID = 0;
            UInt32 SpawnGroupID = 0;
            UInt32 SpawnEntryID = 0;
            UInt32 Spawn2ID = 0;
            UInt32 GridDBID = 0;
            UInt32 MerchantDBID = 0;

            List<ZoneEntryStruct> ZoneSpawns = PatchDecoder.GetSpawns();

            List<UInt32> FindableEntities = PatchDecoder.GetFindableSpawns();

            if (GenerateSpawns)
            {
                SQLOut("--");
                SQLOut("-- Spawns");
                SQLOut("--");
                if (SpawnVersion == 0)
                {
                    SQLOut("DELETE from npc_types where id >= @StartingNPCTypeID and id <= @StartingNPCTypeID + 999 and version = " + SpawnVersion + ";");

                    if(UseNPCTypesTint)
                        SQLOut("DELETE from npc_types_tint where id >= @StartingNPCTypeID and id <= @StartingNPCTypeID + 999;");

                    SQLOut("DELETE from spawngroup where id >= @StartingSpawnGroupID and id <= @StartingSpawnGroupID + 999;");
                    SQLOut("DELETE from spawnentry where spawngroupID >= @StartingSpawnEntryID and spawngroupID <= @StartingSpawnEntryID + 999;");
                    SQLOut("DELETE from spawn2 where id >= @StartingSpawn2ID and id <= @StartingSpawn2ID + 999 and version = " + SpawnVersion + ";");
                }
                else
                {
                    SQLOut("DELETE from npc_types where id >= @StartingNPCTypeID and id <= @StartingNPCTypeID + 99 and version = " + SpawnVersion + ";");
                    SQLOut("DELETE from spawngroup where id >= @StartingSpawnGroupID and id <= @StartingSpawnGroupID + 99;");
                    SQLOut("DELETE from spawnentry where spawngroupID >= @StartingSpawnEntryID and spawngroupID <= @StartingSpawnEntryID + 99;");
                    SQLOut("DELETE from spawn2 where id >= @StartingSpawn2ID and id <= @StartingSpawn2ID + 99 and version = " + SpawnVersion + ";");
                }

            }

            NPCTypeList NPCTL = new NPCTypeList();

            NPCSpawnList NPCSL = new NPCSpawnList();

            foreach(ZoneEntryStruct Spawn in ZoneSpawns)
            {
                if (NPCType.IsMount(Spawn.SpawnName))
                    continue;

                if (!IncludeInvisibleMen && (Spawn.Race == 127))
                    continue;

                Spawn.Findable = (FindableEntities.IndexOf(Spawn.SpawnID) >= 0);

                if (Spawn.IsNPC != 1)
                    continue;

                if (Spawn.PetOwnerID > 0)
                    continue;

                if ((SpawnNameFilter.Length > 0) && (Spawn.SpawnName.IndexOf(SpawnNameFilter) == -1))
                    continue;

                bool ColoursInUse = false;

                for (int ColourSlot = 0; ColourSlot < 9; ++ColourSlot)
                {
                    if (((Spawn.SlotColour[ColourSlot] & 0x00ffffff) != 0) && UseNPCTypesTint)
                        ColoursInUse = true;
                }

                if (Spawn.IsMercenary > 0)
                    continue;

                UInt32 ExistingDBID = NPCTL.FindNPCType(Spawn.SpawnName, Spawn.Level, Spawn.Gender, Spawn.Size, Spawn.Face, Spawn.WalkSpeed, Spawn.RunSpeed, Spawn.Race,
                       Spawn.BodyType, Spawn.HairColor, Spawn.BeardColor, Spawn.EyeColor1, Spawn.EyeColor2, Spawn.HairStyle, Spawn.Beard,
                       Spawn.DrakkinHeritage, Spawn.DrakkinTattoo, Spawn.DrakkinDetails, Spawn.Deity, Spawn.Class, Spawn.EquipChest2,
                       Spawn.Helm, Spawn.LastName);

                if (ExistingDBID == 0)
                {
                    NPCType NewNPCType = new NPCType(NPCTypeDBID, Spawn.SpawnName, Spawn.Level, Spawn.Gender, Spawn.Size, Spawn.Face, Spawn.WalkSpeed, Spawn.RunSpeed, Spawn.Race,
                       Spawn.BodyType, Spawn.HairColor, Spawn.BeardColor, Spawn.EyeColor1, Spawn.EyeColor2, Spawn.HairStyle, Spawn.Beard,
                       Spawn.DrakkinHeritage, Spawn.DrakkinTattoo, Spawn.DrakkinDetails, Spawn.Deity, Spawn.Class, Spawn.EquipChest2,
                       Spawn.Helm, Spawn.LastName, Spawn.Findable, Spawn.MeleeTexture1, Spawn.MeleeTexture2, Spawn.ArmorTintRed, Spawn.ArmorTintGreen, Spawn.ArmorTintBlue, Spawn.SlotColour);

                    NPCTL.AddNPCType(NewNPCType);

                    ExistingDBID = NPCTypeDBID++;

                    UInt32 ArmorTintID = 0;

                    if (ColoursInUse)
                    {
                        ArmorTintID = ExistingDBID;
                        Spawn.ArmorTintRed = 0;
                        Spawn.ArmorTintGreen = 0;
                        Spawn.ArmorTintBlue = 0;
                    }

                    string NPCTypesQuery = "INSERT INTO npc_types(`id`, `name`, `lastname`, `level`, `gender`, `size`, `runspeed`,`race`, `class`, `bodytype`, `hp`, `texture`, `helmtexture`, `face`, `luclin_hairstyle`, `luclin_haircolor`, `luclin_eyecolor`, `luclin_eyecolor2`,`luclin_beard`, `luclin_beardcolor`, `findable`, `version`, `d_meele_texture1`, `d_meele_texture2`, `armortint_red`, `armortint_green`, `armortint_blue`, `drakkin_heritage`, `drakkin_tattoo`, `drakkin_details`) VALUES(";

                    NPCTypesQuery += "@StartingNPCTypeID + " + ExistingDBID + ", '" + Spawn.SpawnName + "', " + "'" + Spawn.LastName + "', " + Spawn.Level + ", " + Spawn.Gender + ", " + Spawn.Size + ", ";
                    NPCTypesQuery += Spawn.RunSpeed + ", " + Spawn.Race + ", " + Spawn.Class + ", " + Spawn.BodyType + ", " + Spawn.Level * (10 + Spawn.Level) + ", ";
                    NPCTypesQuery += Spawn.EquipChest2 + ", " + Spawn.Helm + ", " + Spawn.Face + ", " + Spawn.HairStyle + ", " + Spawn.HairColor + ", " + Spawn.EyeColor1 + ", ";
                    NPCTypesQuery += Spawn.EyeColor2 + ", " + Spawn.Beard + ", " + Spawn.BeardColor + ", " + (Spawn.Findable ? 1 : 0) + ", " + SpawnVersion + ", ";
                    NPCTypesQuery += Spawn.MeleeTexture1 + ", " + Spawn.MeleeTexture2 + ", " + Spawn.ArmorTintRed + ", " + Spawn.ArmorTintGreen + ", " + Spawn.ArmorTintBlue + ", ";
                    NPCTypesQuery += Spawn.DrakkinHeritage + ", " + Spawn.DrakkinTattoo + ", " + Spawn.DrakkinDetails + ");";

                    if (GenerateSpawns)
                        SQLOut(NPCTypesQuery);

                    if (GenerateSpawns && ColoursInUse && NPCType.IsPlayableRace(Spawn.Race))
                    {
                        string TintQuery = "REPLACE INTO npc_types_tint(id, tint_set_name, ";
                        TintQuery += "red1h, grn1h, blu1h, ";
                        TintQuery += "red2c, grn2c, blu2c, ";
                        TintQuery += "red3a, grn3a, blu3a, ";
                        TintQuery += "red4b, grn4b, blu4b, ";
                        TintQuery += "red5g, grn5g, blu5g, ";
                        TintQuery += "red6l, grn6l, blu6l, ";
                        TintQuery += "red7f, grn7f, blu7f, ";
                        TintQuery += "red8x, grn8x, blu8x, ";
                        TintQuery += "red9x, grn9x, blu9x) values(@StartingNPCTypeID + " + ExistingDBID + ", '" + Spawn.SpawnName + "'";

                        for (int sc = 0; sc < 9; ++sc)
                        {
                            TintQuery += String.Format(", {0}, {1}, {2}", (Spawn.SlotColour[sc] >> 16) & 0xff,
                                                                           (Spawn.SlotColour[sc] >> 8) & 0xff,
                                                                           (Spawn.SlotColour[sc] & 0xff));
                        }

                        TintQuery += ");";
                        SQLOut(TintQuery);
                        SQLOut("UPDATE npc_types SET armortint_id = @StartingNPCTypeID + " + ArmorTintID + " WHERE id = @StartingNPCTypeID + " + ExistingDBID + " LIMIT 1;");
                    }

                }

                NPCSL.AddNPCSpawn(Spawn.SpawnID, Spawn2ID, ExistingDBID, Spawn.SpawnName);

                Position p = new Position(Spawn.XPos, Spawn.YPos, Spawn.ZPos, Spawn.Heading, DateTime.MinValue);

                NPCSL.AddWaypoint(Spawn.SpawnID, p, false);

                string SpawnGroupQuery = "INSERT INTO spawngroup(`id`, `name`, `spawn_limit`, `dist`, `max_x`, `min_x`, `max_y`, `min_y`, `delay`) VALUES(";
                SpawnGroupQuery += "@StartingSpawnGroupID + " + SpawnGroupID + ", CONCAT('" + ZoneName + "', @StartingSpawnGroupID + " + SpawnGroupID + "), 0, 0, 0, 0, 0, 0, 0);";

                string SpawnEntryQuery = "INSERT INTO spawnentry(`spawngroupID`, `npcID`, `chance`) VALUES(";
                SpawnEntryQuery += "@StartingSpawnEntryID + " + SpawnEntryID + ", @StartingNPCTypeID + " + ExistingDBID + ", " + "100);";

                string Spawn2EntryQuery = "INSERT INTO spawn2(`id`, `spawngroupID`, `zone`, `version`, `x`, `y`, `z`, `heading`, `respawntime`, `variance`, `pathgrid`, `_condition`, `cond_value`, `enabled`) VALUES(";
                Spawn2EntryQuery += "@StartingSpawn2ID + " + Spawn2ID + ", @StartingSpawnGroupID + " + SpawnGroupID + ", '" + ZoneName + "', " + SpawnVersion + ", " + Spawn.XPos + ", " + Spawn.YPos + ", " + Spawn.ZPos + ", ";
                Spawn2EntryQuery += Spawn.Heading + ", 640, 0, 0, 0, 1, 1);";

                SpawnGroupID++;
                SpawnEntryID++;
                Spawn2ID++;

                if (GenerateSpawns)
                {
                    SQLOut(SpawnGroupQuery);
                    SQLOut(SpawnEntryQuery);
                    SQLOut(Spawn2EntryQuery);
                }
            }

            if (UpdateExistingNPCTypes)
            {
                List<NPCType> UniqueSpawns = NPCTL.GetUniqueSpawns();

                foreach (NPCType n in UniqueSpawns)
                {
                    string UpdateQuery = "UPDATE npc_types set texture = {0}, helmtexture = {1}, size = {2}, face = {3}, luclin_hairstyle = {4}, ";
                    UpdateQuery += "luclin_haircolor = {5}, luclin_eyecolor = {6}, luclin_eyecolor2 = {7}, luclin_beardcolor = {8}, ";
                    UpdateQuery += "luclin_beard = {9}, drakkin_heritage = {10}, drakkin_tattoo = {11}, drakkin_details = {12}, ";
                    UpdateQuery += "armortint_red = {13}, armortint_green = {14}, armortint_blue = {15}, d_meele_texture1 = {16}, ";
                    UpdateQuery += "d_meele_texture2 = {17}, findable = {18}, gender = {20} where name = '{19}' and id >= @StartingNPCTypeID and id <= @StartingNPCTypeID + 999 and version = {21};";

                    SQLOut(String.Format(UpdateQuery, n.EquipChest2, n.Helm, n.Size, n.Face, n.HairStyle, n.HairColor, n.EyeColor1, n.EyeColor2, n.BeardColor,
                                                      n.Beard, n.DrakkinHeritage, n.DrakkinTattoo, n.DrakkinDetails, n.ArmorTintRed, n.ArmorTintGreen,
                                                      n.ArmorTintBlue, n.MeleeTexture1, n.MeleeTexture2, n.Findable, n.Name, n.Gender, SpawnVersion));

                    if(!NPCType.IsPlayableRace(n.Race))
                        continue;

                    bool ColoursInUse = false;

                    for (int ColourSlot = 0; ColourSlot < 9; ++ColourSlot)
                    {
                        if (((n.SlotColour[ColourSlot] & 0x00ffffff) != 0) && UseNPCTypesTint)
                            ColoursInUse = true;
                    }

                    if (ColoursInUse)
                    {
                        string TintQuery = "REPLACE INTO npc_types_tint(id, tint_set_name, ";
                        TintQuery += "red1h, grn1h, blu1h, ";
                        TintQuery += "red2c, grn2c, blu2c, ";
                        TintQuery += "red3a, grn3a, blu3a, ";
                        TintQuery += "red4b, grn4b, blu4b, ";
                        TintQuery += "red5g, grn5g, blu5g, ";
                        TintQuery += "red6l, grn6l, blu6l, ";
                        TintQuery += "red7f, grn7f, blu7f, ";
                        TintQuery += "red8x, grn8x, blu8x, ";
                        TintQuery += "red9x, grn9x, blu9x) SELECT id, '" + n.Name + "'";

                        for (int sc = 0; sc < 9; ++sc)
                        {
                            TintQuery += String.Format(", {0}, {1}, {2}", (n.SlotColour[sc] >> 16) & 0xff,
                                                                           (n.SlotColour[sc] >> 8) & 0xff,
                                                                           (n.SlotColour[sc] & 0xff));
                        }

                        TintQuery += " from npc_types where name = '" + n.Name + "' and id >= @StartingNPCTypeID and id <= @StartingNPCTypeID + 999 and version = " + SpawnVersion + " LIMIT 1;";
                        SQLOut(TintQuery);
                        SQLOut(String.Format("UPDATE npc_types set armortint_id = (SELECT id from npc_types_tint WHERE tint_set_name = '{0}' and id >= @StartingNPCTypeID and id <= @StartingNPCTypeID + 999 and version = {1} LIMIT 1), armortint_red = 0, armortint_green = 0, armortint_blue = 0 WHERE name = '{0}' and id >= @StartingNPCTypeID and id <= @StartingNPCTypeID + 999 and version = {1} LIMIT 1;",
                            n.Name, SpawnVersion));
                    }
                }
                return;
            }

            if (GenerateGrids)
            {
                List<PositionUpdate> AllMovementUpdates = PatchDecoder.GetAllMovementUpdates();

                foreach (PositionUpdate Update in AllMovementUpdates)
                    NPCSL.AddWaypoint(Update.SpawnID, Update.p, Update.HighRes);

                SQLOut("--");
                SQLOut("-- Grids");
                SQLOut("--");

                SQLOut("DELETE from grid WHERE id >= @StartingGridID AND id <= @StartingGridID + 999;");
                SQLOut("DELETE from grid_entries WHERE gridid >= @StartingGridID AND gridid <= @StartingGridID + 999;");
                foreach (NPCSpawn ns in NPCSL._NPCSpawnList)
                {
                    if (ns.Waypoints.Count > 1)
                    {
                        bool AllWaypointsTheSame = true;

                        for (int WPNumber = 0; WPNumber < ns.Waypoints.Count; ++WPNumber)
                        {
                            if (WPNumber == 0)
                                continue;
                            if ((ns.Waypoints[WPNumber].x != ns.Waypoints[WPNumber - 1].x) ||
                               (ns.Waypoints[WPNumber].y != ns.Waypoints[WPNumber - 1].y) ||
                               (ns.Waypoints[WPNumber].z != ns.Waypoints[WPNumber - 1].z))
                            {
                                AllWaypointsTheSame = false;
                            }
                        }

                        if (AllWaypointsTheSame)
                            continue;

                        int WaypointsInserted = 0;

                        int WPNum = 1;

                        int Pause = 10;

                        int FirstUsableWaypoint = 0;

                        if (ns.DoesHaveHighResWaypoints())
                            FirstUsableWaypoint = 1;

                        for (int WPNumber = FirstUsableWaypoint; WPNumber < ns.Waypoints.Count; ++WPNumber)
                        {
                            Position p = ns.Waypoints[WPNumber];

                            if (CoalesceWaypoints)
                            {
                                if ((WPNumber > FirstUsableWaypoint) && (WPNumber < (ns.Waypoints.Count - 2)))
                                {
                                    Position np = ns.Waypoints[WPNumber + 1];

                                    if ((Math.Abs(p.heading - np.heading) < 1) || (Math.Abs(p.heading - np.heading) > 255))
                                    {
                                        // Skipping waypoint as heading is the same as next.
                                        continue;
                                    }
                                    if ((Math.Abs(p.heading - np.heading) < 5) || (Math.Abs(p.heading - np.heading) > 251))
                                    {
                                        // Setting pause to 0 because headings are similar
                                        Pause = 0;
                                    }
                                    else if ((p.x == np.x) && (p.y == np.y) && (p.z == np.z))
                                    {
                                        // Skipping waypoint as same as next");
                                        continue;
                                    }
                                    else
                                        Pause = 10;
                                }
                            }

                            // If this is the last waypoint, and we haven't inserted any of the previous ones, then don't bother
                            // with this one either.
                            if ((WPNumber == (ns.Waypoints.Count - 1)) && (WaypointsInserted == 0))
                                continue;

                            SQLOut("INSERT into grid_entries (`gridid`, `zoneid`, `number`, `x`, `y`, `z`, `heading`, `pause`) VALUES(@StartingGridID + " + GridDBID + ", " + ZoneID + ", " + (WPNum++) + ", " + p.x + ", " + p.y + ", " + p.z + ", " + p.heading + ", " + Pause + ");");

                            ++WaypointsInserted;
                        }
                        if (WaypointsInserted > 1)
                        {
                            SQLOut("INSERT into grid(`id`, `zoneid`, `type`, `type2`) VALUES(@StartingGridID + " + GridDBID + ", " + ZoneID + ", 3, 2); -- " + ns.Name);

                            SQLOut("UPDATE spawn2 set pathgrid = @StartingGridID + " + GridDBID + " WHERE id = @StartingSpawn2ID + " + ns.Spawn2DBID + ";");

                            if (ns.DoesHaveHighResWaypoints())
                                SQLOut("UPDATE spawn2 set x = " + ns.Waypoints[1].x + ", y = " + ns.Waypoints[1].y + ", z = " + ns.Waypoints[1].z + ", heading = " + ns.Waypoints[1].heading + " WHERE id = @StartingSpawn2ID + " + ns.Spawn2DBID + ";");

                            ++GridDBID;
                        }
                    }
                }
            }
            if(GenerateMerchants)
                GenerateMerchantSQL(NPCSL, MerchantDBID, GenerateSpawns, SQLOut);
        }
コード例 #4
0
        public void GenerateObjectSQL(bool DoGroundSpawns, bool DoObjects, UInt32 SpawnVersion, SQLDestination SQLOut)
        {
            List<GroundSpawnStruct> GroundSpawns = PatchDecoder.GetGroundSpawns();

            UInt32 GroundSpawnDBID = 0;
            UInt32 ObjectDBID = 0;

            SQLOut("--");
            SQLOut("-- Objects and Groundspawns");
            SQLOut("--");

            if(DoGroundSpawns)
                SQLOut("DELETE from ground_spawns where id >= @StartingGroundSpawnID and id <= @StartingGroundSpawnID + 999 and version = " + SpawnVersion + ";");

            if(DoObjects)
                SQLOut("DELETE from object where id >= @StartingObjectID and id <= @StartingObjectID + 999 and version = " + SpawnVersion + ";");

            foreach(GroundSpawnStruct GroundSpawn in GroundSpawns)
            {
                String Insert;

                if (IsGroundSpawn(GroundSpawn.ObjectType) && DoGroundSpawns)
                {
                    Insert = "INSERT into ground_spawns(`id`, `zoneid`, `version`, `max_x`, `max_y`, `max_z`, `min_x`, `min_y`, `heading`, `name`, `item`, `max_allowed`, `comment`, `respawn_timer`) VALUES(";

                    Insert += "@StartingGroundSpawnID + " + (GroundSpawnDBID++) + ", " + GroundSpawn.ZoneID + ", " + SpawnVersion + ", " + GroundSpawn.x + ", " + GroundSpawn.y + ", " + GroundSpawn.z + ", " + GroundSpawn.x + ", " + GroundSpawn.y + ", " + GroundSpawn.Heading + ", '" + GroundSpawn.Name + "', 1001, 1, 'Auto generated by Collector. FIX THE ITEMID!', 300000);";

                    SQLOut(Insert);
                }
                else if(!IsGroundSpawn(GroundSpawn.ObjectType) && DoObjects)
                {
                    GroundSpawn.ObjectType = ObjectNameToType(GroundSpawn.Name);

                    Insert = "INSERT into object(`id`, `zoneid`, `version`, `xpos`, `ypos`, `zpos`, `heading`, `itemid`, `charges`, `objectname`, `type`, `icon`) VALUES(";

                    Insert += "@StartingObjectID + " + (ObjectDBID++) + ", " + GroundSpawn.ZoneID + ", " + SpawnVersion + ", " + GroundSpawn.x + ", " + GroundSpawn.y + ", " + GroundSpawn.z + ", " + GroundSpawn.Heading + ", 0, 0, '" + GroundSpawn.Name + "', " + GroundSpawn.ObjectType + ", 0);";

                    SQLOut(Insert);
                }
            }
        }
コード例 #5
0
        public void GenerateMerchantSQL(NPCSpawnList NPCSL, UInt32 MerchantDBID, bool GenerateSpawns, SQLDestination SQLOut)
        {
            MerchantManager mm = PatchDecoder.GetMerchantData(NPCSL);

            if(GenerateSpawns)
                SQLOut("DELETE from merchantlist where merchantid >= @StartingMerchantID and merchantid <= @StartingMerchantID + 999;");

            SQLOut("--");
            SQLOut("-- Merchant Lists");
            SQLOut("-- ");

            foreach (Merchant m in mm.MerchantList)
            {
                UInt32 MerchantSpawnID = m.SpawnID;

                NPCSpawn npc = NPCSL.GetNPC(MerchantSpawnID);

                if(npc == null)
                    continue;

                UInt32 MerchantNPCTypeID = npc.NPCTypeID;

                SQLOut("--");
                SQLOut("-- " + npc.Name);
                SQLOut("-- ");

                bool StartOfPlayerSoldItems = false;

                foreach (MerchantItem mi in m.Items)
                {
                    string Insert = "";

                    if (mi.Quantity >= 0)
                    {
                        if (!StartOfPlayerSoldItems)
                        {
                            StartOfPlayerSoldItems = true;
                            SQLOut("--");
                            SQLOut("-- The items below were more than likely sold to " + npc.Name + " by players. Uncomment them if you want.");
                            SQLOut("--");
                        }

                        Insert += "-- ";
                    }

                    Insert += "INSERT into merchantlist(`merchantid`, `slot`, `item`) VALUES(";

                    Insert += "@StartingMerchantID + " + MerchantDBID + ", " + mi.Slot + ", " + mi.ItemID + "); -- " + mi.Name;

                    SQLOut(Insert);
                }

                if(GenerateSpawns)
                    SQLOut("UPDATE npc_types SET merchant_id = @StartingMerchantID + " + MerchantDBID + " WHERE id = @StartingNPCTypeID + " + MerchantNPCTypeID + ";");

                ++MerchantDBID;
            }
        }
コード例 #6
0
        public void GenerateDoorsSQL(string ZoneName, int DoorDBID, UInt32 SpawnVersion, SQLDestination SQLOut)
        {
            List<Door> DoorList = PatchDecoder.GetDoors();

            SQLOut("--");
            SQLOut("-- Doors");
            SQLOut("--");
            int UpperBound = (DoorDBID == 1 ? 998 : 999);
            SQLOut("DELETE from doors where zone = '" + ZoneName + "' and doorid >= @BaseDoorID and doorid <= @BaseDoorID + " + UpperBound + " and version = " + SpawnVersion + ";");

            foreach(Door d in DoorList)
            {
                if ((d.OpenType == 57) || (d.OpenType == 58))
                {
                    ZonePoint? zp = GetZonePointNumber(d.DoorParam);

                    if (zp != null)
                    {
                        d.DestZone = ZoneNumberToName(zp.Value.TargetZoneID);
                        d.DestX = zp.Value.TargetX;
                        d.DestY = zp.Value.TargetY;
                        d.DestZ = zp.Value.TargetZ;
                        d.DestHeading = zp.Value.Heading;

                    }
                }

                string DoorQuery = "INSERT INTO doors(`doorid`, `zone`, `version`, `name`, `pos_y`, `pos_x`, `pos_z`, `heading`, `opentype`, `doorisopen`, `door_param`, `dest_zone`, `dest_x`, `dest_y`, `dest_z`, `dest_heading`, `invert_state`, `incline`, `size`) VALUES(";
                DoorQuery += "@BaseDoorID + " + d.ID + ", '" + ZoneName + "', " + SpawnVersion + ", '" + d.Name + "', " + d.YPos + ", " + d.XPos + ", " + d.ZPos + ", " + d.Heading + ", " + d.OpenType + ", " + d.StateAtSpawn + ", " + d.DoorParam + ", '" + d.DestZone + "', " + d.DestX + ", " + d.DestY + ", " + d.DestZ + ", " + d.DestHeading + ", " + d.InvertState + ", " + d.Incline + ", " + d.Size + ");";

                SQLOut(DoorQuery);
            }
        }