Exemplo n.º 1
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }


            #region defineNPCS

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Lady Grynoch", eRealm.Albion);

            if (npcs.Length == 0)
            {
                LadyGrynoch       = new GameNPC();
                LadyGrynoch.Model = 5;
                LadyGrynoch.Name  = "Lady Grynoch";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + LadyGrynoch.Name + ", creating her ...");
                }
                //k109: My preference, no guildname for quest NPCs.  Uncomment if you like that...
                //LadyGrynoch.GuildName = "Part of " + questTitle + " Quest";
                LadyGrynoch.Realm           = eRealm.Albion;
                LadyGrynoch.CurrentRegionID = 1;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 58);                    //Slot 25
                LadyGrynoch.Inventory = template.CloseTemplate();
                LadyGrynoch.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                LadyGrynoch.Size    = 51;
                LadyGrynoch.Level   = 38;
                LadyGrynoch.X       = 559698;
                LadyGrynoch.Y       = 513578;
                LadyGrynoch.Z       = 2428;
                LadyGrynoch.Heading = 2742;

                if (SAVE_INTO_DATABASE)
                {
                    LadyGrynoch.SaveIntoDatabase();
                }

                LadyGrynoch.AddToWorld();
            }
            else
            {
                LadyGrynoch = npcs[0];
            }

            #endregion
            #region defineAreas
            Demons_Breach_Area = WorldMgr.GetRegion(Demons_Breach.RegionID).AddArea(new Area.Circle("", Demons_Breach.Position, 200));
            Demons_Breach_Area.RegisterPlayerEnter(new DOLEventHandler(PlayerEnterDemonBreachArea));
            #endregion

            GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
            GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));

            GameEventMgr.AddHandler(LadyGrynoch, GameLivingEvent.Interact, new DOLEventHandler(TalkToLadyGrynoch));
            GameEventMgr.AddHandler(LadyGrynoch, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToLadyGrynoch));

            LadyGrynoch.AddQuestToGive(typeof(ToReachTheBreach));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Exemplo n.º 2
0
        public static bool Start(GameClient client = null)
        {
            // load hookpoint offsets
            House.LoadHookpointOffsets();

            // initialize the house template manager
            HouseTemplateMgr.Initialize();

            _houseList = new Dictionary <ushort, Dictionary <int, House> >();
            _idList    = new Dictionary <ushort, int>();

            int regions = 0;

            foreach (RegionEntry entry in WorldMgr.GetRegionList())
            {
                Region reg = WorldMgr.GetRegion(entry.id);
                if (reg != null && reg.UseHousingManager)
                {
                    if (!_houseList.ContainsKey(reg.ID))
                    {
                        _houseList.Add(reg.ID, new Dictionary <int, House>());
                    }

                    if (!_idList.ContainsKey(reg.ID))
                    {
                        _idList.Add(reg.ID, 0);
                    }

                    regions++;
                }
            }

            int houses     = 0;
            int lotmarkers = 0;

            foreach (DBHouse house in GameServer.Database.SelectAllObjects <DBHouse>())
            {
                Dictionary <int, House> housesForRegion;

                _houseList.TryGetValue(house.RegionID, out housesForRegion);

                // if we don't have the given region loaded as a housing zone, skip this house
                if (housesForRegion == null)
                {
                    continue;
                }

                // if we already loaded this house, that's no bueno, but just skip
                if (housesForRegion.ContainsKey(house.HouseNumber))
                {
                    continue;
                }

                if (SpawnLot(house, housesForRegion) == eLotSpawnType.House)
                {
                    houses++;
                }
                else
                {
                    lotmarkers++;
                }
            }

            if (log.IsInfoEnabled)
            {
                log.Info("[Housing] Loaded " + houses + " houses and " + lotmarkers + " lotmarkers in " + regions + " regions!");
            }

            if (client != null)
            {
                client.Out.SendMessage("Loaded " + houses + " houses and " + lotmarkers + " lotmarkers in " + regions + " regions!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }

            if (CheckRentTimer != null)
            {
                CheckRentTimer.Change(Properties.RENT_CHECK_INTERVAL * 60 * 1000, Properties.RENT_CHECK_INTERVAL * 60 * 1000);
            }
            else
            {
                CheckRentTimer = new Timer(CheckRents, null, Properties.RENT_CHECK_INTERVAL * 60 * 1000, Properties.RENT_CHECK_INTERVAL * 60 * 1000);
            }

            return(true);
        }
Exemplo n.º 3
0
        // Dunnerholl 2009-09-10 i do not like the way this is done
        public override void SendCharacterOverview(eRealm realm)
        {
            int firstAccountSlot;

            switch (realm)
            {
            case eRealm.Albion:
                firstAccountSlot = 100;
                break;

            case eRealm.Midgard:
                firstAccountSlot = 200;
                break;

            case eRealm.Hibernia:
                firstAccountSlot = 300;
                break;

            default:
                throw new Exception("CharacterOverview requested for unknown realm " + realm);
            }

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview)))
            {
                pak.FillString(m_gameClient.Account.Name, 24);
                IList <InventoryItem> items;
                DOLCharacters[]       characters = m_gameClient.Account.Characters;
                if (characters == null)
                {
                    pak.Fill(0x0, 1880);
                }
                else
                {
                    for (int i = firstAccountSlot; i < firstAccountSlot + 10; i++)
                    {
                        bool written = false;
                        for (int j = 0; j < characters.Length && !written; j++)
                        {
                            if (characters[j].AccountSlot == i)
                            {
                                pak.FillString(characters[j].Name, 24);
                                items = DOLDB <InventoryItem> .SelectObjects(DB.Column(nameof(InventoryItem.OwnerID)).IsEqualTo(characters[j].ObjectId).And(DB.Column(nameof(InventoryItem.SlotPosition)).IsGreaterOrEqualTo(10)).And(DB.Column(nameof(InventoryItem.SlotPosition)).IsLessOrEqualTo(37)));

                                byte ExtensionTorso  = 0;
                                byte ExtensionGloves = 0;
                                byte ExtensionBoots  = 0;
                                foreach (InventoryItem item in items)
                                {
                                    switch (item.SlotPosition)
                                    {
                                    case 22:
                                        ExtensionGloves = item.Extension;
                                        break;

                                    case 23:
                                        ExtensionBoots = item.Extension;
                                        break;

                                    case 25:
                                        ExtensionTorso = item.Extension;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                                pak.WriteByte(0x01);
                                pak.WriteByte((byte)characters[j].EyeSize);
                                pak.WriteByte((byte)characters[j].LipSize);
                                pak.WriteByte((byte)characters[j].EyeColor);
                                pak.WriteByte((byte)characters[j].HairColor);
                                pak.WriteByte((byte)characters[j].FaceType);
                                pak.WriteByte((byte)characters[j].HairStyle);
                                pak.WriteByte((byte)((ExtensionBoots << 4) | ExtensionGloves));
                                pak.WriteByte((byte)((ExtensionTorso << 4) | (characters[j].IsCloakHoodUp ? 0x1 : 0x0)));
                                pak.WriteByte((byte)characters[j].CustomisationStep); //1 = auto generate config, 2= config ended by player, 3= enable config to player
                                pak.WriteByte((byte)characters[j].MoodType);
                                pak.Fill(0x0, 13);                                    //0 String
                                Region reg = WorldMgr.GetRegion((ushort)characters[j].Region);
                                if (reg != null)
                                {
                                    var description = m_gameClient.GetTranslatedSpotDescription(reg, characters[j].Xpos, characters[j].Ypos, characters[j].Zpos);
                                    pak.FillString(description, 24);
                                }
                                else
                                {
                                    pak.Fill(0x0, 24);                                     //No known location
                                }
                                if (characters[j].Class == 0)
                                {
                                    pak.FillString("", 24);                                     //Class name
                                }
                                else
                                {
                                    pak.FillString(((eCharacterClass)characters[j].Class).ToString(), 24);                                     //Class name
                                }
                                //pak.FillString(GamePlayer.RACENAMES[characters[j].Race], 24);
                                pak.FillString(m_gameClient.RaceToTranslatedName(characters[j].Race, characters[j].Gender), 24);
                                pak.WriteByte((byte)characters[j].Level);
                                pak.WriteByte((byte)characters[j].Class);
                                pak.WriteByte((byte)characters[j].Realm);
                                pak.WriteByte((byte)((((characters[j].Race & 0x10) << 2) + (characters[j].Race & 0x0F)) | (characters[j].Gender << 4)));                                 // race max value can be 0x1F
                                pak.WriteShortLowEndian((ushort)characters[j].CurrentModel);
                                pak.WriteByte((byte)characters[j].Region);
                                if (reg == null || (int)m_gameClient.ClientType > reg.Expansion)
                                {
                                    pak.WriteByte(0x00);
                                }
                                else
                                {
                                    pak.WriteByte((byte)(reg.Expansion + 1));      //0x04-Cata zone, 0x05 - DR zone
                                }
                                pak.WriteInt(0x0);                                 // Internal database ID
                                pak.WriteByte((byte)characters[j].Strength);
                                pak.WriteByte((byte)characters[j].Dexterity);
                                pak.WriteByte((byte)characters[j].Constitution);
                                pak.WriteByte((byte)characters[j].Quickness);
                                pak.WriteByte((byte)characters[j].Intelligence);
                                pak.WriteByte((byte)characters[j].Piety);
                                pak.WriteByte((byte)characters[j].Empathy);
                                pak.WriteByte((byte)characters[j].Charisma);

                                int found = 0;
                                //16 bytes: armor model
                                for (int k = 0x15; k < 0x1D; k++)
                                {
                                    found = 0;
                                    foreach (InventoryItem item in items)
                                    {
                                        if (item.SlotPosition == k && found == 0)
                                        {
                                            pak.WriteShortLowEndian((ushort)item.Model);
                                            found = 1;
                                        }
                                    }
                                    if (found == 0)
                                    {
                                        pak.WriteShort(0x00);
                                    }
                                }
                                //16 bytes: armor color
                                for (int k = 0x15; k < 0x1D; k++)
                                {
                                    int l;
                                    if (k == 0x15 + 3)
                                    {
                                        //shield emblem
                                        l = (int)eInventorySlot.LeftHandWeapon;
                                    }
                                    else
                                    {
                                        l = k;
                                    }

                                    found = 0;
                                    foreach (InventoryItem item in items)
                                    {
                                        if (item.SlotPosition == l && found == 0)
                                        {
                                            if (item.Emblem != 0)
                                            {
                                                pak.WriteShortLowEndian((ushort)item.Emblem);
                                            }
                                            else
                                            {
                                                pak.WriteShortLowEndian((ushort)item.Color);
                                            }
                                            found = 1;
                                        }
                                    }
                                    if (found == 0)
                                    {
                                        pak.WriteShort(0x00);
                                    }
                                }
                                //8 bytes: weapon model
                                for (int k = 0x0A; k < 0x0E; k++)
                                {
                                    found = 0;
                                    foreach (InventoryItem item in items)
                                    {
                                        if (item.SlotPosition == k && found == 0)
                                        {
                                            pak.WriteShortLowEndian((ushort)item.Model);
                                            found = 1;
                                        }
                                    }
                                    if (found == 0)
                                    {
                                        pak.WriteShort(0x00);
                                    }
                                }
                                if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.TwoHanded)
                                {
                                    pak.WriteByte(0x02);
                                    pak.WriteByte(0x02);
                                }
                                else if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.Distance)
                                {
                                    pak.WriteByte(0x03);
                                    pak.WriteByte(0x03);
                                }
                                else
                                {
                                    byte righthand = 0xFF;
                                    byte lefthand  = 0xFF;
                                    foreach (InventoryItem item in items)
                                    {
                                        if (item.SlotPosition == (int)eInventorySlot.RightHandWeapon)
                                        {
                                            righthand = 0x00;
                                        }
                                        if (item.SlotPosition == (int)eInventorySlot.LeftHandWeapon)
                                        {
                                            lefthand = 0x01;
                                        }
                                    }
                                    if (righthand == lefthand)
                                    {
                                        if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.TwoHanded)
                                        {
                                            righthand = lefthand = 0x02;
                                        }
                                        else if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.Distance)
                                        {
                                            righthand = lefthand = 0x03;
                                        }
                                    }
                                    pak.WriteByte(righthand);
                                    pak.WriteByte(lefthand);
                                }
                                if (reg == null || reg.Expansion != 1)
                                {
                                    pak.WriteByte(0x00);
                                }
                                else
                                {
                                    pak.WriteByte(0x01);                                     //0x01=char in ShroudedIsles zone, classic client can't "play"
                                }
                                pak.WriteByte((byte)characters[j].Constitution);
                                pak.Fill(0x0, 4);                                //new trailing bytes in 1.99
                                written = true;
                            }
                        }
                        if (!written)
                        {
                            pak.Fill(0x0, 188);
                        }
                    }
                }
                pak.Fill(0x0, 90);

                SendTCP(pak);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Send Game Doors Depening on last refresh time.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="nowTicks"></param>
        private static void UpdatePlayerDoors(GamePlayer player, long nowTicks)
        {
            // Get All Game Doors in Range
            var doors = player.GetDoorsInRadius(WorldMgr.OBJ_UPDATE_DISTANCE).Cast <IDoor>().OfType <GameObject>().Where(o => o.IsVisibleTo(player)).ToArray();

            try
            {
                // Clean Cache
                foreach (var objEntry in player.Client.GameObjectUpdateArray)
                {
                    var        objKey = objEntry.Key;
                    GameObject obj    = WorldMgr.GetRegion(objKey.Item1).GetObject(objKey.Item2);

                    // We have a Door in cache that is not in vincinity
                    if (obj is IDoor && !doors.Contains(obj) && nowTicks - objEntry.Value >= GetPlayerItemUpdateInterval)
                    {
                        long dummy;
                        player.Client.GameObjectUpdateArray.TryRemove(objKey, out dummy);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error($"Error while Cleaning Doors cache for Player : {player.Name}, Exception : {e}");
                }
            }

            try
            {
                // Now Send remaining doors
                foreach (IDoor ldoor in doors)
                {
                    IDoor door = ldoor;

                    // Get last update time
                    long lastUpdate;
                    if (player.Client.GameObjectUpdateArray.TryGetValue(new Tuple <ushort, ushort>(((GameObject)door).CurrentRegionID, (ushort)door.ObjectID), out lastUpdate))
                    {
                        // This Door Needs Update
                        if (nowTicks - lastUpdate >= GetPlayerItemUpdateInterval)
                        {
                            player.SendDoorUpdate(door);
                        }
                    }
                    else
                    {
                        // Not in cache, Door entering in range, sending update will add it to cache.
                        player.SendDoorUpdate(door);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error($"Error while updating Doors for Player : {player.Name}, Exception : {e}");
                }
            }
        }
Exemplo n.º 5
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            ushort jumpSpotID = packet.ReadShort();

            eRealm targetRealm = client.Player.Realm;

            if (client.Player.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis && client.Player.CurrentZone.Realm != eRealm.None)
            {
                // if we are in TrialsOfAtlantis then base the target jump on the current region realm instead of the players realm
                // this is only used if zone table has the proper realms defined, otherwise it reverts to old behavior - Tolakram
                targetRealm = client.Player.CurrentZone.Realm;
            }

            var zonePoint = GameServer.Database.SelectObject <ZonePoint>("`Id` = '" + jumpSpotID + "' AND (`Realm` = '" + (byte)targetRealm +
                                                                         "' OR `Realm` = '0' OR `Realm` = NULL)");

            if (zonePoint == null || zonePoint.TargetRegion == 0)
            {
                ChatUtil.SendDebugMessage(client, "Invalid Jump (ZonePoint table): [" + jumpSpotID + "]" + ((zonePoint == null) ? ". Entry missing!" : ". TargetRegion is 0!"));
                zonePoint    = new ZonePoint();
                zonePoint.Id = jumpSpotID;
            }

            if (client.Account.PrivLevel > 1)
            {
                client.Out.SendMessage("JumpSpotID = " + jumpSpotID, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                client.Out.SendMessage("ZonePoint Target: Region = " + zonePoint.TargetRegion + ", ClassType = '" + zonePoint.ClassType + "'", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }

            //Dinberg: Fix - some jump points are handled code side, such as instances.
            //As such, region MAY be zero in the database, so this causes an issue.

            if (zonePoint.TargetRegion != 0)
            {
                Region reg = WorldMgr.GetRegion(zonePoint.TargetRegion);
                if (reg != null)
                {
                    // check for target region disabled if player is in a standard region
                    // otherwise the custom region should handle OnZonePoint for this check
                    if (client.Player.CurrentRegion.IsCustom == false && reg.IsDisabled)
                    {
                        if ((client.Player.Mission is TaskDungeonMission &&
                             (client.Player.Mission as TaskDungeonMission).TaskRegion.Skin == reg.Skin) == false)
                        {
                            client.Out.SendMessage("This region has been disabled!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            if (client.Account.PrivLevel == 1)
                            {
                                return;
                            }
                        }
                    }
                }
            }

            // Allow the region to either deny exit or handle the zonepoint in a custom way
            if (client.Player.CurrentRegion.OnZonePoint(client.Player, zonePoint) == false)
            {
                return;
            }

            //check caps for battleground
            Battleground bg = GameServer.KeepManager.GetBattleground(zonePoint.TargetRegion);

            if (bg != null)
            {
                if (client.Player.Level < bg.MinLevel && client.Player.Level > bg.MaxLevel &&
                    client.Player.RealmLevel >= bg.MaxRealmLevel)
                {
                    return;
                }
            }

            IJumpPointHandler customHandler = null;

            if (string.IsNullOrEmpty(zonePoint.ClassType) == false)
            {
                customHandler = (IJumpPointHandler)m_customJumpPointHandlers[zonePoint.ClassType];

                // check for db change to update cached handler
                if (customHandler != null && customHandler.GetType().FullName != zonePoint.ClassType)
                {
                    customHandler = null;
                }

                if (customHandler == null)
                {
                    //Dinberg - Instances need to use a special handler. This is because some instances will result
                    //in duplicated zonepoints, such as if Tir Na Nog were to be instanced for a quest.
                    string type = (client.Player.CurrentRegion.IsInstance)
                                                ? "DOL.GS.ServerRules.InstanceDoorJumpPoint"
                                                : zonePoint.ClassType;
                    Type t = ScriptMgr.GetType(type);

                    if (t == null)
                    {
                        Log.ErrorFormat("jump point {0}: class {1} not found!", zonePoint.Id, zonePoint.ClassType);
                    }
                    else if (!typeof(IJumpPointHandler).IsAssignableFrom(t))
                    {
                        Log.ErrorFormat("jump point {0}: class {1} must implement IJumpPointHandler interface!", zonePoint.Id,
                                        zonePoint.ClassType);
                    }
                    else
                    {
                        try
                        {
                            customHandler = (IJumpPointHandler)Activator.CreateInstance(t);
                        }
                        catch (Exception e)
                        {
                            customHandler = null;
                            Log.Error(
                                string.Format("jump point {0}: error creating a new instance of jump point handler {1}", zonePoint.Id,
                                              zonePoint.ClassType), e);
                        }
                    }
                }

                if (customHandler != null)
                {
                    m_customJumpPointHandlers[zonePoint.ClassType] = customHandler;
                }
            }

            new RegionChangeRequestHandler(client.Player, zonePoint, customHandler).Start(1);
        }
Exemplo n.º 6
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            /* First thing we do in here is to search for the NPCs inside
             * the world who comes from the certain Realm. If we find a the players,
             * this means we don't have to create a new one.
             *
             * NOTE: You can do anything you want in this method, you don't have
             * to search for NPC's ... you could create a custom item, place it
             * on the ground and if a player picks it up, he will get the quest!
             * Just examples, do anything you like and feel comfortable with :)
             */

            #region defineNPCS

            masterFrederick = GetMasterFrederick();

            #endregion

            #region defineItems

            // item db check
            emptyMagicBox = GameServer.Database.FindObjectByKey <ItemTemplate>("empty_wodden_magic_box");
            if (emptyMagicBox == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Empty Wodden Magic Box, creating it ...");
                }
                emptyMagicBox      = new ItemTemplate();
                emptyMagicBox.Name = "Empty Wodden Magic Box";

                emptyMagicBox.Weight = 5;
                emptyMagicBox.Model  = 602;

                emptyMagicBox.Object_Type = (int)eObjectType.GenericItem;
                emptyMagicBox.Id_nb       = "empty_wodden_magic_box";

                emptyMagicBox.IsPickable = true;
                emptyMagicBox.IsDropable = false;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database

                GameServer.Database.AddObject(emptyMagicBox);
            }

            // item db check
            fullMagicBox = GameServer.Database.FindObjectByKey <ItemTemplate>("full_wodden_magic_box");
            if (fullMagicBox == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Full Wodden Magic Box, creating it ...");
                }
                fullMagicBox      = new ItemTemplate();
                fullMagicBox.Name = "Full Wodden Magic Box";

                fullMagicBox.Weight = 3;
                fullMagicBox.Model  = 602;

                fullMagicBox.Object_Type = (int)eObjectType.GenericItem;

                fullMagicBox.Id_nb      = "full_wodden_magic_box";
                fullMagicBox.IsPickable = true;
                fullMagicBox.IsDropable = false;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database

                GameServer.Database.AddObject(fullMagicBox);
            }

            // item db check
            recruitsShortSword = GameServer.Database.FindObjectByKey <ItemTemplate>("recruits_short_sword");
            if (recruitsShortSword == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Recruit's Short Sword, creating it ...");
                }
                recruitsShortSword       = new ItemTemplate();
                recruitsShortSword.Name  = "Recruit's Short Sword";
                recruitsShortSword.Level = 4;

                recruitsShortSword.Weight = 18;
                recruitsShortSword.Model  = 3;                // studded Boots

                recruitsShortSword.DPS_AF  = 23;              // Armour
                recruitsShortSword.SPD_ABS = 30;              // Absorption

                recruitsShortSword.Type_Damage = (int)eDamageType.Slash;
                recruitsShortSword.Object_Type = (int)eObjectType.SlashingWeapon;
                recruitsShortSword.Item_Type   = (int)eEquipmentItems.LEFT_HAND;
                recruitsShortSword.Id_nb       = "recruits_short_sword";
                recruitsShortSword.Price       = Money.GetMoney(0, 0, 0, 2, 0);
                recruitsShortSword.IsPickable  = true;
                recruitsShortSword.IsDropable  = true;
                recruitsShortSword.Color       = 45;          // blue metal

                recruitsShortSword.Bonus = 1;                 // default bonus

                recruitsShortSword.Bonus1     = 3;
                recruitsShortSword.Bonus1Type = (int)eStat.STR;

                recruitsShortSword.Bonus2     = 1;
                recruitsShortSword.Bonus2Type = (int)eResist.Body;

                recruitsShortSword.Quality       = 100;
                recruitsShortSword.Condition     = 1000;
                recruitsShortSword.MaxCondition  = 1000;
                recruitsShortSword.Durability    = 1000;
                recruitsShortSword.MaxDurability = 1000;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database

                GameServer.Database.AddObject(recruitsShortSword);
            }

            // item db check
            recruitsStaff = GameServer.Database.FindObjectByKey <ItemTemplate>("recruits_staff");
            if (recruitsStaff == null)
            {
                recruitsStaff      = new ItemTemplate();
                recruitsStaff.Name = "Recruit's Staff";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + recruitsStaff.Name + ", creating it ...");
                }
                recruitsStaff.Level = 4;

                recruitsStaff.Weight = 45;
                recruitsStaff.Model  = 442;

                recruitsStaff.DPS_AF  = 24;
                recruitsStaff.SPD_ABS = 45;

                recruitsStaff.Type_Damage = (int)eDamageType.Slash;
                recruitsStaff.Object_Type = (int)eObjectType.Staff;
                recruitsStaff.Item_Type   = (int)eEquipmentItems.LEFT_HAND;
                recruitsStaff.Id_nb       = "recruits_staff";
                recruitsStaff.Price       = Money.GetMoney(0, 0, 0, 2, 0);
                recruitsStaff.IsPickable  = true;
                recruitsStaff.IsDropable  = true;
                recruitsStaff.Color       = 45;          // blue metal

                recruitsStaff.Bonus = 1;                 // default bonus

                recruitsStaff.Bonus1     = 3;
                recruitsStaff.Bonus1Type = (int)eStat.INT;

                recruitsStaff.Bonus2     = 1;
                recruitsStaff.Bonus2Type = (int)eResist.Crush;

                recruitsStaff.Quality       = 100;
                recruitsStaff.Condition     = 1000;
                recruitsStaff.MaxCondition  = 1000;
                recruitsStaff.Durability    = 1000;
                recruitsStaff.MaxDurability = 1000;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database

                GameServer.Database.AddObject(recruitsStaff);
            }

            #endregion

            fairyArea = WorldMgr.GetRegion(fairyLocation.RegionID).AddArea(new Area.Circle("Fairy contamined Area", fairyLocation.X, fairyLocation.Y, 0, 1500));
            fairyArea.RegisterPlayerEnter(new DOLEventHandler(PlayerEnterFairyArea));

            /* Now we add some hooks to the npc we found.
             * Actually, we want to know when a player interacts with him.
             * So, we hook the right-click (interact) and the whisper method
             * of npc and set the callback method to the "TalkToXXX"
             * method. This means, the "TalkToXXX" method is called whenever
             * a player right clicks on him or when he whispers to him.
             */

            GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
            GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));

            //We want to be notified whenever a player enters the world
            GameEventMgr.AddHandler(GamePlayerEvent.GameEntered, new DOLEventHandler(PlayerEnterWorld));

            GameEventMgr.AddHandler(masterFrederick, GameLivingEvent.Interact, new DOLEventHandler(TalkToMasterFrederick));
            GameEventMgr.AddHandler(masterFrederick, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToMasterFrederick));

            /* Now we bring to masterFrederick the possibility to give this quest to players */
            masterFrederick.AddQuestToGive(typeof(Nuisances));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Exemplo n.º 7
