//init the faction without modifying the faction attributes public void Init(int factionID, FactionManager factionMgr, GameManager gameMgr) { this.ID = factionID; this.FactionMgr = factionMgr; FactionMgr.Init(gameMgr, ID, typeInfo ? typeInfo.GetLimits() : null, this); //init the faction manager component of this faction //depending on the faction type, add extra units/buildings (if there's actually any) to be created for each faction: if (playerControlled == true) //if this faction is player controlled: { if (typeInfo != null) //if this faction has a valid type. { gameMgr.PlacementMgr.AddBuildingRange(typeInfo.GetExtraBuildings()); //add the extra buildings so that this faction can use them. } } else if (IsNPCFaction() == true) //if this is not controlled by the local player but rather NPC. //Init the NPC Faction manager: { InitNPCMgr(gameMgr); } Lost = false; CustomEvents.OnFactionInit(this); }
public override bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool quiet) { if (!base.IsAllowedToAttack(attacker, defender, quiet)) { return(false); } // if controlled NPC - do checks for owner instead if (attacker is GameNPC npc) { if (npc.Brain is IControlledBrain controlled) { attacker = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (defender is GameNPC gameNpc) { if (gameNpc.Brain is IControlledBrain controlled) { defender = controlled.GetLivingOwner(); } } // "You can't attack yourself!" if (attacker == defender) { if (quiet == false) { MessageToLiving(attacker, "You can't attack yourself!"); } return(false); } // Don't allow attacks on same realm members on Normal Servers if (attacker.Realm == defender.Realm && !(attacker is GamePlayer && ((GamePlayer)attacker).DuelTarget == defender)) { // allow confused mobs to attack same realm if (attacker is GameNPC && (attacker as GameNPC).IsConfused) { return(true); } if (attacker.Realm == 0) { return(FactionMgr.CanLivingAttack(attacker, defender)); } if (quiet == false) { MessageToLiving(attacker, "You can't attack a member of your realm!"); } return(false); } return(true); }
public static void WriteAllEnums() { RealmDBMgr.Initialize(); ContentMgr.Initialize(); World.InitializeWorld(); SpellHandler.LoadSpells(); FactionMgr.Initialize(); SpellHandler.Initialize2(); AreaTriggerMgr.Initialize(); WriteZoneEnum(); WriteMapEnum(); WriteSkillEnums(); WriteRangeEnum(); WriteFactionEnums(); WriteSpellFocusEnum(); WriteSpellId(); WriteSpellMechanicEnum(); WriteTalentEnums(); WriteItemId(); WriteItemSetId(); WriteNpcId(); WriteCreatureFamilyId(); WriteGOEntryId(); WriteRealmCategory(); WriteTotemCategories(); WriteAreaTriggers(); //NPCMgr.ForceInitialize(); //WriteRideEnum(); }
public static void WriteNpcId() { RealmDBMgr.Initialize(); SpellHandler.LoadSpells(); FactionMgr.Initialize(); NPCMgr.LoadAll(); WriteEnum("NPCId", " : uint", "NPCs", NPCMgr.GetAllEntries(), false, (item) => { return(item != null); }, (item) => { return(item.DefaultName); }, entry => { var strs = new List <string>(); if (entry.DefaultTitle.Length > 0) { strs.Add("Title: " + entry.DefaultTitle); } if (entry.MinLevel > 0) { strs.Add("Level: " + entry.MinLevel + (entry.MaxLevel != entry.MinLevel ? " - " + entry.MaxLevel : "")); } if (entry.Rank != CreatureRank.Normal) { strs.Add("Rank: " + entry.Rank + (entry.IsLeader ? " (Leader)" : "")); } else if (entry.IsLeader) { strs.Add("Leader"); } return(strs.ToString("\n")); }, (item, name) => null, (item) => { return(item.Id.ToString()); }); }
public static void WriteAll() { DBSetup.Initialize(); World.EnsureMapDataLoaded(); SpellHandler.Initialize(); FactionMgr.Initialize(); SkillHandler.Initialize(); TalentMgr.Initialize(); WriteZoneEnum(); WriteMapEnum(); WriteSkillEnums(); WriteRangeEnum(); WriteFactionEnums(); WriteSpellFocusEnum(); WriteSpellId(); WriteSpellMechanicEnum(); WriteTalentEnums(); WriteItemId(); WriteItemSetId(); WriteNpcId(); WriteGOEntryId(); WriteRealmCategory(); NPCMgr.ForceInitialize(); WriteRideEnum(); }
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args) { if (!ServerProperties.Properties.LOAD_EXAMPLES) { return; } GameNPC[] npcs = WorldMgr.GetObjectsByName <GameNPC>("Sir Quait", eRealm.Albion); npcs = WorldMgr.GetObjectsByName <GameNPC>("Sir Quait", (eRealm)1); GameNPC SirQuait = null; if (npcs.Length == 0) { SirQuait = new DOL.GS.GameNPC(); SirQuait.Model = 40; SirQuait.Name = "Sir Quait"; if (log.IsWarnEnabled) { log.Warn("Could not find " + SirQuait.Name + ", creating ..."); } SirQuait.Realm = eRealm.Albion; SirQuait.CurrentRegionID = 1; SirQuait.Size = 50; SirQuait.Level = 10; SirQuait.MaxSpeedBase = 100; SirQuait.Faction = FactionMgr.GetFactionByID(0); SirQuait.X = 531971; SirQuait.Y = 478955; SirQuait.Z = 0; SirQuait.Heading = 3570; SirQuait.RespawnInterval = 0; SirQuait.BodyType = 0; StandardMobBrain brain = new StandardMobBrain(); brain.AggroLevel = 0; brain.AggroRange = 0; SirQuait.SetOwnBrain(brain); SirQuait.AddToWorld(); } else { SirQuait = npcs[0]; } BaseBehaviour b = new BaseBehaviour(SirQuait); MessageAction a = new MessageAction(SirQuait, "This is just a simple test bahaviour.", eTextType.Emote); b.AddAction(a); InteractTrigger t = new InteractTrigger(SirQuait, b.NotifyHandler, SirQuait); b.AddTrigger(t); // store the behaviour in a list so it won't be garbage collected behaviours.Add(b); log.Info("Simple Test Behaviour added"); }
public override void OnUpdate(AchievementCollection achievements, uint value1, uint value2, ObjectBase involved) { if ((FactionId)value1 != this.FactionId) { return; } int num = achievements.Owner.Reputations.GetValue(FactionMgr.GetFactionIndex(this.FactionId)); achievements.SetCriteriaProgress((AchievementCriteriaEntry)this, (uint)num, ProgressType.ProgressHighest); }
public static void LoadEntries(bool force) { if (!force && entriesLoaded) { return; } try { Loading = true; FactionMgr.Initialize(); ContentMgr.Load <NPCEquipmentEntry>(force); //Dont move this into LoadTrainers, the templates must //be loaded before NPC Entries ContentMgr.Load <TrainerSpellTemplate>(force); ContentMgr.Load <NPCEntry>(force); //foreach (var entry in Entries) //{ // if (entry != null && entry.Template == null) // { // ContentHandler.OnInvalidData("NPCEntry had no corresponding NPCTemplate: " + entry.NPCId); // } //} LoadTrainers(force); // mount-entries //foreach (var spell in SpellHandler.ById) //{ // if (spell != null && spell.IsMount) // { // var id = (MountId)spell.Effects[0].MiscValue; // if ((int)id >= Entries.Length) // { // log.Warn("Invalid Mount Id: " + id); // spell.Effects[0].EffectType = SpellEffectType.Dummy; // reach-around fix for the time being // continue; // } // var entry = Entries[(int)id]; // if (entry != null) // { // Mounts[id] = entry; // } // } //} EntriesLoaded = true; } finally { Loading = false; } }
public static void Init() { RealmDBMgr.Initialize(); var mgr = RealmServer.RealmServer.InitMgr; RealmAddonMgr.Initialize(mgr); mgr.PerformInitialization(); ContentMgr.Initialize(); SpellHandler.LoadSpells(); FactionMgr.Initialize(); SpellHandler.Initialize2(); }
public void TestInitialReputations() { Setup.EnsureDBSetup(); FactionMgr.Initialize(); var stormWind = FactionMgr.Get(FactionId.Stormwind); var bootyBay = FactionMgr.Get(FactionId.BootyBay); Assert.IsNotNull(bootyBay); var reputation = new Reputation(new ReputationRecord(), bootyBay, 1000, ReputationFlags.None); Asser.FlatNotSet(reputation.Flags, ReputationFlags.AtWar); }
public virtual void FinalizeDataHolder() { if (Id != 0U) { GOId = (GOEntryId)Id; } else { Id = (uint)GOId; } if (FactionId != FactionTemplateId.None) { Faction = FactionMgr.Get(FactionId); } InitEntry(); if (GossipId != 0U && DefaultGossip == null) { if (GossipMgr.GetEntry(GossipId) == null) { ContentMgr.OnInvalidDBData("GOEntry {0} has missing GossipId: {1}", (object)this, (object)GossipId); DefaultGossip = new GossipMenu(); } else { DefaultGossip = new GossipMenu(GossipId); } } else if (QuestHolderInfo != null) { DefaultGossip = new GossipMenu(); } if (HandlerCreator == null) { HandlerCreator = GOMgr.Handlers[(int)Type]; } if (GOCreator == null) { GOCreator = !IsTransport ? () => new GameObject() : (Func <GameObject>)(() => (GameObject) new Transport()); } if (Fields == null) { return; } GOMgr.Entries[Id] = this; }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { //Check if the character exists. This should always be true in theory if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return(false); } //Checks if the relation target char exist if (relatedCharInfo == null) { relResult = RelationResult.FRIEND_NOT_FOUND; return(false); } //Checks if the target char is the same as the related one if (charInfo.EntityLowId == relatedCharInfo.EntityLowId) { relResult = RelationResult.FRIEND_SELF; return(false); } //Checks if both chars are in the same faction if (FactionMgr.GetFactionGroup(charInfo.Race) != FactionMgr.GetFactionGroup(relatedCharInfo.Race)) { relResult = RelationResult.FRIEND_ENEMY; return(false); } //Checks if the relation currently exist if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, Type)) { relResult = RelationResult.FRIEND_ALREADY; return(false); } //All checks are ok so check if the related char is online if (World.GetCharacter(relatedCharInfo.EntityLowId) != null) { relResult = RelationResult.FRIEND_ADDED_ONLINE; } else { relResult = RelationResult.FRIEND_ADDED_OFFLINE; } return(true); }
public static void WriteNpcId() { SpellHandler.Initialize(); FactionMgr.Initialize(); NPCMgr.ForceInitialize(); WriteEnum("NPCId", "NPCs", NPCMgr.Prototypes, false, (item) => { return(item.Entry != null); }, (item) => { return(item.Entry.Name); }, prototype => { var strs = new List <string>(); if (prototype.Entry.Title.Length > 0) { strs.Add("Title: " + prototype.Entry.Title); } if (prototype.MinLevel > 0) { strs.Add("Level: " + prototype.MinLevel + (prototype.MaxLevel != prototype.MinLevel ? " - " + prototype.MaxLevel : "")); } if (prototype.DefaultFaction != null) { strs.Add("Faction: " + prototype.DefaultFaction); } if (prototype.Entry.Rank != CreatureRank.Normal) { strs.Add("Rank: " + prototype.Entry.Rank + (prototype.Entry.IsLeader ? " (Leader)" : "")); } else if (prototype.Entry.IsLeader) { strs.Add("Leader"); } if (prototype.Entry.Spells != null && prototype.Entry.Spells.Length > 0) { strs.Add("Spells: " + prototype.Entry.Spells.ToString(", ")); } if (prototype.Auras != null && prototype.Auras.Length > 0) { strs.Add("Auras: " + prototype.Auras.ToString(", ")); } return(strs.ToString("\n")); }, (item, name) => null, (item) => { return(item.Entry.Id.ToString()); }); }
public static void WriteFactionEnums() { FactionMgr.Initialize(); WriteEnum("FactionId", " : uint", "Factions", FactionMgr.ById, (faction) => { return(true); }, (faction) => { return(faction.Entry.Name); }, (faction) => { return(((int)faction.Id).ToString()); }); WriteEnum("FactionReputationIndex", "", "Factions", FactionMgr.ByReputationIndex, (faction) => true, (faction) => faction.Entry.Name, (faction) => ((int)faction.ReputationIndex).ToString()); WriteEnum("FactionTemplateId", " : uint", "Factions", FactionMgr.ByTemplateId, (faction) => { return(true); }, (faction) => { return(faction.Entry.Name); }, (faction) => { return(((int)faction.Template.Id).ToString()); }); }
public static void WriteFactionEnums() { FactionMgr.Initialize(); WriteEnum <Faction>("FactionId", "Factions", FactionMgr.ById, (faction) => { return(true); }, (faction) => { return(faction.Entry.Name); }, (faction) => { return(((int)faction.Id).ToString()); }); WriteEnum <Faction>("FactionRepListId", "Factions", FactionMgr.ByRepId, (faction) => { return(true); }, (faction) => { return(faction.Entry.Name); }, (faction) => { return(((int)faction.RepListId).ToString()); }); WriteEnum <Faction>("FactionTemplateId", "Factions", FactionMgr.ByTemplateId, (faction) => { return(true); }, (faction) => { return(faction.Entry.Name); }, (faction) => { return(((int)faction.Template.Id).ToString()); }); }
public static void WriteItemId() { World.InitializeWorld(); SpellHandler.LoadSpells(); FactionMgr.Initialize(); NPCMgr.LoadAll(); ItemMgr.ForceInitialize(); WriteEnum("ItemId", " : uint", "Items", ItemMgr.Templates, false, (item) => { return(item.DefaultName != null); }, (item) => { return(item.DefaultName); }, template => { var strs = new List <string>(); if (!string.IsNullOrEmpty(template.DefaultDescription)) { strs.Add("Desc: " + template.DefaultDescription); } if (template.InventorySlotType != InventorySlotType.None) { strs.Add(template.InventorySlotType.ToString()); } if (template.Level > 0) { strs.Add("Level: " + template.Level); } if (template.Set != null) { strs.Add("Set: " + template.Set); } if (template.Class != ItemClass.None) { strs.Add("Class: " + template.Class); } return(strs.ToString("\n")); }, (item, name) => null, (item) => { return(item.Id.ToString()); }); }
public static void LoadEntries(bool force) { if (!force) { if (NPCMgr.entriesLoaded) { return; } } try { NPCMgr.Loading = true; FactionMgr.Initialize(); ContentMgr.Load <NPCEntry>(force); NPCMgr.EntriesLoaded = true; } finally { NPCMgr.Loading = false; } }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return(false); } if (relatedCharInfo == null) { relResult = RelationResult.FRIEND_NOT_FOUND; return(false); } if ((int)charInfo.EntityLowId == (int)relatedCharInfo.EntityLowId) { relResult = RelationResult.FRIEND_SELF; return(false); } if (FactionMgr.GetFactionGroup(charInfo.Race) != FactionMgr.GetFactionGroup(relatedCharInfo.Race)) { relResult = RelationResult.FRIEND_ENEMY; return(false); } if (Singleton <RelationMgr> .Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, Type)) { relResult = RelationResult.FRIEND_ALREADY; return(false); } relResult = World.GetCharacter(relatedCharInfo.EntityLowId) == null ? RelationResult.FRIEND_ADDED_OFFLINE : RelationResult.FRIEND_ADDED_ONLINE; return(true); }
/// <summary> /// Is called to initialize the object; usually after a set of other operations have been performed or if /// the right time has come and other required steps have been performed. /// </summary> public void FinalizeAfterLoad() { NPCId = (NPCId)Id; SetFlagIndeces = Utility.GetSetIndices((uint)Flags); DefaultFaction = FactionMgr.Get(DefaultFactionId); if (AuraIds != null) { var auras = new List <Spell>(AuraIds.Length); foreach (var auraId in AuraIds) { var spell = SpellHandler.Get(auraId); if (spell != null) { auras.Add(spell); } } Auras = auras.ToArray(); } else { Auras = Spell.EmptyArray; } var entry = NPCMgr.GetEntry(Id); if (entry != null) { // set the prototype entry.Prototype = this; Entry = entry; } InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this); SpawnTypeHandlers = NPCMgr.GetNPCSpawnTypeHandlers(this); }
public override bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool quiet) { if (!base.IsAllowedToAttack(attacker, defender, quiet)) { return(false); } // if controlled NPC - do checks for owner instead if (attacker is GameNPC) { IControlledBrain controlled = ((GameNPC)attacker).Brain as IControlledBrain; if (controlled != null) { attacker = controlled.GetPlayerOwner(); quiet = true; // silence all attacks by controlled npc } } if (defender is GameNPC) { IControlledBrain controlled = ((GameNPC)defender).Brain as IControlledBrain; if (controlled != null) { defender = controlled.GetPlayerOwner(); } } //"You can't attack yourself!" if (attacker == defender) { if (quiet == false) { MessageToLiving(attacker, "You can't attack yourself!"); } return(false); } // Pet release might cause one of these to be null if (attacker == null || defender == null) { return(false); } if (attacker.Realm != eRealm.None && defender.Realm != eRealm.None) { if (attacker is GamePlayer && ((GamePlayer)attacker).DuelTarget == defender) { return(true); } if (quiet == false) { MessageToLiving(attacker, "You can not attack other players on this server!"); } return(false); } //allow attacks on same realm only under the following circumstances if (attacker.Realm == defender.Realm) { //allow confused mobs to attack same realm if (attacker is GameNPC && (attacker as GameNPC).IsConfused) { return(true); } // else, don't allow mobs to attack mobs if (attacker.Realm == eRealm.None) { return(FactionMgr.CanLivingAttack(attacker, defender)); } if (quiet == false) { MessageToLiving(attacker, "You can't attack a member of your realm!"); } return(false); } return(true); }
/// <summary> /// Is called to initialize the object; usually after a set of other operations have been performed or if /// the right time has come and other required steps have been performed. /// </summary> public void FinalizeDataHolder() { if (string.IsNullOrEmpty(DefaultName)) { ContentMgr.OnInvalidDBData("NPCEntry has no name: " + this); return; } if (SpellGroupId != 0 && NPCMgr.PetSpells != null) { var spells = NPCMgr.PetSpells.Get(SpellGroupId) ?? Spell.EmptyArray; foreach (var spell in spells) { AddSpell(spell); } } if (MinMana > MaxMana) { MaxMana = MinMana; } if (MaxDamage > 0) { if (MinDamage < 1) { MinDamage = 1; } if (MaxDamage < MinDamage) { MaxDamage = MinDamage; } } if (Rank == CreatureRank.WorldBoss || Rank == CreatureRank.Boss) { IsBoss = true; } NPCId = (NPCId)Id; DefaultDecayDelayMillis = _DefaultDecayDelayMillis; Family = NPCMgr.GetFamily(CreatureFamilyId.Wolf); if (Type == CreatureType.NotSpecified || VehicleEntry != null) { IsIdle = true; } if (Type == CreatureType.NotSpecified && UnitFlags.HasFlag((UnitFlags.Passive | UnitFlags.NotSelectable))) { IsEventTrigger = true; IsIdle = false; } if (Resistances == null) { Resistances = new int[ItemConstants.MaxResCount]; } SetFlagIndices = Utility.GetSetIndices((uint)NPCFlags); // set/fix factions HordeFaction = FactionMgr.Get(HordeFactionId); AllianceFaction = FactionMgr.Get(AllianceFactionId); if (HordeFaction == null) { HordeFaction = AllianceFaction; HordeFactionId = AllianceFactionId; } else if (AllianceFaction == null) { AllianceFaction = HordeFaction; AllianceFactionId = HordeFactionId; } if (AllianceFaction == null) { ContentMgr.OnInvalidDBData("NPCEntry has no valid Faction: " + this); HordeFaction = AllianceFaction = NPCMgr.DefaultFaction; HordeFactionId = AllianceFactionId = (FactionTemplateId)HordeFaction.Template.Id; } // Add all default spells if (FixedSpells != null) { foreach (var spell in FixedSpells) { AddSpell(spell); } } InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this); SpawnTypeHandlers = NPCMgr.GetNPCSpawnTypeHandlers(this); GeneratesXp = (Type != CreatureType.Critter && Type != CreatureType.None && !ExtraFlags.HasFlag(UnitExtraFlags.NoXP)); AtackRange = CombatReach + 0.2f; ModelInfo = new UnitModelInfo { BoundingRadius = BoundingRadius, CombatReach = CombatReach }; // add to container if (Id < NPCMgr.Entries.Length) { NPCMgr.Entries[Id] = this; } else { NPCMgr.CustomEntries[Id] = this; } ++NPCMgr.EntryCount; if (BrainCreator == null) { BrainCreator = DefaultBrainCreator; } if (NPCCreator == null) { NPCCreator = DefaultCreator; } #region calc expirience Expirience = (int) (((MinHealth + MaxHealth) * 2.2f + (MaxDamage + MinDamage) * 100 + Resistances.Aggregate((a, r) => a + r * 100)) / 2000 * Math.Pow(MinLevel, 0.3325f)); #endregion }
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args) { if (!ServerProperties.Properties.LOAD_QUESTS) { return; } if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initializing ..."); } #region defineNPCs GameNPC[] npcs; npcs = WorldMgr.GetNPCsByName("Audun", (eRealm)2); if (npcs.Length == 0) { if (!WorldMgr.GetRegion(101).IsDisabled) { Audun = new DOL.GS.GameNPC(); Audun.Model = 232; Audun.Name = "Audun"; if (log.IsWarnEnabled) { log.Warn("Could not find " + Audun.Name + ", creating ..."); } Audun.GuildName = "Part of " + questTitle + " Quest"; Audun.Realm = eRealm.Midgard; Audun.CurrentRegionID = 101; Audun.Size = 48; Audun.Level = 49; Audun.MaxSpeedBase = 191; Audun.Faction = FactionMgr.GetFactionByID(0); Audun.X = 33283; Audun.Y = 35305; Audun.Z = 8027; Audun.Heading = 1763; Audun.RespawnInterval = -1; Audun.BodyType = 0; StandardMobBrain brain = new StandardMobBrain(); brain.AggroLevel = 0; brain.AggroRange = 500; Audun.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) { Audun.SaveIntoDatabase(); } Audun.AddToWorld(); } } else { Audun = npcs[0]; } npcs = WorldMgr.GetNPCsByName("Guard Olja", (eRealm)2); if (npcs.Length == 0) { if (!WorldMgr.GetRegion(229).IsDisabled) { GuardOlja = new DOL.GS.GameNPC(); GuardOlja.Model = 180; GuardOlja.Name = "Guard Olja"; if (log.IsWarnEnabled) { log.Warn("Could not find " + GuardOlja.Name + ", creating ..."); } GuardOlja.GuildName = "Part of " + questTitle + " Quest"; GuardOlja.Realm = eRealm.Midgard; GuardOlja.CurrentRegionID = 229; GuardOlja.Size = 50; GuardOlja.Level = 50; GuardOlja.MaxSpeedBase = 191; GuardOlja.Faction = FactionMgr.GetFactionByID(0); GuardOlja.X = 47994; GuardOlja.Y = 37341; GuardOlja.Z = 21812; GuardOlja.Heading = 204; GuardOlja.RespawnInterval = -1; GuardOlja.BodyType = 0; StandardMobBrain brain = new StandardMobBrain(); brain.AggroLevel = 0; brain.AggroRange = 500; GuardOlja.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) { GuardOlja.SaveIntoDatabase(); } GuardOlja.AddToWorld(); } } else { GuardOlja = npcs[0]; } #endregion #region defineItems emptybottle = GameServer.Database.FindObjectByKey <ItemTemplate>("emptybottle"); if (emptybottle == null) { emptybottle = new ItemTemplate(); emptybottle.Name = "Empty Bottle"; if (log.IsWarnEnabled) { log.Warn("Could not find " + emptybottle.Name + ", creating it ..."); } emptybottle.Level = 50; emptybottle.Weight = 5; emptybottle.Model = 554; emptybottle.Object_Type = 0; emptybottle.Item_Type = 40; emptybottle.Id_nb = "emptybottle"; emptybottle.Hand = 0; emptybottle.Price = 0; emptybottle.IsPickable = true; emptybottle.IsDropable = true; emptybottle.IsTradable = true; emptybottle.CanDropAsLoot = false; emptybottle.Color = 0; emptybottle.Bonus = 35; // default bonus emptybottle.Bonus1 = 0; emptybottle.Bonus1Type = (int)0; emptybottle.Bonus2 = 0; emptybottle.Bonus2Type = (int)0; emptybottle.Bonus3 = 0; emptybottle.Bonus3Type = (int)0; emptybottle.Bonus4 = 0; emptybottle.Bonus4Type = (int)0; emptybottle.Bonus5 = 0; emptybottle.Bonus5Type = (int)0; emptybottle.Bonus6 = 0; emptybottle.Bonus6Type = (int)0; emptybottle.Bonus7 = 0; emptybottle.Bonus7Type = (int)0; emptybottle.Bonus8 = 0; emptybottle.Bonus8Type = (int)0; emptybottle.Bonus9 = 0; emptybottle.Bonus9Type = (int)0; emptybottle.Bonus10 = 0; emptybottle.Bonus10Type = (int)0; emptybottle.ExtraBonus = 0; emptybottle.ExtraBonusType = (int)0; emptybottle.Effect = 0; emptybottle.Emblem = 0; emptybottle.Charges = 0; emptybottle.MaxCharges = 0; emptybottle.SpellID = 0; emptybottle.ProcSpellID = 0; emptybottle.Type_Damage = 0; emptybottle.Realm = 0; emptybottle.MaxCount = 1; emptybottle.PackSize = 1; emptybottle.Extension = 0; emptybottle.Quality = 99; emptybottle.Condition = 100; emptybottle.MaxCondition = 100; emptybottle.Durability = 100; emptybottle.MaxDurability = 100; emptybottle.PoisonCharges = 0; emptybottle.PoisonMaxCharges = 0; emptybottle.PoisonSpellID = 0; emptybottle.ProcSpellID1 = 0; emptybottle.SpellID1 = 0; emptybottle.MaxCharges1 = 0; emptybottle.Charges1 = 0; //You don't have to store the created item in the db if you don't want, //it will be recreated each time it is not found, just comment the following //line if you rather not modify your database if (SAVE_INTO_DATABASE) { GameServer.Database.AddObject(emptybottle); } } bottleofmead = GameServer.Database.FindObjectByKey <ItemTemplate>("bottleofmead"); if (bottleofmead == null) { bottleofmead = new ItemTemplate(); bottleofmead.Name = "Bottle of Mead"; if (log.IsWarnEnabled) { log.Warn("Could not find " + bottleofmead.Name + ", creating it ..."); } bottleofmead.Level = 50; bottleofmead.Weight = 5; bottleofmead.Model = 554; bottleofmead.Object_Type = 0; bottleofmead.Item_Type = 40; bottleofmead.Id_nb = "bottleofmead"; bottleofmead.Hand = 0; bottleofmead.Price = 0; bottleofmead.IsPickable = true; bottleofmead.IsDropable = true; bottleofmead.IsTradable = true; bottleofmead.CanDropAsLoot = false; bottleofmead.Color = 0; bottleofmead.Bonus = 35; // default bonus bottleofmead.Bonus1 = 0; bottleofmead.Bonus1Type = (int)0; bottleofmead.Bonus2 = 0; bottleofmead.Bonus2Type = (int)0; bottleofmead.Bonus3 = 0; bottleofmead.Bonus3Type = (int)0; bottleofmead.Bonus4 = 0; bottleofmead.Bonus4Type = (int)0; bottleofmead.Bonus5 = 0; bottleofmead.Bonus5Type = (int)0; bottleofmead.Bonus6 = 0; bottleofmead.Bonus6Type = (int)0; bottleofmead.Bonus7 = 0; bottleofmead.Bonus7Type = (int)0; bottleofmead.Bonus8 = 0; bottleofmead.Bonus8Type = (int)0; bottleofmead.Bonus9 = 0; bottleofmead.Bonus9Type = (int)0; bottleofmead.Bonus10 = 0; bottleofmead.Bonus10Type = (int)0; bottleofmead.ExtraBonus = 0; bottleofmead.ExtraBonusType = (int)0; bottleofmead.Effect = 0; bottleofmead.Emblem = 0; bottleofmead.Charges = 0; bottleofmead.MaxCharges = 0; bottleofmead.SpellID = 0; bottleofmead.ProcSpellID = 0; bottleofmead.Type_Damage = 0; bottleofmead.Realm = 0; bottleofmead.MaxCount = 1; bottleofmead.PackSize = 1; bottleofmead.Extension = 0; bottleofmead.Quality = 99; bottleofmead.Condition = 100; bottleofmead.MaxCondition = 100; bottleofmead.Durability = 100; bottleofmead.MaxDurability = 100; bottleofmead.PoisonCharges = 0; bottleofmead.PoisonMaxCharges = 0; bottleofmead.PoisonSpellID = 0; bottleofmead.ProcSpellID1 = 0; bottleofmead.SpellID1 = 0; bottleofmead.MaxCharges1 = 0; bottleofmead.Charges1 = 0; //You don't have to store the created item in the db if you don't want, //it will be recreated each time it is not found, just comment the following //line if you rather not modify your database if (SAVE_INTO_DATABASE) { GameServer.Database.AddObject(bottleofmead); } } #endregion #region defineAreas #endregion #region defineQuestParts QuestBuilder builder = QuestMgr.getBuilder(typeof(meadrun)); QuestBehaviour a; a = builder.CreateBehaviour(Audun, -1); a.AddTrigger(eTriggerType.Interact, null, Audun); a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.meadrun), Audun); a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.meadrun), null, (eComparator)5); a.AddAction(eActionType.Talk, "Greetings. You appear to be down on your luck. I have a [proposition] for you if you're interested.", null); AddBehaviour(a); a = builder.CreateBehaviour(Audun, -1); a.AddTrigger(eTriggerType.Whisper, "proposition", Audun); a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.meadrun), Audun); a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.meadrun), null, (eComparator)5); a.AddAction(eActionType.Talk, "I need to deliver some mead to the guards just inside the Burial Grounds. There is a bit of coin to be had if you would deliver the mead for me.", Audun); a.AddAction(eActionType.OfferQuest, typeof(DOL.GS.Quests.Midgard.meadrun), "Will you deliver the mead for Audun? [Levels 1-4]"); AddBehaviour(a); a = builder.CreateBehaviour(Audun, -1); a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.meadrun)); a.AddAction(eActionType.Talk, "No problem. See you", Audun); AddBehaviour(a); a = builder.CreateBehaviour(Audun, -1); a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.meadrun)); a.AddAction(eActionType.Talk, "Here take the mead to Guard Olja inside the entrance of the Burial Grounds.", Audun); a.AddAction(eActionType.GiveItem, bottleofmead, Audun); a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.meadrun), Audun); AddBehaviour(a); a = builder.CreateBehaviour(GuardOlja, -1); a.AddTrigger(eTriggerType.GiveItem, GuardOlja, bottleofmead); a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.meadrun), null); a.AddAction(eActionType.Talk, "Thanks. Here, take this empty bottle back to Auduan.", GuardOlja); a.AddAction(eActionType.GiveItem, emptybottle, GuardOlja); a.AddAction(eActionType.TakeItem, bottleofmead, null); a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.meadrun), null); AddBehaviour(a); a = builder.CreateBehaviour(Audun, -1); a.AddTrigger(eTriggerType.GiveItem, Audun, emptybottle); a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.meadrun), 2, (eComparator)3); a.AddAction(eActionType.Talk, "Good work. Here is that bit of coin I was talking about. Check back with me later, and I may have more work for you.", Audun); a.AddAction(eActionType.GiveXP, 5, null); a.AddAction(eActionType.GiveGold, 27, null); a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.meadrun), null); AddBehaviour(a); #endregion // Custom Scriptloaded Code Begin // Custom Scriptloaded Code End if (Audun != null) { Audun.AddQuestToGive(typeof(meadrun)); } if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initialized"); } }
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args) { if (!ServerProperties.Properties.LOAD_QUESTS) { return; } if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initializing ..."); } #region defineNPCS GameNPC[] npcs = WorldMgr.GetNPCsByName("Guard Alakyrr", eRealm.None); if (npcs.Length == 0) { GuardAlakyrr = new DOL.GS.GameNPC(); GuardAlakyrr.Model = 748; GuardAlakyrr.Name = "Guard Alakyrr"; if (log.IsWarnEnabled) { log.Warn("Could not find " + GuardAlakyrr.Name + ", creating ..."); } GuardAlakyrr.GuildName = "Part of " + questTitle + " Quest"; GuardAlakyrr.Realm = eRealm.Albion; GuardAlakyrr.CurrentRegionID = 63; GuardAlakyrr.Size = 50; GuardAlakyrr.Level = 30; GuardAlakyrr.MaxSpeedBase = 191; GuardAlakyrr.Faction = FactionMgr.GetFactionByID(0); GuardAlakyrr.X = 28707; GuardAlakyrr.Y = 20147; GuardAlakyrr.Z = 16760; GuardAlakyrr.Heading = 4016; GuardAlakyrr.RespawnInterval = -1; GuardAlakyrr.BodyType = 0; StandardMobBrain brain = new StandardMobBrain(); brain.AggroLevel = 0; brain.AggroRange = 500; GuardAlakyrr.SetOwnBrain(brain); if (SAVE_INTO_DATABASE) { GuardAlakyrr.SaveIntoDatabase(); } GuardAlakyrr.AddToWorld(); } else { GuardAlakyrr = npcs[0]; } #endregion #region defineItems enchantedtenebrousflask = GameServer.Database.FindObjectByKey <ItemTemplate>("enchantedtenebrousflask"); if (enchantedtenebrousflask == null) { if (log.IsWarnEnabled) { log.Warn("Could not find Enchanted Tenebrous Flask, creating it ..."); } enchantedtenebrousflask = new ItemTemplate(); enchantedtenebrousflask.Name = "enchanted tenebrous flask"; enchantedtenebrousflask.Level = 1; enchantedtenebrousflask.Weight = 10; enchantedtenebrousflask.Model = 1610; enchantedtenebrousflask.Object_Type = (int)eObjectType.GenericItem; enchantedtenebrousflask.Id_nb = "enchantedtenebrousflask"; enchantedtenebrousflask.Price = 0; enchantedtenebrousflask.IsPickable = false; enchantedtenebrousflask.IsDropable = false; enchantedtenebrousflask.Quality = 100; enchantedtenebrousflask.Condition = 1000; enchantedtenebrousflask.MaxCondition = 1000; enchantedtenebrousflask.Durability = 1000; enchantedtenebrousflask.MaxDurability = 1000; GameServer.Database.AddObject(enchantedtenebrousflask); } quarterfulltenebrousflask = GameServer.Database.FindObjectByKey <ItemTemplate>("quarterfulltenebrousflask"); if (quarterfulltenebrousflask == null) { if (log.IsWarnEnabled) { log.Warn("Could not find Quarter Full Tenebrous Flask, creating it ..."); } quarterfulltenebrousflask = new ItemTemplate(); quarterfulltenebrousflask.Name = "quarter full tenebrous flask"; quarterfulltenebrousflask.Level = 1; quarterfulltenebrousflask.Weight = 250; quarterfulltenebrousflask.Model = 1610; quarterfulltenebrousflask.Object_Type = (int)eObjectType.GenericItem; quarterfulltenebrousflask.Id_nb = "quarterfulltenebrousflask"; quarterfulltenebrousflask.Price = 0; quarterfulltenebrousflask.IsPickable = false; quarterfulltenebrousflask.IsDropable = false; quarterfulltenebrousflask.Quality = 100; quarterfulltenebrousflask.Condition = 1000; quarterfulltenebrousflask.MaxCondition = 1000; quarterfulltenebrousflask.Durability = 1000; quarterfulltenebrousflask.MaxDurability = 1000; GameServer.Database.AddObject(quarterfulltenebrousflask); } halffulltenebrousflask = GameServer.Database.FindObjectByKey <ItemTemplate>("halffulltenebrousflask"); if (halffulltenebrousflask == null) { if (log.IsWarnEnabled) { log.Warn("Could not find Half Full Tenebrous Flask, creating it ..."); } halffulltenebrousflask = new ItemTemplate(); halffulltenebrousflask.Name = "half full tenebrous flask"; halffulltenebrousflask.Level = 1; halffulltenebrousflask.Weight = 250; halffulltenebrousflask.Model = 1610; halffulltenebrousflask.Object_Type = (int)eObjectType.GenericItem; halffulltenebrousflask.Id_nb = "halffulltenebrousflask"; halffulltenebrousflask.Price = 0; halffulltenebrousflask.IsPickable = false; halffulltenebrousflask.IsDropable = false; halffulltenebrousflask.Quality = 100; halffulltenebrousflask.Condition = 1000; halffulltenebrousflask.MaxCondition = 1000; halffulltenebrousflask.Durability = 1000; halffulltenebrousflask.MaxDurability = 1000; GameServer.Database.AddObject(halffulltenebrousflask); } threequarterfulltenebrousflask = GameServer.Database.FindObjectByKey <ItemTemplate>("threequarterfulltenebrousflask"); if (threequarterfulltenebrousflask == null) { if (log.IsWarnEnabled) { log.Warn("Could not find Three Quarter Full Tenebrous Flask, creating it ..."); } threequarterfulltenebrousflask = new ItemTemplate(); threequarterfulltenebrousflask.Name = "three quarter full tenebrous flask"; threequarterfulltenebrousflask.Level = 1; threequarterfulltenebrousflask.Weight = 250; threequarterfulltenebrousflask.Model = 1610; threequarterfulltenebrousflask.Object_Type = (int)eObjectType.GenericItem; threequarterfulltenebrousflask.Id_nb = "threequarterfulltenebrousflask"; threequarterfulltenebrousflask.Price = 0; threequarterfulltenebrousflask.IsPickable = false; threequarterfulltenebrousflask.IsDropable = false; threequarterfulltenebrousflask.Quality = 100; threequarterfulltenebrousflask.Condition = 1000; threequarterfulltenebrousflask.MaxCondition = 1000; threequarterfulltenebrousflask.Durability = 1000; threequarterfulltenebrousflask.MaxDurability = 1000; GameServer.Database.AddObject(threequarterfulltenebrousflask); } fullflaskoftenebrousessence = GameServer.Database.FindObjectByKey <ItemTemplate>("fullflaskoftenebrousessence"); if (fullflaskoftenebrousessence == null) { if (log.IsWarnEnabled) { log.Warn("Could not find Full Flask Of Tenebrous Essence, creating it ..."); } fullflaskoftenebrousessence = new ItemTemplate(); fullflaskoftenebrousessence.Name = "full flask of tenebrous essence"; fullflaskoftenebrousessence.Level = 1; fullflaskoftenebrousessence.Weight = 250; fullflaskoftenebrousessence.Model = 1610; fullflaskoftenebrousessence.Object_Type = (int)eObjectType.GenericItem; fullflaskoftenebrousessence.Id_nb = "fullflaskoftenebrousessence"; fullflaskoftenebrousessence.Price = 0; fullflaskoftenebrousessence.IsPickable = false; fullflaskoftenebrousessence.IsDropable = false; fullflaskoftenebrousessence.Quality = 100; fullflaskoftenebrousessence.Condition = 1000; fullflaskoftenebrousessence.MaxCondition = 1000; fullflaskoftenebrousessence.Durability = 1000; fullflaskoftenebrousessence.MaxDurability = 1000; GameServer.Database.AddObject(fullflaskoftenebrousessence); } #endregion GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest)); GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest)); GameEventMgr.AddHandler(GamePlayerEvent.GameEntered, new DOLEventHandler(PlayerEnterWorld)); GameEventMgr.AddHandler(GuardAlakyrr, GameLivingEvent.Interact, new DOLEventHandler(TalkToGuardAlakyrr)); GameEventMgr.AddHandler(GuardAlakyrr, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToGuardAlakyrr)); GuardAlakyrr.AddQuestToGive(typeof(AidingGuardAlakyrr)); if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initialized"); } }
public override bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool quiet) { if (!base.IsAllowedToAttack(attacker, defender, quiet)) { return(false); } // if controlled NPC - do checks for owner instead if (attacker is GameNPC) { IControlledBrain controlled = ((GameNPC)attacker).Brain as IControlledBrain; if (controlled != null) { attacker = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (defender is GameNPC) { IControlledBrain controlled = ((GameNPC)defender).Brain as IControlledBrain; if (controlled != null) { defender = controlled.GetLivingOwner(); } } // can't attack self if (attacker == defender) { if (quiet == false) { MessageToLiving(attacker, "You can't attack yourself!"); } return(false); } //ogre: sometimes other players shouldn't be attackable GamePlayer playerAttacker = attacker as GamePlayer; GamePlayer playerDefender = defender as GamePlayer; if (playerAttacker != null && playerDefender != null) { //check group if (playerAttacker.Group != null && playerAttacker.Group.IsInTheGroup(playerDefender)) { if (!quiet) { MessageToLiving(playerAttacker, "You can't attack your group members."); } return(false); } if (playerAttacker.DuelTarget != defender) { //check guild if (playerAttacker.Guild != null && playerAttacker.Guild == playerDefender.Guild) { if (!quiet) { MessageToLiving(playerAttacker, "You can't attack your guild members."); } return(false); } // Player can't hit other members of the same BattleGroup BattleGroup mybattlegroup = (BattleGroup)playerAttacker.TempProperties.getProperty <object>(BattleGroup.BATTLEGROUP_PROPERTY, null); if (mybattlegroup != null && mybattlegroup.IsInTheBattleGroup(playerDefender)) { if (!quiet) { MessageToLiving(playerAttacker, "You can't attack a member of your battlegroup."); } return(false); } // Safe regions if (m_safeRegions != null) { foreach (int reg in m_safeRegions) { if (playerAttacker.CurrentRegionID == reg) { if (quiet == false) { MessageToLiving(playerAttacker, "You're currently in a safe zone, you can't attack other players here."); } return(false); } } } // Players with safety flag can not attack other players if (playerAttacker.Level < m_safetyLevel && playerAttacker.SafetyFlag) { if (quiet == false) { MessageToLiving(attacker, "Your PvP safety flag is ON."); } return(false); } // Players with safety flag can not be attacked in safe regions if (playerDefender.Level < m_safetyLevel && playerDefender.SafetyFlag) { bool unsafeRegion = false; foreach (int regionID in m_unsafeRegions) { if (regionID == playerDefender.CurrentRegionID) { unsafeRegion = true; break; } } if (unsafeRegion == false) { //"PLAYER has his safety flag on and is in a safe area, you can't attack him here." if (quiet == false) { MessageToLiving(attacker, playerDefender.Name + " has " + playerDefender.GetPronoun(1, false) + " safety flag on and is in a safe area, you can't attack " + playerDefender.GetPronoun(2, false) + " here."); } return(false); } } } } if (attacker.Realm == 0 && defender.Realm == 0) { return(FactionMgr.CanLivingAttack(attacker, defender)); } //allow confused mobs to attack same realm if (attacker is GameNPC && (attacker as GameNPC).IsConfused && attacker.Realm == defender.Realm) { return(true); } // "friendly" NPCs can't attack "friendly" players if (defender is GameNPC && defender.Realm != 0 && attacker.Realm != 0 && defender is GameKeepGuard == false && defender is GameFont == false) { if (quiet == false) { MessageToLiving(attacker, "You can't attack a friendly NPC!"); } return(false); } // "friendly" NPCs can't be attacked by "friendly" players if (attacker is GameNPC && attacker.Realm != 0 && defender.Realm != 0 && attacker is GameKeepGuard == false) { return(false); } #region Keep Guards //guard vs guard / npc if (attacker is GameKeepGuard) { if (defender is GameKeepGuard) { return(false); } if (defender is GameNPC && (defender as GameNPC).Brain is IControlledBrain == false) { return(false); } } //player vs guard if (defender is GameKeepGuard && attacker is GamePlayer && GameServer.KeepManager.IsEnemy(defender as GameKeepGuard, attacker as GamePlayer) == false) { if (quiet == false) { MessageToLiving(attacker, "You can't attack a friendly NPC!"); } return(false); } //guard vs player if (attacker is GameKeepGuard && defender is GamePlayer && GameServer.KeepManager.IsEnemy(attacker as GameKeepGuard, defender as GamePlayer) == false) { return(false); } #endregion return(true); }
public void OnCommand(GameClient client, string[] args) { if (args.Length < 2) { DisplaySyntax(client); return; } Faction myfaction = (Faction)client.Player.TempProperties.getProperty <object>(TEMP_FACTION_LAST, null); switch (args[1]) { case "create": { if (args.Length < 4) { DisplaySyntax(client); return; } string name = args[2]; int baseAggro = 0; try { baseAggro = Convert.ToInt32(args[3]); } catch { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.Create.BAMustBeNumber"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } int max = 0; // Log.Info("count:" + FactionMgr.Factions.Count.ToString()); if (FactionMgr.Factions.Count != 0) { // Log.Info("count >0"); IEnumerator enumerator = FactionMgr.Factions.Keys.GetEnumerator(); while (enumerator.MoveNext()) { // Log.Info("max :" + max + " et current :" + (int)enumerator.Current); max = System.Math.Max(max, (int)enumerator.Current); } } // Log.Info("max :" + max); DBFaction dbfaction = new DBFaction(); dbfaction.BaseAggroLevel = baseAggro; dbfaction.Name = name; dbfaction.ID = max + 1; // Log.Info("add obj to db with id :" + dbfaction.ID); GameServer.Database.AddObject(dbfaction); // Log.Info("add obj to db"); myfaction = new Faction(); myfaction.LoadFromDatabase(dbfaction); FactionMgr.Factions.Add(dbfaction.ID, myfaction); client.Player.TempProperties.setProperty(TEMP_FACTION_LAST, myfaction); client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.Create.NewCreated"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); } break; case "assign": { if (myfaction == null) { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.MustSelectFaction"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } GameNPC npc = client.Player.TargetObject as GameNPC; if (npc == null) { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.Assign.MustSelectMob"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } npc.Faction = myfaction; client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.Assign.MobHasJoinedFact", npc.Name, myfaction.Name), eChatType.CT_Say, eChatLoc.CL_SystemWindow); } break; case "addfriend": { if (myfaction == null) { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.MustSelectFaction"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } if (args.Length < 3) { DisplaySyntax(client); return; } int id = 0; try { id = Convert.ToInt32(args[2]); } catch { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.IndexMustBeNumber"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } Faction linkedfaction = FactionMgr.GetFactionByID(id); if (linkedfaction == null) { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.FactionNotLoaded"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } DBLinkedFaction dblinkedfaction = new DBLinkedFaction(); dblinkedfaction.FactionID = myfaction.ID; dblinkedfaction.LinkedFactionID = linkedfaction.ID; dblinkedfaction.IsFriend = true; GameServer.Database.AddObject(dblinkedfaction); myfaction.AddFriendFaction(linkedfaction); } break; case "addenemy": { if (myfaction == null) { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.MustSelectFaction"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } if (args.Length < 3) { DisplaySyntax(client); return; } int id = 0; try { id = Convert.ToInt32(args[2]); } catch { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.IndexMustBeNumber"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } Faction linkedfaction = FactionMgr.GetFactionByID(id); if (linkedfaction == null) { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.FactionNotLoaded"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } DBLinkedFaction dblinkedfaction = new DBLinkedFaction(); dblinkedfaction.FactionID = myfaction.ID; dblinkedfaction.LinkedFactionID = linkedfaction.ID; dblinkedfaction.IsFriend = false; GameServer.Database.AddObject(dblinkedfaction); myfaction.AddEnemyFaction(linkedfaction); } break; case "list": { foreach (Faction faction in FactionMgr.Factions.Values) { client.Player.Out.SendMessage("#" + faction.ID.ToString() + ": " + faction.Name + " (" + faction.BaseAggroLevel + ")", eChatType.CT_Say, eChatLoc.CL_SystemWindow); } return; } case "select": { if (args.Length < 3) { DisplaySyntax(client); return; } int id = 0; try { id = Convert.ToInt32(args[2]); } catch { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.IndexMustBeNumber"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } Faction tempfaction = FactionMgr.GetFactionByID(id); if (tempfaction == null) { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Faction.FactionNotLoaded"), eChatType.CT_Say, eChatLoc.CL_SystemWindow); return; } client.Player.TempProperties.setProperty(TEMP_FACTION_LAST, tempfaction); } break; default: { DisplaySyntax(client); return; } } }
public MailError SendMail(string recipientName, string subject, string body, MailStationary stationary, ICollection <Item> items, uint money, uint cod) { FactionGroup recipientFaction; int recipientMailCount; // Find and verify the recipient var normalizedName = recipientName; var recipient = World.GetCharacter(normalizedName, false); CharacterRecord recipientRecord; if (recipient != null) { // receiving character is online, get info from the character object recipientFaction = recipient.Faction.Group; recipientMailCount = recipient.MailAccount.AllMail.Count; recipientRecord = recipient.Record; } else { // no character online with that name, get info from the CharacterRecord var charRecord = CharacterRecord.GetRecordByName(normalizedName); if (charRecord == null) { MailHandler.SendResult(m_chr.Client, 0, MailResult.MailSent, MailError.RECIPIENT_NOT_FOUND); return(MailError.RECIPIENT_NOT_FOUND); } recipientFaction = FactionMgr.GetFactionGroup(charRecord.Race); recipientMailCount = charRecord.MailCount; recipientRecord = charRecord; } if (!m_chr.GodMode) { if (stationary == MailStationary.GM) { MailHandler.SendResult(m_chr.Client, 0, MailResult.MailSent, MailError.INTERNAL_ERROR); return(MailError.INTERNAL_ERROR); } // Can't send to people who ignore you if (RelationMgr.IsIgnoring(recipientRecord.EntityLowId, m_chr.EntityId.Low)) { MailHandler.SendResult(m_chr.Client, 0, MailResult.MailSent, MailError.RECIPIENT_NOT_FOUND); return(MailError.RECIPIENT_NOT_FOUND); } // Can't send mail to people on the other team if (!MailMgr.AllowInterFactionMail && !m_chr.GodMode) { if (recipientFaction != m_chr.Faction.Group) { MailHandler.SendResult(m_chr, 0u, MailResult.MailSent, MailError.NOT_YOUR_ALLIANCE); return(MailError.NOT_YOUR_ALLIANCE); } } // Check that the recipient can recieve more mail. if (recipientMailCount > MailMgr.MaxMailCount) { MailHandler.SendResult(m_chr, 0u, MailResult.MailSent, MailError.RECIPIENT_CAP_REACHED); return(MailError.RECIPIENT_CAP_REACHED); } } return(SendMail(recipientRecord, subject, body, stationary, items, money, cod)); }
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args) { if (!ServerProperties.Properties.LOAD_QUESTS) { return; } if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initializing ..."); } GameNPC[] npcs; npcs = WorldMgr.GetObjectsByName <GameNPC>(LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.NPCKreimhilde"), (eRealm)2); if (npcs.Length == 0) { VikingKreimhilde = new DOL.GS.GameNPC(); VikingKreimhilde.Model = 218; VikingKreimhilde.Name = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.NPCKreimhilde"); if (log.IsWarnEnabled) { log.Warn("Could not find " + VikingKreimhilde.Name + ", creating ..."); } VikingKreimhilde.GuildName = "Part of " + questTitle + " Quest"; VikingKreimhilde.Realm = eRealm.Midgard; VikingKreimhilde.CurrentRegionID = 100; VikingKreimhilde.Size = 51; VikingKreimhilde.Level = 50; VikingKreimhilde.MaxSpeedBase = 191; VikingKreimhilde.Faction = FactionMgr.GetFactionByID(0); VikingKreimhilde.X = 803999; VikingKreimhilde.Y = 726551; VikingKreimhilde.Z = 4752; VikingKreimhilde.Heading = 2116; VikingKreimhilde.RespawnInterval = -1; VikingKreimhilde.BodyType = 0; StandardMobBrain brain = new StandardMobBrain(); brain.AggroLevel = 0; brain.AggroRange = 500; VikingKreimhilde.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) { VikingKreimhilde.SaveIntoDatabase(); } VikingKreimhilde.AddToWorld(); } else { VikingKreimhilde = npcs[0]; } silverringofhealth = GameServer.Database.FindObjectByKey <ItemTemplate>("silverringofhealth"); if (silverringofhealth == null) { silverringofhealth = new ItemTemplate(); silverringofhealth.Name = "Silver Ring of Health"; if (log.IsWarnEnabled) { log.Warn("Could not find " + silverringofhealth.Name + ", creating it ..."); } silverringofhealth.Level = 5; silverringofhealth.Weight = 5; silverringofhealth.Model = 103; silverringofhealth.Object_Type = 0; silverringofhealth.Item_Type = 35; silverringofhealth.Id_nb = "silverringofhealth"; silverringofhealth.Hand = 0; silverringofhealth.Price = 0; silverringofhealth.IsPickable = true; silverringofhealth.IsDropable = true; silverringofhealth.IsTradable = false; silverringofhealth.CanDropAsLoot = false; silverringofhealth.Color = 0; silverringofhealth.Bonus = 5; // default bonus silverringofhealth.Bonus1 = 12; silverringofhealth.Bonus1Type = (int)10; silverringofhealth.Bonus2 = 0; silverringofhealth.Bonus2Type = (int)0; silverringofhealth.Bonus3 = 0; silverringofhealth.Bonus3Type = (int)0; silverringofhealth.Bonus4 = 0; silverringofhealth.Bonus4Type = (int)0; silverringofhealth.Bonus5 = 0; silverringofhealth.Bonus5Type = (int)0; silverringofhealth.Bonus6 = 0; silverringofhealth.Bonus6Type = (int)0; silverringofhealth.Bonus7 = 0; silverringofhealth.Bonus7Type = (int)0; silverringofhealth.Bonus8 = 0; silverringofhealth.Bonus8Type = (int)0; silverringofhealth.Bonus9 = 0; silverringofhealth.Bonus9Type = (int)0; silverringofhealth.Bonus10 = 0; silverringofhealth.Bonus10Type = (int)0; silverringofhealth.ExtraBonus = 0; silverringofhealth.ExtraBonusType = (int)0; silverringofhealth.Effect = 0; silverringofhealth.Emblem = 0; silverringofhealth.Charges = 0; silverringofhealth.MaxCharges = 0; silverringofhealth.SpellID = 0; silverringofhealth.ProcSpellID = 0; silverringofhealth.Type_Damage = 0; silverringofhealth.Realm = 0; silverringofhealth.MaxCount = 1; silverringofhealth.PackSize = 1; silverringofhealth.Extension = 0; silverringofhealth.Quality = 100; silverringofhealth.Condition = 100; silverringofhealth.MaxCondition = 100; silverringofhealth.Durability = 100; silverringofhealth.MaxDurability = 100; silverringofhealth.PoisonCharges = 0; silverringofhealth.PoisonMaxCharges = 0; silverringofhealth.PoisonSpellID = 0; silverringofhealth.ProcSpellID1 = 0; silverringofhealth.SpellID1 = 0; silverringofhealth.MaxCharges1 = 0; silverringofhealth.Charges1 = 0; GameServer.Database.AddObject(silverringofhealth); } blackmaulercubpelt = GameServer.Database.FindObjectByKey <ItemTemplate>("blackmaulercubpelt"); if (blackmaulercubpelt == null) { blackmaulercubpelt = new ItemTemplate(); blackmaulercubpelt.Name = "Black Mauler Cub Pelt"; if (log.IsWarnEnabled) { log.Warn("Could not find " + blackmaulercubpelt.Name + ", creating it ..."); } blackmaulercubpelt.Level = 1; blackmaulercubpelt.Weight = 5; blackmaulercubpelt.Model = 100; blackmaulercubpelt.Object_Type = 0; blackmaulercubpelt.Item_Type = 40; blackmaulercubpelt.Id_nb = "blackmaulercubpelt"; blackmaulercubpelt.Hand = 0; blackmaulercubpelt.Price = 0; blackmaulercubpelt.IsPickable = true; blackmaulercubpelt.IsDropable = true; blackmaulercubpelt.IsTradable = true; blackmaulercubpelt.CanDropAsLoot = false; blackmaulercubpelt.Color = 0; blackmaulercubpelt.Bonus = 35; // default bonus blackmaulercubpelt.Bonus1 = 0; blackmaulercubpelt.Bonus1Type = (int)0; blackmaulercubpelt.Bonus2 = 0; blackmaulercubpelt.Bonus2Type = (int)0; blackmaulercubpelt.Bonus3 = 0; blackmaulercubpelt.Bonus3Type = (int)0; blackmaulercubpelt.Bonus4 = 0; blackmaulercubpelt.Bonus4Type = (int)0; blackmaulercubpelt.Bonus5 = 0; blackmaulercubpelt.Bonus5Type = (int)0; blackmaulercubpelt.Bonus6 = 0; blackmaulercubpelt.Bonus6Type = (int)0; blackmaulercubpelt.Bonus7 = 0; blackmaulercubpelt.Bonus7Type = (int)0; blackmaulercubpelt.Bonus8 = 0; blackmaulercubpelt.Bonus8Type = (int)0; blackmaulercubpelt.Bonus9 = 0; blackmaulercubpelt.Bonus9Type = (int)0; blackmaulercubpelt.Bonus10 = 0; blackmaulercubpelt.Bonus10Type = (int)0; blackmaulercubpelt.ExtraBonus = 0; blackmaulercubpelt.ExtraBonusType = (int)0; blackmaulercubpelt.Effect = 0; blackmaulercubpelt.Emblem = 0; blackmaulercubpelt.Charges = 0; blackmaulercubpelt.MaxCharges = 0; blackmaulercubpelt.SpellID = 0; blackmaulercubpelt.ProcSpellID = 0; blackmaulercubpelt.Type_Damage = 0; blackmaulercubpelt.Realm = 0; blackmaulercubpelt.MaxCount = 1; blackmaulercubpelt.PackSize = 1; blackmaulercubpelt.Extension = 0; blackmaulercubpelt.Quality = 99; blackmaulercubpelt.Condition = 100; blackmaulercubpelt.MaxCondition = 100; blackmaulercubpelt.Durability = 100; blackmaulercubpelt.MaxDurability = 100; blackmaulercubpelt.PoisonCharges = 0; blackmaulercubpelt.PoisonMaxCharges = 0; blackmaulercubpelt.PoisonSpellID = 0; blackmaulercubpelt.ProcSpellID1 = 0; blackmaulercubpelt.SpellID1 = 0; blackmaulercubpelt.MaxCharges1 = 0; blackmaulercubpelt.Charges1 = 0; GameServer.Database.AddObject(blackmaulercubpelt); } QuestBuilder builder = QuestMgr.GetBuilder(typeof(Abearybadproblem)); QuestBehaviour a; a = builder.CreateBehaviour(VikingKreimhilde, -1); a.AddTrigger(eTriggerType.Interact, null, VikingKreimhilde); a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), VikingKreimhilde); a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), null, (eComparator)5); a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.Talk1"), VikingKreimhilde); a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.Talk2"), VikingKreimhilde); a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.Talk3"), VikingKreimhilde); a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.Talk4"), VikingKreimhilde); a.AddAction(eActionType.OfferQuest, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.OfferQuest")); AddBehaviour(a); a = builder.CreateBehaviour(VikingKreimhilde, -1); a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.Abearybadproblem)); a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), VikingKreimhilde); a.AddAction(eActionType.SetQuestStep, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), 1); AddBehaviour(a); a = builder.CreateBehaviour(VikingKreimhilde, -1); a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.Abearybadproblem)); AddBehaviour(a); a = builder.CreateBehaviour(VikingKreimhilde, -1); a.AddTrigger(eTriggerType.EnemyKilled, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.EnemyKilled"), null); a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), 1, (eComparator)3); a.AddAction(eActionType.GiveItem, blackmaulercubpelt, null); a.AddAction(eActionType.SetQuestStep, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), 2); AddBehaviour(a); a = builder.CreateBehaviour(VikingKreimhilde, -1); a.AddTrigger(eTriggerType.Interact, null, VikingKreimhilde); a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), 2, (eComparator)3); a.AddAction(eActionType.Talk, LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Mid.ABearyBadProblem.GoodJob"), VikingKreimhilde); a.AddAction(eActionType.GiveXP, 22, null); a.AddAction(eActionType.GiveGold, 23, null); a.AddAction(eActionType.TakeItem, blackmaulercubpelt, null); a.AddAction(eActionType.GiveItem, silverringofhealth, VikingKreimhilde); a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.Abearybadproblem), null); AddBehaviour(a); // Custom Scriptloaded Code Begin // Custom Scriptloaded Code End VikingKreimhilde.AddQuestToGive(typeof(Abearybadproblem)); if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initialized"); } }
/// <summary> /// Is called to initialize the object; usually after a set of other operations have been performed or if /// the right time has come and other required steps have been performed. /// </summary> public void FinalizeDataHolder() { if (string.IsNullOrEmpty(DefaultName)) { ContentMgr.OnInvalidDBData("NPCEntry has no name: " + this); return; } if (Titles == null) { Titles = new string[(int)ClientLocale.End]; } if (DefaultTitle == null) { DefaultTitle = ""; } if (SpellGroupId != 0 && NPCMgr.PetSpells != null) { var spells = NPCMgr.PetSpells.Get(SpellGroupId) ?? Spell.EmptyArray; foreach (var spell in spells) { AddSpell(spell); } } if (MinMana > MaxMana) { MaxMana = MinMana; } if (MaxDamage > 0) { if (MinDamage < 1) { MinDamage = 1; } if (MaxDamage < MinDamage) { MaxDamage = MinDamage; } } if (RangedMaxDamage > 0 && RangedMinDamage > 0) { if (RangedMaxDamage < RangedMinDamage) { RangedMaxDamage = RangedMinDamage; } if (RangedAttackTime == 0) { RangedAttackTime = AttackTime; } } AggroBaseRange = AggroBaseRangeDefault; NPCId = (NPCId)Id; DefaultDecayDelayMillis = _DefaultDecayDelayMillis; Family = NPCMgr.GetFamily(FamilyId); if (Type == CreatureType.NotSpecified || VehicleEntry != null) { IsIdle = true; } if (Type == CreatureType.NotSpecified && UnitFlags.HasFlag((UnitFlags.Passive | UnitFlags.NotSelectable))) { IsEventTrigger = true; IsIdle = false; } if (Resistances == null) { Resistances = new int[ItemConstants.MaxResCount]; } SetFlagIndices = Utility.GetSetIndices((uint)NPCFlags); // set/fix factions HordeFaction = FactionMgr.Get(HordeFactionId); AllianceFaction = FactionMgr.Get(AllianceFactionId); if (HordeFaction == null) { HordeFaction = AllianceFaction; HordeFactionId = AllianceFactionId; } else if (AllianceFaction == null) { AllianceFaction = HordeFaction; AllianceFactionId = HordeFactionId; } if (AllianceFaction == null) { ContentMgr.OnInvalidDBData("NPCEntry has no valid Faction: " + this); HordeFaction = AllianceFaction = NPCMgr.DefaultFaction; HordeFactionId = AllianceFactionId = (FactionTemplateId)HordeFaction.Template.Id; } // speeds if (SpeedFactor < 0.01) { SpeedFactor = 1; } if (WalkSpeed == 0) { WalkSpeed = NPCMgr.DefaultNPCWalkSpeed * SpeedFactor; } if (RunSpeed == 0) { RunSpeed = NPCMgr.DefaultNPCRunSpeed * SpeedFactor; } if (FlySpeed == 0) { FlySpeed = NPCMgr.DefaultNPCFlySpeed * SpeedFactor; } // Add all default spells if (FixedSpells != null) { foreach (var spell in FixedSpells) { AddSpell(spell); } } InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this); SpawnTypeHandlers = NPCMgr.GetNPCSpawnTypeHandlers(this); //ArrayUtil.PruneVals(ref DisplayIds); if (EquipmentId != 0) { Equipment = NPCMgr.GetEquipment(EquipmentId); } ModelInfos = new UnitModelInfo[DisplayIds.Length]; GeneratesXp = (Type != CreatureType.Critter && Type != CreatureType.None && !ExtraFlags.HasFlag(UnitExtraFlags.NoXP)); var x = 0; for (var i = 0; i < DisplayIds.Length; i++) { var did = DisplayIds[i]; if (did > 0) { var model = UnitMgr.GetModelInfo(did); if (model != null) { ModelInfos[x++] = model; } } } if (x == 0) { ContentMgr.OnInvalidDBData("NPCEntry has no valid DisplayId: {0} ({1})", this, DisplayIds.ToString(", ")); return; } if (TrainerTemplateId != 0) { if (!NPCMgr.TrainerSpellTemplates.ContainsKey(TrainerTemplateId)) { ContentMgr.OnInvalidDBData("NPCEntry has invalid TrainerTemplateId: {0} ({1})", this, TrainerTemplateId); } else { if (TrainerEntry == null) { TrainerEntry = new TrainerEntry(); } foreach (var trainerSpell in NPCMgr.TrainerSpellTemplates[TrainerTemplateId]) { TrainerEntry.AddSpell(trainerSpell); } } } if (AddonData != null) { AddonData.InitAddonData(this); } if (x < ModelInfos.Length) { Array.Resize(ref ModelInfos, x); } // add to container if (Id < NPCMgr.Entries.Length) { NPCMgr.Entries[Id] = this; } else { NPCMgr.CustomEntries[Id] = this; } ++NPCMgr.EntryCount; if (BrainCreator == null) { BrainCreator = DefaultBrainCreator; } if (NPCCreator == null) { NPCCreator = DefaultCreator; } }
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args) { if (!ServerProperties.Properties.LOAD_QUESTS) { return; } if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initializing ..."); } GameNPC[] npcs; npcs = WorldMgr.GetObjectsByName <GameNPC>("Aegan", (eRealm)2); if (npcs.Length == 0) { Aegan = new DOL.GS.GameNPC(); Aegan.Model = 232; Aegan.Name = "Aegan"; if (log.IsWarnEnabled) { log.Warn("Could not find " + Aegan.Name + ", creating ..."); } Aegan.GuildName = "Part of " + questTitle + " Quest"; Aegan.Realm = eRealm.Midgard; Aegan.CurrentRegionID = 100; Aegan.Size = 51; Aegan.Level = 41; Aegan.MaxSpeedBase = 191; Aegan.Faction = FactionMgr.GetFactionByID(0); Aegan.X = 805398; Aegan.Y = 725829; Aegan.Z = 4700; Aegan.Heading = 3595; Aegan.RespawnInterval = -1; Aegan.BodyType = 0; StandardMobBrain brain = new StandardMobBrain(); brain.AggroLevel = 0; brain.AggroRange = 500; Aegan.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) { Aegan.SaveIntoDatabase(); } Aegan.AddToWorld(); } else { Aegan = npcs[0]; } clawofblackmauler = GameServer.Database.FindObjectByKey <ItemTemplate>("clawofblackmauler"); if (clawofblackmauler == null) { clawofblackmauler = new ItemTemplate(); clawofblackmauler.Name = "Claw of Black Mauler"; if (log.IsWarnEnabled) { log.Warn("Could not find " + clawofblackmauler.Name + ", creating it ..."); } clawofblackmauler.Level = 50; clawofblackmauler.Weight = 5; clawofblackmauler.Model = 1; clawofblackmauler.Object_Type = 0; clawofblackmauler.Item_Type = 40; clawofblackmauler.Id_nb = "clawofblackmauler"; clawofblackmauler.Hand = 0; clawofblackmauler.Price = 0; clawofblackmauler.IsPickable = true; clawofblackmauler.IsDropable = true; clawofblackmauler.IsTradable = true; clawofblackmauler.CanDropAsLoot = false; clawofblackmauler.Color = 0; clawofblackmauler.Bonus = 35; // default bonus clawofblackmauler.Bonus1 = 0; clawofblackmauler.Bonus1Type = (int)0; clawofblackmauler.Bonus2 = 0; clawofblackmauler.Bonus2Type = (int)0; clawofblackmauler.Bonus3 = 0; clawofblackmauler.Bonus3Type = (int)0; clawofblackmauler.Bonus4 = 0; clawofblackmauler.Bonus4Type = (int)0; clawofblackmauler.Bonus5 = 0; clawofblackmauler.Bonus5Type = (int)0; clawofblackmauler.Bonus6 = 0; clawofblackmauler.Bonus6Type = (int)0; clawofblackmauler.Bonus7 = 0; clawofblackmauler.Bonus7Type = (int)0; clawofblackmauler.Bonus8 = 0; clawofblackmauler.Bonus8Type = (int)0; clawofblackmauler.Bonus9 = 0; clawofblackmauler.Bonus9Type = (int)0; clawofblackmauler.Bonus10 = 0; clawofblackmauler.Bonus10Type = (int)0; clawofblackmauler.ExtraBonus = 0; clawofblackmauler.ExtraBonusType = (int)0; clawofblackmauler.Effect = 0; clawofblackmauler.Emblem = 0; clawofblackmauler.Charges = 0; clawofblackmauler.MaxCharges = 0; clawofblackmauler.SpellID = 0; clawofblackmauler.ProcSpellID = 0; clawofblackmauler.Type_Damage = 0; clawofblackmauler.Realm = 0; clawofblackmauler.MaxCount = 1; clawofblackmauler.PackSize = 1; clawofblackmauler.Extension = 0; clawofblackmauler.Quality = 99; clawofblackmauler.Condition = 100; clawofblackmauler.MaxCondition = 100; clawofblackmauler.Durability = 100; clawofblackmauler.MaxDurability = 100; clawofblackmauler.PoisonCharges = 0; clawofblackmauler.PoisonMaxCharges = 0; clawofblackmauler.PoisonSpellID = 0; clawofblackmauler.ProcSpellID1 = 0; clawofblackmauler.SpellID1 = 0; clawofblackmauler.MaxCharges1 = 0; clawofblackmauler.Charges1 = 0; // You don't have to store the created item in the db if you don't want, // it will be recreated each time it is not found, just comment the following // line if you rather not modify your database if (SAVE_INTO_DATABASE) { GameServer.Database.AddObject(clawofblackmauler); } } QuestBuilder builder = QuestMgr.GetBuilder(typeof(Learnthehunt)); QuestBehaviour a; a = builder.CreateBehaviour(Aegan, -1); a.AddTrigger(eTriggerType.Interact, null, Aegan); a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.Learnthehunt), Aegan); a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.Learnthehunt), null, (eComparator)5); a.AddAction(eActionType.Talk, "Greetings, are you [worthy of the hunt]?", Aegan); AddBehaviour(a); a = builder.CreateBehaviour(Aegan, -1); a.AddTrigger(eTriggerType.Whisper, "worthy of the hunt", Aegan); a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.Learnthehunt), Aegan); a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.Learnthehunt), null, (eComparator)5); a.AddAction(eActionType.Talk, "Oh ho! Another bright young come to help Midgard fend off her enemies, eh? Wonderful, that's what I say! Wonderful! With the rise of the Albion and Hibernia armies,Midgard will need all the she can get!", Aegan); a.AddAction(eActionType.Talk, "I have spent a great deal of my life hunting the [maulers] of this region", Aegan); AddBehaviour(a); a = builder.CreateBehaviour(Aegan, -1); a.AddTrigger(eTriggerType.Whisper, "maulers", Aegan); a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.Learnthehunt), Aegan); a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.Learnthehunt), null, (eComparator)5); a.AddAction(eActionType.Talk, "Bring me the claws of a mauler cub and I shall reward you", Aegan); a.AddAction(eActionType.OfferQuest, typeof(DOL.GS.Quests.Midgard.Learnthehunt), "Accept Learn the Hunt quest?"); AddBehaviour(a); a = builder.CreateBehaviour(Aegan, -1); a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.Learnthehunt)); a.AddAction(eActionType.Talk, "No problem. See you.", Aegan); AddBehaviour(a); a = builder.CreateBehaviour(Aegan, -1); a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.Learnthehunt)); a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.Learnthehunt), Aegan); a.AddAction(eActionType.SetQuestStep, typeof(DOL.GS.Quests.Midgard.Learnthehunt), 2); AddBehaviour(a); a = builder.CreateBehaviour(Aegan, -1); a.AddTrigger(eTriggerType.EnemyKilled, "black mauler cub", null); a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.Learnthehunt), 1, (eComparator)2); a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.Learnthehunt), 7, (eComparator)1); a.AddAction(eActionType.GiveItem, clawofblackmauler, null); a.AddAction(eActionType.IncQuestStep, typeof(DOL.GS.Quests.Midgard.Learnthehunt), null); AddBehaviour(a); a = builder.CreateBehaviour(Aegan, -1); a.AddTrigger(eTriggerType.Interact, null, Aegan); a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.Learnthehunt), 7, (eComparator)3); a.AddAction(eActionType.Talk, "You are doing well! Continue to pass me the bear claws!", Aegan); a.AddAction(eActionType.Talk, "You have proven yourself well youngster! I hope the coin serves you well.", Aegan); a.AddAction(eActionType.GiveXP, 20, null); a.AddAction(eActionType.GiveGold, 100, null); a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.Learnthehunt), null); a.AddAction(eActionType.TakeItem, clawofblackmauler, 5); AddBehaviour(a); // Custom Scriptloaded Code Begin // Custom Scriptloaded Code End Aegan.AddQuestToGive(typeof(Learnthehunt)); if (log.IsInfoEnabled) { log.Info("Quest \"" + questTitle + "\" initialized"); } }
public virtual void FinalizeDataHolder() { if (Id != 0) { GOId = (GOEntryId)Id; } else { Id = (uint)GOId; } if (FactionId != 0) { Faction = FactionMgr.Get(FactionId); } InitEntry(); // create GossipMenu if (GossipId != 0 && DefaultGossip == null) { var gossipEntry = GossipMgr.GetEntry(GossipId); if (gossipEntry == null) { ContentMgr.OnInvalidDBData("GOEntry {0} has missing GossipId: {1}", this, GossipId); DefaultGossip = new GossipMenu(); } else { DefaultGossip = new GossipMenu(GossipId); } } else if (QuestHolderInfo != null) { // Make sure, there is a gossip menu, so quests can be started/completed DefaultGossip = new GossipMenu(); } // set HandlerCreator if (HandlerCreator == null) { HandlerCreator = GOMgr.Handlers[(int)Type]; } if (GOCreator == null) { if (IsTransport) { GOCreator = () => new Transport(); } else { GOCreator = () => new GameObject(); } } if (Fields != null) // ignore invalid ones { //Fields = null; GOMgr.Entries[Id] = this; } }