Пример #1
0
        public override bool Start()
        {
            bool result = true;

            try
            {
                IsRunning = 0;
                Thread.CurrentThread.Priority = ThreadPriority.Normal;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);


                if (!this.StartScriptComponents())
                {
                    result = false;
                    GameServer.log.Error("初始化脚本失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化脚本成功!");

                if (!this.InitSocket(IPAddress.Parse(this.Config.GameIP), this.Config.GamePort))
                {
                    result = false;
                    GameServer.log.Error("初始化监听端口失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化监听端口成功!");

                if (!this.AllocatePacketBuffers())
                {
                    result = false;
                    GameServer.log.Error("分配数据包缓冲区失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("分配数据包缓冲区成功!");

                //LogMgr.Setup

                if (!WorldMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化世界场景失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化世界场景成功!");



                if (!FusionMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化熔炼失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化熔炼成功!");

                if (!AwardMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化奖励失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化奖励成功!");


                if (!MissionInfoMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化关卡失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化关卡成功!");

                if (!PveInfoMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化pve失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化pve成功!");



                if (!FightRateMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化战斗倍率失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化战斗倍率成功!");

                if (!ConsortiaLevelMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化公会等级失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化公会等级成功!");

                if (!StrengthenMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化强化失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化强化成功!");

                if (!ShopMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化商店失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化商店成功!");

                if (!BoxMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化时间宝箱失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化时间宝箱成功!");

                if (!QuestMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化任务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化任务成功!");

                if (!AchievementMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化成就失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化成就成功!");

                if (!AchievementMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化成就失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化成就成功!");

                if (!RoomMgr.Setup(this.Config.MaxRoomCount))
                {
                    result = false;
                    GameServer.log.Error("初始化房间管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化房间管理服务成功!");

                if (!GameMgr.Setup(1, 4))
                {
                    result = false;
                    GameServer.log.Error("初始化游戏管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化游戏管理服务成功!");

                if (!ConsortiaMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化公会失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化公会成功!");


                if (!Game.Server.Managers.RateMgr.Init(this.Config))
                {
                    result = false;
                    GameServer.log.Error("初始化经验倍率管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化经验倍率管理服务成功!");

                if (!MacroDropMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化宏观掉落失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化宏观掉落成功!");


                if (!BattleMgr.Setup(this.Config))
                {
                    result = false;
                    GameServer.log.Error("加载战斗管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("加载战斗管理服务成功!");

                if (!this.InitGlobalTimer())
                {
                    result = false;
                    GameServer.log.Error("初始化全局Timers失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化全局Timers成功!");

                if (!this.InitLoginServer())
                {
                    result = false;
                    GameServer.log.Error("登陆到中心服务器失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("登陆到中心服务器成功!");

                if (!MarryRoomMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化礼堂失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化礼堂成功!");

                if (!SpaRoomMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化温泉失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化温泉成功!");

                if (!ActiveMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化活动失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化活动成功!");
                if (!VIPMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化VIP失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化VIP成功!");
                if (!LevelMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化等级失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化等级成功!");

                /*  if (!WorldBossMgr.Init())
                 * {
                 *    result = false;
                 *    GameServer.log.Error("初始化世界Boss失败,请检查!");
                 *    return result;
                 * }
                 * GameServer.log.Info("初始化世界Boss成功!");
                 */
                RoomMgr.Start();
                GameMgr.Start();
                BattleMgr.Start();
                MacroDropMgr.Start();

                if (!base.Start())
                {
                    result = false;
                    GameServer.log.Error("启动基础服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("启动基础服务成功!");

                GameEventMgr.Notify(ScriptEvent.Loaded);
                GC.Collect(GC.MaxGeneration);
                //LogMgr.Setup(1, 1, 1);
                GameServer.log.Warn("游戏服务器启动成功!");
                IsRunning = 1;
            }
            catch (Exception e)
            {
                GameServer.log.Error("Failed to start the server", e);
                // throw e;
                result = false;
            }
            return(result);
        }
Пример #2
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(LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.ScriptLoaded.Text1"), eRealm.Albion);

            if (npcs.Length == 0)
            {
                MasterKless       = new GameNPC();
                MasterKless.Model = 64;
                MasterKless.Name  = LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.ScriptLoaded.Text1");
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + MasterKless.Name + ", creating him ...");
                }
                //k109: My preference, no guildname for quest NPCs.  Uncomment if you like that...
                //MasterKless.GuildName = "Part of " + questTitle + " Quest";
                MasterKless.Realm           = eRealm.Albion;
                MasterKless.CurrentRegionID = 1;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 1005);                  //Slot 25
                template.AddNPCEquipment(eInventorySlot.Cloak, 96);                         //Slot 26
                template.AddNPCEquipment(eInventorySlot.TwoHandWeapon, 1166);               //Slot 12
                MasterKless.Inventory = template.CloseTemplate();
                MasterKless.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                MasterKless.Size    = 51;
                MasterKless.Level   = 50;
                MasterKless.X       = 559370;
                MasterKless.Y       = 513587;
                MasterKless.Z       = 2428;
                MasterKless.Heading = 2685;

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

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

            #endregion

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

            GameEventMgr.AddHandler(MasterKless, GameLivingEvent.Interact, new DOLEventHandler(TalkToMasterKless));
            GameEventMgr.AddHandler(MasterKless, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToMasterKless));

            MasterKless.AddQuestToGive(typeof(WhenGoodBrowniesGoBad));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Пример #3
0
 /// <summary>
 /// Remove anything added in handlers
 /// </summary>
 protected virtual void RemoveHandlers()
 {
     GameEventMgr.RemoveAllHandlersForObject(m_pet);
 }
Пример #4
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

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Brice Yarley", eRealm.Albion);
            if (npcs.Length == 0)
            {
                briceYarley       = new GameNPC();
                briceYarley.Model = 10;
                briceYarley.Name  = "Brice Yarley";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + briceYarley.Name + ", creating him ...");
                }
                briceYarley.Realm           = eRealm.Albion;
                briceYarley.CurrentRegionID = 1;
                briceYarley.Size            = 51;
                briceYarley.Level           = 43;
                briceYarley.X            = 370236;
                briceYarley.Y            = 679755;
                briceYarley.Z            = 5558;
                briceYarley.Heading      = 2468;
                briceYarley.MaxSpeedBase = 191;

                //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)
                {
                    briceYarley.SaveIntoDatabase();
                }


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

            npcs = WorldMgr.GetNPCsByName("Patrick Yarley", eRealm.Albion);
            if (npcs.Length == 0)
            {
                patrickYarley       = new GameNPC();
                patrickYarley.Model = 9;
                patrickYarley.Name  = "Patrick Yarley";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + patrickYarley.Name + ", creating him ...");
                }
                patrickYarley.Realm           = eRealm.Albion;
                patrickYarley.CurrentRegionID = 1;
                patrickYarley.Size            = 51;
                patrickYarley.Level           = 43;
                patrickYarley.X            = 371752;
                patrickYarley.Y            = 680486;
                patrickYarley.Z            = 5595;
                patrickYarley.Heading      = 0;
                patrickYarley.MaxSpeedBase = 200;

                //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)
                {
                    patrickYarley.SaveIntoDatabase();
                }


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



            #endregion

            #region defineItems



            elderWood = GameServer.Database.FindObjectByKey <ItemTemplate>("elder_wood");
            if (elderWood == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Elder Wood, creating it ...");
                }
                elderWood             = new ItemTemplate();
                elderWood.Object_Type = 0;
                elderWood.Id_nb       = "elder_wood";
                elderWood.Name        = "Elder Wood";
                elderWood.Level       = 1;
                elderWood.Model       = 520;
                elderWood.IsDropable  = false;
                elderWood.IsPickable  = false;
                elderWood.Weight      = 5;
                GameServer.Database.AddObject(elderWood);
            }

            boogeyTeeth = GameServer.Database.FindObjectByKey <ItemTemplate>("boogey_teeth");
            if (boogeyTeeth == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Boogey Teeth, creating it ...");
                }
                boogeyTeeth             = new ItemTemplate();
                boogeyTeeth.Object_Type = 0;
                boogeyTeeth.Id_nb       = "boogey_teeth";
                boogeyTeeth.Name        = "Boogey Teeth";
                boogeyTeeth.Level       = 1;
                boogeyTeeth.Model       = 106;
                boogeyTeeth.IsDropable  = false;
                boogeyTeeth.IsPickable  = false;
                boogeyTeeth.Weight      = 4;
                GameServer.Database.AddObject(boogeyTeeth);
            }

            #endregion

            /* Now we add some hooks to the Sir Quait 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 Sir Quait 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(briceYarley, GameLivingEvent.Interact, new DOLEventHandler(TalkToBriceYarley));
            GameEventMgr.AddHandler(briceYarley, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToBriceYarley));

            GameEventMgr.AddHandler(patrickYarley, GameLivingEvent.Interact, new DOLEventHandler(TalkToPatrickYarley));
            GameEventMgr.AddHandler(patrickYarley, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToPatrickYarley));



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

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Пример #5
0
        /// <summary>
        /// When an applied effect expires.
        /// Duration spells only.
        /// </summary>
        /// <param name="effect">The expired effect</param>
        /// <param name="noMessages">true, when no messages should be sent to player and surrounding</param>
        /// <returns>immunity duration in milliseconds</returns>
        public override int OnEffectExpires(GameSpellEffect effect, bool noMessages)
        {
            base.OnEffectExpires(effect, noMessages);

            GamePlayer player = Caster as GamePlayer;
            GameNPC    npc    = effect.Owner as GameNPC;

            if (player != null && npc != null)
            {
                if (!noMessages) // no overwrite
                {
                    GameEventMgr.RemoveHandler(npc, GameLivingEvent.PetReleased, new DOLEventHandler(ReleaseEventHandler));

                    player.SetControlledBrain(null);
                    MessageToCaster("You lose control of " + npc.GetName(0, false) + "!", eChatType.CT_SpellExpires);

                    lock (npc.BrainSync)
                    {
                        npc.StopAttack();
                        npc.RemoveBrain(m_controlledBrain);
                        m_isBrainSet = false;


                        if (npc.Brain != null && npc.Brain is IOldAggressiveBrain)
                        {
                            ((IOldAggressiveBrain)npc.Brain).ClearAggroList();

                            if (Spell.Pulse != 0 && Caster.ObjectState == GameObject.eObjectState.Active && Caster.IsAlive)
                            {
                                ((IOldAggressiveBrain)npc.Brain).AddToAggroList(Caster, Caster.Level * 10);
                                npc.StartAttack(Caster);
                            }
                            else
                            {
                                npc.WalkToSpawn();
                            }
                        }
                    }

                    // remove NPC with new brain from all attackers aggro list
                    lock (npc.Attackers)
                        foreach (GameObject obj in npc.Attackers)
                        {
                            if (obj == null || !(obj is GameNPC))
                            {
                                continue;
                            }

                            if (((GameNPC)obj).Brain != null && ((GameNPC)obj).Brain is IOldAggressiveBrain)
                            {
                                ((IOldAggressiveBrain)((GameNPC)obj).Brain).RemoveFromAggroList(npc);
                            }
                        }

                    m_controlledBrain.ClearAggroList();
                    npc.StopFollowing();

                    npc.TempProperties.setProperty(GameNPC.CHARMED_TICK_PROP, npc.CurrentRegion.Time);


                    foreach (GamePlayer ply in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                    {
                        if (npc.IsAlive)
                        {
                            ply.Out.SendNPCCreate(npc);

                            if (npc.Inventory != null)
                            {
                                ply.Out.SendLivingEquipmentUpdate(npc);
                            }

                            ply.Out.SendObjectGuildID(npc, null);
                        }
                    }
                }
            }
            else
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn(string.Format("charm effect expired: Caster={0} effect.Owner={1}",
                                           (Caster == null ? "(null)" : Caster.GetType().ToString()),
                                           (effect.Owner == null ? "(null)" : effect.Owner.GetType().ToString())));
                }
            }

            return(0);
        }
Пример #6
0
 /// <summary>
 /// Registers the needed EventHandler for this Trigger
 /// </summary>
 /// <remarks>
 /// This method will be called multiple times, so use AddHandlerUnique to make
 /// sure only one handler is actually registered
 /// </remarks>
 public override void Register()
 {
     GameEventMgr.AddHandler(I, AreaEvent.PlayerLeave, NotifyHandler);
 }
Пример #7
0
 /// <summary>
 /// Called when this client has connected
 /// </summary>
 public override void OnConnect()
 {
     GameEventMgr.Notify(GameClientEvent.Connected, this);
 }
Пример #8
0
        public override void Stop()
        {
            GameEventMgr.RemoveHandler(owner, GameLivingEvent.AttackedByEnemy, new DOLEventHandler(OnAttack));

            base.Stop();
        }
Пример #9
0
 /// <summary>
 /// 统一注册消息/事件回调
 /// </summary>
 protected virtual void RegisterHander()
 {
     msgHanderDic = null;
     GameEventMgr.GetInstance().RegisterHandler(this, EventType.ServerMsg);
 }
Пример #10
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("Roben Fraomar", eRealm.Albion);

            if (npcs.Length == 0)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Roben , creating it ...");
                }
                Roben                 = new GameNPC();
                Roben.Model           = 36;
                Roben.Name            = "Roben Fraomar";
                Roben.GuildName       = "";
                Roben.Realm           = eRealm.Albion;
                Roben.CurrentRegionID = 1;
                Roben.Size            = 52;
                Roben.Level           = 50;
                Roben.X               = 408557;
                Roben.Y               = 651675;
                Roben.Z               = 5200;
                Roben.Heading         = 3049;
                Roben.AddToWorld();

                if (SAVE_INTO_DATABASE)
                {
                    Roben.SaveIntoDatabase();
                }
            }
            else
            {
                Roben = npcs[0];
            }
            // end npc

            npcs = WorldMgr.GetNPCsByName("Sister Blythe", eRealm.None);
            if (npcs.Length == 0)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Blythe , creating it ...");
                }
                Blythe                 = new GameNPC();
                Blythe.Model           = 67;
                Blythe.Name            = "Sister Blythe";
                Blythe.GuildName       = "";
                Blythe.Realm           = eRealm.None;
                Blythe.CurrentRegionID = 1;
                Blythe.Size            = 50;
                Blythe.Level           = 69;
                Blythe.X               = 322231;
                Blythe.Y               = 671546;
                Blythe.Z               = 2762;
                Blythe.Heading         = 1683;
                Blythe.AddToWorld();

                if (SAVE_INTO_DATABASE)
                {
                    Blythe.SaveIntoDatabase();
                }
            }
            else
            {
                Blythe = npcs[0];
            }
            // end npc

            #endregion

            #region defineItems

            statue_of_arawn = GameServer.Database.FindObjectByKey <ItemTemplate>("statue_of_arawn");
            if (statue_of_arawn == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Statue of Arawn, creating it ...");
                }
                statue_of_arawn             = new ItemTemplate();
                statue_of_arawn.Id_nb       = "statue_of_arawn";
                statue_of_arawn.Name        = "Statue of Arawn";
                statue_of_arawn.Level       = 8;
                statue_of_arawn.Item_Type   = 29;
                statue_of_arawn.Model       = 593;
                statue_of_arawn.IsDropable  = false;
                statue_of_arawn.IsPickable  = false;
                statue_of_arawn.DPS_AF      = 0;
                statue_of_arawn.SPD_ABS     = 0;
                statue_of_arawn.Object_Type = 41;
                statue_of_arawn.Hand        = 0;
                statue_of_arawn.Type_Damage = 0;
                statue_of_arawn.Quality     = 100;
                statue_of_arawn.Weight      = 12;
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(statue_of_arawn);
                }
            }
// end item
            ItemTemplate i = null;
            ClericEpicBoots = GameServer.Database.FindObjectByKey <ItemTemplate>("ClericEpicBoots");
            if (ClericEpicBoots == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Clerics Epic Boots , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "ClericEpicBoots";
                i.Name          = "Boots of Defiant Soul";
                i.Level         = 50;
                i.Item_Type     = 23;
                i.Model         = 717;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 27;
                i.Object_Type   = 35;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 13;
                i.Bonus1Type = (int)eStat.CON;

                i.Bonus2     = 13;
                i.Bonus2Type = (int)eStat.DEX;

                i.Bonus3     = 13;
                i.Bonus3Type = (int)eStat.QUI;

                i.Bonus4     = 8;
                i.Bonus4Type = (int)eResist.Spirit;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }
                ClericEpicBoots = i;
            }
//end item
            //of the Defiant Soul  Coif
            ClericEpicHelm = GameServer.Database.FindObjectByKey <ItemTemplate>("ClericEpicHelm");
            if (ClericEpicHelm == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Clerics Epic Helm , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "ClericEpicHelm";
                i.Name          = "Coif of Defiant Soul";
                i.Level         = 50;
                i.Item_Type     = 21;
                i.Model         = 1290;         //NEED TO WORK ON..
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 27;
                i.Object_Type   = 35;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 4;
                i.Bonus1Type = (int)eProperty.Focus_Enchantments;

                i.Bonus2     = 12;
                i.Bonus2Type = (int)eStat.CON;

                i.Bonus3     = 19;
                i.Bonus3Type = (int)eStat.PIE;

                i.Bonus4     = 8;
                i.Bonus4Type = (int)eResist.Energy;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                ClericEpicHelm = i;
            }
//end item
            //of the Defiant Soul  Gloves
            ClericEpicGloves = GameServer.Database.FindObjectByKey <ItemTemplate>("ClericEpicGloves");
            if (ClericEpicGloves == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Clerics Epic Gloves , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "ClericEpicGloves";
                i.Name          = "Gauntlets of Defiant Soul";
                i.Level         = 50;
                i.Item_Type     = 22;
                i.Model         = 716;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 27;
                i.Object_Type   = 35;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 4;
                i.Bonus1Type = (int)eProperty.Skill_Smiting;

                i.Bonus2     = 22;
                i.Bonus2Type = (int)eStat.PIE;

                i.Bonus3     = 8;
                i.Bonus3Type = (int)eResist.Crush;

                i.Bonus4     = 8;
                i.Bonus4Type = (int)eResist.Matter;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                ClericEpicGloves = i;
            }
            //of the Defiant Soul  Hauberk
            ClericEpicVest = GameServer.Database.FindObjectByKey <ItemTemplate>("ClericEpicVest");
            if (ClericEpicVest == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Clerics Epic Vest , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "ClericEpicVest";
                i.Name          = "Habergeon of Defiant Soul";
                i.Level         = 50;
                i.Item_Type     = 25;
                i.Model         = 713;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 27;
                i.Object_Type   = 35;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 4;
                i.Bonus1Type = (int)eResist.Crush;

                i.Bonus2     = 4;
                i.Bonus2Type = (int)eResist.Spirit;

                i.Bonus3     = 12;
                i.Bonus3Type = (int)eProperty.PowerRegenerationRate;

                i.Bonus4     = 27;
                i.Bonus4Type = (int)eProperty.MaxHealth;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }
                ClericEpicVest = i;
            }
            //of the Defiant Soul  Legs
            ClericEpicLegs = GameServer.Database.FindObjectByKey <ItemTemplate>("ClericEpicLegs");
            if (ClericEpicLegs == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Clerics Epic Legs , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "ClericEpicLegs";
                i.Name          = "Chaussess of Defiant Soul";
                i.Level         = 50;
                i.Item_Type     = 27;
                i.Model         = 714;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 27;
                i.Object_Type   = 35;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 4;
                i.Bonus1Type = (int)eProperty.Skill_Rejuvenation;

                i.Bonus2     = 22;
                i.Bonus2Type = (int)eStat.CON;

                i.Bonus3     = 8;
                i.Bonus3Type = (int)eResist.Slash;

                i.Bonus4     = 8;
                i.Bonus4Type = (int)eResist.Cold;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                ClericEpicLegs = i;
            }
            //of the Defiant Soul  Sleeves
            ClericEpicArms = GameServer.Database.FindObjectByKey <ItemTemplate>("ClericEpicArms");
            if (ClericEpicArms == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Cleric Epic Arms , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "ClericEpicArms";
                i.Name          = "Sleeves of Defiant Soul";
                i.Level         = 50;
                i.Item_Type     = 28;
                i.Model         = 715;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 27;
                i.Object_Type   = 35;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 16;
                i.Bonus1Type = (int)eStat.STR;

                i.Bonus2     = 18;
                i.Bonus2Type = (int)eStat.PIE;

                i.Bonus3     = 8;
                i.Bonus3Type = (int)eResist.Thrust;

                i.Bonus4     = 8;
                i.Bonus4Type = (int)eResist.Heat;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                ClericEpicArms = i;
            }

            PaladinEpicBoots = GameServer.Database.FindObjectByKey <ItemTemplate>("PaladinEpicBoots");
            if (PaladinEpicBoots == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Paladin Epic Boots , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "PaladinEpicBoots";
                i.Name          = "Sabaton of the Iron Will";
                i.Level         = 50;
                i.Item_Type     = 23;
                i.Model         = 697;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 34;
                i.Object_Type   = 36;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 18;
                i.Bonus1Type = (int)eStat.STR;

                i.Bonus2     = 19;
                i.Bonus2Type = (int)eStat.QUI;

                i.Bonus3     = 6;
                i.Bonus3Type = (int)eResist.Slash;

                i.Bonus4     = 6;
                i.Bonus4Type = (int)eResist.Energy;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                PaladinEpicBoots = i;
            }
//end item
            //of the Iron Will Coif
            PaladinEpicHelm = GameServer.Database.FindObjectByKey <ItemTemplate>("PaladinEpicHelm");
            if (PaladinEpicHelm == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Paladin Epic Helm , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "PaladinEpicHelm";
                i.Name          = "Hounskull of the Iron Will";
                i.Level         = 50;
                i.Item_Type     = 21;
                i.Model         = 1290;         //NEED TO WORK ON..
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 34;
                i.Object_Type   = 36;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 18;
                i.Bonus1Type = (int)eStat.CON;

                i.Bonus2     = 19;
                i.Bonus2Type = (int)eStat.DEX;

                i.Bonus3     = 6;
                i.Bonus3Type = (int)eResist.Crush;

                i.Bonus4     = 6;
                i.Bonus4Type = (int)eResist.Matter;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                PaladinEpicHelm = i;
            }
//end item
            //of the Iron Will Gloves
            PaladinEpicGloves = GameServer.Database.FindObjectByKey <ItemTemplate>("PaladinEpicGloves");
            if (PaladinEpicGloves == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Paladin Epic Gloves , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "PaladinEpicGloves";
                i.Name          = "Gauntlets of the Iron Will";
                i.Level         = 50;
                i.Item_Type     = 22;
                i.Model         = 696;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 34;
                i.Object_Type   = 36;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 19;
                i.Bonus1Type = (int)eStat.STR;

                i.Bonus2     = 18;
                i.Bonus2Type = (int)eStat.QUI;

                i.Bonus3     = 6;
                i.Bonus3Type = (int)eResist.Crush;

                i.Bonus4     = 6;
                i.Bonus4Type = (int)eResist.Heat;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                PaladinEpicGloves = i;
            }
            //of the Iron Will Hauberk
            PaladinEpicVest = GameServer.Database.FindObjectByKey <ItemTemplate>("PaladinEpicVest");
            if (PaladinEpicVest == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Paladin Epic Vest , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "PaladinEpicVest";
                i.Name          = "Curiass of the Iron Will";
                i.Level         = 50;
                i.Item_Type     = 25;
                i.Model         = 693;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 34;
                i.Object_Type   = 36;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 15;
                i.Bonus1Type = (int)eStat.STR;

                i.Bonus2     = 6;
                i.Bonus2Type = (int)eResist.Body;

                i.Bonus3     = 6;
                i.Bonus3Type = (int)eResist.Spirit;

                i.Bonus4     = 24;
                i.Bonus4Type = (int)eProperty.MaxHealth;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                PaladinEpicVest = i;
            }
            //of the Iron Will Legs
            PaladinEpicLegs = GameServer.Database.FindObjectByKey <ItemTemplate>("PaladinEpicLegs");
            if (PaladinEpicLegs == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Paladin Epic Legs , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "PaladinEpicLegs";
                i.Name          = "Greaves of the Iron Will";
                i.Level         = 50;
                i.Item_Type     = 27;
                i.Model         = 694;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 34;
                i.Object_Type   = 36;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 22;
                i.Bonus1Type = (int)eStat.CON;

                i.Bonus2     = 15;
                i.Bonus2Type = (int)eStat.DEX;

                i.Bonus3     = 6;
                i.Bonus3Type = (int)eResist.Crush;

                i.Bonus4     = 6;
                i.Bonus4Type = (int)eResist.Cold;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                PaladinEpicLegs = i;
            }
            //of the Iron Will Sleeves
            PaladinEpicArms = GameServer.Database.FindObjectByKey <ItemTemplate>("PaladinEpicArms");
            if (PaladinEpicArms == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Paladin Epic Arms , creating it ...");
                }
                i               = new ItemTemplate();
                i.Id_nb         = "PaladinEpicArms";
                i.Name          = "Spaulders of the Iron Will";
                i.Level         = 50;
                i.Item_Type     = 28;
                i.Model         = 695;
                i.IsDropable    = true;
                i.IsPickable    = true;
                i.DPS_AF        = 100;
                i.SPD_ABS       = 34;
                i.Object_Type   = 36;
                i.Quality       = 100;
                i.Weight        = 22;
                i.Bonus         = 35;
                i.MaxCondition  = 50000;
                i.MaxDurability = 50000;
                i.Condition     = 50000;
                i.Durability    = 50000;

                i.Bonus1     = 19;
                i.Bonus1Type = (int)eStat.CON;

                i.Bonus2     = 15;
                i.Bonus2Type = (int)eStat.DEX;

                i.Bonus3     = 9;
                i.Bonus3Type = (int)eStat.QUI;

                i.Bonus4     = 6;
                i.Bonus4Type = (int)eResist.Spirit;

                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(i);
                }

                PaladinEpicArms = i;
            }

            #endregion

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

            GameEventMgr.AddHandler(Roben, GameObjectEvent.Interact, new DOLEventHandler(TalkToRoben));
            GameEventMgr.AddHandler(Roben, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToRoben));

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

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Пример #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 ...");
            }

            /* 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

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Hugh Gallen", eRealm.Albion);

            /* Whops, if the npcs array length is 0 then no npc exists in
             * this users Mob Database, so we simply create one ;-)
             * else we take the existing one. And if more than one exist, we take
             * the first ...
             */
            if (npcs.Length == 0)
            {
                hughGallen       = new GameNPC();
                hughGallen.Model = 40;
                hughGallen.Name  = "Hugh Gallen";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + hughGallen.Name + ", creating him ...");
                }
                hughGallen.GuildName       = "Part of " + questTitle + " Quest";
                hughGallen.Realm           = eRealm.Albion;
                hughGallen.CurrentRegionID = 1;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.HandsArmor, 39);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 40);
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 36);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 37);
                template.AddNPCEquipment(eInventorySlot.ArmsArmor, 38);
                hughGallen.Inventory = template.CloseTemplate();
                hughGallen.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                hughGallen.Size    = 49;
                hughGallen.Level   = 38;
                hughGallen.X       = 574640;
                hughGallen.Y       = 531109;
                hughGallen.Z       = 2896;
                hughGallen.Heading = 2275;

                //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)
                {
                    hughGallen.SaveIntoDatabase();
                }

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

            #endregion

            #region defineItems

            // item db check
            beltOfAnimation = GameServer.Database.FindObjectByKey <ItemTemplate>("belt_of_animation");
            if (beltOfAnimation == null)
            {
                beltOfAnimation      = new ItemTemplate();
                beltOfAnimation.Name = "Belt of Animation";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + beltOfAnimation.Name + ", creating it ...");
                }

                beltOfAnimation.Level  = 5;
                beltOfAnimation.Weight = 3;
                beltOfAnimation.Model  = 597;

                beltOfAnimation.Object_Type = (int)eObjectType.Magical;
                beltOfAnimation.Item_Type   = (int)eEquipmentItems.WAIST;
                beltOfAnimation.Id_nb       = "belt_of_animation";
                beltOfAnimation.Price       = 0;
                beltOfAnimation.IsPickable  = true;
                beltOfAnimation.IsDropable  = false;                // can't be sold to merchand

                beltOfAnimation.Bonus1     = 6;
                beltOfAnimation.Bonus1Type = (int)eProperty.MaxHealth;

                beltOfAnimation.Quality       = 100;
                beltOfAnimation.Condition     = 1000;
                beltOfAnimation.MaxCondition  = 1000;
                beltOfAnimation.Durability    = 1000;
                beltOfAnimation.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(beltOfAnimation);
            }

            #endregion


            /* 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(hughGallen, GameLivingEvent.Interact, new DOLEventHandler(TalkToHughGallen));
            GameEventMgr.AddHandler(hughGallen, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToHughGallen));

            /* Now we bring to Yetta Fletcher the possibility to give this quest to players */
            hughGallen.AddQuestToGive(typeof(ClericMulgrut));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Пример #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 ...");
            }

            /* 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>("Laridia the Minstrel", eRealm.Albion);

            /* Whops, if the npcs array length is 0 then no npc exists in
             * this users Mob Database, so we simply create one ;-)
             * else we take the existing one. And if more than one exist, we take
             * the first ...
             */
            if (npcs.Length == 0)
            {
                laridiaTheMinstrel       = new GameNPC();
                laridiaTheMinstrel.Model = 38;
                laridiaTheMinstrel.Name  = "Laridia the Minstrel";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + laridiaTheMinstrel.Name + ", creating him ...");
                }

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

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.HandsArmor, 137, 9);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 138, 9);
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 134, 9);
                template.AddNPCEquipment(eInventorySlot.Cloak, 96, 72);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 140, 43);
                template.AddNPCEquipment(eInventorySlot.ArmsArmor, 141, 43);
                laridiaTheMinstrel.Inventory = template.CloseTemplate();
                laridiaTheMinstrel.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                laridiaTheMinstrel.Size    = 49;
                laridiaTheMinstrel.Level   = 25;
                laridiaTheMinstrel.X       = 562280;
                laridiaTheMinstrel.Y       = 512243;
                laridiaTheMinstrel.Z       = 2448;
                laridiaTheMinstrel.Heading = 3049;

                // 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)
                {
                    laridiaTheMinstrel.SaveIntoDatabase();
                }

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

            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];
            }

            /* 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(laridiaTheMinstrel, GameLivingEvent.Interact, new DOLEventHandler(TalkToLaridiaTheMinstrel));
            GameEventMgr.AddHandler(laridiaTheMinstrel, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToLaridiaTheMinstrel));

            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 */
            laridiaTheMinstrel.AddQuestToGive(typeof(AgainstTheGrain));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Пример #13
0
        /// <summary>
        /// reset the realm when the lord have been killed
        /// </summary>
        /// <param name="realm"></param>
        public virtual void Reset(eRealm realm)
        {
            LastAttackedByEnemyTick = 0;
            StartCombatTick         = 0;

            Realm = realm;

            PlayerMgr.BroadcastCapture(this);

            Level = (byte)ServerProperties.Properties.STARTING_KEEP_LEVEL;

            //if a guild holds the keep, we release it
            if (Guild != null)
            {
                Release();
            }
            //we repair all keep components, but not if it is a tower and is raised
            foreach (GameKeepComponent component in this.KeepComponents)
            {
                if (!component.IsRaized)
                {
                    component.Repair(component.MaxHealth - component.Health);
                }
                foreach (GameKeepHookPoint hp in component.KeepHookPoints.Values)
                {
                    if (hp.Object != null)
                    {
                        hp.Object.Die(null);
                    }
                }
            }
            //change realm
            foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegion.ID))
            {
                client.Out.SendKeepComponentUpdate(this, false);
            }
            //we reset all doors
            foreach (GameKeepDoor door in Doors.Values)
            {
                door.Reset(realm);
            }

            //we make sure all players are not in the air
            ResetPlayersOfKeep();

            //we reset the guards
            foreach (GameKeepGuard guard in Guards.Values)
            {
                if (guard is GuardLord && guard.IsAlive)
                {
                    this.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { guard });
                }
                else if (guard is GuardLord == false)
                {
                    guard.Die(guard);
                }
            }

            //we reset the banners
            foreach (GameKeepBanner banner in Banners.Values)
            {
                banner.ChangeRealm();
            }

            //update guard level for every keep
            if (!IsPortalKeep && ServerProperties.Properties.USE_KEEP_BALANCING)
            {
                GameServer.KeepManager.UpdateBaseLevels();
            }

            //update the counts of keeps for the bonuses
            if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
            {
                KeepBonusMgr.UpdateCounts();
            }

            SaveIntoDatabase();

            GameEventMgr.Notify(KeepEvent.KeepTaken, new KeepEventArgs(this));
        }
Пример #14
0
 public static void OnScriptLoaded(DOLEvent e, object sender, EventArgs args)
 {
     InitStarterEquipment();
     GameEventMgr.AddHandler(DatabaseEvent.CharacterCreated, new DOLEventHandler(OnCharacterCreation));
 }
Пример #15
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 Albion 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 :)
             */

            dalikor = GetDalikor();

            generalLocations[0] = new GameLocation(generalNames[0], 100, 100, 40124, 44594, 4712, 216);
            generalLocations[1] = new GameLocation(generalNames[1], 100, 100, 46821, 40884, 4972, 21);
            generalLocations[2] = new GameLocation(generalNames[2], 100, 100, 56104, 43865, 5460, 48);

            GameNPC[] npcs = null;
            for (int i = 0; i < general.Length; i++)
            {
                npcs = WorldMgr.GetObjectsByName <GameNPC>(generalNames[i], eRealm.None);
                if (npcs.Length > 0)
                {
                    general[i] = npcs[0] as GameNPC;
                }
                else
                {
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + generalNames[i] + ", creating ...");
                    }

                    general[i] = new GameNPC();

                    general[i].Model = 678;

                    general[i].GuildName = "Part of " + questTitle + " Quest";
                    general[i].Name      = generalNames[i];
                    general[i].X         = generalLocations[i].X;
                    general[i].Y         = generalLocations[i].Y;
                    general[i].Z         = generalLocations[i].Z;
                    general[i].Heading   = generalLocations[i].Heading;

                    general[i].Realm           = eRealm.None;
                    general[i].CurrentRegionID = generalLocations[i].RegionID;
                    general[i].Size            = 49;
                    general[i].Level           = 2;

                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 80;
                    brain.AggroRange = 1000;
                    general[i].SetOwnBrain(brain);

                    if (SAVE_INTO_DATABASE)
                    {
                        general[i].SaveIntoDatabase();
                    }

                    general[i].AddToWorld();
                }
            }

            /*
             * TODO Model for Campfire doesn't work. Very Stange!
             */
            /*
             * // Add campfires to generals
             * for (int i = 0; i < generalLocations.Length; i++)
             * {
             *  GameStaticItem campfire = null;
             *
             *  IEnumerable items =  WorldMgr.GetItemsCloseToSpot(generalLocations[i].RegionID,generalLocations[i].X, generalLocations[i].Y, generalLocations[i].Z, 400,true);
             *  foreach (GameObject obj in items)
             *  {
             *      if (obj is GameStaticItem && obj.Name=="Camp Fire")
             *      {
             *          campfire= (GameStaticItem) obj;
             *          break;
             *      }
             *  }
             *
             *  if (campfire==null)
             *  {
             *      campfire = new GameStaticItem();
             *      campfire.Name="Camp Fire";
             *
             *      campfire.Model = 2593;
             *      campfire.Heading = generalLocations[i].Heading;
             *      campfire.X = generalLocations[i].X;
             *      campfire.Y = generalLocations[i].Y;
             *      campfire.Z = generalLocations[i].Z;
             *      campfire.CurrentRegionID = generalLocations[i].RegionID;
             *
             *      if (SAVE_INTO_DATABASE)
             *          campfire.SaveIntoDatabase();
             *
             *      campfire.AddToWorld();
             *
             *      DOLConsole.WriteLine("Camp Fire added"+generalNames[i]);
             *  }
             * }
             */

            askefruerWings = GameServer.Database.FindObjectByKey <ItemTemplate>("askefruer_wings");
            if (askefruerWings == null)
            {
                askefruerWings      = new ItemTemplate();
                askefruerWings.Name = "Wings of Askefruer";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + askefruerWings.Name + " , creating it ...");
                }

                askefruerWings.Weight = 2;
                askefruerWings.Model  = 551;

                askefruerWings.Object_Type = (int)eObjectType.GenericItem;

                askefruerWings.Id_nb      = "askefruer_wings";
                askefruerWings.IsPickable = true;
                askefruerWings.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
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(askefruerWings);
                }
            }

            dustyOldMap = GameServer.Database.FindObjectByKey <ItemTemplate>("dusty_old_map");
            if (dustyOldMap == null)
            {
                dustyOldMap      = new ItemTemplate();
                dustyOldMap.Name = "Dusty Old Map";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + dustyOldMap.Name + " , creating it ...");
                }

                dustyOldMap.Weight = 10;
                dustyOldMap.Model  = 498;

                dustyOldMap.Object_Type = (int)eObjectType.GenericItem;

                dustyOldMap.Id_nb      = "dusty_old_map";
                dustyOldMap.IsPickable = true;
                dustyOldMap.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
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(dustyOldMap);
                }
            }

            // item db check
            recruitsArms = GameServer.Database.FindObjectByKey <ItemTemplate>("recruits_studded_arms_mid");
            if (recruitsArms == null)
            {
                recruitsArms      = new ItemTemplate();
                recruitsArms.Name = "Recruit's Studded Arms (Mid)";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + recruitsArms.Name + ", creating it ...");
                }

                recruitsArms.Level = 7;

                recruitsArms.Weight = 36;
                recruitsArms.Model  = 83;  // studded Boots

                recruitsArms.DPS_AF  = 10; // Armour
                recruitsArms.SPD_ABS = 19; // Absorption

                recruitsArms.Object_Type = (int)eObjectType.Studded;
                recruitsArms.Item_Type   = (int)eEquipmentItems.ARMS;
                recruitsArms.Id_nb       = "recruits_studded_arms_mid";
                recruitsArms.Price       = Money.GetMoney(0, 0, 0, 4, 0);
                recruitsArms.IsPickable  = true;
                recruitsArms.IsDropable  = true;
                recruitsArms.Color       = 36; // blue cloth

                recruitsArms.Bonus = 5;        // default bonus

                recruitsArms.Bonus1     = 4;
                recruitsArms.Bonus1Type = (int)eStat.QUI;

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

                recruitsArms.Quality       = 100;
                recruitsArms.Condition     = 1000;
                recruitsArms.MaxCondition  = 1000;
                recruitsArms.Durability    = 1000;
                recruitsArms.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
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(recruitsArms);
                }
            }

            recruitsSleeves = GameServer.Database.FindObjectByKey <ItemTemplate>("recruits_quilted_sleeves");
            if (recruitsSleeves == null)
            {
                recruitsSleeves      = new ItemTemplate();
                recruitsSleeves.Name = "Recruit's Quilted Sleeves";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + recruitsSleeves.Name + ", creating it ...");
                }

                recruitsSleeves.Level = 7;

                recruitsSleeves.Weight = 12;
                recruitsSleeves.Model  = 153;

                recruitsSleeves.DPS_AF  = 6; // Armour
                recruitsSleeves.SPD_ABS = 0; // Absorption

                recruitsSleeves.Object_Type = (int)eObjectType.Cloth;
                recruitsSleeves.Item_Type   = (int)eEquipmentItems.ARMS;
                recruitsSleeves.Id_nb       = "recruits_quilted_sleeves";
                recruitsSleeves.Price       = Money.GetMoney(0, 0, 0, 4, 0);
                recruitsSleeves.IsPickable  = true;
                recruitsSleeves.IsDropable  = true;
                recruitsSleeves.Color       = 27; // red cloth

                recruitsSleeves.Bonus = 5;        // default bonus

                recruitsSleeves.Bonus1     = 4;
                recruitsSleeves.Bonus1Type = (int)eStat.DEX;

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

                recruitsSleeves.Quality       = 100;
                recruitsSleeves.Condition     = 1000;
                recruitsSleeves.MaxCondition  = 1000;
                recruitsSleeves.Durability    = 1000;
                recruitsSleeves.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
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(recruitsSleeves);
                }
            }

            /* 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.
             */

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

            GameEventMgr.AddHandler(dalikor, GameLivingEvent.Interact, new DOLEventHandler(TalkToDalikor));
            GameEventMgr.AddHandler(dalikor, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToDalikor));

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

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

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Version >= GameClient.eClientVersion.Version1125 && client.MinorRev == "d") // 1125d support TODO this needs to be changed when a version greater than 1125d comes out
            {
                var charSelectRequest = new CharacterSelectRequestHandler1125d();
                charSelectRequest.HandlePacket(client, packet);
                return;
            }
            else if (client.Version >= GameClient.eClientVersion.Version1126)
            {
                var charSelectRequest = new CharacterSelectRequestHandler1126();
                charSelectRequest.HandlePacket(client, packet);
                return;
            }

            packet.Skip(4); // Skip the first 4 bytes
            packet.Skip(1);

            string charName = packet.ReadString(28);

            // TODO Character handling
            if (charName.Equals("noname"))
            {
                client.Out.SendSessionID();
            }
            else
            {
                // SH: Also load the player if client player is NOT null but their charnames differ!!!
                // only load player when on charscreen and player is not loaded yet
                // packet is sent on every region change (and twice after "play" was pressed)
                if (((client.Player == null && client.Account.Characters != null) || (client.Player != null && client.Player.Name.ToLower() != charName.ToLower())) && client.ClientState == GameClient.eClientState.CharScreen)
                {
                    bool charFound = false;
                    for (int i = 0; i < client.Account.Characters.Length; i++)
                    {
                        if (client.Account.Characters[i] != null &&
                            client.Account.Characters[i].Name == charName)
                        {
                            charFound = true;

                            // Notify Character Selection Event, last hope to fix any bad data before Loading.
                            GameEventMgr.Notify(DatabaseEvent.CharacterSelected, new CharacterEventArgs(client.Account.Characters[i], client));
                            client.LoadPlayer(i);
                            break;
                        }
                    }

                    if (charFound == false)
                    {
                        client.Player          = null;
                        client.ActiveCharIndex = -1;
                    }
                    else
                    {
                        // Log character play
                        AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterLogin, string.Empty, charName);
                    }
                }

                client.Out.SendSessionID();
            }
        }