0
        public override void SendCharacterOverview(eRealm realm)
        {
            if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm)
            {
                throw new Exception("CharacterOverview requested for unknown realm " + realm);
            }

            int firstSlot = (byte)realm * 100;

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview)))
            {
                pak.FillString(m_gameClient.Account.Name, 24);

                if (m_gameClient.Account.Characters == null)
                {
                    pak.Fill(0x0, 1880);
                }
                else
                {
                    Dictionary <int, DOLCharacters> charsBySlot = new Dictionary <int, DOLCharacters>();
                    foreach (DOLCharacters c in m_gameClient.Account.Characters)
                    {
                        try
                        {
                            charsBySlot.Add(c.AccountSlot, c);
                        }
                        catch (Exception ex)
                        {
                            log.Error("SendCharacterOverview - Duplicate char in slot? Slot: " + c.AccountSlot + ", Account: " + c.AccountName, ex);
                        }
                    }
                    var itemsByOwnerID = new Dictionary <string, Dictionary <eInventorySlot, InventoryItem> >();

                    if (charsBySlot.Any())
                    {
                        var allItems = GameServer.Database.SelectObjects <InventoryItem>("`OwnerID` = @OwnerID AND `SlotPosition` >= @MinEquipable AND `SlotPosition` <= @MaxEquipable",
                                                                                         charsBySlot.Select(kv => new [] { new QueryParameter("@OwnerID", kv.Value.ObjectId), new QueryParameter("@MinEquipable", (int)eInventorySlot.MinEquipable), new QueryParameter("@MaxEquipable", (int)eInventorySlot.MaxEquipable) }))
                                       .SelectMany(objs => objs);

                        foreach (InventoryItem item in allItems)
                        {
                            try
                            {
                                if (!itemsByOwnerID.ContainsKey(item.OwnerID))
                                {
                                    itemsByOwnerID.Add(item.OwnerID, new Dictionary <eInventorySlot, InventoryItem>());
                                }

                                itemsByOwnerID[item.OwnerID].Add((eInventorySlot)item.SlotPosition, item);
                            }
                            catch (Exception ex)
                            {
                                log.Error("SendCharacterOverview - Duplicate item on character? OwnerID: " + item.OwnerID + ", SlotPosition: " + item.SlotPosition + ", Account: " + m_gameClient.Account.Name, ex);
                            }
                        }
                    }

                    for (int i = firstSlot; i < (firstSlot + 10); i++)
                    {
                        DOLCharacters c = null;
                        if (!charsBySlot.TryGetValue(i, out c))
                        {
                            pak.Fill(0x0, 188);
                        }
                        else
                        {
                            Dictionary <eInventorySlot, InventoryItem> charItems = null;

                            if (!itemsByOwnerID.TryGetValue(c.ObjectId, out charItems))
                            {
                                charItems = new Dictionary <eInventorySlot, InventoryItem>();
                            }

                            byte extensionTorso  = 0;
                            byte extensionGloves = 0;
                            byte extensionBoots  = 0;

                            InventoryItem item = null;

                            if (charItems.TryGetValue(eInventorySlot.TorsoArmor, out item))
                            {
                                extensionTorso = item.Extension;
                            }

                            if (charItems.TryGetValue(eInventorySlot.HandsArmor, out item))
                            {
                                extensionGloves = item.Extension;
                            }

                            if (charItems.TryGetValue(eInventorySlot.FeetArmor, out item))
                            {
                                extensionBoots = item.Extension;
                            }

                            pak.Fill(0x00, 4);                            //new heading bytes in from 1.99 relocated in 1.104
                            pak.FillString(c.Name, 24);
                            pak.WriteByte(0x01);
                            pak.WriteByte((byte)c.EyeSize);
                            pak.WriteByte((byte)c.LipSize);
                            pak.WriteByte((byte)c.EyeColor);
                            pak.WriteByte((byte)c.HairColor);
                            pak.WriteByte((byte)c.FaceType);
                            pak.WriteByte((byte)c.HairStyle);
                            pak.WriteByte((byte)((extensionBoots << 4) | extensionGloves));
                            pak.WriteByte((byte)((extensionTorso << 4) | (c.IsCloakHoodUp ? 0x1 : 0x0)));
                            pak.WriteByte((byte)c.CustomisationStep);      //1 = auto generate config, 2= config ended by player, 3= enable config to player
                            pak.WriteByte((byte)c.MoodType);
                            pak.Fill(0x0, 13);                             //0 String

                            string locationDescription = string.Empty;
                            Region region = WorldMgr.GetRegion((ushort)c.Region);
                            if (region != null)
                            {
                                locationDescription = m_gameClient.GetTranslatedSpotDescription(region, c.Xpos, c.Ypos, c.Zpos);
                            }
                            pak.FillString(locationDescription, 24);

                            string classname = "";
                            if (c.Class != 0)
                            {
                                classname = ((eCharacterClass)c.Class).ToString();
                            }
                            pak.FillString(classname, 24);

                            string racename = m_gameClient.RaceToTranslatedName(c.Race, c.Gender);
                            pak.FillString(racename, 24);

                            pak.WriteByte((byte)c.Level);
                            pak.WriteByte((byte)c.Class);
                            pak.WriteByte((byte)c.Realm);
                            pak.WriteByte((byte)((((c.Race & 0x10) << 2) + (c.Race & 0x0F)) | (c.Gender << 4)));                             // race max value can be 0x1F
                            pak.WriteShortLowEndian((ushort)c.CurrentModel);
                            pak.WriteByte((byte)c.Region);
                            if (region == null || (int)m_gameClient.ClientType > region.Expansion)
                            {
                                pak.WriteByte(0x00);
                            }
                            else
                            {
                                pak.WriteByte((byte)(region.Expansion + 1)); //0x04-Cata zone, 0x05 - DR zone
                            }
                            pak.WriteInt(0x0);                               // Internal database ID
                            pak.WriteByte((byte)c.Strength);
                            pak.WriteByte((byte)c.Dexterity);
                            pak.WriteByte((byte)c.Constitution);
                            pak.WriteByte((byte)c.Quickness);
                            pak.WriteByte((byte)c.Intelligence);
                            pak.WriteByte((byte)c.Piety);
                            pak.WriteByte((byte)c.Empathy);
                            pak.WriteByte((byte)c.Charisma);

                            InventoryItem rightHandWeapon = null;
                            charItems.TryGetValue(eInventorySlot.RightHandWeapon, out rightHandWeapon);
                            InventoryItem leftHandWeapon = null;
                            charItems.TryGetValue(eInventorySlot.LeftHandWeapon, out leftHandWeapon);
                            InventoryItem twoHandWeapon = null;
                            charItems.TryGetValue(eInventorySlot.TwoHandWeapon, out twoHandWeapon);
                            InventoryItem distanceWeapon = null;
                            charItems.TryGetValue(eInventorySlot.DistanceWeapon, out distanceWeapon);

                            InventoryItem helmet = null;
                            charItems.TryGetValue(eInventorySlot.HeadArmor, out helmet);
                            InventoryItem gloves = null;
                            charItems.TryGetValue(eInventorySlot.HandsArmor, out gloves);
                            InventoryItem boots = null;
                            charItems.TryGetValue(eInventorySlot.FeetArmor, out boots);
                            InventoryItem torso = null;
                            charItems.TryGetValue(eInventorySlot.TorsoArmor, out torso);
                            InventoryItem cloak = null;
                            charItems.TryGetValue(eInventorySlot.Cloak, out cloak);
                            InventoryItem legs = null;
                            charItems.TryGetValue(eInventorySlot.LegsArmor, out legs);
                            InventoryItem arms = null;
                            charItems.TryGetValue(eInventorySlot.ArmsArmor, out arms);

                            pak.WriteShortLowEndian((ushort)(helmet != null ? helmet.Model : 0));
                            pak.WriteShortLowEndian((ushort)(gloves != null ? gloves.Model : 0));
                            pak.WriteShortLowEndian((ushort)(boots != null ? boots.Model : 0));

                            ushort rightHandColor = 0;
                            if (rightHandWeapon != null)
                            {
                                rightHandColor = (ushort)(rightHandWeapon.Emblem != 0 ? rightHandWeapon.Emblem : rightHandWeapon.Color);
                            }
                            pak.WriteShortLowEndian(rightHandColor);

                            pak.WriteShortLowEndian((ushort)(torso != null ? torso.Model : 0));
                            pak.WriteShortLowEndian((ushort)(cloak != null ? cloak.Model : 0));
                            pak.WriteShortLowEndian((ushort)(legs != null ? legs.Model : 0));
                            pak.WriteShortLowEndian((ushort)(arms != null ? arms.Model : 0));

                            ushort helmetColor = 0;
                            if (helmet != null)
                            {
                                helmetColor = (ushort)(helmet.Emblem != 0 ? helmet.Emblem : helmet.Color);
                            }
                            pak.WriteShortLowEndian(helmetColor);

                            ushort glovesColor = 0;
                            if (gloves != null)
                            {
                                glovesColor = (ushort)(gloves.Emblem != 0 ? gloves.Emblem : gloves.Color);
                            }
                            pak.WriteShortLowEndian(glovesColor);

                            ushort bootsColor = 0;
                            if (boots != null)
                            {
                                bootsColor = (ushort)(boots.Emblem != 0 ? boots.Emblem : boots.Color);
                            }
                            pak.WriteShortLowEndian(bootsColor);

                            ushort leftHandWeaponColor = 0;
                            if (leftHandWeapon != null)
                            {
                                leftHandWeaponColor = (ushort)(leftHandWeapon.Emblem != 0 ? leftHandWeapon.Emblem : leftHandWeapon.Color);
                            }
                            pak.WriteShortLowEndian(leftHandWeaponColor);

                            ushort torsoColor = 0;
                            if (torso != null)
                            {
                                torsoColor = (ushort)(torso.Emblem != 0 ? torso.Emblem : torso.Color);
                            }
                            pak.WriteShortLowEndian(torsoColor);

                            ushort cloakColor = 0;
                            if (cloak != null)
                            {
                                cloakColor = (ushort)(cloak.Emblem != 0 ? cloak.Emblem : cloak.Color);
                            }
                            pak.WriteShortLowEndian(cloakColor);

                            ushort legsColor = 0;
                            if (legs != null)
                            {
                                legsColor = (ushort)(legs.Emblem != 0 ? legs.Emblem : legs.Color);
                            }
                            pak.WriteShortLowEndian(legsColor);

                            ushort armsColor = 0;
                            if (arms != null)
                            {
                                armsColor = (ushort)(arms.Emblem != 0 ? arms.Emblem : arms.Color);
                            }
                            pak.WriteShortLowEndian(armsColor);

                            //weapon models

                            pak.WriteShortLowEndian((ushort)(rightHandWeapon != null ? rightHandWeapon.Model : 0));
                            pak.WriteShortLowEndian((ushort)(leftHandWeapon != null ? leftHandWeapon.Model : 0));
                            pak.WriteShortLowEndian((ushort)(twoHandWeapon != null ? twoHandWeapon.Model : 0));
                            pak.WriteShortLowEndian((ushort)(distanceWeapon != null ? distanceWeapon.Model : 0));

                            if (c.ActiveWeaponSlot == (byte)DOL.GS.GameLiving.eActiveWeaponSlot.TwoHanded)
                            {
                                pak.WriteByte(0x02);
                                pak.WriteByte(0x02);
                            }
                            else if (c.ActiveWeaponSlot == (byte)DOL.GS.GameLiving.eActiveWeaponSlot.Distance)
                            {
                                pak.WriteByte(0x03);
                                pak.WriteByte(0x03);
                            }
                            else
                            {
                                byte righthand = 0xFF;
                                byte lefthand  = 0xFF;

                                if (rightHandWeapon != null)
                                {
                                    righthand = 0x00;
                                }

                                if (leftHandWeapon != null)
                                {
                                    lefthand = 0x01;
                                }

                                pak.WriteByte(righthand);
                                pak.WriteByte(lefthand);
                            }

                            if (region == null || region.Expansion != 1)
                            {
                                pak.WriteByte(0x00);
                            }
                            else
                            {
                                pak.WriteByte(0x01);                                 //0x01=char in SI zone, classic client can't "play"
                            }
                            pak.WriteByte((byte)c.Constitution);
                        }
                    }
                }

                pak.Fill(0x0, 94);
                SendTCP(pak);
            }
        }
Exemplo n.º 8
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            #region defineNPCs
            GameNPC[] npcs;

            npcs = WorldMgr.GetNPCsByName("Dwarven Guard Rinda", (eRealm)2);
            if (npcs.Length == 0)
            {
                if (!WorldMgr.GetRegion(100).IsDisabled)
                {
                    DwarvenGuardRinda       = new DOL.GS.GameNPC();
                    DwarvenGuardRinda.Model = 238;
                    DwarvenGuardRinda.Name  = "Dwarven Guard Rinda";
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + DwarvenGuardRinda.Name + ", creating ...");
                    }
                    DwarvenGuardRinda.GuildName       = "Part of " + questTitle + " Quest";
                    DwarvenGuardRinda.Realm           = eRealm.Midgard;
                    DwarvenGuardRinda.CurrentRegionID = 100;
                    DwarvenGuardRinda.Size            = 53;
                    DwarvenGuardRinda.Level           = 41;
                    DwarvenGuardRinda.MaxSpeedBase    = 191;
                    DwarvenGuardRinda.Faction         = FactionMgr.GetFactionByID(0);
                    DwarvenGuardRinda.X               = 805496;
                    DwarvenGuardRinda.Y               = 701215;
                    DwarvenGuardRinda.Z               = 4960;
                    DwarvenGuardRinda.Heading         = 1570;
                    DwarvenGuardRinda.RespawnInterval = -1;
                    DwarvenGuardRinda.BodyType        = 0;


                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 0;
                    brain.AggroRange = 500;
                    DwarvenGuardRinda.SetOwnBrain(brain);

                    //You don't have to store the created mob in the db if you don't want,
                    //it will be recreated each time it is not found, just comment the following
                    //line if you rather not modify your database
                    if (SAVE_INTO_DATABASE)
                    {
                        DwarvenGuardRinda.SaveIntoDatabase();
                    }

                    DwarvenGuardRinda.AddToWorld();
                }
            }
            else
            {
                DwarvenGuardRinda = npcs[0];
            }

            npcs = WorldMgr.GetNPCsByName("hobgoblin snake-finder", (eRealm)0);
            if (npcs.Length == 0)
            {
                if (!WorldMgr.GetRegion(100).IsDisabled)
                {
                    hobgoblinsnakefinder       = new DOL.GS.GameNPC();
                    hobgoblinsnakefinder.Model = 251;
                    hobgoblinsnakefinder.Name  = "hobgoblin snake-finder";
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + hobgoblinsnakefinder.Name + ", creating ...");
                    }
                    hobgoblinsnakefinder.GuildName       = "Part of " + questTitle + " Quest";
                    hobgoblinsnakefinder.Realm           = eRealm.None;
                    hobgoblinsnakefinder.CurrentRegionID = 100;
                    hobgoblinsnakefinder.Size            = 37;
                    hobgoblinsnakefinder.Level           = 1;
                    hobgoblinsnakefinder.MaxSpeedBase    = 191;
                    hobgoblinsnakefinder.Faction         = FactionMgr.GetFactionByID(0);
                    hobgoblinsnakefinder.X               = 803189;
                    hobgoblinsnakefinder.Y               = 695157;
                    hobgoblinsnakefinder.Z               = 4926;
                    hobgoblinsnakefinder.Heading         = 125;
                    hobgoblinsnakefinder.RespawnInterval = -1;
                    hobgoblinsnakefinder.BodyType        = 0;


                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 0;
                    brain.AggroRange = 500;
                    hobgoblinsnakefinder.SetOwnBrain(brain);

                    //You don't have to store the created mob in the db if you don't want,
                    //it will be recreated each time it is not found, just comment the following
                    //line if you rather not modify your database
                    if (SAVE_INTO_DATABASE)
                    {
                        hobgoblinsnakefinder.SaveIntoDatabase();
                    }

                    hobgoblinsnakefinder.AddToWorld();
                }
            }
            else
            {
                hobgoblinsnakefinder = npcs[0];
            }


            #endregion

            #region defineItems

            rindaskey = GameServer.Database.FindObjectByKey <ItemTemplate>("rindaskey");
            if (rindaskey == null)
            {
                rindaskey      = new ItemTemplate();
                rindaskey.Name = "Rinda's Key";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + rindaskey.Name + ", creating it ...");
                }
                rindaskey.Level            = 50;
                rindaskey.Weight           = 5;
                rindaskey.Model            = 583;
                rindaskey.Object_Type      = 0;
                rindaskey.Item_Type        = 40;
                rindaskey.Id_nb            = "rindaskey";
                rindaskey.Hand             = 0;
                rindaskey.Price            = 0;
                rindaskey.IsPickable       = true;
                rindaskey.IsDropable       = true;
                rindaskey.IsTradable       = true;
                rindaskey.CanDropAsLoot    = false;
                rindaskey.Color            = 0;
                rindaskey.Bonus            = 35;      // default bonus
                rindaskey.Bonus1           = 0;
                rindaskey.Bonus1Type       = (int)0;
                rindaskey.Bonus2           = 0;
                rindaskey.Bonus2Type       = (int)0;
                rindaskey.Bonus3           = 0;
                rindaskey.Bonus3Type       = (int)0;
                rindaskey.Bonus4           = 0;
                rindaskey.Bonus4Type       = (int)0;
                rindaskey.Bonus5           = 0;
                rindaskey.Bonus5Type       = (int)0;
                rindaskey.Bonus6           = 0;
                rindaskey.Bonus6Type       = (int)0;
                rindaskey.Bonus7           = 0;
                rindaskey.Bonus7Type       = (int)0;
                rindaskey.Bonus8           = 0;
                rindaskey.Bonus8Type       = (int)0;
                rindaskey.Bonus9           = 0;
                rindaskey.Bonus9Type       = (int)0;
                rindaskey.Bonus10          = 0;
                rindaskey.Bonus10Type      = (int)0;
                rindaskey.ExtraBonus       = 0;
                rindaskey.ExtraBonusType   = (int)0;
                rindaskey.Effect           = 0;
                rindaskey.Emblem           = 0;
                rindaskey.Charges          = 0;
                rindaskey.MaxCharges       = 0;
                rindaskey.SpellID          = 0;
                rindaskey.ProcSpellID      = 0;
                rindaskey.Type_Damage      = 0;
                rindaskey.Realm            = 0;
                rindaskey.MaxCount         = 1;
                rindaskey.PackSize         = 1;
                rindaskey.Extension        = 0;
                rindaskey.Quality          = 99;
                rindaskey.Condition        = 50000;
                rindaskey.MaxCondition     = 50000;
                rindaskey.Durability       = 50000;
                rindaskey.MaxDurability    = 50000;
                rindaskey.PoisonCharges    = 0;
                rindaskey.PoisonMaxCharges = 0;
                rindaskey.PoisonSpellID    = 0;
                rindaskey.ProcSpellID1     = 0;
                rindaskey.SpellID1         = 0;
                rindaskey.MaxCharges1      = 0;
                rindaskey.Charges1         = 0;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(rindaskey);
                }
            }
            ironkeychain = GameServer.Database.FindObjectByKey <ItemTemplate>("ironkeychain");
            if (ironkeychain == null)
            {
                ironkeychain      = new ItemTemplate();
                ironkeychain.Name = "Iron Keychain";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + ironkeychain.Name + ", creating it ...");
                }
                ironkeychain.Level            = 50;
                ironkeychain.Weight           = 5;
                ironkeychain.Model            = 583;
                ironkeychain.Object_Type      = 0;
                ironkeychain.Item_Type        = 40;
                ironkeychain.Id_nb            = "ironkeychain";
                ironkeychain.Hand             = 0;
                ironkeychain.Price            = 0;
                ironkeychain.IsPickable       = true;
                ironkeychain.IsDropable       = true;
                ironkeychain.IsTradable       = true;
                ironkeychain.CanDropAsLoot    = false;
                ironkeychain.Color            = 0;
                ironkeychain.Bonus            = 35;      // default bonus
                ironkeychain.Bonus1           = 0;
                ironkeychain.Bonus1Type       = (int)0;
                ironkeychain.Bonus2           = 0;
                ironkeychain.Bonus2Type       = (int)0;
                ironkeychain.Bonus3           = 0;
                ironkeychain.Bonus3Type       = (int)0;
                ironkeychain.Bonus4           = 0;
                ironkeychain.Bonus4Type       = (int)0;
                ironkeychain.Bonus5           = 0;
                ironkeychain.Bonus5Type       = (int)0;
                ironkeychain.Bonus6           = 0;
                ironkeychain.Bonus6Type       = (int)0;
                ironkeychain.Bonus7           = 0;
                ironkeychain.Bonus7Type       = (int)0;
                ironkeychain.Bonus8           = 0;
                ironkeychain.Bonus8Type       = (int)0;
                ironkeychain.Bonus9           = 0;
                ironkeychain.Bonus9Type       = (int)0;
                ironkeychain.Bonus10          = 0;
                ironkeychain.Bonus10Type      = (int)0;
                ironkeychain.ExtraBonus       = 0;
                ironkeychain.ExtraBonusType   = (int)0;
                ironkeychain.Effect           = 0;
                ironkeychain.Emblem           = 0;
                ironkeychain.Charges          = 0;
                ironkeychain.MaxCharges       = 0;
                ironkeychain.SpellID          = 0;
                ironkeychain.ProcSpellID      = 0;
                ironkeychain.Type_Damage      = 0;
                ironkeychain.Realm            = 0;
                ironkeychain.MaxCount         = 1;
                ironkeychain.PackSize         = 1;
                ironkeychain.Extension        = 0;
                ironkeychain.Quality          = 99;
                ironkeychain.Condition        = 50000;
                ironkeychain.MaxCondition     = 50000;
                ironkeychain.Durability       = 50000;
                ironkeychain.MaxDurability    = 50000;
                ironkeychain.PoisonCharges    = 0;
                ironkeychain.PoisonMaxCharges = 0;
                ironkeychain.PoisonSpellID    = 0;
                ironkeychain.ProcSpellID1     = 0;
                ironkeychain.SpellID1         = 0;
                ironkeychain.MaxCharges1      = 0;
                ironkeychain.Charges1         = 0;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(ironkeychain);
                }
            }
            silverringofhealth = GameServer.Database.FindObjectByKey <ItemTemplate>("silverringofhealth");
            if (silverringofhealth == null)
            {
                silverringofhealth      = new ItemTemplate();
                silverringofhealth.Name = "Silver Ring of Health";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + silverringofhealth.Name + ", creating it ...");
                }
                silverringofhealth.Level            = 5;
                silverringofhealth.Weight           = 5;
                silverringofhealth.Model            = 103;
                silverringofhealth.Object_Type      = 41;
                silverringofhealth.Item_Type        = 35;
                silverringofhealth.Id_nb            = "silverringofhealth";
                silverringofhealth.Hand             = 0;
                silverringofhealth.Price            = 0;
                silverringofhealth.IsPickable       = true;
                silverringofhealth.IsDropable       = true;
                silverringofhealth.IsTradable       = false;
                silverringofhealth.CanDropAsLoot    = false;
                silverringofhealth.Color            = 0;
                silverringofhealth.Bonus            = 5;      // default bonus
                silverringofhealth.Bonus1           = 12;
                silverringofhealth.Bonus1Type       = (int)10;
                silverringofhealth.Bonus2           = 0;
                silverringofhealth.Bonus2Type       = (int)0;
                silverringofhealth.Bonus3           = 0;
                silverringofhealth.Bonus3Type       = (int)0;
                silverringofhealth.Bonus4           = 0;
                silverringofhealth.Bonus4Type       = (int)0;
                silverringofhealth.Bonus5           = 0;
                silverringofhealth.Bonus5Type       = (int)0;
                silverringofhealth.Bonus6           = 0;
                silverringofhealth.Bonus6Type       = (int)0;
                silverringofhealth.Bonus7           = 0;
                silverringofhealth.Bonus7Type       = (int)0;
                silverringofhealth.Bonus8           = 0;
                silverringofhealth.Bonus8Type       = (int)0;
                silverringofhealth.Bonus9           = 0;
                silverringofhealth.Bonus9Type       = (int)0;
                silverringofhealth.Bonus10          = 0;
                silverringofhealth.Bonus10Type      = (int)0;
                silverringofhealth.ExtraBonus       = 0;
                silverringofhealth.ExtraBonusType   = (int)0;
                silverringofhealth.Effect           = 0;
                silverringofhealth.Emblem           = 0;
                silverringofhealth.Charges          = 0;
                silverringofhealth.MaxCharges       = 0;
                silverringofhealth.SpellID          = 0;
                silverringofhealth.ProcSpellID      = 0;
                silverringofhealth.Type_Damage      = 0;
                silverringofhealth.Realm            = 0;
                silverringofhealth.MaxCount         = 1;
                silverringofhealth.PackSize         = 1;
                silverringofhealth.Extension        = 0;
                silverringofhealth.Quality          = 100;
                silverringofhealth.Condition        = 100;
                silverringofhealth.MaxCondition     = 100;
                silverringofhealth.Durability       = 100;
                silverringofhealth.MaxDurability    = 100;
                silverringofhealth.PoisonCharges    = 0;
                silverringofhealth.PoisonMaxCharges = 0;
                silverringofhealth.PoisonSpellID    = 0;
                silverringofhealth.ProcSpellID1     = 0;
                silverringofhealth.SpellID1         = 0;
                silverringofhealth.MaxCharges1      = 0;
                silverringofhealth.Charges1         = 0;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(silverringofhealth);
                }
            }


            #endregion

            #region defineAreas

            #endregion

            #region defineQuestParts

            QuestBuilder   builder = QuestMgr.getBuilder(typeof(rindaslostkey));
            QuestBehaviour a;
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.Interact, null, DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.rindaslostkey), DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.rindaslostkey), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "Greetings, and welcome to the dwarf town of Haggerfel. I wish I could stay and talk with you for a moment, but I am in a hurry to find my [lost keys].", DwarvenGuardRinda);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.Whisper, "lost keys", DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.rindaslostkey), DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.rindaslostkey), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "Oh yes. It is dreadful that I was so careless as to lost them like this! You see, I am responsible for helping to lock the money the merchants bring in during the day into a large chest. I am the only one with the keys, and I have [misplaced them].", DwarvenGuardRinda);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.Whisper, "misplaced them", DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.rindaslostkey), DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.rindaslostkey), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "Oh, this makes me so angry! I have searched all around Haggerfel for them, but they are no where to be found. I don't suppose you would have a [little time] to help me out, would you?", DwarvenGuardRinda);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.Whisper, "little time", DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.rindaslostkey), DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.rindaslostkey), null, (eComparator)5);
            a.AddAction(eActionType.OfferQuest, typeof(DOL.GS.Quests.Midgard.rindaslostkey), "Will you help Rinda find her keys?");
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.rindaslostkey));
            a.AddAction(eActionType.Talk, "No problem. See you", DwarvenGuardRinda);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.rindaslostkey));
            a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.rindaslostkey), DwarvenGuardRinda);
            a.AddAction(eActionType.Talk, "Thank you! Thank you! I know there are some hobgoblins around that like to play jokes on people, viscious and mean ones. Why don't you check there while I check the merchant huts again?", DwarvenGuardRinda);
            AddBehaviour(a);
            a = builder.CreateBehaviour(hobgoblinsnakefinder, -1);
            a.AddTrigger(eTriggerType.Interact, null, hobgoblinsnakefinder);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.rindaslostkey), 1, (eComparator)3);
            a.AddAction(eActionType.Talk, "Ha ha! Me no have keys! Feed to hungry bear! haha! You no help Rinda...Gold be ours!", hobgoblinsnakefinder);
            a.AddAction(eActionType.GiveItem, ironkeychain, hobgoblinsnakefinder);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.rindaslostkey), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.EnemyKilled, "black mauler cub", null);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.rindaslostkey), 2, (eComparator)3);
            a.AddAction(eActionType.GiveItem, rindaskey, null);
            a.AddAction(eActionType.IncQuestStep, typeof(rindaslostkey), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.Interact, null, DwarvenGuardRinda);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.rindaslostkey), 3, (eComparator)3);
            a.AddAction(eActionType.Talk, "I couldn't find them again in the village. Did you have better luck?", DwarvenGuardRinda);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.GiveItem, DwarvenGuardRinda, ironkeychain);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.rindaslostkey), 3, (eComparator)3);
            a.AddAction(eActionType.Talk, "Oh my keychain. Well, this is a good start. But you didn't happen to find my key, did you?", DwarvenGuardRinda);
            a.AddAction(eActionType.GiveXP, 20, null);
            a.AddAction(eActionType.GiveGold, 225, null);
            a.AddAction(eActionType.TakeItem, ironkeychain, null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.GiveItem, DwarvenGuardRinda, rindaskey);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.rindaslostkey), 3, (eComparator)3);
            a.AddRequirement(eRequirementType.InventoryItem, ironkeychain, null, (eComparator)3);
            a.AddAction(eActionType.Talk, "Ah! This is great! My key! You have done a fabulous job in helping me. Please accept this coin in return for your time and effort. Thank you so much! Now, I can safely lock up the town's money. Thank you!", DwarvenGuardRinda);
            a.AddAction(eActionType.TakeItem, rindaskey, null);
            a.AddAction(eActionType.TakeItem, ironkeychain, null);
            a.AddAction(eActionType.GiveXP, 40, null);
            a.AddAction(eActionType.GiveGold, 450, null);
            a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.rindaslostkey), null);
            a.AddAction(eActionType.GiveItem, silverringofhealth, DwarvenGuardRinda);
            AddBehaviour(a);
            a = builder.CreateBehaviour(DwarvenGuardRinda, -1);
            a.AddTrigger(eTriggerType.GiveItem, DwarvenGuardRinda, rindaskey);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.rindaslostkey), 3, (eComparator)3);
            a.AddRequirement(eRequirementType.InventoryItem, ironkeychain, null, (eComparator)1);
            a.AddAction(eActionType.Talk, "Ah! This is great! My key! You have done a fabulous job in helping me. Please accept this coin in return for your time and effort. Thank you so much! Now, I can safely lock up the town's money. Thank you!", DwarvenGuardRinda);
            a.AddAction(eActionType.GiveXP, 20, null);
            a.AddAction(eActionType.GiveGold, 225, null);
            a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.rindaslostkey), null);
            a.AddAction(eActionType.TakeItem, rindaskey, null);
            a.AddAction(eActionType.GiveItem, silverringofhealth, DwarvenGuardRinda);
            AddBehaviour(a);

            #endregion

            // Custom Scriptloaded Code Begin

            // Custom Scriptloaded Code End
            if (DwarvenGuardRinda != null)
            {
                DwarvenGuardRinda.AddQuestToGive(typeof(rindaslostkey));
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Exemplo n.º 9
0
        private static void UpdatePlayerOtherPlayers(GamePlayer player, long nowTicks)
        {
            // Get All Player in Range
            var players = player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE).Cast <GamePlayer>().Where(p => p != null && p.IsVisibleTo(player) && (!p.IsStealthed || player.CanDetect(p))).ToArray();

            try
            {
                // Clean Cache
                foreach (var objEntry in player.Client.GameObjectUpdateArray)
                {
                    var        objKey = objEntry.Key;
                    GameObject obj    = WorldMgr.GetRegion(objKey.Item1).GetObject(objKey.Item2);
                    // We have a Player in cache that is not in vincinity
                    // For updating "out of view" we allow a halved refresh time.
                    if (obj is GamePlayer && !players.Contains((GamePlayer)obj) && (nowTicks - objEntry.Value) >= GetPlayertoPlayerUpdateInterval)
                    {
                        long dummy;

                        // Update him out of View and delete from cache
                        if (obj.IsVisibleTo(player) && (((GamePlayer)obj).IsStealthed == false || player.CanDetect((GamePlayer)obj)))
                        {
                            player.Client.Out.SendPlayerForgedPosition((GamePlayer)obj);
                        }

                        player.Client.GameObjectUpdateArray.TryRemove(objKey, out dummy);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("Error while Cleaning OtherPlayers cache for Player : {0}, Exception : {1}", player.Name, e);
                }
            }

            try
            {
                // Now Send Remaining Players.
                foreach (GamePlayer lplayer in players)
                {
                    GamePlayer otherply = lplayer;

                    if (otherply != null)
                    {
                        // Get last update time
                        long lastUpdate;
                        if (player.Client.GameObjectUpdateArray.TryGetValue(new Tuple <ushort, ushort>(otherply.CurrentRegionID, (ushort)otherply.ObjectID), out lastUpdate))
                        {
                            // This Player Needs Update
                            if ((nowTicks - lastUpdate) >= GetPlayertoPlayerUpdateInterval)
                            {
                                player.Client.Out.SendPlayerForgedPosition(otherply);
                            }
                        }
                        else
                        {
                            player.Client.Out.SendPlayerForgedPosition(otherply);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("Error while updating OtherPlayers for Player : {0}, Exception : {1}", player.Name, e);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Send Mobs Update to Player depending on last refresh time.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="nowTicks"></param>
        private static void UpdatePlayerNPCs(GamePlayer player, long nowTicks)
        {
            // Get All Mobs in Range
            var npcs = player.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE).Cast <GameNPC>().Where(n => n != null && n.IsVisibleTo(player)).ToArray();

            try
            {
                // Clean Cache
                foreach (var objEntry in player.Client.GameObjectUpdateArray)
                {
                    var        objKey = objEntry.Key;
                    GameObject obj    = WorldMgr.GetRegion(objKey.Item1).GetObject(objKey.Item2);

                    // Brain is updating to its master, no need to handle it.
                    if (obj is GameNPC && ((GameNPC)obj).Brain is IControlledBrain && ((IControlledBrain)((GameNPC)obj).Brain).GetPlayerOwner() == player)
                    {
                        continue;
                    }

                    // We have a NPC in cache that is not in vincinity
                    if (obj is GameNPC && !npcs.Contains((GameNPC)obj) && (nowTicks - objEntry.Value) >= GetPlayerNPCUpdateInterval)
                    {
                        // Update him out of View
                        if (obj.IsVisibleTo(player))
                        {
                            player.Client.Out.SendObjectUpdate(obj);
                        }

                        long dummy;
                        // this will add the object to the cache again, remove it after sending...
                        player.Client.GameObjectUpdateArray.TryRemove(objKey, out dummy);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("Error while Cleaning NPC cache for Player : {0}, Exception : {1}", player.Name, e);
                }
            }

            try
            {
                // Now Send remaining npcs
                foreach (GameNPC lnpc in npcs)
                {
                    GameNPC npc = lnpc;

                    // Get last update time
                    long lastUpdate;
                    if (player.Client.GameObjectUpdateArray.TryGetValue(new Tuple <ushort, ushort>(npc.CurrentRegionID, (ushort)npc.ObjectID), out lastUpdate))
                    {
                        // This NPC Needs Update
                        if ((nowTicks - lastUpdate) >= GetPlayerNPCUpdateInterval)
                        {
                            player.Client.Out.SendObjectUpdate(npc);
                        }
                    }
                    else
                    {
                        // Not in cache, Object entering in range, sending update will add it to cache.
                        player.Client.Out.SendObjectUpdate(npc);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("Error while updating NPC for Player : {0}, Exception : {1}", player.Name, e);
                }
            }
        }
Exemplo n.º 11
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            #region defineNPCs
            GameNPC[] npcs;

            npcs = WorldMgr.GetNPCsByName(LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.NPCBarkeepNognar"), (eRealm)2);

            if (npcs.Length == 0)
            {
                if (!WorldMgr.GetRegion(100).IsDisabled)
                {
                    BarkeepNognar       = new DOL.GS.GameMerchant();
                    BarkeepNognar.Model = 212;
                    BarkeepNognar.Name  = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.NPCBarkeepNognar");
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + BarkeepNognar.Name + ", creating ...");
                    }
                    BarkeepNognar.GuildName       = "Part of " + questTitle + " Quest";
                    BarkeepNognar.Realm           = eRealm.Midgard;
                    BarkeepNognar.CurrentRegionID = 100;
                    BarkeepNognar.Size            = 58;
                    BarkeepNognar.Level           = 15;
                    BarkeepNognar.MaxSpeedBase    = 191;
                    BarkeepNognar.Faction         = FactionMgr.GetFactionByID(0);
                    BarkeepNognar.X               = 805429;
                    BarkeepNognar.Y               = 726478;
                    BarkeepNognar.Z               = 4717;
                    BarkeepNognar.Heading         = 4073;
                    BarkeepNognar.RespawnInterval = -1;
                    BarkeepNognar.BodyType        = 0;

                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 0;
                    brain.AggroRange = 500;
                    BarkeepNognar.SetOwnBrain(brain);

                    //You don't have to store the created mob in the db if you don't want,
                    //it will be recreated each time it is not found, just comment the following
                    //line if you rather not modify your database
                    if (SAVE_INTO_DATABASE)
                    {
                        BarkeepNognar.SaveIntoDatabase();
                    }

                    BarkeepNognar.AddToWorld();
                }
            }
            else
            {
                BarkeepNognar = npcs[0];
            }

            npcs = WorldMgr.GetNPCsByName(LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.NPCBarkeepPrugar"), (eRealm)2);

            if (npcs.Length == 0)
            {
                if (!WorldMgr.GetRegion(101).IsDisabled)
                {
                    BarkeepPrugar       = new DOL.GS.GameMerchant();
                    BarkeepPrugar.Model = 213;
                    BarkeepPrugar.Name  = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.NPCBarkeepPrugar");
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + BarkeepPrugar.Name + ", creating ...");
                    }
                    BarkeepPrugar.GuildName       = "Part of " + questTitle + " Quest";
                    BarkeepPrugar.Realm           = eRealm.Midgard;
                    BarkeepPrugar.CurrentRegionID = 101;
                    BarkeepPrugar.Size            = 60;
                    BarkeepPrugar.Level           = 15;
                    BarkeepPrugar.MaxSpeedBase    = 191;
                    BarkeepPrugar.Faction         = FactionMgr.GetFactionByID(0);
                    BarkeepPrugar.X               = 33230;
                    BarkeepPrugar.Y               = 34802;
                    BarkeepPrugar.Z               = 8027;
                    BarkeepPrugar.Heading         = 1194;
                    BarkeepPrugar.RespawnInterval = -1;
                    BarkeepPrugar.BodyType        = 0;

                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 0;
                    brain.AggroRange = 500;
                    BarkeepPrugar.SetOwnBrain(brain);

                    //You don't have to store the created mob in the db if you don't want,
                    //it will be recreated each time it is not found, just comment the following
                    //line if you rather not modify your database
                    if (SAVE_INTO_DATABASE)
                    {
                        BarkeepPrugar.SaveIntoDatabase();
                    }

                    BarkeepPrugar.AddToWorld();
                }
            }
            else
            {
                BarkeepPrugar = npcs[0];
            }


            #endregion

            #region defineItems

            rattlingskeletonpendant = GameServer.Database.FindObjectByKey <ItemTemplate>("rattlingskeletonpendant");
            if (rattlingskeletonpendant == null)
            {
                rattlingskeletonpendant      = new ItemTemplate();
                rattlingskeletonpendant.Name = "Rattling Skeleton Pendant";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + rattlingskeletonpendant.Name + ", creating it ...");
                }
                rattlingskeletonpendant.Level            = 50;
                rattlingskeletonpendant.Weight           = 5;
                rattlingskeletonpendant.Model            = 101;
                rattlingskeletonpendant.Object_Type      = 0;
                rattlingskeletonpendant.Item_Type        = 40;
                rattlingskeletonpendant.Id_nb            = "rattlingskeletonpendant";
                rattlingskeletonpendant.Hand             = 0;
                rattlingskeletonpendant.Price            = 0;
                rattlingskeletonpendant.IsPickable       = true;
                rattlingskeletonpendant.IsDropable       = true;
                rattlingskeletonpendant.IsTradable       = true;
                rattlingskeletonpendant.CanDropAsLoot    = false;
                rattlingskeletonpendant.Color            = 0;
                rattlingskeletonpendant.Bonus            = 35;      // default bonus
                rattlingskeletonpendant.Bonus1           = 0;
                rattlingskeletonpendant.Bonus1Type       = (int)0;
                rattlingskeletonpendant.Bonus2           = 0;
                rattlingskeletonpendant.Bonus2Type       = (int)0;
                rattlingskeletonpendant.Bonus3           = 0;
                rattlingskeletonpendant.Bonus3Type       = (int)0;
                rattlingskeletonpendant.Bonus4           = 0;
                rattlingskeletonpendant.Bonus4Type       = (int)0;
                rattlingskeletonpendant.Bonus5           = 0;
                rattlingskeletonpendant.Bonus5Type       = (int)0;
                rattlingskeletonpendant.Bonus6           = 0;
                rattlingskeletonpendant.Bonus6Type       = (int)0;
                rattlingskeletonpendant.Bonus7           = 0;
                rattlingskeletonpendant.Bonus7Type       = (int)0;
                rattlingskeletonpendant.Bonus8           = 0;
                rattlingskeletonpendant.Bonus8Type       = (int)0;
                rattlingskeletonpendant.Bonus9           = 0;
                rattlingskeletonpendant.Bonus9Type       = (int)0;
                rattlingskeletonpendant.Bonus10          = 0;
                rattlingskeletonpendant.Bonus10Type      = (int)0;
                rattlingskeletonpendant.ExtraBonus       = 0;
                rattlingskeletonpendant.ExtraBonusType   = (int)0;
                rattlingskeletonpendant.Effect           = 0;
                rattlingskeletonpendant.Emblem           = 0;
                rattlingskeletonpendant.Charges          = 0;
                rattlingskeletonpendant.MaxCharges       = 0;
                rattlingskeletonpendant.SpellID          = 0;
                rattlingskeletonpendant.ProcSpellID      = 0;
                rattlingskeletonpendant.Type_Damage      = 0;
                rattlingskeletonpendant.Realm            = 0;
                rattlingskeletonpendant.MaxCount         = 1;
                rattlingskeletonpendant.PackSize         = 1;
                rattlingskeletonpendant.Extension        = 0;
                rattlingskeletonpendant.Quality          = 99;
                rattlingskeletonpendant.Condition        = 50000;
                rattlingskeletonpendant.MaxCondition     = 50000;
                rattlingskeletonpendant.Durability       = 50000;
                rattlingskeletonpendant.MaxDurability    = 50000;
                rattlingskeletonpendant.PoisonCharges    = 0;
                rattlingskeletonpendant.PoisonMaxCharges = 0;
                rattlingskeletonpendant.PoisonSpellID    = 0;
                rattlingskeletonpendant.ProcSpellID1     = 0;
                rattlingskeletonpendant.SpellID1         = 0;
                rattlingskeletonpendant.MaxCharges1      = 0;
                rattlingskeletonpendant.Charges1         = 0;

                GameServer.Database.AddObject(rattlingskeletonpendant);
            }
            giftandnoteforprugar = GameServer.Database.FindObjectByKey <ItemTemplate>("giftandnoteforprugar");
            if (giftandnoteforprugar == null)
            {
                giftandnoteforprugar      = new ItemTemplate();
                giftandnoteforprugar.Name = "Gift and Note for Prugar";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + giftandnoteforprugar.Name + ", creating it ...");
                }
                giftandnoteforprugar.Level            = 50;
                giftandnoteforprugar.Weight           = 5;
                giftandnoteforprugar.Model            = 1347;
                giftandnoteforprugar.Object_Type      = 0;
                giftandnoteforprugar.Item_Type        = 40;
                giftandnoteforprugar.Id_nb            = "giftandnoteforprugar";
                giftandnoteforprugar.Hand             = 0;
                giftandnoteforprugar.Price            = 0;
                giftandnoteforprugar.IsPickable       = true;
                giftandnoteforprugar.IsDropable       = true;
                giftandnoteforprugar.IsTradable       = true;
                giftandnoteforprugar.CanDropAsLoot    = false;
                giftandnoteforprugar.Color            = 0;
                giftandnoteforprugar.Bonus            = 35;      // default bonus
                giftandnoteforprugar.Bonus1           = 0;
                giftandnoteforprugar.Bonus1Type       = (int)0;
                giftandnoteforprugar.Bonus2           = 0;
                giftandnoteforprugar.Bonus2Type       = (int)0;
                giftandnoteforprugar.Bonus3           = 0;
                giftandnoteforprugar.Bonus3Type       = (int)0;
                giftandnoteforprugar.Bonus4           = 0;
                giftandnoteforprugar.Bonus4Type       = (int)0;
                giftandnoteforprugar.Bonus5           = 0;
                giftandnoteforprugar.Bonus5Type       = (int)0;
                giftandnoteforprugar.Bonus6           = 0;
                giftandnoteforprugar.Bonus6Type       = (int)0;
                giftandnoteforprugar.Bonus7           = 0;
                giftandnoteforprugar.Bonus7Type       = (int)0;
                giftandnoteforprugar.Bonus8           = 0;
                giftandnoteforprugar.Bonus8Type       = (int)0;
                giftandnoteforprugar.Bonus9           = 0;
                giftandnoteforprugar.Bonus9Type       = (int)0;
                giftandnoteforprugar.Bonus10          = 0;
                giftandnoteforprugar.Bonus10Type      = (int)0;
                giftandnoteforprugar.ExtraBonus       = 0;
                giftandnoteforprugar.ExtraBonusType   = (int)0;
                giftandnoteforprugar.Effect           = 0;
                giftandnoteforprugar.Emblem           = 0;
                giftandnoteforprugar.Charges          = 0;
                giftandnoteforprugar.MaxCharges       = 0;
                giftandnoteforprugar.SpellID          = 0;
                giftandnoteforprugar.ProcSpellID      = 0;
                giftandnoteforprugar.Type_Damage      = 0;
                giftandnoteforprugar.Realm            = 0;
                giftandnoteforprugar.MaxCount         = 1;
                giftandnoteforprugar.PackSize         = 1;
                giftandnoteforprugar.Extension        = 0;
                giftandnoteforprugar.Quality          = 99;
                giftandnoteforprugar.Condition        = 50000;
                giftandnoteforprugar.MaxCondition     = 50000;
                giftandnoteforprugar.Durability       = 50000;
                giftandnoteforprugar.MaxDurability    = 50000;
                giftandnoteforprugar.PoisonCharges    = 0;
                giftandnoteforprugar.PoisonMaxCharges = 0;
                giftandnoteforprugar.PoisonSpellID    = 0;
                giftandnoteforprugar.ProcSpellID1     = 0;
                giftandnoteforprugar.SpellID1         = 0;
                giftandnoteforprugar.MaxCharges1      = 0;
                giftandnoteforprugar.Charges1         = 0;

                GameServer.Database.AddObject(giftandnoteforprugar);
            }

            #endregion

            #region defineAreas

            #endregion

            #region defineQuestParts

            QuestBuilder   builder = QuestMgr.getBuilder(typeof(thebirthdaygift));
            QuestBehaviour a;
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Interact, null, BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null, (eComparator)5);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk1"), BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Whisper, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Whisper1"), BarkeepNognar);

            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null, (eComparator)5);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk2"), BarkeepNognar);

            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Whisper, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Whisper2"), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null, (eComparator)5);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk3"), BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Whisper, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Whisper3"), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null, (eComparator)5);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk4"), BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Whisper, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Whisper4"), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null, (eComparator)5);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk5"), BarkeepNognar);
            a.AddAction(eActionType.OfferQuest, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.OfferQuest"));
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.thebirthdaygift));
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk6"), BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.thebirthdaygift));
            a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), BarkeepNognar);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk7"), BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Whisper, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Whisper5"), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 1, (eComparator)3);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk8"), BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.EnemyKilled, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.EnemyKilled"), null);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 1, (eComparator)3);
            a.AddAction(eActionType.GiveItem, rattlingskeletonpendant, null);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Interact, null, BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 2, (eComparator)3);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk9"), BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.GiveItem, BarkeepNognar, rattlingskeletonpendant);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 2, (eComparator)3);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk10"), BarkeepNognar);
            a.AddAction(eActionType.TakeItem, rattlingskeletonpendant, null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepNognar, -1);
            a.AddTrigger(eTriggerType.Whisper, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Whisper6"), BarkeepNognar);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 2, (eComparator)3);
            a.AddRequirement(eRequirementType.InventoryItem, rattlingskeletonpendant, 0, (eComparator)3);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk11"), BarkeepNognar);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null);
            a.AddAction(eActionType.GiveItem, giftandnoteforprugar, BarkeepNognar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepPrugar, -1);
            a.AddTrigger(eTriggerType.Interact, null, BarkeepPrugar);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 3, (eComparator)3);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk12"), BarkeepPrugar);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepPrugar, -1);
            a.AddTrigger(eTriggerType.GiveItem, BarkeepPrugar, giftandnoteforprugar);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 3, (eComparator)3);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk13"), BarkeepPrugar);
            a.AddAction(eActionType.TakeItem, giftandnoteforprugar, null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(BarkeepPrugar, -1);
            a.AddTrigger(eTriggerType.Whisper, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Whisper7"), BarkeepPrugar);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), 3, (eComparator)3);
            a.AddRequirement(eRequirementType.InventoryItem, giftandnoteforprugar, 0, (eComparator)3);
            a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.TheBirthdayGift.Talk14"), BarkeepPrugar);
            a.AddAction(eActionType.GiveXP, 20, null);
            a.AddAction(eActionType.GiveGold, 27, null);
            a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.thebirthdaygift), null);
            AddBehaviour(a);

            #endregion

            // Custom Scriptloaded Code Begin

            // Custom Scriptloaded Code End
            if (BarkeepNognar != null)
            {
                BarkeepNognar.AddQuestToGive(typeof(thebirthdaygift));
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Exemplo n.º 12
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            GameNPC[] npcs;

            npcs = WorldMgr.GetObjectsByName <GameNPC>("Gridash", (eRealm)2);
            if (npcs.Length == 0)
            {
                if (!WorldMgr.GetRegion(100).IsDisabled)
                {
                    Gridash       = new DOL.GS.GameNPC();
                    Gridash.Model = 137;
                    Gridash.Name  = "Gridash";
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + Gridash.Name + ", creating ...");
                    }

                    Gridash.GuildName       = "Part of " + questTitle + " Quest";
                    Gridash.Realm           = eRealm.Midgard;
                    Gridash.CurrentRegionID = 100;
                    Gridash.Size            = 51;
                    Gridash.Level           = 21;
                    Gridash.MaxSpeedBase    = 191;
                    Gridash.Faction         = FactionMgr.GetFactionByID(0);
                    Gridash.X               = 772795;
                    Gridash.Y               = 753335;
                    Gridash.Z               = 4600;
                    Gridash.Heading         = 3356;
                    Gridash.RespawnInterval = -1;
                    Gridash.BodyType        = 0;

                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 0;
                    brain.AggroRange = 500;
                    Gridash.SetOwnBrain(brain);

                    // You don't have to store the created mob in the db if you don't want,
                    // it will be recreated each time it is not found, just comment the following
                    // line if you rather not modify your database
                    if (SAVE_INTO_DATABASE)
                    {
                        Gridash.SaveIntoDatabase();
                    }

                    Gridash.AddToWorld();
                }
            }
            else
            {
                Gridash = npcs[0];
            }

            bronze_short_sword = GameServer.Database.FindObjectByKey <ItemTemplate>("bronze_short_sword");
            if (bronze_short_sword == null)
            {
                bronze_short_sword      = new ItemTemplate();
                bronze_short_sword.Name = "bronze short sword";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + bronze_short_sword.Name + ", creating it ...");
                }

                bronze_short_sword.Level            = 1;
                bronze_short_sword.Weight           = 180;
                bronze_short_sword.Model            = 3;
                bronze_short_sword.Object_Type      = 3;
                bronze_short_sword.Item_Type        = 11;
                bronze_short_sword.Id_nb            = "bronze_short_sword";
                bronze_short_sword.Hand             = 2;
                bronze_short_sword.Price            = Money.GetMoney(0, 0, 0, 1, 50);
                bronze_short_sword.IsPickable       = true;
                bronze_short_sword.IsDropable       = true;
                bronze_short_sword.IsTradable       = false;
                bronze_short_sword.CanDropAsLoot    = true;
                bronze_short_sword.Color            = 0;
                bronze_short_sword.Bonus            = 0; // default bonus
                bronze_short_sword.Bonus1           = 0;
                bronze_short_sword.Bonus1Type       = (int)0;
                bronze_short_sword.Bonus2           = 0;
                bronze_short_sword.Bonus2Type       = (int)0;
                bronze_short_sword.Bonus3           = 0;
                bronze_short_sword.Bonus3Type       = (int)0;
                bronze_short_sword.Bonus4           = 0;
                bronze_short_sword.Bonus4Type       = (int)0;
                bronze_short_sword.Bonus5           = 0;
                bronze_short_sword.Bonus5Type       = (int)0;
                bronze_short_sword.Bonus6           = 0;
                bronze_short_sword.Bonus6Type       = (int)0;
                bronze_short_sword.Bonus7           = 0;
                bronze_short_sword.Bonus7Type       = (int)0;
                bronze_short_sword.Bonus8           = 0;
                bronze_short_sword.Bonus8Type       = (int)0;
                bronze_short_sword.Bonus9           = 0;
                bronze_short_sword.Bonus9Type       = (int)0;
                bronze_short_sword.Bonus10          = 0;
                bronze_short_sword.Bonus10Type      = (int)0;
                bronze_short_sword.ExtraBonus       = 0;
                bronze_short_sword.ExtraBonusType   = (int)0;
                bronze_short_sword.Effect           = 0;
                bronze_short_sword.Emblem           = 0;
                bronze_short_sword.Charges          = 0;
                bronze_short_sword.MaxCharges       = 0;
                bronze_short_sword.SpellID          = 0;
                bronze_short_sword.ProcSpellID      = 0;
                bronze_short_sword.Type_Damage      = 2;
                bronze_short_sword.Realm            = 1;
                bronze_short_sword.MaxCount         = 1;
                bronze_short_sword.PackSize         = 1;
                bronze_short_sword.Extension        = 0;
                bronze_short_sword.Quality          = 85;
                bronze_short_sword.Condition        = 50000;
                bronze_short_sword.MaxCondition     = 50000;
                bronze_short_sword.Durability       = 100;
                bronze_short_sword.MaxDurability    = 100;
                bronze_short_sword.PoisonCharges    = 0;
                bronze_short_sword.PoisonMaxCharges = 0;
                bronze_short_sword.PoisonSpellID    = 0;
                bronze_short_sword.ProcSpellID1     = 0;
                bronze_short_sword.SpellID1         = 0;
                bronze_short_sword.MaxCharges1      = 0;
                bronze_short_sword.Charges1         = 0;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(bronze_short_sword);
                }
            }

            sveawolftooth = GameServer.Database.FindObjectByKey <ItemTemplate>("sveawolftooth");
            if (sveawolftooth == null)
            {
                sveawolftooth      = new ItemTemplate();
                sveawolftooth.Name = "Sveawolf Tooth";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + sveawolftooth.Name + ", creating it ...");
                }

                sveawolftooth.Level            = 50;
                sveawolftooth.Weight           = 5;
                sveawolftooth.Model            = 106;
                sveawolftooth.Object_Type      = 0;
                sveawolftooth.Item_Type        = 40;
                sveawolftooth.Id_nb            = "sveawolftooth";
                sveawolftooth.Hand             = 0;
                sveawolftooth.Price            = 0;
                sveawolftooth.IsPickable       = true;
                sveawolftooth.IsDropable       = true;
                sveawolftooth.IsTradable       = true;
                sveawolftooth.CanDropAsLoot    = false;
                sveawolftooth.Color            = 0;
                sveawolftooth.Bonus            = 35; // default bonus
                sveawolftooth.Bonus1           = 0;
                sveawolftooth.Bonus1Type       = (int)0;
                sveawolftooth.Bonus2           = 0;
                sveawolftooth.Bonus2Type       = (int)0;
                sveawolftooth.Bonus3           = 0;
                sveawolftooth.Bonus3Type       = (int)0;
                sveawolftooth.Bonus4           = 0;
                sveawolftooth.Bonus4Type       = (int)0;
                sveawolftooth.Bonus5           = 0;
                sveawolftooth.Bonus5Type       = (int)0;
                sveawolftooth.Bonus6           = 0;
                sveawolftooth.Bonus6Type       = (int)0;
                sveawolftooth.Bonus7           = 0;
                sveawolftooth.Bonus7Type       = (int)0;
                sveawolftooth.Bonus8           = 0;
                sveawolftooth.Bonus8Type       = (int)0;
                sveawolftooth.Bonus9           = 0;
                sveawolftooth.Bonus9Type       = (int)0;
                sveawolftooth.Bonus10          = 0;
                sveawolftooth.Bonus10Type      = (int)0;
                sveawolftooth.ExtraBonus       = 0;
                sveawolftooth.ExtraBonusType   = (int)0;
                sveawolftooth.Effect           = 0;
                sveawolftooth.Emblem           = 0;
                sveawolftooth.Charges          = 0;
                sveawolftooth.MaxCharges       = 0;
                sveawolftooth.SpellID          = 0;
                sveawolftooth.ProcSpellID      = 0;
                sveawolftooth.Type_Damage      = 0;
                sveawolftooth.Realm            = 0;
                sveawolftooth.MaxCount         = 1;
                sveawolftooth.PackSize         = 1;
                sveawolftooth.Extension        = 0;
                sveawolftooth.Quality          = 99;
                sveawolftooth.Condition        = 50000;
                sveawolftooth.MaxCondition     = 50000;
                sveawolftooth.Durability       = 50000;
                sveawolftooth.MaxDurability    = 50000;
                sveawolftooth.PoisonCharges    = 0;
                sveawolftooth.PoisonMaxCharges = 0;
                sveawolftooth.PoisonSpellID    = 0;
                sveawolftooth.ProcSpellID1     = 0;
                sveawolftooth.SpellID1         = 0;
                sveawolftooth.MaxCharges1      = 0;
                sveawolftooth.Charges1         = 0;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(sveawolftooth);
                }
            }

            sveabone_hilt_sword = GameServer.Database.FindObjectByKey <ItemTemplate>("sveabone_hilt_sword");
            if (sveabone_hilt_sword == null)
            {
                sveabone_hilt_sword      = new ItemTemplate();
                sveabone_hilt_sword.Name = "Sveabone Hilt Sword";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + sveabone_hilt_sword.Name + ", creating it ...");
                }

                sveabone_hilt_sword.Level            = 1;
                sveabone_hilt_sword.Weight           = 18;
                sveabone_hilt_sword.Model            = 311;
                sveabone_hilt_sword.Object_Type      = 11;
                sveabone_hilt_sword.Item_Type        = 10;
                sveabone_hilt_sword.Id_nb            = "sveabone_hilt_sword";
                sveabone_hilt_sword.Hand             = 0;
                sveabone_hilt_sword.Price            = 0;
                sveabone_hilt_sword.IsPickable       = true;
                sveabone_hilt_sword.IsDropable       = true;
                sveabone_hilt_sword.IsTradable       = false;
                sveabone_hilt_sword.CanDropAsLoot    = false;
                sveabone_hilt_sword.Color            = 0;
                sveabone_hilt_sword.Bonus            = 0; // default bonus
                sveabone_hilt_sword.Bonus1           = 1;
                sveabone_hilt_sword.Bonus1Type       = (int)52;
                sveabone_hilt_sword.Bonus2           = 0;
                sveabone_hilt_sword.Bonus2Type       = (int)0;
                sveabone_hilt_sword.Bonus3           = 0;
                sveabone_hilt_sword.Bonus3Type       = (int)0;
                sveabone_hilt_sword.Bonus4           = 0;
                sveabone_hilt_sword.Bonus4Type       = (int)0;
                sveabone_hilt_sword.Bonus5           = 0;
                sveabone_hilt_sword.Bonus5Type       = (int)0;
                sveabone_hilt_sword.Bonus6           = 0;
                sveabone_hilt_sword.Bonus6Type       = (int)0;
                sveabone_hilt_sword.Bonus7           = 0;
                sveabone_hilt_sword.Bonus7Type       = (int)0;
                sveabone_hilt_sword.Bonus8           = 0;
                sveabone_hilt_sword.Bonus8Type       = (int)0;
                sveabone_hilt_sword.Bonus9           = 0;
                sveabone_hilt_sword.Bonus9Type       = (int)0;
                sveabone_hilt_sword.Bonus10          = 0;
                sveabone_hilt_sword.Bonus10Type      = (int)0;
                sveabone_hilt_sword.ExtraBonus       = 0;
                sveabone_hilt_sword.ExtraBonusType   = (int)0;
                sveabone_hilt_sword.Effect           = 0;
                sveabone_hilt_sword.Emblem           = 0;
                sveabone_hilt_sword.Charges          = 0;
                sveabone_hilt_sword.MaxCharges       = 0;
                sveabone_hilt_sword.SpellID          = 0;
                sveabone_hilt_sword.ProcSpellID      = 0;
                sveabone_hilt_sword.Type_Damage      = 2;
                sveabone_hilt_sword.Realm            = 0;
                sveabone_hilt_sword.MaxCount         = 1;
                sveabone_hilt_sword.PackSize         = 1;
                sveabone_hilt_sword.Extension        = 0;
                sveabone_hilt_sword.Quality          = 99;
                sveabone_hilt_sword.Condition        = 100;
                sveabone_hilt_sword.MaxCondition     = 100;
                sveabone_hilt_sword.Durability       = 100;
                sveabone_hilt_sword.MaxDurability    = 100;
                sveabone_hilt_sword.PoisonCharges    = 0;
                sveabone_hilt_sword.PoisonMaxCharges = 0;
                sveabone_hilt_sword.PoisonSpellID    = 0;
                sveabone_hilt_sword.ProcSpellID1     = 0;
                sveabone_hilt_sword.SpellID1         = 0;
                sveabone_hilt_sword.MaxCharges1      = 0;
                sveabone_hilt_sword.Charges1         = 0;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(sveabone_hilt_sword);
                }
            }

            QuestBuilder   builder = QuestMgr.GetBuilder(typeof(sveabonehiltsword));
            QuestBehaviour a;

            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.Interact, null, Gridash);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), Gridash);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "Hail young one! I have noticed that you do not carry one of my fine [bone hilt swords].", Gridash);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.Whisper, "bone hilt swords", Gridash);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), Gridash);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "Aye! They are some of my finest works! I don't suppose you [would care for one] eh?", Gridash);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.Whisper, "would care for one", Gridash);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), Gridash);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), null, (eComparator)5);
            a.AddAction(eActionType.OfferQuest, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), "Will you do what is asked so that Gridash can make a Sveabone hilt sword?");
            AddBehaviour(a);
            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword));
            a.AddAction(eActionType.Talk, "No problem. See you", Gridash);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword));
            a.AddAction(eActionType.Talk, "Oh great then! Run along and buy me a bronze short sword. I should be ready once you return.", Gridash);
            a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), Gridash);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.GiveItem, Gridash, bronze_short_sword);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), null);
            a.AddAction(eActionType.Talk, "Good work! I cannot seem to find anymore sveawolf teeth to fashion your weapon. Find one and return it to me.", Gridash);
            a.AddAction(eActionType.TakeItem, bronze_short_sword, null);
            a.AddAction(eActionType.IncQuestStep, typeof(sveabonehiltsword), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.EnemyKilled, "young sveawof", null);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), 2, (eComparator)3);
            a.AddAction(eActionType.GiveItem, sveawolftooth, null);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Gridash, -1);
            a.AddTrigger(eTriggerType.GiveItem, Gridash, sveawolftooth);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), 3, (eComparator)3);
            a.AddAction(eActionType.Talk, "Here is your completed work. I hope it serves you well!", Gridash);
            a.AddAction(eActionType.TakeItem, sveawolftooth, null);
            a.AddAction(eActionType.GiveItem, sveabone_hilt_sword, Gridash);
            a.AddAction(eActionType.GiveXP, 20, null);
            a.AddAction(eActionType.GiveGold, 450, null);
            a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.sveabonehiltsword), null);
            AddBehaviour(a);

            // Custom Scriptloaded Code Begin

            // Custom Scriptloaded Code End
            if (Gridash != null)
            {
                Gridash.AddQuestToGive(typeof(sveabonehiltsword));
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            GameNPC[] npcs = WorldMgr.GetObjectsByName <GameNPC>(questGiverName, eRealm.Albion);

            if (npcs.Length == 0)
            {
                questGiver       = new GameNPC();
                questGiver.Model = 1960;
                questGiver.Name  = questGiverName;
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + questGiver.Name + ", creating him ...");
                }

                questGiver.Realm           = eRealm.Albion;
                questGiver.CurrentRegionID = 27;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.HandsArmor, 691, 0);        // Slot 22
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 692, 0);         // Slot 23
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 688, 0);        // Slot 25
                template.AddNPCEquipment(eInventorySlot.Cloak, 676, 0);             // Slot 26
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 689, 0);         // Slot 27
                template.AddNPCEquipment(eInventorySlot.ArmsArmor, 690, 0);         // Slot 28
                questGiver.Inventory = template.CloseTemplate();
                questGiver.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                questGiver.Size    = 55;
                questGiver.Level   = 70;
                questGiver.X       = 95510;
                questGiver.Y       = 101313;
                questGiver.Z       = 5340;
                questGiver.Heading = 3060;

                if (SAVE_INTO_DATABASE)
                {
                    questGiver.SaveIntoDatabase();
                }

                questGiver.AddToWorld();
            }
            else
            {
                questGiver = npcs[0];
            }

            npcs = WorldMgr.GetObjectsByName <GameNPC>(questTargetName, eRealm.Albion);

            if (npcs.Length == 0)
            {
                questTarget       = new GameNPC();
                questTarget.Model = 73;
                questTarget.Name  = questTargetName;
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + questTarget.Name + ", creating him ...");
                }

                questTarget.Realm           = eRealm.Albion;
                questTarget.CurrentRegionID = 27;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.HandsArmor, 665, 0);        // Slot 22
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 666, 0);         // Slot 23
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 662, 0);        // Slot 25
                template.AddNPCEquipment(eInventorySlot.Cloak, 676, 0);             // Slot 26
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 663, 0);         // Slot 27
                template.AddNPCEquipment(eInventorySlot.ArmsArmor, 664, 0);         // Slot 28
                questTarget.Inventory = template.CloseTemplate();
                questTarget.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                questTarget.Size    = 50;
                questTarget.Level   = 38;
                questTarget.X       = 94789;
                questTarget.Y       = 101439;
                questTarget.Z       = 5248;
                questTarget.Heading = 2878;

                if (SAVE_INTO_DATABASE)
                {
                    questTarget.SaveIntoDatabase();
                }

                questTarget.AddToWorld();
            }
            else
            {
                questTarget = npcs[0];
            }

            targetArea = WorldMgr.GetRegion(targetLocation.RegionID).AddArea(new Area.Circle(string.Empty, targetLocation.X, targetLocation.Y, targetLocation.Z, 200));

            QuestBuilder   builder  = QuestMgr.GetBuilder(typeof(MovementAndInteraction));
            QuestBehaviour a        = null;
            string         message1 = "Welcome to " + zoneName + ", <Class>. Here you will learn the basic skills needed to defend yourself as you explore our realm and grow in power and wisdom. Now, without further delay, let's get you started on your [training].";
            string         message2 = "If you exit through the doors behind me, you will enter the courtyard. In the courtyard, you will find Master Gethin, who will be your training instructor. Go now and speak to Master Gethin.";

            a = builder.CreateBehaviour(questGiver, -1);
            a.AddTrigger(eTriggerType.Interact, null, questGiver);
            a.AddRequirement(eRequirementType.QuestPending, typeof(MovementAndInteraction), null, (eComparator)5);
            a.AddAction(eActionType.GiveQuest, typeof(MovementAndInteraction), questGiver);
            AddBehaviour(a);

            a = builder.CreateBehaviour(questGiver, -1);
            a.AddTrigger(eTriggerType.Interact, null, questGiver);
            a.AddRequirement(eRequirementType.QuestStep, typeof(MovementAndInteraction), 1, (eComparator)3);
            a.AddAction(eActionType.Talk, message1, questGiver);
            AddBehaviour(a);

            a = builder.CreateBehaviour(questGiver, -1);
            a.AddTrigger(eTriggerType.Whisper, "training", questGiver);
            a.AddRequirement(eRequirementType.QuestStep, typeof(MovementAndInteraction), 1, (eComparator)3);
            a.AddAction(eActionType.IncQuestStep, typeof(MovementAndInteraction), null);
            a.AddAction(eActionType.Talk, message2, questGiver);
            AddBehaviour(a);

            a = builder.CreateBehaviour(questGiver, -1);
            a.AddTrigger(eTriggerType.Interact, null, questGiver);
            a.AddRequirement(eRequirementType.QuestStep, typeof(MovementAndInteraction), 2, (eComparator)3);
            a.AddAction(eActionType.Talk, message2, questGiver);
            AddBehaviour(a);

            a = builder.CreateBehaviour(questGiver, -1);
            a.AddTrigger(eTriggerType.EnterArea, null, targetArea);
            a.AddRequirement(eRequirementType.QuestStep, typeof(MovementAndInteraction), 2, (eComparator)3);
            a.AddAction(eActionType.IncQuestStep, typeof(MovementAndInteraction), null);
            AddBehaviour(a);

            a = builder.CreateBehaviour(questTarget, -1);
            a.AddTrigger(eTriggerType.Interact, null, questTarget);
            a.AddRequirement(eRequirementType.QuestStep, typeof(MovementAndInteraction), 3, (eComparator)3);
            a.AddAction(eActionType.FinishQuest, typeof(MovementAndInteraction), null);
            AddBehaviour(a);

            questGiver.AddQuestToGive(typeof(MovementAndInteraction));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Exemplo n.º 14
