Apply reputation discount to all points in multi-segment paths
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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<uint> m_TaxiDestinations = new List<uint>();
|
||||
uint m_flightMasterFactionId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user