Damage Counter script errors

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Thanks, works but went on a killing spree, nothing was recorded. I even added display to see my hits... it works no feeding into the table

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Total hits: 19
Total crits: 0
Total crit-rate: 0.000


Statistics:
pathetic 0 [ 0.000 ] - 19 hits ago!
weak 0 [ 0.000 ] - 19 hits ago!
punishing 0 [ 0.000 ] - 19 hits ago!
surprising 0 [ 0.000 ] - 19 hits ago!
amazing 0 [ 0.000 ] - 19 hits ago!
astonishing 0 [ 0.000 ] - 19 hits ago!
mauling 0 [ 0.000 ] - 19 hits ago!
decimating 0 [ 0.000 ] - 19 hits ago!
devastating 0 [ 0.000 ] - 19 hits ago!
pulverizing 0 [ 0.000 ] - 19 hits ago!
maiming 0 [ 0.000 ] - 19 hits ago!
eviscerating 0 [ 0.000 ] - 19 hits ago!
mutilating 0 [ 0.000 ] - 19 hits ago!
disemboweling 0 [ 0.000 ] - 19 hits ago!
dismembering 0 [ 0.000 ] - 19 hits ago!
massacring 0 [ 0.000 ] - 19 hits ago!
mangling 0 [ 0.000 ] - 19 hits ago!
demolishing 0 [ 0.000 ] - 19 hits ago!
obliterating 0 [ 0.000 ] - 19 hits ago!
annihilating 0 [ 0.000 ] - 19 hits ago!
eradicating 0 [ 0.000 ] - 19 hits ago!
vaporizing 0 [ 0.000 ] - 19 hits ago!
destructive 0 [ 0.000 ] - 19 hits ago!
extreme 0 [ 0.000 ] - 19 hits ago!
porcine 0 [ 0.000 ] - 19 hits ago!
divine 0 [ 0.000 ] - 19 hits ago!
daunting 0 [ 0.000 ] - 19 hits ago!
terminal 0 [ 0.000 ] - 19 hits ago!

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Damage Counter script errors

Post by Wyd »

Change the "CritCounter:AddCrit(type)" function to this:
Code: [show] | [select all] lua
function CritCounter:AddCrit(type)

	if not self._enabled or not type then return end

	type = self._critNames[type]

	self._critTable[type] = self._critTable[type] + 1
	self._critLast[type] = 0

	self:Save()
end
Then go and get a critical hit again - you should see "Crit Type: <the type of critical>" printed.

Make sure that matches one of the entries in the _critNames table.

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Still wont auto add on table. Strange...

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Damage Counter script errors

Post by Wyd »

Any errors showing up when you get a critical hit?

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Total hits: 935
Total crits: 49
Total crit-rate: 5.241


Statistics:
pathetic 0 [ 0.000 ] - 935 hits ago!
weak 0 [ 0.000 ] - 935 hits ago!
punishing 0 [ 0.000 ] - 935 hits ago!
surprising 0 [ 0.000 ] - 935 hits ago!
amazing 0 [ 0.000 ] - 935 hits ago!
astonishing 0 [ 0.000 ] - 935 hits ago!
mauling 0 [ 0.000 ] - 935 hits ago!
decimating 0 [ 0.000 ] - 935 hits ago!
devastating 0 [ 0.000 ] - 935 hits ago!
pulverizing 0 [ 0.000 ] - 935 hits ago!
maiming 0 [ 0.000 ] - 935 hits ago!
eviscerating 0 [ 0.000 ] - 935 hits ago!
mutilating 0 [ 0.000 ] - 935 hits ago!
disemboweling 0 [ 0.000 ] - 935 hits ago!
dismembering 0 [ 0.000 ] - 935 hits ago!
massacring 0 [ 0.000 ] - 935 hits ago!
mangling 0 [ 0.000 ] - 935 hits ago!
demolishing 0 [ 0.000 ] - 935 hits ago!
obliterating 0 [ 0.000 ] - 935 hits ago!
annihilating 0 [ 0.000 ] - 935 hits ago!
eradicating 0 [ 0.000 ] - 935 hits ago!
vaporizing 0 [ 0.000 ] - 935 hits ago!
destructive 0 [ 0.000 ] - 935 hits ago!
extreme 0 [ 0.000 ] - 935 hits ago!
porcine 0 [ 0.000 ] - 935 hits ago!
divine 0 [ 0.000 ] - 935 hits ago!
daunting 0 [ 0.000 ] - 935 hits ago!
terminal 49 [ 100.000 ] - 5 hits ago!

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

I added this display(matches) on trigger, fired everything just fine, but wont add to the table... hmm.

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Damage Counter script errors

Post by Wyd »

It has added the terminal hits - chances are your regex trigger for capturing critical hits, is either not catching right, or is capturing a different string than you have in the critNames table

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Your attacks strike an unholy wasp 3 times, with *MANGLING* strength!
Your attacks strike a ghastly wasp 2 times, with ***DISMEMBERING*** viciousness!
Your attacks strike a cunning wasp 6 times, with obliterating passion!

**************************************************************************************************

^Your attack[s]? strike[s]? a[n]? (.*) (\d+) time[s]?, with (.*) (.*)!
^Your attack[s]? strike[s]? the (.*) (\d+) time[s]?, with (.*) (.*)!

CritCounter:AddCrit(matches[4])

**************************************************************************************************
Code: [show] | [select all] lua
if not CritCounter then
        display("Loading Crit Table")
        CritCounter = {
                _totalHits = 0,
                _loaded = false,
                _enabled = true,
                }

        local cc = CritCounter

        cc._critDisplayOrder = {
                "pathetic", "weak", "punishing", "surprising",
                "amazing", "astonishing", "mauling", "decimating",
                "devastating", "pulverizing", "maiming", "eviscerating",
                "mutilating", "disemboweling", "dismembering", "massacring",
                "mangling", "demolishing", "obliterating", "annihilating",
                "eradicating", "vaporizing", "destructive", "extreme",
                "porcine", "divine", "daunting", "terminal",
                }
        cc._critTable = {
                pathetic = 0, weak = 0, punishing = 0, surprising = 0,
                amazing = 0, astonishing = 0, mauling = 0, decimating = 0,
                devastating = 0, pulverizing = 0, maiming = 0, eviscerating = 0,
                mutilating = 0, disemboweling = 0, dismembering = 0, massacring = 0,
                mangling = 0, demolishing = 0, obliterating = 0, annihilating = 0,
                eradicating = 0, vaporizing = 0, destructive = 0, extreme = 0,
                porcine = 0, divine = 0, daunting = 0, terminal = 0,
                }
        cc._critLast = {
                pathetic = 0, weak = 0, punishing = 0, surprising = 0,
                amazing = 0, astonishing = 0, mauling = 0, decimating = 0,
                devastating = 0, pulverizing = 0, maiming = 0, eviscerating = 0,
                mutilating = 0, disemboweling = 0, dismembering = 0, massacring = 0,
                mangling = 0, demolishing = 0, obliterating = 0, annihilating = 0,
                eradicating = 0, vaporizing = 0, destructive = 0, extreme = 0,
                porcine = 0, divine = 0, daunting = 0, terminal = 0,
                }
	cc._critNames = {}
	cc._critNames["pathetic"] = "pathetic"
	cc._critNames["weak"] = "weak"
	cc._critNames["punishing"] = "punishing"
	cc._critNames["surprising"] = "surprising"
	cc._critNames["amazing"] = "amazing"
	cc._critNames["astonishing"] = "astonishing"
	cc._critNames["mauling MAULING *MAULING* **MAULING** ***MAULING***"] = "mauling"
	cc._critNames["decimating DECIMATING *DECIMATING* **DECIMATING** ***DECIMATING***"] = "decimating"
	cc._critNames["devastating DEVASTATING *DEVASTATING* **DEVASTATING** ***DEVASTATING***"] = "devastating"
	cc._critNames["pulverizing PULVERIZING *PULVERIZING* **PULVERIZING** ***PULVERIZING***"] = "pulverizing"
	cc._critNames["maiming MAIMING *MAIMING* **MAIMING** ***MAIMING***"] = "maiming"
	cc._critNames["eviscerating EVISCERATING *EVISCERATING* **EVISCERATING** ***EVISCERATING***"] = "eviscerating"
	cc._critNames["mutilating MUTILATING *MUTILATING* **MUTILATING** ***MUTILATING***"] = "mutilating"
	cc._critNames["disemboweling DISEMBOWELING *DISEMBOWELING* **DISEMBOWELING** ***DISEMBOWELING***"] = "disemboweling"
	cc._critNames["dismembering DISMEMBERING *DISMEMBERING* **DISMEMBERING** ***DISMEMBERING***"] = "dismembering"
	cc._critNames["massacring MASSACRING *MASSACRING* *MASSACRING** ***MASSACRING***"] = "massacring"
	cc._critNames["mangling MANGLING *MANGLING* **MANGLING** ***MANGLING***"] = "mangling"
	cc._critNames["demolishing DEMOLISHING *DEMOLISHING* **DEMOLISHING** ***DEMOLISHING***"] = "demolishing"
	cc._critNames["obliterating OBLITERATING *OBLITERATING* **OBLITERATING** ***OBLITERATING***"] = "obliterating"
	cc._critNames["annihilating ANNIHILATING *ANNIHILATING* **ANNIHILATING** ***ANNIHILATING*** >***ANNIHILATING***< >>***ANNIHILATING***<< >>>***ANNIHILATING***<<< >>>>***ANNIHILATING***<<<<"] = "annihilating"
	cc._critNames["eradicating ERADICATING *ERADICATING* **ERADICATING** ***ERADICATING*** >***ERADICATING***< >>***ERADICATING***<< >>>***ERADICATING***<<< >>>>***ERADICATING***<<<<"] = "eradicating"
	cc._critNames["vaporizing VAPORIZING *VAPORIZING* **VAPORIZING** ***VAPORIZING*** >***VAPORIZING***< >>***VAPORIZING***<< >>>***VAPORIZING***<<< >>>>***VAPORIZING***<<<<"] = "vaporizing"
	cc._critNames["destructive DESTRUCTIVE *DESTRUCTIVE* **DESTRUCTIVE** ***DESTRUCTIVE*** ****DESTRUCTIVE**** >****DESTRUCTIVE****< >>****DESTRUCTIVE****<< >>>****DESTRUCTIVE****<<< >>>>****DESTRUCTIVE****<<<< =>>>>DESTRUCTIVE***<<<<= ==>>>>DESTRUCTIVE**<<<<== ===>>>>DESTRUCTIVE*<<<<=== ====>>>>DESTRUCTIVE<<<<===="] = "destructive"
	cc._critNames["extreme EXTREME *EXTREME* **EXTREME** ***EXTREME*** ****EXTREME**** >****EXTREME****< >>****EXTREME****<< >>>****EXTREME****<<< >>>>****EXTREME****<<<< =>>>>***EXTREME***<<<<= ==>>>>**EXTREME**<<<<== ===>>>>*EXTREME*<<<<=== ====>>>>EXTREME<<<<===="] = "extreme"
	cc._critNames["porcine PORCINE *PORCINE* **PORCINE** ***PORCINE*** >***PORCINE***< >>***PORCINE***<< >>>***PORCINE***<<< >>>>***PORCINE***<<<<"] = "porcine"
	cc._critNames["divine"] = "divine"
	cc._critNames["daunting"] = "daunting"
	cc._critNames["terminal"] = "terminal"
end

function CritCounter:Enable(enable)
	self._enabled = enable
	cecho("\n<light_grey>[ <yellow>DAMAGE REPORT <light_grey>]: Counter has been ")
	if enable then cecho("<light_grey>enabled!")
	else cecho("<light_grey>disabled!") end
	echo("\n")
end

function CritCounter:Load(force)
	if self._loaded and not force then return end

	local loadTable = {}

	if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else  _sep = "\\" end
	
	local l_SettingsFile = getMudletHomeDir() .. _sep .. "DmgCounter.lua"
	
	if (io.exists(l_SettingsFile)) then
		table.load(l_SettingsFile, loadTable)
	end

	if not loadTable.critTable or not loadTable.totalHits or not loadTable.critLast then
		cecho("<red>Failed to load DAMAGE REPORT saved data!")
		cecho("<white>Ignore this warning if you have just")
		cecho("<white> installed the counter")
		return
	end

	self._critTable = loadTable.critTable
	self._totalHits = loadTable.totalHits
	self._critLast  = loadTable.critLast

	self._loaded = true
end

function CritCounter:Save()
	if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else  _sep = "\\" end
	local l_SettingsFile = getMudletHomeDir() .. _sep .. "CritCounter.lua"

	local savetable = {}

	savetable.critTable = self._critTable
	savetable.totalHits = self._totalHits
	savetable.critLast  = self._critLast

	table.save(l_SettingsFile, savetable)