0
        public override void SendRegions(ushort regionId)
        {
            if (m_gameClient.Player != null)
            {
                if (!m_gameClient.Socket.Connected)
                {
                    return;
                }
                Region region = WorldMgr.GetRegion((ushort)m_gameClient.Player.CurrentRegionID);
                if (region == null)
                {
                    return;
                }
                using (GSTCPPacketOut pak = new GSTCPPacketOut(0xB1))
                {
                    //				pak.WriteByte((byte)((region.Expansion + 1) << 4)); // Must be expansion
                    pak.WriteByte(0);                     // but this packet sended when client in old region. but this field must show expanstion for jump destanation region
                    //Dinberg - trying to get instances to work.
                    pak.WriteByte((byte)region.Skin);     // This was pak.WriteByte((byte)region.ID);
                    pak.Fill(0, 20);
                    pak.FillString(region.ServerPort.ToString(), 5);
                    pak.FillString(region.ServerPort.ToString(), 5);
                    string ip = region.ServerIP;
                    if (ip == "any" || ip == "0.0.0.0" || ip == "127.0.0.1" || ip.StartsWith("10.13.") || ip.StartsWith("192.168."))
                    {
                        ip = ((IPEndPoint)m_gameClient.Socket.LocalEndPoint).Address.ToString();
                    }
                    pak.FillString(ip, 20);
                    SendTCP(pak);
                }
            }
            else
            {
                RegionEntry[] entries = WorldMgr.GetRegionList();

                if (entries == null)
                {
                    return;
                }
                int index = 0;
                int num   = 0;
                int count = entries.Length;
                while (entries != null && count > index)
                {
                    using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.ClientRegions)))
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            while (index < count && (int)m_gameClient.ClientType <= entries[index].expansion)
                            {
                                index++;
                            }

                            if (index >= count)
                            {                                   //If we have no more entries
                                pak.Fill(0x0, 52);
                            }
                            else
                            {
                                pak.WriteByte((byte)(++num));
                                pak.WriteByte((byte)entries[index].id);
                                pak.FillString(entries[index].name, 20);
                                pak.FillString(entries[index].fromPort, 5);
                                pak.FillString(entries[index].toPort, 5);
                                //Try to fix the region ip so UDP is enabled!
                                string ip = entries[index].ip;
                                if (ip == "any" || ip == "0.0.0.0" || ip == "127.0.0.1" || ip.StartsWith("10.13.") || ip.StartsWith("192.168."))
                                {
                                    ip = ((IPEndPoint)m_gameClient.Socket.LocalEndPoint).Address.ToString();
                                }
                                pak.FillString(ip, 20);

                                //							DOLConsole.WriteLine(string.Format(" ip={3}; fromPort={1}; toPort={2}; num={4}; id={0}; region name={5}", entries[index].id, entries[index].fromPort, entries[index].toPort, entries[index].ip, num, entries[index].name));
                                index++;
                            }
                        }
                        SendTCP(pak);
                    }
                }
            }
        }