Пример #17
0
 /// <summary>
 /// Unregisters the needed EventHandler for this Trigger
 /// </summary>
 /// <remarks>
 /// Don't remove handlers that will be used by other triggers etc.
 /// This is rather difficult since we don't know which events other triggers use.
 /// </remarks>
 public override void Unregister()
 {
     GameEventMgr.RemoveHandler(I, AreaEvent.PlayerLeave, NotifyHandler);
 }
Пример #18
0
        public static bool CheckForDeletedCharacter(string accountName, GameClient client, int slot)
        {
            int charSlot = slot;

            if (accountName.EndsWith("-S"))
            {
                charSlot = 100 + slot;
            }
            else if (accountName.EndsWith("-N"))
            {
                charSlot = 200 + slot;
            }
            else if (accountName.EndsWith("-H"))
            {
                charSlot = 300 + slot;
            }

            DOLCharacters[] allChars = client.Account.Characters;

            if (allChars != null)
            {
                foreach (DOLCharacters character in allChars.ToArray())
                {
                    if (character.AccountSlot == charSlot && client.ClientState == GameClient.eClientState.CharScreen)
                    {
                        if (Log.IsWarnEnabled)
                        {
                            Log.Warn($"DB Character Delete:  Account {accountName}, Character: {character.Name}, slot position: {character.AccountSlot}, client slot {slot}");
                        }

                        if (allChars.Length < client.ActiveCharIndex && client.ActiveCharIndex > -1 && allChars[client.ActiveCharIndex] == character)
                        {
                            client.ActiveCharIndex = -1;
                        }

                        GameEventMgr.Notify(DatabaseEvent.CharacterDeleted, null, new CharacterEventArgs(character, client));

                        if (Properties.BACKUP_DELETED_CHARACTERS)
                        {
                            var backupCharacter = new DOLCharactersBackup(character);
                            backupCharacter.CustomParams.ForEach(param => GameServer.Database.AddObject(param));
                            GameServer.Database.AddObject(backupCharacter);

                            if (Log.IsWarnEnabled)
                            {
                                Log.Warn($"DB Character {character.ObjectId} backed up to DOLCharactersBackup and no associated content deleted.");
                            }
                        }
                        else
                        {
                            // delete associated data
                            try
                            {
                                var objs = GameServer.Database.SelectObjects <InventoryItem>("`OwnerID` = @OwnerID", new QueryParameter("@OwnerID", character.ObjectId));
                                GameServer.Database.DeleteObject(objs);
                            }
                            catch (Exception e)
                            {
                                if (Log.IsErrorEnabled)
                                {
                                    Log.Error($"Error deleting char items, char OID={character.ObjectId}, Exception:{e}");
                                }
                            }

                            // delete quests
                            try
                            {
                                var objs = GameServer.Database.SelectObjects <DBQuest>("`Character_ID` = @Character_ID", new QueryParameter("@Character_ID", character.ObjectId));
                                GameServer.Database.DeleteObject(objs);
                            }
                            catch (Exception e)
                            {
                                if (Log.IsErrorEnabled)
                                {
                                    Log.Error($"Error deleting char quests, char OID={character.ObjectId}, Exception:{e}");
                                }
                            }

                            // delete ML steps
                            try
                            {
                                var objs = GameServer.Database.SelectObjects <DBCharacterXMasterLevel>("`Character_ID` = @Character_ID", new QueryParameter("@Character_ID", character.ObjectId));
                                GameServer.Database.DeleteObject(objs);
                            }
                            catch (Exception e)
                            {
                                if (Log.IsErrorEnabled)
                                {
                                    Log.Error($"Error deleting char ml steps, char OID={character.ObjectId}, Exception:{e}");
                                }
                            }

                            // delete gravestone if character has one
                            try
                            {
                                var objs = GameServer.Database.SelectObjects <DBGravestones>("`Gravestones_ID` = @Gravestones_ID", new QueryParameter("@Gravestones_ID", character.ObjectId));
                                GameServer.Database.DeleteObject(objs);
                            }
                            catch (Exception e)
                            {
                                if (Log.IsErrorEnabled)
                                {
                                    Log.ErrorFormat("No gravestone found for deleted character, char OID={0}, Exception:{1}", character.ObjectId, e);
                                }
                            }
                        }

                        string deletedChar = character.Name;

                        GameServer.Database.DeleteObject(character);
                        client.Account.Characters = null;
                        client.Player             = null;
                        GameServer.Database.FillObjectRelations(client.Account);

                        if (client.Account.Characters == null || client.Account.Characters.Length == 0)
                        {
                            if (Log.IsInfoEnabled)
                            {
                                Log.Info($"Account {client.Account.Name} has no more chars. Realm reset!");
                            }

                            // Client has no more characters, so the client can choose the realm again!
                            client.Account.Realm = 0;
                        }

                        GameServer.Database.SaveObject(client.Account);

                        // Log deletion
                        AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterDelete, string.Empty, deletedChar);

                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #19
0
 public override void OnEffectRestored(GameSpellEffect effect, int[] vars)
 {
     effect.Owner.TempProperties.setProperty(Damage_Reduction, (int)vars[1]);
     GameEventMgr.AddHandler(effect.Owner, GameLivingEvent.AttackedByEnemy, new DOLEventHandler(OnAttack));
 }
Пример #20
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>("Yetta Fletcher", eRealm.Albion);

            /* Whops, if the npcs array length is 0 then no npc exists in
             * this users Mob Database, so we simply create one ;-)
             * else we take the existing one. And if more than one exist, we take
             * the first ...
             */
            if (npcs.Length == 0)
            {
                yettaFletcher       = new GameNPC();
                yettaFletcher.Model = 82;
                yettaFletcher.Name  = "Yetta Fletcher";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + yettaFletcher.Name + ", creating him ...");
                }

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

                yettaFletcher.Size    = 53;
                yettaFletcher.Level   = 17;
                yettaFletcher.X       = 560072;
                yettaFletcher.Y       = 510125;
                yettaFletcher.Z       = 2473;
                yettaFletcher.Heading = 1956;

                // 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)
                {
                    yettaFletcher.SaveIntoDatabase();
                }

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

            // item db check
            bundleOfDecayedZombieLegs = GameServer.Database.FindObjectByKey <ItemTemplate>("bundle_of_decayed_zombie_legs");
            if (bundleOfDecayedZombieLegs == null)
            {
                bundleOfDecayedZombieLegs      = new ItemTemplate();
                bundleOfDecayedZombieLegs.Name = "Bundle of Decayed Zombie Legs";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + bundleOfDecayedZombieLegs.Name + ", creating it ...");
                }

                bundleOfDecayedZombieLegs.Level  = 0;
                bundleOfDecayedZombieLegs.Weight = 3;
                bundleOfDecayedZombieLegs.Model  = 497;

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

                bundleOfDecayedZombieLegs.Quality       = 100;
                bundleOfDecayedZombieLegs.Condition     = 1000;
                bundleOfDecayedZombieLegs.MaxCondition  = 1000;
                bundleOfDecayedZombieLegs.Durability    = 1000;
                bundleOfDecayedZombieLegs.MaxDurability = 1000;
                GameServer.Database.AddObject(bundleOfDecayedZombieLegs);
            }

            /* 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(yettaFletcher, GameLivingEvent.Interact, new DOLEventHandler(TalkToYettaFletcher));
            GameEventMgr.AddHandler(yettaFletcher, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToYettaFletcher));

            /* Now we bring to Yetta Fletcher the possibility to give this quest to players */
            yettaFletcher.AddQuestToGive(typeof(ArrowsForYettaFletcher));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Пример #21
