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();
|
ulong money = GetMoney();
|
||||||
if (npc != null)
|
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)
|
if (money < totalcost)
|
||||||
{
|
{
|
||||||
@@ -6985,11 +6992,15 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public float GetReputationPriceDiscount(Creature creature)
|
public float GetReputationPriceDiscount(Creature creature)
|
||||||
{
|
{
|
||||||
var vendor_faction = creature.GetFactionTemplateEntry();
|
return GetReputationPriceDiscount(creature.GetFactionTemplateEntry());
|
||||||
if (vendor_faction == null || vendor_faction.Faction == 0)
|
}
|
||||||
|
|
||||||
|
public float GetReputationPriceDiscount(FactionTemplateRecord factionTemplate)
|
||||||
|
{
|
||||||
|
if (factionTemplate == null || factionTemplate.Faction == 0)
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
ReputationRank rank = GetReputationRank(vendor_faction.Faction);
|
ReputationRank rank = GetReputationRank(factionTemplate.Faction);
|
||||||
if (rank <= ReputationRank.Neutral)
|
if (rank <= ReputationRank.Neutral)
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -125,10 +125,13 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
ClearTaxiDestinations();
|
ClearTaxiDestinations();
|
||||||
|
|
||||||
var split = new StringArray(values, ' ');
|
var stringArray = new StringArray(values, ' ');
|
||||||
for (var i = 0; i < split.Length; ++i)
|
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);
|
AddTaxiDestination(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,9 +164,10 @@ namespace Game.Entities
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
StringBuilder ss = new StringBuilder();
|
StringBuilder ss = new StringBuilder();
|
||||||
|
ss.Append($"{m_flightMasterFactionId} ");
|
||||||
|
|
||||||
for (int i = 0; i < m_TaxiDestinations.Count; ++i)
|
for (int i = 0; i < m_TaxiDestinations.Count; ++i)
|
||||||
ss.AppendFormat("{0} ", m_TaxiDestinations[i]);
|
ss.Append($"{m_TaxiDestinations[i]} ");
|
||||||
|
|
||||||
return ss.ToString();
|
return ss.ToString();
|
||||||
}
|
}
|
||||||
@@ -202,6 +206,16 @@ namespace Game.Entities
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FactionTemplateRecord GetFlightMasterFactionTemplate()
|
||||||
|
{
|
||||||
|
return CliDB.FactionTemplateStorage.LookupByKey(m_flightMasterFactionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFlightMasterFactionTemplateId(uint factionTemplateId)
|
||||||
|
{
|
||||||
|
m_flightMasterFactionId = factionTemplateId;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsTaximaskNodeKnown(uint nodeidx)
|
public bool IsTaximaskNodeKnown(uint nodeidx)
|
||||||
{
|
{
|
||||||
byte field = (byte)((nodeidx - 1) / 8);
|
byte field = (byte)((nodeidx - 1) / 8);
|
||||||
@@ -240,5 +254,6 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public byte[] m_taximask = new byte[PlayerConst.TaxiMaskSize];
|
public byte[] m_taximask = new byte[PlayerConst.TaxiMaskSize];
|
||||||
List<uint> m_TaxiDestinations = new List<uint>();
|
List<uint> m_TaxiDestinations = new List<uint>();
|
||||||
|
uint m_flightMasterFactionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,6 +269,8 @@ namespace Game.Movement
|
|||||||
i_currentNode = (int)startNode;
|
i_currentNode = (int)startNode;
|
||||||
_pointsForPathSwitch.Clear();
|
_pointsForPathSwitch.Clear();
|
||||||
var taxi = player.m_taxi.GetPath();
|
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++)
|
for (int src = 0, dst = 1; dst < taxi.Count; src = dst++)
|
||||||
{
|
{
|
||||||
uint path, cost;
|
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
|
class TaxiNodeChangeInfo
|
||||||
{
|
{
|
||||||
public TaxiNodeChangeInfo(uint pathIndex, int cost)
|
public TaxiNodeChangeInfo(uint pathIndex, long cost)
|
||||||
{
|
{
|
||||||
PathIndex = pathIndex;
|
PathIndex = pathIndex;
|
||||||
Cost = cost;
|
Cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint PathIndex;
|
public uint PathIndex;
|
||||||
public int Cost;
|
public long Cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user