Exemplo n.º 15
0
        public static void F_INIT_PLAYER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            Player Plr = cclient.Plr;

            if (Plr == null)
            {
                return;
            }

            // clear all lockouts if they are expired
            InstanceService.ClearLockouts(Plr);

            if (!Plr.IsInWorld()) // If the player is not on a map, then we add it to the map
            {
                ushort zoneId   = Plr.Info.Value.ZoneId;
                ushort regionId = (ushort)Plr.Info.Value.RegionId;

                Zone_Info info = ZoneService.GetZone_Info(zoneId);
                if (info?.Type == 0)
                {
                    RegionMgr region = WorldMgr.GetRegion(regionId, true);
                    if (region.AddObject(Plr, zoneId, true))
                    {
                        return;
                    }
                }
                else if (info?.Type == 4 || info?.Type == 5 || info?.Type == 6)  // login into a instance results in teleport outside
                {
                    if (InstanceService._InstanceInfo.TryGetValue(zoneId, out Instance_Info II))
                    {
                        Zone_jump ExitJump = null;
                        if (Plr.Realm == Realms.REALMS_REALM_ORDER)
                        {
                            ExitJump = ZoneService.GetZoneJump(II.OrderExitZoneJumpID);
                        }
                        else if (Plr.Realm == Realms.REALMS_REALM_DESTRUCTION)
                        {
                            ExitJump = ZoneService.GetZoneJump(II.DestrExitZoneJumpID);
                        }

                        if (ExitJump == null)
                        {
                            Log.Error("Exit Jump in Instance", " " + zoneId + " missing!");
                        }
                        else
                        {
                            Plr.Teleport(ExitJump.ZoneID, ExitJump.WorldX, ExitJump.WorldY, ExitJump.WorldZ, ExitJump.WorldO);
                        }
                    }
                    return;
                }

                // Warp a player to their bind point if they attempt to load into a scenario map.
                RallyPoint rallyPoint = RallyPointService.GetRallyPoint(Plr.Info.Value.RallyPoint);

                if (rallyPoint != null)
                {
                    Plr.Teleport(rallyPoint.ZoneID, rallyPoint.WorldX, rallyPoint.WorldY, rallyPoint.WorldZ, rallyPoint.WorldO);
                }
                else
                {
                    CharacterInfo cInfo = CharMgr.GetCharacterInfo(Plr.Info.Career);
                    Plr.Teleport(cInfo.ZoneId, (uint)cInfo.WorldX, (uint)cInfo.WorldY, (ushort)cInfo.WorldZ,
                                 (ushort)cInfo.WorldO);
                }
            }
            else
            {
                Plr.Loaded = false;
                Plr.StartInit();
            }
        }
