Exemple #1
0
 public Faction(FactionId id, Dictionary<FactionId, Disposition> dispositions)
 {
     this.id = id;
     this.dispositions = dispositions;
     this.dispositions[id] = Disposition.Friendly; //Set self to friendly
     Reset();
 }
        private Dictionary <string, string> BuildReplacementArguments()
        {
            var replacementArguments = new Dictionary <string, string>();

            if (QuestId > 0)
            {
                replacementArguments.Add("QuestId", QuestId.ToString());
            }
            if (QuestRequirementComplete != QuestCompleteRequirement.NotComplete)
            {
                replacementArguments.Add("QuestCompleteRequirement", QuestRequirementComplete.ToString());
            }
            if (QuestRequirementInLog != QuestInLogRequirement.InLog)
            {
                replacementArguments.Add("QuestCompleteRequirement", QuestRequirementInLog.ToString());
            }
            if (MobId > 0)
            {
                replacementArguments.Add("MobId", MobId.ToString());
            }
            if (FactionId > 0)
            {
                replacementArguments.Add("FactionId", FactionId.ToString());
            }
            if (IsMoveToMob)
            {
                replacementArguments.Add("MovementBy", "ClickToMoveOnly");
            }

            return(replacementArguments);
        }
Exemple #3
0
 public static Faction Get(FactionId id)
 {
     if ((uint)id >= ById.Length)
     {
         return(null);
     }
     return(ById[(uint)id]);
 }
Exemple #4
0
 public SettlementRecord(int raceTypeId, int factionId, PointI locationHex, string name)
 {
     Id          = GameDataSequences.GetNextSequence("Settlement");
     RaceTypeId  = new RaceTypeId(raceTypeId);
     FactionId   = new FactionId(factionId);
     LocationHex = new LocationHex(locationHex);
     Name        = new Name(name);
 }
Exemple #5
0
 public SettlementRecord(SettlementRecord settlementRecord, FactionId factionId)
 {
     Id          = settlementRecord.Id;
     RaceTypeId  = settlementRecord.RaceTypeId;
     FactionId   = factionId;
     LocationHex = settlementRecord.LocationHex;
     Name        = settlementRecord.Name;
 }
Exemple #6
0
 public StackRecord(int factionId, PointI locationHex)
 {
     Id          = GameDataSequences.GetNextSequence("Stack");
     FactionId   = new FactionId(factionId);
     LocationHex = new LocationHex(locationHex);
     Status      = new Status(UnitStatus.None);
     HaveOrdersBeenGivenThisTurn = new HaveOrdersBeenGivenThisTurn(false);
 }
Exemple #7
0
 public Faction(FactionEntry entry, FactionTemplateEntry template)
 {
     Entry           = entry;
     Template        = template;
     Id              = entry.Id;
     ReputationIndex = entry.FactionIndex;
     IsAlliance      = template.FactionGroup.HasFlag(FactionGroupMask.Alliance);
     IsHorde         = template.FactionGroup.HasFlag(FactionGroupMask.Horde);
 }
Exemple #8
0
 /// <summary>
 /// Serves as a hash function for a <see cref="Army"/> object.
 /// </summary>
 /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
 /// hash table.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         return(((FactionId != null ? FactionId.GetHashCode() : 0) * 397) ^
                (UnitId != null ? UnitId.GetHashCode() : 0) ^
                Size.GetHashCode());
     }
 }
Exemple #9
0
 public Faction(FactionEntry entry, FactionTemplateEntry template)
 {
     this.Entry           = entry;
     this.Template        = template;
     this.Id              = entry.Id;
     this.ReputationIndex = entry.FactionIndex;
     this.IsAlliance      = template.FactionGroup.HasFlag((Enum)FactionGroupMask.Alliance);
     this.IsHorde         = template.FactionGroup.HasFlag((Enum)FactionGroupMask.Horde);
 }
Exemple #10
0
        public Faction(FactionEntry entry, FactionTemplateEntry template)
        {
            Entry = entry;
            Template = template;
            Id = entry.Id;
            ReputationIndex = entry.FactionIndex;

            IsAlliance = template.FactionGroup.HasFlag(FactionGroupMask.Alliance);
            IsHorde = template.FactionGroup.HasFlag(FactionGroupMask.Horde);
        }
Exemple #11
0
 public EntityDatabaseEntry(Entity entity)
 {
     this.entity = entity;
     this.enterCount = 1;
     this.exitCount = 0;
     this.disabled = false;
     this.destroyed = false;
     this.factionId = entity.factionId;
     this.size = entity.size;
     this.type = entity.type;
 }
