EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EvEMath.cpp
Go to the documentation of this file.
1 //
3 // EVE Math Equations for in-game features
4 // (pulled directly from client code and http://wiki.eve-id.net/Equations)
5 //
6 // Latest Update: Allan 13Nov20
7 //
9 
10 #include "../eve-common.h"
11 
12 double EvEMath::Units::MetersToLightYears(double meters) {
13  return meters / 9460730472580800;
14 }
15 
16 // skill Equations
18 {
19  if (level > EvESkill::MAXSKILLLEVEL)
21  float ret = pow(sqrt(32), (level -1)) * EvESkill::skillPointMultiplier * rank;
22  return (uint32)ceil(ret);
23 }
24 
26 {
27  uint16 baseSLC = rank * EvESkill::skillPointMultiplier;
28  if (baseSLC == 0)
29  return 0;
30  if (baseSLC > currentSP)
31  return 0;
32  int8 ret = log(currentSP / baseSLC) / EvESkill::DIVCONSTANT + 1;
34 }
35 
37 {
38  return (pAttr + (0.5f * sAttr));
39 }
40 
41 int64 EvEMath::Skill::StartTime(uint32 currentSP, uint32 nextSP, uint8 SPMin, int64 timeNow)
42 {
43  return (timeNow - (((nextSP - currentSP) / SPMin) * EvE::Time::Minute));
44 }
45 
46 int64 EvEMath::Skill::EndTime(uint32 currentSP, uint32 nextSP, uint8 SPMin, int64 timeNow)
47 {
48  if (currentSP >= nextSP)
49  return 0;
50  return ((((nextSP - currentSP) / SPMin) * EvE::Time::Minute) + timeNow);
51 }
52 
53 
54 //RAM Equations
55 int32 EvEMath::RAM::ProductionTime(uint32 BaseTime, float bpProductivityModifier, float ProductionLevel, float TimeModifier/*1*/ )
56 {
57  float PE_Factor(0.0f);
58  if (ProductionLevel >= 0.0f)
59  PE_Factor = (ProductionLevel / (1.0f + ProductionLevel));
60  else
61  PE_Factor = (ProductionLevel - 1.0f);
62 
63  float effModifier(1.0f);
64  effModifier -= ((bpProductivityModifier / BaseTime) * PE_Factor);
65  return (BaseTime * effModifier * TimeModifier);
66 }
67 
68 int32 EvEMath::RAM::ME_ResearchTime(uint32 BaseTime, uint8 MetallurgyLevel, float SlotModifier/*1*/, float ImplantModifier/*1*/ )
69 {
70  return (BaseTime * (13.0f - (0.05f * MetallurgyLevel)) * SlotModifier * ImplantModifier);
71 }
72 
73 int32 EvEMath::RAM::PE_ResearchTime(uint32 BaseTime, uint8 ResearchLevel, float SlotModifier/*1*/, float ImplantModifier/*1*/ )
74 {
75  return (BaseTime * (15.0f - (0.05f * ResearchLevel)) * SlotModifier * ImplantModifier);
76 }
77 
78 int32 EvEMath::RAM::RE_ResearchTime(uint32 BaseTime, uint8 ResearchLevel, float SlotModifier, float ImplantModifier)
79 {
80  // base RE time is 60 min. we may update/modify this later as system matures
81  return 60;
82 }
83 
84 int32 EvEMath::RAM::CopyTime(uint16 BaseTime, uint8 ScienceLevel, float SlotModifier/*1*/, float ImplantModifier/*1*/ )
85 {
86  return (BaseTime * (1.0f - (0.05f * ScienceLevel)) * SlotModifier * ImplantModifier);
87 }
88 
89 int32 EvEMath::RAM::InventionTime(uint32 BaseTime, uint8 AdvLabLevel, float SlotModifier/*1*/, float ImplantModifier/*1*/ )
90 {
91  return BaseTime * (1.0f - (0.03f * AdvLabLevel)) * SlotModifier * ImplantModifier;
92 }
93 
94 float EvEMath::RAM::ME_EffectOnWaste( float MaterialAmount, float BaseWasteFactor, float MaterialEfficiency )
95 {
96  float ME_Factor(0.0f);
97  if (MaterialEfficiency >= 0.0f)
98  ME_Factor = 1.0f / (1.0f + MaterialEfficiency);
99  else
100  ME_Factor = 1.0f - MaterialEfficiency;
101 
102  return (floor(0.5f + (MaterialAmount * (BaseWasteFactor / 100.0f) * ME_Factor)));
103 }
104 
105 uint32 EvEMath::RAM::PerfectME(uint32 MaterialAmount, uint8 BaseWasteFactor)
106 {
107  return floor(0.02f * BaseWasteFactor * MaterialAmount);
108 }
109 
110 float EvEMath::RAM::ResearchPointsPerDay( float Multiplier, float AgentEffectiveQuality, uint8 CharSkillLevel, uint8 AgentSkillLevel )
111 {
112  return (Multiplier * (2.0f + (AgentEffectiveQuality / 100.0f)) * pow(CharSkillLevel + AgentSkillLevel,2));
113 }
114 
115 
117 {
118  return (floor(0.5f + (MaterialAmount * ((25.0f - (5.0f * ProductionEfficiency)) / 100.0f))));
119 }
120 
121 float EvEMath::RAM::InventionChance( float BaseChance, uint8 EncryptionLevel, uint8 DataCore1SkillLevel, uint8 DataCore2SkillLevel, uint8 MetaLevel, float DecryptorModifier )
122 {
123  return (BaseChance * (1 + 0.11f * EncryptionLevel) * (1.0f + (DataCore1SkillLevel + DataCore2SkillLevel)
124  * (0.8f / (5.0f - MetaLevel)) * DecryptorModifier));
125  // fuzzysteve's formula (23may13)
126  // base * (1+0.01*EncryptionLevel) * (1+ (skill*(0.1/(5-metalevel)))) * max(decryptor,1)
127  // skill = sum of sciences skill lvls (as required by bpc)
128 
129  // decryptor formula
130  // min(max(rounddown((inputT1BPCruns/T1MaxPerBPC)*(T2MaxPerBPC/10)),1)+decryptorRunBonus, T2MaxPerBPC)
131 
132  // new formula (pre phoebe)
133  // base * skill * decryptor
134  // skill = 1 + EncryptionLevel/40 + (DataCore1SkillLevel + DataCore2SkillLevel)/30
135 }
136 
137 float EvEMath::Refine::StationTaxesForReprocessing(float CharacterStandingWithStationOwner )
138 {
139  return 5.0f - (0.75f * CharacterStandingWithStationOwner);
140 }
141 
142 float EvEMath::Refine::EffectiveRefiningYield(float EquipmentYield, uint8 RefiningLevel, uint8 RefiningEfficiencyLevel/*0*/, uint8 OreProcessingLevel/*0*/)
143 {
144  return (EquipmentYield + 0.375f * (1.0f + (RefiningLevel * 0.02f))
145  * (1.0f + (RefiningEfficiencyLevel * 0.04f)) * (1.0f + (OreProcessingLevel * 0.05f)));
146 }
147 
148 
149 // Agent Equations
150 float EvEMath::Agent::EffectiveQuality(int8 AgentQuality, uint8 NegotiationLevel, float AgentPersonalStanding)
151 {
152  return (AgentQuality + (5.0f * NegotiationLevel) + AgentPersonalStanding);
153 }
154 
155 float EvEMath::Agent::EffectiveStanding(float YourStanding, double standingBonus)
156 {
157  return (1.0f - (1.0f - YourStanding / 10.0f) * (1.0f - standingBonus / 10.0f)) * 10.0f;
158 }
159 
160 float EvEMath::Agent::RequiredStanding( uint8 AgentLevel, int8 AgentQuality )
161 {
162  return (((AgentLevel - 1.0f) * 2.0f) + (AgentQuality/20.0f));
163 }
164 
165 float EvEMath::Agent::MissionStandingIncrease( float BaseMissionIncrease, uint8 YourSocialSkillLevel )
166 {
167  return (BaseMissionIncrease * (1.0f + 0.05f * YourSocialSkillLevel));
168 }
169 
170 float EvEMath::Agent::Efficiency( uint8 AgentLevel, int8 AgentQuality )
171 {
172  return (0.01f * ((8.0f * AgentLevel) + (0.1f * AgentQuality) - 4.0f));
173 }
174 
175 float EvEMath::Agent::AgentStandingIncrease(float CurrentStanding, float PercentIncrease)
176 {
177  return (((10.0f - CurrentStanding) * PercentIncrease) + CurrentStanding);
178 }
179 
180 float EvEMath::Agent::GetStandingBonus(float fromStanding, uint32 fromFactionID, uint8 ConnectionsSkillLevel, uint8 DiplomacySkillLevel, uint8 CriminalConnectionsSkillLevel)
181 {
182  float bonus(0.0f);
183  if (fromStanding < 0.0f) {
184  bonus = DiplomacySkillLevel * 0.4f;
185  } else if (fromStanding > 0.0f) {
186  switch (fromFactionID) {
187  case 500010:
188  case 500011:
189  case 500012:
190  case 500019:
191  case 500020: {
192  bonus = CriminalConnectionsSkillLevel * 0.4f;
193  } break;
194  default: {
195  bonus = ConnectionsSkillLevel * 0.4f;
196  } break;
197  }
198  }
199  return bonus;
200 }
201 
202 float EvEMath::Market::BrokerFee(uint8 brSkillLvl, float fStanding, float cStanding, float orderValue)
203 {
204  float wStanding = (0.7f * fStanding + 0.3f * cStanding) / 10.0f;
205  float fee = 0.01f * (1.0f - (0.05f * brSkillLvl)) * pow(2, -2 * wStanding);
206  return EvE::max(fee * orderValue, 100.0f);
207 }
208 
209 float EvEMath::Market::RelistFee(float oldPrice, float newPrice, float brokerPercent/*0.01*/, float discount/*0*/)
210 {
211  // this needs a 'Relist Discount' but no clue where to find data for it yet
212  return EvE::max(brokerPercent * (newPrice -oldPrice)) + (1 -discount) *brokerPercent *newPrice;
213 }
214 
215 float EvEMath::Market::SalesTax(float baseSalesTax, uint8 accountingLvl/*0*/, uint8 taxEvasionLvl/*0*/)
216 {
218  float maximumTax = baseSalesTax / 100.0f;
219  float tax = maximumTax * (1 - 0.1f * accountingLvl);
220  return EvE::min(tax, maximumTax);
221 }
222 
223 void EvEMath::PI::Dijkstra(uint32 sourcePin, uint32 destinationPin)
224 {
225  // not used yet...
226 }
227 
228 
229 /*
230  *
231  * Research Points Per Day
232  * Research_Points_Per_Day = Multiplier * ((1 + (Agent_Effective_Quality / 100)) * ((Your_Skill + Agent_Skill) ^ 2))
233  * Multiplier is a specific multiplier for the research field you want to do research in. Like 3x for starship engineering
234  * Your_Skill is your skill level in the research field
235  * Agent_Skill is the agent's skill level in the research field
236  *
237  *
238  * Station take when refining/reprocessing
239  * Station_Take = Max((5 - (0.75 * Your_Standing)), 0)
240  * For the station to take 0% you need a standing to the station owner of at least: 5 / 0.75 = 6.67
241  *
242  *
243  * Agent Effective Quality - Removed in Incursion 1.5 (2011-05-19)
244  * Agent_Effective_Quality = Agent_Quality + (5 * Negotiation_Skill_Level) + Round_Down(Effective_Standing)
245  * Effective_Standing is the highest effective of either personal, corp. or faction standing.
246  *
247  *
248  * Blueprint Material Requirement - Before Crius 1.0 (2014-07-22)
249  * Required_Amount = Round(Base_Amount * ((1 + (Default_Blueprint_Waste_Factor / (1 + Blueprint_Material_Level))) + (0.25 - (0.05 * Production_Efficiency_Skill_Level))), 0)
250  *
251  *
252  * Invention Chance - Before Phoebe 1.0 (2014-11-04)
253  * Invention_Chance = Base_Chance * (1 + (0.01 * Encryption_Skill_Level)) * (1 + ((Datacore_1_Skill_Level + Datacore_2_Skill_Level) * (0.1 / (5 - Meta_Level)))) * Decryptor_Modifier
254  * Meta_Level of the base items used. No base items is the same as metalevel 0 = useless.
255  * Decryptor_Modifier is optional :-)
256  *
257  *
258  * Reverse Engineering Chance - Merged with Invention in Phoebe 1.0 (2014-11-04)
259  * Reverse_Chance = Base_Chance * (1 + (0.01 * Reverse_Engineering_Skill_Level)) * (1 + (0.1 * (Datacore_1_Skill_Level + Datacore_2_Skill_Level)))
260  */
unsigned __int8 uint8
Definition: eve-compat.h:46
float InventionChance(float BaseChance, uint8 EncryptionLevel, uint8 DataCore1SkillLevel, uint8 DataCore2SkillLevel, uint8 MetaLevel, float DecryptorModifier)
Definition: EvEMath.cpp:121
void Dijkstra(uint32 sourcePin, uint32 destinationPin)
Definition: EvEMath.cpp:223
double min(double x, double y)
Definition: misc.h:95
uint8 PointsPerMinute(uint8 pAttr, uint8 sAttr)
Definition: EvEMath.cpp:36
float EffectiveQuality(int8 AgentQuality, uint8 NegotiationSkillLevel, float AgentPersonalStanding)
Definition: EvEMath.cpp:150
float ResearchPointsPerDay(float Multiplier, float AgentEffectiveQuality, uint8 CharSkillLevel, uint8 AgentSkillLevel)
Definition: EvEMath.cpp:110
float WasteSkillBased(uint32 MaterialAmount, float ProductionEfficiency)
Definition: EvEMath.cpp:116
uint32 PerfectME(uint32 MaterialAmount, uint8 BaseWasteFactor)
Definition: EvEMath.cpp:105
uint32 PointsAtLevel(uint8 level, float rank)
Definition: EvEMath.cpp:17
const uint8 skillPointMultiplier
Definition: EvEMath.h:20
const float DIVCONSTANT
Definition: EvEMath.h:21
signed __int8 int8
Definition: eve-compat.h:45
int32 InventionTime(uint32 BaseTime, uint8 AdvLabLevel, float SlotModifier=1, float ImplantModifier=1)
Definition: EvEMath.cpp:89
signed __int32 int32
Definition: eve-compat.h:49
int64 StartTime(uint32 currentSP, uint32 nextSP, uint8 SPMin, int64 timeNow)
Definition: EvEMath.cpp:41
int32 ME_ResearchTime(uint32 BaseTime, uint8 MetallurgyLevel, float SlotModifier=1, float ImplantModifier=1)
Definition: EvEMath.cpp:68
int64 EndTime(uint32 currentSP, uint32 nextSP, uint8 SPMin, int64 timeNow)
Definition: EvEMath.cpp:46
uint8 LevelForPoints(uint32 currentSP, uint8 rank)
Definition: EvEMath.cpp:25
int32 PE_ResearchTime(uint32 BaseTime, uint8 ResearchLevel, float SlotModifier=1, float ImplantModifier=1)
Definition: EvEMath.cpp:73
float MissionStandingIncrease(float BaseMissionIncrease, uint8 YourSocialSkillLevel)
Definition: EvEMath.cpp:165
double MetersToLightYears(double meters)
Definition: EvEMath.cpp:12
float Efficiency(uint8 AgentLevel, int8 AgentQuality)
Definition: EvEMath.cpp:170
const uint8 MAXSKILLLEVEL
Definition: EvEMath.h:19
int32 RE_ResearchTime(uint32 BaseTime, uint8 ResearchLevel, float SlotModifier=1, float ImplantModifier=1)
Definition: EvEMath.cpp:78
int32 ProductionTime(uint32 BaseTime, float bpProductivityModifier, float ProductionLevel, float TimeModifier=1)
Definition: EvEMath.cpp:55
float StationTaxesForReprocessing(float CharacterStandingWithStationOwner)
Definition: EvEMath.cpp:137
unsigned __int32 uint32
Definition: eve-compat.h:50
int32 CopyTime(uint16 BaseTime, uint8 ScienceLevel, float SlotModifier=1, float ImplantModifier=1)
Definition: EvEMath.cpp:84
float BrokerFee(uint8 brSkillLvl, float fStanding, float cStanding, float total)
Definition: EvEMath.cpp:202
float EffectiveRefiningYield(float EquipmentYield, uint8 RefiningLevel, uint8 RefiningEfficiencyLevel=9, uint8 OreProcessingLevel=0)
Definition: EvEMath.cpp:142
signed __int64 int64
Definition: eve-compat.h:51
float SalesTax(float baseSalesTax, uint8 accountingLvl=0, uint8 taxEvasionLvl=0)
Definition: EvEMath.cpp:215
int64 max(int64 x, int64 y=0)
Definition: misc.h:103
float RelistFee(float oldPrice, float newPrice, float brokerPercent=0.01, float discount=0)
Definition: EvEMath.cpp:209
float GetStandingBonus(float fromStanding, uint32 fromFactionID, uint8 ConnectionsSkillLevel, uint8 DiplomacySkillLevel, uint8 CriminalConnectionsSkillLevel)
Definition: EvEMath.cpp:180
float EffectiveStanding(float YourStanding, double standingBonus)
Definition: EvEMath.cpp:155
float RequiredStanding(uint8 AgentLevel, int8 AgentQuality)
Definition: EvEMath.cpp:160
float AgentStandingIncrease(float CurrentStanding, float PercentIncrease)
Definition: EvEMath.cpp:175
float ME_EffectOnWaste(float MaterialAmount, float BaseWasteFactor, float MaterialEfficiency)
Definition: EvEMath.cpp:94
unsigned __int16 uint16
Definition: eve-compat.h:48