Exemplo n.º 16
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            #region defineNPCs
            GameNPC[] npcs;

            npcs = WorldMgr.GetNPCsByName("Torold Sterkkriger", (eRealm)2);
            if (npcs.Length == 0)
            {
                if (!WorldMgr.GetRegion(151).IsDisabled)
                {
                    ToroldSterkkriger       = new DOL.GS.GameNPC();
                    ToroldSterkkriger.Model = 522;
                    ToroldSterkkriger.Name  = "Torold Sterkkriger";
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + ToroldSterkkriger.Name + ", creating ...");
                    }
                    ToroldSterkkriger.GuildName       = "Part of " + questTitle + " Quest";
                    ToroldSterkkriger.Realm           = eRealm.Midgard;
                    ToroldSterkkriger.CurrentRegionID = 151;
                    ToroldSterkkriger.Size            = 50;
                    ToroldSterkkriger.Level           = 55;
                    ToroldSterkkriger.MaxSpeedBase    = 191;
                    ToroldSterkkriger.Faction         = FactionMgr.GetFactionByID(0);
                    ToroldSterkkriger.X               = 287623;
                    ToroldSterkkriger.Y               = 355226;
                    ToroldSterkkriger.Z               = 3488;
                    ToroldSterkkriger.Heading         = 3788;
                    ToroldSterkkriger.RespawnInterval = -1;
                    ToroldSterkkriger.BodyType        = 0;


                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 0;
                    brain.AggroRange = 500;
                    ToroldSterkkriger.SetOwnBrain(brain);

                    //You don't have to store the created mob in the db if you don't want,
                    //it will be recreated each time it is not found, just comment the following
                    //line if you rather not modify your database
                    if (SAVE_INTO_DATABASE)
                    {
                        ToroldSterkkriger.SaveIntoDatabase();
                    }

                    ToroldSterkkriger.AddToWorld();
                }
            }
            else
            {
                ToroldSterkkriger = npcs[0];
            }

            npcs = WorldMgr.GetNPCsByName("Jorund Bruttstein", (eRealm)2);
            if (npcs.Length == 0)
            {
                if (!WorldMgr.GetRegion(151).IsDisabled)
                {
                    JorundBruttstein       = new DOL.GS.GameNPC();
                    JorundBruttstein.Model = 513;
                    JorundBruttstein.Name  = "Jorund Bruttstein";
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + JorundBruttstein.Name + ", creating ...");
                    }
                    JorundBruttstein.GuildName       = "Part of " + questTitle + " Quest";
                    JorundBruttstein.Realm           = eRealm.Midgard;
                    JorundBruttstein.CurrentRegionID = 151;
                    JorundBruttstein.Size            = 52;
                    JorundBruttstein.Level           = 50;
                    JorundBruttstein.MaxSpeedBase    = 191;
                    JorundBruttstein.Faction         = FactionMgr.GetFactionByID(0);
                    JorundBruttstein.X               = 287884;
                    JorundBruttstein.Y               = 356307;
                    JorundBruttstein.Z               = 3488;
                    JorundBruttstein.Heading         = 3163;
                    JorundBruttstein.RespawnInterval = -1;
                    JorundBruttstein.BodyType        = 0;


                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 0;
                    brain.AggroRange = 500;
                    JorundBruttstein.SetOwnBrain(brain);

                    //You don't have to store the created mob in the db if you don't want,
                    //it will be recreated each time it is not found, just comment the following
                    //line if you rather not modify your database
                    if (SAVE_INTO_DATABASE)
                    {
                        JorundBruttstein.SaveIntoDatabase();
                    }

                    JorundBruttstein.AddToWorld();
                }
            }
            else
            {
                JorundBruttstein = npcs[0];
            }


            #endregion

            #region defineItems

            marinefungusroot = GameServer.Database.FindObjectByKey <ItemTemplate>("marinefungusroot");
            if (marinefungusroot == null)
            {
                marinefungusroot      = new ItemTemplate();
                marinefungusroot.Name = "Marine Fungus Root";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + marinefungusroot.Name + ", creating it ...");
                }
                marinefungusroot.Level            = 50;
                marinefungusroot.Weight           = 5;
                marinefungusroot.Model            = 546;
                marinefungusroot.Object_Type      = 0;
                marinefungusroot.Item_Type        = 40;
                marinefungusroot.Id_nb            = "marinefungusroot";
                marinefungusroot.Hand             = 0;
                marinefungusroot.Price            = 0;
                marinefungusroot.IsPickable       = true;
                marinefungusroot.IsDropable       = true;
                marinefungusroot.IsTradable       = true;
                marinefungusroot.CanDropAsLoot    = false;
                marinefungusroot.Color            = 0;
                marinefungusroot.Bonus            = 35;      // default bonus
                marinefungusroot.Bonus1           = 0;
                marinefungusroot.Bonus1Type       = (int)0;
                marinefungusroot.Bonus2           = 0;
                marinefungusroot.Bonus2Type       = (int)0;
                marinefungusroot.Bonus3           = 0;
                marinefungusroot.Bonus3Type       = (int)0;
                marinefungusroot.Bonus4           = 0;
                marinefungusroot.Bonus4Type       = (int)0;
                marinefungusroot.Bonus5           = 0;
                marinefungusroot.Bonus5Type       = (int)0;
                marinefungusroot.Bonus6           = 0;
                marinefungusroot.Bonus6Type       = (int)0;
                marinefungusroot.Bonus7           = 0;
                marinefungusroot.Bonus7Type       = (int)0;
                marinefungusroot.Bonus8           = 0;
                marinefungusroot.Bonus8Type       = (int)0;
                marinefungusroot.Bonus9           = 0;
                marinefungusroot.Bonus9Type       = (int)0;
                marinefungusroot.Bonus10          = 0;
                marinefungusroot.Bonus10Type      = (int)0;
                marinefungusroot.ExtraBonus       = 0;
                marinefungusroot.ExtraBonusType   = (int)0;
                marinefungusroot.Effect           = 0;
                marinefungusroot.Emblem           = 0;
                marinefungusroot.Charges          = 0;
                marinefungusroot.MaxCharges       = 0;
                marinefungusroot.SpellID          = 0;
                marinefungusroot.ProcSpellID      = 0;
                marinefungusroot.Type_Damage      = 0;
                marinefungusroot.Realm            = 0;
                marinefungusroot.MaxCount         = 1;
                marinefungusroot.PackSize         = 1;
                marinefungusroot.Extension        = 0;
                marinefungusroot.Quality          = 99;
                marinefungusroot.Condition        = 50000;
                marinefungusroot.MaxCondition     = 50000;
                marinefungusroot.Durability       = 50000;
                marinefungusroot.MaxDurability    = 50000;
                marinefungusroot.PoisonCharges    = 0;
                marinefungusroot.PoisonMaxCharges = 0;
                marinefungusroot.PoisonSpellID    = 0;
                marinefungusroot.ProcSpellID1     = 0;
                marinefungusroot.SpellID1         = 0;
                marinefungusroot.MaxCharges1      = 0;
                marinefungusroot.Charges1         = 0;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(marinefungusroot);
                }
            }


            #endregion

            #region defineAreas

            #endregion

            #region defineQuestParts

            QuestBuilder   builder = QuestMgr.getBuilder(typeof(trialofstrength));
            QuestBehaviour a;
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.Interact, null, ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(trialofstrength), ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.trialofstrength), null, (eComparator)5);
            a.AddRequirement(eRequirementType.Class, 35, false);
            a.AddAction(eActionType.Talk, "Hail. I am Torold, and I shall be your trainer in this wild land. King Goran Stonefist and his brother Stonelock have charged me with training all young Vikings to prepare them to join the ranks of King Goran's army to aid in the exploration of Aegir. Aegir is a wild, untamed place, and it's made even more dangerous for a your Viking like you by the presence of [Morvaltar].", ToroldSterkkriger);
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.Interact, null, ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.trialofstrength), ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.trialofstrength), null, (eComparator)5);
            a.AddRequirement(eRequirementType.Class, 38, false);
            a.AddAction(eActionType.Talk, "Hail. I am Torold, and I shall be your trainer in this wild land. King Goran Stonefist and his brother Stonelock have charged me with training all young Rogue to prepare them to join the ranks of King Goran's army to aid in the exploration of Aegir. Aegir is a wild, untamed place, and it's made even more dangerous for a your Rogue like you by the presence of [Morvaltar].", ToroldSterkkriger);
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.Whisper, "Morvaltar", ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.trialofstrength), ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.trialofstrength), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "As you may know, the Morvaltar are your wild cousins. We of Midgard do not fear Valkyn like you, for as a group you have more than proven your loyalty to King Goran. Many Valkyn have also proven that they are strong, intelligent, and brave. These are [the qualities] that all Vikings must possess before they can choose where their destiny lies.", ToroldSterkkriger);
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.Whisper, "the qualities", ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.trialofstrength), ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.trialofstrength), null, (eComparator)5);
            a.AddRequirement(eRequirementType.Class, 35, false);
            a.AddAction(eActionType.Talk, "Now, young one, prepare yourself. You have three trials to face before I can allow you to make your destiny. These trials are designed to separate the true Vikings from the everyday Valkyn. So, prepare yourself now, for you trial is waiting for you. It is a test to [prove your strength]. Only the strongest will survive in this land.", ToroldSterkkriger);
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.Whisper, "the qualities", ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.trialofstrength), ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.trialofstrength), null, (eComparator)5);
            a.AddRequirement(eRequirementType.Class, 38, false);
            a.AddAction(eActionType.Talk, "Now, young one, prepare yourself. You have three trials to face before I can allow you to make your destiny. These trials are designed to separate the true Rogues from the everyday Valkyn. So, prepare yourself now, for you trial is waiting for you. It is a test to [prove your strength]. Only the strongest will survive in this land.", ToroldSterkkriger);
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.Whisper, "prove your strength", ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.trialofstrength), ToroldSterkkriger);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.trialofstrength), null, (eComparator)5);
            a.AddAction(eActionType.OfferQuest, typeof(trialofstrength), "Will you prove you have the strength to survive in the land of Aegir?");
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.trialofstrength));
            a.AddAction(eActionType.Talk, "No problem. See you", ToroldSterkkriger);
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.trialofstrength));
            a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.trialofstrength), ToroldSterkkriger);
            a.AddAction(eActionType.Talk, "Seek out Jorund Bruttstein in Aegirhamn. Tell him your name when he asks.", ToroldSterkkriger);
            AddBehaviour(a);
            a = builder.CreateBehaviour(JorundBruttstein, -1);
            a.AddTrigger(eTriggerType.Interact, null, JorundBruttstein);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), 1, (eComparator)3);
            a.AddRequirement(eRequirementType.Class, 35, false);
            a.AddAction(eActionType.Talk, "Lo, I see a young Viking before me. What is your name? Speak up!", JorundBruttstein);
            a.AddAction(eActionType.Talk, "You are here to prove that you have the strength in you to endure in this land. The trial is simple in nature, but unless you are strong, may prove difficult to execute. You must venture out and face [one of the creatures] that roam this land.", JorundBruttstein);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(JorundBruttstein, -1);
            a.AddTrigger(eTriggerType.Interact, null, JorundBruttstein);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), 1, (eComparator)3);
            a.AddRequirement(eRequirementType.Class, 38, false);
            a.AddAction(eActionType.Talk, "Lo, I see a young Rogue before me. What is your name? Speak up!", JorundBruttstein);
            a.AddAction(eActionType.Talk, "You are here to prove that you have the strength in you to endure in this land. The trial is simple in nature, but unless you are strong, may prove difficult to execute. You must venture out and face [one of the creatures] that roam this land.", JorundBruttstein);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(JorundBruttstein, -1);
            a.AddTrigger(eTriggerType.Whisper, "one of the creatures", JorundBruttstein);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), 2, (eComparator)3);
            a.AddAction(eActionType.Talk, "You must seek out a marine fungus. They may be found in the waters south and southwest of here. Find one and defeat it. Once you have, obtain proof that you have accomplished this test. Return to me here.", JorundBruttstein);
            AddBehaviour(a);
            a = builder.CreateBehaviour(ToroldSterkkriger, -1);
            a.AddTrigger(eTriggerType.EnemyKilled, "marine fungus", null);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), 2, (eComparator)3);
            a.AddAction(eActionType.GiveItem, marinefungusroot, null);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(JorundBruttstein, -1);
            a.AddTrigger(eTriggerType.Interact, null, JorundBruttstein);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), 3, (eComparator)3);
            a.AddAction(eActionType.Talk, "So, you managed to survive, but anyone can run away. Show me the proof you defeated the marine fungus.", JorundBruttstein);
            a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(JorundBruttstein, -1);
            a.AddTrigger(eTriggerType.GiveItem, JorundBruttstein, marinefungusroot);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), 4, (eComparator)3);
            a.AddRequirement(eRequirementType.Class, 35, false);
            a.AddAction(eActionType.Talk, "Well done. I do not like to be so rough with young Vikings, but I must be. I do not want to see anyone die because I failed to do my job. But you have proven that you have the potential for great strength. I shall let your trainer know of your success.", JorundBruttstein);
            a.AddAction(eActionType.GiveXP, 20, null);
            a.AddAction(eActionType.GiveGold, 230, null);
            a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.trialofstrength), null);
            AddBehaviour(a);
            a = builder.CreateBehaviour(JorundBruttstein, -1);
            a.AddTrigger(eTriggerType.GiveItem, JorundBruttstein, marinefungusroot);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.trialofstrength), 4, (eComparator)3);
            a.AddRequirement(eRequirementType.Class, 38, false);
            a.AddAction(eActionType.Talk, "\"Well done. I do not like to be so rough with young Rogues, but I must be. I do not want to see anyone die because I failed to do my job. But you have proven that you have the potential for great strength. I shall let your trainer know of your success.", JorundBruttstein);
            a.AddAction(eActionType.GiveXP, 20, null);
            a.AddAction(eActionType.GiveGold, 230, null);
            a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.trialofstrength), null);
            AddBehaviour(a);

            #endregion

            // Custom Scriptloaded Code Begin

            // Custom Scriptloaded Code End
            if (ToroldSterkkriger != null)
            {
                ToroldSterkkriger.AddQuestToGive(typeof(trialofstrength));
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Exemplo n.º 17
0
 private static IEnumerable <Zone2> GetZonesToBuild()
 {
     // Zones
     foreach (var zone in Arguments.RecastBuildZoneID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
     {
         yield return(WorldMgr.GetZone(int.Parse(zone)));
     }
     // Regions
     foreach (var region in Arguments.RecastBuildRegionID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(r => WorldMgr.GetRegion(int.Parse(r))).Where(r => r != null))
     {
         foreach (var zone in region.Values)
         {
             yield return(zone);
         }
     }
     // All?
     if (Arguments.RecastBuildAll)
     {
         foreach (var zone in WorldMgr.GetAllRegions().SelectMany(r => r.Values))
         {
             yield return(zone);
         }
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Get Player's Bind Spot Description Checking Any Area with Description or Zone Description
 /// </summary>
 /// <param name="player"></param>
 /// <returns></returns>
 public static string GetBindSpotDescription(this GamePlayer player)
 {
     return(player.GetTranslatedSpotDescription(WorldMgr.GetRegion((ushort)player.BindRegion), player.BindXpos, player.BindYpos, player.BindZpos));
 }
Exemplo n.º 19
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length == 1)
            {
                DisplaySyntax(client);
                return;
            }

            switch (args[1].ToLower())
            {
            case "create":
            {
                if (args.Length != 7)
                {
                    DisplaySyntax(client);
                    return;
                }

                DBArea area = new DBArea();
                area.Description = args[2];

                switch (args[3].ToLower())
                {
                case "circle": area.ClassType = "DOL.GS.Area+Circle"; break;

                case "square": area.ClassType = "DOL.GS.Area+Square"; break;

                case "safe":
                case "safearea": area.ClassType = "DOL.GS.Area+SafeArea"; break;

                case "bind":
                case "bindarea": area.ClassType = "DOL.GS.Area+BindArea"; break;

                default:
                {
                    DisplaySyntax(client);
                    return;
                }
                }

                area.Radius = Convert.ToInt16(args[4]);
                switch (args[5].ToLower())
                {
                case "y": { area.CanBroadcast = true; break; }

                case "n": { area.CanBroadcast = false; break; }

                default: { DisplaySyntax(client); return; }
                }

                area.Sound  = byte.Parse(args[6]);
                area.Region = client.Player.CurrentRegionID;
                area.X      = client.Player.X;
                area.Y      = client.Player.Y;
                area.Z      = client.Player.Z;

                Assembly     gasm    = Assembly.GetAssembly(typeof(GameServer));
                AbstractArea newArea = (AbstractArea)gasm.CreateInstance(area.ClassType, false);
                newArea.LoadFromDatabase(area);

                newArea.Sound        = area.Sound;
                newArea.CanBroadcast = area.CanBroadcast;
                WorldMgr.GetRegion(client.Player.CurrentRegionID).AddArea(newArea);
                GameServer.Database.AddObject(area);
                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Area.AreaCreated", area.Description, area.X, area.Z, area.Radius, area.CanBroadcast.ToString(), area.Sound));
                break;
            }

            default:
            {
                DisplaySyntax(client);
                break;
            }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// load all relics from DB
        /// </summary>
        /// <returns></returns>
        public static bool Init()
        {
            lock (m_relics.SyncRoot)
            {
                //at first remove all relics
                foreach (GameRelic rel in m_relics.Values)
                {
                    rel.SaveIntoDatabase();
                    rel.RemoveFromWorld();
                }

                //then clear the hashtable
                m_relics.Clear();

                //then we remove all relics from the pads
                foreach (GameRelicPad pad in m_relicPads)
                {
                    pad.RemoveRelic();
                }

                // if relics are on the ground during init we will return them to their owners
                List <GameRelic> lostRelics = new List <GameRelic>();

                var relics = GameServer.Database.SelectAllObjects <DBRelic>();
                foreach (DBRelic datarelic in relics)
                {
                    if (datarelic.relicType < 0 || datarelic.relicType > 1 ||
                        datarelic.OriginalRealm < 1 || datarelic.OriginalRealm > 3)
                    {
                        log.Warn("DBRelic: Could not load " + datarelic.RelicID + ": Realm or Type missmatch.");
                        continue;
                    }

                    if (WorldMgr.GetRegion((ushort)datarelic.Region) == null)
                    {
                        log.Warn("DBRelic: Could not load " + datarelic.RelicID + ": Region missmatch.");
                        continue;
                    }
                    GameRelic relic = new GameRelic(datarelic);
                    m_relics.Add(datarelic.RelicID, relic);

                    relic.AddToWorld();
                    GameRelicPad pad = GetPadAtRelicLocation(relic);
                    if (pad != null)
                    {
                        if (relic.RelicType == pad.PadType)
                        {
                            relic.RelicPadTakesOver(pad, true);
                            log.Debug("DBRelic: " + relic.Name + " has been loaded and added to pad " + pad.Name + ".");
                        }
                    }
                    else
                    {
                        lostRelics.Add(relic);
                    }
                }

                foreach (GameRelic lostRelic in lostRelics)
                {
                    eRealm returnRealm = (eRealm)lostRelic.LastRealm;

                    if (returnRealm == eRealm.None)
                    {
                        returnRealm = lostRelic.OriginalRealm;
                    }

                    // ok, now we have a realm to return the relic too, lets find a pad

                    foreach (GameRelicPad pad in m_relicPads)
                    {
                        if (pad.MountedRelic == null && pad.Realm == returnRealm && pad.PadType == lostRelic.RelicType)
                        {
                            lostRelic.RelicPadTakesOver(pad, true);
                            log.Debug("Lost Relic: " + lostRelic.Name + " has returned to last pad: " + pad.Name + ".");
                        }
                    }
                }

                // Final cleanup.  If any relic is still unmounted then mount the damn thing to any empty pad

                foreach (GameRelic lostRelic in lostRelics)
                {
                    if (lostRelic.CurrentRelicPad == null)
                    {
                        foreach (GameRelicPad pad in m_relicPads)
                        {
                            if (pad.MountedRelic == null && pad.PadType == lostRelic.RelicType)
                            {
                                lostRelic.RelicPadTakesOver(pad, true);
                                log.Debug("Lost Relic: " + lostRelic.Name + " auto assigned to pad: " + pad.Name + ".");
                            }
                        }
                    }
                }
            }

            log.Debug(m_relicPads.Count + " relicpads" + ((m_relicPads.Count > 1) ? "s were" : " was") + " loaded.");
            log.Debug(m_relics.Count + " relic" + ((m_relics.Count > 1) ? "s were" : " was") + " loaded.");
            return(true);
        }
Exemplo n.º 21
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            /* First thing we do in here is to search for the NPCs inside
             * the world who comes from the certain Realm. If we find a the players,
             * this means we don't have to create a new one.
             *
             * NOTE: You can do anything you want in this method, you don't have
             * to search for NPC's ... you could create a custom item, place it
             * on the ground and if a player picks it up, he will get the quest!
             * Just examples, do anything you like and feel comfortable with :)
             */

            GameNPC[] npcs = WorldMgr.GetObjectsByName <GameNPC>("Farmer Asma", eRealm.Albion);
            if (npcs.Length == 0)
            {
                farmerAsma       = new GameNPC();
                farmerAsma.Model = 82;
                farmerAsma.Name  = "Farmer Asma";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + farmerAsma.Name + ", creating him ...");
                }

                farmerAsma.GuildName       = "Part of " + questTitle + " Quest";
                farmerAsma.Realm           = eRealm.Albion;
                farmerAsma.CurrentRegionID = 1;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 31);
                template.AddNPCEquipment(eInventorySlot.Cloak, 57);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 32);
                template.AddNPCEquipment(eInventorySlot.ArmsArmor, 33);
                farmerAsma.Inventory = template.CloseTemplate();
                farmerAsma.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                farmerAsma.Size    = 50;
                farmerAsma.Level   = 35;
                farmerAsma.X       = 563939;
                farmerAsma.Y       = 509234;
                farmerAsma.Z       = 2744;
                farmerAsma.Heading = 21;

                // You don't have to store the created mob in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    farmerAsma.SaveIntoDatabase();
                }

                farmerAsma.AddToWorld();
            }
            else
            {
                farmerAsma = npcs[0];
            }

            // item db check
            farmerAsmasMap = GameServer.Database.FindObjectByKey <ItemTemplate>("farmer_asma_map");
            if (farmerAsmasMap == null)
            {
                farmerAsmasMap      = new ItemTemplate();
                farmerAsmasMap.Name = "Farmer Asma's Map";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + farmerAsmasMap.Name + ", creating it ...");
                }

                farmerAsmasMap.Level  = 0;
                farmerAsmasMap.Weight = 1;
                farmerAsmasMap.Model  = 499;

                farmerAsmasMap.Object_Type = (int)eObjectType.GenericItem;
                farmerAsmasMap.Id_nb       = "farmer_asma_map";
                farmerAsmasMap.Price       = 0;
                farmerAsmasMap.IsPickable  = false;
                farmerAsmasMap.IsDropable  = false;

                farmerAsmasMap.Quality       = 100;
                farmerAsmasMap.Condition     = 1000;
                farmerAsmasMap.MaxCondition  = 1000;
                farmerAsmasMap.Durability    = 1000;
                farmerAsmasMap.MaxDurability = 1000;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                GameServer.Database.AddObject(farmerAsmasMap);
            }

            firstFieldArea = WorldMgr.GetRegion(firstField.RegionID).AddArea(new Area.Circle("First Vacant Field", firstField.X, firstField.Y, 0, 1450));
            firstFieldArea.RegisterPlayerEnter(new DOLEventHandler(PlayerEnterFirstFieldArea));

            secondFieldArea = WorldMgr.GetRegion(secondField.RegionID).AddArea(new Area.Circle("Second Vacant Field", secondField.X, secondField.Y, 0, 1100));
            secondFieldArea.RegisterPlayerEnter(new DOLEventHandler(PlayerEnterSecondFieldArea));

            thirdFieldArea = WorldMgr.GetRegion(thirdField.RegionID).AddArea(new Area.Circle("Third Vacant Field", thirdField.X, thirdField.Y, 0, 1100));
            thirdFieldArea.RegisterPlayerEnter(new DOLEventHandler(PlayerEnterThirdFieldArea));

            /* Now we add some hooks to the npc we found.
             * Actually, we want to know when a player interacts with him.
             * So, we hook the right-click (interact) and the whisper method
             * of npc and set the callback method to the "TalkToXXX"
             * method. This means, the "TalkToXXX" method is called whenever
             * a player right clicks on him or when he whispers to him.
             */

            GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
            GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));

            GameEventMgr.AddHandler(GamePlayerEvent.GameEntered, new DOLEventHandler(PlayerEnterWorld));

            GameEventMgr.AddHandler(farmerAsma, GameObjectEvent.Interact, new DOLEventHandler(TalkToFarmerAsma));
            GameEventMgr.AddHandler(farmerAsma, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToFarmerAsma));

            /* Now we bring to Ydenia the possibility to give this quest to players */
            farmerAsma.AddQuestToGive(typeof(GreenerPastures));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Exemplo n.º 22