Exemple #12
0
 public static FactionReputationIndex GetFactionIndex(FactionId id)
 {
     if ((uint)id < ByReputationIndex.Length)
     {
         var faction = ById[(uint)id];
         if (faction != null)
         {
             return(faction.ReputationIndex);
         }
     }
     return(0);
 }
Exemple #13
0
 /// <summary>
 /// Serves as a hash function for a <see cref="Province"/> object.
 /// </summary>
 /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
 /// hash table.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Id != null ? Id.GetHashCode() : 0) * 397) ^
                (Name != null ? Name.GetHashCode() : 0) ^
                (Description != null ? Description.GetHashCode() : 0) ^
                (ResourceId != null ? ResourceId.GetHashCode() : 0) ^
                (FactionId != null ? FactionId.GetHashCode() : 0) ^
                (SovereignFactionId != null ? SovereignFactionId.GetHashCode() : 0) ^
                (Colour != null ? Colour.GetHashCode() : 0) ^
                Locked.GetHashCode() ^
                Type.GetHashCode());
     }
 }
Exemple #14
0
 public static FactionReputationIndex GetFactionIndex(FactionId id)
 {
     return(FactionReputationIndex.None);
 }
Exemple #15
0
    public void SetFactionNeutral(FactionId factionId)
    {
        Disposition disp = dispositions[factionId];
        if (factionId == id || disp == Disposition.Neutral) {
            return;

        } else if (disp == Disposition.Hostile) {

            for (var i = 0; i < hostiles.Count; i++) {
                if (hostiles[i].factionId == factionId) {
                    neutrals.Add(hostiles[i]);
                    hostiles.RemoveAt(i);
                    i--;
                }
            }

        } else {
            for (var i = 0; i < friendlies.Count; i++) {
                if (friendlies[i].factionId == factionId) {
                    neutrals.Add(friendlies[i]);
                    friendlies.RemoveAt(i);
                    i--;
                }
            }
        }
        dispositions[factionId] = Disposition.Neutral;
    }
Exemple #16
0
 public void SetDisposition(FactionId other, Disposition disposition)
 {
     switch (disposition) {
         case Disposition.Friendly:
             SetFactionFriendly(other);
             break;
         case Disposition.Hostile:
             SetFactionHostile(other);
             break;
         case Disposition.Neutral:
             SetFactionNeutral(other);
             break;
     }
 }
 /// <summary>
 /// Increases or Decreases reputation with the given faction.
 /// </summary>
 /// <param name="factionId">Faction Id.</param>
 /// <param name="value">Amount to add or decrease</param>
 /// <returns></returns>
 public Reputation GainReputation(FactionId factionId, int value)
 {
     value = value + (int)Math.Round(value * m_owner.ReputationGainModifierPercent / 100.0);
     return(ModValue(factionId, value));
 }
 /// <summary>
 /// Increases or Decreases reputation with the given faction.
 /// </summary>
 /// <param name="factionId">Faction Id.</param>
 /// <param name="value">Amount to add or decrease</param>
 /// <returns></returns>
 public Reputation GainReputation(FactionId factionId, int value)
 {
     value = value + (int)Math.Round(value * m_owner.ReputationGainModifierPercent / 100.0);
     return ModValue(factionId, value);
 }
Exemple #19
0
 public NPC CreateVendor(FactionId faction)
 {
     FactionMgr.Initialize();
     return(CreateVendor(FactionMgr.Get(faction)));
 }
        public Reputation ModValue(FactionId factionId, int value)
        {
            var faction = FactionMgr.Get(factionId);

            return(ModValue(faction.ReputationIndex, value));
        }
Exemple #21
0
 public NPC CreateMob(FactionId factionId)
 {
     FactionMgr.Initialize();
     return CreateMob(FactionMgr.Get(factionId));
 }
Exemple #22
0
 public NPC CreateVendor(FactionId faction)
 {
     FactionMgr.Initialize();
     return CreateVendor(FactionMgr.Get(faction));
 }
Exemple #23
0
 public Reputation ModValue(FactionId factionId, int value)
 {
     return(this.ModValue(FactionMgr.Get(factionId).ReputationIndex, value));
 }
