forked from EVEIPH/EVE-IPH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNPCStandings.vb
167 lines (128 loc) · 5.12 KB
/
NPCStandings.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Public Class NPCStandings
Private NPCStandings As List(Of NPCStanding)
Private StandingToFind As NPCStanding
Public Class NPCStanding
Public NPCID As Long
Public NPCType As String ' Agent, Faction, or Corporation
Public NPCName As String
Public Standing As Double ' Will be a base standing (no connections skill applied)
End Class
Public Sub New()
NPCStandings = New List(Of NPCStanding)
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
' Returns the standing of a sent NPC ID
Public Function GetStanding(ByVal NPCID As Long) As Double
' Find the Industry Skill level
If NPCStandings.Count <> 0 Then
For i = 0 To NPCStandings.Count - 1
If NPCStandings(i).NPCID = NPCID Then
Return NPCStandings(i).Standing
Exit Function
End If
Next
End If
' Got this far we didn't find it in the list
Return 0
End Function
' Returns the standing of a sent name
Public Function GetStanding(ByVal NPCName As String) As Double
' Find the Industry Skill level
If NPCStandings.Count <> 0 Then
For i = 0 To NPCStandings.Count - 1
If NPCStandings(i).NPCName = NPCName Then
Return NPCStandings(i).Standing
Exit Function
End If
Next
End If
' Got this far we didn't find it in the list
Return 0
End Function
' Returns the effective standing of a sent NPC ID
Public Function GetEffectiveStanding(ByVal NPCID As Long, SentConnections As Integer, SentDiplomacy As Integer) As Double
' Find the Industry Skill level
If NPCStandings.Count <> 0 Then
For i = 0 To NPCStandings.Count - 1
If NPCStandings(i).NPCID = NPCID Then
Return CalcEffectiveStanding(NPCStandings(i).Standing, SentConnections, SentDiplomacy)
Exit Function
End If
Next
End If
' Got this far we didn't find it in the list
Return 0
End Function
' Returns the effective standing of a sent name
Public Function GetEffectiveStanding(ByVal NPCName As String, SentConnections As Integer, SentDiplomacy As Integer) As Double
' Find the Industry Skill level
If NPCStandings.Count <> 0 Then
For i = 0 To NPCStandings.Count - 1
If NPCStandings(i).NPCName = NPCName Then
Return CalcEffectiveStanding(NPCStandings(i).Standing, SentConnections, SentDiplomacy)
Exit Function
End If
Next
End If
' Got this far we didn't find it in the list
Return 0
End Function
Private Function CalcEffectiveStanding(BaseCorpStanding As Double, Connections As Integer, Diplomacy As Integer) As Double
Dim EffectiveStanding As Double
If BaseCorpStanding < 0 Then
' Use Diplomacy
EffectiveStanding = BaseCorpStanding + ((10 - BaseCorpStanding) * (0.04 * Diplomacy))
ElseIf BaseCorpStanding > 0 Then
' Use connections
EffectiveStanding = BaseCorpStanding + ((10 - BaseCorpStanding) * (0.04 * Connections))
Else
EffectiveStanding = 0
End If
Return EffectiveStanding
End Function
' Returns the list of standings
Public Function GetStandingsList() As List(Of NPCStanding)
Return NPCStandings
End Function
' Returns the number of standings in the list
Public Function NumStandings() As Integer
If NPCStandings.Count <> 0 Then
Return NPCStandings.Count
Else
Return 0
End If
End Function
' Inserts standing with each value
Public Sub InsertStanding(ByVal sentNPCID As Long, ByVal sentNPCType As String, ByVal sentNPCName As String, ByVal sentStanding As Double)
Dim TempStanding As New NPCStanding
TempStanding.NPCID = sentNPCID
TempStanding.NPCName = sentNPCName
TempStanding.NPCType = sentNPCType
TempStanding.Standing = sentStanding
Call InsertSTanding(TempStanding)
End Sub
' Inserts a set of character skills into the current set
Public Sub InsertStanding(ByVal SentStanding As NPCStanding)
Dim FoundStanding As NPCStanding
Dim i As Integer = 0
' See if the skill exists already
StandingToFind = SentStanding
FoundStanding = NPCStandings.Find(AddressOf FindStanding)
If FoundStanding IsNot Nothing Then
Exit Sub
Else ' add standing
NPCStandings.Add(SentStanding)
End If
End Sub
' Predicate for finding the standing
Private Function FindStanding(ByVal SStanding As NPCStanding) As Boolean
If SStanding.NPCID = StandingToFind.NPCID And SStanding.NPCType = StandingToFind.NPCType And SStanding.NPCName = StandingToFind.NPCName Then
Return True
Else
Return False
End If
End Function
End Class