Demon Queen Quest for Albion

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Demon Queen Quest for Albion

Postby Celdron » Thu Apr 30, 2015 10:32 pm

Here is my new created Quest [The Demon Queen], at the Moment for Albion.

Source are: http://camelot.allakhazam.com/quests.html?cquest=3709
Code: Select all
/* * DAWN OF LIGHT - The first free open source DAoC server emulator * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ /* *Author : Elcotek - Quest The Demon Queen *Source : http://camelot.allakhazam.com/quests.html?cquest=3709 *Date : 25 april 2015 *Quest Name : The Demon Queen (level 50) *Quest Realm : Albion *Quest Classes : All *Quest Version : beta v 0.1 *At the moment not 100% livelike but beter an nothing * *ToDo: * * Add correct Text * * before you can use this script: * * 1. you must create the item with ID_NB = Demonslayer_Medal_of_Honor and stats form here http://camelot.allakhazam.com/item.html?citem=31378 * 2. you must save your demon queen under npctemplate ID = 3005 at the moment but you can change id under: templateID1 = ID; * 3. you must save your Theof Barnswallow under npctemplate ID = 3007 at the moment but you can change id under: templateID2 = ID; * * I can export the item, but it dont work with the dol db my server db have another structure and tables */ using System; using System.Reflection; using DOL.Database; using DOL.AI.Brain; using DOL.Events; using DOL.GS.PacketHandler; using log4net; using DOL.Language; namespace DOL.GS.Quests.Albion { public class TheDemonQueenAlb : BaseQuest { /// <summary> /// Defines a logger for this class. /// </summary> private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); //Npc spawned? private static bool addDemonQueen1 = false; private static bool addTheofBarnswallow = false; protected const string questTitle = "The Demon Queen"; protected const int minimumLevel = 50; protected const int maximumLevel = 50; protected const int addQueenDespwanTime = 1800; //despawn Time in Sec protected const int addTheofBarnswallowDespwanTime = 600; //despawn Time in Sec protected const int templateID1 = 3005; //npcTemplate for the Demon Queen protected const int templateID2 = 3007; //npcTemplate ID for Entrance Spawn of Theof Barnswallow //NPCs private static GameNPC npcsTheofBarnswallow = null; // Start NPC Theof Barnswallow //Questitems private static ItemTemplate LilithsHead = null; //Lilith's Head //Rewards private static ItemTemplate DemonslayerMedalofHonor = null; //Demonslayer Medal of Honor // Constructors public TheDemonQueenAlb() : base() { InitializeQuest(null); } public TheDemonQueenAlb(GamePlayer questingPlayer) : this(questingPlayer, 1) { InitializeQuest(questingPlayer); } public TheDemonQueenAlb(GamePlayer questingPlayer, int step) : base(questingPlayer, step) { InitializeQuest(questingPlayer); } public TheDemonQueenAlb(GamePlayer questingPlayer, DBQuest dbQuest) : base(questingPlayer, dbQuest) { InitializeQuest(questingPlayer); } /// <summary> /// Perform any initialization actions needed when quest is created /// </summary> protected void InitializeQuest(GamePlayer player) { } [ScriptLoadedEvent] 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 NPC Declarations GameNPC[] npcs = WorldMgr.GetNPCsByName("Theof Barnswallow", eRealm.Albion); if (npcs.Length == 0) { npcsTheofBarnswallow = new GameNPC(); npcsTheofBarnswallow.Model = 10; npcsTheofBarnswallow.Name = "Theof Barnswallow"; if (log.IsWarnEnabled) log.Warn("Could not find Theof Barnswallow, creating it ..."); npcsTheofBarnswallow.GuildName = "The Demon Queen Quest"; npcsTheofBarnswallow.Realm = eRealm.Albion; npcsTheofBarnswallow.CurrentRegionID = 10; npcsTheofBarnswallow.Size = 54; npcsTheofBarnswallow.Level = 54; npcsTheofBarnswallow.X = 35357; npcsTheofBarnswallow.Y = 22081; npcsTheofBarnswallow.Z = 8447; npcsTheofBarnswallow.Heading = 2811; npcsTheofBarnswallow.AddToWorld(); if (SAVE_INTO_DATABASE) { npcsTheofBarnswallow.SaveIntoDatabase(); } } else { npcsTheofBarnswallow = npcs[0]; } // end npc #endregion #region Item Declarations LilithsHead = GameServer.Database.FindObjectByKey<ItemTemplate>("liliths_head"); if (LilithsHead == null) { LilithsHead = new ItemTemplate(); LilithsHead.Id_nb = "liliths_head"; LilithsHead.Name = "Lilith's Head"; if (log.IsWarnEnabled) log.Warn("Could not find Lilith's Head , creating it ..."); LilithsHead.Realm = 0; LilithsHead.Level = 0; LilithsHead.Item_Type = 41; LilithsHead.Model = 503; LilithsHead.IsDropable = false; LilithsHead.IsPickable = true; LilithsHead.DPS_AF = 0; LilithsHead.SPD_ABS = 0; LilithsHead.Object_Type = 0; LilithsHead.Hand = 0; LilithsHead.Type_Damage = 0; LilithsHead.Quality = 49; LilithsHead.Weight = 1; if (SAVE_INTO_DATABASE) { GameServer.Database.AddObject(LilithsHead); } } //Item Descriptions End //the reward item from Database DemonslayerMedalofHonor = GameServer.Database.FindObjectByKey<ItemTemplate>("Demonslayer_Medal_of_Honor"); //midgard #endregion GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest)); GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest)); GameEventMgr.AddHandler(npcsTheofBarnswallow, GameObjectEvent.Interact, new DOLEventHandler(TalkToYahsawHuny)); GameEventMgr.AddHandler(npcsTheofBarnswallow, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToYahsawHuny)); /* Now we bring to Theof Barnswallow the possibility to give this quest to players */ npcsTheofBarnswallow.AddQuestToGive(typeof(TheDemonQueenAlb)); if (log.IsInfoEnabled) log.Info("Quest \"" + questTitle + "\" initialized"); } [ScriptUnloadedEvent] public static void ScriptUnloaded(DOLEvent e, object sender, EventArgs args) { //if not loaded, don't worry if (npcsTheofBarnswallow == null) return; // remove handlers GameEventMgr.RemoveHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest)); GameEventMgr.RemoveHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest)); GameEventMgr.RemoveHandler(npcsTheofBarnswallow, GameObjectEvent.Interact, new DOLEventHandler(TalkToYahsawHuny)); GameEventMgr.RemoveHandler(npcsTheofBarnswallow, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToYahsawHuny)); /* Now we remove to Theof Barnswallow the possibility to give this quest to players */ npcsTheofBarnswallow.RemoveQuestToGive(typeof(TheDemonQueenAlb)); } protected static void TalkToYahsawHuny(DOLEvent e, object sender, EventArgs args) { //We get the player from the event arguments and check if he qualifies GamePlayer player = ((SourceEventArgs)args).Source as GamePlayer; if (player == null) return; if (npcsTheofBarnswallow.CanGiveQuest(typeof(TheDemonQueenAlb), player) <= 0) return; //We also check if the player is already doing the quest TheDemonQueenAlb quest = player.IsDoingQuest(typeof(TheDemonQueenAlb)) as TheDemonQueenAlb; npcsTheofBarnswallow.TurnTo(player); if (e == GameObjectEvent.Interact) { if (quest != null) { npcsTheofBarnswallow.SayTo(player, "Check your Journal for instructions!"); } else { npcsTheofBarnswallow.SayTo(player, "Ah, " + player.Name + " , Due to the hasty departure of the Scholars of the Ancient Ways after Queen Lilith's defeat, the following quests from the Doppelganger Invasion can now be turned in to Traurig in Camelot." + " After all these months we have finally discovered who, or rather what is behind the attack on our realm." + "Lilith, the Demon Queen of Darkness Falls, has claimed to be the dark general of the doppelganger forces. " + " She has openly challenged us to pursue her and fight her on her own ground. Now we shall make her eat those words, [more].. " + player.Name + " ."); } } // The player whispered to the NPC else if (e == GameLivingEvent.WhisperReceive) { WhisperReceiveEventArgs wArgs = (WhisperReceiveEventArgs)args; //Check player is already doing quest if (quest == null) { switch (wArgs.Text) { case "more": player.Out.SendQuestSubscribeCommand(npcsTheofBarnswallow, QuestMgr.GetIDForQuestType(typeof(TheDemonQueenAlb)), "Travel into these firey depths and slay the Dark Mistress of this place and take her [Head]. When you have done so, return to me fore your well earned reward. You should also speak to Mavet over there. He has turned against his old mistress."); break; } } else { switch (wArgs.Text) { case "abort": player.Out.SendCustomDialog("Do you really want to abort this quest, \nall items gained during quest will be lost?", new CustomDialogResponse(CheckPlayerAbortQuest)); break; } } } } public override bool CheckQuestQualification(GamePlayer player) { // if the player is already doing the quest his level is no longer of relevance if (player.IsDoingQuest(typeof(TheDemonQueenAlb)) != null) return true; if (player.Level < minimumLevel || player.Level > maximumLevel) return false; return true; } /* This is our callback hook that will be called when the player clicks * on any button in the quest offer dialog. We check if he accepts or * declines here... */ private static void CheckPlayerAbortQuest(GamePlayer player, byte response) { TheDemonQueenAlb quest = player.IsDoingQuest(typeof(TheDemonQueenAlb)) as TheDemonQueenAlb; if (quest == null) return; if (response == 0x00) { SendSystemMessage(player, "Good look, now go out there and do your job!"); } else { SendSystemMessage(player, "Aborting Quest " + questTitle + ". You can start over again if you want."); quest.AbortQuest(); } } protected static void SubscribeQuest(DOLEvent e, object sender, EventArgs args) { QuestEventArgs qargs = args as QuestEventArgs; if (qargs == null) return; if (qargs.QuestID != QuestMgr.GetIDForQuestType(typeof(TheDemonQueenAlb))) return; if (e == GamePlayerEvent.AcceptQuest) CheckPlayerAcceptQuest(qargs.Player, 0x01); else if (e == GamePlayerEvent.DeclineQuest) CheckPlayerAcceptQuest(qargs.Player, 0x00); } private static void CheckPlayerAcceptQuest(GamePlayer player, byte response) { if (npcsTheofBarnswallow.CanGiveQuest(typeof(TheDemonQueenAlb), player) <= 0) return; if (player.IsDoingQuest(typeof(TheDemonQueenAlb)) != null) return; if (response == 0x00) { player.Out.SendMessage("Our God forgives your laziness, just look out for stray lightning bolts.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); } else { //Check if we can add the quest! if (!npcsTheofBarnswallow.GiveQuest(typeof(TheDemonQueenAlb), player, 1)) return; //step 1 player.Out.SendMessage("Kill Lilith the Demon Queen and take the Head of her and then return to heof Barnswallow at the DF entrance [give him the Head].", eChatType.CT_System, eChatLoc.CL_PopupWindow); } } //Set quest name public override string Name { get { return "The Demon Queen (Level 50 Darkness Falls Quest)"; } } // Define Steps public override string Description { get { switch (Step) { case 1: if (addDemonQueen1 == false) { //27935 41339 18796 h2057 249 hib DF SpawnAdd(templateID1, Util.Random(68, 70), 27932, 27982, 20333, 249, (ushort)(Util.Random(0, 4095)), addQueenDespwanTime); //Play Sound m_questPlayer.Out.SendSoundEffect(6, 0, 0, 0, 0, 0); m_questPlayer.Out.SendMessage("you hear the sound of deepess around you, Lilith the Demon Queen has Spawned!", eChatType.CT_ScreenCenter, eChatLoc.CL_SystemWindow); addDemonQueen1 = true; } return "[Step #1] the Evil is comming, Kill Lilith the Demon Queen in Darkness Falls and take her [Head]. (you have 30 min to find Lilith in DF! loc 27,9k 27,9k)"; case 2: if (addTheofBarnswallow == false) { //hib entrance down SpawnAdd(templateID2, Util.Random(46, 48), 36081, 28808, 22381, 249, 2103, addTheofBarnswallowDespwanTime); //Questindicator for finish quest m_questPlayer.Out.SendNPCsQuestEffect(npcsTheofBarnswallow, eQuestIndicator.Finish); addTheofBarnswallow = true; } // return "[Step #2] you have to collect some stones near the ruins."; return "[Step #2] return to Theof Barnswallow he will wait at the entrance of Darkess Falls, give him the [Head]."; } return base.Description; } } public override void Notify(DOLEvent e, object sender, EventArgs args) { GamePlayer player = sender as GamePlayer; if (player == null || player.IsDoingQuest(typeof(TheDemonQueenAlb)) == null) return; if (Step == 1 && e == GameLivingEvent.EnemyKilled) { EnemyKilledEventArgs gArgs = (EnemyKilledEventArgs)args; if (gArgs.Target.Name == "Lilith the Demon Queen") { m_questPlayer.Out.SendMessage("You have sly the Demon Queen!", eChatType.CT_System, eChatLoc.CL_SystemWindow); TryGiveItem(QuestPlayer, LilithsHead); //FinishQuest(); Step = 2; return; } } if (Step == 2 && e == GamePlayerEvent.GiveItem) { GiveItemEventArgs gArgs1 = (GiveItemEventArgs)args; if (gArgs1.Target.Name == npcsTheofBarnswallow.Name && gArgs1.Item.Id_nb == LilithsHead.Id_nb) { npcsTheofBarnswallow.TurnTo(QuestPlayer); npcsTheofBarnswallow.SayTo(player, "Lilith, the Demon Queen of Darkness Fall has bean slyed, take this Medal for your good jop!"); FinishQuest(); return; } } } public override void AbortQuest() { base.AbortQuest(); //Defined in Quest, changes the state, stores in DB etc ... } public override void FinishQuest() { addTheofBarnswallow = false; addDemonQueen1 = false; // Here we try to place the item in the players backpack. If their inventory is full it fails and quest does not advance. if (m_questPlayer.Inventory.IsSlotsFree(1, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack)) { //remove the Head RemoveItem(npcsTheofBarnswallow, m_questPlayer, LilithsHead); //play endsound m_questPlayer.Out.SendSoundEffect(11, 0, 0, 0, 0, 0); //Questindicator reset m_questPlayer.Out.SendNPCsQuestEffect(npcsTheofBarnswallow, eQuestIndicator.None); base.FinishQuest(); //Defined in Quest, changes the state, stores in DB etc ... { //player take the Reward GiveItem(m_questPlayer, DemonslayerMedalofHonor); } //take xp and gold m_questPlayer.GainExperience(GameLiving.eXPSource.Quest, 332899648, true); m_questPlayer.AddMoney(Money.GetMoney(0, 0, 110, 18, Util.Random(50)), "You recieve {0} as a reward."); } else { m_questPlayer.Out.SendMessage("You do not have enough free space in your inventory!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); } } #region Add Create from Template private INpcTemplate m_addTemplate; /// Create an add from the specified template ID. protected GameNPC SpawnAdd(int templateID, int level, int x, int y, int Z, ushort id, ushort heading, int uptime) { GameNPC add = null; try { if (m_addTemplate == null || m_addTemplate.TemplateId != templateID) { m_addTemplate = NpcTemplateMgr.GetTemplate(templateID); } // Create add from template. if (m_addTemplate != null) { add = new GameNPC(m_addTemplate); add.CurrentRegionID = id; add.Heading = (ushort)heading;// add.Realm = 0; add.X = x; add.Y = y; add.Z = Z; add.CurrentSpeed = 0; add.Level = (byte)level; add.RespawnInterval = -1; add.AddToWorld(); // foreach (GameNPC npc in QuestPlayer.GetNPCsInRadius(1500)) // { // if (npc != null && npc.NPCTemplate != null) new DespawnTimer(add, add, uptime * 1000); } } catch { log.Warn(String.Format("Unable to get template for {0}", Name)); } return add; } /// <summary> /// Provides a timer to remove an NPC from the world after some /// time has passed. /// </summary> protected class DespawnTimer : GameTimer { private GameNPC m_npc; /// <summary> /// Constructs a new DespawnTimer. /// </summary> /// <param name="timerOwner">The owner of this timer.</param> /// <param name="npc">The GameNPC to despawn when the time is up.</param> /// <param name="delay">The time after which the add is supposed to despawn.</param> public DespawnTimer(GameObject timerOwner, GameNPC npc, int delay) : base(timerOwner.CurrentRegion.TimeManager) { if (npc.Name == "Lilith the Demon Queen" && addDemonQueen1 == true) { return; } if (npc.Name == "Theof Barnswallow" && addTheofBarnswallow == true) { return; } m_npc = npc; Start(delay); } /// <summary> /// Called on every timer tick. /// </summary> protected override void OnTick() { // Remove the NPC from the world. if (m_npc != null && m_npc.InCombat == false) { m_npc.Delete(); m_npc = null; } } } #endregion } }
Celdron
DOL Visitor
 
Posts: 8
Joined: Thu Jan 02, 2014 6:24 pm

Re: Demon Queen Quest for Albion

Postby Leodagan » Fri May 01, 2015 8:36 am

Hi,

Any reasons this can't be made as a DataQuest ?

Quest Scripts are harder to debug I must admit ;)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Demon Queen Quest for Albion

Postby Celdron » Fri May 01, 2015 10:44 am

for dataquests you need a new funtion to let npcs spawn, i favorite only scriptet quest for more free handling of quests.


for dataquest you can integrate the spawn funtion.

as a sample, use this for the tables of Dataquests, you can them link.
Code: Select all
/// <summary> /// Create an add from the specified template. /// </summary> /// <param name="templateID"></param> /// <param name="level"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="uptime"></param> /// <returns></returns> protected GameNPC SpawnAdd(int TemplateID, int SpawnLevel, int SpawnX, int SpawnY, int SpawnZ, ushort SpawnHeading, int Uptime) { GameNPC add = null; try { if (m_addTemplate == null || m_addTemplate.TemplateId != TemplateID) { m_addTemplate = NpcTemplateMgr.GetTemplate(TemplateID); } // Create add from template. if (m_addTemplate != null) { add = new GameNPC(m_addTemplate); add.CurrentRegion = m_questPlayer.CurrentRegion; add.Heading = SpawnHeading; add.Realm = 0; add.X = SpawnX; add.Y = SpawnY; add.Z = SpawnZ; add.CurrentSpeed = 0; add.Level = (byte)SpawnLevel; add.RespawnInterval = -1; add.AddToWorld(); // foreach (GameNPC npc in QuestPlayer.GetNPCsInRadius(1500)) // { // if (npc != null && npc.NPCTemplate != null) new DespawnTimer(add, add, uptime * 1000); } } catch { log.Warn(String.Format("Unable to get template for {0}", Name)); } return add; }

greetings :)
Celdron
DOL Visitor
 
Posts: 8
Joined: Thu Jan 02, 2014 6:24 pm

Re: Demon Queen Quest for Albion

Postby Leodagan » Fri May 01, 2015 11:16 am

This is for spawning Lilith when player kill Female Darkness Fall mobs If I remember Correctly ?
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Demon Queen Quest for Albion

Postby Celdron » Fri May 01, 2015 12:12 pm

no for this quest link here: http://camelot.allakhazam.com/quests.html?cquest=3712

to spawn the queen at quest begin in df and to spawn the questgiver after kill the queen in DF. (quest start was in Camelot)
Celdron
DOL Visitor
 
Posts: 8
Joined: Thu Jan 02, 2014 6:24 pm


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest