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
167
168
169
170
171
172
173
174
175
176
177
178
|
--[[
Object to encapsulate Player battle data
For each mob fought, a separate player instance will be stored. Therefore
there will be multiple Player instances for each actual player in the game.
This allows for easier mob filtering.
]]
local Player = {}
function Player:new (o)
o = o or {}
assert(o.name, "Must pass a name to player constructor")
-- attrs should be defined in Player above but due to interpreter bug it's here for now
local attrs = {
clock = nil, -- specific DPS clock for this player
damage = 0, -- total damage done by this player
ws = T{}, -- table of all WS and their corresponding damage
ws_misses = 0, -- total ws misses
m_hits = 0, -- total melee hits
m_misses = 0, -- total melee misses
m_min = math.huge, -- minimum melee damage
m_max = 0, -- maximum melee damage
m_avg = 0, -- avg melee damage
m_crits = 0, -- total melee crits
m_crit_min = math.huge, -- minimum melee crit
m_crit_max = 0, -- maximum melee crit
m_crit_avg = 0, -- avg melee crit
r_hits = 0, -- total ranged hits
r_min = math.huge, -- minimum ranged damage
r_max = 0, -- maximum ranged damage
r_avg = 0, -- avg ranged damage
r_misses = 0, -- total ranged misses
r_crits = 0, -- total ranged crits
r_crit_min = math.huge, -- minimum ranged crit
r_crit_max = 0, -- maximum ranged crit
r_crit_avg = 0, -- avg ranged crit
jobabils = 0, -- total damage from JAs
spells = 0, -- total damage from spells
parries = 0, -- total number of parries
blocks = 0, -- total number of blocks/guards
nonblocks = 0, -- total number of nonblocks
evades = 0, -- total number of evades
damage_taken = 0, -- total damage taken by this player
}
attrs.name = o.name
o = attrs
if o.name:match('^Skillchain%(') then
o.is_sc = true
else
o.is_sc = false
end
setmetatable(o, self)
self.__index = self
return o
end
function Player:add_damage(damage)
self.damage = self.damage + damage
end
function Player:add_ws_damage(ws_name, damage)
--[[
if not self.ws[ws_name] then
self.ws[ws_name] = L{}
end
self.ws[ws_name]:append(damage)
]]
self.ws:append(damage)
self.damage = self.damage + damage
end
function Player:add_m_hit(damage)
-- increment hits
self.m_hits = self.m_hits + 1
-- update min/max/avg melee values
self.m_min = math.min(self.m_min, damage)
self.m_max = math.max(self.m_max, damage)
self.m_avg = self.m_avg * (self.m_hits - 1)/self.m_hits + damage/self.m_hits
-- accumulate damage
self.damage = self.damage + damage
end
function Player:add_m_crit(damage)
-- increment crits
self.m_crits = self.m_crits + 1
-- update min/max/avg melee values
self.m_crit_min = math.min(self.m_crit_min, damage)
self.m_crit_max = math.max(self.m_crit_max, damage)
self.m_crit_avg = self.m_crit_avg * (self.m_crits - 1)/self.m_crits + damage/self.m_crits
-- accumulate damage
self.damage = self.damage + damage
end
function Player:incr_m_misses() self.m_misses = self.m_misses + 1 end
function Player:incr_ws_misses() self.ws_misses = self.ws_misses + 1 end
function Player:add_r_hit(damage)
-- increment hits
self.r_hits = self.r_hits + 1
-- update min/max/avg melee values
self.r_min = math.min(self.r_min, damage)
self.r_max = math.max(self.r_max, damage)
self.r_avg = self.r_avg * (self.r_hits - 1)/self.r_hits + damage/self.r_hits
-- accumulate damage
self.damage = self.damage + damage
end
function Player:add_r_crit(damage)
-- increment crits
self.r_crits = self.r_crits + 1
-- update min/max/avg melee values
self.r_crit_min = math.min(self.r_crit_min, damage)
self.r_crit_max = math.max(self.r_crit_max, damage)
self.r_crit_avg = self.r_crit_avg * (self.r_crits - 1)/self.r_crits + damage/self.r_crits
-- accumulate damage
self.damage = self.damage + damage
end
function Player:incr_r_misses() self.r_misses = self.r_misses + 1 end
-- Returns the name of this player
function Player:get_name() return self.name end
return Player
--[[
Copyright (c) 2013, Jerry Hebert
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Scoreboard nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL JERRY HEBERT BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
|