0
        /// <summary>
        /// Quits a client from the world
        /// </summary>
        protected internal void Quit()
        {
            lock (this)
            {
                try
                {
                    eClientState oldClientState = ClientState;
                    if (m_sessionID != 0)
                    {
                        if (oldClientState == eClientState.Playing || oldClientState == eClientState.WorldEnter ||
                            oldClientState == eClientState.Linkdead)
                        {
                            try
                            {
                                if (Player != null)
                                {
                                    Player.Quit(true); // calls delete
                                }

                                // m_player.Delete(true);
                            }
                            catch (Exception e)
                            {
                                log.Error("player cleanup on client quit", e);
                            }
                        }

                        try
                        {
                            // Now free our objid and sessionid again
                            WorldMgr.RemoveClient(this); // calls RemoveSessionID -> player.Delete
                        }
                        catch (Exception e)
                        {
                            log.Error("client cleanup on quit", e);
                        }
                    }

                    ClientState = eClientState.Disconnected;
                    Player      = null;

                    GameEventMgr.Notify(GameClientEvent.Disconnected, this);

                    if (Account != null)
                    {
                        if (log.IsInfoEnabled)
                        {
                            if (m_udpEndpoint != null)
                            {
                                log.Info("(" + m_udpEndpoint.Address + ") " + Account.Name + " just disconnected!");
                            }
                            else
                            {
                                log.Info("(" + TcpEndpoint + ") " + Account.Name + " just disconnected!");
                            }
                        }

                        // log disconnect
                        AuditMgr.AddAuditEntry(this, AuditType.Account, AuditSubtype.AccountLogout, string.Empty, Account.Name);
                    }
                }
                catch (Exception e)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("Quit", e);
                    }
                }
            }
        }