Exemple #24
0
 /// <summary>
 /// Increases or Decreases reputation with the given faction.
 /// </summary>
 /// <param name="factionId">Faction Id.</param>
 /// <param name="value">Amount to add or decrease</param>
 /// <returns></returns>
 public Reputation GainReputation(FactionId factionId, int value)
 {
     value += (int)Math.Round((double)(value * this.m_owner.ReputationGainModifierPercent) / 100.0);
     return(this.ModValue(factionId, value));
 }
Exemple #25
0
		public static Faction Get(FactionId id)
		{
			if ((uint)id >= ById.Length)
			{
				return null;
			}
			return ById[(uint)id];
		}
Exemple #26
0
		public static FactionReputationIndex GetFactionIndex(FactionId id)
		{
			if ((uint)id < ByReputationIndex.Length)
			{
				var faction = ById[(uint)id];
				if (faction != null)
				{
					return faction.ReputationIndex;
				}
			}
			return 0;
		}
Exemple #27
0
        private string GetCodeLine()
        {
            Argument stateArgument = Arguments[0];

            stateArgument.Type = RecordType.State;
            string state = stateArgument.Value < 0 ? string.Empty : stateArgument.ToString();

            Arguments[0] = stateArgument;
            string message = (MessageId > 0) ? $" [Msg {MessageId}]" : "";

            string line;

            switch (Code)
            {
            case Instruction.DisplayMessage:
                return($"{state} => Say ({MessageId})");

            case Instruction.WhenItemIsUsed:
            case Instruction.WhenPlayerCasts:
            case Instruction.WhenAtLocation:
                return($"{state} >> {Code} ({Arguments[2]}): set {Arguments[1]}{message}");

//                    return $"{state} >> {Code} ({Arguments[2]}, {Arguments[3]}): set {Arguments[1]}{message}";
            case Instruction.WhenPlayerHasItems:
                line = $"{state} >> {Code} (";
                for (var i = 2; i < ArgCount; i++)
                {
                    line += Arguments[i].ToString();
                    if (i < ArgCount - 1 && Arguments[i + 1].ToString().Length >= 1)
                    {
                        line += ", ";
                    }
                }

                return(line + $"): set {Arguments[1]}{message}");

            case Instruction.TriggerOnAndStates:
                line = " >> If (";
                for (var i = 1; i < ArgCount; i++)
                {
                    line += Arguments[i].ToString();
                    if (i < ArgCount - 1 && Arguments[i + 1].ToString().Length >= 1)
                    {
                        line += " and ";
                    }
                }

                return(line + $"): set {state}{message}");

            case Instruction.TriggerOnOrStates:
                line = $" >> If (";
                for (var i = 1; i < ArgCount; i++)
                {
                    line += Arguments[i].ToString();
                    if (i < ArgCount - 1 && Arguments[i + 1].ToString().Length >= 1)
                    {
                        line += " or ";
                    }
                }

                return(line + $"): set {state}{message}");

            case Instruction.IfMobHurtByPlayer:
            case Instruction.IfItemPickedUp:
            case Instruction.IfNpcClicked:
            case Instruction.IfPlayerHasLevel:
                return($" >> {Code} ({Arguments[1]}): set {state}{message}");

            case Instruction.IfTimeOfDayBetween:
                TimeSpan start = new TimeSpan(0, Arguments[1].Value, 0);
                TimeSpan end   = new TimeSpan(0, Arguments[2].Value, 0);
                return($" >> {Code} ({start}, {end}): set {state}{message}");

            case Instruction.IfGivingItemToNpc:
            case Instruction.IfMobsKilled:
            case Instruction.IfNpcReputation:
            case Instruction.IfItemDroppedAt:
                return($" >> {Code} ({Arguments[1]}, {Arguments[2]}): set {state}{message}");

            case Instruction.IfFactionReputation:
                FactionId faction = (FactionId)Arguments[1].Value;
                return($" >> {Code} ({faction}, {Arguments[2]}): set {state}{message}");

            case Instruction.StartTimer:
                State timerState = FindTimerState(Arguments[1]);
                return($"{state} >> {Code} ({Arguments[1]}); When it expires: set {timerState}{message}");

            case Instruction.CreateFoe:
                Argument mobArgument = Arguments[1];
                mobArgument.Type = RecordType.Mob;
                Arguments[1]     = mobArgument;
                return($"{state} => CreateFoe({mobArgument}, {Arguments[2]}, {Arguments[3]}%, {Arguments[4]}){message}");

            case Instruction.TeleportPlayer:
                return($"{state} >> {Code} ({Arguments[1]}, {(Region)Arguments[2].Value}, 0x{Arguments[3].Value:X4}){message}");

            default:
                StringBuilder sb = new StringBuilder(state);
                sb.Append($" => {Code} (");
                for (var i = 1; i < ArgCount; i++)
                {
                    var argument = Arguments[i].ToString();
                    sb.Append(argument);
                    if (argument.Length > 0 && i < ArgCount - 1 && Arguments[i + 1].ToString().Length > 0)
                    {
                        sb.Append(", ");
                    }
                }

                sb.Append(")");
                sb.Append(message);
                return(sb.ToString());
            }
        }