0
        public override void SendCharacterOverview(eRealm realm)
        {
            if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm)
            {
                throw new Exception($"CharacterOverview requested for unknown realm {realm}");
            }

            int firstSlot = (byte)realm * 100;

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview1126)))
            {
                pak.WriteIntLowEndian(0);                 // 0x01 & 0x02 are flags
                pak.WriteIntLowEndian(0);
                pak.WriteIntLowEndian(0);
                pak.WriteIntLowEndian(0);
                if (m_gameClient.Account.Characters == null || m_gameClient.Account.Characters.Length == 0)
                {
                    SendTCP(pak);
                    return;
                }

                Dictionary <int, DOLCharacters> charsBySlot = new Dictionary <int, DOLCharacters>();
                foreach (DOLCharacters c in m_gameClient.Account.Characters)
                {
                    try
                    {
                        charsBySlot.Add(c.AccountSlot, c);
                    }
                    catch (Exception ex)
                    {
                        log.Error($"SendCharacterOverview - Duplicate char in slot? Slot: {c.AccountSlot}, Account: {c.AccountName}", ex);
                    }
                }
                var itemsByOwnerID = new Dictionary <string, Dictionary <eInventorySlot, InventoryItem> >();

                if (charsBySlot.Any())
                {
                    var allItems = GameServer.Database.SelectObjects <InventoryItem>(
                        "`OwnerID` = @OwnerID AND `SlotPosition` >= @MinEquipable AND `SlotPosition` <= @MaxEquipable",
                        charsBySlot.Select(kv => new[] {
                        new QueryParameter("@OwnerID", kv.Value.ObjectId),
                        new QueryParameter("@MinEquipable", (int)eInventorySlot.MinEquipable),
                        new QueryParameter("@MaxEquipable", (int)eInventorySlot.MaxEquipable)
                    })
                        )
                                   .SelectMany(objs => objs);

                    foreach (InventoryItem item in allItems)
                    {
                        try
                        {
                            if (!itemsByOwnerID.ContainsKey(item.OwnerID))
                            {
                                itemsByOwnerID.Add(item.OwnerID, new Dictionary <eInventorySlot, InventoryItem>());
                            }

                            itemsByOwnerID[item.OwnerID].Add((eInventorySlot)item.SlotPosition, item);
                        }
                        catch (Exception ex)
                        {
                            log.Error($"SendCharacterOverview - Duplicate item on character? OwnerID: {item.OwnerID}, SlotPosition: {item.SlotPosition}, Account: {m_gameClient.Account.Name}", ex);
                        }
                    }
                }

                // send each characters
                for (int i = firstSlot; i < (firstSlot + 10); i++)
                {
                    DOLCharacters c = null;
                    if (!charsBySlot.TryGetValue(i, out c))
                    {
                        pak.WriteByte(0);
                        continue;
                    }

                    Dictionary <eInventorySlot, InventoryItem> charItems = null;

                    if (!itemsByOwnerID.TryGetValue(c.ObjectId, out charItems))
                    {
                        charItems = new Dictionary <eInventorySlot, InventoryItem>();
                    }

                    byte extensionTorso  = 0;
                    byte extensionGloves = 0;
                    byte extensionBoots  = 0;

                    InventoryItem item = null;
                    if (charItems.TryGetValue(eInventorySlot.TorsoArmor, out item))
                    {
                        extensionTorso = item.Extension;
                    }
                    if (charItems.TryGetValue(eInventorySlot.HandsArmor, out item))
                    {
                        extensionGloves = item.Extension;
                    }
                    if (charItems.TryGetValue(eInventorySlot.FeetArmor, out item))
                    {
                        extensionBoots = item.Extension;
                    }

                    string locationDescription = string.Empty;
                    Region region = WorldMgr.GetRegion((ushort)c.Region);
                    if (region != null)
                    {
                        locationDescription = m_gameClient.GetTranslatedSpotDescription(region, c.Xpos, c.Ypos, c.Zpos);
                    }
                    string classname = "";
                    if (c.Class != 0)
                    {
                        classname = ((eCharacterClass)c.Class).ToString();
                    }
                    string racename = m_gameClient.RaceToTranslatedName(c.Race, c.Gender);

                    charItems.TryGetValue(eInventorySlot.RightHandWeapon, out InventoryItem rightHandWeapon);
                    charItems.TryGetValue(eInventorySlot.LeftHandWeapon, out InventoryItem leftHandWeapon);
                    charItems.TryGetValue(eInventorySlot.TwoHandWeapon, out InventoryItem twoHandWeapon);
                    charItems.TryGetValue(eInventorySlot.DistanceWeapon, out InventoryItem distanceWeapon);
                    charItems.TryGetValue(eInventorySlot.HeadArmor, out InventoryItem helmet);
                    charItems.TryGetValue(eInventorySlot.HandsArmor, out InventoryItem gloves);
                    charItems.TryGetValue(eInventorySlot.FeetArmor, out InventoryItem boots);
                    charItems.TryGetValue(eInventorySlot.TorsoArmor, out InventoryItem torso);
                    charItems.TryGetValue(eInventorySlot.Cloak, out InventoryItem cloak);
                    charItems.TryGetValue(eInventorySlot.LegsArmor, out InventoryItem legs);
                    charItems.TryGetValue(eInventorySlot.ArmsArmor, out InventoryItem arms);

                    ushort rightHandColor = 0;
                    if (rightHandWeapon != null)
                    {
                        rightHandColor = (ushort)(rightHandWeapon.Emblem != 0 ? rightHandWeapon.Emblem : rightHandWeapon.Color);
                    }
                    ushort helmetColor = 0;
                    if (helmet != null)
                    {
                        helmetColor = (ushort)(helmet.Emblem != 0 ? helmet.Emblem : helmet.Color);
                    }
                    ushort glovesColor = 0;
                    if (gloves != null)
                    {
                        glovesColor = (ushort)(gloves.Emblem != 0 ? gloves.Emblem : gloves.Color);
                    }
                    ushort bootsColor = 0;
                    if (boots != null)
                    {
                        bootsColor = (ushort)(boots.Emblem != 0 ? boots.Emblem : boots.Color);
                    }
                    ushort leftHandWeaponColor = 0;
                    if (leftHandWeapon != null)
                    {
                        leftHandWeaponColor = (ushort)(leftHandWeapon.Emblem != 0 ? leftHandWeapon.Emblem : leftHandWeapon.Color);
                    }
                    ushort torsoColor = 0;
                    if (torso != null)
                    {
                        torsoColor = (ushort)(torso.Emblem != 0 ? torso.Emblem : torso.Color);
                    }
                    ushort cloakColor = 0;
                    if (cloak != null)
                    {
                        cloakColor = (ushort)(cloak.Emblem != 0 ? cloak.Emblem : cloak.Color);
                    }
                    ushort legsColor = 0;
                    if (legs != null)
                    {
                        legsColor = (ushort)(legs.Emblem != 0 ? legs.Emblem : legs.Color);
                    }
                    ushort armsColor = 0;
                    if (arms != null)
                    {
                        armsColor = (ushort)(arms.Emblem != 0 ? arms.Emblem : arms.Color);
                    }

                    pak.WriteByte((byte)c.Level);
                    pak.WritePascalStringIntLE(c.Name);
                    pak.WriteIntLowEndian(0x18);
                    pak.WriteByte(1);                     // always 1 ?
                    pak.WriteByte(c.EyeSize);             // seems to be : 0xF0 = eyes, 0x0F = nose
                    pak.WriteByte(c.LipSize);             // seems to be : 0xF0 = lips, 0xF = jaw
                    pak.WriteByte(c.EyeColor);            // seems to be : 0xF0 = eye color, 0x0F = skin tone
                    pak.WriteByte(c.HairColor);
                    pak.WriteByte(c.FaceType);            // seems to be : 0xF0 = face
                    pak.WriteByte(c.HairStyle);           // seems to be : 0xF0 = hair
                    pak.WriteByte((byte)((extensionBoots << 4) | extensionGloves));
                    pak.WriteByte((byte)((extensionTorso << 4) | (c.IsCloakHoodUp ? 0x1 : 0x0)));
                    pak.WriteByte(c.CustomisationStep);                     //1 = auto generate config, 2= config ended by player, 3= enable config to player
                    pak.WriteByte(c.MoodType);
                    pak.Fill(0x0, 13);
                    pak.WritePascalStringIntLE(locationDescription);
                    pak.WritePascalStringIntLE(classname);
                    pak.WritePascalStringIntLE(racename);
                    pak.WriteShortLowEndian((ushort)c.CurrentModel);

                    pak.WriteByte((byte)c.Region);
                    if (region == null || (int)m_gameClient.ClientType > region.Expansion)
                    {
                        pak.WriteByte(0x00);
                    }
                    else
                    {
                        pak.WriteByte((byte)(region.Expansion + 1));                         //0x04-Cata zone, 0x05 - DR zone
                    }
                    pak.WriteShortLowEndian((ushort)(helmet != null ? helmet.Model : 0));
                    pak.WriteShortLowEndian((ushort)(gloves != null ? gloves.Model : 0));
                    pak.WriteShortLowEndian((ushort)(boots != null ? boots.Model : 0));
                    pak.WriteShortLowEndian(rightHandColor);
                    pak.WriteShortLowEndian((ushort)(torso != null ? torso.Model : 0));
                    pak.WriteShortLowEndian((ushort)(cloak != null ? cloak.Model : 0));
                    pak.WriteShortLowEndian((ushort)(legs != null ? legs.Model : 0));
                    pak.WriteShortLowEndian((ushort)(arms != null ? arms.Model : 0));

                    pak.WriteShortLowEndian(helmetColor);
                    pak.WriteShortLowEndian(glovesColor);
                    pak.WriteShortLowEndian(bootsColor);
                    pak.WriteShortLowEndian(leftHandWeaponColor);
                    pak.WriteShortLowEndian(torsoColor);
                    pak.WriteShortLowEndian(cloakColor);
                    pak.WriteShortLowEndian(legsColor);
                    pak.WriteShortLowEndian(armsColor);

                    //weapon models
                    pak.WriteShortLowEndian((ushort)(rightHandWeapon != null ? rightHandWeapon.Model : 0));
                    pak.WriteShortLowEndian((ushort)(leftHandWeapon != null ? leftHandWeapon.Model : 0));
                    pak.WriteShortLowEndian((ushort)(twoHandWeapon != null ? twoHandWeapon.Model : 0));
                    pak.WriteShortLowEndian((ushort)(distanceWeapon != null ? distanceWeapon.Model : 0));

                    pak.WriteByte((byte)c.Strength);
                    pak.WriteByte((byte)c.Quickness);
                    pak.WriteByte((byte)c.Constitution);
                    pak.WriteByte((byte)c.Dexterity);
                    pak.WriteByte((byte)c.Intelligence);
                    pak.WriteByte((byte)c.Piety);
                    pak.WriteByte((byte)c.Empathy);                     // ?
                    pak.WriteByte((byte)c.Charisma);                    // ?

                    pak.WriteByte((byte)c.Class);
                    pak.WriteByte((byte)c.Realm);                     // ok?
                    pak.WriteByte((byte)((((c.Race & 0x10) << 2) + (c.Race & 0x0F)) | (c.Gender << 4)));
                    if (c.ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.TwoHanded)
                    {
                        pak.WriteByte(0x02);
                        pak.WriteByte(0x02);
                    }
                    else if (c.ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.Distance)
                    {
                        pak.WriteByte(0x03);
                        pak.WriteByte(0x03);
                    }
                    else
                    {
                        pak.WriteByte((byte)(rightHandWeapon != null ? 0x00 : 0xFF));
                        pak.WriteByte((byte)(leftHandWeapon != null ? 0x01 : 0xFF));
                    }
                    pak.WriteByte(0);                     // SI = 1, Classic = 0
                    pak.WriteByte((byte)c.Constitution);  // ok
                    pak.WriteByte(0);                     // unknown
                }

                SendTCP(pak);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// 1125 char overview
        /// </summary>
        public override void SendCharacterOverview(eRealm realm)
        {
            if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm)
            {
                throw new Exception("CharacterOverview requested for unknown realm " + realm);
            }

            int firstSlot = (byte)realm * 100;

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview)))
            {
                //pak.Fillstring(GameClient.Account.Name, 24);
                pak.Fill(0, 8);
                if (m_gameClient.Account.Characters == null)
                {
                    pak.Fill(0x0, 10);
                }
                else
                {
                    Dictionary <int, DOLCharacters> charsBySlot = new Dictionary <int, DOLCharacters>();
                    foreach (DOLCharacters c in m_gameClient.Account.Characters)
                    {
                        try
                        {
                            charsBySlot.Add(c.AccountSlot, c);
                        }
                        catch (Exception ex)
                        {
                            log.Error("SendCharacterOverview - Duplicate char in slot? Slot: " + c.AccountSlot + ", Account: " + c.AccountName, ex);
                        }
                    }
                    var itemsByOwnerID = new Dictionary <string, Dictionary <eInventorySlot, InventoryItem> >();

                    if (charsBySlot.Any())
                    {
                        var filterBySlotPosition = DB.Column(nameof(InventoryItem.SlotPosition)).IsGreaterOrEqualTo((int)eInventorySlot.MinEquipable)
                                                   .And(DB.Column(nameof(InventoryItem.SlotPosition)).IsLessOrEqualTo((int)eInventorySlot.MaxEquipable));
                        var allItems = DOLDB <InventoryItem> .SelectObjects(DB.Column(nameof(InventoryItem.OwnerID)).IsIn(charsBySlot.Values.Select(c => c.ObjectId)).And(filterBySlotPosition));

                        foreach (InventoryItem item in allItems)
                        {
                            try
                            {
                                if (!itemsByOwnerID.ContainsKey(item.OwnerID))
                                {
                                    itemsByOwnerID.Add(item.OwnerID, new Dictionary <eInventorySlot, InventoryItem>());
                                }

                                itemsByOwnerID[item.OwnerID].Add((eInventorySlot)item.SlotPosition, item);
                            }
                            catch (Exception ex)
                            {
                                log.Error("SendCharacterOverview - Duplicate item on character? OwnerID: " + item.OwnerID + ", SlotPosition: " + item.SlotPosition + ", Account: " + m_gameClient.Account.Name, ex);
                            }
                        }
                    }

                    for (int i = firstSlot; i < (firstSlot + 10); i++)
                    {
                        if (!charsBySlot.TryGetValue(i, out DOLCharacters c))
                        {
                            pak.WriteByte(0);
                        }
                        else
                        {
                            if (!itemsByOwnerID.TryGetValue(c.ObjectId, out Dictionary <eInventorySlot, InventoryItem> charItems))
                            {
                                charItems = new Dictionary <eInventorySlot, InventoryItem>();
                            }

                            byte extensionTorso  = 0;
                            byte extensionGloves = 0;
                            byte extensionBoots  = 0;


                            if (charItems.TryGetValue(eInventorySlot.TorsoArmor, out InventoryItem item))
                            {
                                extensionTorso = item.Extension;
                            }

                            if (charItems.TryGetValue(eInventorySlot.HandsArmor, out item))
                            {
                                extensionGloves = item.Extension;
                            }

                            if (charItems.TryGetValue(eInventorySlot.FeetArmor, out item))
                            {
                                extensionBoots = item.Extension;
                            }

                            pak.WriteByte((byte)c.Level);                // moved
                            pak.WritePascalStringIntLE(c.Name, 0x18);
                            pak.WriteByte(0x18);                         // no idea
                            pak.WriteInt(1);                             // no idea
                            pak.WriteByte((byte)c.EyeSize);
                            pak.WriteByte((byte)c.LipSize);
                            pak.WriteByte((byte)c.EyeColor);
                            pak.WriteByte((byte)c.HairColor);
                            pak.WriteByte((byte)c.FaceType);
                            pak.WriteByte((byte)c.HairStyle);
                            pak.WriteByte((byte)((extensionBoots << 4) | extensionGloves));
                            pak.WriteByte((byte)((extensionTorso << 4) | (c.IsCloakHoodUp ? 0x1 : 0x0)));
                            pak.WriteByte((byte)c.CustomisationStep);      //1 = auto generate config, 2= config ended by player, 3= enable config to player
                            pak.WriteByte((byte)c.MoodType);
                            pak.Fill(0x0, 13);                             //0 string

                            string locationDescription = string.Empty;
                            Region region = WorldMgr.GetRegion((ushort)c.Region);
                            if (region != null)
                            {
                                locationDescription = region.GetTranslatedSpotDescription(m_gameClient, c.Xpos, c.Ypos, c.Zpos);
                            }
                            if (locationDescription.Length > 23)                             // location name over 23 chars has to be truncated eg. "The Great Pyramid of Stygia"
                            {
                                locationDescription = (locationDescription.Substring(0, 20)) + "...";
                            }
                            pak.WritePascalStringIntLE(locationDescription, 0x18);

                            string classname = "";
                            if (c.Class != 0)
                            {
                                classname = ((eCharacterClass)c.Class).ToString();
                            }
                            pak.WritePascalStringIntLE(classname, 0x18);

                            string racename = m_gameClient.RaceToTranslatedName(c.Race, c.Gender);

                            pak.WritePascalStringIntLE(racename, 0x18);
                            pak.WriteShortLowEndian((ushort)c.CurrentModel);                             // moved
                            // something here
                            pak.WriteByte((byte)c.Region);

                            if (region == null || (int)m_gameClient.ClientType > region.Expansion)
                            {
                                pak.WriteByte(0x00);
                            }
                            else
                            {
                                pak.WriteByte((byte)(region.Expansion + 1));                                 //0x04-Cata zone, 0x05 - DR zone
                            }

                            charItems.TryGetValue(eInventorySlot.RightHandWeapon, out InventoryItem rightHandWeapon);
                            charItems.TryGetValue(eInventorySlot.LeftHandWeapon, out InventoryItem leftHandWeapon);
                            charItems.TryGetValue(eInventorySlot.TwoHandWeapon, out InventoryItem twoHandWeapon);
                            charItems.TryGetValue(eInventorySlot.DistanceWeapon, out InventoryItem distanceWeapon);
                            charItems.TryGetValue(eInventorySlot.HeadArmor, out InventoryItem helmet);
                            charItems.TryGetValue(eInventorySlot.HandsArmor, out InventoryItem gloves);
                            charItems.TryGetValue(eInventorySlot.FeetArmor, out InventoryItem boots);
                            charItems.TryGetValue(eInventorySlot.TorsoArmor, out InventoryItem torso);
                            charItems.TryGetValue(eInventorySlot.Cloak, out InventoryItem cloak);
                            charItems.TryGetValue(eInventorySlot.LegsArmor, out InventoryItem legs);
                            charItems.TryGetValue(eInventorySlot.ArmsArmor, out InventoryItem arms);

                            pak.WriteShortLowEndian((ushort)(helmet != null ? helmet.Model : 0));
                            pak.WriteShortLowEndian((ushort)(gloves != null ? gloves.Model : 0));
                            pak.WriteShortLowEndian((ushort)(boots != null ? boots.Model : 0));

                            ushort rightHandColor = 0;
                            if (rightHandWeapon != null)
                            {
                                rightHandColor = (ushort)(rightHandWeapon.Emblem != 0 ? rightHandWeapon.Emblem : rightHandWeapon.Color);
                            }
                            pak.WriteShortLowEndian(rightHandColor);

                            pak.WriteShortLowEndian((ushort)(torso != null ? torso.Model : 0));
                            pak.WriteShortLowEndian((ushort)(cloak != null ? cloak.Model : 0));
                            pak.WriteShortLowEndian((ushort)(legs != null ? legs.Model : 0));
                            pak.WriteShortLowEndian((ushort)(arms != null ? arms.Model : 0));

                            ushort helmetColor = 0;
                            if (helmet != null)
                            {
                                helmetColor = (ushort)(helmet.Emblem != 0 ? helmet.Emblem : helmet.Color);
                            }
                            pak.WriteShortLowEndian(helmetColor);

                            ushort glovesColor = 0;
                            if (gloves != null)
                            {
                                glovesColor = (ushort)(gloves.Emblem != 0 ? gloves.Emblem : gloves.Color);
                            }
                            pak.WriteShortLowEndian(glovesColor);

                            ushort bootsColor = 0;
                            if (boots != null)
                            {
                                bootsColor = (ushort)(boots.Emblem != 0 ? boots.Emblem : boots.Color);
                            }
                            pak.WriteShortLowEndian(bootsColor);

                            ushort leftHandWeaponColor = 0;
                            if (leftHandWeapon != null)
                            {
                                leftHandWeaponColor = (ushort)(leftHandWeapon.Emblem != 0 ? leftHandWeapon.Emblem : leftHandWeapon.Color);
                            }
                            pak.WriteShortLowEndian(leftHandWeaponColor);

                            ushort torsoColor = 0;
                            if (torso != null)
                            {
                                torsoColor = (ushort)(torso.Emblem != 0 ? torso.Emblem : torso.Color);
                            }
                            pak.WriteShortLowEndian(torsoColor);

                            ushort cloakColor = 0;
                            if (cloak != null)
                            {
                                cloakColor = (ushort)(cloak.Emblem != 0 ? cloak.Emblem : cloak.Color);
                            }
                            pak.WriteShortLowEndian(cloakColor);

                            ushort legsColor = 0;
                            if (legs != null)
                            {
                                legsColor = (ushort)(legs.Emblem != 0 ? legs.Emblem : legs.Color);
                            }
                            pak.WriteShortLowEndian(legsColor);

                            ushort armsColor = 0;
                            if (arms != null)
                            {
                                armsColor = (ushort)(arms.Emblem != 0 ? arms.Emblem : arms.Color);
                            }
                            pak.WriteShortLowEndian(armsColor);

                            //weapon models

                            pak.WriteShortLowEndian((ushort)(rightHandWeapon != null ? rightHandWeapon.Model : 0));
                            pak.WriteShortLowEndian((ushort)(leftHandWeapon != null ? leftHandWeapon.Model : 0));
                            pak.WriteShortLowEndian((ushort)(twoHandWeapon != null ? twoHandWeapon.Model : 0));
                            pak.WriteShortLowEndian((ushort)(distanceWeapon != null ? distanceWeapon.Model : 0));

                            //pak.WriteInt(0x0); // Internal database ID
                            pak.WriteByte((byte)c.Strength);
                            pak.WriteByte((byte)c.Dexterity);
                            pak.WriteByte((byte)c.Constitution);
                            pak.WriteByte((byte)c.Quickness);
                            pak.WriteByte((byte)c.Intelligence);
                            pak.WriteByte((byte)c.Piety);
                            pak.WriteByte((byte)c.Empathy);
                            pak.WriteByte((byte)c.Charisma);
                            pak.WriteByte((byte)c.Class);                             // moved
                            pak.WriteByte((byte)c.Realm);                             // moved
                            pak.WriteByte((byte)((((c.Race & 0x10) << 2) + (c.Race & 0x0F)) | (c.Gender << 4)));

                            if (c.ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.TwoHanded)
                            {
                                pak.WriteByte(0x02);
                                pak.WriteByte(0x02);
                            }
                            else if (c.ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.Distance)
                            {
                                pak.WriteByte(0x03);
                                pak.WriteByte(0x03);
                            }
                            else
                            {
                                byte righthand = 0xFF;
                                byte lefthand  = 0xFF;

                                if (rightHandWeapon != null)
                                {
                                    righthand = 0x00;
                                }

                                if (leftHandWeapon != null)
                                {
                                    lefthand = 0x01;
                                }

                                pak.WriteByte(righthand);
                                pak.WriteByte(lefthand);
                            }

                            if (region == null || region.Expansion != 1)
                            {
                                pak.WriteByte(0x00);
                            }
                            else
                            {
                                pak.WriteByte(0x01);                                 //0x01=char in SI zone, classic client can't "play"
                            }

                            pak.WriteByte((byte)c.Constitution);
                        }
                    }
                }

                SendTCP(pak);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// load all keeps from the DB
        /// </summary>
        /// <returns></returns>
        public virtual bool Load()
        {
            // first check the regions we manage
            foreach (Region r in WorldMgr.Regions.Values)
            {
                if (r.IsFrontier)
                {
                    m_frontierRegionsList.Add(r.ID);
                }
            }

            // default to NF if no frontier regions found
            if (m_frontierRegionsList.Count == 0)
            {
                m_frontierRegionsList.Add(DEFAULT_FRONTIERS_REGION);
            }

            ClothingMgr.LoadTemplates();

            //Dinberg - moved this here, battlegrounds must be loaded before keepcomponents are.
            LoadBattlegroundCaps();

            if (!ServerProperties.Properties.LOAD_KEEPS)
            {
                return(true);
            }

            lock (m_keepList.SyncRoot)
            {
                m_keepList.Clear();

                var keeps = GameServer.Database.SelectAllObjects <DBKeep>();
                foreach (DBKeep datakeep in keeps)
                {
                    Region keepRegion = WorldMgr.GetRegion(datakeep.Region);
                    if (keepRegion == null)
                    {
                        continue;
                    }

                    var currentKeepComponents = GameServer.Database.SelectObjects <DBKeepComponent>("`KeepID` = @KeepID", new QueryParameter("@KeepID", datakeep.KeepID));

                    AbstractGameKeep keep;
                    if ((datakeep.KeepID >> 8) != 0 || ((datakeep.KeepID & 0xFF) > 150))
                    {
                        keep = keepRegion.CreateGameKeepTower();
                    }
                    else
                    {
                        keep = keepRegion.CreateGameKeep();
                    }

                    keep.Load(datakeep);
                    RegisterKeep(datakeep.KeepID, keep);
                }

                // This adds owner keeps to towers / portal keeps
                foreach (AbstractGameKeep keep in m_keepList.Values)
                {
                    GameKeepTower tower = keep as GameKeepTower;
                    if (tower != null)
                    {
                        int      index     = tower.KeepID & 0xFF;
                        GameKeep ownerKeep = GetKeepByID(index) as GameKeep;
                        if (ownerKeep != null)
                        {
                            ownerKeep.AddTower(tower);
                        }
                        tower.Keep        = ownerKeep;
                        tower.OwnerKeepID = index;

                        if (tower.OwnerKeepID < 10)
                        {
                            log.WarnFormat("Tower.OwnerKeepID < 10 for KeepID {0}. Doors on this tower will not be targetable! ({0} & 0xFF < 10). Choose a different KeepID to correct this issue.", tower.KeepID);
                        }
                    }
                }
                if (ServerProperties.Properties.USE_NEW_KEEPS == 2)
                {
                    log.ErrorFormat("ServerProperty USE_NEW_KEEPS is actually set to 2 but it is no longer used. Loading as if he were 0 but please set to 0 or 1 !");
                }

                var keepcomponents = default(IList <DBKeepComponent>);

                if (ServerProperties.Properties.USE_NEW_KEEPS == 0 || ServerProperties.Properties.USE_NEW_KEEPS == 2)
                {
                    keepcomponents = GameServer.Database.SelectObjects <DBKeepComponent>("`Skin` < @Skin", new QueryParameter("@Skin", 20));
                }
                else if (ServerProperties.Properties.USE_NEW_KEEPS == 1)
                {
                    keepcomponents = GameServer.Database.SelectObjects <DBKeepComponent>("`Skin` > @Skin", new QueryParameter("@Skin", 20));
                }

                foreach (DBKeepComponent component in keepcomponents)
                {
                    AbstractGameKeep keep = GetKeepByID(component.KeepID);
                    if (keep == null)
                    {
                        //missingKeeps = true;
                        continue;
                    }

                    GameKeepComponent gamecomponent = keep.CurrentRegion.CreateGameKeepComponent();
                    gamecomponent.LoadFromDatabase(component, keep);
                    keep.KeepComponents.Add(gamecomponent);
                }

                /*if (missingKeeps && log.IsWarnEnabled)
                 * {
                 *      log.WarnFormat("Some keeps not found while loading components, possibly old/new keeptypes.");
                 * }*/

                if (m_keepList.Count != 0)
                {
                    foreach (AbstractGameKeep keep in m_keepList.Values)
                    {
                        if (keep.KeepComponents.Count != 0)
                        {
                            keep.KeepComponents.Sort();
                        }
                    }
                }
                LoadHookPoints();

                log.Info("Loaded " + m_keepList.Count + " keeps successfully");
            }

            if (ServerProperties.Properties.USE_KEEP_BALANCING)
            {
                UpdateBaseLevels();
            }

            if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
            {
                KeepBonusMgr.UpdateCounts();
            }

            return(true);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Send Game Static Item depending on last refresh time
        /// </summary>
        /// <param name="player"></param>
        /// <param name="nowTicks"></param>
        private static void UpdatePlayerItems(GamePlayer player, long nowTicks)
        {
            // Get All Static Item in Range
            var objs = player.GetItemsInRadius(WorldMgr.OBJ_UPDATE_DISTANCE)
                       .Cast <GameStaticItem>()
                       .Where(i => i != null && i.IsVisibleTo(player))
                       .ToArray();

            try
            {
                // Clean Cache
                foreach (var objEntry in player.Client.GameObjectUpdateArray)
                {
                    var        objKey = objEntry.Key;
                    GameObject obj    = WorldMgr.GetRegion(objKey.Item1).GetObject(objKey.Item2);

                    // We have a Static Item in cache that is not in vincinity
                    if (obj is GameStaticItem item && !objs.Contains(item) && (nowTicks - objEntry.Value) >= GetPlayerItemUpdateInterval)
                    {
                        long dummy;
                        player.Client.GameObjectUpdateArray.TryRemove(objKey, out dummy);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error($"Error while Cleaning Static Item cache for Player : {player.Name}, Exception : {e}");
                }
            }

            try
            {
                // Now Send remaining objects
                foreach (GameStaticItem lobj in objs)
                {
                    GameStaticItem staticObj = lobj;

                    // Get last update time
                    long lastUpdate;
                    if (player.Client.GameObjectUpdateArray.TryGetValue(new Tuple <ushort, ushort>(staticObj.CurrentRegionID, (ushort)staticObj.ObjectID), out lastUpdate))
                    {
                        // This Static Object Needs Update
                        if (nowTicks - lastUpdate >= GetPlayerItemUpdateInterval)
                        {
                            player.Client.Out.SendObjectCreate(staticObj);
                        }
                    }
                    else
                    {
                        // Not in cache, Object entering in range, sending update will add it to cache
                        player.Client.Out.SendObjectCreate(staticObj);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error($"Error while updating Static Item for Player : {player.Name}, Exception : {e}");
                }
            }
        }