Пример #22
0
 public static void OnScriptUnloaded(DOLEvent e, object sender, EventArgs args)
 {
     GameEventMgr.RemoveHandler(DatabaseEvent.CharacterCreated, new DOLEventHandler(CharacterCreation));
     GameEventMgr.RemoveHandler(DatabaseEvent.CharacterSelected, new DOLEventHandler(CharacterSelection));
 }
Пример #23
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("Sir Dorian", eRealm.Albion);

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

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.HandsArmor, 49);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 50);
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 46);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 47);
                template.AddNPCEquipment(eInventorySlot.ArmsArmor, 48);
                sirDorian.Inventory = template.CloseTemplate();
                sirDorian.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                sirDorian.Size    = 52;
                sirDorian.Level   = 40;
                sirDorian.X       = 560869;
                sirDorian.Y       = 511737;
                sirDorian.Z       = 2344;
                sirDorian.Heading = 2930;

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

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

            #endregion

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

            GameEventMgr.AddHandler(sirDorian, GameLivingEvent.Interact, new DOLEventHandler(TalkTosirDorian));
            GameEventMgr.AddHandler(sirDorian, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkTosirDorian));

            sirDorian.AddQuestToGive(typeof(DredgeUpAPledge));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Пример #24
0
 public override void ExpireMission()
 {
     base.ExpireMission();
     GameEventMgr.RemoveHandler(AreaEvent.PlayerEnter, new DOLEventHandler(Notify));
     GameEventMgr.RemoveHandler(KeepEvent.KeepTaken, new DOLEventHandler(Notify));
 }