end

function CritCounter:display()
        local totalcrits = 0
        for _, num in pairs(self._critTable) do
                totalcrits = totalcrits + num
        end

        local critrate = self._totalHits == 0 and 0 or (totalcrits / self._totalHits) * 100

        cecho("\n<grey>" .. string.rep("-", 31) .. "[ <yellow>DAMAGE REPORT:<grey> ]" .. string.rep("-", 31) .. "\n\n")
        cecho("<RoyalBlue>Total hits:         <white>" .. self._totalHits .. "\n")
        cecho("<RoyalBlue>Total crits:        <white>" .. totalcrits .. "\n")
        cecho("<RoyalBlue>Total crit-rate:    <white>"  .. string.format("%.3f", critrate) .. "\n")

        cecho("\n\n<dodger_blue>Statistics:\n")
        for _, crit in ipairs(self._critDisplayOrder) do
                local rate = totalcrits == 0 and 0.0 or (self._critTable[crit] / totalcrits) * 100
                
                if not crit then print("NIL VARIABLE: crit") end
                if not self._critTable[crit] then
   print("NIL VARIABLE: self._critTable[crit]")
   display(crit)
   display(self._critTable)
end
                if not rate then print("NIL VARIABLE: rate") end
                if not self._critLast[crit] then print("NIL VARIABLE: self._critLast[crit]") end
                
                local format_str = "<yellow>%-20s<white>%s  <LimeGreen>[ %-8.3f ]  - %s hits ago!\n"
                local line = string.format(format_str,crit,self._critTable[crit],rate,self._critLast[crit])

                cecho(line)
        end
        cecho("\n<grey>" .. string.rep("-", 80) .. "\n")
end

function CritCounter:Reset()
	for crit, _  in pairs(self._critTable) do
		self._critTable[crit] = 0
		self._critLast[crit] = 0
	end

	self._totalHits = 0

	self:Save()

	cecho("\n<light_grey>[ <yellow>DAMAGE REPORT <light_grey>]: Counter has been reset!")
end

function CritCounter:AddHit()
	if not self._enabled then return end

	self._totalHits = self._totalHits + 1
	for crit, _ in pairs(self._critLast) do
		self._critLast[crit] = self._critLast[crit] + 1
	end

end

function CritCounter:AddCrit(type)

        if not self._enabled or not type then return end

        type = self._critNames[type]

        self._critTable[type] = self._critTable[type] + 1
        self._critLast[type] = 0

        self:Save()
end
 

CritCounter:Load()
* Edited for clarity. Seriously, man, use your Lua tags. =p Do everyone helping you a favour. (Oneymus)

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Just discovered why it wont feed into the table;

It only picks up terminal not others, check the trigger and list above. Thanks

Post Reply