diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 0bc1f8209..8d9f86d1d 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -6771,7 +6771,14 @@ namespace Game.Entities ulong money = GetMoney(); if (npc != null) - totalcost = (uint)Math.Ceiling(totalcost * GetReputationPriceDiscount(npc)); + { + float discount = GetReputationPriceDiscount(npc); + totalcost = (uint)Math.Ceiling(totalcost * discount); + firstcost = (uint)Math.Ceiling(firstcost * discount); + m_taxi.SetFlightMasterFactionTemplateId(npc.getFaction()); + } + else + m_taxi.SetFlightMasterFactionTemplateId(0); if (money < totalcost) { @@ -6985,11 +6992,15 @@ namespace Game.Entities public float GetReputationPriceDiscount(Creature creature) { - var vendor_faction = creature.GetFactionTemplateEntry(); - if (vendor_faction == null || vendor_faction.Faction == 0) + return GetReputationPriceDiscount(creature.GetFactionTemplateEntry()); + } + + public float GetReputationPriceDiscount(FactionTemplateRecord factionTemplate) + { + if (factionTemplate == null || factionTemplate.Faction == 0) return 1.0f; - ReputationRank rank = GetReputationRank(vendor_faction.Faction); + ReputationRank rank = GetReputationRank(factionTemplate.Faction); if (rank <= ReputationRank.Neutral) return 1.0f; diff --git a/Source/Game/Entities/Player/PlayerTaxi.cs b/Source/Game/Entities/Player/PlayerTaxi.cs index 936e4ec77..cbe07d508 100644 --- a/Source/Game/Entities/Player/PlayerTaxi.cs +++ b/Source/Game/Entities/Player/PlayerTaxi.cs @@ -125,10 +125,13 @@ namespace Game.Entities { ClearTaxiDestinations(); - var split = new StringArray(values, ' '); - for (var i = 0; i < split.Length; ++i) + var stringArray = new StringArray(values, ' '); + if (stringArray.Length > 0) + m_flightMasterFactionId = uint.Parse(stringArray[0]); + + for (var i = 1; i < stringArray.Length; ++i) { - uint node = uint.Parse(split[i]); + uint node = uint.Parse(stringArray[i]); AddTaxiDestination(node); } @@ -161,9 +164,10 @@ namespace Game.Entities return ""; StringBuilder ss = new StringBuilder(); + ss.Append($"{m_flightMasterFactionId} "); for (int i = 0; i < m_TaxiDestinations.Count; ++i) - ss.AppendFormat("{0} ", m_TaxiDestinations[i]); + ss.Append($"{m_TaxiDestinations[i]} "); return ss.ToString(); } @@ -202,6 +206,16 @@ namespace Game.Entities return false; } + public FactionTemplateRecord GetFlightMasterFactionTemplate() + { + return CliDB.FactionTemplateStorage.LookupByKey(m_flightMasterFactionId); + } + + public void SetFlightMasterFactionTemplateId(uint factionTemplateId) + { + m_flightMasterFactionId = factionTemplateId; + } + public bool IsTaximaskNodeKnown(uint nodeidx) { byte field = (byte)((nodeidx - 1) / 8); @@ -240,5 +254,6 @@ namespace Game.Entities public byte[] m_taximask = new byte[PlayerConst.TaxiMaskSize]; List m_TaxiDestinations = new List(); + uint m_flightMasterFactionId; } } diff --git a/Source/Game/Movement/Generators/WaypointMovement.cs b/Source/Game/Movement/Generators/WaypointMovement.cs index c8ffa0d47..3d83ab3e1 100644 --- a/Source/Game/Movement/Generators/WaypointMovement.cs +++ b/Source/Game/Movement/Generators/WaypointMovement.cs @@ -269,6 +269,8 @@ namespace Game.Movement i_currentNode = (int)startNode; _pointsForPathSwitch.Clear(); var taxi = player.m_taxi.GetPath(); + float discount = player.GetReputationPriceDiscount(player.m_taxi.GetFlightMasterFactionTemplate()); + for (int src = 0, dst = 1; dst < taxi.Count; src = dst++) { uint path, cost; @@ -301,7 +303,7 @@ namespace Game.Movement } } - _pointsForPathSwitch.Add(new TaxiNodeChangeInfo((uint)(i_path.Count - 1), (int)cost)); + _pointsForPathSwitch.Add(new TaxiNodeChangeInfo((uint)(i_path.Count - 1), (long)Math.Ceiling(cost * discount))); } } @@ -490,14 +492,14 @@ namespace Game.Movement class TaxiNodeChangeInfo { - public TaxiNodeChangeInfo(uint pathIndex, int cost) + public TaxiNodeChangeInfo(uint pathIndex, long cost) { PathIndex = pathIndex; Cost = cost; } public uint PathIndex; - public int Cost; + public long Cost; } } }