Пример #25
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();

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Nob the Stableboy", eRealm.Albion);
            if (npcs.Length == 0)
            {
                nob       = new GameNPC();
                nob.Model = 9;
                nob.Name  = "Nob the Stableboy";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + nob.Name + ", creating him ...");
                }
                nob.GuildName       = "Part of " + questTitle + " Quest";
                nob.Realm           = eRealm.Albion;
                nob.CurrentRegionID = 1;

                nob.Size    = 45;
                nob.Level   = 4;
                nob.X       = 573019;
                nob.Y       = 504485;
                nob.Z       = 2199;
                nob.Heading = 10;

                //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)
                {
                    nob.SaveIntoDatabase();
                }

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

            npcs = (GameNPC[])WorldMgr.GetObjectsByName("Dragonfly Handler Colm", eRealm.Albion, typeof(GameStableMaster));
            if (npcs.Length == 0)
            {
                colm       = new GameStableMaster();
                colm.Model = 78;
                colm.Name  = "Dragonfly Handler Colm";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + colm.Name + ", creating ...");
                }
                colm.GuildName       = "Stable Master";
                colm.Realm           = eRealm.Albion;
                colm.CurrentRegionID = 1;
                colm.Size            = 51;
                colm.Level           = 50;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 81, 10);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 82, 10);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 84, 10);
                template.AddNPCEquipment(eInventorySlot.Cloak, 57, 32);
                colm.Inventory = template.CloseTemplate();