Exemple #28
0
 public static Faction Get(FactionId id)
 {
     return(NPCMgr.DefaultFaction);
 }
        public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            if (World.CharacterCount == 0)
            {
                trigger.Reply("There are no characters online.");
            }
            else
            {
                string           str1 = trigger.Text.NextModifiers();
                List <Character> characterList;
                if (str1.Contains("r"))
                {
                    Map nonInstancedMap =
                        World.GetNonInstancedMap(trigger.Text.NextEnum(MapId.End));
                    if (nonInstancedMap != null)
                    {
                        characterList = new List <Character>(nonInstancedMap.CharacterCount);
                        characterList.AddRange(nonInstancedMap.Characters);
                    }
                    else
                    {
                        trigger.Reply("Invalid map id.");
                        return;
                    }
                }
                else
                {
                    characterList = World.GetAllCharacters();
                }

                if (str1.Contains("f"))
                {
                    FactionId factionId = trigger.Text.NextEnum(FactionId.End);
                    switch (factionId)
                    {
                    case FactionId.None:
                    case FactionId.End:
                        trigger.Reply("Invalid FactionID.");
                        return;

                    default:
                        for (int index = characterList.Count - 1; index >= 0; --index)
                        {
                            Character character = characterList[index];
                            if (character.FactionId != factionId)
                            {
                                characterList.Remove(character);
                            }
                        }

                        break;
                    }
                }

                if (str1.Contains("c"))
                {
                    ClassId classId = trigger.Text.NextEnum(ClassId.End);
                    if (classId == ClassId.End)
                    {
                        trigger.Reply("Invalid class.");
                        return;
                    }

                    for (int index = characterList.Count - 1; index >= 0; --index)
                    {
                        Character character = characterList[index];
                        if (character.Class != classId)
                        {
                            characterList.Remove(character);
                        }
                    }
                }

                if (str1.Contains("n"))
                {
                    string str2 = trigger.Text.NextWord();
                    if (str2.Length > 1)
                    {
                        for (int index = characterList.Count - 1; index >= 0; --index)
                        {
                            Character character = characterList[index];
                            if (!character.Name.Contains(str2))
                            {
                                characterList.Remove(character);
                            }
                        }
                    }
                    else
                    {
                        for (int index = characterList.Count - 1; index >= 0; --index)
                        {
                            Character character = characterList[index];
                            if (!character.Name.StartsWith(str2))
                            {
                                characterList.Remove(character);
                            }
                        }
                    }
                }

                if (str1.Contains("a"))
                {
                    string str2 = trigger.Text.NextWord();
                    if (str2.Length > 1)
                    {
                        for (int index = characterList.Count - 1; index >= 0; --index)
                        {
                            Character character = characterList[index];
                            if (!character.Account.Name.Contains(str2))
                            {
                                characterList.Remove(character);
                            }
                        }
                    }
                    else
                    {
                        for (int index = characterList.Count - 1; index >= 0; --index)
                        {
                            Character character = characterList[index];
                            if (!character.Name.StartsWith(str2))
                            {
                                characterList.Remove(character);
                            }
                        }
                    }
                }

                if (characterList.Count == World.CharacterCount)
                {
                    trigger.Reply("All Online Players:");
                }
                else if (characterList.Count == 0)
                {
                    trigger.Reply("No players match the given conditions.");
                }
                else
                {
                    trigger.Reply("Matching Players:");
                }
                foreach (Character character in characterList)
                {
                    trigger.Reply(character.ToString());
                }
            }
        }
 public Reputation ModValue(FactionId factionId, int value)
 {
     var faction = FactionMgr.Get(factionId);
     return ModValue(faction.ReputationIndex, value);
 }
Exemple #31
0
 public NPC CreateMob(FactionId factionId)
 {
     FactionMgr.Initialize();
     return(CreateMob(FactionMgr.Get(factionId)));
 }