//				colm.AddNPCEquipment(Slot.TORSO, 81, 10, 0, 0);
//				colm.AddNPCEquipment(Slot.LEGS, 82, 10, 0, 0);
//				colm.AddNPCEquipment(Slot.FEET, 84, 10, 0, 0);
//				colm.AddNPCEquipment(Slot.CLOAK, 57, 32, 0, 0);

                colm.X            = 562775;
                colm.Y            = 512453;
                colm.Z            = 2438;
                colm.Heading      = 158;
                colm.MaxSpeedBase = 200;

                StandardMobBrain brain = new StandardMobBrain();
                brain.AggroLevel = 0;
                brain.AggroRange = 0;
                colm.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)
                {
                    colm.SaveIntoDatabase();
                }
                colm.AddToWorld();
            }
            else
            {
                colm = npcs[0] as GameStableMaster;
            }

            npcs = WorldMgr.GetNPCsByName("Haruld", eRealm.Albion);
            if (npcs.Length == 0 || !(npcs[0] is GameStableMaster))
            {
                haruld       = new GameStableMaster();
                haruld.Model = 9;
                haruld.Name  = "Haruld";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + haruld.Name + ", creating ...");
                }
                haruld.GuildName       = "Stable Master";
                haruld.Realm           = eRealm.Albion;
                haruld.CurrentRegionID = 1;
                haruld.Size            = 49;
                haruld.Level           = 4;

                haruld.X            = 572479;
                haruld.Y            = 504410;
                haruld.Z            = 2184;
                haruld.Heading      = 944;
                haruld.MaxSpeedBase = 100;

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

                haruld.EquipmentTemplateID = "11701337";

                //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)
                {
                    haruld.SaveIntoDatabase();
                }
                haruld.AddToWorld();
            }
            else
            {
                haruld = npcs[0] as GameStableMaster;
            }

            npcs = WorldMgr.GetNPCsByName("Fairy Dragonfly Handler", eRealm.None);
            if (npcs.Length == 0)
            {
                fairyDragonflyHandler      = new GameNPC();
                fairyDragonflyHandler.Name = "Fairy Dragonfly Handler";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + fairyDragonflyHandler.Name + ", creating ...");
                }
                fairyDragonflyHandler.X               = 575334;
                fairyDragonflyHandler.Y               = 506403;
                fairyDragonflyHandler.Z               = 2331;
                fairyDragonflyHandler.Heading         = 114;
                fairyDragonflyHandler.Model           = 603;
                fairyDragonflyHandler.GuildName       = "Part of " + questTitle + " Quest";
                fairyDragonflyHandler.Realm           = eRealm.None;
                fairyDragonflyHandler.CurrentRegionID = 1;
                fairyDragonflyHandler.Size            = 49;
                fairyDragonflyHandler.Level           = 3;

                // Leave at default values to be one the save side ...
                //fairyDragonflyHandler.AggroLevel = 80;
                //fairyDragonflyHandler.AggroRange = 1000;

                //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)
                {
                    fairyDragonflyHandler.SaveIntoDatabase();
                }

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

            #endregion

            #region defineItems

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

                dragonflyWhip.Weight = 15;
                dragonflyWhip.Model  = 859;

                dragonflyWhip.Object_Type = (int)eObjectType.GenericItem;

                dragonflyWhip.Id_nb      = "dragonfly_whip";
                dragonflyWhip.IsPickable = true;
                dragonflyWhip.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(dragonflyWhip);
            }

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

                recruitsVest.Weight = 60;
                recruitsVest.Model  = 81;                // studded vest

                recruitsVest.DPS_AF  = 12;               // Armour
                recruitsVest.SPD_ABS = 19;               // Absorption

                recruitsVest.Object_Type   = (int)eObjectType.Studded;
                recruitsVest.Item_Type     = (int)eEquipmentItems.TORSO;
                recruitsVest.Id_nb         = "recruits_studded_vest";
                recruitsVest.Price         = Money.GetMoney(0, 0, 0, 9, 0);
                recruitsVest.IsPickable    = true;
                recruitsVest.IsDropable    = true;
                recruitsVest.CanDropAsLoot = false;
                recruitsVest.Color         = 9;         // red leather

                recruitsVest.Bonus = 5;                 // default bonus

                recruitsVest.Bonus1     = 4;
                recruitsVest.Bonus1Type = (int)eStat.STR;

                recruitsVest.Bonus2     = 3;
                recruitsVest.Bonus2Type = (int)eStat.CON;

                recruitsVest.Quality       = 100;
                recruitsVest.Condition     = 1000;
                recruitsVest.MaxCondition  = 1000;
                recruitsVest.Durability    = 1000;
                recruitsVest.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(recruitsVest);
            }

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

                recruitsQuiltedVest.Weight = 20;
                recruitsQuiltedVest.Model  = 151;               // studded vest

                recruitsQuiltedVest.DPS_AF  = 6;                // Armour
                recruitsQuiltedVest.SPD_ABS = 0;                // Absorption

                recruitsQuiltedVest.Object_Type = (int)eObjectType.Cloth;
                recruitsQuiltedVest.Item_Type   = (int)eEquipmentItems.TORSO;
                recruitsQuiltedVest.Id_nb       = "recruits_quilted_vest";
                recruitsQuiltedVest.Price       = Money.GetMoney(0, 0, 0, 9, 0);
                recruitsQuiltedVest.IsPickable  = true;
                recruitsQuiltedVest.IsDropable  = true;
                recruitsQuiltedVest.Color       = 9;           // red leather

                recruitsQuiltedVest.Bonus = 5;                 // default bonus

                recruitsQuiltedVest.Bonus1     = 4;
                recruitsQuiltedVest.Bonus1Type = (int)eStat.INT;

                recruitsQuiltedVest.Bonus2     = 3;
                recruitsQuiltedVest.Bonus2Type = (int)eStat.DEX;

                recruitsQuiltedVest.Quality       = 100;
                recruitsQuiltedVest.Condition     = 1000;
                recruitsQuiltedVest.MaxCondition  = 1000;
                recruitsQuiltedVest.Durability    = 1000;
                recruitsQuiltedVest.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(recruitsQuiltedVest);
            }

            #endregion

            /* 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.Quit, new DOLEventHandler(PlayerLeftWorld));

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

            GameEventMgr.AddHandler(colm, GameLivingEvent.Interact, new DOLEventHandler(TalkToColm));
            GameEventMgr.AddHandler(colm, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToColm));

            GameEventMgr.AddHandler(nob, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToNob));

            GameEventMgr.AddHandler(haruld, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToHaruld));

            GameEventMgr.AddHandler(fairyDragonflyHandler, GameNPCEvent.OnAICallback, new DOLEventHandler(CheckNearFairyDragonflyHandler));

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

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
        private bool CreateCharacter(CreationCharacterData pdata, GameClient client, int accountSlot)
        {
            Account account = client.Account;
            var     ch      = new DOLCharacters();

            ch.AccountName = account.Name;
            ch.Name        = pdata.CharName;

            if (pdata.CustomMode == 0x01)
            {
                ch.EyeSize           = (byte)pdata.EyeSize;
                ch.LipSize           = (byte)pdata.LipSize;
                ch.EyeColor          = (byte)pdata.EyeColor;
                ch.HairColor         = (byte)pdata.HairColor;
                ch.FaceType          = (byte)pdata.FaceType;
                ch.HairStyle         = (byte)pdata.HairStyle;
                ch.MoodType          = (byte)pdata.MoodType;
                ch.CustomisationStep = 2;                 // disable config button

                if (log.IsDebugEnabled)
                {
                    log.Debug("Disable Config Button");
                }
            }

            ch.Level = 1;
            // Set Realm and Class
            ch.Realm = pdata.Realm;
            ch.Class = pdata.Class;

            // Set Account Slot, Gender
            ch.AccountSlot = accountSlot + ch.Realm * 100;
            ch.Gender      = pdata.Gender;

            // Set Race
            ch.Race = pdata.Race;

            ch.CreationModel = pdata.CreationModel;
            ch.CurrentModel  = ch.CreationModel;
            ch.Region        = pdata.Region;

            ch.Strength     = pdata.Strength;
            ch.Dexterity    = pdata.Dexterity;
            ch.Constitution = pdata.Constitution;
            ch.Quickness    = pdata.Quickness;
            ch.Intelligence = pdata.Intelligence;
            ch.Piety        = pdata.Piety;
            ch.Empathy      = pdata.Empathy;
            ch.Charisma     = pdata.Charisma;

            // defaults
            ch.CreationDate = DateTime.Now;

            ch.Endurance     = 100;
            ch.MaxEndurance  = 100;
            ch.Concentration = 100;
            ch.MaxSpeed      = GamePlayer.PLAYER_BASE_SPEED;

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Creation {0} character, class:{1}, realm:{2}", client.Version, ch.Class, ch.Realm);
            }

            // Is class disabled ?
            int           occurences       = 0;
            List <string> disabled_classes = Properties.DISABLED_CLASSES.SplitCSV(true);

            occurences = (from j in disabled_classes
                          where j == ch.Class.ToString()
                          select j).Count();

            if (occurences > 0 && (ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Client {0} tried to create a disabled classe: {1}", client.Account.Name, (eCharacterClass)ch.Class);
                }

                return(true);
            }

            // check if race disabled
            List <string> disabled_races = Properties.DISABLED_RACES.SplitCSV(true);

            occurences = (from j in disabled_races
                          where j == ch.Race.ToString()
                          select j).Count();

            if (occurences > 0 && (ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Client {0} tried to create a disabled race: {1}", client.Account.Name, (eRace)ch.Race);
                }

                return(true);
            }


            // If sending invalid Class ID
            if (!Enum.IsDefined(typeof(eCharacterClass), (eCharacterClass)ch.Class))
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("{0} tried to create a character with wrong class ID: {1}, realm:{2}", client.Account.Name, ch.Class, ch.Realm);
                }

                if (ServerProperties.Properties.BAN_HACKERS)
                {
                    client.BanAccount(string.Format("Autoban character create class: id:{0} realm:{1} name:{2} account:{3}", ch.Class, ch.Realm, ch.Name, account.Name));
                    client.Disconnect();
                    return(false);
                }
                return(true);
            }

            // check if client tried to create invalid char
            if (!IsCharacterValid(ch))
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("{0} tried to create invalid character:\nchar name={1}, gender={2}, race={3}, realm={4}, class={5}, region={6}" +
                                   "\nstr={7}, con={8}, dex={9}, qui={10}, int={11}, pie={12}, emp={13}, chr={14}", ch.AccountName, ch.Name, ch.Gender,
                                   ch.Race, ch.Realm, ch.Class, ch.Region, ch.Strength, ch.Constitution, ch.Dexterity, ch.Quickness, ch.Intelligence, ch.Piety, ch.Empathy, ch.Charisma);
                }
                return(true);
            }

            //Save the character in the database
            GameServer.Database.AddObject(ch);

            // Fire the character creation event
            // This is Where Most Creation Script should take over to update any data they would like !
            GameEventMgr.Notify(DatabaseEvent.CharacterCreated, null, new CharacterEventArgs(ch, client));

            //write changes
            GameServer.Database.SaveObject(ch);

            // Log creation
            AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.CharacterCreate, "", pdata.CharName);

            client.Account.Characters = null;

            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Character {0} created on Account {1}!", pdata.CharName, account);
            }

            // Reload Account Relations
            GameServer.Database.FillObjectRelations(client.Account);

            return(true);
        }
Пример #27
0
 protected virtual void AddHandlers()
 {
     GameEventMgr.AddHandler(m_pet, GameLivingEvent.PetReleased, new DOLEventHandler(OnNpcReleaseCommand));
 }
        public static bool CheckForDeletedCharacter(string accountName, GameClient client, int slot)
        {
            int charSlot = slot;

            if (accountName.EndsWith("-S"))
            {
                charSlot = 100 + slot;
            }
            else if (accountName.EndsWith("-N"))
            {
                charSlot = 200 + slot;
            }
            else if (accountName.EndsWith("-H"))
            {
                charSlot = 300 + slot;
            }

            DOLCharacters[] allChars = client.Account.Characters;

            if (allChars != null)
            {
                foreach (DOLCharacters character in allChars.ToArray())
                {
                    if (character.AccountSlot == charSlot && client.ClientState == GameClient.eClientState.CharScreen)
                    {
                        if (log.IsWarnEnabled)
                        {
                            log.WarnFormat("DB Character Delete:  Account {0}, Character: {1}, slot position: {2}, client slot {3}", accountName, character.Name, character.AccountSlot, slot);
                        }

                        var characterRealm = (eRealm)character.Realm;

                        if (allChars.Length < client.ActiveCharIndex && client.ActiveCharIndex > -1 && allChars[client.ActiveCharIndex] == character)
                        {
                            client.ActiveCharIndex = -1;
                        }


                        GameEventMgr.Notify(DatabaseEvent.CharacterDeleted, null, new CharacterEventArgs(character, client));

                        if (Properties.BACKUP_DELETED_CHARACTERS)
                        {
                            var backupCharacter = new DOLCharactersBackup(character);
                            GameServer.Database.AddObject(backupCharacter);

                            if (log.IsWarnEnabled)
                            {
                                log.WarnFormat("DB Character {0} backed up to DOLCharactersBackup and no associated content deleted.", character.ObjectId);
                            }
                        }
                        else
                        {
                            // delete associated data

                            try
                            {
                                var objs = GameServer.Database.SelectObjects <InventoryItem>(string.Format("OwnerID = '{0}'", GameServer.Database.Escape(character.ObjectId)));
                                foreach (InventoryItem item in objs)
                                {
                                    GameServer.Database.DeleteObject(item);
                                }
                            }
                            catch (Exception e)
                            {
                                if (log.IsErrorEnabled)
                                {
                                    log.ErrorFormat("Error deleting char items, char OID={0}, Exception:{1}", character.ObjectId, e);
                                }
                            }

                            // delete quests
                            try
                            {
                                var objs = GameServer.Database.SelectObjects <DBQuest>(string.Format("Character_ID = '{0}'", GameServer.Database.Escape(character.ObjectId)));
                                foreach (DBQuest quest in objs)
                                {
                                    GameServer.Database.DeleteObject(quest);
                                }
                            }
                            catch (Exception e)
                            {
                                if (log.IsErrorEnabled)
                                {
                                    log.ErrorFormat("Error deleting char quests, char OID={0}, Exception:{1}", character.ObjectId, e);
                                }
                            }

                            // delete ML steps
                            try
                            {
                                var objs = GameServer.Database.SelectObjects <DBCharacterXMasterLevel>(string.Format("Character_ID = '{0}'", GameServer.Database.Escape(character.ObjectId)));
                                foreach (DBCharacterXMasterLevel mlstep in objs)
                                {
                                    GameServer.Database.DeleteObject(mlstep);
                                }
                            }
                            catch (Exception e)
                            {
                                if (log.IsErrorEnabled)
                                {
                                    log.ErrorFormat("Error deleting char ml steps, char OID={0}, Exception:{1}", character.ObjectId, e);
                                }
                            }
                        }

                        string deletedChar = character.Name;

                        GameServer.Database.DeleteObject(character);
                        client.Account.Characters = null;
                        client.Player             = null;
                        GameServer.Database.FillObjectRelations(client.Account);

                        if (client.Account.Characters == null || client.Account.Characters.Length == 0)
                        {
                            if (log.IsInfoEnabled)
                            {
                                log.InfoFormat("Account {0} has no more chars. Realm reset!", client.Account.Name);
                            }

                            //Client has no more characters, so the client can choose the realm again!
                            client.Account.Realm = 0;
                        }

                        GameServer.Database.SaveObject(client.Account);

                        // Log deletion
                        AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterDelete, "", deletedChar);

                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #29
0
        /// <summary>
        /// Unregisters the needed EventHandler for this Trigger
        /// </summary>
        /// <remarks>
        /// Don't remove handlers that will be used by other triggers etc.
        /// This is rather difficult since we don't know which events other triggers use.
        /// </remarks>
        public override void Unregister()
        {
            GameEventMgr.RemoveHandler(I, GameLivingEvent.WhisperReceive, NotifyHandler);

            // GameEventMgr.RemoveHandler(I, GameObjectEvent.Interact, NotifyHandler);
        }
Пример #30
0
 public override void OnDirectEffect(GameLiving target, double effectiveness)
 {
     base.OnDirectEffect(target, effectiveness);
     GameEventMgr.AddHandler(Caster, GamePlayerEvent.Quit, OnPlayerLeft);
 }