initial commit

This commit is contained in:
ember-rp
2024-05-17 23:27:34 +00:00
commit ee1e110336
112 changed files with 25062 additions and 0 deletions

1270
AIO_Server/AIO.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
LuaSrcDiet License
------------------
LuaSrcDiet is licensed under the terms of the MIT license reproduced
below. This means that LuaSrcDiet is free software and can be used for
both academic and commercial purposes at absolutely no cost.
Parts of LuaSrcDiet is based on Lua 5 code. See COPYRIGHT_Lua51
(Lua 5.1.3) for Lua 5 license information.
For details and rationale, see http://www.lua.org/license.html .
===============================================================================
Copyright (C) 2005-2008 Kein-Hong Man <khman@users.sf.net>
Lua 5.1.3 Copyright (C) 1994-2008 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================
(end of COPYRIGHT)

View File

@@ -0,0 +1,34 @@
Lua License
-----------
Lua is licensed under the terms of the MIT license reproduced below.
This means that Lua is free software and can be used for both academic
and commercial purposes at absolutely no cost.
For details and rationale, see http://www.lua.org/license.html .
===============================================================================
Copyright (C) 1994-2008 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================
(end of COPYRIGHT)

View File

@@ -0,0 +1,809 @@
#!/usr/bin/env lua
--[[--------------------------------------------------------------------
LuaSrcDiet
Compresses Lua source code by removing unnecessary characters.
For Lua 5.1.x source code.
Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
The COPYRIGHT file describes the conditions
under which this software may be distributed.
See the ChangeLog for more information.
----------------------------------------------------------------------]]
--[[--------------------------------------------------------------------
-- NOTES:
-- * Remember to update version and date information below (MSG_TITLE)
-- * TODO: to implement pcall() to properly handle lexer etc. errors
-- * TODO: verify token stream or double-check binary chunk?
-- * TODO: need some automatic testing for a semblance of sanity
-- * TODO: the plugin module is highly experimental and unstable
----------------------------------------------------------------------]]
-- standard libraries, functions
local string = string
local math = math
local table = table
local require = require
local print = print
local sub = string.sub
local gmatch = string.gmatch
-- support modules
local llex = require "llex"
local lparser = require "lparser"
local optlex = require "optlex"
local optparser = require "optparser"
local plugin
--[[--------------------------------------------------------------------
-- messages and textual data
----------------------------------------------------------------------]]
local MSG_TITLE = [[
LuaSrcDiet: Puts your Lua 5.1 source code on a diet
Version 0.11.2 (20080608) Copyright (c) 2005-2008 Kein-Hong Man
The COPYRIGHT file describes the conditions under which this
software may be distributed.
]]
local MSG_USAGE = [[
usage: LuaSrcDiet [options] [filenames]
example:
>LuaSrcDiet myscript.lua -o myscript_.lua
options:
-v, --version prints version information
-h, --help prints usage information
-o <file> specify file name to write output
-s <suffix> suffix for output files (default '_')
--keep <msg> keep block comment with <msg> inside
--plugin <module> run <module> in plugin/ directory
- stop handling arguments
(optimization levels)
--none all optimizations off (normalizes EOLs only)
--basic lexer-based optimizations only
--maximum maximize reduction of source
(informational)
--quiet process files quietly
--read-only read file and print token stats only
--dump-lexer dump raw tokens from lexer to stdout
--dump-parser dump variable tracking tables from parser
--details extra info (strings, numbers, locals)
features (to disable, insert 'no' prefix like --noopt-comments):
%s
default settings:
%s]]
------------------------------------------------------------------------
-- optimization options, for ease of switching on and off
-- * positive to enable optimization, negative (no) to disable
-- * these options should follow --opt-* and --noopt-* style for now
------------------------------------------------------------------------
local OPTION = [[
--opt-comments,'remove comments and block comments'
--opt-whitespace,'remove whitespace excluding EOLs'
--opt-emptylines,'remove empty lines'
--opt-eols,'all above, plus remove unnecessary EOLs'
--opt-strings,'optimize strings and long strings'
--opt-numbers,'optimize numbers'
--opt-locals,'optimize local variable names'
--opt-entropy,'tries to reduce symbol entropy of locals'
]]
-- preset configuration
local DEFAULT_CONFIG = [[
--opt-comments --opt-whitespace --opt-emptylines
--opt-numbers --opt-locals
]]
-- override configurations: MUST explicitly enable/disable everything
local BASIC_CONFIG = [[
--opt-comments --opt-whitespace --opt-emptylines
--noopt-eols --noopt-strings --noopt-numbers
--noopt-locals
]]
local MAXIMUM_CONFIG = [[
--opt-comments --opt-whitespace --opt-emptylines
--opt-eols --opt-strings --opt-numbers
--opt-locals --opt-entropy
]]
local NONE_CONFIG = [[
--noopt-comments --noopt-whitespace --noopt-emptylines
--noopt-eols --noopt-strings --noopt-numbers
--noopt-locals
]]
local DEFAULT_SUFFIX = "_" -- default suffix for file renaming
local PLUGIN_SUFFIX = "plugin/" -- relative location of plugins
--[[--------------------------------------------------------------------
-- startup and initialize option list handling
----------------------------------------------------------------------]]
-- simple error message handler; change to error if traceback wanted
local function die(msg)
print("LuaSrcDiet: "..msg); os.exit()
end
--die = error--DEBUG
--if not string.match(_VERSION, "5.1", 1, 1) then -- sanity check
-- die("requires Lua 5.1 to run")
--end
------------------------------------------------------------------------
-- prepares text for list of optimizations, prepare lookup table
------------------------------------------------------------------------
local MSG_OPTIONS = ""
do
local WIDTH = 24
local o = {}
for op, desc in gmatch(OPTION, "%s*([^,]+),'([^']+)'") do
local msg = " "..op
msg = msg..string.rep(" ", WIDTH - #msg)..desc.."\n"
MSG_OPTIONS = MSG_OPTIONS..msg
o[op] = true
o["--no"..sub(op, 3)] = true
end
OPTION = o -- replace OPTION with lookup table
end
MSG_USAGE = string.format(MSG_USAGE, MSG_OPTIONS, DEFAULT_CONFIG)
------------------------------------------------------------------------
-- global variable initialization, option set handling
------------------------------------------------------------------------
local suffix = DEFAULT_SUFFIX -- file suffix
local option = {} -- program options
local stat_c, stat_l -- statistics tables
-- function to set option lookup table based on a text list of options
-- note: additional forced settings for --opt-eols is done in optlex.lua
local function set_options(CONFIG)
for op in gmatch(CONFIG, "(%-%-%S+)") do
if sub(op, 3, 4) == "no" and -- handle negative options
OPTION["--"..sub(op, 5)] then
option[sub(op, 5)] = false
else
option[sub(op, 3)] = true
end
end
end
--[[--------------------------------------------------------------------
-- support functions
----------------------------------------------------------------------]]
-- list of token types, parser-significant types are up to TTYPE_GRAMMAR
-- while the rest are not used by parsers; arranged for stats display
local TTYPES = {
"TK_KEYWORD", "TK_NAME", "TK_NUMBER", -- grammar
"TK_STRING", "TK_LSTRING", "TK_OP",
"TK_EOS",
"TK_COMMENT", "TK_LCOMMENT", -- non-grammar
"TK_EOL", "TK_SPACE",
}
local TTYPE_GRAMMAR = 7
local EOLTYPES = { -- EOL names for token dump
["\n"] = "LF", ["\r"] = "CR",
["\n\r"] = "LFCR", ["\r\n"] = "CRLF",
}
------------------------------------------------------------------------
-- read source code from file
------------------------------------------------------------------------
local function load_file(fname)
local INF = io.open(fname, "rb")
if not INF then die("cannot open \""..fname.."\" for reading") end
local dat = INF:read("*a")
if not dat then die("cannot read from \""..fname.."\"") end
INF:close()
print("loadf ", type(dat))
return dat
end
------------------------------------------------------------------------
-- save source code to file
------------------------------------------------------------------------
local function save_file(fname, dat)
local OUTF = io.open(fname, "wb")
if not OUTF then die("cannot open \""..fname.."\" for writing") end
local status = OUTF:write(dat)
if not status then die("cannot write to \""..fname.."\"") end
OUTF:close()
print("loadf ", type(dat))
end
------------------------------------------------------------------------
-- functions to deal with statistics
------------------------------------------------------------------------
-- initialize statistics table
local function stat_init()
stat_c, stat_l = {}, {}
for i = 1, #TTYPES do
local ttype = TTYPES[i]
stat_c[ttype], stat_l[ttype] = 0, 0
end
end
-- add a token to statistics table
local function stat_add(tok, seminfo)
stat_c[tok] = stat_c[tok] + 1
stat_l[tok] = stat_l[tok] + #seminfo
end
-- do totals for statistics table, return average table
local function stat_calc()
local function avg(c, l) -- safe average function
if c == 0 then return 0 end
return l / c
end
local stat_a = {}
local c, l = 0, 0
for i = 1, TTYPE_GRAMMAR do -- total grammar tokens
local ttype = TTYPES[i]
c = c + stat_c[ttype]; l = l + stat_l[ttype]
end
stat_c.TOTAL_TOK, stat_l.TOTAL_TOK = c, l
stat_a.TOTAL_TOK = avg(c, l)
c, l = 0, 0
for i = 1, #TTYPES do -- total all tokens
local ttype = TTYPES[i]
c = c + stat_c[ttype]; l = l + stat_l[ttype]
stat_a[ttype] = avg(stat_c[ttype], stat_l[ttype])
end
stat_c.TOTAL_ALL, stat_l.TOTAL_ALL = c, l
stat_a.TOTAL_ALL = avg(c, l)
return stat_a
end
--[[--------------------------------------------------------------------
-- main tasks
----------------------------------------------------------------------]]
------------------------------------------------------------------------
-- a simple token dumper, minimal translation of seminfo data
------------------------------------------------------------------------
local function dump_tokens(srcfl)
--------------------------------------------------------------------
-- load file and process source input into tokens
--------------------------------------------------------------------
local z = load_file(srcfl)
llex.init(z)
llex.llex()
local toklist, seminfolist = llex.tok, llex.seminfo
--------------------------------------------------------------------
-- display output
--------------------------------------------------------------------
for i = 1, #toklist do
local tok, seminfo = toklist[i], seminfolist[i]
if tok == "TK_OP" and string.byte(seminfo) < 32 then
seminfo = "(".. string.byte(seminfo)..")"
elseif tok == "TK_EOL" then
seminfo = EOLTYPES[seminfo]
else
seminfo = "'"..seminfo.."'"
end
print(tok.." "..seminfo)
end--for
end
----------------------------------------------------------------------
-- parser dump; dump globalinfo and localinfo tables
----------------------------------------------------------------------
local function dump_parser(srcfl)
local print = print
--------------------------------------------------------------------
-- load file and process source input into tokens
--------------------------------------------------------------------
local z = load_file(srcfl)
llex.init(z)
llex.llex()
local toklist, seminfolist, toklnlist
= llex.tok, llex.seminfo, llex.tokln
--------------------------------------------------------------------
-- do parser optimization here
--------------------------------------------------------------------
lparser.init(toklist, seminfolist, toklnlist)
local globalinfo, localinfo = lparser.parser()
--------------------------------------------------------------------
-- display output
--------------------------------------------------------------------
local hl = string.rep("-", 72)
print("*** Local/Global Variable Tracker Tables ***")
print(hl.."\n GLOBALS\n"..hl)
-- global tables have a list of xref numbers only
for i = 1, #globalinfo do
local obj = globalinfo[i]
local msg = "("..i..") '"..obj.name.."' -> "
local xref = obj.xref
for j = 1, #xref do msg = msg..xref[j].." " end
print(msg)
end
-- local tables have xref numbers and a few other special
-- numbers that are specially named: decl (declaration xref),
-- act (activation xref), rem (removal xref)
print(hl.."\n LOCALS (decl=declared act=activated rem=removed)\n"..hl)
for i = 1, #localinfo do
local obj = localinfo[i]
local msg = "("..i..") '"..obj.name.."' decl:"..obj.decl..
" act:"..obj.act.." rem:"..obj.rem
if obj.isself then
msg = msg.." isself"
end
msg = msg.." -> "
local xref = obj.xref
for j = 1, #xref do msg = msg..xref[j].." " end
print(msg)
end
print(hl.."\n")
end
------------------------------------------------------------------------
-- reads source file(s) and reports some statistics
------------------------------------------------------------------------
local function read_only(srcfl)
local print = print
--------------------------------------------------------------------
-- load file and process source input into tokens
--------------------------------------------------------------------
local z = load_file(srcfl)
llex.init(z)
llex.llex()
local toklist, seminfolist = llex.tok, llex.seminfo
print(MSG_TITLE)
print("Statistics for: "..srcfl.."\n")
--------------------------------------------------------------------
-- collect statistics
--------------------------------------------------------------------
stat_init()
for i = 1, #toklist do
local tok, seminfo = toklist[i], seminfolist[i]
stat_add(tok, seminfo)
end--for
local stat_a = stat_calc()
--------------------------------------------------------------------
-- display output
--------------------------------------------------------------------
local fmt = string.format
local function figures(tt)
return stat_c[tt], stat_l[tt], stat_a[tt]
end
local tabf1, tabf2 = "%-16s%8s%8s%10s", "%-16s%8d%8d%10.2f"
local hl = string.rep("-", 42)
print(fmt(tabf1, "Lexical", "Input", "Input", "Input"))
print(fmt(tabf1, "Elements", "Count", "Bytes", "Average"))
print(hl)
for i = 1, #TTYPES do
local ttype = TTYPES[i]
print(fmt(tabf2, ttype, figures(ttype)))
if ttype == "TK_EOS" then print(hl) end
end
print(hl)
print(fmt(tabf2, "Total Elements", figures("TOTAL_ALL")))
print(hl)
print(fmt(tabf2, "Total Tokens", figures("TOTAL_TOK")))
print(hl.."\n")
end
------------------------------------------------------------------------
-- process source file(s), write output and reports some statistics
------------------------------------------------------------------------
local function process_file(srcfl, destfl)
local function print(...) -- handle quiet option
if option.QUIET then return end
_G.print(...)
end
if plugin and plugin.init then -- plugin init
option.EXIT = false
plugin.init(option, srcfl, destfl)
if option.EXIT then return end
end
print(MSG_TITLE) -- title message
--------------------------------------------------------------------
-- load file and process source input into tokens
--------------------------------------------------------------------
local z = load_file(srcfl)
if plugin and plugin.post_load then -- plugin post-load
z = plugin.post_load(z) or z
if option.EXIT then return end
end
llex.init(z)
llex.llex()
local toklist, seminfolist, toklnlist
= llex.tok, llex.seminfo, llex.tokln
if plugin and plugin.post_lex then -- plugin post-lex
plugin.post_lex(toklist, seminfolist, toklnlist)
if option.EXIT then return end
end
--------------------------------------------------------------------
-- collect 'before' statistics
--------------------------------------------------------------------
stat_init()
for i = 1, #toklist do
local tok, seminfo = toklist[i], seminfolist[i]
stat_add(tok, seminfo)
end--for
local stat1_a = stat_calc()
local stat1_c, stat1_l = stat_c, stat_l
--------------------------------------------------------------------
-- do parser optimization here
--------------------------------------------------------------------
if option["opt-locals"] then
optparser.print = print -- hack
lparser.init(toklist, seminfolist, toklnlist)
local globalinfo, localinfo = lparser.parser()
if plugin and plugin.post_parse then -- plugin post-parse
plugin.post_parse(globalinfo, localinfo)
if option.EXIT then return end
end
optparser.optimize(option, toklist, seminfolist, globalinfo, localinfo)
if plugin and plugin.post_optparse then -- plugin post-optparse
plugin.post_optparse()
if option.EXIT then return end
end
end
--------------------------------------------------------------------
-- do lexer optimization here, save output file
--------------------------------------------------------------------
optlex.print = print -- hack
toklist, seminfolist, toklnlist
= optlex.optimize(option, toklist, seminfolist, toklnlist)
if plugin and plugin.post_optlex then -- plugin post-optlex
plugin.post_optlex(toklist, seminfolist, toklnlist)
if option.EXIT then return end
end
local dat = table.concat(seminfolist)
-- depending on options selected, embedded EOLs in long strings and
-- long comments may not have been translated to \n, tack a warning
if string.find(dat, "\r\n", 1, 1) or
string.find(dat, "\n\r", 1, 1) then
optlex.warn.mixedeol = true
end
-- save optimized source stream to output file
save_file(destfl, dat)
--------------------------------------------------------------------
-- collect 'after' statistics
--------------------------------------------------------------------
stat_init()
for i = 1, #toklist do
local tok, seminfo = toklist[i], seminfolist[i]
stat_add(tok, seminfo)
end--for
local stat_a = stat_calc()
--------------------------------------------------------------------
-- display output
--------------------------------------------------------------------
-- print("Statistics for: "..srcfl.." -> "..destfl.."\n")
-- local fmt = string.format
-- local function figures(tt)
-- return stat1_c[tt], stat1_l[tt], stat1_a[tt],
-- stat_c[tt], stat_l[tt], stat_a[tt]
-- end
-- local tabf1, tabf2 = "%-16s%8s%8s%10s%8s%8s%10s",
-- "%-16s%8d%8d%10.2f%8d%8d%10.2f"
-- local hl = string.rep("-", 68)
-- print("*** lexer-based optimizations summary ***\n"..hl)
-- print(fmt(tabf1, "Lexical",
-- "Input", "Input", "Input",
-- "Output", "Output", "Output"))
-- print(fmt(tabf1, "Elements",
-- "Count", "Bytes", "Average",
-- "Count", "Bytes", "Average"))
-- print(hl)
-- for i = 1, #TTYPES do
-- local ttype = TTYPES[i]
-- print(fmt(tabf2, ttype, figures(ttype)))
-- if ttype == "TK_EOS" then print(hl) end
-- end
-- print(hl)
-- print(fmt(tabf2, "Total Elements", figures("TOTAL_ALL")))
-- print(hl)
-- print(fmt(tabf2, "Total Tokens", figures("TOTAL_TOK")))
-- print(hl)
--------------------------------------------------------------------
-- report warning flags from optimizing process
--------------------------------------------------------------------
if optlex.warn.lstring then
print("* WARNING: "..optlex.warn.lstring)
elseif optlex.warn.mixedeol then
print("* WARNING: ".."output still contains some CRLF or LFCR line endings")
end
print()
end
local function process_code(code, config)
option.QUIET = true
if config == 1 then
set_options(DEFAULT_CONFIG)
elseif config == 2 then
set_options(BASIC_CONFIG)
elseif config == 3 then
set_options(MAXIMUM_CONFIG)
else
set_options(NONE_CONFIG)
end
local function print(...) -- handle quiet option
if option.QUIET then return end
_G.print(...)
end
-- if plugin and plugin.init then -- plugin init
-- option.EXIT = false
-- plugin.init(option, srcfl, destfl)
-- if option.EXIT then return end
-- end
print(MSG_TITLE) -- title message
--------------------------------------------------------------------
-- load file and process source input into tokens
--------------------------------------------------------------------
local z = code -- load_file(srcfl)
if plugin and plugin.post_load then -- plugin post-load
z = plugin.post_load(z) or z
if option.EXIT then return end
end
llex.init(z)
llex.llex()
local toklist, seminfolist, toklnlist
= llex.tok, llex.seminfo, llex.tokln
if plugin and plugin.post_lex then -- plugin post-lex
plugin.post_lex(toklist, seminfolist, toklnlist)
if option.EXIT then return end
end
--------------------------------------------------------------------
-- collect 'before' statistics
--------------------------------------------------------------------
stat_init()
for i = 1, #toklist do
local tok, seminfo = toklist[i], seminfolist[i]
stat_add(tok, seminfo)
end--for
local stat1_a = stat_calc()
local stat1_c, stat1_l = stat_c, stat_l
--------------------------------------------------------------------
-- do parser optimization here
--------------------------------------------------------------------
if option["opt-locals"] then
optparser.print = print -- hack
lparser.init(toklist, seminfolist, toklnlist)
local globalinfo, localinfo = lparser.parser()
if plugin and plugin.post_parse then -- plugin post-parse
plugin.post_parse(globalinfo, localinfo)
if option.EXIT then return end
end
optparser.optimize(option, toklist, seminfolist, globalinfo, localinfo)
if plugin and plugin.post_optparse then -- plugin post-optparse
plugin.post_optparse()
if option.EXIT then return end
end
end
--------------------------------------------------------------------
-- do lexer optimization here, save output file
--------------------------------------------------------------------
optlex.print = print -- hack
toklist, seminfolist, toklnlist
= optlex.optimize(option, toklist, seminfolist, toklnlist)
if plugin and plugin.post_optlex then -- plugin post-optlex
plugin.post_optlex(toklist, seminfolist, toklnlist)
if option.EXIT then return end
end
local dat = table.concat(seminfolist)
-- depending on options selected, embedded EOLs in long strings and
-- long comments may not have been translated to \n, tack a warning
if string.find(dat, "\r\n", 1, 1) or
string.find(dat, "\n\r", 1, 1) then
optlex.warn.mixedeol = true
end
-- save optimized source stream to output file
-- save_file(destfl, dat)
--------------------------------------------------------------------
-- collect 'after' statistics
--------------------------------------------------------------------
-- stat_init()
-- for i = 1, #toklist do
-- local tok, seminfo = toklist[i], seminfolist[i]
-- stat_add(tok, seminfo)
-- end--for
-- local stat_a = stat_calc()
--------------------------------------------------------------------
-- display output
--------------------------------------------------------------------
-- print("Statistics for: "..srcfl.." -> "..destfl.."\n")
-- local fmt = string.format
-- local function figures(tt)
-- return stat1_c[tt], stat1_l[tt], stat1_a[tt],
-- stat_c[tt], stat_l[tt], stat_a[tt]
-- end
-- local tabf1, tabf2 = "%-16s%8s%8s%10s%8s%8s%10s",
-- "%-16s%8d%8d%10.2f%8d%8d%10.2f"
-- local hl = string.rep("-", 68)
-- print("*** lexer-based optimizations summary ***\n"..hl)
-- print(fmt(tabf1, "Lexical",
-- "Input", "Input", "Input",
-- "Output", "Output", "Output"))
-- print(fmt(tabf1, "Elements",
-- "Count", "Bytes", "Average",
-- "Count", "Bytes", "Average"))
-- print(hl)
-- for i = 1, #TTYPES do
-- local ttype = TTYPES[i]
-- print(fmt(tabf2, ttype, figures(ttype)))
-- if ttype == "TK_EOS" then print(hl) end
-- end
-- print(hl)
-- print(fmt(tabf2, "Total Elements", figures("TOTAL_ALL")))
-- print(hl)
-- print(fmt(tabf2, "Total Tokens", figures("TOTAL_TOK")))
-- print(hl)
--------------------------------------------------------------------
-- report warning flags from optimizing process
--------------------------------------------------------------------
if optlex.warn.lstring then
print("* WARNING: "..optlex.warn.lstring)
elseif optlex.warn.mixedeol then
print("* WARNING: ".."output still contains some CRLF or LFCR line endings")
end
print()
return dat
end
--[[--------------------------------------------------------------------
-- main functions
----------------------------------------------------------------------]]
local arg = {...} -- program arguments
local fspec = {}
set_options(DEFAULT_CONFIG) -- set to default options at beginning
------------------------------------------------------------------------
-- per-file handling, ship off to tasks
------------------------------------------------------------------------
local function do_files(fspec)
for _, srcfl in ipairs(fspec) do
local destfl
------------------------------------------------------------------
-- find and replace extension for filenames
------------------------------------------------------------------
local extb, exte = string.find(srcfl, "%.[^%.%\\%/]*$")
local basename, extension = srcfl, ""
if extb and extb > 1 then
basename = sub(srcfl, 1, extb - 1)
extension = sub(srcfl, extb, exte)
end
destfl = basename..suffix..extension
if #fspec == 1 and option.OUTPUT_FILE then
destfl = option.OUTPUT_FILE
end
if srcfl == destfl then
die("output filename identical to input filename")
end
------------------------------------------------------------------
-- perform requested operations
------------------------------------------------------------------
if option.DUMP_LEXER then
dump_tokens(srcfl)
elseif option.DUMP_PARSER then
dump_parser(srcfl)
elseif option.READ_ONLY then
read_only(srcfl)
else
process_file(srcfl, destfl)
end
end--for
end
------------------------------------------------------------------------
-- main function (entry point is after this definition)
------------------------------------------------------------------------
local function main()
local argn, i = #arg, 1
if argn == 0 then
option.HELP = true
end
--------------------------------------------------------------------
-- handle arguments
--------------------------------------------------------------------
while i <= argn do
local o, p = arg[i], arg[i + 1]
local dash = string.match(o, "^%-%-?")
if dash == "-" then -- single-dash options
if o == "-h" then
option.HELP = true; break
elseif o == "-v" then
option.VERSION = true; break
elseif o == "-s" then
if not p then die("-s option needs suffix specification") end
suffix = p
i = i + 1
elseif o == "-o" then
if not p then die("-o option needs a file name") end
option.OUTPUT_FILE = p
i = i + 1
elseif o == "-" then
break -- ignore rest of args
else
die("unrecognized option "..o)
end
elseif dash == "--" then -- double-dash options
if o == "--help" then
option.HELP = true; break
elseif o == "--version" then
option.VERSION = true; break
elseif o == "--keep" then
if not p then die("--keep option needs a string to match for") end
option.KEEP = p
i = i + 1
elseif o == "--plugin" then
if not p then die("--plugin option needs a module name") end
if option.PLUGIN then die("only one plugin can be specified") end
option.PLUGIN = p
plugin = require(PLUGIN_SUFFIX..p)
i = i + 1
elseif o == "--quiet" then
option.QUIET = true
elseif o == "--read-only" then
option.READ_ONLY = true
elseif o == "--basic" then
set_options(BASIC_CONFIG)
elseif o == "--maximum" then
set_options(MAXIMUM_CONFIG)
elseif o == "--none" then
set_options(NONE_CONFIG)
elseif o == "--dump-lexer" then
option.DUMP_LEXER = true
elseif o == "--dump-parser" then
option.DUMP_PARSER = true
elseif o == "--details" then
option.DETAILS = true
elseif OPTION[o] then -- lookup optimization options
set_options(o)
else
die("unrecognized option "..o)
end
else
fspec[#fspec + 1] = o -- potential filename
end
i = i + 1
end--while
if option.HELP then
print(MSG_TITLE..MSG_USAGE); return true
elseif option.VERSION then
print(MSG_TITLE); return true
end
if #fspec > 0 then
if #fspec > 1 and option.OUTPUT_FILE then
die("with -o, only one source file can be specified")
end
do_files(fspec)
return true
else
die("nothing to do!")
end
end
-- entry point -> main() -> do_files()
-- if not main() then
-- die("Please run with option -h or --help for usage information")
-- end
-- end of script
return process_code

View File

@@ -0,0 +1,193 @@
LuaSrcDiet
Compresses Lua source code by removing unnecessary characters.
Copyright (c) 2005-2008 Kein-Hong Man <khman@users.sf.net>
The COPYRIGHT file describes the conditions
under which this software may be distributed.
http://luaforge.net/projects/luasrcdiet/
http://luasrcdiet.luaforge.net/
--
For the older unmaintained version of LuaSrcDiet for Lua 5.0.2 sources,
please see the 5.0/README file.
--
PREVIEW NOTES
See also: http://luasrcdiet.luaforge.net/
The 0.11.0 release of LuaSrcDiet has a local variable name optimizer.
Local variable names are renamed into the shortest possible names. In
addition, variable names are reused whenever possible, reducing the
number of unique variable names. Several hundred local variable names
can be reduced into 53 or less unique names, which allows all locals
to be single-character in length.
The local variable name optimizer uses a full parser of Lua 5.1 source
code, thus it can rename all local variables, including function
parameters. It should handle the implicit "self" parameter gracefully.
The optimizer needs more testing, but is already able to optimize the
LuaSrcDiet sources itself and generate correct Lua output.
String and number token optimizations are also performed, apart from the
usual whitespace, line ending and comment removal. Numbers can switch
between different formats. Strings can be simplified and can switch
delimiters between " or ' characters.
Most options can also be enabled or disabled separately, for maximum
flexibility. If you need to keep a copyright message in the optimized
output, the --keep option can keep block comments that contain a certain
string.
For samples, see the sample/ directory. Performance statistics can be
found in the sample/statistics.txt file. Preliminary test samples for
strings and numbers can also be found in the sample/ directory.
Priority for future work:
(a) automatic tests for lexer/parser optimizations
(b) integrity checking, token stream check or binary chunk check
--
INTRODUCTION
...
WARNING! Locals optimization does NOT have support for 'arg' vararg
functions (LUA_COMPAT_VARARG).
--
WHAT'S NEW
Major changes for version 0.11.2 (see the ChangeLog as well):
* improved local variable name allocation, more efficient now
* added experimental --plugin option with an example plugin script
* added a SLOC plugin to count SLOC for Lua 5.1 source files
* added a HTML plugin to see globals and locals marked
Major changes for version 0.11.1 (see the ChangeLog as well):
* --detail option for more string, number and local variable info
* fixed a local rename bug that generates names that are keywords
* added explanatory notes on local variable optimization
* added --opt-entropy option for locals to reduce symbol entropy
Major changes for version 0.11.0 (see the ChangeLog as well):
* Local variable name optimization.
* Many options and sample output added.
Major changes for version 0.10.2 (see the ChangeLog as well):
* Aggressive optimizations for string and number tokens.
* Minor bug fixes.
Major changes for version 0.10.1 (see the ChangeLog as well):
* Totally rewritten for Lua 5.1.x.
--
USAGE OPTIONS
...
Example of summary data display:
Statistics for: LuaSrcDiet.lua -> sample/LuaSrcDiet.lua
*** local variable optimization summary ***
----------------------------------------------------------
Variable Unique Decl. Token Size Average
Types Names Count Count Bytes Bytes
----------------------------------------------------------
Global 10 0 19 95 5.00
----------------------------------------------------------
Local (in) 88 153 683 3340 4.89
TOTAL (in) 98 153 702 3435 4.89
----------------------------------------------------------
Local (out) 32 153 683 683 1.00
TOTAL (out) 42 153 702 778 1.11
----------------------------------------------------------
*** lexer-based optimizations summary ***
--------------------------------------------------------------------
Lexical Input Input Input Output Output Output
Elements Count Bytes Average Count Bytes Average
--------------------------------------------------------------------
TK_KEYWORD 374 1531 4.09 374 1531 4.09
TK_NAME 795 3963 4.98 795 1306 1.64
TK_NUMBER 54 59 1.09 54 59 1.09
TK_STRING 152 1725 11.35 152 1717 11.30
TK_LSTRING 7 1976 282.29 7 1976 282.29
TK_OP 997 1092 1.10 997 1092 1.10
TK_EOS 1 0 0.00 1 0 0.00
--------------------------------------------------------------------
TK_COMMENT 140 6884 49.17 1 18 18.00
TK_LCOMMENT 7 1723 246.14 0 0 0.00
TK_EOL 543 543 1.00 197 197 1.00
TK_SPACE 1270 2465 1.94 263 263 1.00
--------------------------------------------------------------------
Total Elements 4340 21961 5.06 2841 8159 2.87
--------------------------------------------------------------------
Total Tokens 2380 10346 4.35 2380 7681 3.23
--------------------------------------------------------------------
--
USING LUASRCDIET
...
Please see the command line help or see sample/Makefile for examples.
This is experimental software and nothing has been done yet on a proper
installation scheme for use with normal work. A thousand apologies...
--
CODE SIZE REDUCTION
...
--
OTHER OPTIONS
...
--
BEHAVIOUR NOTES
* embedded line endings in strings and long strings always
normalized to LF
* will not optimize trailing spaces in long strings, only warns
* scientific notation generated in number optimzation is not in
canonical form, this may or may not be a bad thing, so feedback
is welcome
--
ACKNOWLEDGEMENTS
Thanks to the LuaForge people for hosting this.
Developed on SciTE http://www.scintilla.org/. Two thumbs up.
--
FEEDBACK
Feedback and contributions are welcome. Your name will be acknowledged,
as long as you are willing to comply with COPYRIGHT. If your material is
self-contained, you can retain a copyright notice for those material in
your own name, as long as you use the same Lua 5/MIT-style copyright.
My alternative e-mail address is: keinhong AT gmail DOT com
Enjoy!!
Kein-Hong Man (esq.)
Kuala Lumpur
Malaysia 20080603

View File

@@ -0,0 +1,355 @@
--[[--------------------------------------------------------------------
base.llex.lua: Lua 5.1 lexical analyzer in Lua
This file is part of LuaSrcDiet, based on Yueliang material.
Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
The COPYRIGHT file describes the conditions
under which this software may be distributed.
See the ChangeLog for more information.
----------------------------------------------------------------------]]
--[[--------------------------------------------------------------------
-- NOTES:
-- * This is a version of the native 5.1.x lexer from Yueliang 0.4.0,
-- with significant modifications to handle LuaSrcDiet's needs:
-- (1) base.llex.error is an optional error function handler
-- (2) base.seminfo for strings include their delimiters and no
-- translation operations are performed on them
-- * ADDED shbang handling has been added to support executable scripts
-- * NO localized decimal point replacement magic
-- * NO limit to number of lines
-- * NO support for compatible long strings (LUA_COMPAT_LSTR)
-- * Please read technotes.txt for more technical details.
----------------------------------------------------------------------]]
local base = {}
-- local base = _G
-- local string = require "string"
-- module "base.llex"
local find = string.find
local match = string.match
local sub = string.sub
----------------------------------------------------------------------
-- initialize keyword list, variables
----------------------------------------------------------------------
local kw = {}
for v in string.gmatch([[
and break do else elseif end false for function if in
local nil not or repeat return then true until while]], "%S+") do
kw[v] = true
end
-- NOTE: see init() for module variables (externally visible):
-- base.tok, base.seminfo, base.tokln
local z, -- source stream
sourceid, -- name of source
I, -- position of lexer
buff, -- buffer for strings
ln -- line number
----------------------------------------------------------------------
-- add information to token listing
----------------------------------------------------------------------
local function addtoken(token, info)
local i = #base.tok + 1
base.tok[i] = token
base.seminfo[i] = info
base.tokln[i] = ln
end
----------------------------------------------------------------------
-- handles line number incrementation and end-of-line characters
----------------------------------------------------------------------
local function inclinenumber(i, is_tok)
local sub = sub
local old = sub(z, i, i)
i = i + 1 -- skip '\n' or '\r'
local c = sub(z, i, i)
if (c == "\n" or c == "\r") and (c ~= old) then
i = i + 1 -- skip '\n\r' or '\r\n'
old = old..c
end
if is_tok then addtoken("TK_EOL", old) end
ln = ln + 1
I = i
return i
end
----------------------------------------------------------------------
-- initialize lexer for given source _z and source name _sourceid
----------------------------------------------------------------------
function base.init(_z, _sourceid)
z = _z -- source
sourceid = _sourceid -- name of source
I = 1 -- lexer's position in source
ln = 1 -- line number
base.tok = {} -- lexed token list*
base.seminfo = {} -- lexed semantic information list*
base.tokln = {} -- line numbers for messages*
-- (*) externally visible thru' module
--------------------------------------------------------------------
-- initial processing (shbang handling)
--------------------------------------------------------------------
local p, _, q, r = find(z, "^(#[^\r\n]*)(\r?\n?)")
if p then -- skip first line
I = I + #q
addtoken("TK_COMMENT", q)
if #r > 0 then inclinenumber(I, true) end
end
end
----------------------------------------------------------------------
-- returns a chunk name or id, no truncation for long names
----------------------------------------------------------------------
function base.chunkid()
if sourceid and match(sourceid, "^[=@]") then
return sub(sourceid, 2) -- remove first char
end
return "[string]"
end
----------------------------------------------------------------------
-- formats error message and throws error
-- * a simplified version, does not report what token was responsible
----------------------------------------------------------------------
function base.errorline(s, line)
local e = error or base.error
e(string.format("%s:%d: %s", base.chunkid(), line or ln, s))
end
------------------------------------------------------------------------
-- count separators ("=") in a long string delimiter
------------------------------------------------------------------------
local function skip_sep(i)
local sub = sub
local s = sub(z, i, i)
i = i + 1
local count = #match(z, "=*", i) -- note, take the length
i = i + count
I = i
return (sub(z, i, i) == s) and count or (-count) - 1
end
----------------------------------------------------------------------
-- reads a long string or long comment
----------------------------------------------------------------------
local function read_long_string(is_str, sep)
local i = I + 1 -- skip 2nd '['
local sub = sub
local c = sub(z, i, i)
if c == "\r" or c == "\n" then -- string starts with a newline?
i = inclinenumber(i) -- skip it
end
local j = i
while true do
local p, q, r = find(z, "([\r\n%]])", i) -- (long range)
if not p then
base.errorline(is_str and "unfinished long string" or
"unfinished long comment")
end
i = p
if r == "]" then -- delimiter test
if skip_sep(i) == sep then
buff = sub(z, buff, I)
I = I + 1 -- skip 2nd ']'
return buff
end
i = I
else -- newline
buff = buff.."\n"
i = inclinenumber(i)
end
end--while
end
----------------------------------------------------------------------
-- reads a string
----------------------------------------------------------------------
local function read_string(del)
local i = I
local find = find
local sub = sub
while true do
local p, q, r = find(z, "([\n\r\\\"\'])", i) -- (long range)
if p then
if r == "\n" or r == "\r" then
base.errorline("unfinished string")
end
i = p
if r == "\\" then -- handle escapes
i = i + 1
r = sub(z, i, i)
if r == "" then break end -- (EOZ error)
p = find("abfnrtv\n\r", r, 1, true)
------------------------------------------------------
if p then -- special escapes
if p > 7 then
i = inclinenumber(i)
else
i = i + 1
end
------------------------------------------------------
elseif find(r, "%D") then -- other non-digits
i = i + 1
------------------------------------------------------
else -- \xxx sequence
local p, q, s = find(z, "^(%d%d?%d?)", i)
i = q + 1
if s + 1 > 256 then -- UCHAR_MAX
base.errorline("escape sequence too large")
end
------------------------------------------------------
end--if p
else
i = i + 1
if r == del then -- ending delimiter
I = i
return sub(z, buff, i - 1) -- return string
end
end--if r
else
break -- (error)
end--if p
end--while
base.errorline("unfinished string")
end
------------------------------------------------------------------------
-- main lexer function
------------------------------------------------------------------------
function base.llex()
local find = find
local match = match
while true do--outer
local i = I
-- inner loop allows break to be used to nicely section tests
while true do--inner
----------------------------------------------------------------
local p, _, r = find(z, "^([_%a][_%w]*)", i)
if p then
I = i + #r
if kw[r] then
addtoken("TK_KEYWORD", r) -- reserved word (keyword)
else
addtoken("TK_NAME", r) -- identifier
end
break -- (continue)
end
----------------------------------------------------------------
local p, _, r = find(z, "^(%.?)%d", i)
if p then -- numeral
if r == "." then i = i + 1 end
local _, q, r = find(z, "^%d*[%.%d]*([eE]?)", i)
i = q + 1
if #r == 1 then -- optional exponent
if match(z, "^[%+%-]", i) then -- optional sign
i = i + 1
end
end
local _, q = find(z, "^[_%w]*", i)
I = q + 1
local v = sub(z, p, q) -- string equivalent
if not tonumber(v) then -- handles hex test also
base.errorline("malformed number")
end
addtoken("TK_NUMBER", v)
break -- (continue)
end
----------------------------------------------------------------
local p, q, r, t = find(z, "^((%s)[ \t\v\f]*)", i)
if p then
if t == "\n" or t == "\r" then -- newline
inclinenumber(i, true)
else
I = q + 1 -- whitespace
addtoken("TK_SPACE", r)
end
break -- (continue)
end
----------------------------------------------------------------
local r = match(z, "^%p", i)
if r then
buff = i
local p = find("-[\"\'.=<>~", r, 1, true)
if p then
-- two-level if block for punctuation/symbols
--------------------------------------------------------
if p <= 2 then
if p == 1 then -- minus
local c = match(z, "^%-%-(%[?)", i)
if c then
i = i + 2
local sep = -1
if c == "[" then
sep = skip_sep(i)
end
if sep >= 0 then -- long comment
addtoken("TK_LCOMMENT", read_long_string(false, sep))
else -- short comment
I = find(z, "[\n\r]", i) or (#z + 1)
addtoken("TK_COMMENT", sub(z, buff, I - 1))
end
break -- (continue)
end
-- (fall through for "-")
else -- [ or long string
local sep = skip_sep(i)
if sep >= 0 then
addtoken("TK_LSTRING", read_long_string(true, sep))
elseif sep == -1 then
addtoken("TK_OP", "[")
else
base.errorline("invalid long string delimiter")
end
break -- (continue)
end
--------------------------------------------------------
elseif p <= 5 then
if p < 5 then -- strings
I = i + 1
addtoken("TK_STRING", read_string(r))
break -- (continue)
end
r = match(z, "^%.%.?%.?", i) -- .|..|... dots
-- (fall through)
--------------------------------------------------------
else -- relational
r = match(z, "^%p=?", i)
-- (fall through)
end
end
I = i + #r
addtoken("TK_OP", r) -- for other symbols, fall through
break -- (continue)
end
----------------------------------------------------------------
local r = sub(z, i, i)
if r ~= "" then
I = i + 1
addtoken("TK_OP", r) -- other single-char tokens
break
end
addtoken("TK_EOS", "") -- end of stream,
return base -- exit here
----------------------------------------------------------------
end--while inner
end--while outer
end
return base

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,837 @@
--[[--------------------------------------------------------------------
optlex.lua: does lexer-based optimizations
This file is part of LuaSrcDiet.
Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
The COPYRIGHT file describes the conditions
under which this software may be distributed.
See the ChangeLog for more information.
----------------------------------------------------------------------]]
--[[--------------------------------------------------------------------
-- NOTES:
-- * For more lexer-based optimization ideas, see the TODO items or
-- look at technotes.txt.
-- * TODO: general string delimiter conversion optimizer
-- * TODO: (numbers) warn if overly significant digit
----------------------------------------------------------------------]]
local base = {}
-- local base = _G
-- local string = require "string"
-- module "optlex"
local match = string.match
local sub = string.sub
local find = string.find
local rep = string.rep
local print = print
local tostring = tostring
local tonumber = tonumber
------------------------------------------------------------------------
-- variables and data structures
------------------------------------------------------------------------
-- error function, can override by setting own function into module
local error = error
base.warn = {} -- table for warning flags
local stoks, sinfos, stoklns -- source lists
local is_realtoken = { -- significant (grammar) tokens
TK_KEYWORD = true,
TK_NAME = true,
TK_NUMBER = true,
TK_STRING = true,
TK_LSTRING = true,
TK_OP = true,
TK_EOS = true,
}
local is_faketoken = { -- whitespace (non-grammar) tokens
TK_COMMENT = true,
TK_LCOMMENT = true,
TK_EOL = true,
TK_SPACE = true,
}
local opt_details -- for extra information
------------------------------------------------------------------------
-- true if current token is at the start of a line
-- * skips over deleted tokens via recursion
------------------------------------------------------------------------
local function atlinestart(i)
local tok = stoks[i - 1]
if i <= 1 or tok == "TK_EOL" then
return true
elseif tok == "" then
return atlinestart(i - 1)
end
return false
end
------------------------------------------------------------------------
-- true if current token is at the end of a line
-- * skips over deleted tokens via recursion
------------------------------------------------------------------------
local function atlineend(i)
local tok = stoks[i + 1]
if i >= #stoks or tok == "TK_EOL" or tok == "TK_EOS" then
return true
elseif tok == "" then
return atlineend(i + 1)
end
return false
end
------------------------------------------------------------------------
-- counts comment EOLs inside a long comment
-- * in order to keep line numbering, EOLs need to be reinserted
------------------------------------------------------------------------
local function commenteols(lcomment)
local sep = #match(lcomment, "^%-%-%[=*%[")
local z = sub(lcomment, sep + 1, -(sep - 1)) -- remove delims
local i, c = 1, 0
while true do
local p, q, r, s = find(z, "([\r\n])([\r\n]?)", i)
if not p then break end -- if no matches, done
i = p + 1
c = c + 1
if #s > 0 and r ~= s then -- skip CRLF or LFCR
i = i + 1
end
end
return c
end
------------------------------------------------------------------------
-- compares two tokens (i, j) and returns the whitespace required
-- * important! see technotes.txt for more information
-- * only two grammar/real tokens are being considered
-- * if "", no separation is needed
-- * if " ", then at least one whitespace (or EOL) is required
------------------------------------------------------------------------
local function checkpair(i, j)
local match = match
local t1, t2 = stoks[i], stoks[j]
--------------------------------------------------------------------
if t1 == "TK_STRING" or t1 == "TK_LSTRING" or
t2 == "TK_STRING" or t2 == "TK_LSTRING" then
return ""
--------------------------------------------------------------------
elseif t1 == "TK_OP" or t2 == "TK_OP" then
if (t1 == "TK_OP" and (t2 == "TK_KEYWORD" or t2 == "TK_NAME")) or
(t2 == "TK_OP" and (t1 == "TK_KEYWORD" or t1 == "TK_NAME")) then
return ""
end
if t1 == "TK_OP" and t2 == "TK_OP" then
-- for TK_OP/TK_OP pairs, see notes in technotes.txt
local op, op2 = sinfos[i], sinfos[j]
if (match(op, "^%.%.?$") and match(op2, "^%.")) or
(match(op, "^[~=<>]$") and op2 == "=") or
(op == "[" and (op2 == "[" or op2 == "=")) then
return " "
end
return ""
end
-- "TK_OP" + "TK_NUMBER" case
local op = sinfos[i]
if t2 == "TK_OP" then op = sinfos[j] end
if match(op, "^%.%.?%.?$") then
return " "
end
return ""
--------------------------------------------------------------------
else-- "TK_KEYWORD" | "TK_NAME" | "TK_NUMBER" then
return " "
--------------------------------------------------------------------
end
end
------------------------------------------------------------------------
-- repack tokens, removing deletions caused by optimization process
------------------------------------------------------------------------
local function repack_tokens()
local dtoks, dinfos, dtoklns = {}, {}, {}
local j = 1
for i = 1, #stoks do
local tok = stoks[i]
if tok ~= "" then
dtoks[j], dinfos[j], dtoklns[j] = tok, sinfos[i], stoklns[i]
j = j + 1
end
end
stoks, sinfos, stoklns = dtoks, dinfos, dtoklns
end
------------------------------------------------------------------------
-- number optimization
-- * optimization using string formatting functions is one way of doing
-- this, but here, we consider all cases and handle them separately
-- (possibly an idiotic approach...)
-- * scientific notation being generated is not in canonical form, this
-- may or may not be a bad thing, feedback welcome
-- * note: intermediate portions need to fit into a normal number range
-- * optimizations can be divided based on number patterns:
-- * hexadecimal:
-- (1) no need to remove leading zeros, just skip to (2)
-- (2) convert to integer if size equal or smaller
-- * change if equal size -> lose the 'x' to reduce entropy
-- (3) number is then processed as an integer
-- (4) note: does not make 0[xX] consistent
-- * integer:
-- (1) note: includes anything with trailing ".", ".0", ...
-- (2) remove useless fractional part, if present, e.g. 123.000
-- (3) remove leading zeros, e.g. 000123
-- (4) switch to scientific if shorter, e.g. 123000 -> 123e3
-- * with fraction:
-- (1) split into digits dot digits
-- (2) if no integer portion, take as zero (can omit later)
-- (3) handle degenerate .000 case, after which the fractional part
-- must be non-zero (if zero, it's matched as an integer)
-- (4) remove trailing zeros for fractional portion
-- (5) p.q where p > 0 and q > 0 cannot be shortened any more
-- (6) otherwise p == 0 and the form is .q, e.g. .000123
-- (7) if scientific shorter, convert, e.g. .000123 -> 123e-6
-- * scientific:
-- (1) split into (digits dot digits) [eE] ([+-] digits)
-- (2) if significand has ".", shift it out so it becomes an integer
-- (3) if significand is zero, just use zero
-- (4) remove leading zeros for significand
-- (5) shift out trailing zeros for significand
-- (6) examine exponent and determine which format is best:
-- integer, with fraction, scientific
------------------------------------------------------------------------
local function do_number(i)
local before = sinfos[i] -- 'before'
local z = before -- working representation
local y -- 'after', if better
--------------------------------------------------------------------
if match(z, "^0[xX]") then -- hexadecimal number
local v = tostring(tonumber(z))
if #v <= #z then
z = v -- change to integer, AND continue
else
return -- no change; stick to hex
end
end
--------------------------------------------------------------------
if match(z, "^%d+%.?0*$") then -- integer or has useless frac
z = match(z, "^(%d+)%.?0*$") -- int portion only
if z + 0 > 0 then
z = match(z, "^0*([1-9]%d*)$") -- remove leading zeros
local v = #match(z, "0*$")
local nv = tostring(v)
if v > #nv + 1 then -- scientific is shorter
z = sub(z, 1, #z - v).."e"..nv
end
y = z
else
y = "0" -- basic zero
end
--------------------------------------------------------------------
elseif not match(z, "[eE]") then -- number with fraction part
local p, q = match(z, "^(%d*)%.(%d+)$") -- split
if p == "" then p = 0 end -- int part zero
if q + 0 == 0 and p == 0 then
y = "0" -- degenerate .000 case
else
-- now, q > 0 holds and p is a number
local v = #match(q, "0*$") -- remove trailing zeros
if v > 0 then
q = sub(q, 1, #q - v)
end
-- if p > 0, nothing else we can do to simplify p.q case
if p + 0 > 0 then
y = p.."."..q
else
y = "."..q -- tentative, e.g. .000123
local v = #match(q, "^0*") -- # leading spaces
local w = #q - v -- # significant digits
local nv = tostring(#q)
-- e.g. compare 123e-6 versus .000123
if w + 2 + #nv < 1 + #q then
y = sub(q, -w).."e-"..nv
end
end
end
--------------------------------------------------------------------
else -- scientific number
local sig, ex = match(z, "^([^eE]+)[eE]([%+%-]?%d+)$")
ex = tonumber(ex)
-- if got ".", shift out fractional portion of significand
local p, q = match(sig, "^(%d*)%.(%d*)$")
if p then
ex = ex - #q
sig = p..q
end
if sig + 0 == 0 then
y = "0" -- basic zero
else
local v = #match(sig, "^0*") -- remove leading zeros
sig = sub(sig, v + 1)
v = #match(sig, "0*$") -- shift out trailing zeros
if v > 0 then
sig = sub(sig, 1, #sig - v)
ex = ex + v
end
-- examine exponent and determine which format is best
local nex = tostring(ex)
if ex == 0 then -- it's just an integer
y = sig
elseif ex > 0 and (ex <= 1 + #nex) then -- a number
y = sig..rep("0", ex)
elseif ex < 0 and (ex >= -#sig) then -- fraction, e.g. .123
v = #sig + ex
y = sub(sig, 1, v).."."..sub(sig, v + 1)
elseif ex < 0 and (#nex >= -ex - #sig) then
-- e.g. compare 1234e-5 versus .01234
-- gives: #sig + 1 + #nex >= 1 + (-ex - #sig) + #sig
-- -> #nex >= -ex - #sig
v = -ex - #sig
y = "."..rep("0", v)..sig
else -- non-canonical scientific representation
y = sig.."e"..ex
end
end--if sig
end
--------------------------------------------------------------------
if y and y ~= sinfos[i] then
if opt_details then
print("<number> (line "..stoklns[i]..") "..sinfos[i].." -> "..y)
opt_details = opt_details + 1
end
sinfos[i] = y
end
end
------------------------------------------------------------------------
-- string optimization
-- * note: works on well-formed strings only!
-- * optimizations on characters can be summarized as follows:
-- \a\b\f\n\r\t\v -- no change
-- \\ -- no change
-- \"\' -- depends on delim, other can remove \
-- \[\] -- remove \
-- \<char> -- general escape, remove \
-- \<eol> -- normalize the EOL only
-- \ddd -- if \a\b\f\n\r\t\v, change to latter
-- if other < ascii 32, keep ddd but zap leading zeros
-- if >= ascii 32, translate it into the literal, then also
-- do escapes for \\,\",\' cases
-- <other> -- no change
-- * switch delimiters if string becomes shorter
------------------------------------------------------------------------
local function do_string(I)
local info = sinfos[I]
local delim = sub(info, 1, 1) -- delimiter used
local ndelim = (delim == "'") and '"' or "'" -- opposite " <-> '
local z = sub(info, 2, -2) -- actual string
local i = 1
local c_delim, c_ndelim = 0, 0 -- "/' counts
--------------------------------------------------------------------
while i <= #z do
local c = sub(z, i, i)
----------------------------------------------------------------
if c == "\\" then -- escaped stuff
local j = i + 1
local d = sub(z, j, j)
local p = find("abfnrtv\\\n\r\"\'0123456789", d, 1, true)
------------------------------------------------------------
if not p then -- \<char> -- remove \
z = sub(z, 1, i - 1)..sub(z, j)
i = i + 1
------------------------------------------------------------
elseif p <= 8 then -- \a\b\f\n\r\t\v\\
i = i + 2 -- no change
------------------------------------------------------------
elseif p <= 10 then -- \<eol> -- normalize EOL
local eol = sub(z, j, j + 1)
if eol == "\r\n" or eol == "\n\r" then
z = sub(z, 1, i).."\n"..sub(z, j + 2)
elseif p == 10 then -- \r case
z = sub(z, 1, i).."\n"..sub(z, j + 1)
end
i = i + 2
------------------------------------------------------------
elseif p <= 12 then -- \"\' -- remove \ for ndelim
if d == delim then
c_delim = c_delim + 1
i = i + 2
else
c_ndelim = c_ndelim + 1
z = sub(z, 1, i - 1)..sub(z, j)
i = i + 1
end
------------------------------------------------------------
else -- \ddd -- various steps
local s = match(z, "^(%d%d?%d?)", j)
j = i + 1 + #s -- skip to location
local cv = s + 0
local cc = string.char(cv)
local p = find("\a\b\f\n\r\t\v", cc, 1, true)
if p then -- special escapes
s = "\\"..sub("abfnrtv", p, p)
elseif cv < 32 then -- normalized \ddd
s = "\\"..cv
elseif cc == delim then -- \<delim>
s = "\\"..cc
c_delim = c_delim + 1
elseif cc == "\\" then -- \\
s = "\\\\"
else -- literal character
s = cc
if cc == ndelim then
c_ndelim = c_ndelim + 1
end
end
z = sub(z, 1, i - 1)..s..sub(z, j)
i = i + #s
------------------------------------------------------------
end--if p
----------------------------------------------------------------
else-- c ~= "\\" -- <other> -- no change
i = i + 1
if c == ndelim then -- count ndelim, for switching delimiters
c_ndelim = c_ndelim + 1
end
----------------------------------------------------------------
end--if c
end--while
--------------------------------------------------------------------
-- switching delimiters, a long-winded derivation:
-- (1) delim takes 2+2*c_delim bytes, ndelim takes c_ndelim bytes
-- (2) delim becomes c_delim bytes, ndelim becomes 2+2*c_ndelim bytes
-- simplifying the condition (1)>(2) --> c_delim > c_ndelim
if c_delim > c_ndelim then
i = 1
while i <= #z do
local p, q, r = find(z, "([\'\"])", i)
if not p then break end
if r == delim then -- \<delim> -> <delim>
z = sub(z, 1, p - 2)..sub(z, p)
i = p
else-- r == ndelim -- <ndelim> -> \<ndelim>
z = sub(z, 1, p - 1).."\\"..sub(z, p)
i = p + 2
end
end--while
delim = ndelim -- actually change delimiters
end
--------------------------------------------------------------------
z = delim..z..delim
if z ~= sinfos[I] then
if opt_details then
print("<string> (line "..stoklns[I]..") "..sinfos[I].." -> "..z)
opt_details = opt_details + 1
end
sinfos[I] = z
end
end
------------------------------------------------------------------------
-- long string optimization
-- * note: warning flagged if trailing whitespace found, not trimmed
-- * remove first optional newline
-- * normalize embedded newlines
-- * reduce '=' separators in delimiters if possible
------------------------------------------------------------------------
local function do_lstring(I)
local info = sinfos[I]
local delim1 = match(info, "^%[=*%[") -- cut out delimiters
local sep = #delim1
local delim2 = sub(info, -sep, -1)
local z = sub(info, sep + 1, -(sep + 1)) -- lstring without delims
local y = ""
local i = 1
--------------------------------------------------------------------
while true do
local p, q, r, s = find(z, "([\r\n])([\r\n]?)", i)
-- deal with a single line
local ln
if not p then
ln = sub(z, i)
elseif p >= i then
ln = sub(z, i, p - 1)
end
if ln ~= "" then
-- flag a warning if there are trailing spaces, won't base.optimize!
if match(ln, "%s+$") then
warn.lstring = "trailing whitespace in long string near line "..stoklns[I]
end
y = y..ln
end
if not p then -- done if no more EOLs
break
end
-- deal with line endings, normalize them
i = p + 1
if p then
if #s > 0 and r ~= s then -- skip CRLF or LFCR
i = i + 1
end
-- skip first newline, which can be safely deleted
if not(i == 1 and i == p) then
y = y.."\n"
end
end
end--while
--------------------------------------------------------------------
-- handle possible deletion of one or more '=' separators
if sep >= 3 then
local chk, okay = sep - 1
-- loop to test ending delimiter with less of '=' down to zero
while chk >= 2 do
local delim = "%]"..rep("=", chk - 2).."%]"
if not match(y, delim) then okay = chk end
chk = chk - 1
end
if okay then -- change delimiters
sep = rep("=", okay - 2)
delim1, delim2 = "["..sep.."[", "]"..sep.."]"
end
end
--------------------------------------------------------------------
sinfos[I] = delim1..y..delim2
end
------------------------------------------------------------------------
-- long comment optimization
-- * note: does not remove first optional newline
-- * trim trailing whitespace
-- * normalize embedded newlines
-- * reduce '=' separators in delimiters if possible
------------------------------------------------------------------------
local function do_lcomment(I)
local info = sinfos[I]
local delim1 = match(info, "^%-%-%[=*%[") -- cut out delimiters
local sep = #delim1
local delim2 = sub(info, -sep, -1)
local z = sub(info, sep + 1, -(sep - 1)) -- comment without delims
local y = ""
local i = 1
--------------------------------------------------------------------
while true do
local p, q, r, s = find(z, "([\r\n])([\r\n]?)", i)
-- deal with a single line, extract and check trailing whitespace
local ln
if not p then
ln = sub(z, i)
elseif p >= i then
ln = sub(z, i, p - 1)
end
if ln ~= "" then
-- trim trailing whitespace if non-empty line
local ws = match(ln, "%s*$")
if #ws > 0 then ln = sub(ln, 1, -(ws + 1)) end
y = y..ln
end
if not p then -- done if no more EOLs
break
end
-- deal with line endings, normalize them
i = p + 1
if p then
if #s > 0 and r ~= s then -- skip CRLF or LFCR
i = i + 1
end
y = y.."\n"
end
end--while
--------------------------------------------------------------------
-- handle possible deletion of one or more '=' separators
sep = sep - 2
if sep >= 3 then
local chk, okay = sep - 1
-- loop to test ending delimiter with less of '=' down to zero
while chk >= 2 do
local delim = "%]"..rep("=", chk - 2).."%]"
if not match(y, delim) then okay = chk end
chk = chk - 1
end
if okay then -- change delimiters
sep = rep("=", okay - 2)
delim1, delim2 = "--["..sep.."[", "]"..sep.."]"
end
end
--------------------------------------------------------------------
sinfos[I] = delim1..y..delim2
end
------------------------------------------------------------------------
-- short comment optimization
-- * trim trailing whitespace
------------------------------------------------------------------------
local function do_comment(i)
local info = sinfos[i]
local ws = match(info, "%s*$") -- just look from end of string
if #ws > 0 then
info = sub(info, 1, -(ws + 1)) -- trim trailing whitespace
end
sinfos[i] = info
end
------------------------------------------------------------------------
-- returns true if string found in long comment
-- * this is a feature to keep copyright or license texts
------------------------------------------------------------------------
local function keep_lcomment(opt_keep, info)
if not opt_keep then return false end -- option not set
local delim1 = match(info, "^%-%-%[=*%[") -- cut out delimiters
local sep = #delim1
local delim2 = sub(info, -sep, -1)
local z = sub(info, sep + 1, -(sep - 1)) -- comment without delims
if find(z, opt_keep, 1, true) then -- try to match
return true
end
end
------------------------------------------------------------------------
-- main entry point
-- * currently, lexer processing has 2 passes
-- * processing is done on a line-oriented basis, which is easier to
-- grok due to the next point...
-- * since there are various options that can be enabled or disabled,
-- processing is a little messy or convoluted
------------------------------------------------------------------------
function base.optimize(option, toklist, semlist, toklnlist)
--------------------------------------------------------------------
-- set option flags
--------------------------------------------------------------------
local opt_comments = option["opt-comments"]
local opt_whitespace = option["opt-whitespace"]
local opt_emptylines = option["opt-emptylines"]
local opt_eols = option["opt-eols"]
local opt_strings = option["opt-strings"]
local opt_numbers = option["opt-numbers"]
local opt_keep = option.KEEP
opt_details = option.DETAILS and 0 -- upvalues for details display
print = print or base.print
if opt_eols then -- forced settings, otherwise won't work properly
opt_comments = true
opt_whitespace = true
opt_emptylines = true
end
--------------------------------------------------------------------
-- variable initialization
--------------------------------------------------------------------
stoks, sinfos, stoklns -- set source lists
= toklist, semlist, toklnlist
local i = 1 -- token position
local tok, info -- current token
local prev -- position of last grammar token
-- on same line (for TK_SPACE stuff)
--------------------------------------------------------------------
-- changes a token, info pair
--------------------------------------------------------------------
local function settoken(tok, info, I)
I = I or i
stoks[I] = tok or ""
sinfos[I] = info or ""
end
--------------------------------------------------------------------
-- processing loop (PASS 1)
--------------------------------------------------------------------
while true do
tok, info = stoks[i], sinfos[i]
----------------------------------------------------------------
local atstart = atlinestart(i) -- set line begin flag
if atstart then prev = nil end
----------------------------------------------------------------
if tok == "TK_EOS" then -- end of stream/pass
break
----------------------------------------------------------------
elseif tok == "TK_KEYWORD" or -- keywords, identifiers,
tok == "TK_NAME" or -- operators
tok == "TK_OP" then
-- TK_KEYWORD and TK_OP can't be optimized without a big
-- optimization framework; it would be more of an optimizing
-- compiler, not a source code compressor
-- TK_NAME that are locals needs parser to analyze/base.optimize
prev = i
----------------------------------------------------------------
elseif tok == "TK_NUMBER" then -- numbers
if opt_numbers then
do_number(i) -- base.optimize
end
prev = i
----------------------------------------------------------------
elseif tok == "TK_STRING" or -- strings, long strings
tok == "TK_LSTRING" then
if opt_strings then
if tok == "TK_STRING" then
do_string(i) -- base.optimize
else
do_lstring(i) -- base.optimize
end
end
prev = i
----------------------------------------------------------------
elseif tok == "TK_COMMENT" then -- short comments
if opt_comments then
if i == 1 and sub(info, 1, 1) == "#" then
-- keep shbang comment, trim whitespace
do_comment(i)
else
-- safe to delete, as a TK_EOL (or TK_EOS) always follows
settoken() -- remove entirely
end
elseif opt_whitespace then -- trim whitespace only
do_comment(i)
end
----------------------------------------------------------------
elseif tok == "TK_LCOMMENT" then -- long comments
if keep_lcomment(opt_keep, info) then
------------------------------------------------------------
-- if --keep, we keep a long comment if <msg> is found;
-- this is a feature to keep copyright or license texts
if opt_whitespace then -- trim whitespace only
do_lcomment(i)
end
prev = i
elseif opt_comments then
local eols = commenteols(info)
------------------------------------------------------------
-- prepare opt_emptylines case first, if a disposable token
-- follows, current one is safe to dump, else keep a space;
-- it is implied that the operation is safe for '-', because
-- current is a TK_LCOMMENT, and must be separate from a '-'
if is_faketoken[stoks[i + 1]] then
settoken() -- remove entirely
tok = ""
else
settoken("TK_SPACE", " ")
end
------------------------------------------------------------
-- if there are embedded EOLs to keep and opt_emptylines is
-- disabled, then switch the token into one or more EOLs
if not opt_emptylines and eols > 0 then
settoken("TK_EOL", rep("\n", eols))
end
------------------------------------------------------------
-- if optimizing whitespaces, force reinterpretation of the
-- token to give a chance for the space to be optimized away
if opt_whitespace and tok ~= "" then
i = i - 1 -- to reinterpret
end
------------------------------------------------------------
else -- disabled case
if opt_whitespace then -- trim whitespace only
do_lcomment(i)
end
prev = i
end
----------------------------------------------------------------
elseif tok == "TK_EOL" then -- line endings
if atstart and opt_emptylines then
settoken() -- remove entirely
elseif info == "\r\n" or info == "\n\r" then
-- normalize the rest of the EOLs for CRLF/LFCR only
-- (note that TK_LCOMMENT can change into several EOLs)
settoken("TK_EOL", "\n")
end
----------------------------------------------------------------
elseif tok == "TK_SPACE" then -- whitespace
if opt_whitespace then
if atstart or atlineend(i) then
-- delete leading and trailing whitespace
settoken() -- remove entirely
else
------------------------------------------------------------
-- at this point, since leading whitespace have been removed,
-- there should be a either a real token or a TK_LCOMMENT
-- prior to hitting this whitespace; the TK_LCOMMENT case
-- only happens if opt_comments is disabled; so prev ~= nil
local ptok = stoks[prev]
if ptok == "TK_LCOMMENT" then
-- previous TK_LCOMMENT can abut with anything
settoken() -- remove entirely
else
-- prev must be a grammar token; consecutive TK_SPACE
-- tokens is impossible when optimizing whitespace
local ntok = stoks[i + 1]
if is_faketoken[ntok] then
-- handle special case where a '-' cannot abut with
-- either a short comment or a long comment
if (ntok == "TK_COMMENT" or ntok == "TK_LCOMMENT") and
ptok == "TK_OP" and sinfos[prev] == "-" then
-- keep token
else
settoken() -- remove entirely
end
else--is_realtoken
-- check a pair of grammar tokens, if can abut, then
-- delete space token entirely, otherwise keep one space
local s = checkpair(prev, i + 1)
if s == "" then
settoken() -- remove entirely
else
settoken("TK_SPACE", " ")
end
end
end
------------------------------------------------------------
end
end
----------------------------------------------------------------
else
error("unidentified token encountered")
end
----------------------------------------------------------------
i = i + 1
end--while
repack_tokens()
--------------------------------------------------------------------
-- processing loop (PASS 2)
--------------------------------------------------------------------
if opt_eols then
i = 1
-- aggressive EOL removal only works with most non-grammar tokens
-- optimized away because it is a rather simple scheme -- basically
-- it just checks 'real' token pairs around EOLs
if stoks[1] == "TK_COMMENT" then
-- first comment still existing must be shbang, skip whole line
i = 3
end
while true do
tok, info = stoks[i], sinfos[i]
--------------------------------------------------------------
if tok == "TK_EOS" then -- end of stream/pass
break
--------------------------------------------------------------
elseif tok == "TK_EOL" then -- consider each TK_EOL
local t1, t2 = stoks[i - 1], stoks[i + 1]
if is_realtoken[t1] and is_realtoken[t2] then -- sanity check
local s = checkpair(i - 1, i + 1)
if s == "" then
settoken() -- remove entirely
end
end
end--if tok
--------------------------------------------------------------
i = i + 1
end--while
repack_tokens()
end
--------------------------------------------------------------------
if opt_details and opt_details > 0 then print() end -- spacing
return stoks, sinfos, stoklns
end
return base

View File

@@ -0,0 +1,566 @@
--[[--------------------------------------------------------------------
optparser.lua: does parser-based optimizations
This file is part of LuaSrcDiet.
Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
The COPYRIGHT file describes the conditions
under which this software may be distributed.
See the ChangeLog for more information.
----------------------------------------------------------------------]]
--[[--------------------------------------------------------------------
-- NOTES:
-- * For more parser-based optimization ideas, see the TODO items or
-- look at technotes.txt.
-- * The processing load is quite significant, but since this is an
-- off-line text processor, I believe we can wait a few seconds.
-- * TODO: might process "local a,a,a" wrongly... need tests!
-- * TODO: remove position handling if overlapped locals (rem < 0)
-- needs more study, to check behaviour
-- * TODO: there are probably better ways to do allocation, e.g. by
-- choosing better methods to sort and pick locals...
-- * TODO: we don't need 53*63 two-letter identifiers; we can make
-- do with significantly less depending on how many that are really
-- needed and improve entropy; e.g. 13 needed -> choose 4*4 instead
----------------------------------------------------------------------]]
local base = {}
-- local base = _G
-- local string = require "string"
-- local table = require "table"
-- module "optparser"
----------------------------------------------------------------------
-- Letter frequencies for reducing symbol entropy (fixed version)
-- * Might help a wee bit when the output file is compressed
-- * See Wikipedia: http://en.wikipedia.org/wiki/Letter_frequencies
-- * We use letter frequencies according to a Linotype keyboard, plus
-- the underscore, and both lower case and upper case letters.
-- * The arrangement below (LC, underscore, %d, UC) is arbitrary.
-- * This is certainly not optimal, but is quick-and-dirty and the
-- process has no significant overhead
----------------------------------------------------------------------
local LETTERS = "etaoinshrdlucmfwypvbgkqjxz_ETAOINSHRDLUCMFWYPVBGKQJXZ"
local ALPHANUM = "etaoinshrdlucmfwypvbgkqjxz_0123456789ETAOINSHRDLUCMFWYPVBGKQJXZ"
-- names or identifiers that must be skipped
-- * the first two lines are for keywords
local SKIP_NAME = {}
for v in string.gmatch([[
and break do else elseif end false for function if in
local nil not or repeat return then true until while
self]], "%S+") do
SKIP_NAME[v] = true
end
------------------------------------------------------------------------
-- variables and data structures
------------------------------------------------------------------------
local toklist, seminfolist, -- token lists
globalinfo, localinfo, -- variable information tables
globaluniq, localuniq, -- unique name tables
var_new, -- index of new variable names
varlist -- list of output variables
----------------------------------------------------------------------
-- preprocess information table to get lists of unique names
----------------------------------------------------------------------
local function preprocess(infotable)
local uniqtable = {}
for i = 1, #infotable do -- enumerate info table
local obj = infotable[i]
local name = obj.name
--------------------------------------------------------------------
if not uniqtable[name] then -- not found, start an entry
uniqtable[name] = {
decl = 0, token = 0, size = 0,
}
end
--------------------------------------------------------------------
local uniq = uniqtable[name] -- count declarations, tokens, size
uniq.decl = uniq.decl + 1
local xref = obj.xref
local xcount = #xref
uniq.token = uniq.token + xcount
uniq.size = uniq.size + xcount * #name
--------------------------------------------------------------------
if obj.decl then -- if local table, create first,last pairs
obj.id = i
obj.xcount = xcount
if xcount > 1 then -- if ==1, means local never accessed
obj.first = xref[2]
obj.last = xref[xcount]
end
--------------------------------------------------------------------
else -- if global table, add a back ref
uniq.id = i
end
--------------------------------------------------------------------
end--for
return uniqtable
end
----------------------------------------------------------------------
-- calculate actual symbol frequencies, in order to reduce entropy
-- * this may help further reduce the size of compressed sources
-- * note that since parsing optimizations is put before lexing
-- optimizations, the frequency table is not exact!
-- * yes, this will miss --keep block comments too...
----------------------------------------------------------------------
local function recalc_for_entropy(option)
local byte = string.byte
local char = string.char
-- table of token classes to accept in calculating symbol frequency
local ACCEPT = {
TK_KEYWORD = true, TK_NAME = true, TK_NUMBER = true,
TK_STRING = true, TK_LSTRING = true,
}
if not option["opt-comments"] then
ACCEPT.TK_COMMENT = true
ACCEPT.TK_LCOMMENT = true
end
--------------------------------------------------------------------
-- create a new table and remove any original locals by filtering
--------------------------------------------------------------------
local filtered = {}
for i = 1, #toklist do
filtered[i] = seminfolist[i]
end
for i = 1, #localinfo do -- enumerate local info table
local obj = localinfo[i]
local xref = obj.xref
for j = 1, obj.xcount do
local p = xref[j]
filtered[p] = "" -- remove locals
end
end
--------------------------------------------------------------------
local freq = {} -- reset symbol frequency table
for i = 0, 255 do freq[i] = 0 end
for i = 1, #toklist do -- gather symbol frequency
local tok, info = toklist[i], filtered[i]
if ACCEPT[tok] then
for j = 1, #info do
local c = byte(info, j)
freq[c] = freq[c] + 1
end
end--if
end--for
--------------------------------------------------------------------
-- function to re-sort symbols according to actual frequencies
--------------------------------------------------------------------
local function resort(symbols)
local symlist = {}
for i = 1, #symbols do -- prepare table to sort
local c = byte(symbols, i)
symlist[i] = { c = c, freq = freq[c], }
end
table.sort(symlist, -- sort selected symbols
function(v1, v2)
return v1.freq > v2.freq
end
)
local charlist = {} -- reconstitute the string
for i = 1, #symlist do
charlist[i] = char(symlist[i].c)
end
return table.concat(charlist)
end
--------------------------------------------------------------------
LETTERS = resort(LETTERS) -- change letter arrangement
ALPHANUM = resort(ALPHANUM)
end
----------------------------------------------------------------------
-- returns a string containing a new local variable name to use, and
-- a flag indicating whether it collides with a global variable
-- * trapping keywords and other names like 'self' is done elsewhere
----------------------------------------------------------------------
local function new_var_name()
local var
local cletters, calphanum = #LETTERS, #ALPHANUM
local v = var_new
if v < cletters then -- single char
v = v + 1
var = string.sub(LETTERS, v, v)
else -- longer names
local range, sz = cletters, 1 -- calculate # chars fit
repeat
v = v - range
range = range * calphanum
sz = sz + 1
until range > v
local n = v % cletters -- left side cycles faster
v = (v - n) / cletters -- do first char first
n = n + 1
var = string.sub(LETTERS, n, n)
while sz > 1 do
local m = v % calphanum
v = (v - m) / calphanum
m = m + 1
var = var..string.sub(ALPHANUM, m, m)
sz = sz - 1
end
end
var_new = var_new + 1
return var, globaluniq[var] ~= nil
end
----------------------------------------------------------------------
-- calculate and print some statistics
-- * probably better in main source, put here for now
----------------------------------------------------------------------
local function stats_summary(globaluniq, localuniq, afteruniq, option)
local fmt = string.format
local opt_details = option.DETAILS
local uniq_g , uniq_li, uniq_lo, uniq_ti, uniq_to, -- stats needed
decl_g, decl_li, decl_lo, decl_ti, decl_to,
token_g, token_li, token_lo, token_ti, token_to,
size_g, size_li, size_lo, size_ti, size_to
= 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
local function avg(c, l) -- safe average function
if c == 0 then return 0 end
return l / c
end
--------------------------------------------------------------------
-- collect statistics (note: globals do not have declarations!)
--------------------------------------------------------------------
for name, uniq in pairs(globaluniq) do
uniq_g = uniq_g + 1
token_g = token_g + uniq.token
size_g = size_g + uniq.size
end
for name, uniq in pairs(localuniq) do
uniq_li = uniq_li + 1
decl_li = decl_li + uniq.decl
token_li = token_li + uniq.token
size_li = size_li + uniq.size
end
for name, uniq in pairs(afteruniq) do
uniq_lo = uniq_lo + 1
decl_lo = decl_lo + uniq.decl
token_lo = token_lo + uniq.token
size_lo = size_lo + uniq.size
end
uniq_ti = uniq_g + uniq_li
decl_ti = decl_g + decl_li
token_ti = token_g + token_li
size_ti = size_g + size_li
uniq_to = uniq_g + uniq_lo
decl_to = decl_g + decl_lo
token_to = token_g + token_lo
size_to = size_g + size_lo
--------------------------------------------------------------------
-- detailed stats: global list
--------------------------------------------------------------------
if opt_details then
local sorted = {} -- sort table of unique global names by size
for name, uniq in pairs(globaluniq) do
uniq.name = name
sorted[#sorted + 1] = uniq
end
table.sort(sorted,
function(v1, v2)
return v1.size > v2.size
end
)
local tabf1, tabf2 = "%8s%8s%10s %s", "%8d%8d%10.2f %s"
local hl = string.rep("-", 44)
print("*** global variable list (sorted by size) ***\n"..hl)
print(fmt(tabf1, "Token", "Input", "Input", "Global"))
print(fmt(tabf1, "Count", "Bytes", "Average", "Name"))
print(hl)
for i = 1, #sorted do
local uniq = sorted[i]
print(fmt(tabf2, uniq.token, uniq.size, avg(uniq.token, uniq.size), uniq.name))
end
print(hl)
print(fmt(tabf2, token_g, size_g, avg(token_g, size_g), "TOTAL"))
print(hl.."\n")
--------------------------------------------------------------------
-- detailed stats: local list
--------------------------------------------------------------------
local tabf1, tabf2 = "%8s%8s%8s%10s%8s%10s %s", "%8d%8d%8d%10.2f%8d%10.2f %s"
local hl = string.rep("-", 70)
print("*** local variable list (sorted by allocation order) ***\n"..hl)
print(fmt(tabf1, "Decl.", "Token", "Input", "Input", "Output", "Output", "Global"))
print(fmt(tabf1, "Count", "Count", "Bytes", "Average", "Bytes", "Average", "Name"))
print(hl)
for i = 1, #varlist do -- iterate according to order assigned
local name = varlist[i]
local uniq = afteruniq[name]
local old_t, old_s = 0, 0
for j = 1, #localinfo do -- find corresponding old names and calculate
local obj = localinfo[j]
if obj.name == name then
old_t = old_t + obj.xcount
old_s = old_s + obj.xcount * #obj.oldname
end
end
print(fmt(tabf2, uniq.decl, uniq.token, old_s, avg(old_t, old_s),
uniq.size, avg(uniq.token, uniq.size), name))
end
print(hl)
print(fmt(tabf2, decl_lo, token_lo, size_li, avg(token_li, size_li),
size_lo, avg(token_lo, size_lo), "TOTAL"))
print(hl.."\n")
end--if opt_details
--------------------------------------------------------------------
-- display output
--------------------------------------------------------------------
-- local tabf1, tabf2 = "%-16s%8s%8s%8s%8s%10s", "%-16s%8d%8d%8d%8d%10.2f"
-- local hl = string.rep("-", 58)
-- print("*** local variable optimization summary ***\n"..hl)
-- print(fmt(tabf1, "Variable", "Unique", "Decl.", "Token", "Size", "Average"))
-- print(fmt(tabf1, "Types", "Names", "Count", "Count", "Bytes", "Bytes"))
-- print(hl)
-- print(fmt(tabf2, "Global", uniq_g, decl_g, token_g, size_g, avg(token_g, size_g)))
-- print(hl)
-- print(fmt(tabf2, "Local (in)", uniq_li, decl_li, token_li, size_li, avg(token_li, size_li)))
-- print(fmt(tabf2, "TOTAL (in)", uniq_ti, decl_ti, token_ti, size_ti, avg(token_ti, size_ti)))
-- print(hl)
-- print(fmt(tabf2, "Local (out)", uniq_lo, decl_lo, token_lo, size_lo, avg(token_lo, size_lo)))
-- print(fmt(tabf2, "TOTAL (out)", uniq_to, decl_to, token_to, size_to, avg(token_to, size_to)))
-- print(hl.."\n")
end
----------------------------------------------------------------------
-- main entry point
-- * does only local variable optimization for now
----------------------------------------------------------------------
function base.optimize(option, _toklist, _seminfolist, _globalinfo, _localinfo)
-- set tables
toklist, seminfolist, globalinfo, localinfo
= _toklist, _seminfolist, _globalinfo, _localinfo
var_new = 0 -- reset variable name allocator
varlist = {}
------------------------------------------------------------------
-- preprocess global/local tables, handle entropy reduction
------------------------------------------------------------------
globaluniq = preprocess(globalinfo)
localuniq = preprocess(localinfo)
if option["opt-entropy"] then -- for entropy improvement
recalc_for_entropy(option)
end
------------------------------------------------------------------
-- build initial declared object table, then sort according to
-- token count, this might help assign more tokens to more common
-- variable names such as 'e' thus possibly reducing entropy
-- * an object knows its localinfo index via its 'id' field
-- * special handling for "self" special local (parameter) here
------------------------------------------------------------------
local object = {}
for i = 1, #localinfo do
object[i] = localinfo[i]
end
table.sort(object, -- sort largest first
function(v1, v2)
return v1.xcount > v2.xcount
end
)
------------------------------------------------------------------
-- the special "self" function parameters must be preserved
-- * the allocator below will never use "self", so it is safe to
-- keep those implicit declarations as-is
------------------------------------------------------------------
local temp, j, gotself = {}, 1, false
for i = 1, #object do
local obj = object[i]
if not obj.isself then
temp[j] = obj
j = j + 1
else
gotself = true
end
end
object = temp
------------------------------------------------------------------
-- a simple first-come first-served heuristic name allocator,
-- note that this is in no way optimal...
-- * each object is a local variable declaration plus existence
-- * the aim is to assign short names to as many tokens as possible,
-- so the following tries to maximize name reuse
-- * note that we preserve sort order
------------------------------------------------------------------
local nobject = #object
while nobject > 0 do
local varname, gcollide
repeat
varname, gcollide = new_var_name() -- collect a variable name
until not SKIP_NAME[varname] -- skip all special names
varlist[#varlist + 1] = varname -- keep a list
local oleft = nobject
------------------------------------------------------------------
-- if variable name collides with an existing global, the name
-- cannot be used by a local when the name is accessed as a global
-- during which the local is alive (between 'act' to 'rem'), so
-- we drop objects that collides with the corresponding global
------------------------------------------------------------------
if gcollide then
-- find the xref table of the global
local gref = globalinfo[globaluniq[varname].id].xref
local ngref = #gref
-- enumerate for all current objects; all are valid at this point
for i = 1, nobject do
local obj = object[i]
local act, rem = obj.act, obj.rem -- 'live' range of local
-- if rem < 0, it is a -id to a local that had the same name
-- so follow rem to extend it; does this make sense?
while rem < 0 do
rem = localinfo[-rem].rem
end
local drop
for j = 1, ngref do
local p = gref[j]
if p >= act and p <= rem then drop = true end -- in range?
end
if drop then
obj.skip = true
oleft = oleft - 1
end
end--for
end--if gcollide
------------------------------------------------------------------
-- now the first unassigned local (since it's sorted) will be the
-- one with the most tokens to rename, so we set this one and then
-- eliminate all others that collides, then any locals that left
-- can then reuse the same variable name; this is repeated until
-- all local declaration that can use this name is assigned
-- * the criteria for local-local reuse/collision is:
-- A is the local with a name already assigned
-- B is the unassigned local under consideration
-- => anytime A is accessed, it cannot be when B is 'live'
-- => to speed up things, we have first/last accesses noted
------------------------------------------------------------------
while oleft > 0 do
local i = 1
while object[i].skip do -- scan for first object
i = i + 1
end
------------------------------------------------------------------
-- first object is free for assignment of the variable name
-- [first,last] gives the access range for collision checking
------------------------------------------------------------------
oleft = oleft - 1
local obja = object[i]
i = i + 1
obja.newname = varname
obja.skip = true
obja.done = true
local first, last = obja.first, obja.last
local xref = obja.xref
------------------------------------------------------------------
-- then, scan all the rest and drop those colliding
-- if A was never accessed then it'll never collide with anything
-- otherwise trivial skip if:
-- * B was activated after A's last access (last < act)
-- * B was removed before A's first access (first > rem)
-- if not, see detailed skip below...
------------------------------------------------------------------
if first and oleft > 0 then -- must have at least 1 access
local scanleft = oleft
while scanleft > 0 do
while object[i].skip do -- next valid object
i = i + 1
end
scanleft = scanleft - 1
local objb = object[i]
i = i + 1
local act, rem = objb.act, objb.rem -- live range of B
-- if rem < 0, extend range of rem thru' following local
while rem < 0 do
rem = localinfo[-rem].rem
end
--------------------------------------------------------
if not(last < act or first > rem) then -- possible collision
--------------------------------------------------------
-- B is activated later than A or at the same statement,
-- this means for no collision, A cannot be accessed when B
-- is alive, since B overrides A (or is a peer)
--------------------------------------------------------
if act >= obja.act then
for j = 1, obja.xcount do -- ... then check every access
local p = xref[j]
if p >= act and p <= rem then -- A accessed when B live!
oleft = oleft - 1
objb.skip = true
break
end
end--for
--------------------------------------------------------
-- A is activated later than B, this means for no collision,
-- A's access is okay since it overrides B, but B's last
-- access need to be earlier than A's activation time
--------------------------------------------------------
else
if objb.last and objb.last >= obja.act then
oleft = oleft - 1
objb.skip = true
end
end
end
--------------------------------------------------------
if oleft == 0 then break end
end
end--if first
------------------------------------------------------------------
end--while
------------------------------------------------------------------
-- after assigning all possible locals to one variable name, the
-- unassigned locals/objects have the skip field reset and the table
-- is compacted, to hopefully reduce iteration time
------------------------------------------------------------------
local temp, j = {}, 1
for i = 1, nobject do
local obj = object[i]
if not obj.done then
obj.skip = false
temp[j] = obj
j = j + 1
end
end
object = temp -- new compacted object table
nobject = #object -- objects left to process
------------------------------------------------------------------
end--while
------------------------------------------------------------------
-- after assigning all locals with new variable names, we can
-- patch in the new names, and reprocess to get 'after' stats
------------------------------------------------------------------
for i = 1, #localinfo do -- enumerate all locals
local obj = localinfo[i]
local xref = obj.xref
if obj.newname then -- if got new name, patch it in
for j = 1, obj.xcount do
local p = xref[j] -- xrefs indexes the token list
seminfolist[p] = obj.newname
end
obj.name, obj.oldname -- adjust names
= obj.newname, obj.name
else
obj.oldname = obj.name -- for cases like 'self'
end
end
------------------------------------------------------------------
-- deal with statistics output
------------------------------------------------------------------
if gotself then -- add 'self' to end of list
varlist[#varlist + 1] = "self"
end
local afteruniq = preprocess(localinfo)
stats_summary(globaluniq, localuniq, afteruniq, option)
------------------------------------------------------------------
end
return base

View File

@@ -0,0 +1,361 @@
Tech Notes for LuaSrcDiet
=========================
The following are notes on the optimization process for easy reference.
Miscellaneous Ideas, TODO Stuff
===============================
Other Ideas:
(a) remove unused locals that can be removed in the source
(b) remove declarations using nil
(c) remove table constructor elements using nil
(d) extra optional semicolon removal
(e) extra comma or semicolon removal in table constructors
(f) special number forms: using ^ and * to shorten constants: 1^16
(g) simple declaration of locals that can be merged: local a,b,c,d
(h) warn of opportunity for using a local to zap a bunch of globals
(i) warn of trailing whitespace in strings or long strings
(j) spaces to tabs in comments/long comments/long strings
(k) convert long strings to normal strings, vice versa
(l) simplify logical or relational operator expression
Modified Lexer Output
=====================
The lexer is works almost exactly like llex.c in 'normal' Lua. Instead
of returning one token on each call, the lexer processes the entire
string (from an entire file) and returns. Two lists (tokens and semantic
information items) are set up in the module for use by the caller.
For maximum flexibility during processing, the lexer returns non-grammar
lexical elements as tokens too. Non-grammar elements, such as comments,
whitespace, line endings, are classified along with 'normal' tokens. The
lexer classifies 7 kinds of grammar tokens and 4 kinds of non-grammar
tokens:
---------------------------------------------------------------------
TOKEN CLASS DESCRIPTION
---------------------------------------------------------------------
"TK_KEYWORD" keywords
"TK_NAME" identifiers
"TK_NUMBER" numbers (unconverted, kept in original form)
"TK_STRING" strings (no translation is done, includes delimiters)
"TK_LSTRING" long strings (no translation is done, includes delimiters)
"TK_OP" operators and punctuation (most single-char, some double)
"TK_EOS" end-of-stream (there is only one for each file/stream)
---------------------------------------------------------------------
"TK_SPACE" whitespace (generally, spaces, \t, \v and \f)
"TK_COMMENT" comments (includes delimiters, also includes special
first line shbang, which is handled specially in the
optimizer)
"TK_LCOMMENT" block comments (includes delimiters)
"TK_EOL" end-of-lines (excludes those embedded in strings)
---------------------------------------------------------------------
Table for Lexer-Based Optimizations
===================================
We aim to keep lexer-based optimizations free of parser considerations,
i.e. we allow for generalized optimization of token sequences. The table
below considers the requirements for all combinations of significant
tokens. Other tokens are whitespace-like. Comments can be considered to
be a special kind of whitespace, e.g. a short comment needs to have a
following EOL token, if we do not want to optimize away short comments.
FIRST SECOND TOKEN
TOKEN |
| V
V Keyword Name Number String LString Oper
--------------------------------------------------------
Keyword [S] [S] [S] 0 0 0
Name [S] [S] [S] 0 0 0
Number [S] [S] [S] 0 0 [1]
String 0 0 0 0 0 0
LString 0 0 0 0 0 0
Oper 0 0 [1] 0 0 [2]
--------------------------------------------------------
[S] = need at least one whitespace (set as either a space or keep EOL)
[1] = need a space if operator is a '.', all others okay; a '+' or '-'
is used as part of a floating-point spec, but there does not
appear to be any way of creating a float by joining with number
with a a '+' or '-' plus another number, because an 'e' has to
be somewhere in the first token, this can't be done
[2] = normally there cannot be consecutive operators, but we plan to
allow for generalized optimization of token sequences, i.e. even
sequences that are grammatically illegal; so disallow adjacent
operators if:
(a) the first is in [=<>] and the second is '='
(b) disallow dot sequences to be adjacent, but "..." first okay
(c) disallow '[' followed by '=' or '[' (not optimal)
Also, a minus '-' cannot preceed a Comment or LComment, because comments
start with a '--' prefix. Apart from that, all Comment or LComment
tokens can be set abut with a real token.
Sequence of Lexer-Based Optimization Process
============================================
*** TODO ***
Description of Locals Optimization
==================================
VARIABLE TRACKING AND LOCAL VARIABLE RENAMING
(A) TK_NAME token class considerations
--------------------------------------
A TK_NAME token means a number of things, and some of these cannot be
renamed. We are interested in the use of TK_NAME in the following:
(a) global variable access
(b) local variable declaration, includes local statements, local
functions, function parameters, implicit "self" local, etc.
(c) local variable access, including upvalue access
TK_NAME is also used in parts of grammar as constant strings -- these
tokens cannot be optimized without user assistance. These include:
(d) as the key in key=value pairs in table construction
(e) as field or method names in a:b or a.b syntax forms
For local variable name optimization, we do not need to consider (d) and
(e), and while global variables cannot be renamed (since we do not have
support for user assistance), they need to be considered as part of
Lua's variable access scheme.
(B) Lifetime of a local variable
--------------------------------
Take the following example:
local string, table = string, table
In the example, the two locals are assigned the values of the globals
with the same names. Therefore, when Lua encounters the declaration
portion:
local string, table
The parser cannot immediately make the two local variable available to
following code. In the parser and code generator, locals are inactive
when its entry is created. They are activated only when the function
adjustlocalvars() is called to activate the appropriate local variables.
In the example, the two local variables are activated only after the
whole statement has been parsed, that is, after the last "table" token.
Hence, the statement works as expected. Also, once the two local
variables goes out of scope, removevars() is called to deactivate them,
allowing other variables of the same name to become visible again.
Another example worth mentioning is:
local a, a, a, = 1, 2, 3
The above will assign 3 to 'a'.
Thus, when optimizing local variable names, (1) we need to consider
accesses of global variable names affecting the namespace, (2) for the
local variable names themselves, we need to consider when they are
declared, activated and removed, and (3) within the 'live' time of
locals, we need to know when they are accessed (since locals that are
never accessed don't really matter.)
(C) Local variable tracking
---------------------------
Every local variable declaration is considered an object to be renamed.
From the parser, we have the original name of the local variable, the
token positions for declaration, activation and removal, and the token
position for all the TK_NAME tokens which references this local. All
instances of the implicit "self" local variable are flagged as such.
In addition to local variable information, all global variable accesses
are tabled, one object entry for one name, and each object has a
corresponding list of token positions for the TK_NAME tokens, which is
where the global variables were accessed.
The key criteria is: Our act of renaming cannot change the visibility of
any of these locals and globals at the time they are accessed.
Of course, if every variable has a unique name, then there is no need
for a name allocation algorithm, as there will be no conflict. But, in
order to maximize utilization of short identifier names, we want to
reuse the names as much as possible. In addition, fewer names will
likely reduce symbol entropy and may slightly improve compressibility of
the source code.
(D) Name allocation theory
--------------------------
To understand the renaming algorithm, first we need to establish how
different local and global variables can operate happily without
interfering with each other.
Consider three objects, local object A, local object B and global object
G. A and B involve declaration, activation and removal, and within the
period it is active, there may be zero or more accesses of the local.
For G, there are only global variable accesses to look into.
Assume that we have assigned a new name to A and we wish to consider its
effects on other locals and globals, for which we choose B and G as
examples. We assume local B has not been assigned a new name as we
expect our algorithm to take care of collisions.
A's lifetime is something like this:
Decl Act Rem
+ +-------------------------------+
-------------------------------------------------
where 'Decl' is the time of declaration, 'Act' is the time of
activation, and 'Rem' is the time of removal. Between 'Act' and 'Rem',
the local is alive or 'live' and Lua can see it if its corresponding
TK_NAME identifier comes up.
Decl Act Rem
+ +-------------------------------+
-------------------------------------------------
* * * *
(1) (2) (3) (4)
Recall that the key criteria is to not change the visibility of globals
and locals. Consider local and global accesses at (1), (2), (3) and (4).
A global G of the same name as A will only collide at (3), where Lua
will see A and not G. Since G must be accessed at (3) according to what
the parser says, and we cannot modify the positions of 'Decl', 'Act' and
'Rem', it follows that A cannot have the same name as G.
Decl Act Rem
+ +-----------------------+
---------------------------------
(1)+ +---+ (2)+ +---+ (3)+ +---+ (4)+ +---+
--------- --------- --------- ---------
For the case of A and B having the same names and colliding, consider
the cases for which B is at (1), (2), (3) or (4) in the above.
(1) and (4) means that A and B are completely isolated from each other,
hence in the two cases, A and B can safely use the same variable names.
To be specific, since we have assigned A, B is considered completely
isolated from A if B's Activation-to-Removal period is isolated from
the time of A's first access to last access, meaning B's active time
will never affect any of A's accesses.
For (2) and (3), we have two cases where we need to consider which one
has been activated first. For (2), B is active before A, so A cannot
impose on B. But A's accesses are valid while B is active, since A can
override B. For no collision in the case of (2), we simply need to
ensure that the last access of B occurs before A is activated.
For (3), B is activated before A, hence B can override A's accesses. For
no collision, all of A's accesses cannot happen while B is active. Thus
position (3) follows the "A is never accessed when B is active" rule in
a general way. Local variables of a child function are in the position
of (3). To illustrate, the local B can use the same name as local A and
live in a child function or block scope if each time A is accessed, Lua
sees A and not B. So we have to check all accesses of A and see whether
they collide with the active period of B. Now if A was never accessed,
then B can be active anywhere.
The above appears to resolve all sorts of cases where the active times
of A and B overlap. If there is a more simple scheme, do let me know.
Note that in the above, the allocator does not need to know how locals
are separated according to function prototypes. Perhaps the allocator
can be simplified if knowledge of function structure is utilized.
(E) Name allocation algorithm
-----------------------------
To begin with, the name generator is mostly separate from the name
allocation algorithm. The name generator returns the next shortest name
for the algorithm to apply to local variables. To attempt to reduce
symbol entropy (which benefit compression algorithms), the name
generator follows English frequent letter usage. Later, there may be an
option to calculate an actual symbol entropy table from the input data.
Since there are 53 one-character identifiers and (53*63-4) two-character
identifiers (minus a few keywords), there isn't a pressing need to
optimally maximize name reuse. Sample files show that we can eventually
get 20 tokens per identifier name, thus a source file can have over 1000
local variable tokens that are all single character in length.
In theory, we should need no more than 260 local identifiers by default.
Why? Since LUAI_MAXVARS is 200 and LUAI_MAXUPVALUES is 60, at any block
scope, there can be at most (LUAI_MAXVARS + LUAI_MAXUPVALUES) locals
referenced, or 260. Also, those from outer scopes not referenced in
inner scopes can reuse identifiers. The net effect of this is that a
local variable name allocation method should not allocate more than 260
identifier names for locals.
The current algorithm is a simple first-come first-served scheme:
(a) One local object that use the most tokens is named first.
(b) Any other non-conflicting locals with respect to the first
object are assigned the same name.
(c) Assigned locals are removed and the procedure is repeated for
objects that have not been assigned new names. (a) to (c)
repeats until no local objects are left.
In addition, there are a few extra issues to take care of:
(d) Implicit "self" locals that have been flagged as such are
already "assigned to" and so they are left unmodified.
(e) The name generator skips "self" to avoid conflicts. This
is not optimal but it is unlikely a script will use so many
local variables as to reach "self".
(f) Keywords are also skipped for the name generator.
(g) Global name conflict resolution.
For (g), global name conflict resolution is handled just after the new
name is generated. The name can still be used for some locals even if it
conflicts with other locals. To remove conflicts, global variable
accesses for the particular identifier name is checked. Any local
variables that are active when a global access is made is marked to be
skipped. The rest of the local objects can then use that name.
The algorithm has special handling for locals that use the same name in
the same scope. For example:
local foo = 10 -- (1)
...
local foo = 20 -- (2)
...
print(e)
Since we are considering name visibility, the first 'foo' does not
really cease to exist when the second 'foo' is declared, because if we
were to make that assumption, and the first 'foo' is removed before (2),
then I should be able to use 'e' as the name for the first 'foo' and
after (2), it should not conflict with variables in the outer scope
with the same name. To illustrate:
local e = 10 -- 'foo ' renamed to 'e'
...
local t = 20 -- error if we assumed 'e' removed here
...
print(e)
Since 'e' is a global in the example, we now have an error as the
name as been taken over by a local. Thus, the first 'foo' local must
have its active time extend to the end of the current scope. If there
is no conflict between the first and second 'foo', the algorithm may
still assign the same names to them.
The current fix to deal with the above chains local objects in order to
find the removal position. Practically, the parser can be modified to
simplify this.
END.

View File

@@ -0,0 +1,20 @@
Copyright (c) 2014 Robin Wellner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,97 @@
Smallfolk
=========
Smallfolk is a reasonably fast, robust, richtly-featured table serialization
library for Lua. It was specifically written to allow complex data structures
to be loaded from unsafe sources for [LÖVE](http://love2d.org/) games, but can
be used anywhere.
You use, distribute and extend Smallfolk under the terms of the MIT license.
Usage
-----
Smallfolk is very simple and easy to use:
```lua
local smallfolk = require 'smallfolk'
print(smallfolk.dumps({"Hello", world = true}))
print(smallfolk.loads('{"foo":"bar"}').foo)
-- prints:
-- {"Hello","world":t}
-- bar
```
Fast
----
Using Serpent's benchmark code, Smallfolk's serialization speed is comparable
to that of Ser (and Ser is 33% faster than Serpent).
It should be noted that deserialization is much slower in Smallfolk than in
most other serialization libraries, because it parses the input itself instead
of handing it over to Lua. However, if you use LuaJIT this difference is much
less, and it is not noticable for small outputs. By default, Smallfolk rejects
inputs that are too large, to prevent DOS attacks.
Robust
------
Sometimes you have strange, non-euclidean geometries in your table
constructions. It happens, I don't judge. Smallfolk can deal with that, where
some other serialization libraries (or anything that produces JSON) cry "Iä!
Iä! Cthulhu fhtagn!" and give up &mdash; or worse, silently produce incorrect
data.
```lua
local smallfolk = require 'smallfolk'
local cthulhu = {{}, {}, {}}
cthulhu.fhtagn = cthulhu
cthulhu[1][cthulhu[2]] = cthulhu[3]
cthulhu[2][cthulhu[1]] = cthulhu[2]
cthulhu[3][cthulhu[3]] = cthulhu
print(smallfolk.dumps(cthulhu))
-- prints:
-- {{{@2:@3}:{@4:@1}},@3,@4,"fhtagn":@1}
```
Secure
------
Smallfolk doesn't run arbitrary Lua code, so you can safely use it when you
want to read data from an untrusted source.
Compact
-------
Smallfolk creates really small output files compared to something like Ser when
it encounters a lot of non-tree-like data, by using numbered references rather
than item assignment.
Tested
------
Check out `tests.lua` to see how Smallfolk behaves with all kinds of inputs.
Reference
---------
###`smallfolk.dumps(object)`
Returns an 8-bit string representation of `object`. Throws an error if `object`
contains any types that cannot be serialised (userdata, functions and threads).
###`smallfolk.loads(string[, maxsize=10000])`
Returns an object whose representation would be `string`. If the length of
`string` is larger than `maxsize`, no deserialization is attempted and instead
an error is thrown. If `string` is not a valid representation of any object,
an error is thrown.
See also
--------
* [Ser](https://github.com/gvx/Ser): for trusted-source serialization
* [Lady](https://github.com/gvx/Lady): for trusted-source savegames

View File

@@ -0,0 +1,218 @@
local M = {}
Smallfolk = M
local expect_object, dump_object
local error, tostring, pairs, type, floor, huge, concat = error, tostring, pairs, type, math.floor, math.huge, table.concat
local dump_type = {}
function dump_type:string(nmemo, memo, acc)
local nacc = #acc
acc[nacc + 1] = '"'
acc[nacc + 2] = self:gsub('"', '""')
acc[nacc + 3] = '"'
return nmemo
end
function dump_type:number(nmemo, memo, acc)
acc[#acc + 1] = ("%.17g"):format(self)
return nmemo
end
function dump_type:table(nmemo, memo, acc)
--[[
if memo[self] then
acc[#acc + 1] = '@'
acc[#acc + 1] = tostring(memo[self])
return nmemo
end
nmemo = nmemo + 1
]]
memo[self] = nmemo
acc[#acc + 1] = '{'
local nself = #self
for i = 1, nself do -- don't use ipairs here, we need the gaps
nmemo = dump_object(self[i], nmemo, memo, acc)
acc[#acc + 1] = ','
end
for k, v in pairs(self) do
if type(k) ~= 'number' or floor(k) ~= k or k < 1 or k > nself then
nmemo = dump_object(k, nmemo, memo, acc)
acc[#acc + 1] = ':'
nmemo = dump_object(v, nmemo, memo, acc)
acc[#acc + 1] = ','
end
end
acc[#acc] = acc[#acc] == '{' and '{}' or '}'
return nmemo
end
function dump_object(object, nmemo, memo, acc)
if object == true then
acc[#acc + 1] = 't'
elseif object == false then
acc[#acc + 1] = 'f'
elseif object == nil then
acc[#acc + 1] = 'n'
elseif object ~= object then
if (''..object):sub(1,1) == '-' then
acc[#acc + 1] = 'N'
else
acc[#acc + 1] = 'Q'
end
elseif object == huge then
acc[#acc + 1] = 'I'
elseif object == -huge then
acc[#acc + 1] = 'i'
else
local t = type(object)
if not dump_type[t] then
error('cannot dump type ' .. t)
end
return dump_type[t](object, nmemo, memo, acc)
end
return nmemo
end
function M.dumps(object)
local nmemo = 0
local memo = {}
local acc = {}
dump_object(object, nmemo, memo, acc)
return concat(acc)
end
local function invalid(i)
error('invalid input at position ' .. i)
end
local nonzero_digit = {['1'] = true, ['2'] = true, ['3'] = true, ['4'] = true, ['5'] = true, ['6'] = true, ['7'] = true, ['8'] = true, ['9'] = true}
local is_digit = {['0'] = true, ['1'] = true, ['2'] = true, ['3'] = true, ['4'] = true, ['5'] = true, ['6'] = true, ['7'] = true, ['8'] = true, ['9'] = true}
local function expect_number(string, start)
local i = start
local head = string:sub(i, i)
if head == '-' then
i = i + 1
head = string:sub(i, i)
end
if nonzero_digit[head] then
repeat
i = i + 1
head = string:sub(i, i)
until not is_digit[head]
elseif head == '0' then
i = i + 1
head = string:sub(i, i)
else
invalid(i)
end
if head == '.' then
local oldi = i
repeat
i = i + 1
head = string:sub(i, i)
until not is_digit[head]
if i == oldi + 1 then
invalid(i)
end
end
if head == 'e' or head == 'E' then
i = i + 1
head = string:sub(i, i)
if head == '+' or head == '-' then
i = i + 1
head = string:sub(i, i)
end
if not is_digit[head] then
invalid(i)
end
repeat
i = i + 1
head = string:sub(i, i)
until not is_digit[head]
end
return tonumber(string:sub(start, i - 1)), i
end
local expect_object_head = {
t = function(string, i) return true, i end,
f = function(string, i) return false, i end,
n = function(string, i) return nil, i end,
Q = function(string, i) return -(0/0), i end,
N = function(string, i) return 0/0, i end,
I = function(string, i) return 1/0, i end,
i = function(string, i) return -1/0, i end,
['"'] = function(string, i)
local nexti = i - 1
repeat
nexti = string:find('"', nexti + 1, true) + 1
until string:sub(nexti, nexti) ~= '"'
return string:sub(i, nexti - 2):gsub('""', '"'), nexti
end,
['0'] = function(string, i)
return expect_number(string, i - 1)
end,
['{'] = function(string, i, tables)
local nt, k, v = {}
local j = 1
tables[#tables + 1] = nt
if string:sub(i, i) == '}' then
return nt, i + 1
end
while true do
k, i = expect_object(string, i, tables)
if string:sub(i, i) == ':' then
v, i = expect_object(string, i + 1, tables)
nt[k] = v
else
nt[j] = k
j = j + 1
end
local head = string:sub(i, i)
if head == ',' then
i = i + 1
elseif head == '}' then
return nt, i + 1
else
invalid(i)
end
end
end,
--[[
['@'] = function(string, i, tables)
local match = string:match('^%d+', i)
local ref = tonumber(match)
if tables[ref] then
return tables[ref], i + #match
end
invalid(i)
end,
]]
}
expect_object_head['1'] = expect_object_head['0']
expect_object_head['2'] = expect_object_head['0']
expect_object_head['3'] = expect_object_head['0']
expect_object_head['4'] = expect_object_head['0']
expect_object_head['5'] = expect_object_head['0']
expect_object_head['6'] = expect_object_head['0']
expect_object_head['7'] = expect_object_head['0']
expect_object_head['8'] = expect_object_head['0']
expect_object_head['9'] = expect_object_head['0']
expect_object_head['-'] = expect_object_head['0']
expect_object_head['.'] = expect_object_head['0']
expect_object = function(string, i, tables)
local head = string:sub(i, i)
if expect_object_head[head] then
return expect_object_head[head](string, i + 1, tables)
end
invalid(i)
end
function M.loads(string, maxsize)
if #string > (maxsize or 10000) then
error 'input too large'
end
return (expect_object(string, 1, {}))
end
return M

View File

@@ -0,0 +1,25 @@
lua-digest-crc32lua License
===============================================================================
Copyright (C) 2008, David Manura.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================

View File

@@ -0,0 +1,207 @@
--[[
LUA MODULE
digest.crc32 - CRC-32 checksum implemented entirely in Lua.
SYNOPSIS
local CRC = require 'digest.crc32lua'
print(CRC.crc32 'test') --> 0xD87F7E0C or -662733300
assert(CRC.crc32('st', CRC.crc32('te')) == CRC.crc32 'test')
DESCRIPTION
This can be used to compute CRC-32 checksums on strings.
This is similar to [1-2].
API
Note: in the functions below, checksums are 32-bit integers stored in
numbers. The number format currently depends on the bit
implementation--see DESIGN NOTES below.
CRC.crc32_byte(byte [, crc]) --> rcrc
Returns CRC-32 checksum `rcrc` of byte `byte` (number 0..255) appended to
a string with CRC-32 checksum `crc`. `crc` defaults to 0 (empty string)
if omitted.
CRC.crc32_string(s, crc) --> bcrc
Returns CRC-32 checksum `rcrc` of string `s` appended to
a string with CRC-32 checksum `crc`. `crc` defaults to 0 (empty string)
if omitted.
CRC.crc32(o, crc) --> bcrc
This invokes `crc32_byte` if `o` is a byte or `crc32_string` if `o`
is a string.
CRC.bit
This contains the underlying bit library used by the module. It
should be considered a read-only copy.
DESIGN NOTES
Currently, this module exposes the underlying bit array implementation in CRC
checksums returned. In BitOp, bit arrays are 32-bit signed integer numbers
(may be negative). In Lua 5.2 'bit32' and 'bit.numberlua', bit arrays are
32-bit unsigned integer numbers (non-negative). This is subject to change
in the future but is currently done due to (unconfirmed) performance
implications.
On platforms with 64-bit numbers, one way to normalize CRC
checksums to be unsigned is to do `crcvalue % 2^32`,
The name of this module is inspired by Perl `Digest::CRC*`.
DEPENDENCIES
Requires one of the following bit libraries:
BitOp "bit" -- bitop.luajit.org -- This is included in LuaJIT and also available
for Lua 5.1/5.2. This provides the fastest performance in LuaJIT.
Lua 5.2 "bit32" -- www.lua.org/manual/5.2 -- This is provided in Lua 5.2
and is preferred in 5.2 (unless "bit" also happens to be installed).
"bit.numberlua" (>=000.003) -- https://github.com/davidm/lua-bit-numberlua
This is slowest and used as a last resort.
It is only a few times slower than "bit32" though.
DOWNLOAD/INSTALLATION
If using LuaRocks:
luarocks install lua-digest-crc32lua
Otherwise, download <https://github.com/davidm/lua-digest-crc32lua/zipball/master>.
Alternately, if using git:
git clone git://github.com/davidm/lua-digest-crc32lua.git
cd lua-digest-crc32lua
Optionally unpack:
./util.mk
or unpack and install in LuaRocks:
./util.mk install
REFERENCES
[1] http://www.axlradius.com/freestuff/CRC32.java
[2] http://www.gamedev.net/reference/articles/article1941.asp
[3] http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/CRC32.html
[4] http://www.dsource.org/projects/tango/docs/current/tango.io.digest.Crc32.html
[5] http://pydoc.org/1.5.2/zlib.html#-crc32
[6] http://www.python.org/doc/2.5.2/lib/module-binascii.html
LICENSE
(c) 2008-2011 David Manura. Licensed under the same terms as Lua (MIT).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
(end license)
--]]
local M = {_TYPE='module', _NAME='digest.crc32', _VERSION='0.3.20111128'}
local type = type
local require = require
local setmetatable = setmetatable
--[[
Requires the first module listed that exists, else raises like `require`.
If a non-string is encountered, it is returned.
Second return value is module name loaded (or '').
--]]
local function requireany(...)
local errs = {}
for _,name in ipairs{...} do
if type(name) ~= 'string' then return name, '' end
local ok, mod = pcall(require, name)
if ok then return mod, name end
errs[#errs+1] = mod
end
error(table.concat(errs, '\n'), 2)
end
local bit, name_ = requireany('bit', 'bit32', 'bit.numberlua', 'bit53')
local bxor = bit.bxor
local bnot = bit.bnot
local band = bit.band
local rshift = bit.rshift
-- CRC-32-IEEE 802.3 (V.42)
local POLY = 0xEDB88320
-- Memoize function pattern (like http://lua-users.org/wiki/FuncTables ).
local function memoize(f)
local mt = {}
local t = setmetatable({}, mt)
function mt:__index(k)
local v = f(k); t[k] = v
return v
end
return t
end
-- CRC table.
local crc_table = memoize(function(i)
local crc = i
for _=1,8 do
local b = band(crc, 1)
crc = rshift(crc, 1)
if b == 1 then crc = bxor(crc, POLY) end
end
return crc
end)
function M.crc32_byte(byte, crc)
crc = bnot(crc or 0)
local v1 = rshift(crc, 8)
local v2 = crc_table[bxor(crc % 256, byte)]
return bnot(bxor(v1, v2))
end
local M_crc32_byte = M.crc32_byte
function M.crc32_string(s, crc)
crc = crc or 0
for i=1,#s do
crc = M_crc32_byte(s:byte(i), crc)
end
return crc
end
local M_crc32_string = M.crc32_string
function M.crc32(s, crc)
if type(s) == 'string' then
return M_crc32_string(s, crc)
else
return M_crc32_byte(s, crc)
end
end
M.bit = bit -- bit library used
return M

127
AIO_Server/LibCompress.lua Normal file
View File

@@ -0,0 +1,127 @@
-- LibCompress.lua
--
-- Authors: jjsheets and Galmok of European Stormrage (Horde)
-- Email: sheets.jeff@gmail.com and galmok@gmail.com
-- Licence: GPL version 2 (General Public License)
--
-- Hacked severely by Taehl (SelfMadeSpirit@gmail.com)
----------------------------------------------------------------------------------
assert(not TLibCompress, "LibCompress already loaded. Possibly loading different versions of LibCompress")
TLibCompress = {}
local assert = assert
local type = type
local unpack = unpack or table.unpack
local tconcat = table.concat
local schar = string.char
local ssub = string.sub
local sbyte = string.byte
local mmodf = math.modf
local floor = floor or math.floor
local function encode(x)
local bytes = {}
local xmod
repeat
x, xmod = mmodf(x/255)
xmod = xmod * 255
bytes[#bytes + 1] = xmod
until x <= 0
if #bytes == 1 and bytes[1] > 0 and bytes[1] < 250 then
return schar(bytes[1])
else
for i = 1, #bytes do bytes[i] = bytes[i] + 1 end
return schar(256 - #bytes, unpack(bytes))
end
end
local function decode(ss,i)
i = i or 1
local a = sbyte(ss,i,i)
if a > 249 then
local r = 0
a = 256 - a
for n = i+a, i+1, -1 do
r = r * 255 + sbyte(ss,n,n) - 1
end
return r, a + 1
else
return a, 1
end
end
function TLibCompress.CompressLZW(uncompressed)
assert(type(uncompressed) == 'string')
local result = {'\222'}
local ressize = 1
local w = ''
local dict = {}
local dict_size = 256
for i = 0, 255 do
dict[schar(i)] = i
end
for i = 1, #uncompressed do
local c = ssub(uncompressed,i,i)
local wc = w..c
if dict[wc] then
w = wc
else
dict[wc] = dict_size
dict_size = dict_size +1
local r = encode(dict[w])
ressize = ressize + #r
result[#result + 1] = r
w = c
end
end
if w then
local r = encode(dict[w])
ressize = ressize + #r
result[#result + 1] = r
end
if (#uncompressed+1) > ressize then
return tconcat(result)
else
return '\1'..uncompressed
end
end
function TLibCompress.DecompressLZW(compressed)
assert(type(compressed) == 'string')
local UC
UC, compressed = ssub(compressed,1,1), ssub(compressed, 2)
if UC == '\1' then
return compressed
end
if UC ~= "\222" then
return nil, "Can only decompress LZW compressed data ("..tostring(UC)..")"
end
local dict_size = 256
local dict = {}
for i = 0, 255 do
dict[i] = schar(i)
end
local result = {}
local t = 1
local delta, k
k, delta = decode(compressed,t)
t = t + delta
result[#result+1] = dict[k]
local w = dict[k]
local entry
local csize = #compressed
while t <= csize do
k, delta = decode(compressed,t)
t = t + delta
entry = dict[k] or (w..ssub(w,1,1))
result[#result+1] = entry
dict[dict_size] = w..ssub(entry,1,1)
dict_size = dict_size + 1
w = entry
end
return tconcat(result)
end
return TLibCompress

29
AIO_Server/bit53.lua Normal file
View File

@@ -0,0 +1,29 @@
-- Provides compatibility for scripts using bit libs for lua versions < 5.3
-- Using load to avoid errors when having this file in earlier lua sources than 5.3
-- check that lua version is higher or equal to 5.3
local MIN_LUA_VER = 5.3
if tonumber(_VERSION:match("%d+%.?%d*")) >= MIN_LUA_VER then
return assert(assert(load( [[
local bit53 = {}
function bit53.band(a,b)
return a&b
end
function bit53.bor(a,b)
return a|b
end
function bit53.bxor(a,b)
return a~b
end
function bit53.bnot(a)
return ~a
end
function bit53.lshift(a, b)
return a<<b
end
function bit53.rshift(a, b)
return a>>b
end
return bit53
]], "bit53" ))())
end

83
AIO_Server/queue.lua Normal file
View File

@@ -0,0 +1,83 @@
local Queue = {}
function Queue.__index(que, key)
return Queue[key]
end
function NewQueue()
local t = {first = 0, last = -1}
setmetatable(t, Queue)
return t
end
function Queue.pushleft(que, value)
local first = que.first - 1
que.first = first
que[first] = value
return first
end
function Queue.pushright(que, value)
local last = que.last + 1
que.last = last
que[last] = value
return last
end
function Queue.popleft(que)
local first = que.first
if first > que.last then error("que is empty") end
local value = que[first]
que[first] = nil -- to allow garbage collection
que.first = first + 1
return value
end
function Queue.popright(que)
local last = que.last
if que.first > last then error("que is empty") end
local value = que[last]
que[last] = nil -- to allow garbage collection
que.last = last - 1
return value
end
function Queue.peekleft(que)
return que[que.first]
end
function Queue.peekright(que)
return que[que.last]
end
function Queue.empty(que)
return que.last < que.first
end
function Queue.size(que)
return que.last - que.first + 1
end
function Queue.clear(que)
local l, r = self:getrange()
for i = l, r do
que[idx] = nil
end
que.first, que.last = 0, -1
end
function Queue.get(que, idx)
if idx < que.first or idx > que.last then
return
end
return que[idx]
end
function Queue.getrange(que)
return que.first, que.last
end
function Queue.gettable(que)
return que
end
return NewQueue

63
DatatypeCheckFunction.lua Normal file
View File

@@ -0,0 +1,63 @@
--[[LIST OF FUNCTIONS WE HAVE client->Server for this protection to be enabled.
TheClassMaskingSolution/TooltipCorrectorServer.lua
tTHandler.HasSpellID(player, spellid) -- done
tTHandler.CostGrabber(player, spellid) -- done
EnchantReRoll/EnchantReRollS.lua
MyHandlers.ReforgeItem(player,bag,slot) -- done
MyHandlers.ReforgeItem_Prep(player,bag,slot) -- done
MyHandlers.SetItem(player,bag,slot) -- done
extra_buttons_bar/ServerEBB.lua
MyHandlers.AddStats(player, stat, s_amount) -- done
MyHandlers.ReduceStats(player, stat, s_amount) -- done
MyHandlers.SendAmountOfSpells(player, class, Spec) -- done
MyHandlers.GetAllBGs(player, ClassSpec) -- done
MyHandlers.LearnThisTalent(player, attached_talent, indexAt,ClassSpec) -- done
MyHandlers.UnLearnThisTalent(player, attached_talent, indexAt,ClassSpec)
MyHandlers.LearnThisSpell(player, got_spell, i,class,spec) -- done
MyHandlers.UnLearnThisSpell(player, got_spell, i,class,spec) -- done
hardcore_pvp/PvPServer.lua
MyHandlers.AddPlayerItem(player, itemEntry, itemCount, object) -- done
]]--
local valid_types = {
["nil"] = true,
["number"] = true,
["string"] = true,
["boolean"] = true,
["table"] = true,
["function"] = true,
["thread"] = true,
["userdata"] = true,
}
function DataTypeCheck(fmt, args)
for k, expected in pairs(fmt) do
local exp_type = type(expected)
if exp_type == "string" then
assert(valid_types[expected], "invalid type in fmt: "..tostring(expected))
local typ = type(args[k])
if typ ~= expected then
return false, string.format("%s was of type %s, %s expected", tostring(k), typ, expected)
end
elseif exp_type == "table" then
local typ = type(args[k])
if typ ~= exp_type then
return false, string.format("%s was of type %s, %s expected", tostring(k), typ, exp_type)
end
local succ, err = DataTypeCheck(expected, args[k])
if not succ then
return succ, err
end
else
error("unknown expecatation in fmt: "..tostring(expected))
end
end
return true
end
--[[some example usage
local fmt = {"number", "string", {}, {"number", "string", ke = {}}}
local arg = {1, "asd", {}, {1,"str", ke = {}}}
print(DataTypeCheck(fmt, arg))]]--

30
Dungeons/AoEDamage.lua~ Normal file
View File

@@ -0,0 +1,30 @@
--[[local dmg = 0
local function Apply(eventId, delay, repeats, creature)
local people = creature:GetUnfriendlyUnitsInRange(100)
local hp2 = creature:GetHealth()
local dmg = hp1 - hp2
for x=1,#people,1 do
people[x]:DealDamage(people[x], dmg, true, 6)
SendWorldMessage("damage applied")
end
SendWorldMessage("Hp2 is " ..hp2.. ".")
SendWorldMessage("dmg is " ..dmg.. ".")
creature:AddAura(20217, creature)
end
local function AoE(event, creature, attacker, damage)
if creature:HasAura(465) == true and creature:HasAura(20217) == false then
creature:RegisterEvent(Apply, 10000, 1)
attacker:SendBroadcastMessage("applied event")
creature:AddAura(20217, creature)
hp1 = creature:GetHealth()
attacker:SendBroadcastMessage("current hp is " ..hp1.. ".")
end
end--]]
local function AoE(event, creature, attacker, damage)
attacker:SendBroadcastMessage("LUA is working.")
end
RegisterCreatureEvent( 12264, 9, AoE )

132
Dungeons/Buff.lua Normal file
View File

@@ -0,0 +1,132 @@
--[[local function Redo(eventId, delay, repeats, player)
Buff(event, player)
--DEBUG--player:SendBroadcastMessage("test")
end
local timing = false
function Buff(event, player)
-- query to select spell and map
local Buff1 = WorldDBQuery("SELECT map, spell FROM instance_buff WHERE map = " ..player:GetMapId().. ";")
if (Buff1 ~= nil) then
--so we dont dupe the same timer 100000 times
if (timing == false) then
player:RegisterEvent(Redo, 60000, 0)
--DEBUG--player:SendBroadcastMessage("timing now")
timing = true
end
local mobs = player:GetCreaturesInRange(533)
local buffspell = {}
for z=1,Buff1:GetRowCount(),1 do
buffspell[z] = Buff1:GetInt32(1)
Buff1:NextRow()
end
-- add aura based on DB query above and loop for mobs in range
for x=1,#mobs,1 do
for y=1,#buffspell,1 do
-- checks for aura first, then possible pet, then for player
if (mobs[x]:HasAura(buffspell[y]) == false) and (mobs[x]:GetPetGUID() == nil) and (mobs[x]:HasSpell(818011) == false) then
mobs[x]:AddAura(buffspell[y], mobs[x])
end
end
end
else
-- do this because they arent in a buffed instance
timing = false
--DEBUG--player:SendBroadcastMessage("stopped timing")
end
end
RegisterPlayerEvent(28, Buff)]]--
-- my edit of this script -- Need to be tested --
local instance_buff = {
[43]={966010}, -- WC
[389]={966010}, -- RFC
[36]={966010}, -- Deadmines
[33]={966011}, -- SFK
[48]={966011}, -- BFD
[34]={966011}, -- Stockades
[90]={966012}, -- Gnomer
[47]={966012}, -- RFK
[189]={966012}, -- SM
[129]={966013}, -- RFD
[70]={966013}, -- Uld
[209]={966013}, -- ZF
[349]={966013}, -- Mara
[109]={966014}, -- ST
[230]={966014}, -- BRD
[229]={966016}, -- Scholo
[429]={966016}, -- DM
[329]={966016}, -- Strat
[289]={966015}, -- BRS
[409]={966019}, -- MC
[249]={966020}, -- Onyxias Lair
[309]={966022}, -- Zul'Gurub
[469]={966021}, -- Blackwing Lair
[509]={966021}, -- AQ20
[531]={966024}, -- AQ40
[533]={966025}, -- Naxx
}
local instance_flag_buff = 966026
local function Instance_Buff(event,player,enemy)
if not(enemy:ToCreature()) then
return false
end
if (enemy:HasAura(instance_flag_buff)) then -- flag check
return false
end
local Instance_Map = player:GetMap()
local Instance_Creatures_ToBuff = {}
local Instance_Buffs = {}
if not(Instance_Map:IsDungeon()) and not(Instance_Map:IsRaid()) then
return false
end
Instance_Buffs = instance_buff[Instance_Map:GetMapId()]
if not(Instance_Buffs[1]) then
return false
end
local Instance_Creatures = player:GetCreaturesInRange(300)
for id,creature in pairs(Instance_Creatures) do
if not(creature:HasAura(instance_flag_buff)) and not(creature:HasSpell(818011)) then -- flag check (replaced with special aura which works the same way as auras we have)
-- pet check --
if (creature:GetOwner()) then
if not(creature:GetOwner():ToPlayer()) then
table.insert(Instance_Creatures_ToBuff, creature)
end
else
-- --
table.insert(Instance_Creatures_ToBuff, creature)
end
end
end
if not(Instance_Creatures_ToBuff[1]) then
return false
end
for k,cre_to_buff in pairs(Instance_Creatures_ToBuff) do
for i,cre_aura in pairs(Instance_Buffs) do
if not(cre_to_buff:HasAura(cre_aura)) then
cre_to_buff:AddAura(cre_aura, cre_to_buff)
cre_to_buff:AddAura(instance_flag_buff, cre_to_buff)
--cre_to_buff:SendUnitSay("Aura Applied", 0) -- DEBUG
end
end
end
end
--RegisterPlayerEvent(28, Instance_Buff) -- run the script on mapchange event
RegisterPlayerEvent(33, Instance_Buff) -- on enter combat

View File

@@ -0,0 +1,29 @@
RegisterGameObjectEvent( 170592, 1, function(event, go, diff)
if (diff>100) then
diff = 0
local player = go:GetNearestPlayer(10)
if not(player) then
return false
end -- check if there is a player
local throne = player:GetNearestGameObject(5)
if not(throne) then
return false
end
if (throne:GetEntry() ~= go:GetEntry()) then
return false
end-- check if nearest gameobject is throne we need
if not(player:GetStandState() == 5) then
return false
end -- check if player is sitting
local creature = player:GetNearestCreature(533, 9019)
if not(creature) then
return false
end -- check if there is a crature we need
if not(creature:IsAlive()) then
return false
end -- check if it is alive and we can cast spells
player:CastSpell( creature, 56685, true)
end
end)

View File

@@ -0,0 +1,12 @@
--[[local BossEntry_Magmadar = 11982
local GameObject_LavaBomb1 = 177704
local Spell_LavaBomb1 = 19411
local Spell_LavaBomb2 = 20474
local function LavaBombSpawn(event, creature, target, spellid)
if (spellid == Spell_LavaBomb1) or (spellid == Spell_LavaBomb2) then
PerformIngameSpawn( 2, GameObject_LavaBomb1, target:GetMapId(), target:GetInstanceId(), target:GetX(), target:GetY(), target:GetZ(), target:GetO(), 0, 1800, target:GetPhaseMask())
end
end
RegisterCreatureEvent(BossEntry_Magmadar, 15, LavaBombSpawn)]]--

View File

@@ -0,0 +1,354 @@
local AIO = AIO or require("AIO")
if AIO.AddAddon() then
return
end
local MyHandlers = AIO.AddHandlers("EnchantReRoll", {})
local Reforge_Spell = 964998
--[[MAIN FRAME SCRIPTS]]--
local function EnchantReRollMain_RollButton_Check(self,elapsed)
if (EnchantReRollMain.item) then
self:Enable()
else
self:Disable()
end
end
-- gets last item player locked to send slot and bug id to server
local function EnchantReRollMain_GetLastLockedItem(self,event,bag,slot)
if (bag and slot) then
if (bag == 0) then
EnchantReRollMain.Bag = 255
EnchantReRollMain.Slot = slot+22
else
EnchantReRollMain.Bag = bag+18
EnchantReRollMain.Slot = slot-1
end
elseif (bag and (slot == nil)) then
EnchantReRollMain.Bag = 255
EnchantReRollMain.Slot = bag-1
end
end
local function EnchantReRollMain_Reforge_CastSuccess(self,event,unit,spellname)
local name = GetSpellInfo(964998)
if (spellname == name) and (unit == "player") then
if (EnchantReRollMain.item and EnchantReRollMain_RollButton.Bag and EnchantReRollMain_RollButton.Slot) then
AIO.Handle("EnchantReRoll", "ReforgeItem", EnchantReRollMain_RollButton.Bag, EnchantReRollMain_RollButton.Slot)
PlaySound("Glyph_MajorDestroy")
end
end
end
function MyHandlers.EnchantReRollMain_Reforge(player,neweffect) -- AIO
--Set up strings from server
EnchantReRollMain.itemEffectName2 = GetSpellInfo(neweffect)
if (not(EnchantReRollMain.itemEffectName2)) or (EnchantReRollMain.itemEffectName2 == "Enchanting") then
EnchantReRollMain.itemEffectName2 = "Enhant Reforged"
neweffect = 964998
end
EnchantReRollMain.itemEffect2 = "|Hspell:"..neweffect.."|h["..EnchantReRollMain.itemEffectName2.."]|h"
EnchantReRollMain_Item_EffectAFrame_BaseEffectAText:SetText("|cff00FF00"..EnchantReRollMain.itemEffect2.."|r")
--Play Reforge Animations
EnchantReRollMain_Item_EffectAFrame_Animgroup:Stop()
EnchantReRollMain_Item_EffectAFrame_Animgroup2:Stop()
BaseFrameFadeIn(EnchantReRollMain_Item_EffectAFrame)
EnchantReRollMain_Item_EffectAFrame_Animgroup:Play()
BaseFrameFadeIn(EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture)
end
---[[MAIN FRAME SETTINGS]]---
FrameMain = CreateFrame("Frame", "EnchantReRollMain", UIParent, nil)
local EnchantReRollMain = FrameMain
EnchantReRollMain:SetSize(420,420)
EnchantReRollMain:SetPoint("CENTER")
EnchantReRollMain:SetMovable(true)
EnchantReRollMain:EnableMouse(true)
EnchantReRollMain:RegisterForDrag("LeftButton")
EnchantReRollMain:SetClampedToScreen(true)
EnchantReRollMain:SetScript("OnDragStart", EnchantReRollMain.StartMoving)
EnchantReRollMain:SetScript("OnHide", EnchantReRollMain.StopMovingOrSizing)
EnchantReRollMain:SetScript("OnDragStop", EnchantReRollMain.StopMovingOrSizing)
EnchantReRollMain:RegisterEvent("ITEM_LOCKED")
EnchantReRollMain:SetScript("OnEvent", EnchantReRollMain_GetLastLockedItem)
--EnchantReRollMain:Hide()
EnchantReRollMain:SetBackdrop({
bgFile = "Interface\\AddOns\\AwAddons\\Textures\\enchant\\enchants_main",
insets = { left = -40, right = -40, top = -40, bottom = -40}
})
EnchantReRollMain:Hide()
local EnchantReRollMain_CloseButton = CreateFrame("Button", "EnchantReRollMain_CloseButton", EnchantReRollMain, "UIPanelCloseButton")
EnchantReRollMain_CloseButton:SetPoint("TOPRIGHT", -19, -15)
EnchantReRollMain_CloseButton:EnableMouse(true)
EnchantReRollMain_CloseButton:SetSize(25, 25)
EnchantReRollMain_CloseButton:SetScript("OnClick", function()
PlaySound("igMainMenuOptionCheckBoxOn")
EnchantReRollMain:Hide()
end)
local EnchantReRollMain_RollButton = CreateFrame("Button", "EnchantReRollMain_RollButton", EnchantReRollMain, "UIPanelButtonTemplate")
EnchantReRollMain_RollButton:SetWidth(120)
EnchantReRollMain_RollButton:SetHeight(22)
EnchantReRollMain_RollButton:SetPoint("BOTTOM", 0,90)
EnchantReRollMain_RollButton:RegisterForClicks("AnyUp")
EnchantReRollMain_RollButton:SetText("Reforge item")
EnchantReRollMain_RollButton:Disable()
EnchantReRollMain_RollButton:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
EnchantReRollMain_RollButton:SetScript("OnEvent", EnchantReRollMain_Reforge_CastSuccess)
EnchantReRollMain_RollButton:SetScript("OnUpdate", EnchantReRollMain_RollButton_Check)
EnchantReRollMain_RollButton:SetScript("OnMouseDown",function()
if (EnchantReRollMain.item and EnchantReRollMain_RollButton.Bag and EnchantReRollMain_RollButton.Slot) then
PlaySound("igMainMenuOptionCheckBoxOn")
AIO.Handle("EnchantReRoll", "ReforgeItem_Prep", EnchantReRollMain_RollButton.Bag, EnchantReRollMain_RollButton.Slot)
end
end)
local EnchantReRollMain_TitleText = EnchantReRollMain:CreateFontString("EnchantReRollMain_TitleText")
EnchantReRollMain_TitleText:SetFont("Fonts\\MORPHEUS.TTF", 15)
EnchantReRollMain_TitleText:SetPoint("TOP", 0, -6)
EnchantReRollMain_TitleText:SetShadowOffset(0,0)
EnchantReRollMain_TitleText:SetText("|cff110011Enchant Reforge|r")
local EnchantReRollMain_CostText = EnchantReRollMain:CreateFontString("EnchantReRollMain_TitleText")
EnchantReRollMain_CostText:SetFont("Fonts\\MORPHEUS.TTF", 14, "OUTLINE")
EnchantReRollMain_CostText:SetShadowOffset(1, -1)
EnchantReRollMain_CostText:SetPoint("BOTTOM", 0, 125)
EnchantReRollMain_CostText:SetShadowOffset(0,0)
EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture = EnchantReRollMain:CreateTexture(nil, "ARTWORK")
EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture:SetHeight(EnchantReRollMain:GetHeight()+80)
EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture:SetWidth(EnchantReRollMain:GetWidth()+80)
EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\enchant\\enchants_ReforgeEffect")
EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture:SetPoint("CENTER",EnchantReRollMain,0,0)
EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture:SetBlendMode("ADD")
EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture:Hide()
--[[ITEM FRAME SCRIPTS]]--
function MyHandlers.EnchantReRoll_PlaceItem(player,item,nameeffect,cost,bag,slot) -- AIO
--Setting up item to the button
PlaySound("Glyph_MajorCreate")
local name, itemlink, _, _, _, _, _, _, _, texture, _ = GetItemInfo(item)
ClearCursor()
EnchantReRollMain_Item.Button:SetNormalTexture(texture)
EnchantReRollMain.item = item
EnchantReRollMain.itemEffectName = GetSpellInfo(nameeffect)
if (not(EnchantReRollMain.itemEffectName)) or (EnchantReRollMain.itemEffectName == "Enchanting") then
EnchantReRollMain.itemEffectName = "This item is ready to be enchanted"
nameeffect = 964998
end
EnchantReRollMain.itemEffect = "|Hspell:"..nameeffect.."|h["..EnchantReRollMain.itemEffectName.."]|h"
EnchantReRollMain.itemCost = cost
--For Reforge
EnchantReRollMain_RollButton.Slot = slot
EnchantReRollMain_RollButton.Bag = bag
--cost
local gold,silver,copper = GetGoldForMoney(EnchantReRollMain.itemCost)
--Play animations
EnchantReRollMain_Item_EffectFrame_BaseEffectText:SetText("|cff00FF00"..EnchantReRollMain.itemEffect.."|r")
EnchantReRollMain_CostText:SetText("|cffE1AB18Reforge cost: |cffFFFFFF"..gold.."|TInterface\\MONEYFRAME\\UI-GoldIcon.blp:11:11:0:-1|t "..silver.."|TInterface\\MONEYFRAME\\UI-SilverIcon.blp:11:11:0:-1|t "..copper.."|TInterface\\MONEYFRAME\\UI-CopperIcon.blp:11:11:0:-1|t|r")
EnchantReRollMain_Item_BackgroundTexture:SetAlpha(1.0)
BaseFrameFadeIn(EnchantReRollMain_Item_BackgroundTexture_Effect)
BaseFrameFadeIn(EnchantReRollMain_Item_EffectFrame)
EnchantReRollMain_Item_EffectFrame_Animgroup:Play()
end
local function EnchantReRoll_ShowLink(self)
if (EnchantReRollMain.item) then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetHyperlink(EnchantReRollMain.item)
GameTooltip:Show()
end
end
function MyHandlers.EnchantReRoll_Init(player)
PlaySound("Glyph_MajorCreate")
BaseFrameFadeIn(EnchantReRollMain)
end
function MyHandlers.EnchantReRoll_Close(player)
if (EnchantReRollMain:IsVisible()) then
PlaySound("igMainMenuOptionCheckBoxOn")
EnchantReRollMain:Hide()
end
end
---[[ITEM FRAME SETTINGS]]---
local EnchantReRollMain_Item = CreateFrame("Frame", "EnchantReRollMain_Item", EnchantReRollMain, nil)
EnchantReRollMain_Item:SetSize(108,108)
EnchantReRollMain_Item:SetPoint("CENTER", 0, 130)
EnchantReRollMain_Item:SetFrameStrata("HIGH")
EnchantReRollMain_Item:SetBackdrop({
bgFile = "Interface\\AddOns\\AwAddons\\Textures\\enchant\\itemslot",
})
EnchantReRollMain_Item.Button = CreateFrame("Button", "EnchantReRollMain_Item.Button", EnchantReRollMain_Item, nil)
EnchantReRollMain_Item.Button:SetSize(34, 34)
EnchantReRollMain_Item.Button:SetPoint("CENTER",0,0)
EnchantReRollMain_Item.Button:EnableMouse(true)
EnchantReRollMain_Item.Button:SetFrameStrata("HIGH")
--EnchantReRollMain_Item.Button:SetNormalTexture("Interface\\Icons\\INV_Chest_Samurai")
EnchantReRollMain_Item.Button:SetHighlightTexture("Interface\\BUTTONS\\ButtonHilight-Square")
--EnchantReRollMain_Item.Button:SetPushedTexture("Interface/BUTTONS/UI-SpellbookIcon-NextPage-Down")
EnchantReRollMain_Item.Button:SetScript("OnMouseDown",function()
local Type, data, subType, subData = GetCursorInfo()
if (Type == "item") and EnchantReRollMain.Bag and EnchantReRollMain.Slot then
AIO.Handle("EnchantReRoll", "SetItem", EnchantReRollMain.Bag, EnchantReRollMain.Slot) -- AIO part
else
--Remove Item and animations
EnchantReRollMain_Item.Button:SetNormalTexture(nil)
EnchantReRollMain.item = nil
EnchantReRollMain_Item_BackgroundTexture:SetAlpha(0.6)
EnchantReRollMain_CostText:SetText("")
BaseFrameFadeOut(EnchantReRollMain_Item_BackgroundTexture_Effect)
BaseFrameFadeOut(EnchantReRollMain_Item_EffectFrame)
end
end)
EnchantReRollMain_Item.Button:SetScript("OnEnter",EnchantReRoll_ShowLink)
EnchantReRollMain_Item.Button:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
EnchantReRollMain_Item_Border = EnchantReRollMain_Item.Button:CreateTexture(nil, "OVERLAY")
EnchantReRollMain_Item_Border:SetSize(EnchantReRollMain_Item:GetSize())
EnchantReRollMain_Item_Border:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\enchant\\itemborder")
EnchantReRollMain_Item_Border:SetPoint("CENTER",1,-2)
EnchantReRollMain_Item_Background = CreateFrame("FRAME","EnchantReRollMain_Item_Background",EnchantReRollMain)
EnchantReRollMain_Item_Background:SetSize(EnchantReRollMain:GetSize())
EnchantReRollMain_Item_Background:SetPoint("CENTER")
EnchantReRollMain_Item_Background:SetFrameStrata("MEDIUM")
EnchantReRollMain_Item_BackgroundTexture = EnchantReRollMain_Item_Background:CreateTexture(nil, "BACKGROUND")
EnchantReRollMain_Item_BackgroundTexture:SetSize(256,64)
EnchantReRollMain_Item_BackgroundTexture:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\enchant\\itemHighlight")
EnchantReRollMain_Item_BackgroundTexture:SetPoint("CENTER",EnchantReRollMain_Item,0,-5)
EnchantReRollMain_Item_BackgroundTexture:SetBlendMode("ADD")
EnchantReRollMain_Item_BackgroundTexture:SetAlpha(0.6)
EnchantReRollMain_Item_BackgroundTexture_Effect = CreateFrame("Model", "EnchantReRollMain_Item_BackgroundTexture_Effect", EnchantReRollMain_Item_Background)
EnchantReRollMain_Item_BackgroundTexture_Effect:SetWidth(256);
EnchantReRollMain_Item_BackgroundTexture_Effect:SetHeight(256);
EnchantReRollMain_Item_BackgroundTexture_Effect:SetPoint("CENTER", EnchantReRollMain_Item, "CENTER", 0, -20)
EnchantReRollMain_Item_BackgroundTexture_Effect:SetModel("World\\Expansion01\\doodads\\netherstorm\\crackeffects\\netherstormcracksmokeblue.m2")
EnchantReRollMain_Item_BackgroundTexture_Effect:SetModelScale(0.07)
EnchantReRollMain_Item_BackgroundTexture_Effect:SetCamera(0)
EnchantReRollMain_Item_BackgroundTexture_Effect:SetPosition(0.08,0.10,0)
--EnchantReRollMain_Item_BackgroundTexture_Effect:SetAlpha(0.8)
EnchantReRollMain_Item_BackgroundTexture_Effect:SetFacing(0.1)
EnchantReRollMain_Item_BackgroundTexture_Effect:Hide()
--[ITEM FRAME EFFECT SCRIPTS]--
local function EnchantReRollMain_Item_EffectFrame_ShowLink(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetHyperlink(EnchantReRollMain.itemEffect)
GameTooltip:Show()
end
local function EnchantReRollMain_Item_EffectAFrame_ShowLink(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetHyperlink(EnchantReRollMain.itemEffect2)
GameTooltip:Show()
end
local function EnchantReRollMain_Item_EffectAFrame_Animgroup_End(self)
BaseFrameFadeOut(EnchantReRollMain_Item_EffectAFrame)
BaseFrameFadeOut(EnchantReRollMain_Item_EffectAFrame_ReforgeCompleteTexture)
EnchantReRollMain.itemEffect = EnchantReRollMain.itemEffect2
EnchantReRollMain_Item_EffectFrame_BaseEffectText:SetText("|cff00FF00"..EnchantReRollMain.itemEffect.."|r")
end
--[ITEM FRAME EFFECT]--
local EnchantReRollMain_Item_EffectFrame = CreateFrame("Frame", "EnchantReRollMain_Item_EffectFrame", EnchantReRollMain, nil)
EnchantReRollMain_Item_EffectFrame:SetSize(100,44)
EnchantReRollMain_Item_EffectFrame:SetPoint("CENTER", 0, 57)
EnchantReRollMain_Item_EffectFrame:SetFrameStrata("HIGH")
EnchantReRollMain_Item_EffectFrame:EnableMouse(true)
EnchantReRollMain_Item_EffectFrame:SetScript("OnEnter", EnchantReRollMain_Item_EffectFrame_ShowLink)
EnchantReRollMain_Item_EffectFrame:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
EnchantReRollMain_Item_EffectFrame:Hide()
local EnchantReRollMain_Item_EffectFrame_BackgroundTexture = EnchantReRollMain_Item_EffectFrame:CreateTexture(nil, "BACKGROUND")
EnchantReRollMain_Item_EffectFrame_BackgroundTexture:SetSize(EnchantReRollMain:GetSize())
EnchantReRollMain_Item_EffectFrame_BackgroundTexture:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\enchant\\enchants_textH")
EnchantReRollMain_Item_EffectFrame_BackgroundTexture:SetPoint("CENTER",EnchantReRollMain,0,0)
--EnchantReRollMain_Item_EffectFrame_BackgroundTexture:SetBlendMode("ADD")
EnchantReRollMain_Item_EffectFrame_BaseEffectText = EnchantReRollMain_Item_EffectFrame:CreateFontString("EnchantReRollMain_TitleText")
EnchantReRollMain_Item_EffectFrame_BaseEffectText:SetFont("Fonts\\MORPHEUS.TTF", 14, "OUTLINE")
EnchantReRollMain_Item_EffectFrame_BaseEffectText:SetShadowOffset(1, -1)
EnchantReRollMain_Item_EffectFrame_BaseEffectText:SetSize(200,14)
EnchantReRollMain_Item_EffectFrame_BaseEffectText:SetPoint("CENTER", EnchantReRollMain, 0, 57)
EnchantReRollMain_Item_EffectFrame_BaseEffectText:SetShadowOffset(0,0)
--effect animations
EnchantReRollMain_Item_EffectFrame_Animgroup2 = EnchantReRollMain_Item_EffectFrame:CreateAnimationGroup()
local EnchantReRollMain_Item_EffectFrame_Scale2 = EnchantReRollMain_Item_EffectFrame_Animgroup2:CreateAnimation("Scale")
EnchantReRollMain_Item_EffectFrame_Scale2:SetDuration(0.5)
EnchantReRollMain_Item_EffectFrame_Scale2:SetOrder(1)
EnchantReRollMain_Item_EffectFrame_Scale2:SetEndDelay(0)
EnchantReRollMain_Item_EffectFrame_Scale2:SetScale(10,1)
EnchantReRollMain_Item_EffectFrame_Animgroup = EnchantReRollMain_Item_EffectFrame:CreateAnimationGroup()
local EnchantReRollMain_Item_EffectFrame_Scale1 = EnchantReRollMain_Item_EffectFrame_Animgroup:CreateAnimation("Scale")
EnchantReRollMain_Item_EffectFrame_Scale1:SetDuration(0)
EnchantReRollMain_Item_EffectFrame_Scale1:SetOrder(1)
EnchantReRollMain_Item_EffectFrame_Scale1:SetEndDelay(0.5)
EnchantReRollMain_Item_EffectFrame_Scale1:SetScale(0.1,1)
EnchantReRollMain_Item_EffectFrame_Animgroup:SetScript("OnPlay", function()
EnchantReRollMain_Item_EffectFrame_Animgroup2:Play()
end)
--[ITEM FRAME APPLIED EFFECT]--
local EnchantReRollMain_Item_EffectAFrame = CreateFrame("Frame", "EnchantReRollMain_Item_EffectAFrame", EnchantReRollMain, nil)
EnchantReRollMain_Item_EffectAFrame:SetSize(100,44)
EnchantReRollMain_Item_EffectAFrame:SetPoint("CENTER", 0, -20)
EnchantReRollMain_Item_EffectAFrame:SetFrameStrata("MEDIUM")
EnchantReRollMain_Item_EffectAFrame:EnableMouse(true)
EnchantReRollMain_Item_EffectAFrame:SetScript("OnEnter", EnchantReRollMain_Item_EffectAFrame_ShowLink)
EnchantReRollMain_Item_EffectAFrame:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
EnchantReRollMain_Item_EffectAFrame:Hide()
local EnchantReRollMain_Item_EffectAFrame_BackgroundTexture = EnchantReRollMain_Item_EffectAFrame:CreateTexture(nil, "BACKGROUND")
EnchantReRollMain_Item_EffectAFrame_BackgroundTexture:SetSize(EnchantReRollMain:GetSize())
EnchantReRollMain_Item_EffectAFrame_BackgroundTexture:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\enchant\\enchants_textH")
EnchantReRollMain_Item_EffectAFrame_BackgroundTexture:SetPoint("CENTER",EnchantReRollMain,0,-67)
EnchantReRollMain_Item_EffectAFrame_BackgroundTexture:SetBlendMode("ADD")
EnchantReRollMain_Item_EffectAFrame_BaseEffectAText = EnchantReRollMain_Item_EffectAFrame:CreateFontString("EnchantReRollMain_TitleText")
EnchantReRollMain_Item_EffectAFrame_BaseEffectAText:SetFont("Fonts\\MORPHEUS.TTF", 14, "OUTLINE")
EnchantReRollMain_Item_EffectAFrame_BaseEffectAText:SetShadowOffset(1, -1)
EnchantReRollMain_Item_EffectAFrame_BaseEffectAText:SetSize(200,14)
EnchantReRollMain_Item_EffectAFrame_BaseEffectAText:SetPoint("CENTER", EnchantReRollMain, 0,-11)
EnchantReRollMain_Item_EffectAFrame_BaseEffectAText:SetShadowOffset(0,0)
--effectA animations
EnchantReRollMain_Item_EffectAFrame_Animgroup2 = EnchantReRollMain_Item_EffectAFrame:CreateAnimationGroup()
local EnchantReRollMain_Item_EffectAFrame_Scale2 = EnchantReRollMain_Item_EffectAFrame_Animgroup2:CreateAnimation("Scale")
EnchantReRollMain_Item_EffectAFrame_Scale2:SetDuration(1.5)
EnchantReRollMain_Item_EffectAFrame_Scale2:SetOrder(1)
EnchantReRollMain_Item_EffectAFrame_Scale2:SetEndDelay(2)
EnchantReRollMain_Item_EffectAFrame_Scale2:SetScale(10,1)
EnchantReRollMain_Item_EffectAFrame_Scale2:SetScript("OnFinished", EnchantReRollMain_Item_EffectAFrame_Animgroup_End)
EnchantReRollMain_Item_EffectAFrame_Scale2:SetScript("OnStop", EnchantReRollMain_Item_EffectAFrame_Animgroup_End)
EnchantReRollMain_Item_EffectAFrame_Animgroup = EnchantReRollMain_Item_EffectAFrame:CreateAnimationGroup()
local EnchantReRollMain_Item_EffectAFrame_Scale1 = EnchantReRollMain_Item_EffectAFrame_Animgroup:CreateAnimation("Scale")
EnchantReRollMain_Item_EffectAFrame_Scale1:SetDuration(0)
EnchantReRollMain_Item_EffectAFrame_Scale1:SetOrder(1)
EnchantReRollMain_Item_EffectAFrame_Scale1:SetEndDelay(3.5)
EnchantReRollMain_Item_EffectAFrame_Scale1:SetScale(0.1,1)
EnchantReRollMain_Item_EffectAFrame_Animgroup:SetScript("OnPlay", function()
EnchantReRollMain_Item_EffectAFrame_Animgroup2:Play()
end)

View File

@@ -0,0 +1,228 @@
local AIO = AIO or require("AIO")
local MyHandlers = AIO.AddHandlers("EnchantReRoll", {})
local ReforgeAltar = 8000051
local ReforgeAltar_menu = 45004
--gossip part
function enchantReRoll_CloseMenu(msg,player)
return msg:Add("EnchantReRoll", "EnchantReRoll_Close")
end
function enchantReRoll_OpenMenu(msg,player)
return msg:Add("EnchantReRoll", "EnchantReRoll_Init")
end
local function OnGossipHello_ReforgeAltar(event, player, Altar)
player:GossipClearMenu()
enchantReRoll_OpenMenu(AIO.Msg(), player):Send(player)
player:GossipSendMenu(1, Altar, ReforgeAltar_menu)
player:GossipComplete()
end
RegisterGameObjectGossipEvent(ReforgeAltar, 1, OnGossipHello_ReforgeAltar)
function GameobjectCheck(player)
local altar = nil
altar = player:GetNearestGameObject(10, ReforgeAltar)
if (altar) then
return true
end
enchantReRoll_CloseMenu(AIO.Msg(), player):Send(player)
return false
end
local function PlayerIsFar(event, go, diff)
for k,player in pairs(go:GetPlayersInRange(60)) do
GameobjectCheck(player)
end
end
RegisterGameObjectEvent(ReforgeAltar, 1, PlayerIsFar)
--gossip part
function EnchantItemCheck(player,item)
if not(GameobjectCheck(player)) then
return false
end
if (item:GetClass() == 2 or item:GetClass() == 4) then
if (item:GetQuality() >= 3) then
return true
end
end
player:SendBroadcastMessage("This item can't be reforged")
return false
end
function EnchantItemCost(item)
local cost = nil
cost = item:GetItemLevel() * 2285 -- Temporary was 2285
return cost
end
--[[function EnchantItemTier(item, player)
local Tier = 1
local rlevel = item:GetItemLevel()
local ilevel = item:GetRequiredLevel()
if (1 <= rlevel) and (rlevel <=10) then
Tier = 1
elseif (11 <= rlevel) and (rlevel <=20) then
Tier = 2
elseif (21 <= rlevel) and (rlevel <=30) then
Tier = 3
elseif (31 <= rlevel) and (rlevel <=40) then
Tier = 4
elseif (41 <= rlevel) and (rlevel <=50) then
Tier = 5
elseif (51 <= rlevel) and (rlevel <=59) then
Tier = 6
elseif (rlevel == 60) and ( (ilevel >= 50) and (ilevel <= 55) ) then
Tier = 7
elseif (rlevel == 60) and ( (ilevel >= 56) and (ilevel <= 63) ) then
Tier = 8
elseif (rlevel == 60) and ( (ilevel >= 64) and (ilevel <= 71) ) then
Tier = 9
elseif (rlevel == 60) and ( (ilevel >= 72) and (ilevel <= 78) ) then
Tier = 10
elseif (rlevel == 60) and ( (ilevel >= 79) and (ilevel <= 83) ) then
Tier = 11
elseif (rlevel == 60) and (ilevel >= 84) then
Tier = 12
end
return Tier
end]]--
--MAIN SET ITEM FUNCTION
function MyHandlers.SetItem(player,bag,slot)
--AIO ADDITIONAL CHECK--
local expectedData = {"number","number"}
local values = {bag,slot}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local item = player:GetItemByPos(bag,slot)
if not(item) then
return false
end
if (EnchantItemCheck(player,item)) then
local itemlink = GetItemLink(item:GetEntry())
local effect = nil
local cost = EnchantItemCost(item)
if (item:GetEnchantmentSpellId(5)) then
effect = item:GetEnchantmentSpellId(5)
else
effect = 964998
end
enchantReRoll_PlaceItem(AIO.Msg(), player,itemlink, effect, cost,bag,slot):Send(player)
end
end
function enchantReRoll_PlaceItem(msg,player,item,effect,cost,bag,slot)
return msg:Add("EnchantReRoll", "EnchantReRoll_PlaceItem", item,effect,cost,bag,slot)
end
--end
--MAIN REFORGE ITEM FUNCTION
function MyHandlers.ReforgeItem_Prep(player,bag,slot)
--AIO ADDITIONAL CHECK--
local expectedData = {"number","number"}
local values = {bag,slot}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local item = player:GetItemByPos(bag,slot)
if not(item) then
return false
end
if (EnchantItemCheck(player,item)) then
local cost = EnchantItemCost(item)
if (cost > player:GetCoinage()) then
player:SendBroadcastMessage("You don't have enough money to do that")
return false
end
player:CastSpell(player, 964998)
end
end
function MyHandlers.ReforgeItem(player,bag,slot)
--AIO ADDITIONAL CHECK--
local expectedData = {"number","number"}
local values = {bag,slot}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local item = player:GetItemByPos(bag,slot)
if not(item) then
return false
end
if (EnchantItemCheck(player,item)) then
local cost = EnchantItemCost(item)
local enchant = nil
--local class = item:GetClass()
--local enchantTier = EnchantItemTier(item, player)
--local neweffect = math.random(1,10)
--local neweffectSQL = nil
--[[if (class == 4) then
class = "ANY"
elseif (class == 2) then
class = "WEAPON"
end]]--
if (cost > player:GetCoinage()) then
player:SendBroadcastMessage("You don't have enough money to do that")
return false
else
player:SetCoinage(player:GetCoinage() - cost)
end
--[[local enchantTierSQL = WorldDBQuery("SELECT tier FROM item_enchantment_random_tiers WHERE enchantID = "..effect..";")
if not(enchantTierSQL) then
player:SendBroadcastMessage("Reforge Failed")
return false
else
enchantTier = enchantTierSQL:GetInt32(0)
end]]--
--[[if (class == "ANY") then
neweffectSQL = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier = "..enchantTier.." AND class = '"..class.."';")
else
neweffectSQL = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier = "..enchantTier..";")
end]]--
--choosing random row from our query
enchant = RollEnchant(item, player)
if (enchant) then
--[[if (neweffectSQL:GetRowCount()>1) then
for i = 1, math.random(1, (neweffectSQL:GetRowCount()-1)) do
neweffectSQL:NextRow()
end
end]]--
--neweffect = neweffectSQL:GetInt32(0)
item:SetEnchantment(enchant, 5) -- ATTEMPT TO FIND A REASON OF CRASHES
enchantReRoll_Reforge(AIO.Msg(),player,item):Send(player)
else
player:SendBroadcastMessage("Reforge Failed")
end
end
end
function enchantReRoll_Reforge(msg,player,item)
local neweffect = nil
if (item:GetEnchantmentSpellId(5)) then
neweffect = item:GetEnchantmentSpellId(5)
else
neweffect = 964998
end
return msg:Add("EnchantReRoll", "EnchantReRollMain_Reforge", neweffect)
end

102
Ironman.lua Normal file
View File

@@ -0,0 +1,102 @@
local function stayDead(event, player)
if(player:GetQuestStatus(68934) == 6 or player:GetQuestStatus(689340) == 6) then
player:AddAura(8326, player)
player:SetHealth(0)
player:KillPlayer()
end
end
local function stayDeadLogin(event, player, msg, Type, lang)
if((player:GetQuestStatus(68934) == 6 or player:GetQuestStatus(689340) == 6) and player:HasAura(8326) == true) then
player:SetHealth(0)
player:KillPlayer()
player:CastSpell(player, 50768)
end
end
local function removeMeFromGroup(event, delay, pCall, player)
player:RemoveFromGroup()
end
local function CheckSurvivalistGroup(player)
local survivalistGroup = false
if (player:IsInGroup()) then
local group = player:GetGroup()
local t_GroupMembers = group:GetMembers()
for i, groupMember in ipairs(t_GroupMembers) do
if (groupMember:GetQuestStatus(689340) == 6) then
survivalistGroup = true
break
end
end
return survivalistGroup
else
return false
end
end
local function GroupingLogic(event, group, guid)
local newPlayer = GetPlayerByGUID(guid)
local t_GroupMembers = group:GetMembers()
if (newPlayer:GetQuestStatus(68934) == 6) then
newPlayer:RegisterEvent(removeMeFromGroup, 75, 1, newPlayer)
for i, groupMember in ipairs(t_GroupMembers) do
if (groupMember:GetQuestStatus(68934) == 6) then
groupMember:RegisterEvent(removeMeFromGroup, 50, 1, groupMember)
end
groupMember:SendBroadcastMessage("|cffff0000Ironmen can't join groups!|r")
end
else
local survivalistGroup = CheckSurvivalistGroup(newPlayer)
if (survivalistGroup) then
for i, groupMember in ipairs(t_GroupMembers) do
if (groupMember:GetQuestStatus(689340) ~= 6) then
groupMember:RegisterEvent(removeMeFromGroup, 50, 1, groupMember)
end
groupMember:SendBroadcastMessage("|cffff0000Survivalists can only join other Survivalists!|r")
end
end
end
end
local function FailIronmanQuest(event, delay, pCall, player)
player:SendBroadcastMessage("|cffff0000You have lost the ability to become an Ironman!|r")
player:SetQuestStatus(68934, 5)
player:FailQuest(68934)
end
local function FailSurvivalistQuest(event, delay, pCall, player)
player:SendBroadcastMessage("|cffff0000You have lost the ability to become a Survivalist!|r")
player:SetQuestStatus(689340, 5)
player:FailQuest(689340)
end
local function IronmanCannotCarryQuestForward(event, player, oldLevel)
if (player:HasQuest(68934) and (player:GetQuestStatus(68934) == 1 or player:GetQuestStatus(68934) == 3)) then
player:RegisterEvent(FailIronmanQuest, 1000, 1, player)
end
if (player:HasQuest(689340) and (player:GetQuestStatus(689340) == 1 or player:GetQuestStatus(689340) == 3)) then
PrintError("Fail quest")
player:RegisterEvent(FailSurvivalistQuest, 1000, 1, player)
end
if (((player:HasQuest(68934) and player:GetQuestStatus(68934) == 6) or (player:HasAura(8326) == true)) and player:IsInGroup()) then
player:RegisterEvent(removeMeFromGroup, 50, 1, player)
end
if (((player:HasQuest(689340) and player:GetQuestStatus(689340) == 6)) and player:IsInGroup()) then
local survivalistGroup = CheckSurvivalistGroup(player)
PrintError("Survivalist = "..survivalistGroup)
if (survivalistGroup) then
player:RegisterEvent(removeMeFromGroup, 50, 1, player)
end
end
end
RegisterPlayerEvent(36, stayDead)
RegisterPlayerEvent(3, stayDeadLogin)
RegisterGroupEvent(1, GroupingLogic)
RegisterPlayerEvent(13, IronmanCannotCarryQuestForward)

33
Misc/DailyEvents.lua Normal file
View File

@@ -0,0 +1,33 @@
local function DailyGloryFlush(event, player)
local Stime2 = tostring(GetGameTime())
-- readies for next timer
WorldDBQuery("DELETE FROM timestamps WHERE state = 1")
WorldDBQuery("INSERT INTO timestamps VALUES ( 1, " ..Stime2.. ");")
player:UnbindInstance(409)
end
local function ResetCheck(event, player)
-- the time, in seconds
-- use integers that divide evenly into the "save players interval" value in world.conf for best results
local Stime = GetGameTime()
local timerdaily = 86400
local GUpdate1 = WorldDBQuery("SELECT * FROM timestamps WHERE state = 1")
if (player == nil) then
print("[Eluna]: Error pushing timestamps on reset. No players are online. See: DailyEvents.lua.")
return false
elseif (GUpdate1 == nil) then
if (player:IsGM() == true) then
-- sends an error message to GMs and server if there is no flush time in the DB
player:SendBroadcastMessage("The daily timer system has broken! Contact an administrator ASAP!")
print("[Eluna]: Error loading LUA script: DailyEvents.lua - There is a nil value in the database `timestamps`. Check entries!")
return false
end
return false
elseif (Stime >= GUpdate1:GetInt32(1) + timerdaily) then
DailyGloryFlush(event, player)
else
return false
end
end
RegisterPlayerEvent(25, ResetCheck)

13
Misc/DuelEnd.lua Normal file
View File

@@ -0,0 +1,13 @@
--function Player:Safety()
-- local shield = 67251
-- Self:AddAura(shield)
--end
--function OnDuelEnd(event, winner, loser, type)
--winner:SendBroadcastMessage("Test 1")
--loser:SendBroadcastMessage("Test 2")
--winner:CastSpell(winner, 67251)
--loser:CastSpell(loser, 67251)
--end
--RegisterPlayerEvent(11, OnDuelEnd)

136
Misc/Flight.lua Normal file
View File

@@ -0,0 +1,136 @@
-- Name: Custom Flight Master Script for cMangos.
-- Details: With option to require gold or custom item as price for taxi service & configurable conditions.
-- Easy to configure. Copy a the Flight[#] {} and enter the correct config for each flight path
-- You can add Player conditions to your flight paths. See for reference: http://eluna.emudevs.com/Player/index.html
-- Website: https://github.com/RStijn
-- Config
local NPC_FLIGHTMASTER = 5000220 -- Creature ID. CreatureType must be 3 & NpcFlags 512 or higher.
local MOUNT_DISPLAYID_A = 28135 -- Display ID of flying mount for Alliance
local MOUNT_DISPLAYID_H = 28135 -- Display ID of flying mount for Horde
-- To leave costs or tokens out, remove them from the list or set them as nil
local FLIGHT = {
-- Basic flight path
{
label = "Take me up that mountain.", -- NPC Gossip Menu Text
cost = 2500, -- Cost for taxi services 10000 = 1 Gold default: 0
token = 500000, -- Custom item ID as cost price default: 0
token_count = 50, -- Amount of custom item to take default: 0
waypoints = {
{
path = {
{0, -13838, 3098, 5}, -- WAYPOINT 1
{0, -13947, 3106, 180}, -- WAYPOINT 2
{0, -14099, 3111, 188},
},
},
},
},
-- Flight path with conditions
{
-- condition predicate function list that return true if the player can see this option
conditions = {
function(player)
return player:GetLevel() >= 30
end,
},
label = "Take me to Stranglethorn Vale.", -- NPC Gossip Menu Text
cost = 2500, -- Cost for taxi services 10000 = 1 Gold
token = 500000, -- Custom item ID as cost price
token_count = 50, -- Amount of custom item to take
waypoints = {
{
-- condition predicate functions that return true if the player can use this route
conditions = {
Player.IsAlliance,
},
path = {
{0, -13838, 3098, 5},
{0, -13800, 2913, 60}, -- WAYPOINT 1
{0, -11758, 107, 134}, -- WAYPOINT 2
{0, -11614, -41, 12},
},
},
{
-- condition predicate functions that return true if the player can use this route
conditions = {
Player.IsHorde,
},
path = {
{0, -13838, 3098, 5},
{0, -13800, 2913, 60}, -- WAYPOINT 2
{0, -12438, 296, 25}, -- WAYPOINT 2
{0, -12391, 196, 4},
},
},
},
},
}
-- Create flight paths from points and save their IDs to the FLIGHT table at FLIGHT[intid].waypoints[i].path
for k,v in ipairs(FLIGHT) do
if (v.waypoints) then
for k2,v2 in ipairs(v.waypoints) do
if (v2.path) then
v2.path = AddTaxiPath(v2.path, MOUNT_DISPLAYID_A, MOUNT_DISPLAYID_H)
end
end
end
end
-- Functions
local function TestConditions(conds, player)
if (not conds) then
return true
end
if (not player) then
return false
end
for k,v in ipairs(conds) do
if (not v(player)) then
return false
end
end
return true
end
local function startFlight(player, flight)
-- check if player can afford cost
if ((not flight.cost or player:GetCoinage() >= flight.cost) and (not flight.token or player:GetItemCount(flight.token) >= (flight.token_count or 0))) then
if (flight.cost) then
player:ModifyMoney(-flight.cost)
end
if (flight.token) then
player:RemoveItem(flight.token, flight.token_count or 0)
end
for k,v in ipairs(flight.waypoints) do
if (TestConditions(v.conditions, player)) then
player:StartTaxi(v.path)
break -- stop on first valid path
end
end
else
player:SendNotification("You can't afford to take this flight")
end
end
local function On_Gossip(event, player, unit)
for k,v in ipairs(FLIGHT) do
if (TestConditions(v.conditions, player)) then
player:GossipMenuAddItem(0, v.label, 0, k, nil, nil, v.cost)
end
end
player:GossipSendMenu(1, unit)
end
local function On_Select(event, player, unit, sender, intid, code)
startFlight(player, FLIGHT[intid])
player:GossipComplete()
end
RegisterCreatureGossipEvent(NPC_FLIGHTMASTER, 1, On_Gossip)
RegisterCreatureGossipEvent(NPC_FLIGHTMASTER, 2, On_Select)

9
Misc/ForceGuild.lua~ Normal file
View File

@@ -0,0 +1,9 @@
function ForceGuild(event, player)
--print("Test Phase 1 Complete")
if (player:IsInGuild() == false) then
--print("Test Phase 2 Complete")
GetGuildByName("Awakening Beta"):AddMember(player, 4)
end
end
RegisterPlayerEvent(30, ForceGuild)

View File

@@ -0,0 +1,23 @@
-- Radius 10x10
local stealth = {1784, 58984, 66}
local frost = 122
local function OnNova(event, player, spell, skipCheck)
if (spell:GetEntry() == frost) then
local target = player:GetPlayersInRange(10, 1)
--print("test 1")
for _, t in pairs(target) do
for k, v in pairs(stealth) do
if(t:HasAura(v)) then
--print("test 2")
t:RemoveAura(v)
--t:AddAura(122)
--print("test 3")
end
end
end
end
end
RegisterPlayerEvent(5, OnNova)

106
Misc/GlorySystem.lua Normal file
View File

@@ -0,0 +1,106 @@
-- How it works:
-- Each week it should run a check that will remove 5% of player's glory
-- For each kill player gets 50 glory
-- Each 30 secs time event for player checks if player has enough glory for title
-- if yes, it learns title to a player, otherwise it ulearns a title
-- Titles goes according to array Asc_Glory_Titles = {titleid, cost, hordetitleid}
-- Glory goes according to colum in character DB
-- Check goes according to table in character DB
--[[local Asc_Glory_Titles = {
[1] = {1, 1500, 15},
[2] = {2, 2500, 16},
[3] = {3, 5000, 17},
[4] = {4, 7500, 18},
[5] = {5, 10000, 19},
[6] = {6, 15000, 20},
[7] = {7, 20000, 21},
[8] = {8, 22500, 22},
[9] = {9, 25000, 23},
[10] = {10, 30000, 24},
[11] = {11, 32500, 25},
[12] = {12, 35000, 26},
[13] = {13, 40000, 27},
[14] = {14, 50000, 28},
[15] = {230, 51000, 229},
}
local Asc_Reduce_Amount = 5
local Asc_Kill_Reward = 50
local Asc_Time_ToCheck = 0
local function Asc_Glory_SQL(glory, guid)
local glorySQL = CharDBQuery("SELECT gloryPoints FROM characters WHERE guid = "..guid..";")
if not(glorySQL) then
CharDBQuery("UPDATE characters SET gloryPoints = "..glory.." WHERE guid = "..guid..";")
else
local glory = glorySQL:GetInt32(0)+glory
CharDBQuery("UPDATE characters SET gloryPoints = "..glory.." WHERE guid = "..guid..";")
end
end
function Asc_Glory_Check(eventId, delay, repeats, player) -- function registered in Sanctuaryfix.lua
local enoughGlory = false
local pGUID = player:GetGUIDLow()
local glorySQL = CharDBQuery("SELECT gloryPoints FROM characters WHERE guid = "..pGUID..";")
if not(glorySQL) then
return false
end
local glory = glorySQL:GetInt32(0)
for k,titles in pairs(Asc_Glory_Titles) do
local Title = nil
if (glory >= titles[2]) then -- check for enough glory
enoughGlory = true
else
enoughGlory = false
end
if player:IsAlliance() then --set correct title entry
Title = titles[1]
else
Title = titles[3]
end
if (player:HasTitle(Title)) then -- main check to learn/unlearn title
if not(enoughGlory) then
player:UnsetKnownTitle(Title)
end
else
if (enoughGlory) then
player:SetKnownTitle(Title)
end
end
end
--player:SendBroadcastMessage("DEBUG Glory = "..glory)
end
local function Asc_Glory_HonorKill(event, killer, killed)
local kLevel = killer:GetLevel()
local vLevel = killed:GetLevel()
local kGUID = killer:GetGUIDLow()
local isHonoredKill_glorycount = -Asc_Kill_Reward
if kLevel <= (vLevel+5) then
isHonoredKill_glorycount = Asc_Kill_Reward
end
Asc_Glory_SQL(isHonoredKill_glorycount, kGUID)
end
RegisterPlayerEvent(6, Asc_Glory_HonorKill)
local function Asc_Glory_BG(event, bg, bgId, instanceId, winner)
print(winner)
end
RegisterBGEvent(2, Asc_Glory_BG)]]--

8
Misc/LevelBroadcast.lua Normal file
View File

@@ -0,0 +1,8 @@
local function OnLevel(event, player, oldLevel)
if (player:GetLevel() == 10) then
player:SendBroadcastMessage("You can now pick your first talents!")
elseif (player:GetLevel() == 2) then
player:SendBroadcastMessage("You can now pick your first ability in the Character Advancement page.")
end
end
RegisterPlayerEvent(13, OnLevel)

10
Misc/NewAuras.lua Normal file
View File

@@ -0,0 +1,10 @@
local function NewAuras1(event, player)
player:AddAura(974994, player)
player:AddAura(974995, player)
player:AddAura(974996, player)
player:AddAura(974997, player)
player:AddAura(974998, player)
player:AddAura(974999, player)
end
RegisterPlayerEvent( 3, NewAuras1 )

View File

@@ -0,0 +1,15 @@
local stealth = {1784, 58984, 66}
local starfall = {48505, 53199, 53200, 53201, 75}
local function OnStealth(event, player, spell, skipCheck)
for _, t in pairs(stealth) do
for k, v in pairs(starfall) do
if (player:HasAura(t) and player:HasAura(v)) then
--print("Test 1")
player:RemoveAura(v)
--print("test 2")
end
end
end
end
RegisterPlayerEvent(5, OnStealth)

11
Misc/OrcFix.lua Normal file
View File

@@ -0,0 +1,11 @@
--TEMP USED THIS ONE FOR FIXING SEABISCUIT LEARN SPELL--
RegisterPlayerEvent(28, function(event,player)
if (player:HasSpell(966004)) then
player:LearnSpell(966002)
player:RemoveSpell(966004)
end
if not(player:HasSpell(500000)) then -- Father asked me to make this always learned
player:LearnSpell(500000)
end
end)

11
Misc/Poisons.lua Normal file
View File

@@ -0,0 +1,11 @@
local function PoisonMaxSkill(event, player)
local x = player:GetSkillValue(40)
local level = player:GetLevel()
local mult = (level * 5)
if player:HasSpell(2842) then
player:SetSkill(40, 0, x, mult)
end
end
RegisterPlayerEvent( 3, PoisonMaxSkill)
RegisterPlayerEvent( 13, PoisonMaxSkill)

View File

@@ -0,0 +1,8 @@
local sprint = 818012
local function OnMapChange(event, player)
if player:HasAura(sprint) then
player:RemoveAura(sprint)
end
end
RegisterPlayerEvent(28, OnMapChange)

28
Misc/Scholo.lua~ Normal file
View File

@@ -0,0 +1,28 @@
local function SpookyItUp(eventId, delay, repeats, player)
player:GetCreaturesInRange(100, 10475, 0, 0)
for x=1,#mobs,1 do
local x = mobs[x]:GetX()
local y = mobs[x]:GetY()
local z = mobs[x]:GetZ()
local o = mobs[x]:GetO()
if mobs[x]:IsDead() == false then
mobs[x]:Kill(mobs[x])
end
mobs[x]:SpawnCreature(11547, x, y, z, o, 6, 60000)
end
end
local function Spooky(event, player, item, target)
local dummy = player:GetNearestCreature(100, 750018, 0, 0)
local cx = dummy:GetX()
local cy = dummy:GetY()
local cz = dummy:GetZ()
local co = dummy:GetO()
player:SummonGameObject(177304, cx, cy, cz, co)
local gambit = player:GetNearestGameobject(10, 177304)
gambit:RemoveFromWorld(true)
player:RegisterEvent(14000, SpookyItUp, 1)
player:SendBroadcastMessage("gambit removed: " ..gambit.. ".")
end
RegisterItemEvent(17191, 2, Spooky)

View File

@@ -0,0 +1,9 @@
local Gift_Text = "Your feats in Azeroth will never be forgotten. We hope that this humble reward will help you along your way!"
local Gift_Subject = "To the Great Hero of Azeroth!"
local function ScrollGift(event, player, oldLevel)
if ((oldLevel+1)%10 == 0) then
SendMail( Gift_Subject, Gift_Text, player:GetGUIDLow(), 0, 61, 0, 0, 0, 1101243, 1)
end
end
RegisterPlayerEvent(13, ScrollGift)

35
Misc/SpiritHealer.lua~ Normal file
View File

@@ -0,0 +1,35 @@
local function SpiritHello(event, player, creature)
player:GossipClearMenu()
creature:ClearCreatureGossipEvents(6491)
player:GossipMenuAddItem(0, "Pepsi", 83, 1)
player:GossipMenuAddItem(0, "Coke", 83, 7)
player:GossipSendMenu(83, creature, MenuId)
end
local function SpiritSelect(event, player, creature, sender, intid, code)
-- teleport based on gossip option
player:SendBroadcastMessage("The intid is " ..intid.. ".")
if (intid == 1) then
local RQuery1 = WorldDBQuery("SELECT race, map, x, y, z, o FROM player_resurrect_locations WHERE race = " ..player:GetRace().. ";")
if (RQuery1:GetInt32(0) ~= nil) then
-- add rez sickness, destroy items equipped, resurrect player
player:Teleport(RQuery1:GetInt32(1), RQuery1:GetInt32(2), RQuery1:GetInt32(3), RQuery1:GetInt32(4), RQuery1:GetInt32(5))
player:ResurrectPlayer(50, true)
player:DurabilityLossAll(100, false)
player:AddAura(15007, player)
else
player:SendBroadcastMessage("An error has occurred within script:SpiritHealer.lua. Please report this to an administrator.")
end
elseif (intid == 7) then
player:ResurrectPlayer(25, true)
player:AddAura(15007, player)
player:DurabilityLossAll(25, true)
else
player:ResurrectPlayer(25, true)
player:AddAura(15007, player)
player:DurabilityLossAll(25, true)
end
end
RegisterCreatureGossipEvent(6491, 1, SpiritHello)
RegisterCreatureGossipEvent(6491, 2, SpiritSelect)

41
Misc/TMLock.lua Normal file
View File

@@ -0,0 +1,41 @@
local function TMLock1(event, player) -- prevent using spells by gms rank 2
if (player:GetGMRank() < 2) or (player:GetGMRank() > 3) then
return false
else
--player:AddAura(6462, player)
--player:AddAura(42201, player)
player:SetFlag(150,0x00800000)
end
end
local function TMLock2(event, player, newZone, newArea) -- Teleport rank2 gms to gmisland
if (player:GetGMRank() ~= 2) then
return false
elseif (player:GetZoneId() == 876) then
return false
else
player:Teleport(1, 16225.9, 16255, 13.0438, 4.35969)
end
end
local function TMLock3(eventId, delay, repeats, player)
--player:AddAura(6462, player)
--player:AddAura(42201, player)
--player:SetFlag(150,0x00800000)
if (player:IsGMVisible()) then
player:SetGMVisible(false)
player:AddAura(37800, player)
end
end
RegisterPlayerEvent(27, TMLock2) -- zonechange event
RegisterPlayerEvent(3, TMLock1) -- onlogin event
local function TimingChecks_GM(event,player) -- rank 3 .gm vis off all the time
if (player:GetGMRank() ~= 3) then
return false
end
player:RegisterEvent(TMLock3, 2000, 0)
end
RegisterPlayerEvent(28, TimingChecks_GM)
--RegisterPlayerEvent(3, TimingChecks_GM)

19
Misc/TeleportRevive.lua~ Normal file
View File

@@ -0,0 +1,19 @@
local function Teleport(event, player)
-- on revive, teleport
local RQuery1 = WorldDBQuery("SELECT race, map, x, y, z, o FROM player_resurrect_locations WHERE race = " ..player:GetRace().. ";")
if (RQuery1:GetInt32(0) ~= nil) then
player:Teleport(RQuery1:GetInt32(1), RQuery1:GetInt32(2), RQuery1:GetInt32(3), RQuery1:GetInt32(4), RQuery1:GetInt32(5))
else
player:SendBroadcastMessage("An error has occurred within script:Revive.lua. Please report this to an administrator.")
end
end
local function Rez(event, killer, killed)
-- check to see if player is in BG, Arena, or instance. If no, revive.
if (killed:InBattleground() == false) and (killed:InArena() == false) and (killed:GetInstanceId() == 0) then
killed:ResurrectPlayer(50, false)
end
end
RegisterPlayerEvent(36, Teleport)
RegisterPlayerEvent(8, Rez)

35
Misc/TestReturn.lua Normal file
View File

@@ -0,0 +1,35 @@
local aura = 818052 -- put Test Aura ID here
local function TestReturn(event, player, newZone, NewArea)
if (newZone ~= 3817 and NewArea ~= 3817) then -- Test ZoneID and AreaID
if player:HasAura(aura) then
player:Teleport(13, -5.723160, -6.920650, -144.709000, 3.462120) -- Test Zone Coords
end
end
end
RegisterPlayerEvent(27, TestReturn)
local testnpc = 212341
function On_Gossip(event, player, unit)
player:GossipMenuAddItem(0, "Add Test Aura", 0, 1)
player:GossipMenuAddItem(0, "Remove Test Aura", 0, 2)
player:GossipSendMenu(1, unit)
end
function On_Select(event, player, unit, sender, intid, code)
if (intid == 1) then
player:AddAura(818052, player)
player:GossipComplete()
unit:SendUnitSay(""..player:GetName().." now has the Test aura and is now locked to this map.", 7)
--player:SendBroadcastMessage("You now have a Test Aura, you will not be allowed anywhere else until removed.")
else
player:RemoveAura(818052, player)
player:GossipComplete()
unit:SendUnitSay(""..player:GetName().." has removed the Test aura and is free to return to Azeroth.", 7)
--player:SendBroadcastMessage("Your Test aura has been removed, you're welcome to go back to Azeroth")
end
player:GossipComplete()
end
RegisterCreatureGossipEvent(testnpc, 1, On_Gossip)
RegisterCreatureGossipEvent(testnpc, 2, On_Select)

37
Misc/Unlearn.lua Normal file
View File

@@ -0,0 +1,37 @@
local function UnlearnHello(event, player, creature)
player:GossipMenuAddItem(0, "Alchemy", 900017, 1, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Blacksmithing", 900017, 2, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Enchanting", 900017, 3, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Engineering", 900017, 4, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Herbalism", 900017, 5, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Leatherworking", 900017, 6, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Mining", 900017, 7, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Skinning", 900017, 8, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Tailoring", 900017, 9, false, "Are you sure you want to unlearn this profession?")
player:GossipMenuAddItem(0, "Nevermind", 900017, 0)
player:GossipSendMenu(900017, creature, MenuId)
end
local function UnlearnSelect(event, player, creature, sender, intid, code)
if (intid > 0) then
local UnQuery1 = WorldDBQuery("SELECT intid, spell FROM gossip_options_lua WHERE intid = " ..intid.. ";")
local spellid = UnQuery1:GetInt32(1)
player:GossipComplete()
if (UnQuery1 ~= nil) then
if (player:HasSpell(spellid) == true) then
player:RemoveSpell(spellid)
else
player:SendBroadcastMessage("You do not know that profession!")
end
else
player:SendBroadcastMessage("Sorry, but the action you are trying to perform cannot be finished. Please report this to an administrator.")
end
else
player:GossipComplete()
end
end
RegisterCreatureGossipEvent(9999999, 1, UnlearnHello)
RegisterCreatureGossipEvent(9999999, 2, UnlearnSelect)
RegisterCreatureGossipEvent(9999998, 1, UnlearnHello)
RegisterCreatureGossipEvent(9999998, 2, UnlearnSelect)

38
Misc/XPLock.lua~ Normal file
View File

@@ -0,0 +1,38 @@
local function Lock(event, player, oldLevel)
-- on level up, does loop to check if quest has been completed by level (represented as y). if yes, halt code. if not, continue to add aura.
local questID = {
-- {req. level, questid}
{10, 899},
{20, 4921},
}
for y=1,#questID,1 do
if (player:GetQuestStatus(questID[y][2]) == 6) and (player:GetLevel() == questID[y][1]) then
return true
elseif (player:GetLevel() == questID[y][1]) then
player:AddAura(818057, player)
return false
end
end
end
RegisterPlayerEvent(13, Lock)
local function TimedCheck(event, player)
-- a timer based on the player save interval that will remove the aura if character has completed quests in loop
if (player:HasAura(818057) == false) then
return false
end
local questID = {
-- {req. level, questid}
{10, 899},
{20, 4921},
}
for y=1,#questID,1 do
if (player:GetQuestStatus(questID[y][2]) == 6) and (player:GetLevel() == questID[y][1]) then
player:RemoveAura(818057)
return true
end
end
end
RegisterPlayerEvent(25, TimedCheck)

View File

@@ -0,0 +1,7 @@
local function Scroll(event, player, item, target)
player:SetKnownTitle(257)
player:SendNotification("|cffFF6600 Thanks for the Support! |r")
player:CastSpell(player, 55420, false)
end
RegisterItemEvent(977121, 2, Scroll)

View File

@@ -0,0 +1,7 @@
local function Scroll(event, player, item, target)
player:SetKnownTitle(210)
player:SendNotification("|cffFF6600 Thanks for becoming a founder! |r")
player:CastSpell(player, 55420, false)
end
RegisterItemEvent(977020, 2, Scroll)

8
Misc/items/MaraStaff.lua Normal file
View File

@@ -0,0 +1,8 @@
local function MaraStaff(event, player, item, target)
local goober = player:GetNearestGameObject( 0.1, 178386)
if (goober ~= nil) then
player:CastSpell(player, 21127, true)
end
end
RegisterItemEvent(17191, 2, MaraStaff)

View File

@@ -0,0 +1,7 @@
local function Scroll(event, player, item, target)
player:SetKnownTitle(258)
player:SendNotification("|cffFF6600 Thanks for the Support! |r")
player:CastSpell(player, 55420, false)
end
RegisterItemEvent(977120, 2, Scroll)

View File

@@ -0,0 +1,17 @@
local function TaxiCheatScroll(event, player, item, target)
player:SetTaxiCheat(true)
player:SendNotification("|cffFF6600 You're now free to choose any flight path you want! |r")
player:CastSpell(player, 51908, false)
--player:RemoveAura(70571)
if not(CharDBQuery("SELECT guid FROM custom_taxicheat WHERE guid = "..player:GetGUIDLow()..";")) then
CharDBExecute("INSERT INTO custom_taxicheat VALUES ("..player:GetGUIDLow()..");")
end
end
RegisterItemEvent(977025, 2, TaxiCheatScroll)
RegisterPlayerEvent(3, function(event,player)
if CharDBQuery("SELECT guid FROM custom_taxicheat WHERE guid = "..player:GetGUIDLow()..";") then
player:SetTaxiCheat(true)
end
end)

11
Misc/items/ZFGong.lua Normal file
View File

@@ -0,0 +1,11 @@
local function ZFGong(event, player, item, target)
local goober = player:GetNearestGameObject( 5, 141832)
if (goober == nil) then
return false;
else
player:SpawnCreature(7273, 1665.56, 1187.32, 11.64, 3.9, 7)
end
end
RegisterItemEvent(9240, 2, ZFGong)

8
Misc/quests/Mankrik.lua Normal file
View File

@@ -0,0 +1,8 @@
local function DeadBeatWife(event, player, creature)
player:GossipSendMenu(9999997, creature, MenuId)
if player:HasQuest(4921) then
player:CompleteQuest(4921)
end
end
RegisterCreatureGossipEvent(9999997, 1, DeadBeatWife)

View File

@@ -0,0 +1,7 @@
local function DivineDebuff(event, player, spell, skipCheck)
if (spell:GetEntry() >= 1856) and (spell:GetEntry() <= 1857) then
player:RemoveAura(642)
end
end
RegisterPlayerEvent(5, DivineDebuff)

12
Misc/spells/NoSummon.lua Normal file
View File

@@ -0,0 +1,12 @@
local function NoSummon(event, player, spell, skipCheck)
if (player:GetInstanceId() == 0) then
return false
elseif (spell:GetEntry() ~= 698) then
return false
else
spell:Cancel()
end
end
RegisterPlayerEvent(5, NoSummon)

13
PvP/CityPvP.lua Normal file
View File

@@ -0,0 +1,13 @@
local cityDictionary = {[1637] = true, [1638] = true, [1497] = true, [3487] = true, [1519] = true, [1537] = true, [1657] = true, [3557] = true }
local function killedPlayer(event, killer, killed)
if (killer == killed) then
return false
end
thisArea = killer:GetAreaId()
if (cityDictionary[thisArea] == true) then
killer:AddItem(880000, 1)
end
end
RegisterPlayerEvent(6, killedPlayer)

2557
PvP/Guildwars.lua.disable Normal file

File diff suppressed because it is too large Load Diff

83
PvP/PvPExp2.lua Normal file
View File

@@ -0,0 +1,83 @@
--[[
ToDO:
1. Reduce decimal places on timer
]]--
local function KillReset(event, delay, repeats, pKiller)
CharDBExecute("DELETE FROM character_kill_count WHERE killerguid = "..killerguid.." AND victimguid = "..victimguid)
end
local function PvPExp(event, pKiller, pKilled)
--EXP Formula
local exp1 = pKiller:GetLevel()
local exp2 = pKilled:GetLevel()
local mod = exp1 - exp2
local ExpBase = (exp2 * 5 + 45) * (1 + 0.05 * mod) * PvPExpRate
--Kill Table stuff
local killerguid = pKiller:GetGUIDLow()
local victimguid = pKilled:GetGUIDLow()
local check = CharDBQuery("SELECT victimguid FROM character_kill_count WHERE killerguid = "..killerguid)
local cap = 5 -- set cap
if(pKiller ~= pKilled) then
if(check == nil) then -- if player has not killed anyone yet:
print("Player has no kill data")
CharDBExecute("INSERT INTO character_kill_count(killerguid, victimguid, count) VALUES("..killerguid..","..victimguid..",1)")
if (exp2 >= exp1 - 10 and exp2 <= exp1 + 10) then
-- check for group and if group above max party count (so raid)
local group = pKiller:GetGroup()
if (group ~= nil) then
local groupmem = group:GetMembersCount()
if (groupmem <= 5) then
local partymember = group:GetMembers()
for x=1,#partymember,1 do
partymember[x]:GiveXP(ExpBase / groupmem)
end
end
else
pKiller:GiveXP(ExpBase)
end
end
else
local kills = CharDBQuery("SELECT count FROM character_kill_count WHERE killerguid = "..killerguid.." AND victimguid = "..victimguid):GetInt32(0)
local AddKill = kills + 1
if(pKiller:GetMap():GetMapId() == 0 or pKiller:GetMap():GetMapId() == 1) then
if (kills < cap) then
if (exp2 >= exp1 - 10 and exp2 <= exp1 + 10) then
-- check for group and if group above max party count (so raid)
local group = pKiller:GetGroup()
if (group ~= nil) then
local groupmem = group:GetMembersCount()
if (groupmem <= 5) then
local partymember = group:GetMembers()
for x=1,#partymember,1 do
partymember[x]:GiveXP(ExpBase / groupmem)
end
end
else
pKiller:GiveXP(ExpBase)
CharDBQuery("UPDATE character_kill_count SET count = "..AddKill.." WHERE killerguid = "..killerguid.." AND victimguid = "..victimguid)
end
end
elseif (kills >= cap) then
CharDBQuery("UPDATE character_kill_count SET count = "..AddKill.." WHERE killerguid = "..killerguid.." AND victimguid = "..victimguid)
if(pKiller:GetLuaCooldown() == 0) then -- Check if cooldown is present
pKiller:SetLuaCooldown(86400) -- Set cooldown in seconds for kills. Default: 24hrs = 86400
local timer = math.floor( pKiller:GetLuaCooldown() / 3600 )
pKiller:SendBroadcastMessage("You have killed this player to many times and will no longer receive exp from this player for "..timer.." hours.")
pKiller:RegisterEvent(KillReset, 86400000, 1)
else
local timer = math.floor( pKiller:GetLuaCooldown() / 3600 )
pKiller:SendBroadcastMessage("You have killed this player to many times and will no longer receive exp from this player for "..timer.." hours.")
end
end
end
end
end
end
RegisterPlayerEvent(6, PvPExp)

10
README.md Normal file
View File

@@ -0,0 +1,10 @@
Awakening
========
All of the eluna server code is in this repo!
***Added - Contents***
This is the entirety of the LUA scripts used on the World of Warcraft private server, Ascension. The term Awakening is the predecessor of Ascension. The last date of this repository is June 4th, 2017.
None of these commits were edited.
Ascension is currently using Eluna, and AIO, two products which are listed under the GPL 2.0 License, also known as the GENERAL PUBLIC USE LICENSE, which explicitly restricts Ascension from monetizing or privatizing their content.

View File

@@ -0,0 +1,372 @@
local AIO = AIO or require("AIO")
if AIO.AddAddon() then
return
end
local SlotIsuranceClient = AIO.AddHandlers("SlotIsurance", {})
local Slots = {
[1] = {"Head", "SafeSlot1", false},
[2] = {"Neck", "SafeSlot2", false},
[3] = {"Shoulder", "SafeSlot3", false},
[4] = {"Body", "SafeSlot6", false},
[5] = {"Chest", "SafeSlot5", false},
[6] = {"Waist", "SafeSlot10", false},
[7] = {"Legs", "SafeSlot11", false},
[8] = {"Feet", "SafeSlot12", false},
[9] = {"Wrist", "SafeSlot8", false},
[10] = {"Hand", "SafeSlot9", false},
[11] = {"Finger", "SafeSlot13", false},
[12] = {"Finger", "SafeSlot14", false},
[13] = {"Trinket", "SafeSlot15", false},
[14] = {"Trinket", "SafeSlot16", false},
[15] = {"Back", "SafeSlot4", false},
[16] = {"Main Hand", "SafeSlot17", false},
[17] = {"Off Hand", "SafeSlot18", false},
[18] = {"Ranged", "SafeSlot19", false},
[19] = {"Tabard", "SafeSlot7", false},
}
--name, button, is slot currently activated
local InsureCurrency = 98461
local SafeCostModifier = 3540
local function SafeSlotGetLostCost(itemlink)
local cost = nil
local _, _, _, iLevel = GetItemInfo(itemlink)
cost = iLevel * SafeCostModifier
return cost
end
--MAIN FRAME
local SafeSlots_Main = CreateFrame("FRAME", "SafeSlots_Main", UIParent,nil)
SafeSlots_Main:SetSize(512,512)
SafeSlots_Main:SetPoint("CENTER")
SafeSlots_Main:SetMovable(true)
SafeSlots_Main:EnableMouse(true)
SafeSlots_Main:RegisterForDrag("LeftButton")
SafeSlots_Main:SetClampedToScreen(true)
SafeSlots_Main:SetScript("OnDragStart", SafeSlots_Main.StartMoving)
SafeSlots_Main:SetScript("OnDragStop", SafeSlots_Main.StopMovingOrSizing)
SafeSlots_Main:SetFrameStrata("HIGH")
SafeSlots_Main:SetBackdrop({
bgFile = "Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SafeSlots",
--insets = { left = -256, right = -256, top = -5, bottom = -5}
})
local SafeSlots_Main_CloseButton = CreateFrame("Button", "SafeSlots_Main_CloseButton", SafeSlots_Main, "UIPanelCloseButton")
SafeSlots_Main_CloseButton:SetPoint("TOPRIGHT", -82, -45)
SafeSlots_Main_CloseButton:EnableMouse(true)
--SafeSlots_Main_CloseButton:SetSize(29, 29)
SafeSlots_Main_CloseButton:SetScript("OnMouseUp", function()
PlaySound("TalentScreenOpen")
SafeSlots_Main:Hide()
end)
local SafeSlots_Main_TitleText = SafeSlots_Main:CreateFontString("SafeSlots_Main_TitleText")
SafeSlots_Main_TitleText:SetFont("Fonts\\FRIZQT__.TTF", 11)
SafeSlots_Main_TitleText:SetFontObject(GameFontNormal)
SafeSlots_Main_TitleText:SetPoint("TOP", 0, -55)
SafeSlots_Main_TitleText:SetShadowOffset(1,-1)
SafeSlots_Main_TitleText:SetText("Fel Commutation")
SafeSlots_Main:Hide()
--END OF MAIN FRAME
--MAIN FRAME SCRIPTS--
--END OF MAIN FRAME SCRIPTS--
--SLOT BUTTONS--
--loading same settings for all of the slot buttons
for i = 1, 16 do
_G["SafeSlot"..i] = CreateFrame("Button", "SafeSlot"..i, SafeSlots_Main, nil)
_G["SafeSlot"..i]:SetNormalTexture("Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SlotBorder")
_G["SafeSlot"..i]:SetHighlightTexture("Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SlotBorder_H")
_G["SafeSlot"..i]:SetSize(54,54)
end
for i = 17, 19 do
_G["SafeSlot"..i] = CreateFrame("Button", "SafeSlot"..i, SafeSlots_Main, nil)
_G["SafeSlot"..i]:SetNormalTexture("Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SlotBorder")
_G["SafeSlot"..i]:SetHighlightTexture("Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SlotBorder_H")
_G["SafeSlot"..i]:SetSize(60,60)
end
--additional button textures
for i = 1, 19 do
_G["SafeSlot"..i.."_GlowTex"] = _G["SafeSlot"..i]:CreateTexture("SafeSlot"..i.."_GlowTex", "OVERLAY")
_G["SafeSlot"..i.."_GlowTex"]:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SlotBorder_active")
_G["SafeSlot"..i.."_GlowTex"]:SetSize(_G["SafeSlot"..i]:GetSize())
_G["SafeSlot"..i.."_GlowTex"]:SetPoint("CENTER")
_G["SafeSlot"..i.."_GlowTex"]:SetBlendMode("ADD")
_G["SafeSlot"..i.."_GlowTex"]:Hide()
end
--setting up each button properly
SafeSlot1:SetPoint("CENTER", -100, 144)
SafeSlot2:SetPoint("CENTER", -121, 106)
SafeSlot3:SetPoint("CENTER", -134, 64)
SafeSlot4:SetPoint("CENTER", -140, 22)
SafeSlot5:SetPoint("CENTER", -140, -22)
SafeSlot6:SetPoint("CENTER", -134, -64)
SafeSlot7:SetPoint("CENTER", -121, -106)
SafeSlot8:SetPoint("CENTER", -100, -144)
SafeSlot9:SetPoint("CENTER", 103, 144)
SafeSlot10:SetPoint("CENTER", 124, 106)
SafeSlot11:SetPoint("CENTER", 137, 64)
SafeSlot12:SetPoint("CENTER", 143, 22)
SafeSlot13:SetPoint("CENTER", 143, -22)
SafeSlot14:SetPoint("CENTER", 137, -64)
SafeSlot15:SetPoint("CENTER", 124, -106)
SafeSlot16:SetPoint("CENTER", 103, -144)
SafeSlot17:SetPoint("CENTER", -43, -161)
SafeSlot18:SetPoint("CENTER", 3, -161)
SafeSlot19:SetPoint("CENTER", 46, -161)
--END OF SLOT BUTTONS
--SLOT BUTTONS SCRIPTS--
for i = 1, 19 do
_G["SafeSlot"..i]:SetScript("OnClick", function(self) -- main action
if not(SafeSlots_Main_Confirm:IsVisible()) then
SafeSlots_Main_Confirm:Show()
SafeSlots_Main_Confirm_ItemIcon.slot = self.slot
elseif (SafeSlots_Main_Confirm_ItemIcon.slot) and SafeSlots_Main_Confirm_ItemIcon.slot == self.slot then
SafeSlots_Main_Confirm:Hide()
else
SafeSlots_Main_Confirm_ItemIcon.slot = self.slot
end
end)
_G["SafeSlot"..i]:SetScript("OnEnter", function(self) -- default tooltip text
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("|cffFFFFFF"..Slots[self.slot][1])
if not(Slots[self.slot][3]) then
GameTooltip:AddLine("Click on this slot to insure it")
end
GameTooltip:Show()
end)
_G["SafeSlot"..i]:SetScript("OnLeave", function(self) -- onleave script
GameTooltip:Hide()
end)
end
--END OF SLOT BUTTONS SCRIPTS--
--MODEL OF CHARACTER--
local SafeSlots_Main_PlayerModel = CreateFrame("PlayerModel", "SafeSlots_Main_PlayerModel", SafeSlots_Main)
SafeSlots_Main_PlayerModel:SetWidth(192);
SafeSlots_Main_PlayerModel:SetHeight(256);
SafeSlots_Main_PlayerModel:SetPoint("CENTER", 0, -22)
SafeSlots_Main_PlayerModel:SetUnit("player")
SafeSlots_Main_PlayerModel:SetModelScale(1)
SafeSlots_Main_PlayerModel:SetPosition(0.0,0.0,0)
SafeSlots_Main_PlayerModel:SetCamera(1)
--END OF THE MODEL OF CHARACTER--
--MODEL OF CHARACTER SCRIPTS--
SafeSlots_Main_PlayerModel:RegisterEvent("UNIT_MODEL_CHANGED")
SafeSlots_Main_PlayerModel:SetScript("OnEvent", function(self,event,arg)
if arg == "player" then
self:RefreshUnit()
end
end)
--END OF MODEL OF CHARACTER SCRIPTS--
--Confirm Frame--
SafeSlots_Main_Confirm = CreateFrame("FRAME", "SafeSlots_Main_Confirm", SafeSlots_Main,nil)
SafeSlots_Main_Confirm:SetSize(512,512)
SafeSlots_Main_Confirm:SetPoint("CENTER")
SafeSlots_Main_Confirm:SetBackdrop({
bgFile = "Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SafeSlots_Window",
--insets = { left = -256, right = -256, top = -5, bottom = -5}
})
SafeSlots_Main_Confirm:SetFrameStrata("DIALOG")
SafeSlots_Main_Confirm:Hide()
--[[local SafeSlots_Main_Confirm_CloseButton = CreateFrame("Button", "SafeSlots_Main_Confirm_CloseButton", SafeSlots_Main_Confirm, "UIPanelCloseButton")
SafeSlots_Main_Confirm_CloseButton:SetPoint("CENTER", 90, -2)
SafeSlots_Main_Confirm_CloseButton:EnableMouse(true)
SafeSlots_Main_Confirm_CloseButton:SetSize(25, 25)
SafeSlots_Main_Confirm_CloseButton:SetScript("OnMouseUp", function()
PlaySound("TalentScreenOpen")
SafeSlots_Main_Confirm:Hide()
end)]]--
-- version of frame if your slot is activated
local SafeSlots_Main_Confirm_UnInsureButton = CreateFrame("Button", "SafeSlots_Main_Confirm_UnInsureButton", SafeSlots_Main_Confirm, "UIPanelButtonTemplate")
SafeSlots_Main_Confirm_UnInsureButton:SetWidth(120)
SafeSlots_Main_Confirm_UnInsureButton:SetHeight(21)
SafeSlots_Main_Confirm_UnInsureButton:SetPoint("CENTER", 0,-54)
SafeSlots_Main_Confirm_UnInsureButton:RegisterForClicks("AnyUp")
SafeSlots_Main_Confirm_UnInsureButton:SetText("Remove Commutation")
local SafeSlots_Main_Confirm_InsureButton = CreateFrame("Button", "SafeSlots_Main_Confirm_InsureButton", SafeSlots_Main_Confirm, "UIPanelButtonTemplate")
SafeSlots_Main_Confirm_InsureButton:SetWidth(120)
SafeSlots_Main_Confirm_InsureButton:SetHeight(21)
SafeSlots_Main_Confirm_InsureButton:SetPoint("CENTER", 0,-54)
SafeSlots_Main_Confirm_InsureButton:RegisterForClicks("AnyUp")
SafeSlots_Main_Confirm_InsureButton:SetText("Commute slot")
SafeSlots_Main_Confirm_ItemIcon = CreateFrame("Button", "SafeSlots_Main_Confirm_ItemIcon", SafeSlots_Main_Confirm, "SecureActionButtonTemplate")
SafeSlots_Main_Confirm_ItemIcon:SetSize(34, 34)
SafeSlots_Main_Confirm_ItemIcon:SetPoint("CENTER",-80,-23)
SafeSlots_Main_Confirm_ItemIcon:EnableMouse(true)
SafeSlots_Main_Confirm_ItemIcon:SetNormalTexture("Interface\\PaperDoll\\UI-Backpack-EmptySlot")
SafeSlots_Main_Confirm_ItemIcon:SetHighlightTexture("Interface\\BUTTONS\\ButtonHilight-Square")
local SafeSlots_Main_CostText = SafeSlots_Main_Confirm:CreateFontString("SafeSlots_Main_CostText")
SafeSlots_Main_CostText:SetFont("Fonts\\FRIZQT__.TTF", 12)
SafeSlots_Main_CostText:SetFontObject(GameFontNormal)
SafeSlots_Main_CostText:SetPoint("CENTER", 0, -15)
SafeSlots_Main_CostText:SetShadowOffset(1,-1)
--
--END OF CONFIRM FRAME--
--Confirm Frame Scripts--
-- main frame scripts--
SafeSlots_Main_Confirm:SetScript("OnUpdate", function(self)
if (Slots[SafeSlots_Main_Confirm_ItemIcon.slot][3]) then-- player has insured slot
local Link = GetInventoryItemLink("player", SafeSlots_Main_Confirm_ItemIcon.slot)
if (Link) then
local _, _, _, _, _, _, _, _, _, texture = GetItemInfo(Link)
local gold,silver,copper = GetGoldForMoney(SafeSlotGetLostCost(Link))
SafeSlots_Main_Confirm_ItemIcon:SetNormalTexture(texture)
SafeSlots_Main_CostText:SetText("Losing this item\nwill cost you|r\n\n|cffFFFFFF"..gold.."|TInterface\\MONEYFRAME\\UI-GoldIcon.blp:11:11:0:-1|t "..silver.."|TInterface\\MONEYFRAME\\UI-SilverIcon.blp:11:11:0:-1|t "..copper.."|TInterface\\MONEYFRAME\\UI-CopperIcon.blp:11:11:0:-1|t|r")
else
SafeSlots_Main_Confirm_ItemIcon:SetNormalTexture("Interface\\PaperDoll\\UI-Backpack-EmptySlot")
SafeSlots_Main_CostText:SetText("This slot is empty")
end
SafeSlots_Main_Confirm_UnInsureButton:Show()
SafeSlots_Main_Confirm_InsureButton:Hide()
else-- player has not insured slot
SafeSlots_Main_Confirm_ItemIcon:SetNormalTexture("Interface\\icons\\inv_custom_demonstears")
SafeSlots_Main_CostText:SetText("Commutation cost:\n\n|cffa335ee[Demon's Tears]|r |cffFFFFFFx1|r")
SafeSlots_Main_Confirm_UnInsureButton:Hide()
SafeSlots_Main_Confirm_InsureButton:Show()
end
end)
-- main frame scripts--
--item icon scripts--
SafeSlots_Main_Confirm_ItemIcon:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
local itemlink = GetInventoryItemLink("player", self.slot)
if (itemlink and Slots[self.slot][3]) then
GameTooltip:SetHyperlink(GetInventoryItemLink("player", self.slot))
elseif Slots[self.slot][3] then
GameTooltip:AddLine("Slot is empty")
else
end
GameTooltip:Show()
end)
SafeSlots_Main_Confirm_ItemIcon:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
--insure item button script
SafeSlots_Main_Confirm_InsureButton:SetScript("OnUpdate", function(self)
if ( GetItemCount(InsureCurrency) > 0) then
self:Enable()
else
self:Disable()
end
end)
--end
--End Confirm Frame Scripts--
--ANIMATIONS--
SafeSlots_Main_Complete = SafeSlots_Main:CreateTexture(nil, "ARTWORK")
SafeSlots_Main_Complete:SetSize(SafeSlots_Main:GetSize())
SafeSlots_Main_Complete:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SafeSlotsHighlight")
SafeSlots_Main_Complete:SetPoint("CENTER")
SafeSlots_Main_Complete:SetBlendMode("ADD")
SafeSlots_Main_Complete:Hide()
SafeSlots_Main_Complete_Dialog = SafeSlots_Main_Confirm:CreateTexture(nil, "OVERLAY")
SafeSlots_Main_Complete_Dialog:SetSize(SafeSlots_Main:GetSize())
SafeSlots_Main_Complete_Dialog:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\SafeSlots\\SafeSlots_confirmH")
SafeSlots_Main_Complete_Dialog:SetPoint("CENTER")
SafeSlots_Main_Complete_Dialog:SetBlendMode("ADD")
SafeSlots_Main_Complete_Dialog:Hide()
local function SafeSlots_Main_Animgroup_End()
BaseFrameFadeOut(SafeSlots_Main_Complete)
BaseFrameFadeOut(SafeSlots_Main_Complete_Dialog)
AIO.Handle("SlotIsurance", "GetSlotList")
end
SafeSlots_Main_Animgroup = SafeSlots_Main:CreateAnimationGroup()
local SafeSlots_Main_BlankAnim = SafeSlots_Main_Animgroup:CreateAnimation("Scale")
SafeSlots_Main_BlankAnim:SetDuration(0.5)
SafeSlots_Main_BlankAnim:SetOrder(1)
SafeSlots_Main_BlankAnim:SetEndDelay(0)
--SafeSlots_Main_BlankAnim:SetScale(1,1)
SafeSlots_Main_BlankAnim:SetScript("OnFinished", SafeSlots_Main_Animgroup_End)
SafeSlots_Main_BlankAnim:SetScript("OnStop", SafeSlots_Main_Animgroup_End)
SafeSlots_Main_BlankAnim:SetScript("OnPlay", function()
BaseFrameFadeIn(SafeSlots_Main_Complete)
BaseFrameFadeIn(SafeSlots_Main_Complete_Dialog)
end)
local function SafeSlots_Init()
SafeSlots_Main_PlayerModel:SetUnit("player")
SafeSlots_Main_PlayerModel:SetCamera(1) -- model settings
SafeSlots_Main_Confirm:Hide()
for k,v in pairs(Slots) do
if v[3] then
BaseFrameFadeIn(_G[v[2].."_GlowTex"])
else
if (_G[v[2].."_GlowTex"]:IsVisible()) then
BaseFrameFadeOut(_G[v[2].."_GlowTex"])
else
_G[v[2].."_GlowTex"]:Hide()
end
end
_G[v[2]].slot = k -- button settings
end
end
--END OF ANIMATIONS--
--AIO STUFF, SENDING PART--
SafeSlots_Main:SetScript("OnShow", function()
AIO.Handle("SlotIsurance", "GetSlotList")
end)
SafeSlots_Main_Confirm_UnInsureButton:SetScript("OnMouseDown",function(self)
if (SafeSlots_Main_Confirm_ItemIcon.slot) then
SafeSlots_Main_Animgroup:Stop()
SafeSlots_Main_Animgroup:Play()
AIO.Handle("SlotIsurance", "UnInsureSlot", SafeSlots_Main_Confirm_ItemIcon.slot)
end
end)
SafeSlots_Main_Confirm_InsureButton:SetScript("OnMouseDown",function(self)
if ( GetItemCount(InsureCurrency) > 0) then
SafeSlots_Main_Animgroup:Stop()
SafeSlots_Main_Animgroup:Play()
if (SafeSlots_Main_Confirm_ItemIcon.slot) then
AIO.Handle("SlotIsurance", "InsureSlot", SafeSlots_Main_Confirm_ItemIcon.slot)
end
end
end)
--AIO STUFF, GETTING PART--
function SlotIsuranceClient.SafeSlots_GetList(player, slotlist)
Slots = slotlist
SafeSlots_Init()
end
function SlotIsuranceClient.SafeSlots_Close(player)
SafeSlots_Main:Hide()
end
function SlotIsuranceClient.SafeSlots_Init(player)
SafeSlots_Main:Show()
end

View File

@@ -0,0 +1,188 @@
local AIO = AIO or require("AIO")
local SlotIsuranceServer = AIO.AddHandlers("SlotIsurance", {})
--!NOTE: SERVERSIDE SLOTS STARTS FROM 0, NOT FROM 1.
--!SO HEAD AND OTHER SLOTS HAVE SLOTNUMBER-1
--Slot table Structure:
--PLAYERGUID, head, neck, shoulder etc (0 or 1)
local InsureCurrency = 98461
--[[
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for custom_iteminsurance
-- ----------------------------
DROP TABLE IF EXISTS `custom_iteminsurance`;
CREATE TABLE `custom_iteminsurance` (
`playerguid` int(30) NOT NULL DEFAULT '0',
`slot0` int(1) NOT NULL DEFAULT '0',
`slot1` int(1) NOT NULL DEFAULT '0',
`slot2` int(1) NOT NULL DEFAULT '0',
`slot3` int(1) NOT NULL DEFAULT '0',
`slot4` int(1) NOT NULL DEFAULT '0',
`slot5` int(1) NOT NULL DEFAULT '0',
`slot6` int(1) NOT NULL DEFAULT '0',
`slot7` int(1) NOT NULL DEFAULT '0',
`slot8` int(1) NOT NULL DEFAULT '0',
`slot9` int(1) NOT NULL DEFAULT '0',
`slot10` int(1) NOT NULL DEFAULT '0',
`slot11` int(1) NOT NULL DEFAULT '0',
`slot12` int(1) NOT NULL DEFAULT '0',
`slot13` int(1) NOT NULL DEFAULT '0',
`slot14` int(1) NOT NULL DEFAULT '0',
`slot15` int(1) NOT NULL DEFAULT '0',
`slot16` int(1) NOT NULL DEFAULT '0',
`slot17` int(1) NOT NULL DEFAULT '0',
`slot18` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`playerguid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
]]--
function SlotIsuranceServer.GetSlotList(player)
if not(GreedyDemonCheck(player)) then
return false
end
local Slots = { -- Empty ARRAY
[1] = {"Head", "SafeSlot1", false},
[2] = {"Neck", "SafeSlot2", false},
[3] = {"Shoulder", "SafeSlot3", false},
[4] = {"Body", "SafeSlot6", false},
[5] = {"Chest", "SafeSlot5", false},
[6] = {"Waist", "SafeSlot10", false},
[7] = {"Legs", "SafeSlot11", false},
[8] = {"Feet", "SafeSlot12", false},
[9] = {"Wrist", "SafeSlot8", false},
[10] = {"Hand", "SafeSlot9", false},
[11] = {"Finger", "SafeSlot13", false},
[12] = {"Finger", "SafeSlot14", false},
[13] = {"Trinket", "SafeSlot15", false},
[14] = {"Trinket", "SafeSlot16", false},
[15] = {"Back", "SafeSlot4", false},
[16] = {"Main Hand", "SafeSlot17", false},
[17] = {"Off Hand", "SafeSlot18", false},
[18] = {"Ranged", "SafeSlot19", false},
[19] = {"Tabard", "SafeSlot7", false},
}
local SlotlistSQL = CharDBQuery("SELECT slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18 FROM custom_iteminsurance WHERE playerguid = "..player:GetGUIDLow()..";")
if (SlotlistSQL) then
for i = 0, 18 do
if (SlotlistSQL:GetInt32(i) == 1) then
Slots[i+1][3] = true
end
end
end
SafeSlots_SendList(AIO.Msg(), player,Slots):Send(player)
end
function SafeSlots_SendList(msg,player,SlotList)
return msg:Add("SlotIsurance", "SafeSlots_GetList", SlotList)
end
function SlotIsuranceServer.InsureSlot(player,slot)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {slot}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
if not(GreedyDemonCheck(player)) then
return false
end
slot = slot - 1
if (player:GetItemCount(InsureCurrency) < 1) then
player:SendBroadcastMessage("You don't have enough Demon's Tears to do that!")
return false
end
local SlotSQL = CharDBQuery("SELECT slot"..slot.." FROM custom_iteminsurance WHERE playerguid = "..player:GetGUIDLow()..";")
if (SlotSQL and (SlotSQL:GetInt32(0) == 1)) then
player:SendBroadcastMessage("You have already insured that slot")
return false
end
player:RemoveItem(InsureCurrency, 1)
if (SlotSQL) then
CharDBExecute("UPDATE custom_iteminsurance SET slot"..slot.." = 1 WHERE playerguid = "..player:GetGUIDLow()..";")
else
CharDBExecute("INSERT IGNORE INTO custom_iteminsurance (playerguid, slot"..slot..") VALUES ("..player:GetGUIDLow()..", 1);")
end
--SlotIsuranceServer.GetSlotList(player)
end
function SlotIsuranceServer.UnInsureSlot(player,slot)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {slot}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
if not(GreedyDemonCheck(player)) then
return false
end
slot = slot - 1
local SlotSQL = CharDBQuery("SELECT slot"..slot.." FROM custom_iteminsurance WHERE playerguid = "..player:GetGUIDLow()..";")
if not(SlotSQL) then
return false
end
if (SlotSQL:GetInt32(0) == 0) then
player:SendBroadcastMessage("You have already removed insurance from that slot")
return false
end
CharDBExecute("UPDATE custom_iteminsurance SET slot"..slot.." = 0 WHERE playerguid = "..player:GetGUIDLow()..";")
player:AddItem(InsureCurrency)
--SlotIsuranceServer.GetSlotList(player)
end
--GOSSIP PART
local GreedyDemon = 75120
local GreedyDemon_menu = 45004
function SafeSlots_CloseMenu(msg,player)
return msg:Add("SlotIsurance", "SafeSlots_Close")
end
function SafeSlots_OpenMenu(msg,player)
return msg:Add("SlotIsurance", "SafeSlots_Init")
end
local function OnGossipHello_GreedyDemon(event, player, Demon)
player:GossipClearMenu()
if (Demon:GetOwner() == player) then
SafeSlots_OpenMenu(AIO.Msg(), player):Send(player)
end
player:GossipSendMenu(1, Demon, GreedyDemon_menu)
player:GossipComplete()
end
RegisterCreatureGossipEvent(GreedyDemon, 1, OnGossipHello_GreedyDemon)
function GreedyDemonCheck(player)
local Demon = nil
Demon = player:GetNearestCreature(3, GreedyDemon)
if (Demon) and (Demon:GetOwner() == player) then
return true
end
SafeSlots_CloseMenu(AIO.Msg(), player):Send(player)
return false
end
local function PlayerIsFar(event, creature, unit)
for k,player in pairs(creature:GetPlayersInRange(20)) do
GreedyDemonCheck(player)
end
end
RegisterCreatureEvent(GreedyDemon, 27, PlayerIsFar)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
-- the lua script for grabbing if the player has a certain spellid learned.
local AIO = AIO or require ("AIO")
local tTHandler = AIO.AddHandlers ("TooltipAIO", {})
function tTHandler.HasSpellID(player, spellid)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {spellid}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local y = player:HasSpell(spellid)
AIO.Handle(player, "TooltipAIO", "ReceiveIDCheck", y)
end
function tTHandler.CostGrabber(player, spellid)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {spellid}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local y = player:GetSpellCost(spellid)
local x = player:GetSpellCooldown(spellid)
local z = player:GetSpellRange(spellid)
local w = player:GetSpellPowerType(spellid)
local v = player:GetSpellCastTime(spellid)
AIO.Handle(player, "TooltipAIO", "ReceiveCostGrab", y, w)
AIO.Handle(player, "TooltipAIO", "ReceiveCDGrab", x)
AIO.Handle(player, "TooltipAIO", "ReceiveRangeGrab", z)
AIO.Handle(player, "TooltipAIO", "ReceiveCastTime", v)
AIO.Handle(player, "TooltipAIO", "UpdateTooltips")
end
function tTHandler.SendRefresh(event, player, spellid)
AIO.Handle(player, "TooltipAIO", "RefreshTable")
end
function tTHandler.SpellCostGrabber(player,spellid)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {spellid}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local Cost = player:GetSpellCost(spellid)
local Type = player:GetSpellPowerType(spellid)
local Range = player:GetSpellRange(spellid)
AIO.Handle(player, "TooltipAIO", "GetSpellCost", Cost,Type,Range,spellid)
end
RegisterPlayerEvent(45, tTHandler.SendRefresh)

View File

@@ -0,0 +1,69 @@
-- the lua script for grabbing if the player has a certain spellid learned.
local AIO = AIO or require ("AIO")
local tTHandler = AIO.AddHandlers ("TooltipAIO", {})
function tTHandler.HasSpellID(player, spellid)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {spellid}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local y = player:HasSpell(spellid)
AIO.Handle(player, "TooltipAIO", "ReceiveIDCheck", y)
end
function tTHandler.CostGrabber(player, spellid)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {spellid}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local y = player:GetSpellCost(spellid)
local x = player:GetSpellCooldown(spellid)
local z = player:GetSpellRange(spellid)
local w = player:GetSpellPowerType(spellid)
local v = player:GetSpellCastTime(spellid)
AIO.Handle(player, "TooltipAIO", "ReceiveCostGrab", y, w)
AIO.Handle(player, "TooltipAIO", "ReceiveCDGrab", x)
AIO.Handle(player, "TooltipAIO", "ReceiveRangeGrab", z)
AIO.Handle(player, "TooltipAIO", "ReceiveCastTime", v)
AIO.Handle(player, "TooltipAIO", "UpdateTooltips")
end
function tTHandler.SendRefresh(event, player, spellid)
AIO.Handle(player, "TooltipAIO", "RefreshTable")
end
function tTHandler.SpellCostGrabber(player,spellid)
--AIO ADDITIONAL CHECK--
local expectedData = {"number"}
local values = {spellid}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
local Cost = player:GetSpellCost(spellid)
local Type = player:GetSpellPowerType(spellid)
local Range = player:GetSpellRange(spellid)
AIO.Handle(player, "TooltipAIO", "GetSpellCost", Cost,Type,Range,spellid)
end
function tTHandler.GetDistance(player)
if (player:GetPlayerTarget()) then
local dist = player:GetDistance(player:GetPlayerTarget())
AIO.Handle(player, "TooltipAIO", "Distance", dist)
end
end
RegisterPlayerEvent(45, tTHandler.SendRefresh)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
local AIO = AIO or require("AIO")
if AIO.AddAddon() then
return
end
local TutAIO = AIO.AddHandlers("TutAIO", {})
local TUTORIAL_TIPS = {
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_Tex1","|cffFFFFFFWelcome! |rAscension|cffFFFFFF is a progressive |rclassless|cffFFFFFF realm with 3 different servers in mind ranging from softcore to hardcore. |rSoftcore|cffFFFFFF being the most vanilla-like while the |rharder|cffFFFFFF difficulties introduce new mechanics such as hunger, same faction pvp, and even item drops on death. No matter where you decide to play you can expect to be able to fully live out your fantasy of a character truly unique to you!|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_Addons","|cffFFFFFFPlease, check your |raddons|cffFFFFFF enabled. Ascension |rrequire|cffFFFFFF you to use |rAscension AIO|cffFFFFFF and Ascension Resources addons. You can |rset|cffFFFFFF them as you wish, that is why you have two of Ascension Resources addons, |rone|cffFFFFFF is for using with default User Interface and the |rsecond|cffFFFFFF if you're mature player and have a lot of custom addons in your UI.|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexUpgrades","|cffFFFFFFOn Ascension, you have a lot of |rcustom|cffFFFFFF features. You may get access to them using our special |rCharacter Upgrades|cffFFFFFF panel on your |rMain Menu Bar|cffFFFFFF on trough |rquick access|cffFFFFFF frame on your screen.|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexStat","|cffFFFFFFIn Ascension you are able to allocate stat points into anything you want. Typically, as a rule: |rStrength|cffFFFFFF is for attack power, |rAgility|cffFFFFFF is less attack power but gives critical strike for physical abilities, |rstamina|cffFFFFFF is how much health you can have, |rspirit|cffFFFFFF is your mana regeneration and |rintellect|cffFFFFFF is your spell power and spell crit. With our classless system, however you will discover many more possibilities!|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexPortrait","|cffFFFFFFClassless system means that every user is able to use all 3 kinds of |rresources|cffFFFFFF, such as: |rmana|cffFFFFFF, |rrage|cffFFFFFF and |renergy|cffFFFFFF. To make it clear and easy to control we included all of them to your |rupdated player portrait|cffFFFFFF. Additional |rhorizontal|cffFFFFFF bar is for energy and |rvertical|cffFFFFFF one is for rage.|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_Ffa","|cffFFFFFFIn non-softcore realms there is |rFFA|cffFFFFFF PVP, this means that you can attack players within your own faction who are not in your group or a safe zone. Be |rcareful|cffFFFFFF out there!|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexProgress","|cffFFFFFFDing! You now have 2 |rability essences|cffFFFFFF! You may now purchase any |rspell|cffFFFFFF from the spell character advancement page. Simply click on the book then on the |rclass|cffFFFFFF which has the |rspell|cffFFFFFF you would like and finally on the left side of the window. Think of the possibilities!|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexReset","|cffFFFFFFBe sure to chose your skills and talents carefully, but since we beileve that the main |rgoal|cffFFFFFF of our realms is to give you an opportunity to try out |rnew builds|cffFFFFFF and |rideas|cffFFFFFF all the time, there is a full spell or talent |rreset|cffFFFFFF possibility which is also accessable trough User Interface.|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexFreeReset","|cffFFFFFFNeed a |rchange|cffFFFFFF? Were here to help! Up until level 10 we have |rfree spell resets|cffFFFFFF to ensure you can play around with our system and feel what is right for you.|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_Enchant","|cffFFFFFF|rRandom enchants|cffFFFFFF! Ever wondered what it would be like to have more levels in a talent you really enjoy? Well we have that and more with our |rRandom Enchantment|cffFFFFFF system. You will periodically find gear that has an enchant that might be a rank of a talent or something else entirely! These enchants |rstack|cffFFFFFF as well! So, you can find and experiment with many different possibilities. Good luck on your drops!|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexResetNotFree","|cffFFFFFFFreedom isnt free! The free resets are now over but fear not as you can reset your spell or talent choices by simply using |r[Ability purge]|cffFFFFFF or |r[Talent Purge]|cffFFFFFF. You start off with |r3 of each|cffFFFFFF but after you run out you can use gold to reset further but the cost increases over time.|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_TexLoot","|cffFFFFFFIn addition to FFA PVP we also have |rloot drop on death|cffFFFFFF for our medium and hardcore realms. There is a method to our madness so |rnot only your best stuff will drop|cffFFFFFF! You must also be within a certain level range to drop or get items to drop from others.|r"},
{"Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_FfaEnabled","|cffFFFFFF|rFFA|cffFFFFFF PVP is now |renabled|cffFFFFFF! Youve honed your skills and talents in peace for 20 levels but now you will be able to kill and be killed by members of your |rown faction |cffFFFFFFor opposing. Hopefully youve chosen your skills wisely as you set out on your adventure and may the odds be ever in your favor!|r"},
-- main tip -- TEX DONE
-- Addon Settings -- TEX DONE
-- Character Upgrades -- TEX DONE
-- Stat Allocation -- TEX DONE
-- Player Portrait -- TEX DONE
-- FFA PVP -- TEX DONE
-- level 2 Character Progression -- TEX DONE
-- level 5 Reset spells/talents -- TEX DONE
-- level 5 Free resets -- TEX DONE
-- level 10 random enchants -- TEX DONE
-- level 10 Free resets are over -- TEX DONE
-- level 10 PvP loot on death -- TEX DONE
-- level 20 FFA PVP is now enabled -- TEX DONE
}
local CURRENTTIP = 1
local MAXTIPS = 1
local Ascension_TutorialFrame = CreateFrame("Frame", "Ascension_TutorialFrame", UIParent, nil)
Ascension_TutorialFrame:SetSize(512,512)
--Ascension_TutorialFrame:SetAllPoints()
Ascension_TutorialFrame:SetPoint("CENTER",450,50)
Ascension_TutorialFrame:SetBackdrop({
bgFile = "Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\Tutorial",
})
Ascension_TutorialFrame:Hide()
Ascension_TutorialFrame:SetFrameStrata("TOOLTIP")
local Ascension_TutorialFrame_CloseButton = CreateFrame("Button", "Ascension_TutorialFrame_CloseButton", Ascension_TutorialFrame, "UIPanelCloseButton")
Ascension_TutorialFrame_CloseButton:SetPoint("CENTER", 169, 116)
Ascension_TutorialFrame_CloseButton:EnableMouse(true)
--Ascension_TutorialFrame_CloseButton:SetSize(25, 25)
Ascension_TutorialFrame_CloseButton:SetScript("OnClick", function()
PlaySound("igMainMenuOptionCheckBoxOn")
Ascension_TutorialFrame:Hide()
end)
local Ascension_TutorialFrame_TitleText = Ascension_TutorialFrame:CreateFontString("Ascension_TutorialFrame_TitleText")
Ascension_TutorialFrame_TitleText:SetFont("Fonts\\FRIZQT__.TTF", 12.2)
Ascension_TutorialFrame_TitleText:SetPoint("CENTER", 15, 116)
Ascension_TutorialFrame_TitleText:SetFontObject(GameFontNormal)
Ascension_TutorialFrame_TitleText:SetShadowOffset(1,-1)
Ascension_TutorialFrame_TitleText:SetText("Ascension Survival Guide")
local Ascension_TutorialFrameTexture = Ascension_TutorialFrame:CreateTexture(nil, "ARTWORK")
Ascension_TutorialFrameTexture:SetSize(Ascension_TutorialFrame:GetSize())
Ascension_TutorialFrameTexture:SetTexture("Interface\\AddOns\\AwAddons\\Textures\\Tutorial\\tutorial_Tex1")
Ascension_TutorialFrameTexture:SetPoint("CENTER",Ascension_TutorialFrame,0,0)
local Ascension_TutorialFrame_TextBox = CreateFrame("EditBox",nil,Ascension_TutorialFrame)
Ascension_TutorialFrame_TextBox:SetWidth(330)
Ascension_TutorialFrame_TextBox:SetHeight(30)
Ascension_TutorialFrame_TextBox:SetFontObject(GameFontNormal)
Ascension_TutorialFrame_TextBox:SetMaxLetters(420)
Ascension_TutorialFrame_TextBox:SetIndentedWordWrap(false)
Ascension_TutorialFrame_TextBox:SetMultiLine(true)
Ascension_TutorialFrame_TextBox:SetMaxResize(843, 80)
Ascension_TutorialFrame_TextBox:ClearFocus(self)
Ascension_TutorialFrame_TextBox:SetAutoFocus(false)
Ascension_TutorialFrame_TextBox:EnableMouse(false)
Ascension_TutorialFrame_TextBox:SetPoint("CENTER",Ascension_TutorialFrame,7,-40)
Ascension_TutorialFrame_TextBox:SetFont("Fonts\\FRIZQT__.TTF", 12)
Ascension_TutorialFrame_TextBox:SetJustifyH("CENTER")
Ascension_TutorialFrame_TextBox:SetText("|cffFFFFFFAscension is a progressive Classless project, starting from Vanilla progressing through the expansions. The realms vary from softcore: just the Vanilla world with Classless systems to hardcore with elements like Hunger, High risk death, and Randomly Enchanted items.|r")
local Ascension_TutorialFrame_NextButton = CreateFrame("Button", "Ascension_TutorialFrame_NextButton", Ascension_TutorialFrame, nil)
Ascension_TutorialFrame_NextButton:SetSize(26, 26)
Ascension_TutorialFrame_NextButton:SetPoint("CENTER",110,-103)
Ascension_TutorialFrame_NextButton:EnableMouse(true)
Ascension_TutorialFrame_NextButton:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up")
Ascension_TutorialFrame_NextButton:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down")
Ascension_TutorialFrame_NextButton:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled")
Ascension_TutorialFrame_NextButton:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight")
local Ascension_TutorialFrame_PrevButton = CreateFrame("Button", "Ascension_TutorialFrame_PrevButton", Ascension_TutorialFrame, nil)
Ascension_TutorialFrame_PrevButton:SetSize(26, 26)
Ascension_TutorialFrame_PrevButton:SetPoint("CENTER",-105,-103)
Ascension_TutorialFrame_PrevButton:EnableMouse(true)
Ascension_TutorialFrame_PrevButton:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up")
Ascension_TutorialFrame_PrevButton:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down")
Ascension_TutorialFrame_PrevButton:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled")
Ascension_TutorialFrame_PrevButton:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight")
Ascension_TutorialFrame_NextButton.Text = Ascension_TutorialFrame_NextButton:CreateFontString("Ascension_TutorialFrame_NextButton.Text")
--Ascension_TutorialFrame_NextButton.Text:SetFont("Fonts\\FRIZQT__.TTF", 12.2)
Ascension_TutorialFrame_NextButton.Text:SetPoint("CENTER",-30, 0)
Ascension_TutorialFrame_NextButton.Text:SetFontObject(GameFontHighlightSmall)
Ascension_TutorialFrame_NextButton.Text:SetShadowOffset(1,-1)
Ascension_TutorialFrame_NextButton.Text:SetText("Next")
Ascension_TutorialFrame_PrevButton.Text = Ascension_TutorialFrame_PrevButton:CreateFontString("Ascension_TutorialFrame_PrevButton.Text")
--Ascension_TutorialFrame_PrevButton.Text:SetFont("Fonts\\FRIZQT__.TTF", 12.2)
Ascension_TutorialFrame_PrevButton.Text:SetPoint("CENTER",30, 0)
Ascension_TutorialFrame_PrevButton.Text:SetFontObject(GameFontHighlightSmall)
Ascension_TutorialFrame_PrevButton.Text:SetShadowOffset(1,-1)
Ascension_TutorialFrame_PrevButton.Text:SetText("Prev")
--SCRIPTS PART--
Ascension_TutorialFrame_PrevButton:SetScript("OnUpdate", function(self)
if (CURRENTTIP == 1) and self:IsEnabled() then
self:Disable()
elseif (CURRENTTIP ~= 1) then
self:Enable()
end
end)
Ascension_TutorialFrame_NextButton:SetScript("OnUpdate", function(self)
if (CURRENTTIP == MAXTIPS) and self:IsEnabled() then
self:Disable()
elseif (CURRENTTIP < MAXTIPS) then
self:Enable()
end
end)
Ascension_TutorialFrame_PrevButton:SetScript("OnClick", function()
CURRENTTIP = CURRENTTIP -1
end)
Ascension_TutorialFrame_NextButton:SetScript("OnClick", function()
CURRENTTIP = CURRENTTIP +1
end)
Ascension_TutorialFrame:SetScript("OnUpdate", function(self)
if (Ascension_TutorialFrame_TextBox:GetText() ~= TUTORIAL_TIPS[CURRENTTIP][2]) then
Ascension_TutorialFrameTexture:SetTexture(TUTORIAL_TIPS[CURRENTTIP][1])
Ascension_TutorialFrame_TextBox:SetText(TUTORIAL_TIPS[CURRENTTIP][2])
end
end)
function TutAIO.InitFrame(player,currtip,maxtips) -- AIO
CURRENTTIP = currtip
MAXTIPS = maxtips
Ascension_TutorialFrame:Show()
end

View File

@@ -0,0 +1,30 @@
local AIO = AIO or require("AIO")
local TutAIO = AIO.AddHandlers("TutAIO", {})
local function TutorialStuff_SendHelp(event, player, oldLevel)
if (oldLevel == 1) then
TutorialAio(AIO.Msg(), player,7,7):Send(player)
elseif (oldLevel == 4) then
TutorialAio(AIO.Msg(), player,8,9):Send(player)
elseif (oldLevel == 9) then
TutorialAio(AIO.Msg(), player,10,12):Send(player)
elseif (oldLevel == 19) then
TutorialAio(AIO.Msg(), player,13,13):Send(player)
end
end
RegisterPlayerEvent(13, TutorialStuff_SendHelp)
RegisterPlayerEvent(30, function(event,player)
TutorialAio(AIO.Msg(), player,1,6):Send(player)
end)
function TutorialAio(msg,player,currtip,maxtips)
return msg:Add("TutAIO", "InitFrame", currtip,maxtips)
end

View File

@@ -0,0 +1,41 @@
local cooldowns = {};
function Player:SetLuaCooldown(seconds, opt_id)
assert(type(self) == "userdata");
seconds = assert(tonumber(seconds));
opt_id = opt_id or 1;
local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
if (not cooldowns[guid]) then
cooldowns[guid] = { [source] = {}; };
end
cooldowns[guid][source][opt_id] = os.clock() + seconds;
end
function Player:GetLuaCooldown(opt_id)
assert(type(self) == "userdata");
local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
opt_id = opt_id or 1;
if (not cooldowns[guid]) then
cooldowns[guid] = { [source] = {}; };
end
local cd = cooldowns[guid][source][opt_id];
if (not cd or cd < os.clock()) then
cooldowns[guid][source][opt_id] = 0
return 0;
else
return cooldowns[guid][source][opt_id] - os.clock();
end
end
--[[ Example:
if(player:GetLuaCooldown() == 0) then -- Check if cooldown is present
player:SetLuaCooldown(30)
print("Cooldown is set to 30 seconds")
else
print("There are still "..player:GetLuaCooldown().." seconds remaining of your cooldown!")
end
]]

View File

@@ -0,0 +1,94 @@
--
-- Copyright (C) 2010 - 2015 Eluna Lua Engine <http://emudevs.com/>
-- This program is free software licensed under GPL version 3
-- Please see the included DOCS/LICENSE.md for more information
--
-- filename.ext files are loaded before normal .lua files
--
-- This extension allows saving data to specific object for it's lifetime in current runtime session
-- Supports Map, Player, Creature, GameObject
--
-- SetData sets a value
-- obj:SetData(key, val)
--
-- GetData gets the data table or a specific value by key from it
-- local tbl = obj:GetData()
-- local val = obj:GetData(key)
--
local variableStores = {
Map = {},
Player = {},
Creature = {},
GameObject = {},
}
local function DestroyMapData(event, obj)
local map = obj:GetMapId()
local inst = obj:GetInstanceId()
for k,v in pairs(variableStores) do
local mapdata = v[map]
if mapdata then
mapdata[inst] = nil
end
end
end
local function DestroyObjData(event, obj)
local map = obj:GetMapId()
local inst = obj:GetInstanceId()
local otype = obj:GetObjectType()
local guid = otype == "Map" and 1 or obj:GetGUIDLow()
local mapdata = variableStores[otype][map]
if mapdata then
local instancedata = mapdata[inst]
if instancedata then
instancedata[guid] = nil
end
end
end
local function GetData(self, field)
local map = self:GetMapId()
local inst = self:GetInstanceId()
local otype = self:GetObjectType()
local guid = otype == "Map" and 1 or self:GetGUIDLow()
local varStore = variableStores[otype]
varStore[map] = varStore[map] or {}
varStore[map][inst] = varStore[map][inst] or {}
varStore[map][inst][guid] = varStore[map][inst][guid] or {}
if field ~= nil then
return varStore[map][inst][guid][field]
else
return varStore[map][inst][guid]
end
end
local function SetData(self, field, val)
local map = self:GetMapId()
local inst = self:GetInstanceId()
local otype = self:GetObjectType()
local guid = otype == "Map" and 1 or self:GetGUIDLow()
local varStore = variableStores[otype]
varStore[map] = varStore[map] or {}
varStore[map][inst] = varStore[map][inst] or {}
varStore[map][inst][guid] = varStore[map][inst][guid] or {}
varStore[map][inst][guid][field] = val
end
for k,v in pairs(variableStores) do
_G[k].GetData = GetData
_G[k].SetData = SetData
end
RegisterPlayerEvent(4, DestroyObjData) -- logout
RegisterServerEvent(31, DestroyObjData) -- creature delete
RegisterServerEvent(32, DestroyObjData) -- gameobject delete
RegisterServerEvent(17, DestroyMapData) -- map create
RegisterServerEvent(18, DestroyMapData) -- map destroy

View File

@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2010 Ignacio Burgueño
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,128 @@
# StackTracePlus #
[![Build Status](https://travis-ci.org/ignacio/StackTracePlus.png?branch=master)](https://travis-ci.org/ignacio/StackTracePlus)
[StackTracePlus](https://github.com/ignacio/StackTracePlus) provides enhanced stack traces for [Lua 5.1, Lua 5.2][1] and [LuaJIT][2].
StackTracePlus can be used as a replacement for debug.traceback. It gives detailed information about locals, tries to guess
function names when they're not available, etc, so, instead of
lua5.1.exe: D:\trunk_git\sources\stacktraceplus\test\test.lua:10: attempt to concatenate a nil value
stack traceback:
D:\trunk_git\sources\stacktraceplus\test\test.lua:10: in function <D:\trunk_git\sources\stacktraceplus\test\test.lua:7>
(tail call): ?
D:\trunk_git\sources\stacktraceplus\test\test.lua:15: in main chunk
[C]: ?
you'll get
lua5.1.exe: D:\trunk_git\sources\stacktraceplus\test\test.lua:10: attempt to concatenate a nil value
Stack Traceback
===============
(2) C function 'function: 00A8F418'
(3) Lua function 'g' at file 'D:\trunk_git\sources\stacktraceplus\test\test.lua:10' (best guess)
Local variables:
fun = table module
str = string: "hey"
tb = table: 027DCBE0 {dummy:1, blah:true, foo:bar}
(*temporary) = nil
(*temporary) = string: "text"
(*temporary) = string: "attempt to concatenate a nil value"
(4) tail call
(5) main chunk of file 'D:\trunk_git\sources\stacktraceplus\test\test.lua' at line 15
(6) C function 'function: 002CA480'
## Usage #
StackTracePlus can be used as a replacement for `debug.traceback`, as an `xpcall` error handler or even from C code. Note that
only the Lua 5.1 interpreter allows the traceback function to be replaced "on the fly". LuaJIT and Lua 5.2 always calls luaL_traceback internally so there is no easy way to override that.
```lua
local STP = require "StackTracePlus"
debug.traceback = STP.stacktrace
function test()
local s = "this is a string"
local n = 42
local t = { foo = "bar" }
local co = coroutine
local cr = coroutine.create
error("an error")
end
test()
```
That script will output (only with Lua 5.1):
lua5.1: example.lua:11: an error
Stack Traceback
===============
(2) C function 'function: 006B5758'
(3) global C function 'error'
(4) Lua global 'test' at file 'example.lua:11'
Local variables:
s = string: "this is a string"
n = number: 42
t = table: 006E5220 {foo:bar}
co = coroutine table
cr = C function: 003C7080
(5) main chunk of file 'example.lua' at line 14
(6) C function 'function: 00637B30'
**StackTracePlus** is aware of the usual Lua libraries, like *coroutine*, *table*, *string*, *io*, etc and functions like
*print*, *pcall*, *assert*, and so on.
You can also make STP aware of your own tables and functions by calling *add_known_function* and *add_known_table*.
```lua
local STP = require "StackTracePlus"
debug.traceback = STP.stacktrace
local my_table = {
f = function() end
}
function my_function()
end
function test(data, func)
local s = "this is a string"
error("an error")
end
STP.add_known_table(my_table, "A description for my_table")
STP.add_known_function(my_function, "A description for my_function")
test( my_table, my_function )
```
Will output:
lua5.1: ..\test\example2.lua:13: an error
Stack Traceback
===============
(2) C function 'function: 0073AAA8'
(3) global C function 'error'
(4) Lua global 'test' at file '..\test\example2.lua:13'
Local variables:
data = A description for my_table
func = Lua function 'A description for my_function' (defined at line 7 of chunk ..\test\example2.lua)
s = string: "this is a string"
(5) main chunk of file '..\test\example2.lua' at line 19
(6) C function 'function: 00317B30'
## Installation #
The easiest way to install is with [LuaRocks][3].
- luarocks install stacktraceplus
If you don't want to use LuaRocks, just copy StackTracePlus.lua to Lua's path.
## License #
**StackTracePlus** is available under the MIT license.
[1]: http://www.lua.org/
[2]: http://luajit.org/
[3]: http://luarocks.org/

View File

@@ -0,0 +1,411 @@
-- tables
local _G = _G
local string, io, debug, coroutine = string, io, debug, coroutine
-- functions
local tostring, print, require = tostring, print, require
local next, assert = next, assert
local pcall, type, pairs, ipairs = pcall, type, pairs, ipairs
local error = error
assert(debug, "debug table must be available at this point")
local io_open = io.open
local string_gmatch = string.gmatch
local string_sub = string.sub
local table_concat = table.concat
local _M = {
max_tb_output_len = 70 -- controls the maximum length of the 'stringified' table before cutting with ' (more...)'
}
-- this tables should be weak so the elements in them won't become uncollectable
local m_known_tables = { [_G] = "_G (global table)" }
local function add_known_module(name, desc)
local ok, mod = pcall(require, name)
if ok then
m_known_tables[mod] = desc
end
end
add_known_module("string", "string module")
add_known_module("io", "io module")
add_known_module("os", "os module")
add_known_module("table", "table module")
add_known_module("math", "math module")
add_known_module("package", "package module")
add_known_module("debug", "debug module")
add_known_module("coroutine", "coroutine module")
-- lua5.2
add_known_module("bit32", "bit32 module")
-- luajit
add_known_module("bit", "bit module")
add_known_module("jit", "jit module")
local m_user_known_tables = {}
local m_known_functions = {}
for _, name in ipairs{
-- Lua 5.2, 5.1
"assert",
"collectgarbage",
"dofile",
"error",
"getmetatable",
"ipairs",
"load",
"loadfile",
"next",
"pairs",
"pcall",
"print",
"rawequal",
"rawget",
"rawlen",
"rawset",
"require",
"select",
"setmetatable",
"tonumber",
"tostring",
"type",
"xpcall",
-- Lua 5.1
"gcinfo",
"getfenv",
"loadstring",
"module",
"newproxy",
"setfenv",
"unpack",
-- TODO: add table.* etc functions
} do
if _G[name] then
m_known_functions[_G[name]] = name
end
end
local m_user_known_functions = {}
local function safe_tostring (value)
local ok, err = pcall(tostring, value)
if ok then return err else return ("<failed to get printable value>: '%s'"):format(err) end
end
-- Private:
-- Parses a line, looking for possible function definitions (in a very na?ve way)
-- Returns '(anonymous)' if no function name was found in the line
local function ParseLine(line)
assert(type(line) == "string")
--print(line)
local match = line:match("^%s*function%s+(%w+)")
if match then
--print("+++++++++++++function", match)
return match
end
match = line:match("^%s*local%s+function%s+(%w+)")
if match then
--print("++++++++++++local", match)
return match
end
match = line:match("^%s*local%s+(%w+)%s+=%s+function")
if match then
--print("++++++++++++local func", match)
return match
end
match = line:match("%s*function%s*%(") -- this is an anonymous function
if match then
--print("+++++++++++++function2", match)
return "(anonymous)"
end
return "(anonymous)"
end
-- Private:
-- Tries to guess a function's name when the debug info structure does not have it.
-- It parses either the file or the string where the function is defined.
-- Returns '?' if the line where the function is defined is not found
local function GuessFunctionName(info)
--print("guessing function name")
if type(info.source) == "string" and info.source:sub(1,1) == "@" then
local file, err = io_open(info.source:sub(2), "r")
if not file then
print("file not found: "..tostring(err)) -- whoops!
return "?"
end
local line
for i = 1, info.linedefined do
line = file:read("*l")
end
if not line then
print("line not found") -- whoops!
return "?"
end
return ParseLine(line)
else
local line
local lineNumber = 0
for l in string_gmatch(info.source, "([^\n]+)\n-") do
lineNumber = lineNumber + 1
if lineNumber == info.linedefined then
line = l
break
end
end
if not line then
print("line not found") -- whoops!
return "?"
end
return ParseLine(line)
end
end
---
-- Dumper instances are used to analyze stacks and collect its information.
--
local Dumper = {}
Dumper.new = function(thread)
local t = { lines = {} }
for k,v in pairs(Dumper) do t[k] = v end
t.dumping_same_thread = (thread == coroutine.running())
-- if a thread was supplied, bind it to debug.info and debug.get
-- we also need to skip this additional level we are introducing in the callstack (only if we are running
-- in the same thread we're inspecting)
if type(thread) == "thread" then
t.getinfo = function(level, what)
if t.dumping_same_thread and type(level) == "number" then
level = level + 1
end
return debug.getinfo(thread, level, what)
end
t.getlocal = function(level, loc)
if t.dumping_same_thread then
level = level + 1
end
return debug.getlocal(thread, level, loc)
end
else
t.getinfo = debug.getinfo
t.getlocal = debug.getlocal
end
return t
end
-- helpers for collecting strings to be used when assembling the final trace
function Dumper:add (text)
self.lines[#self.lines + 1] = text
end
function Dumper:add_f (fmt, ...)
self:add(fmt:format(...))
end
function Dumper:concat_lines ()
return table_concat(self.lines)
end
---
-- Private:
-- Iterates over the local variables of a given function.
--
-- @param level The stack level where the function is.
--
function Dumper:DumpLocals (level)
local prefix = "\t "
local i = 1
if self.dumping_same_thread then
level = level + 1
end
local name, value = self.getlocal(level, i)
if not name then
return
end
self:add("\tLocal variables:\r\n")
while name do
if type(value) == "number" then
self:add_f("%s%s = number: %g\r\n", prefix, name, value)
elseif type(value) == "boolean" then
self:add_f("%s%s = boolean: %s\r\n", prefix, name, tostring(value))
elseif type(value) == "string" then
self:add_f("%s%s = string: %q\r\n", prefix, name, value)
elseif type(value) == "userdata" then
self:add_f("%s%s = %s\r\n", prefix, name, safe_tostring(value))
elseif type(value) == "nil" then
self:add_f("%s%s = nil\r\n", prefix, name)
elseif type(value) == "table" then
if m_known_tables[value] then
self:add_f("%s%s = %s\r\n", prefix, name, m_known_tables[value])
elseif m_user_known_tables[value] then
self:add_f("%s%s = %s\r\n", prefix, name, m_user_known_tables[value])
else
local txt = "{"
for k,v in pairs(value) do
txt = txt..safe_tostring(k)..":"..safe_tostring(v)
if #txt > _M.max_tb_output_len then
txt = txt.." (more...)"
break
end
if next(value, k) then txt = txt..", " end
end
self:add_f("%s%s = %s %s\r\n", prefix, name, safe_tostring(value), txt.."}")
end
elseif type(value) == "function" then
local info = self.getinfo(value, "nS")
local fun_name = info.name or m_known_functions[value] or m_user_known_functions[value]
if info.what == "C" then
self:add_f("%s%s = C %s\r\n", prefix, name, (fun_name and ("function: " .. fun_name) or tostring(value)))
else
local source = info.short_src
if source:sub(2,7) == "string" then
source = source:sub(9) -- uno m?s, por el espacio que viene (string "Baragent.Main", por ejemplo)
end
--for k,v in pairs(info) do print(k,v) end
fun_name = fun_name or GuessFunctionName(info)
self:add_f("%s%s = Lua function '%s' (defined at line %d of chunk %s)\r\n", prefix, name, fun_name, info.linedefined, source)
end
elseif type(value) == "thread" then
self:add_f("%sthread %q = %s\r\n", prefix, name, tostring(value))
end
i = i + 1
name, value = self.getlocal(level, i)
end
end
---
-- Public:
-- Collects a detailed stack trace, dumping locals, resolving function names when they're not available, etc.
-- This function is suitable to be used as an error handler with pcall or xpcall
--
-- @param thread An optional thread whose stack is to be inspected (defaul is the current thread)
-- @param message An optional error string or object.
-- @param level An optional number telling at which level to start the traceback (default is 1)
--
-- Returns a string with the stack trace and a string with the original error.
--
function _M.stacktrace(thread, message, level)
if type(thread) ~= "thread" then
-- shift parameters left
thread, message, level = nil, thread, message
end
thread = thread or coroutine.running()
level = level or 1
local dumper = Dumper.new(thread)
local original_error
if type(message) == "table" then
dumper:add("an error object {\r\n")
local first = true
for k,v in pairs(message) do
if first then
dumper:add(" ")
first = false
else
dumper:add(",\r\n ")
end
dumper:add(safe_tostring(k))
dumper:add(": ")
dumper:add(safe_tostring(v))
end
dumper:add("\r\n}")
original_error = dumper:concat_lines()
elseif type(message) == "string" then
dumper:add(message)
original_error = message
end
dumper:add("\r\n")
dumper:add[[
Stack Traceback
===============
]]
--print(error_message)
local level_to_show = level
if dumper.dumping_same_thread then level = level + 1 end
local info = dumper.getinfo(level, "nSlf")
while info do
if info.what == "main" then
if string_sub(info.source, 1, 1) == "@" then
dumper:add_f("(%d) main chunk of file '%s' at line %d\r\n", level_to_show, string_sub(info.source, 2), info.currentline)
else
dumper:add_f("(%d) main chunk of %s at line %d\r\n", level_to_show, info.short_src, info.currentline)
end
elseif info.what == "C" then
--print(info.namewhat, info.name)
--for k,v in pairs(info) do print(k,v, type(v)) end
local function_name = m_user_known_functions[info.func] or m_known_functions[info.func] or info.name or tostring(info.func)
dumper:add_f("(%d) %s C function '%s'\r\n", level_to_show, info.namewhat, function_name)
--dumper:add_f("%s%s = C %s\r\n", prefix, name, (m_known_functions[value] and ("function: " .. m_known_functions[value]) or tostring(value)))
elseif info.what == "tail" then
--print("tail")
--for k,v in pairs(info) do print(k,v, type(v)) end--print(info.namewhat, info.name)
dumper:add_f("(%d) tail call\r\n", level_to_show)
dumper:DumpLocals(level)
elseif info.what == "Lua" then
local source = info.short_src
local function_name = m_user_known_functions[info.func] or m_known_functions[info.func] or info.name
if source:sub(2, 7) == "string" then
source = source:sub(9)
end
local was_guessed = false
if not function_name or function_name == "?" then
--for k,v in pairs(info) do print(k,v, type(v)) end
function_name = GuessFunctionName(info)
was_guessed = true
end
-- test if we have a file name
local function_type = (info.namewhat == "") and "function" or info.namewhat
if info.source and info.source:sub(1, 1) == "@" then
dumper:add_f("(%d) Lua %s '%s' at file '%s:%d'%s\r\n", level_to_show, function_type, function_name, info.source:sub(2), info.currentline, was_guessed and " (best guess)" or "")
elseif info.source and info.source:sub(1,1) == '#' then
dumper:add_f("(%d) Lua %s '%s' at template '%s:%d'%s\r\n", level_to_show, function_type, function_name, info.source:sub(2), info.currentline, was_guessed and " (best guess)" or "")
else
dumper:add_f("(%d) Lua %s '%s' at line %d of chunk '%s'\r\n", level_to_show, function_type, function_name, info.currentline, source)
end
dumper:DumpLocals(level)
else
dumper:add_f("(%d) unknown frame %s\r\n", level_to_show, info.what)
end
level = level + 1
level_to_show = level_to_show + 1
info = dumper.getinfo(level, "nSlf")
end
return dumper:concat_lines(), original_error
end
--
-- Adds a table to the list of known tables
function _M.add_known_table(tab, description)
if m_known_tables[tab] then
error("Cannot override an already known table")
end
m_user_known_tables[tab] = description
end
--
-- Adds a function to the list of known functions
function _M.add_known_function(fun, description)
if m_known_functions[fun] then
error("Cannot override an already known function")
end
m_user_known_functions[fun] = description
end
return _M

14
extensions/_Misc.ext Normal file
View File

@@ -0,0 +1,14 @@
--
-- Copyright (C) 2010 - 2015 Eluna Lua Engine <http://emudevs.com/>
-- This program is free software licensed under GPL version 3
-- Please see the included DOCS/LICENSE.md for more information
--
-- filename.ext files are loaded before normal .lua files
-- Randomize random
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6)))
-- Set debug.traceback to use StackTracePlus to print full stack trace
local trace = require("StackTracePlus")
debug.traceback = trace.stacktrace

View File

@@ -0,0 +1,37 @@
--fix for talent points players have and which can be used in standart interface and then exploited
local function RemoveTalentPoints(event,player)
if (player:GetFreeTalentPoints()) then
player:SetFreeTalentPoints(0)
end
end
RegisterPlayerEvent(3, RemoveTalentPoints)
--ressurect and tele to city
local AIO = AIO or require("AIO")
local MyHandlers = AIO.AddHandlers("DeathRessurect", {})
function MyHandlers.Ressurect(player)
if player:HasAura(8326) and (player:GetLevel() >= 10) then
if (player:InBattleground()) then
return false
end
player:ResurrectPlayer(20, true)
player:DurabilityLossAll(100, true)
if player:IsAlliance() then
player:Teleport(0, -8525.72, 851.9157, 106.51, 3.8)
else
player:Teleport(1, 1451, -4181, 61.6, 1.05)
end
end
end
function GetGoldForMoney(cost)
local c_gold,c_silver,c_copper = 0
c_gold = math.floor(math.abs(cost / 10000))
c_silver = math.floor(math.abs(math.fmod(cost / 100, 100)))
c_copper = math.floor(math.abs(math.fmod(cost, 100)))
return c_gold,c_silver,c_copper
end

View File

@@ -0,0 +1,172 @@
local AIO = AIO or require("AIO")
if AIO.AddAddon() then
return
end
local MicroButtons = {
AchievementMicroButton,
QuestLogMicroButton,
SocialsMicroButton,
PVPMicroButton
}
local MicroButtons2 = {
LFDMicroButton,
MainMenuMicroButton,
HelpMicroButton
}
BI_i = CreateFrame("Frame", nil, UIParent)
BI_i:SetScript("OnUpdate", function()
if (PlayerTalentFrame) then
if (PlayerTalentFrame:IsVisible()) then
PlayerTalentFrameTab2:Hide()
PlayerTalentFrameTab3:Hide()
PlayerTalentFrameTab4:Hide()
end
end
if (InspectFrame) then
if (InspectFrameTab3:IsVisible()) then
InspectFrameTab3:Hide()
end
end
if (FriendsFrameTab2:IsVisible()) then
FriendsFrameTab2:Hide()
end
--[[if (LFDMicroButton:IsVisible()) then
LFDMicroButton:Hide()
CharUpdatesMicroButton:Show()
end]]
if (TalentMicroButton:IsVisible()) then
TalentMicroButton:Hide()
CharUpdatesMicroButton:Show()
--moving all buttons to right
LFDMicroButton:Show()
for i = 1, #MicroButtons do
if (i == 1) then
MicroButtons[i]:SetPoint("BOTTOMLEFT", SpellbookMicroButton, "BOTTOMRIGHT", -3, 0)
else
MicroButtons[i]:SetPoint("BOTTOMLEFT", MicroButtons[i-1], "BOTTOMRIGHT", -3, 0)
end
end
--shitty code, lol
for i = 1, #MicroButtons2 do
if (i == 1) then
MicroButtons2[i]:SetPoint("BOTTOMLEFT", CharUpdatesMicroButton, "BOTTOMRIGHT", -3, 0)
else
MicroButtons2[i]:SetPoint("BOTTOMLEFT", MicroButtons2[i-1], "BOTTOMRIGHT", -3, 0)
end
end
end
if (UnitLevel("player") >= 10) then
if (UnitIsGhost("player")) and not(DeathCapitalTeleportButton:IsVisible()) then
local zonenamename, zonetype = GetInstanceInfo()
if not(zonetype == "pvp") then
DeathCapitalTeleportButton:Show()
end
elseif not(UnitIsGhost("player")) and (DeathCapitalTeleportButton:IsVisible()) then
DeathCapitalTeleportButton:Hide()
end
end
end)
BI_i:Show()
--Pet talents tab
table.insert(UnitPopupMenus["PET"], table.getn(UnitPopupMenus["PET"]), "ASCENSION_PETTALENTS");
UnitPopupButtons["ASCENSION_PETTALENTS"] = {text = "Pet Talents", dist = 0}
hooksecurefunc("UnitPopup_OnClick", function (self)
local name = UIDROPDOWNMENU_INIT_MENU.name
if (name == MC_PLAYER) then return end
if (self.value == "ASCENSION_PETTALENTS") then
ToggleTalentFrame()
end
end);
function IsSpellLearned(entry)
local spellname = GetSpellInfo(entry)
local done = false
local known = false
local i = 1
local id = nil
if not(spellname) then
return false
end
spellname = string.gsub(spellname,"%(Rank %d+%)","");
while not done do
local name = GetSpellName(i,BOOKTYPE_SPELL);
if not name then
done=true;
elseif (name==spellname) then
known = true
end
i = i+1;
end
return known
end
--pet status bar--
--[[function Asc_PetPaperDollFrame_Update()
local hasPetUI, canGainXP = HasPetUI();
if ( not hasPetUI ) then
return;
end
PetModelFrame:SetUnit("pet");
if ( UnitCreatureFamily("pet") ) then
PetLevelText:SetFormattedText(UNIT_TYPE_LEVEL_TEMPLATE,UnitLevel("pet"),UnitCreatureFamily("pet"));
end
if ( PetPaperDollFramePetFrame:IsShown() ) then
PetNameText:SetText(UnitName("pet"));
end
PetExpBar_Update();
PetPaperDollFrame_SetResistances();
PetPaperDollFrame_SetStats();
PaperDollFrame_SetDamage(PetDamageFrame, "Pet");
PaperDollFrame_SetArmor(PetArmorFrame, "Pet");
PaperDollFrame_SetAttackPower(PetAttackPowerFrame, "Pet");
PetPaperDollFrame_SetSpellBonusDamage();
if ( GetPetFoodTypes() ) then
PetPaperDollPetInfo:Show();
else
PetPaperDollPetInfo:Hide();
end
end
ActionButton_UpdateUsable = Asc_PetPaperDollFrame_Update]]--
--[[function Asc_PetFrame_SetHappiness ()
local happiness, damagePercentage = GetPetHappiness();
local hasPetUI, isHunterPet = HasPetUI();
if ( not damagePercentage) then
PetFrameHappiness:Hide();
return;
end
PetFrameHappiness:Show();
--custom hapiness indicator
if (damagePercentage > 100) then
happiness = 3
elseif (damagePercentage == 100) then
happiness = 2
else
happiness = 1
end
--end
if ( happiness == 1 ) then
PetFrameHappinessTexture:SetTexCoord(0.375, 0.5625, 0, 0.359375);
elseif ( happiness == 2 ) then
PetFrameHappinessTexture:SetTexCoord(0.1875, 0.375, 0, 0.359375);
elseif ( happiness == 3 ) then
PetFrameHappinessTexture:SetTexCoord(0, 0.1875, 0, 0.359375);
end
PetFrameHappiness.tooltip = _G["PET_HAPPINESS"..happiness];
PetFrameHappiness.tooltipDamage = format(PET_DAMAGE_PERCENTAGE, damagePercentage);
end
PetFrame_SetHappiness = Asc_PetFrame_SetHappiness]]--

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
local AIO = AIO or require("AIO")
if AIO.AddAddon() then
return
end
local MyHandlers = AIO.AddHandlers("DeathRessurect", {})
DeathCapitalTeleportButton = CreateFrame("Button", "DeathCapitalTeleportButton", UIParent, nil)
DeathCapitalTeleportButton:SetWidth(200)
DeathCapitalTeleportButton:SetHeight(100)
DeathCapitalTeleportButton:SetPoint("TOP", 0,-20)
DeathCapitalTeleportButton:SetNormalTexture("Interface\\AddOns\\AwAddons\\Textures\\misc\\pvprev")
--font
local DeathCapitalTeleportButton_text = DeathCapitalTeleportButton:CreateFontString("TicketMasterFrame_Title")
DeathCapitalTeleportButton_text:SetFontObject(GameFontNormal)
DeathCapitalTeleportButton_text:SetText("Resurrect\nin a capital city")
DeathCapitalTeleportButton_text:SetPoint("CENTER",32,0)
--
DeathCapitalTeleportButton:SetFontString(DeathCapitalTeleportButton_text)
DeathCapitalTeleportButton:RegisterForClicks("AnyUp")
DeathCapitalTeleportButton:SetHighlightTexture("Interface\\AddOns\\AwAddons\\Textures\\misc\\pvprev_h")
DeathCapitalTeleportButton:SetScript("OnClick", function()
DeathDialog:Show()
end)
DeathCapitalTeleportButton:Hide()
local DeathDialog = CreateFrame("Frame", "DeathDialog",DeathCapitalTeleportButton,nil)
DeathDialog:ClearAllPoints()
DeathDialog:SetBackdrop(StaticPopup1:GetBackdrop())
DeathDialog:SetHeight(115)
DeathDialog:SetWidth(390)
DeathDialog:SetPoint("TOP", UIParent, 0, -215)
DeathDialog:Hide()
DeathDialog.text = DeathDialog:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
--DeathDialog.text:SetAllPoints()
DeathDialog.text:SetFont("Fonts\\FRIZQT__.TTF", 11)
DeathDialog.text:SetText("Are you sure you want to be resurrected in a City? All of your items\n will take 100% durability damage,\n and you will be\n afflicted by 10 minutes of Resurrection Sickness.")
DeathDialog.text:SetPoint("TOP",0,-20)
DeathDialog.Alert = DeathDialog:CreateTexture("DeathDialog.Alert")
--DeathDialog.Alert:SetAllPoints()
DeathDialog.Alert:SetTexture("Interface\\DialogFrame\\UI-Dialog-Icon-AlertNew")
DeathDialog.Alert:SetSize(48,48)
DeathDialog.Alert:SetPoint("LEFT",24,0)
DeathDialog.Yes = CreateFrame("Button", nil, DeathDialog, "StaticPopupButtonTemplate")
DeathDialog.Yes:SetWidth(110)
DeathDialog.Yes:SetHeight(19)
DeathDialog.Yes:SetPoint("BOTTOM", -60,15)
DeathDialog.Yes:SetScript("OnClick", function()
AIO.Handle("DeathRessurect", "Ressurect")
DeathDialog:Hide()
end)
DeathDialog.No = CreateFrame("Button", nil, DeathDialog, "StaticPopupButtonTemplate")
DeathDialog.No:SetWidth(110)
DeathDialog.No:SetHeight(19)
DeathDialog.No:SetPoint("BOTTOM", 60,15)
DeathDialog.No:SetScript("OnClick", function()
DeathDialog:Hide()
end)
DeathDialog.Yes.text = DeathDialog.Yes:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
DeathDialog.Yes.text:SetFont("Fonts\\FRIZQT__.TTF", 11)
DeathDialog.Yes.text:SetText("Accept")
DeathDialog.Yes.text:SetPoint("CENTER",0,1)
DeathDialog.No.text = DeathDialog.No:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
DeathDialog.No.text:SetFont("Fonts\\FRIZQT__.TTF", 11)
DeathDialog.No.text:SetText("Cancel")
DeathDialog.No.text:SetPoint("CENTER",0,1)
DeathDialog.Yes:SetFontString(DeathDialog.Yes.text)
DeathDialog.No:SetFontString(DeathDialog.No.text)
DeathDialog:SetScript("OnShow", function(self)
PlaySound("igMainMenuOpen")
end)
DeathDialog:SetScript("OnHide", function(self)
PlaySound("igMainMenuClose")
end)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,74 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
druid_balance_spells = {{5176, 2, 0, 1}, {8921, 2, 0, 4}, {467, 2, 0, 6}, {339, 2, 0, 8}, {18960, 2, 0, 10},
{16689, 2, 0, 10}, {770, 2, 0, 18}, {2637, 2, 0, 18}, {2912, 2, 0, 20}, {2908, 1, 0, 22}, {29166, 2, 0, 40},
{16914, 2, 0, 40}, {22812, 2, 0, 44}, {33786, 2, 0, 70}}
druid_balance_spells_count = 14
druid_balance_bgs = {"Interface\\TalentFrame\\DruidBalance-TopLeft", "Interface\\TalentFrame\\DruidBalance-TopRight",
"Interface\\TalentFrame\\DruidBalance-BottomLeft", "Interface\\TalentFrame\\DruidBalance-BottomRight"}
druid_balance_talents = {{5,{16814,16815,16816,16817,16818},0,1,10,2,762}, {5,{57810,57811,57812,57813,57814},0,1,10,3,2238},
{3,{16845,16846,16847},0,1,15,1,783}, {2,{35363,35364},0,1,15,2,1822}, {2,{16821,16822},0,1,15,4,763},
{3,{16836,16839,16840},0,1,20,1,782}, {3,{16880,61345,61346},0,1,20,2,789}, {1,{57865},1,1,20,3,2240}, {2,{16819,16820},0,1,20,4,764},
{5,{16909,16910,16911,16912,16913},0,1,25,2,792}, {3,{16850,16923,16924},0,1,25,3,784},
{3,{33589,33590,33591},0,1,30,1,1782}, {1,{5570},2,1,30,2,788}, {3,{57849,57850,57851},0,1,30,3,2239},
{3,{33597,33599,33956},0,1,35,1,1784}, {3,{16896,16897,16899},0,1,35,2,790}, {2,{33592,33596},0,1,35,3,1783},
{1,{24858},2,1,40,2,793}, {3,{48384,48395,48396},0,1,40,3,1912}, {3,{33600,33601,33602},0,1,40,4,1785},
{3,{48389,48392,48393},0,1,45,1,1913}, {5,{33603,33604,33605,33606,33607},0,1,45,3,1786},
{3,{48516,48521,48525},0,1,50,1,1924}, {1,{50516},2,1,50,2,1923}, {1,{33831},2,1,50,3,1787}, {2,{48488,48514},0,1,50,4,1925},
{3,{48506,48510,48511},0,1,55,2,1928},
{1,{48505},3,1,60,2,1926}}
druid_balance_talents_tab = 18
druid_feral_spells = {{99, 2, 0, 10}, {6807, 1, 0, 10}, {6795, 1, 0, 10}, {5487, 2, 0, 10}, {5229, 2, 0, 12},
{5211, 2, 0, 14}, {1066, 2, 0, 16}, {779, 2, 0, 16}, {16857, 2, 0, 18}, {1082, 1, 0, 20},
{1079, 2, 0, 20}, {768, 2, 0, 20}, {5215, 2, 0, 20}, {62078, 2, 0, 20}, {5221, 2, 0, 22}, {1822, 1, 0, 24}, {5217, 2, 0, 24},
{1850, 2, 0, 26}, {8998, 2, 0, 28}, {5209, 2, 0, 28}, {783, 2, 0, 30}, {22568, 2, 0, 32},
{6785, 2, 0, 32}, {9005, 2, 0, 36}, {22842, 2, 0, 36}, {20719, 1, 0, 40}, {62600, 2, 0, 40}, {22570, 2, 0, 62}, {33745, 2, 0, 66}, {52610, 2, 0, 75}}
druid_feral_spells_count = 30
druid_feral_bgs = {"Interface\\TalentFrame\\DruidFeralCombat-TopLeft", "Interface\\TalentFrame\\DruidFeralCombat-TopRight",
"Interface\\TalentFrame\\DruidFeralCombat-BottomLeft", "Interface\\TalentFrame\\DruidFeralCombat-BottomRight"}
druid_feral_talents = {{5, {16934,16935,16936,16937,16938}, 0, 1, 10, 2,796}, {5, {16858,16859,16860,16861,16862}, 0, 1, 10, 3,795},
{3, {16947,16948,16949}, 0, 1, 15, 1,799}, {2, {16998,16999}, 0, 1, 15, 2,805}, {3, {16929,16930,16931}, 0, 1, 15, 3,794},
{2, {17002,24866}, 0, 1, 20, 1,807}, {1, {61336}, 2, 1, 20, 2,1162}, {3, {16942,16943,16944}, 0, 1, 20, 3,798},
{2,{16966,16968},0,1,25,1,802},{3,{16972,16974,16975},0,1,25, 2,803},{2,{37116,37117},0,1,25,3,801},{2,{48409,48410},0,1,25,4,1914},
{2, {16940,16941}, 0, 1, 30, 1,797}, {1, {49377}, 2, 1, 30, 3,804}, {2, {33872,33873}, 0, 1, 30, 4,1792},
{3, {57878,57880,57881}, 0, 1, 35, 1,2242},{5, {17003,17004,17005,17006,24894},0,1,35,2,808},{3,{33853,33855,33856},0,1,35,3,1794},
{1, {17007}, 2, 1, 40, 2,809}, {2,{34297,34300},0,1,40,3,1798}, {3,{33851,33852,33957},0,1,40,4,1793},
{3,{57873,57876,57877},0,1,45,1,2241},{3,{33859,33866,33867},0,1,45,3,1795},{3,{48483,48484,48485},0,1,45,4,1919},
{3,{48492,48494,48495},0,1,50,1,1921},{1,{33917},2,1,50,2,1796},{3,{48532,48489,48491},0,1,50,3,1920},
{5,{48432,48433,48434,51268,51269},0,1,55,2,1918},{1,{63503},1,1,55,3,2266},
{1, {50334}, 3, 1, 60, 2,1927}}
druid_feral_talents_tab = 16
druid_restoration_spells = {{5185, 2, 0, 1}, {1126, 2, 0, 1}, {774, 2, 0, 4}, {8936, 2, 0, 12}, {50769, 2, 0, 12},
{8946, 2, 0, 14}, {20484, 2, 0, 20}, {2782, 2, 0, 24}, {2893, 2, 0, 26}, {740, 2, 0 ,30},
{33763, 2, 0, 64},{504642, 0, 80}}
druid_restoration_spells_count = 11
druid_restoration_bgs = {"Interface\\TalentFrame\\DruidRestoration-TopLeft", "Interface\\TalentFrame\\DruidRestoration-TopRight",
"Interface\\TalentFrame\\DruidRestoration-BottomLeft", "Interface\\TalentFrame\\DruidRestoration-BottomRight"}
druid_restoration_talents = {{2,{17050,17051},0,1,10,1,821}, {3,{17063,17065,17066},0,1,10,2,823}, {5,{17056,17058,17059,17060,17061},0,1,10,3,822},
{5,{17069,17070,17071,17072,17073},0,1,15,1,824}, {3,{17118,17119,17120},0,1,15,2,841}, {1,{16833},1,1,15,3,826},
{3,{17106,17107,17108},0,1,20,1,829}, {1,{16864},1,1,20,2,827}, {2,{48411,48412},0,1,20,3,1915},
{5,{24968,24969,24970,24971,24972},0,1,25,2,843}, {3,{17111,17112,17113},0,1,25,3,830},
{1,{17116},2,1,30,1,831}, {5,{17104,24943,24944,24945,24946},0,1,30,2,828}, {2,{17123,17124},0,1,30,4,842},
{2,{33879,33880},0,1,35,1,1788}, {5,{17074,17075,17076,17077,17078},0,1,35,3,825},
{3,{34151,34152,34153},0,1,40,1,1797}, {1,{18562},2,1,40,2,844}, {3,{33881,33882,33883},0,1,40,3,1790},
{5,{33886,33887,33888,33889,33890},0,1,45,2,1789}, {3,{48496,48499,48500},0,1,45,3,1922},
{3,{48539,48544,48545},0,1,50,1,1929}, {1,{65139},2,1,50,2,1791}, {3,{48535,48536,48537},0,1,50,3,1930},
{2,{63410,63411},0,1,55,1,2264}, {5,{51179,51180,51181,51182,51183},0,1,55,3,1916},
{1,{48438},3,1,60,2,1917}}
druid_restoration_talents_tab = 17

View File

@@ -0,0 +1,77 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
hunter_beastmastery_spells = {{13163, 2, 0, 4}, {883, 1, 0, 10}, {1515, 2, 0, 10}, {2641, 1, 0, 10}, {6991, 1, 0, 10}, {13165, 2, 0, 10},
{982, 1, 0, 10}, {136, 2, 0, 12}, {6197, 1, 0, 14}, {1513, 2, 0, 14}, {1002, 1, 0, 14}, {5118, 2, 0, 16},
{34074, 2, 0, 20}, {1462, 1, 0, 24}, {13161, 2, 0, 30}, {13159, 2, 0, 40}, {20043, 2, 0, 46}, {34026, 2, 0, 66},
{61846, 2, 0, 74}, {53271, 2, 0, 75}, {62757, 2, 0, 80}}
hunter_beastmastery_spells_count = 21
hunter_beastmastery_bgs = {"Interface\\TalentFrame\\HunterBeastmastery-TopLeft", "Interface\\TalentFrame\\HunterBeastmastery-TopRight",
"Interface\\TalentFrame\\HunterBeastmastery-BottomLeft", "Interface\\TalentFrame\\HunterBeastmastery-BottomRight"}
hunter_beastmastery_talents = {{5,{19552,19553,19554,19555,19556},0,1,10,2,1382}, {5,{19583,19584,19585,19586,19587},0,1,10,3,1389},
{2,{35029,35030},0,1,15,1,1624},{3,{19549,19550,19551},0,1,15,2,1381}, {3,{19609,19610,19612},0,1,15,3,1395}, {2,{24443,19575},0,1,15,4,1625},
{2,{19559,19560},0,1,20,1,1384}, {1,{53265},1,1,20,2,2138}, {5,{19616,19617,19618,19619,19620},0,1,20,3,1396},
{2,{19572,19573},0,1,25,2,1385}, {5,{19598,19599,19600,19601,19602},0,1,25,3,1393},
{2,{19578,20895},0,1,30,1,1388}, {1,{19577},2,1,30,2,1387}, {2,{19590,19592},0,1,30,4,1390},
{2,{34453,34454},0,1,35,1,1799}, {5,{19621,19622,19623,19624,19625},0,1,35,3,1397},
{3,{34455,34459,34460},0,1,40,1,1800}, {1,{19574},2,1,40,2,1386}, {3,{34462,34464,34465},0,1,40,3,1801},
{2,{53252,53253},0,1,45,1,2136}, {5,{34466,34467,34468,34469,34470},0,1,45,3,1802},
{3,{53262,53263,53264},0,1,50,1,2140}, {1,{34692},1,1,50,2,1803}, {3,{53256,53259,53260},0,1,50,3,2137},
{5,{56314,56315,56316,56317,56318},0,1,55,2,2227},
{1,{53270},3,1,60,2,2139}}
hunter_beastmastery_talents_tab = 22
hunter_marksmanship_spells = {{75, 2, 0, 1}, {1978, 2, 0, 4}, {3044, 2, 0, 6}, {1130, 2, 0, 6}, {5116, 2, 0, 8},
{20736, 2, 0, 12}, {2643, 2, 0, 18}, {3043, 2, 0, 22}, {3045, 2, 0, 26}, {1543, 2, 0, 32}, {3034, 2, 0, 36},
{1510, 2, 0, 40}, {56641, 2, 0, 50}, {19801, 2, 0, 60}, {53351, 2, 0, 71}}
hunter_marksmanship_spells_count = 15
hunter_marksmanship_bgs = {"Interface\\TalentFrame\\HunterMarksmanship-TopLeft", "Interface\\TalentFrame\\HunterMarksmanship-TopRight",
"Interface\\TalentFrame\\HunterMarksmanship-BottomLeft", "Interface\\TalentFrame\\HunterMarksmanship-BottomRight"}
hunter_marksmanship_talents = {{2,{19407,19412},0,1,10,1,1341}, {3,{53620,53621,53622},0,1,10,2,2197}, {5,{19426,19427,19429,19430,19431},0,1,10,3,1344},
{3,{34482,34483,34484},0,1,15,1,1806}, {3,{19421,19422,19423},0,1,15,2,1343}, {5,{19485,19487,19488,19489,19490},0,1,15,3,1349},
{2,{34950,34954},0,1,20,1,1818}, {3,{19454,19455,19456},0,1,20,2,1346}, {1,{19434},2,1,20,3,1345}, {2,{34948,34949},0,1,20,4,1819},
{3,{19464,19465,19466},0,1,25,2,1348}, {5,{19416,19417,19418,19419,19420},0,1,25,3,1342},
{2,{35100,35102},0,1,30,1,1351}, {1,{23989},2,1,30,2,1353}, {3,{19461,19462,24691},0,1,30,3,1347},
{2,{34475,34476},0,1,35,1,1804}, {3,{19507,19508,19509},0,1,35,4,1362},
{3,{53234,53237,53238},0,1,40,1,2130}, {1,{19506},2,1,40,2,1361}, {3,{35104,35110,35111},0,1,40,3,1821},
{5,{34485,34486,34487,34488,34489},0,1,45,2,1807}, {2,{53228,53232},0,1,45,3,2131},
{3,{53215,53216,53217},0,1,50,1,2132}, {1,{34490},2,1,50,2,1808}, {3,{53221,53222,53224},0,1,50,3,2133},
{5,{53241,53243,53244,53245,53246},0,1,55,2,2134},
{1,{53209},3,1,60,2,2135}}
hunter_marksmanship_talents_tab = 24
hunter_survival_spells = {{2973, 2, 0, 1}, {1494, 2, 0, 2}, {19883, 2, 0, 10}, {2974, 2, 0, 12}, {13795, 2, 0, 16},
{1495, 2, 0, 16}, {19884, 1, 0, 18}, {1499, 2, 0 ,20}, {781, 2, 0, 20}, {19885, 2, 0, 24}, {13809, 2, 0, 28},
{19880, 1, 0, 28}, {5384, 2, 0, 30}, {19878, 2, 0, 32}, {13813, 2, 0, 34}, {19882, 1, 0, 40}, {19879, 2, 0, 50},
{19263, 2, 0, 60}, {34600, 2, 0, 68}, {34477, 2, 0, 70}, {60192, 2, 0, 80}}
hunter_survival_spells_count = 21
hunter_survival_bgs = {"Interface\\TalentFrame\\HunterSurvival-TopLeft", "Interface\\TalentFrame\\HunterSurvival-TopRight",
"Interface\\TalentFrame\\HunterSurvival-BottomLeft", "Interface\\TalentFrame\\HunterSurvival-BottomRight"}
hunter_survival_talents = {{5,{52783,52785,52786,52787,52788},0,1,10,1,1623}, {3,{19498,19499,19500},0,1,10,2,1820}, {2,{19159,19160},0,1,10,3,1621},
{3,{19290,19294,24283},0,1,15,1,1310}, {3,{19184,19387,19388},0,1,15,2,1304}, {3,{19376,63457,63458},0,1,15,3,1305}, {2,{34494,34496},0,1,15,4,1810},
{5,{19255,19256,19257,19258,19259},0,1,20,1,1622}, {1,{19503},2,1,20,2,1814}, {3,{19295,19297,19298},0,1,20,3,1311}, {2,{19286,19287},0,1,20,4,1309},
{3,{56333,56336,56337},0,1,25,2,2229}, {3,{56342,56343,56344},0,1,25,4,1306},
{3,{56339,56340,56341},0,1,30,1,2228}, {3,{19370,19371,19373},0,1,30,2,1321}, {1,{19306},2,1,30,3,1312},
{5,{19168,19180,19181,24296,24297},0,1,35,1,1303}, {3,{34491,34492,34493},0,1,35,3,1809},
{3,{34500,34502,34503},0,1,40,1,1812}, {1,{19386},2,1,40,2,1325}, {3,{34497,34498,34499},0,1,40,3,1811},
{5,{34506,34507,34508,34838,34839},0,1,45,1,1813}, {3,{53295,53296,53297},0,1,45,2,2141},
{2,{53298,53299},0,1,50,1,2142}, {1,{3674},2,1,50,2,1322}, {3,{53302,53303,53304},0,1,50,4,2143},
{3,{53290,53291,53292},0,1,55,3,2144},
{1,{53301},3,1,60,2,2145}}
hunter_survival_talents_tab = 23

View File

@@ -0,0 +1,78 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
mage_arcane_spells = {{1459, 2, 0, 1}, {5504, 2, 0, 4}, {587, 2, 0, 6}, {5143, 2, 0, 8}, {118, 2, 0, 8},
{475, 2, 0, 10}, {604, 2, 0, 12}, {130, 2, 0, 12}, {1449, 2, 0, 14}, {1008, 2, 0, 18}, {1463, 2, 0, 20},
{1953, 2, 0, 20}, {818045, 2, 0, 20}, {12051, 2, 0, 20}, {2139, 2, 0, 24}, {759, 2, 0, 28}, {6117, 2, 0, 34},
{30451, 2, 0, 64}, {66, 2, 0, 68}, {43987, 2, 0, 70}, {30449, 2, 0, 70}, {55342, 2, 0, 80}}
mage_arcane_spells_count = 22
mage_arcane_bgs = {"Interface\\TalentFrame\\MageArcane-TopLeft", "Interface\\TalentFrame\\MageArcane-TopRight",
"Interface\\TalentFrame\\MageArcane-BottomLeft", "Interface\\TalentFrame\\MageArcane-BottomRight"}
mage_arcane_talents = {{2,{11210,12592},0,1,10,1,74}, {3,{11222,12839,12840},0,1,10,2,76}, {5,{11237,12463,12464,16769,16770},0,1,10,3,80},
{3,{28574,54658,54659},0,1,15,1,85}, {2,{29441,29444},0,1,15,2,1650}, {5,{11213,12574,12575,12576,12577},0,1,15,3,75},
{2,{11247,12606},0,1,20,1,82}, {3,{11242,12467,12469},0,1,20,2,81}, {3,{44397,44398,44399},0,1,20,3,1845}, {1,{54646},2,1,20,4,2211},
{2,{11252,12605},0,1,25,1,83}, {2,{11255,12598},0,1,25,2,88}, {3,{18462,18463,18464},0,1,25,3,1142}, {3,{29447,55339,55340},0,1,25,4,2222},
{2,{31569,31570},0,1,30,1,1724}, {1,{12043},2,1,30,2,86}, {5,{11232,12500,12501,12502,12503},0,1,30,4,77},
{3,{31574,31575,54354},0,1,35,1,1726}, {3,{15058,15059,15060},0,1,35,2,421}, {2,{31571,31572},0,1,35,3,1725},
{3,{31579,31582,31583},0,1,40,1,1727}, {1,{12042},2,1,40,2,87}, {0,{0,0,0},0,0,40,3,1844},
{2,{44378,44379},0,1,45,2,1843}, {5,{31584,31585,31586,31587,31588},0,1,45,3,1728},
{1,{31589},2,1,50,2,1729}, {5,{44404,54486,54488,54489,54490},0,1,50,3,2209},
{3,{44400,44402,44403},0,1,55,2,1846}, {2,{35578,35581},0,1,55,3,1826},
{1,{44425},3,1,60,2,1847}}
--{3,{44394,44395,44396},0,1,40,3,1844} Incanters
mage_arcane_talents_tab = 3
mage_fire_spells = {{133, 2, 0, 1}, {2136, 2, 0, 6}, {2120, 2, 0, 16}, {543, 2, 0, 20}, {2948, 2, 0, 22},
{30482, 2, 0, 62}, {44614, 2, 0, 75}}
mage_fire_spells_count = 7
mage_fire_bgs = {"Interface\\TalentFrame\\MageFire-TopLeft", "Interface\\TalentFrame\\MageFire-TopRight",
"Interface\\TalentFrame\\MageFire-BottomLeft", "Interface\\TalentFrame\\MageFire-BottomRight"}
mage_fire_talents = {{2,{11078,11080},0,1,10,1,27}, {3,{18459,18460,54734},0,1,10,2,1141}, {5,{11069,12338,12339,12340,12341},0,1,10,3,26},
{5,{11119,11120,12846,12847,12848},0,1,15,1,34}, {2,{54747,54749},0,1,15,2,2212}, {3,{11108,12349,12350},0,1,15,3,31},
{2,{11100,12353},0,1,20,1,28}, {3,{11103,12357,12358},0,1,20,2,30}, {1,{11366},2,1,20,3,29}, {2,{11083,12351},0,1,20,4,23},
{3,{11095,12872,12873},0,1,25,1,25}, {2,{11094,13043},0,1,25,2,24}, {3,{29074,29075,29076},0,1,25,4,1639},
{3,{31638,31639,31640},0,1,30,1,1730}, {3,{11115,11367,11368},0,1,30,2,33}, {1,{11113},2,1,30,3,32},
{2,{31641,31642},0,1,35,1,1731}, {5,{11124,12378,12398,12399,12400},0,1,35,3,35},
{3,{34293,34295,34296},0,1,40,1,1733}, {1,{11129},2,1,40,2,36}, {2,{31679,31680},0,1,40,3,1732},
{2,{64353,64357},0,1,45,1,1848}, {3,{31656,31657,31658},0,1,45,3,1734},
{2,{44442,44443},0,1,50,1,1849}, {1,{31661},2,1,50,2,1735}, {3,{44445,44446,44448},0,1,50,3,1850},
{5,{44449,44469,44470,44471,44472},0,1,55,2,1851},
{1,{44457},3,1,60,2,1852}}
mage_fire_talents_tab = 1
mage_frost_spells = {{168, 2, 0, 1}, {116, 2, 0, 4}, {122, 2, 0, 10}, {10, 2, 0, 20}, {6143, 2, 0, 22},
{120, 2, 0, 26}, {45438, 2, 0, 30}, {30455, 2, 0, 66}}
mage_frost_spells_count = 8
mage_frost_bgs = {"Interface\\TalentFrame\\MageFrost-TopLeft", "Interface\\TalentFrame\\MageFrost-TopRight",
"Interface\\TalentFrame\\MageFrost-BottomLeft", "Interface\\TalentFrame\\MageFrost-BottomRight"}
mage_frost_talents = {{3,{11071,12496,12497},0,1,10,1,38}, {5,{11070,12473,16763,16765,16766},0,1,10,2,37}, {3,{31670,31672,55094},0,1,10,3,62},
{3,{11207,12672,15047},0,1,15,1,73}, {2,{11189,28332},0,1,15,2,70}, {3,{29438,29439,29440},0,1,15,3,1649}, {3,{11175,12569,12571},0,1,15,4,65},
{3,{11151,12952,12953},0,1,20,1,61}, {1,{12472},2,1,20,2,69}, {3,{11185,12487,12488},0,1,20,3,63},
{2,{16757,16758},0,1,25,1,741}, {3,{11160,12518,12519},0,1,25,2,66}, {3,{11170,12982,12983},0,1,25,3,67},
{1,{11958},2,1,30,2,72}, {3,{11190,12489,12490},0,1,30,3,64}, {3,{31667,31668,31669},0,1,30,4,1736},
{2,{55091,55092},0,1,35,1,1737}, {3,{11180,28592,28593},0,1,35,3,68},
{2,{44745,54787},0,1,40,1,2214}, {1,{11426},2,1,40,2,71}, {5,{31674,31675,31676,31677,31678},0,1,40,3,1738},
{3,{31682,31683,31684},0,1,45,2,1740}, {2,{44543,44545},0,1,45,3,1853},
{3,{44546,44548,44549},0,1,50,1,1854}, {1,{31687},2,1,50,2,1741}, {3,{44557,44560,44561},0,1,50,3,1855},
{5,{44566,44567,44568,44570,44571},0,1,55,2,1856},
{1,{44572},3,1,60,2,1857}}
mage_frost_talents_tab = 2

View File

@@ -0,0 +1,78 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
paladin_holy_spells = {{635, 2, 0, 1}, {20154, 2, 0, 1}, {1152, 2, 0, 8}, {633, 2, 0, 10}, {7328, 2, 0, 12}, {19742, 2, 0, 14},
{26573, 2, 0, 20}, {879, 2, 0, 20}, {19750, 2, 0, 20}, {5502, 1, 0 ,20}, {19746, 2, 0, 22}, {10326, 2, 0, 24},
{20165, 2, 0, 30}, {20166, 2, 0, 38}, {4987, 2, 0, 42}, {2812, 2, 0, 50}, {54428, 2, 0, 71},
{53601, 2, 0, 80}}
paladin_holy_spells_count = 18
paladin_holy_bgs = {"Interface\\TalentFrame\\PaladinHoly-TopLeft", "Interface\\TalentFrame\\PaladinHoly-TopRight",
"Interface\\TalentFrame\\PaladinHoly-BottomLeft", "Interface\\TalentFrame\\PaladinHoly-BottomRight"}
paladin_holy_talents = {{5,{20205,20206,20207,20209,20208},0,1,10,2,1432}, {5,{20224,20225,20330,20331,20332},0,1,10,3,1463},
{3,{20237,20238,20239},0,1,15,1,1444}, {5,{20257,20258,20259,20260,20261},0,1,15,2,1449}, {2,{9453,25836},0,1,15,3,1628},
{1,{31821},2,1,20,1,1435}, {5,{20210,20212,20213,20214,20215},0,1,20,2,1461}, {2,{20234,20235},0,1,20,3,1443},
{3,{20254,20255,20256},0,1,25,1,1450}, {2,{20244,20245},0,1,25,3,1446}, {2,{53660,53661},0,1,25,4,2198},
{2,{31822,31823},0,1,30,1,1742}, {1,{20216},2,1,30,2,1433}, {3,{20359,20360,20361},0,1,30,3,1465},
{2,{31825,31826},0,1,35,1,1743}, {5,{5923,5924,5925,5926,25829},0,1,35,3,1627},
{3,{31833,31835,31836},0,1,40,1,1745}, {1,{20473},2,1,40,2,1502}, {3,{31828,31829,31830},0,1,40,3,1744},
{3,{53551,53552,53553},0,1,45,1,2190}, {5,{31837,31838,31839,31840,31841},0,1,45,3,1746},
{1,{31842},2,1,50,1,1747}, {5,{53671,53673,54151,54154,54155},0,1,50,3,2199},
{2,{53569,53576},0,1,55,2,2193}, {2,{53556,53557},0,1,55,3,2191},
{1,{53563},3,1,60,2,2192}}
paladin_holy_talents_tab = 26
paladin_retribution_spells = {{19740, 2, 0, 4}, {20271, 2, 0 ,4}, {53408, 2, 0, 12}, {7294, 2, 0, 16}, {53407, 2, 0, 28},
{24275, 2, 0, 44}, {32223, 2, 0, 62}, {31801, 2, 0, 64}, {31884, 2, 0, 70}}
paladin_retribution_spells_count = 9
paladin_retribution_bgs = {"Interface\\TalentFrame\\Paladincombat-TopLeft", "Interface\\TalentFrame\\Paladincombat-TopRight",
"Interface\\TalentFrame\\Paladincombat-BottomLeft", "Interface\\TalentFrame\\Paladincombat-BottomRight"}
paladin_retribution_talents = {{5,{20060,20061,20062,20063,20064},0,1,10,2,1403}, {5,{20101,20102,20103,20104,20105},0,1,10,3,1407},
{2,{25956,25957},0,1,15,1,1631}, {3,{20335,20336,20337},0,1,15,2,1464}, {2,{20042,20045},0,1,15,3,1401},
{2,{9452,26016},0,1,20,1,1633}, {5,{20117,20118,20119,20120,20121},0,1,20,2,1411}, {1,{20375},2,1,20,3,1481}, {2,{26022,26023},0,1,20,4,1634},
{2,{9799,25988},0,1,25,1,1632}, {3,{32043,35396,35397},0,1,25,3,1761}, {3,{31866,31867,31868},0,1,25,4,1755},
{3,{20111,20112,20113},0,1,30,1,1410}, {1,{31869},1,1,30,3,1756},
{3,{20049,20056,20057},0,1,35,2,1402}, {2,{31871,31872},0,1,35,3,1757},
{2,{53486,53488},0,1,40,1,2176}, {1,{20066},2,1,40,2,1441}, {3,{31876,31877,31878},0,1,40,3,1758},
{3,{31879,31880,31881},0,1,45,2,1759}, {2,{53375,53376},0,1,45,3,2147},
{3,{53379,53484,53648},0,1,50,1,2148}, {1,{35395},2,1,50,2,1823}, {5,{53501,53502,53503,853504,853505},0,1,50,3,2179},
{3,{53380,53381,53382},0,1,55,2,2149},
{1,{53385},3,1,60,2,2150}}
paladin_retribution_talents_tab = 25
paladin_protection_spells = {{465, 2, 0, 1}, {498, 2, 0, 6}, {853, 2, 0, 8}, {1022, 2, 0, 10}, {31789, 2, 0, 14},
{62124, 2, 0, 16}, {25780, 2, 0, 16}, {1044, 2, 0, 18}, {20217, 2, 0, 20}, {20164, 2, 0, 22}, {1038, 2, 0, 26},
{19876, 2, 0, 28}, {19752, 2, 0, 30}, {19888, 2, 0, 32}, {642, 2, 0, 34}, {19891, 2, 0, 36}, {6940, 2, 0, 46}, {53600, 2, 0, 75}}
paladin_protection_spells_count = 18
paladin_protection_bgs = {"Interface\\TalentFrame\\PaladinProtection-TopLeft", "Interface\\TalentFrame\\PaladinProtection-TopRight",
"Interface\\TalentFrame\\PaladinProtection-BottomLeft", "Interface\\TalentFrame\\PaladinProtection-BottomRight"}
paladin_protection_talents = {{5,{63646,63647,63648,63649,63650},0,1,10,2,1442}, {5,{20262,20263,20264,20265,20266},0,1,10,3,2185},
{3,{31844,31845,53519},0,1,15,1,1748}, {2,{20174,20175},0,1,15,2,1425}, {5,{20096,20097,20098,20099,20100},0,1,15,3,1629},
{1,{64205},2,1,20,1,2280}, {3,{20468,20469,20470},0,1,20,2,1501}, {5,{20143,20144,20145,20146,20147},0,1,20,3,1423},
{2,{53527,53530},0,1,25,1,2281}, {2,{20487,20488},0,1,25,2,1521}, {3,{20138,20139,20140},0,1,25,3,1422},
{1,{20911},2,1,30,2,1431}, {5,{20177,20179,20181,20180,20182},0,1,30,3,1426},
{2,{31848,31849},0,1,35,1,1750}, {3,{20196,20197,20198},0,1,35,3,1429},
{2,{31785,33776},0,1,40,1,2282}, {1,{20925},2,1,40,2,1430}, {3,{31850,31851,31852},0,1,40,3,1751},
{3,{20127,20130,20135},0,1,45,1,1421}, {3,{31858,31859,31860},0,1,45,3,1753},
{3,{53590,53591,53592},0,1,50,1,2195}, {1,{31935},2,1,50,2,1754}, {2,{53583,53585},0,1,50,3,2194},
{3,{53709,53710,53711},0,1,55,2,2204}, {2,{53695,53696},0,1,55,3,2200},
{1,{53595},3,1,60,2,2196}}
paladin_protection_talents_tab = 27

View File

@@ -0,0 +1,75 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
priest_discipline_spells = {{1243, 2, 0, 1}, {17, 2, 0, 6}, {588, 2, 0, 12}, {527, 2, 0, 18}, {9484, 2, 0, 20},
{6346, 2, 0, 20}, {8129, 2, 0, 24}, {14752, 2, 0, 30}, {1706, 2, 0, 34}, {32375, 2, 0, 70}, {64901, 2, 0, 80}}
priest_discipline_spells_count = 11
priest_discipline_bgs = {"Interface\\TalentFrame\\PriestDiscipline-TopLeft", "Interface\\TalentFrame\\PriestDiscipline-TopRight",
"Interface\\TalentFrame\\PriestDiscipline-BottomLeft", "Interface\\TalentFrame\\PriestDiscipline-BottomRight"}
priest_discipline_talents = {{5,{14522,14788,14789,14790,14791},0,1,10,2,342},{5,{47586,47587,47588,52802,52803},0,1,10,3,1898},
{3,{14523,14784,14785},0,1,15,1,352}, {3,{14747,14770,14771},0,1,15,2,346}, {2,{14749,14767},0,1,15,3,344}, {2,{14531,14774},0,1,15,4,321},
{3,{14521,14776,14777},0,1,20,1,347}, {1,{14751},2,1,20,2,348}, {3,{14748,14768,14769},0,1,20,3,343},
{3,{33167,33171,33172},0,1,25,1,1769}, {3,{14520,14780,14781},0,1,25,2,341}, {2,{14750,14772},0,1,25,4,350},
{2,{33201,33202},0,1,30,1,2268}, {5,{18551,18552,18553,18554,18555},0,1,30,2,1201}, {1,{63574},1,1,30,3,351},
{2,{33186,33190},0,1,35,1,1771}, {3,{34908,34909,34910},0,1,35,3,1772},
{3,{45234,45243,45244},0,1,40,1,1858}, {1,{10060},2,1,40,2,322}, {3,{63504,63505,63506},0,1,40,3,1773},
{2,{57470,57472},0,1,45,1,2235}, {3,{47535,47536,47537},0,1,45,2,1896}, {2,{47507,47508},0,1,45,3,1894},
{3,{47509,47511,47515},0,1,50,1,1895}, {1,{33206},2,1,50,2,1774}, {2,{47516,47517},0,1,50,3,1901},
{5,{52795,52797,52798,52799,52800},0,1,55,2,1202},
{1,{47540},3,1,60,2,1897}}
priest_discipline_talents_tab = 10
priest_holy_spells = {{2050, 2, 0, 1}, {585, 2, 0, 1}, {139, 2, 0, 8}, {2006, 2, 0, 10}, {528, 2, 0, 14},
{2054, 2, 0, 16}, {2061, 2, 0, 20}, {14914, 2, 0, 20}, {15237, 2, 0, 20}, {596, 2, 0, 30},
{552, 2, 0, 32}, {2060, 2, 0, 40}, {32546, 2, 0, 64}, {33076, 2, 0, 68}, {64843, 2, 0, 80}}
priest_holy_spells_count = 15
priest_holy_bgs = {"Interface\\TalentFrame\\PriestHoly-TopLeft", "Interface\\TalentFrame\\PriestHoly-TopRight",
"Interface\\TalentFrame\\PriestHoly-BottomLeft", "Interface\\TalentFrame\\PriestHoly-BottomRight"}
priest_holy_talents = {{2,{14913,15012},0,1,10,1,410}, {3,{14908,15020,17191},0,1,10,2,406}, {5,{14889,15008,15009,15010,15011},0,1,10,3,401},
{5,{27900,27901,27902,27903,27904},0,1,15,2,411}, {5,{18530,18531,18533,18534,18535},0,1,15,3,1181},
{1,{19236},2,1,20,1,442}, {3,{27811,27815,27816},0,1,20,2,1636}, {3,{14892,15362,15363},0,1,20,4,361},
{2,{27789,27790},0,1,25,1,1635}, {3,{14912,15013,15014},0,1,25,2,408}, {5,{14909,15017,150171,150172,150173},0,1,25,3,403},
{2,{14911,15018},0,1,30,1,413}, {1,{20711},1,1,30,2,1561}, {5,{14901,15028,15029,15030,15031},0,1,30,3,402},
{2,{33150,33154},0,1,35,1,1766}, {5,{14898,15349,15354,15355,15356},0,1,35,3,404},
{3,{34753,34859,34860},0,1,40,1,1768}, {1,{724},2,1,40,2,1637}, {3,{33142,33145,33146},0,1,40,3,1765},
{2,{64127,64129},0,1,45,1,2279}, {5,{33158,33159,33160,33161,33162},0,1,45,2,1767}, {3,{63730,63733,63737},0,1,45,3,1904},
{3,{63534,63542,63543},0,1,50,1,1902}, {1,{34861},2,1,50,2,1815}, {3,{47558,47559,47560},0,1,50,3,1903},
{5,{47562,47564,47565,47566,47567},0,1,55,2,1905},
{1,{47788},3,1,60,2,1911}}
priest_holy_talents_tab = 11
priest_shadow_spells = {{589, 2, 0, 4}, {586, 2, 0, 8}, {8092, 2, 0, 10}, {8122, 2, 0, 10}, {2944, 2, 0, 20},
{453, 1, 0, 20}, {2096, 2, 0, 22}, {976, 2, 0, 30}, {605, 2, 0, 30}, {32379, 2, 0, 62},
{34433, 2, 0, 66}, {48045, 2, 0, 75}}
priest_shadow_spells_count = 12
priest_shadow_bgs = {"Interface\\TalentFrame\\PriestShadow-TopLeft", "Interface\\TalentFrame\\PriestShadow-TopRight",
"Interface\\TalentFrame\\PriestShadow-BottomLeft", "Interface\\TalentFrame\\PriestShadow-BottomRight"}
priest_shadow_talents = {{3,{15270,15335,15336},0,1,10,1,465}, {2,{15337,15338},0,1,10,2,2027}, {5,{15259,15307,15308,15309,15310},0,1,10,3,462},
{3,{15318,15272,15320},0,1,15,1,466}, {2,{15275,15317},0,1,15,2,482}, {3,{15260,15327,15328},0,1,15,3,463},
{2,{15392,15448},0,1,20,1,542}, {5,{15273,15312,15313,15314,15316},0,1,20,2,481}, {1,{15407},2,1,20,3,501},
{2,{15274,15311},0,1,25,2,483}, {2,{17322,17323},0,1,25,3,881}, {3,{15257,15331,15332},0,1,25,4,461},
{1,{15487},2,1,30,1,541}, {1,{15286},2,1,30,2,484}, {2,{27839,27840},0,1,30,3,1638}, {3,{33213,33214,33215},0,1,30,4,1777},
{2,{14910,33371},0,1,35,1,1781}, {3,{63625,63626,63627},0,1,35,3,2267},
{1,{15473},2,1,40,2,521}, {5,{33221,33222,33223,33224,33225},0,1,40,3,1778},
{2,{47569,47570},0,1,45,1,1906}, {3,{33191,33192,33193},0,1,45,3,1816},
{1,{64044},2,1,50,1,1908}, {1,{34914},2,1,50,2,1779}, {3,{47580,47581,47582},0,1,50,3,1909},
{5,{47573,47577,47578,51166,51167},0,1,55,3,1907},
{1,{47585},3,1,60,2,1910}}
priest_shadow_talents_tab = 12

View File

@@ -0,0 +1,72 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
rogue_assassination_spells = {{2098, 2, 0, 1}, {5171, 2, 0, 10}, {8647, 2, 0, 14}, {703, 2, 0, 14}, {8676, 2, 0, 18},
{1943, 2, 0, 20}, {2842, 2, 0, 20}, {1833, 2, 0, 26}, {408, 2, 0, 30}, {32645, 2, 0, 62}, {26679, 2, 0, 64}, {51722, 2, 0, 80}}
rogue_assassination_spells_count = 12
rogue_assassination_bgs = {"Interface\\TalentFrame\\RogueAssassination-TopLeft", "Interface\\TalentFrame\\RogueAssassination-TopRight",
"Interface\\TalentFrame\\RogueAssassination-BottomLeft", "Interface\\TalentFrame\\RogueAssassination-BottomRight"}
rogue_assassination_talents = {{3,{14162,14163,14164},0,1,10,1,276}, {2,{14144,14148},0,1,10,2,272}, {5,{14138,14139,14140,14141,14142},0,1,10,3,270},
{3,{14156,14160,14161},0,1,15,1,273}, {2,{51632,51633},0,1,15,2,2068}, {3,{13733,13865,13866},0,1,15,4,277},
{1,{14983},1,1,20,1,382}, {2,{14168,14169},0,1,20,2,278}, {5,{14128,14132,14135,14136,14137},0,1,20,3,269},
{3,{16513,16514,16515},0,1,25,2,682}, {5,{14113,14114,14115,14116,14117},0,1,25,3,268},
{3,{31208,31209,312090},0,1,30,1,1721}, {1,{14177},2,1,30,2,280}, {3,{14174,14175,14176},0,1,30,3,279}, {2,{31244,31245},0,1,30,4,1762},
{5,{14186,14190,14193,14194,14195},0,1,35,2,283}, {2,{14158,14159},0,1,35,3,274},
{2,{51625,51626},0,1,40,1,2065}, {1,{58426},1,1,40,2,281}, {3,{31380,31382,31383},0,1,40,3,1723},
{3,{51634,51635,51636},0,1,45,1,2069}, {3,{31234,31235,31236},0,1,45,3,1718},
{3,{31226,31227,58410},0,1,50,1,1715}, {1,{1329},2,1,50,2,1719}, {3,{51627,51628,51629},0,1,50,3,2066},
{5,{51664,51665,51667,51668,51669},0,1,55,2,2070},
{1,{51662},3,1,60,2,2071}}
rogue_assassination_talents_tab = 8
rogue_combat_spells = {{1752, 2, 0, 1}, {53, 2, 0, 4}, {1776, 2, 0, 6}, {5277, 2, 0, 8}, {2983, 2, 0, 10},
{1766, 2, 0, 12}, {1966, 2, 0, 16}, {5938, 2, 0, 70}, {51723, 2, 0, 80}}
rogue_combat_spells_count = 9
rogue_combat_bgs = {"Interface\\TalentFrame\\RogueCombat-TopLeft", "Interface\\TalentFrame\\RogueCombat-TopRight",
"Interface\\TalentFrame\\RogueCombat-BottomLeft", "Interface\\TalentFrame\\RogueCombat-BottomRight"}
rogue_combat_talents = {{3,{13741,13793,13792},0,1,10,1,203},{2,{13732,13863},0,1,10,2,201},{5,{13715,13848,13849,13851,13852},0,1,10,3,221},
{2,{14165,14166},0,1,15,1,1827}, {3,{13713,13853,13854},0,1,15,2,187}, {5,{13705,13832,13843,13844,13845},0,1,15,4,181},
{2,{13742,13872},0,1,20,1,204}, {1,{14251},2,1,20,2,301}, {5,{13706,13804,13805,13806,13807},0,1,20,3,182},
{2,{13754,13867},0,1,25,1,206}, {2,{13743,13875},0,1,25,2,222}, {3,{13712,13788,13789},0,1,25,3,186}, {5,{18427,18428,18429,61330,61331},0,1,25,4,1122},
{5,{13709,13800,13801,13802,13803},0,1,30,1,184}, {1,{13877},2,1,30,2,223}, {5,{13960,13961,13962,13963,13964},0,1,30,3,242},
{2,{30919,30920},0,1,35,2,1703}, {2,{31124,31126},0,1,35,3,1706},
{3,{31122,31123,61329},0,1,40,1,1705}, {1,{13750},2,1,40,2,205}, {2,{31130,31131},0,1,40,3,1707},
{2,{5952,51679},0,1,45,1,2072}, {5,{35541,35550,35551,35552,35553},0,1,45,3,1825},
{2,{51672,51674},0,1,50,1,2073}, {1,{32601},1,1,50,2,1709}, {2,{51682,58413},0,1,50,3,2074},
{5,{51685,51686,51687,51688,51689},0,1,55,2,2075},
{1,{51690},3,1,60,2,2076}}
rogue_combat_talents_tab = 7
rogue_subtlety_spells = {{1784, 2, 0, 1}, {921, 2, 0, 4}, {6770, 2, 0, 10}, {1725, 2, 0, 10}, {1804, 2, 0, 10}, {2836, 1, 0, 24},
{1856, 2, 0, 35}, {1842, 1, 0, 30}, {2094, 2, 0, 34}, {1860, 1, 0, 40}, {31224, 2, 0, 66}, {57934, 2, 0, 80}}
rogue_subtlety_spells_count = 12
rogue_subtlety_bgs = {"Interface\\TalentFrame\\RogueSubtlety-TopLeft", "Interface\\TalentFrame\\RogueSubtlety-TopRight",
"Interface\\TalentFrame\\RogueSubtlety-BottomLeft", "Interface\\TalentFrame\\RogueSubtlety-BottomRight"}
rogue_subtlety_talents = {{5,{14179,58422,58423,58424,58425},0,1,10,1,2244}, {5,{13958,13970,13971,813972,813973},0,1,10,2,241}, {2,{14057,14072},0,1,10,3,261},
{2,{30892,30893},0,1,15,1,1700}, {2,{14076,14094},0,1,15,2,262}, {3,{13975,14062,14063},0,1,15,3,244},
{2,{13981,14066},0,1,20,1,247}, {1,{14278},2,1,20,2,303}, {3,{14171,14172,14173},0,1,20,3,1123},
{3,{13983,14070,14071},0,1,25,1,246}, {3,{13976,13979,13980},0,1,25,2,245}, {2,{14079,14080},0,1,25,3,263},
{2,{30894,30895},0,1,30,1,1701}, {1,{14185},2,1,30,2,284}, {2,{14082,14083},0,1,30,3,265}, {1,{16511},2,1,30,4,681},
{3,{31221,31222,31223},0,1,35,1,1713}, {5,{30902,30903,30904,30905,30906},0,1,35,3,1702},
{3,{31211,31212,31213},0,1,40,1,1711}, {1,{14183},2,1,40,2,381}, {3,{31228,31229,31230},0,1,40,3,1722},
{5,{31216,31217,31218,31219,31220},0,1,45,2,1712}, {2,{51692,51696},0,1,45,3,2077},
{3,{51698,51700,51701},0,1,50,1,2078}, {1,{36554},2,1,50,2,1714}, {2,{58414,58415},0,1,50,3,2079},
{5,{51708,51709,51710,51711,51712},0,1,55,2,2080},
{1,{51713},3,1,60,2,2081}}
rogue_subtlety_talents_tab = 9

View File

@@ -0,0 +1,77 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
shaman_elemental_spells = {{403, 2, 0, 1}, {8042, 2, 0, 4}, {2484, 2, 0, 6}, {5730, 2, 0, 8}, {8050, 2, 0, 10},
{3599, 2, 0, 10}, {1535, 2, 0, 12}, {370, 2, 0, 12}, {57994, 2, 0, 16}, {8056, 2, 0, 20}, {8190, 2, 0, 26},
{66842, 2, 0, 30}, {421, 2, 0, 32}, {66843, 2, 0, 40}, {66844, 2, 0, 50}, {2894, 2, 0, 68}, {51505, 2, 0, 75},
{51514, 2, 0, 80}}
shaman_elemental_spells_count = 18
shaman_elemental_bgs = {"Interface\\TalentFrame\\ShamanElementalcombat-TopLeft", "Interface\\TalentFrame\\ShamanElementalcombat-TopRight",
"Interface\\TalentFrame\\ShamanElementalcombat-BottomLeft", "Interface\\TalentFrame\\ShamanElementalcombat-BottomRight"}
shaman_elemental_talents = {{5,{16039,16109,16110,16111,16112},0,1,10,2,564}, {5,{16035,16105,16106,16107,16108},0,1,10,3,563},
{3,{16038,16160,16161},0,1,15,1,561}, {3,{28996,28997,28998},0,1,15,2,1640}, {3,{30160,29179,29180},0,1,15,3,1645},
{5,{16040,16113,16114,16115,16116},0,1,20,1,575}, {1,{16164},1,1,20,2,574}, {5,{16089,60184,60185,60187,60188},0,1,20,3,565},
{2,{16086,16544},0,1,25,1,567}, {3,{29062,29064,29065},0,1,25,4,1642},
{2,{28999,29000},0,1,30,1,1641}, {1,{16041},1,1,30,2,562}, {3,{30664,30665,30666},0,1,30,4,1682},
{3,{30672,30673,30674},0,1,35,1,1685}, {5,{16578,16579,16580,16581,16582},0,1,35,3,721},
{1,{16166},2,1,40,2,573}, {3,{51483,51485,51486},0,1,40,3,2052},
{2,{63370,63372},0,1,45,1,2262}, {2,{51466,51470},0,1,45,2,2049}, {3,{30675,30678,30679},0,1,45,3,1686},
{3,{51474,51478,51479},0,1,50,1,2050}, {1,{30706},2,1,50,2,1687}, {3,{51480,51481,51482},0,1,50,3,2051},
{5,{62097,62098,62099,62100,62101},0,1,55,2,2252},
{1,{51490},3,1,60,2,2053}}
shaman_elemental_talents_tab = 13
shaman_enhancement_spells = {{8017, 2, 0, 1}, {8071, 2, 0, 4}, {324, 2, 0, 8}, {8024, 2, 0, 10}, {8075, 2, 0, 10},
{2645, 2, 0, 20}, {8033, 2, 0, 20}, {131, 1, 0, 22}, {8181, 2, 0, 24}, {6196, 2, 0, 26}, {8184, 2, 0, 28},
{8227, 2, 0, 28}, {546, 1, 0, 28}, {10595, 2, 0, 30}, {8232, 2, 0, 30}, {556, 2, 0, 30}, {8177, 2, 0, 30},
{8512, 2, 0, 32}, {6495, 2, 0, 34}, {3738, 2, 0, 64}, {2825, 2, 0, 70}, {32182, 2, 0, 70}, {2062, 2, 0, 80}}
shaman_enhancement_spells_count = 23
shaman_enhancement_bgs = {"Interface\\TalentFrame\\ShamanEnhancement-TopLeft", "Interface\\TalentFrame\\ShamanEnhancement-TopRight",
"Interface\\TalentFrame\\ShamanEnhancement-BottomLeft", "Interface\\TalentFrame\\ShamanEnhancement-BottomRight"}
shaman_enhancement_talents = {{3,{16259,16295,52456},0,1,10,1,610}, {2,{16043,16130},0,1,10,2,2101}, {5,{17485,17486,17487,17488,17489},0,1,10,3,614},
{2,{16258,16293},0,1,15,1,609}, {5,{16255,16302,16303,16304,16305},0,1,15,2,613}, {2,{16262,16287},0,1,15,3,605}, {3,{16261,16290,51881},0,1,15,4,607},
{3,{16266,29079,29080},0,1,20,1,611}, {1,{43338},1,1,20,3,617}, {3,{16254,16271,16272},0,1,20,4,601},
{5,{16256,16281,16282,16283,16284},0,1,25,2,602}, {5,{16252,16306,16307,16308,16309},0,1,25,3,615},
{2,{29192,29193},0,1,30,1,1647}, {3,{16268,18848,36591},0,1,30,2,616}, {3,{51883,51884,51885},0,1,30,3,2083},
{3,{30802,30808,30809},0,1,35,1,1689}, {3,{29082,29084,29086},0,1,35,3,1643}, {2,{63373,63374},0,1,35,4,2263},
{3,{30816,30818,30819},0,1,40,1,1692}, {0,{0},0,0,40,2,0}, {1,{17364},2,1,40,3,901},
{5,{51525,51526,51527,975065,975066},0,1,45,1,2055}, {1,{60103},2,1,45,2,2249}, {2,{51521,51522},0,1,45,3,2054},
{5,{30812,30813,30814,830815,830816},0,1,50,1,1691}, {1,{30823},2,1,50,2,1693}, {2,{51523,51524},0,1,50,3,2056},
{5,{51528,51529,51530,51531,51532},0,1,55,2,2057},
{1,{51533},3,1,60,2,2058}}
shaman_enhancement_talents_tab = 15
shaman_restoration_spells = {{331, 2, 0 , 1}, {2008, 2, 0, 12}, {526, 2, 0, 16}, {8143, 2, 0, 18}, {5394, 2, 0, 20},
{8004, 2, 0, 20}, {52127, 2, 0, 20}, {5675, 2, 0, 26}, {20608, 2, 0, 26}, {51730, 2, 0, 30}, {36936, 2, 0, 30}, {8170, 2, 0, 34},
{1064, 2, 0, 40}}
shaman_restoration_spells_count = 13
shaman_restoration_bgs = {"Interface\\TalentFrame\\ShamanRestoration-TopLeft", "Interface\\TalentFrame\\ShamanRestoration-TopRight",
"Interface\\TalentFrame\\ShamanRestoration-BottomLeft", "Interface\\TalentFrame\\ShamanRestoration-BottomRight"}
shaman_restoration_talents = {{5,{16182,16226,16227,16228,16229},0,1,10,2,586}, {5,{16173,16222,16223,16224,16225},0,1,10,3,595},
{2,{16184,16209},0,1,15,1,589}, {3,{29187,29189,29191},0,1,15,2,1646}, {5,{16179,16214,16215,16216,16217},0,1,15,3,593},
{3,{16180,16196,16198},0,1,20,1,583}, {3,{16181,16230,16232},0,1,20,2,587}, {1,{55198},2,1,20,3,582}, {3,{16176,16235,16240},0,1,20,4,581},
{3,{16187,16205,16206},0,1,25,2,588}, {5,{16194,16218,16219,16220,16221},0,1,25,3,594},
{3,{29206,29205,29202},0,1,30,1,1648}, {1,{16188},2,1,30,3,591}, {3,{30864,30865,30866},0,1,30,4,1695},
{5,{16178,16210,16211,16212,16213},0,1,35,3,592},
{5,{30881,30883,30884,30885,30886},0,1,40,1,1699}, {1,{16190},2,1,40,2,590}, {1,{51886},2,1,40,3,2084},
{2,{51554,51555},0,1,45,1,2060}, {2,{30872,30873},0,1,45,2,1697}, {3,{30867,30868,30869},0,1,45,3,1696},
{3,{51556,51557,51558},0,1,50,1,2061}, {1,{974},2,1,50,2,1698}, {2,{51560,51561},0,1,50,3,2059},
{5,{51562,51563,51564,51565,51566},0,1,55,2,2063},
{1,{61295},3,1,60,2,2064}}
shaman_restoration_talents_tab = 14

View File

@@ -0,0 +1,77 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
warlock_affliction_spells = {{702, 2, 0, 4}, {172, 2, 0, 4}, {1454, 2, 0, 6}, {980, 2, 0, 8}, {5782, 2, 0, 8},
{1120, 2, 0, 10}, {689, 2, 0, 14}, {5138, 2, 0, 24}, {1714, 2, 0, 26}, {1490, 2, 0, 32}, {5484, 2, 0, 40},
{6789, 2, 0, 42}, {603, 2, 0, 60}, {27243, 2, 0, 70}}
warlock_affliction_spells_count = 14
warlock_affliction_bgs = {"Interface\\TalentFrame\\Warlockcurses-TopLeft", "Interface\\TalentFrame\\Warlockcurses-TopRight",
"Interface\\TalentFrame\\Warlockcurses-BottomLeft", "Interface\\TalentFrame\\Warlockcurses-BottomRight"}
warlock_affliction_talents = {{2,{18827,18829},0,1,10,1,1284}, {3,{18174,18175,18176},0,1,10,2,1005}, {5,{17810,17811,17812,17813,17814},0,1,10,3,1003},
{2,{18179,18180},0,1,15,1,1006}, {2,{18213,18372},0,1,15,2,1101}, {2,{18182,18183},0,1,15,3,1007}, {2,{17804,17805},0,1,15,4,1004},
{2,{53754,53759},0,1,20,1,2205}, {3,{17783,17784,17785},0,1,20,2,1001}, {1,{18288},1,1,20,3,1061},
{2,{18218,18219},0,1,25,1,1021}, {2,{18094,18095},0,1,25,2,1002}, {3,{32381,32382,32383},0,1,25,4,1764},
{5,{32385,32387,32392,32393,32394},0,1,30,1,1763}, {1,{63108},1,1,30,2,1041}, {1,{18223},2,1,30,3,1081},
{2,{54037,54038},0,1,35,1,1873}, {5,{18271,18272,18273,18274,18275},0,1,35,2,1042},
{3,{47195,47196,47197},0,1,40,1,1878}, {5,{30060,30061,30062,30063,30064},0,1,40,2,1669}, {1,{18220},2,1,40,3,1022},
{2,{30054,30057},0,1,45,1,1668}, {3,{32477,32483,32484},0,1,45,3,1667},
{3,{47198,47199,47200},0,1,50,1,1875}, {1,{30108},2,1,50,2,1670}, {1,{58435},1,1,50,3,2245},
{5,{47201,47202,47203,47204,47205},0,1,55,2,1876},
{1,{48181},3,1,60,2,2041}}
warlock_affliction_talents_tab = 20
warlock_demonology_spells = {{687, 2, 0, 1}, {688, 2, 0, 1}, {697, 2, 0, 10}, {6201, 2, 0, 10}, {755, 2, 0, 12},
{5697, 1, 0, 16}, {693, 2, 0, 18}, {698, 2, 0, 20}, {712, 2, 0, 20}, {126, 1, 0, 22},
{5500, 2, 0, 24}, {132, 2, 0, 26}, {710, 2, 0, 28}, {6366, 2, 0, 28}, {1098, 2, 0, 30}, {691, 2, 0, 30},
{6229, 2, 0, 32}, {2362, 2, 0, 36}, {1122, 2, 0, 50},
{18540, 2, 0, 60}, {28176, 2, 0, 62}, {29858, 2, 0, 66}, {29893, 2, 0, 68}, {48018, 2, 0, 80}, {48020, 2, 0, 80}}
warlock_demonology_spells_count = 25
warlock_demonology_bgs = {"Interface\\TalentFrame\\Warlocksummoning-TopLeft", "Interface\\TalentFrame\\Warlocksummoning-TopRight",
"Interface\\TalentFrame\\Warlocksummoning-BottomLeft", "Interface\\TalentFrame\\Warlocksummoning-BottomRight"}
warlock_demonology_talents = {{2,{18692,18693},0,1,10,1,1221}, {3,{18694,18695,18696},0,1,10,2,1222}, {3,{18697,18698,18699},0,1,10,3,1223}, {2,{47230,47231},0,1,10,4,1883},
{2,{18703,18704},0,1,15,1,1224}, {3,{18705,18706,18707},0,1,15,2,1225}, {3,{18731,18743,18744},0,1,15,3,1242},
{3,{18754,18755,18756},0,1,20,1,1243}, {1,{19028},2,1,20,2,1282}, {1,{18708},2,1,20,3,1226}, {3,{30143,30144,30145},0,1,20,4,1671},
{5,{18769,18770,18771,18772,18773},0,1,25,2,1262}, {2,{18709,18710},0,1,25,3,1227},
{1,{30326},1,1,30,1,1281}, {2,{18767,18768},0,1,30,3,1261},
{5,{23785,23822,23823,23824,23825},0,1,35,2,1244}, {3,{47245,47246,47247},0,1,35,3,1283},
{3,{30319,30320,30321},0,1,40,1,1680}, {1,{47193},2,1,40,2,1880}, {3,{35691,35692,35693},0,1,40,3,1263},
{5,{30242,30245,30246,30247,30248},0,1,45,2,1673}, {2,{63156,63158},0,1,45,3,2261},
{3,{54347,54348,54349},0,1,50,1,1882}, {1,{30146},2,1,50,2,1672}, {3,{63117,63121,63123},0,1,50,3,1884},
{5,{47236,47237,47238,47239,47240},0,1,55,2,1885},
{1,{59672},3,1,60,2,1886}}
warlock_demonology_talents_tab = 21
warlock_destruction_spells = {{686, 2, 0, 1}, {348, 2, 0, 6}, {5676, 2, 0, 18}, {5740, 2, 0, 20}, {1949, 2, 0, 30},
{6353, 2, 0, 48}, {29722, 2, 0, 64}, {47897, 2, 0, 75}}
warlock_destruction_spells_count = 8
warlock_destruction_bgs = {"Interface\\TalentFrame\\WarlockDestruction-TopLeft", "Interface\\TalentFrame\\WarlockDestruction-TopRight",
"Interface\\TalentFrame\\WarlockDestruction-BottomLeft", "Interface\\TalentFrame\\WarlockDestruction-BottomRight"}
warlock_destruction_talents = {{5,{17793,17796,17801,17802,17803},0,1,10,2,944}, {5,{17788,17789,17790,17791,17792},0,1,10,3,943},
{2,{18119,18120},0,1,15,1,982}, {3,{63349,63350,63351},0,1,15,2,1887}, {3,{17778,17779,17780},0,1,15,3,941},
{2,{18126,18127},0,1,20,1,983}, {1,{17877},2,1,20,2,963}, {5,{17959,59738,59739,59740,59741},0,1,20,3,967},
{2,{18135,18136},0,1,25,1,985}, {2,{17917,17918},0,1,25,2,964}, {3,{17927,17929,17930},0,1,25,4,965},
{3,{34935,34938,34939},0,1,30,1,1817}, {3,{17815,17833,17834},0,1,30,2,961}, {1,{18130},1,1,30,3,981},
{3,{30299,30301,30302},0,1,35,1,1679}, {5,{17954,17955,17956,17957,17958},0,1,35,3,966},
{1,{17962},2,1,40,2,968}, {3,{30293,30295,30296},0,1,40,3,1678}, {3,{18096,18073,63245},0,1,40,4,986},
{5,{30288,30289,30290,30291,30292},0,1,45,2,1677}, {2,{54117,54118},0,1,45,3,1889},
{3,{47258,47259,47260},0,1,50,1,1888}, {1,{30283},2,1,50,2,1676}, {3,{47220,47221,47223},0,1,50,3,2045},
{5,{47266,47267,47268,47269,47270},0,1,55,2,1890},
{1,{50796},3,1,60,2,1891}}
warlock_destruction_talents_tab = 19

View File

@@ -0,0 +1,77 @@
-- Documentation {5176, 2, 0, 1} {Spellid, Ability Essence, Talent Essence, Required Level}
-- Make sure to adjust Count if you add or subtract any spells
-- talent documentation {5,{16814,16814,16814,16814,16814},0,1,10,2,762} {number of ranks, {spellids}, AE cost, TE cost, required level,
-- column, talentId}
-- talents tab variables refers to talenttab dbc
warrior_arms_spells = {{78, 2, 0, 1}, {2457, 2, 0, 1}, {100, 2, 0, 4}, {772, 2, 0, 4}, {6343, 2, 0, 6},
{1715, 2, 0, 8}, {7384, 2, 0, 12}, {694, 2, 0, 18}, {20230, 2, 0, 20}, {64382, 2, 0, 71}, {57755, 2, 0, 80}}
warrior_arms_spells_count = 11
warrior_arms_bgs = {"Interface\\TalentFrame\\WarriorArms-TopLeft", "Interface\\TalentFrame\\WarriorArms-TopRight",
"Interface\\TalentFrame\\WarriorArms-BottomLeft", "Interface\\TalentFrame\\WarriorArms-BottomRight"}
warrior_arms_talents = {{3,{12282,12663,12664},0,1,10,1,124}, {5,{16462,16463,16464,16465,16466},0,1,10,2,130}, {2,{12286,12658},0,1,10,3,127},
{2,{12285,12697},0,1,15,1,126}, {3,{12300,12959,12960},0,1,15,2,641}, {3,{12295,12676,12677},0,1,15,3,128},
{2,{12290,12963},0,1,20,1,131}, {1,{12296},1,1,20,2,137}, {2,{16493,16494},0,1,20,3,662}, {3,{12834,12849,12867},0,1,20,4,121},
{3,{12163,12711,12712},0,1,25,2,136}, {3,{56636,56637,56638},0,1,25,3,2232},
{5,{12700,12781,12783,12784,12785},0,1,30,1,132}, {1,{12328},2,1,30,2,133}, {5,{12284,12701,12702,12703,12704},0,1,30,3,125}, {5,{12281,12812,12813,12814,12815},0,1,30,4,123},
{2,{20504,20505},0,1,35,1,134}, {3,{12289,12668,23695},0,1,35,3,129}, {2,{46854,46855},0,1,35,4,1859},
{2,{29834,29838},0,1,40,1,1663}, {1,{12294},2,1,40,2,135}, {2,{46865,46866},0,1,40,3,1862}, {2,{12862,12330},0,1,40,4,2233},
{1,{64976},1,1,45,1,2283}, {3,{35446,35448,35449},0,1,45,2,1824}, {2,{46859,46860},0,1,45,3,1860},
{3,{29723,29725,29724},0,1,50,1,1662}, {1,{29623},1,1,50,2,1661}, {2,{29836,29859},0,1,50,3,1664},
{5,{46867,56611,56612,56613,56614},0,1,55,2,2231},
{1,{46924},3,1,60,2,1863}}
warrior_arms_talents_tab = 4
warrior_fury_spells = {{6673, 2, 0, 1}, {34428, 2, 0, 6}, {1160, 2, 0, 14}, {845, 2, 0, 20}, {5246, 2, 0, 22},
{5308, 2, 0, 24}, {1161, 2, 0, 26}, {1464, 2, 0, 30}, {2458, 2, 0, 30}, {20252, 2, 0, 30}, {18499, 2, 0, 32},
{1680, 2, 0, 36}, {6552, 2, 0, 38}, {1719, 2, 0, 50}, {55694, 2, 0, 75}}
warrior_fury_spells_count = 15
warrior_fury_bgs = {"Interface\\TalentFrame\\WarriorFury-TopLeft", "Interface\\TalentFrame\\WarriorFury-TopRight",
"Interface\\TalentFrame\\WarriorFury-BottomLeft", "Interface\\TalentFrame\\WarriorFury-BottomRight"}
warrior_fury_talents = {{3,{61216,61221,61222},0,1,10,1,2250}, {2,{12321,12835},0,1,10,2,158}, {5,{12320,12852,12853,12855,12856},0,1,10,3,157},
{5,{12324,12876,12877,12878,12879},0,1,15,2,161}, {5,{12322,12999,13000,13001,13002},0,1,15,3,159},
{3,{12329,12950,20496},0,1,20,1,166}, {1,{12323},2,1,20,2,160}, {3,{16487,16489,16492},0,1,20,3,661}, {5,{12318,12857,12858,12860,12861},0,1,20,4,154},
{5,{23584,23585,23586,23587,23588},0,1,25,1,1581}, {2,{20502,20503},0,1,25,2,1542}, {5,{12317,13045,13046,13047,13048},0,1,25,3,155},
{3,{29590,29591,29592},0,1,30,1,1657}, {1,{12292},2,1,30,2,165}, {2,{29888,29889},0,1,30,3,1543},
{2,{20500,20501},0,1,35,1,1541}, {5,{12319,12971,12972,12973,12974},0,1,35,3,156},
{3,{46908,46909,56924},0,1,40,1,1864}, {1,{23881},2,1,40,2,167}, {2,{29721,29776},0,1,40,4,1655},
{2,{46910,46911},0,1,45,1,1865}, {5,{29759,29760,29761,29762,29763},0,1,45,4,1658},
{1,{60970},2,1,50,1,1868}, {1,{29801},2,1,50,2,1659}, {3,{46913,46914,46915},0,1,50,3,1866},
{5,{56927,56929,56930,56931,56932},0,1,55,2,2234},
{1,{46917},3,1,60,2,1867}}
warrior_fury_talents_tab = 6
warrior_protection_spells = {{2687, 2, 0, 10}, {71, 2, 0, 10}, {7386, 2, 0, 10}, {355, 2, 0, 10}, {72, 2, 0, 12},
{6572, 2, 0, 14}, {2565, 2, 0, 16}, {676, 2, 0, 18}, {12678, 1, 0, 20}, {871, 2, 0, 28}, {23922, 2, 0, 40},
{23920, 2, 0, 64}, {3411, 2, 0, 70}}
warrior_protection_spells_count = 13
warrior_protection_bgs = {"Interface\\TalentFrame\\WarriorProtection-TopLeft", "Interface\\TalentFrame\\WarriorProtection-TopRight",
"Interface\\TalentFrame\\WarriorProtection-BottomLeft", "Interface\\TalentFrame\\WarriorProtection-BottomRight"}
warrior_protection_talents = {{2,{12301,12818},0,1,10,1,142}, {5,{12298,12724,12725,12726,12727},0,1,10,2,1601}, {3,{12287,12665,12666},0,1,10,3,141},
{3,{50685,50686,50687},0,1,15,2,144}, {5,{12297,12750,12751,12752,12753},0,1,15,3,138},
{1,{12975},2,1,20,1,153}, {2,{12797,12799},0,1,20,2,147}, {2,{29598,29599},0,1,20,3,1654}, {5,{12299,12761,12762,12763,12764},0,1,20,4,140},
{2,{59088,59089},0,1,25,1,2247}, {2,{12313,12804},0,1,25,2,151}, {3,{12308,12810,12811},0,1,25,3,146},
{2,{12312,12803},0,1,30,1,150}, {1,{12809},2,1,30,2,152}, {2,{12311,12958},0,1,30,3,149},
{5,{16538,16539,16540,16541,16542},0,1,35,3,702},
{2,{29593,29594},0,1,40,1,1652}, {1,{50720},2,1,40,2,148}, {3,{29787,29790,29792},0,1,40,3,1660},
{3,{29140,29143,29144},0,1,45,2,1653}, {2,{46945,46949},0,1,45,3,1870},
{1,{57499},1,1,50,1,2236}, {1,{20243},2,1,50,2,1666}, {3,{47294,47295,47296},0,1,50,3,1893},
{3,{46951,46952,46953},0,1,55,2,1871}, {2,{58872,58874},0,1,55,3,2246},
{1,{46968},3,1,60,2,1872}}
warrior_protection_talents_tab = 5

View File

@@ -0,0 +1,5 @@
general_spells = {{107, 1, 0, 1}, {3127, 2, 0, 1}, {774994, 2, 0, 1}, {674, 1, 0, 1}}
--{668, 1, 0, 1}, {669, 1, 0, 1}, {670, 1, 0, 1}, {671, 1, 0, 1}, {672, 1, 0, 1}, {815, 1, 0, 1}, {7340, 1, 0, 1}, {7341, 1, 0, 1}, {17737, 1, 0, 1}} Languages
general_spells_count = 4

View File

@@ -0,0 +1,81 @@
maximumInstanceVariables = 5
instanceTotalIndices = 0 -- The total number of incices and their counters.
instanceIndex = {} -- The instance ID corresponding to an instance counter.
instanceVariables = {} -- An array of arrays containing variables.
function InstanceSystemCreateVariables(instanceId)
local hasBeenAdded = false
for i=1,instanceTotalIndices,1 do
if (instanceVariables[i][1] == nil) then -- If the first value of an array is nil, then it can be reused.
instanceIndex[i] = instanceId
instanceVariables[i] = {}
-- Initalize instance variables.
for j=1,maximumInstanceVariables,1 do
instanceVariables[i][j] = 0
end
hasBeenAdded = true
break
end
end
if (hasBeenAdded == false) then
instanceTotalIndices = instanceTotalIndices + 1
instanceIndex[instanceTotalIndices] = instanceId
instanceVariables[instanceTotalIndices] = {}
-- Initalize instance variables.
for j=1,maximumInstanceVariables,1 do
instanceVariables[instanceTotalIndices][j] = 0
end
end
end
-- Returns the instance variable corresponding to the specified instanceId and index.
-- Returns nil if no variable was found for the specified instanceId and/or index.
function InstanceSystemGetVariable(instanceId, variableIndex)
for i=1,instanceTotalIndices,1 do
if (instanceIndex[i] == instanceId) then
return instanceVariables[i][variableIndex]
end
end
return nil
end
-- Attempts to set the variable for the specified instanceId at the specified index
-- in the variables array.
-- Does nothing if the specified instanceId doesn't correspond to any existing
-- entry.
function InstanceSystemSetVariable(instanceId, index, variable)
if (index < maximumInstanceVariables and index > 0) then
for i=1,instanceTotalIndices,1 do
if (instanceIndex[i] == instanceId) then
instanceVariables[i][index] = variable
end
end
end
end
-- Resets all data held for the specified instanceId.
-- Does nothing if there was no data being held for the specified instanceId.
function InstanceSystemFinish(instanceId)
for i=1,instanceTotalIndices,1 do
if (instanceIndex[i] == instanceId) then
instanceIndex[i] = nil
-- Initalize instance variables.
for j=1,maximumInstanceVariables,1 do
instanceVariables[i][j] = 0
end
break
end
end
end

View File

@@ -0,0 +1,45 @@
--[[SYSTEM PREFERENCES
------------------
CustomClasses - Are Shard's custom classes installed?
EnableDeathAnnouncer - Set to true if you wish PvP deaths to be announced globally.
ClassColorCodes - Table of color codes, correspond to default WoW classes.
PvPExpRate - Experience Rate of the PvP Kill system. (Default: 1)
]]
EnableDeathAnnouncer = true
ClassColorCodes = {"C79C6E", "F58CBA", "ABD473", "FFF569", "FFFFFF", "C41F3B", "0070DE", "69CCF0", "9482C9", nil, "FF7D0A"}
PvPExpRate = 3.5
--[[AWAKENING PREFERENCES
-----------------
SpellCooldownMult - Affects the rate of cooldown for all shard_spell_table defined spells.
StatPointsPerLevel - Amount of Stat Allocation points granted upon Level Up.
GroupBonusExpMultiplier - This number will be multiplied by the level of the killed mob to calculate bonus EXP gain.
GroupBonusExpLevelDiff - The maximum levels higher a player can be than the mob he kills to gain bonus EXP.
PvPLevelDiff - Players that die to a player that has this much of a level advantage will not drop loot.
xpdist - Distance at which group members will gain bonus experience when another group member scores a PvE kill.
tokenid - ID of token to be given to player on levelup
]]
-- blah
SpellCooldownMult = 1
StatPointsPerLevel = 5
GroupBonusExpMultiplier = 0
GroupBonusExpLevelDiff = 5
PvPLevelDiff = 5
xpdist = 74
spell_essence = 383080
talent_essence = 383081
spell_reset_token = 383082
talent_reset_token = 383083
safety_ids = {489, 529, 30, 562, 617, 559, 572, 566, 607}
nocapzones = {46, 1377, 15, 718}
free_spell_reset = false
free_talent_reset = false
--[[COMMAND PREFERENCES
-------------------
ReloadSpellsCommand - Reloads the shard_spells_table data.
CullCharactersCommand - Sweeps through the various Shard tables and deletes characters that don't exist in the "characters" table.
]]
ReloadSpellsCommand = "%reload spells"
CullCharactersCommand = "%cull characters" --Disabled, incomplete/broken.

View File

@@ -0,0 +1,299 @@
local function On_LevelUp (event, player, oldLevel)
player:AddItem(spell_essence, 1)
if oldLevel >= 9 then
player:AddItem(talent_essence, 1)
end
end
RegisterPlayerEvent(13, On_LevelUp)
--[[RANDOM ENCHANTMENT GENERATOR]]
--[[
Enchantment slot test results:
0: WORKS
1: WORKS
2: DOES NOT WORK
3: DOES NOT WORK
4: DOES NOT WORK
5: WORKS
6: WORKS (DOES NOT DISPLAY)
7-11: DOES NOT WORK
]]
function RollEnchant(item, player)
local item_level = item:GetItemLevel()
local player_level = item:GetRequiredLevel()
local tier = 1
local effect = nil
--local req_level = item
local itemClass = ""
if (item:GetClass() == 2) then
itemClass = "WEAPON"
elseif (item:GetClass() == 4) then
itemClass = "ARMOR"
end
if (1 <= player_level) and (player_level <=9) then
tier = 1
elseif (10 <= player_level) and (player_level <=18) then
tier = 2
elseif (19 <= player_level) and (player_level <=27) then
tier = 3
elseif (28 <= player_level) and (player_level <=36) then
tier = 4
elseif (37 <= player_level) and (player_level <=44) then
tier = 5
--elseif (46 <= player_level) and (player_level <=54) then
-- tier = 6
elseif ( (item_level >= 50) and (item_level <= 55) ) then
tier = 7
elseif ( (item_level >= 56) and (item_level <= 63) ) then
tier = 8
elseif ( (item_level >= 64) and (item_level <= 71) ) then
tier = 9
elseif ( (item_level >= 72) and (item_level <= 78) ) then
tier = 10
elseif ( (item_level >= 79) and (item_level <= 83) ) then
tier = 11
elseif (item_level >= 84) then
tier = 12
end
if itemClass ~= "" then
local query = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier="..tier.." AND (class='"..itemClass.."' OR class='ANY') ORDER BY RAND() LIMIT 1;")
if (query) then
effect = query:GetInt32(0)
end
end
return effect
end
function OnLoot(event, player, item, count)
--[[
item quality will be checked in order to allow for a higher chance to get random enchants
item:GetQuality will return a number that will be equal to quality
0 - grey
1 - white
2 - green
3 - blue
4 - purple
5 - orange
6 - red (not used?)
7 - gold (bind to account)
]] -- 0 1 2 3 4 5
--scarlet crusade tabard exception
if (item:GetEntry() == 23192) then
return false
end
--
local chance_increaser = {101, 95, 30, 20, 0, 0} -- chances for each quality to get random_enchantments, the lower the number the higher the chance
local slotBools = {}
local slotIDs = {}
local its = 0
local item_class = item:GetClass()
local item_quality = item:GetQuality()
if item_class == 2 or item_class == 4 then
local boolRoll1 = math.random(1,100)
boolRoll1 = math.random(1,100)
if (boolRoll1 >= chance_increaser[item_quality]) then
slotBools[1] = true
slotIDs[1] = RollEnchant(item, player)
else
slotBools[1] = false
end
if (slotBools[1] == true) and (slotIDs[1] ~= nil) then
item:SetEnchantment(slotIDs[1], 5)
end
end
end
RegisterPlayerEvent(32, OnLoot)
function RemoveExhaustion(eventID, delay, pCall, player)
local CurrentEnergy = player:GetPower(3)
if (CurrentEnergy >= 200) and (player:GetAura(818013)) then
player:RemoveAura(818013)
player:RemoveEvents()
player:SendBroadcastMessage("You feel refreshed.")
end
end
--[[DYNAMIC SPELL SYSTEM FUNCTIONS]]
function SendDamage(player, target, spellID, amount, school) --Sends damage to the target.
player:SendDamage(target, amount, spellID, school, false)
end
function SendHeal(player, target, spellID, amount) --Heals the target.
player:DealHeal(target, spellID, amount, false)
end
function SendCooldown(player, spellID, duration) --Sends the cooldown to the player.
player:SendCooldown(spellID, duration)
end
function SendAura(player, target, spellID, duration) --Sets the duration of the effect on the target.
player:AddAura(spellID, target)
local aura = target:GetAura(spellID)
if (aura) then
aura:SetMaxDuration(duration)
aura:SetDuration(duration)
end
end
--[[ENERGY DRAIN Obsolete]]
function EnergyDrain(eventID, delay, pCall, player)
local CurrentEnergy = player:GetPower(3)
if (player:GetAura(818012)) then
if (player:GetPower(3) >= 25) then
local NewEnergy = (CurrentEnergy-25)
player:SetPower(3, NewEnergy)
else
player:RemoveEvents()
player:RemoveAura(818012)
end
else
player:RemoveEvents()
end
end
--[[AUTO ATTACK]]
--function auto_attack(event, player, spell)
--if (spell:GetEntry()==7712) then
--if (player:GetPower(3)>=75) then
--player:CastSpell(player, 818001, false)
--else
--player:CastSpell(player, 818013, false)
--player:SendBroadcastMessage("|cffff0000I am exhausted!|r")
--player:RegisterEvent(RemoveExhaustion, 250, 0)
--end
--end
--end
--RegisterPlayerEvent(5, auto_attack)
function sprintcheck(event, player, spell)
if (spell:GetEntry()==818012) then
if (player:GetAura(818011)) then
player:RemoveAura(818011)
end
if (player:GetAura(818012)) then
spell:Cancel()
player:RemoveAura(818012)
player:RemoveEvents()
else
curen = player:GetPower(3)
player:RegisterEvent(EnergyDrain, 1700, 0)
end
end
end
RegisterPlayerEvent(5, sprintcheck)
function RestCheck(event, player, spell)
if (spell:GetEntry()==818011) then
player:SendBroadcastMessage("I am resting. . .")
if (player:GetAura(818012)) then
player:RemoveAura(818012)
end
if (player:GetAura(818011)) then
spell:Cancel()
player:RemoveAura(818011)
player:RemoveEvents()
-- else
-- player:RegisterEvent(BreakRest, 50, 0)
end
end
end
RegisterPlayerEvent(5, RestCheck)
function On_LogIn (event, player)
player:AddAura(7711, player) --Modded in the DBC files, this is the aura that makes auto attacks cost energy.
player:RemoveSpell(668, player)
player:LearnSpell(668, player) --Language glitch band-aid. Teaches Player common
player:LearnSpell(669, player) --Language glitch band-aid. Teaches Player common
player:SetSkill(98, 1, 300, 300)
player:SetSkill(109, 1, 300, 300)
if (player:GetAura(818012)) then
player:RegisterEvent(EnergyDrain, 1000, 0)
end
end
function first_login (event, player)
CharDBExecute("INSERT INTO character_stat_points (guid) VALUES ("..player:GetGUIDLow()..")")
CharDBExecute("INSERT INTO character_stat_allocation (guid, str, agi, sta, inte, spi) VALUES ("..player:GetGUIDLow()..",0, 0, 0, 0, 0)")
player:LearnSpell(750)
player:LearnSpell(264)
player:LearnSpell(5011)
player:LearnSpell(1180)
player:LearnSpell(15590)
player:LearnSpell(266)
player:LearnSpell(196)
player:LearnSpell(198)
player:LearnSpell(201)
player:LearnSpell(200)
player:LearnSpell(3018)
player:LearnSpell(5019)
player:LearnSpell(227)
player:LearnSpell(264)
player:LearnSpell(197)
player:LearnSpell(199)
player:LearnSpell(202)
player:LearnSpell(5009)
player:AddItem(2504)
player:AddItem(2512, 400)
player:AddItem(25)
player:AddItem(2211)
player:AddItem(2508)
player:AddItem(2516, 400)
player:AddItem(2092)
player:AddItem(35)
player:AddItem(383082)
player:AddItem(383083)
player:RemoveSpell(78)
player:RemoveSpell(2457)
player:LearnSpell(818003)
player:LearnSpell(818004)
player:LearnSpell(818014)
player:LearnSpell(818011)
player:LearnSpell(818040)
player:LearnSpell(668, player) --Language glitch band-aid. Teaches Player common
player:LearnSpell(669, player) --Language glitch band-aid. Teaches Player common
player:SetSkill(98, 1, 300, 300)
player:SetSkill(109, 1, 300, 300)
end
RegisterPlayerEvent(30, first_login)

View File

@@ -0,0 +1,94 @@
--[[INTERACTIVE GUARDS SYSTEM]]--
--Loading guard ids--
local Guards_Entry = {}
local Guard_Factions = {
88, -- dwarwes of dungarok
11, -- stormwind guards
57, -- ironforge
56, -- night watch
71, -- undercity
85, -- orgrimmar
64, -- gnomerigan
473, -- chernii woron
1625, -- serebryanni rassvet
814, -- serebryanni rassvet
123, -- arathor
1054, -- wildhammer dwarf
--1603, -- lunosvet
76, -- dalaran mages (EASTERN KINGDOM)
79, -- darnas
1575, -- straji pustoti
412, -- oskvernitely
1577, -- liga arathora
105, -- thousand needles guards (horde)
83, -- thunder bluff
150, -- theramore
877, -- sen'jin watchers
1515, -- warsong guard (barrens)
854, --Everlook
121, --Gadgetzan
1857, --Light's Hope Argent Dawn
475, --Steamwheel
1254, -- Cenarion Circle
1475, -- Thormium Point
}
for k, v in pairs(Guard_Factions) do
local entry = WorldDBQuery("SELECT entry FROM creature_template WHERE faction = "..v..";")
if (entry) then
for i = 1, entry:GetRowCount() do
table.insert(Guards_Entry, entry:GetInt32(0))
entry:NextRow()
end
end
end
local function Guard_Back(eventId, delay, repeats, creature)
if (creature:GetFaction() == 7) and (not(creature:GetVictim()) or (creature:GetVictim():IsDead())) then
local faction = WorldDBQuery("SELECT faction FROM creature_template where entry = '"..creature:GetEntry().."';")
creature:SetFaction(faction:GetInt32(0))
if (creature:GetWaypointPath()) then
creature:MoveHome()
creature:MoveWaypoint()
else
creature:MoveHome()
end
end
end
--attack player when player attacks player of the same faction
local function Guard_MainAction(event, killer, killed)
if not(killer:IsFFAPvP()) then
return false
end
if (killer:ToPlayer() and killed:ToPlayer()) and ( (killer:IsAlliance() and killed:IsAlliance()) or (killer:IsHorde() and killed:IsHorde()) ) then
local FriendlyCreatures = killer:GetFriendlyUnitsInRange(60)
for n, creature in pairs(FriendlyCreatures) do
for m,faction_g in pairs(Guard_Factions) do
if (faction_g == creature:GetFaction()) then
creature:SetFaction(7)
creature:AttackStart(killer)
creature:RegisterEvent(Guard_Back, 2000, 0)
if ((killer:GetLevel()-creature:GetLevel()) > 5) then
creature:AddAura(266602, creature)
end
end
end
end
end
end
RegisterPlayerEvent(33, Guard_MainAction)
--[[for k,v in pairs(Guards_Entry) do
RegisterCreatureEvent(v, 2, Guard_Back) -- on leave combat
RegisterCreatureEvent(v, 3, Guard_Back) -- on target died
RegisterCreatureEvent(v, 5, Guard_Back) -- on spawn
--RegisterCreatureEvent(v, 10, Guard_Back) -- on precombat
RegisterCreatureEvent(v, 7, Guard_Back) -- on aiupdate
--RegisterCreatureEvent(v, 23, Guard_Back)
end]]--

331
hardcore_pvp/PvPClient.lua Normal file
View File

@@ -0,0 +1,331 @@
local AIO = AIO or require("AIO")
if AIO.AddAddon() then
return
end
local MyHandlers = AIO.AddHandlers("PvP", {})
Framework = CreateFrame("Frame", "first_frame", UIParent, nil)
local FullLootFrame = Framework
FullLootFrame:SetSize(416, 310)
--FullLootFrame:SetScale(0.88) --making everything more or less fit standart sizes of blizz interfaces
FullLootFrame:SetMovable(true)
FullLootFrame:EnableMouse(true)
FullLootFrame:RegisterForDrag("LeftButton")
FullLootFrame:SetPoint("BOTTOMRIGHT", -270, 60)
FullLootFrame:SetToplevel(true)
FullLootFrame:SetClampedToScreen(true)
FullLootFrame:SetBackdrop({
bgFile = "Interface\\AddOns\\AwAddons\\Textures\\misc\\loot",
insets = { left = -30, right = -30, top = -101, bottom = -101}
})
FullLootFrame:SetScript("OnDragStart", FullLootFrame.StartMoving)
FullLootFrame:SetScript("OnHide", FullLootFrame.StopMovingOrSizing)
FullLootFrame:SetScript("OnDragStop", FullLootFrame.StopMovingOrSizing)
FullLootFrame_scroll = CreateFrame("ScrollFrame", nil, FullLootFrame)
FullLootFrame_scroll:SetSize(500,198)
FullLootFrame_scroll:SetPoint("CENTER", -25, -25)
FullLootFrame_content = CreateFrame("Frame", nil, FullLootFrame)
FullLootFrame_content:SetSize(FullLootFrame_scroll:GetSize())
FullLootFrame_content:SetPoint("CENTER")
FullLootscrollbar = CreateFrame("Slider", nil, FullLootFrame_scroll, "UIPanelScrollBarTemplate")
FullLootscrollbar:SetPoint("TOPLEFT", FullLootFrame, "TOPRIGHT", -79, -57)
FullLootscrollbar:SetPoint("BOTTOMLEFT", FullLootFrame, "BOTTOMRIGHT", -79, 33)
FullLootscrollbar:SetMinMaxValues(1, 1250)
FullLootscrollbar:SetValueStep(1)
FullLootscrollbar.scrollStep = 1
FullLootscrollbar:SetValue(0)
FullLootscrollbar:SetWidth(16)
FullLootscrollbar:SetScript("OnValueChanged",
function (self, value)
FullLootFrame_scroll:SetVerticalScroll(value)
end)
local FLscrollbg = FullLootscrollbar:CreateTexture(nil, "BACKGROUND")
FLscrollbg:SetAllPoints(FullLootscrollbar)
FLscrollbg:SetTexture(0, 0, 0, 0.4)
FullLootFrame_scroll:SetScrollChild(FullLootFrame_content)
FullLootFrame:Hide()
local FullLootFrame_TitleText = FullLootFrame:CreateFontString("FullLootFrame_TitleText")
FullLootFrame_TitleText:SetFont("Fonts\\FRIZQT__.TTF", 12.2)
FullLootFrame_TitleText:SetSize(300, 5)
FullLootFrame_TitleText:SetFontObject(GameFontNormal)
FullLootFrame_TitleText:SetPoint("TOP", -15, -25)
FullLootFrame_TitleText:SetShadowOffset(1, -1)
FullLootFrame_TitleText:SetText("Unclaimed Belongings")
local FullLootFrame_CloseButton = CreateFrame("Button", "FullLootFrame_CloseButton", FullLootFrame, "UIPanelCloseButton")
FullLootFrame_CloseButton:SetPoint("TOPRIGHT", -55, -12)
FullLootFrame_CloseButton:EnableMouse(true)
--FullLootFrame_CloseButton:SetSize(31, 30)
FullLootFrame:EnableMouseWheel(true)
FullLootFrame:SetScript("OnMouseWheel", function(self, delta)
if (FullLootscrollbar:IsVisible()) then
local value = FullLootscrollbar:GetValue()
FullLootscrollbar:SetValue(value-delta*50)
end
end)
local FullLoot_Button1 = CreateFrame("Button", "FullLoot_Button1", FullLootFrame_content, nil)
local FullLoot_Button2 = CreateFrame("Button", "FullLoot_Button2", FullLootFrame_content, nil)
local FullLoot_Button3 = CreateFrame("Button", "FullLoot_Button3", FullLootFrame_content, nil)
local FullLoot_Button4 = CreateFrame("Button", "FullLoot_Button4", FullLootFrame_content, nil)
local FullLoot_Button5 = CreateFrame("Button", "FullLoot_Button5", FullLootFrame_content, nil)
local FullLoot_Button6 = CreateFrame("Button", "FullLoot_Button6", FullLootFrame_content, nil)
local FullLoot_Button7 = CreateFrame("Button", "FullLoot_Button7", FullLootFrame_content, nil)
local FullLoot_Button8 = CreateFrame("Button", "FullLoot_Button8", FullLootFrame_content, nil)
local FullLoot_Button9 = CreateFrame("Button", "FullLoot_Button9", FullLootFrame_content, nil)
local FullLoot_Button10 = CreateFrame("Button", "FullLoot_Button10", FullLootFrame_content, nil)
local FullLoot_Button11 = CreateFrame("Button", "FullLoot_Button11", FullLootFrame_content, nil)
local FullLoot_Button12 = CreateFrame("Button", "FullLoot_Button12", FullLootFrame_content, nil)
local FullLoot_Button13 = CreateFrame("Button", "FullLoot_Button13", FullLootFrame_content, nil)
local FullLoot_Button14 = CreateFrame("Button", "FullLoot_Button14", FullLootFrame_content, nil)
local FullLoot_Button15 = CreateFrame("Button", "FullLoot_Button15", FullLootFrame_content, nil)
local FullLoot_Button16 = CreateFrame("Button", "FullLoot_Button16", FullLootFrame_content, nil)
local FullLoot_Button17 = CreateFrame("Button", "FullLoot_Button17", FullLootFrame_content, nil)
local FullLoot_Button18 = CreateFrame("Button", "FullLoot_Button18", FullLootFrame_content, nil)
local FullLoot_Button19 = CreateFrame("Button", "FullLoot_Button19", FullLootFrame_content, nil)
local FullLoot_Button20 = CreateFrame("Button", "FullLoot_Button20", FullLootFrame_content, nil)
local FullLoot_Button21 = CreateFrame("Button", "FullLoot_Button21", FullLootFrame_content, nil)
local FullLoot_Button22 = CreateFrame("Button", "FullLoot_Button22", FullLootFrame_content, nil)
local FullLoot_Button23 = CreateFrame("Button", "FullLoot_Button23", FullLootFrame_content, nil)
local FullLoot_Button24 = CreateFrame("Button", "FullLoot_Button24", FullLootFrame_content, nil)
local FullLoot_Button25 = CreateFrame("Button", "FullLoot_Button25", FullLootFrame_content, nil)
local FullLoot_Text1 = FullLoot_Button1:CreateFontString("FullLoot_Text1")
local FullLoot_Text2 = FullLoot_Button2:CreateFontString("FullLoot_Text2")
local FullLoot_Text3 = FullLoot_Button3:CreateFontString("FullLoot_Text3")
local FullLoot_Text4 = FullLoot_Button4:CreateFontString("FullLoot_Text4")
local FullLoot_Text5 = FullLoot_Button5:CreateFontString("FullLoot_Text5")
local FullLoot_Text6 = FullLoot_Button6:CreateFontString("FullLoot_Text6")
local FullLoot_Text7 = FullLoot_Button7:CreateFontString("FullLoot_Text7")
local FullLoot_Text8 = FullLoot_Button8:CreateFontString("FullLoot_Text8")
local FullLoot_Text9 = FullLoot_Button9:CreateFontString("FullLoot_Text9")
local FullLoot_Text10 = FullLoot_Button10:CreateFontString("FullLoot_Text10")
local FullLoot_Text11 = FullLoot_Button11:CreateFontString("FullLoot_Text11")
local FullLoot_Text12 = FullLoot_Button12:CreateFontString("FullLoot_Text12")
local FullLoot_Text13 = FullLoot_Button13:CreateFontString("FullLoot_Text13")
local FullLoot_Text14 = FullLoot_Button14:CreateFontString("FullLoot_Text14")
local FullLoot_Text15 = FullLoot_Button15:CreateFontString("FullLoot_Text15")
local FullLoot_Text16 = FullLoot_Button16:CreateFontString("FullLoot_Text16")
local FullLoot_Text17 = FullLoot_Button17:CreateFontString("FullLoot_Text17")
local FullLoot_Text18 = FullLoot_Button18:CreateFontString("FullLoot_Text18")
local FullLoot_Text19 = FullLoot_Button19:CreateFontString("FullLoot_Text19")
local FullLoot_Text20 = FullLoot_Button20:CreateFontString("FullLoot_Text20")
local FullLoot_Text21 = FullLoot_Button21:CreateFontString("FullLoot_Text21")
local FullLoot_Text22 = FullLoot_Button22:CreateFontString("FullLoot_Text22")
local FullLoot_Text23 = FullLoot_Button23:CreateFontString("FullLoot_Text23")
local FullLoot_Text24 = FullLoot_Button24:CreateFontString("FullLoot_Text24")
local FullLoot_Text25 = FullLoot_Button25:CreateFontString("FullLoot_Text25")
local FullLootIconTable = {}
local FullLoot_Icon1 = FullLoot_Button1:CreateTexture("FullLoot_Icon1")
local FullLoot_Icon2 = FullLoot_Button2:CreateTexture("FullLoot_Icon2")
local FullLoot_Icon3 = FullLoot_Button3:CreateTexture("FullLoot_Icon3")
local FullLoot_Icon4 = FullLoot_Button4:CreateTexture("FullLoot_Icon4")
local FullLoot_Icon5 = FullLoot_Button5:CreateTexture("FullLoot_Icon5")
local FullLoot_Icon6 = FullLoot_Button6:CreateTexture("FullLoot_Icon6")
local FullLoot_Icon7 = FullLoot_Button7:CreateTexture("FullLoot_Icon7")
local FullLoot_Icon8 = FullLoot_Button8:CreateTexture("FullLoot_Icon8")
local FullLoot_Icon9 = FullLoot_Button9:CreateTexture("FullLoot_Icon9")
local FullLoot_Icon10 = FullLoot_Button10:CreateTexture("FullLoot_Icon10")
local FullLoot_Icon11 = FullLoot_Button11:CreateTexture("FullLoot_Icon11")
local FullLoot_Icon12 = FullLoot_Button12:CreateTexture("FullLoot_Icon12")
local FullLoot_Icon13 = FullLoot_Button13:CreateTexture("FullLoot_Icon13")
local FullLoot_Icon14 = FullLoot_Button14:CreateTexture("FullLoot_Icon14")
local FullLoot_Icon15 = FullLoot_Button15:CreateTexture("FullLoot_Icon15")
local FullLoot_Icon16 = FullLoot_Button16:CreateTexture("FullLoot_Icon16")
local FullLoot_Icon17 = FullLoot_Button17:CreateTexture("FullLoot_Icon17")
local FullLoot_Icon18 = FullLoot_Button18:CreateTexture("FullLoot_Icon18")
local FullLoot_Icon19 = FullLoot_Button19:CreateTexture("FullLoot_Icon19")
local FullLoot_Icon20 = FullLoot_Button20:CreateTexture("FullLoot_Icon20")
local FullLoot_Icon21 = FullLoot_Button21:CreateTexture("FullLoot_Icon21")
local FullLoot_Icon22 = FullLoot_Button22:CreateTexture("FullLoot_Icon22")
local FullLoot_Icon23 = FullLoot_Button23:CreateTexture("FullLoot_Icon23")
local FullLoot_Icon24 = FullLoot_Button24:CreateTexture("FullLoot_Icon24")
local FullLoot_Icon25 = FullLoot_Button25:CreateTexture("FullLoot_Icon25")
for i = 1, 25 do
table.insert(FullLootIconTable, _G["FullLoot_Icon"..i])
end
local FullLoot_ButtonTable = {FullLoot_Button1, FullLoot_Button2, FullLoot_Button3, FullLoot_Button4, FullLoot_Button5,
FullLoot_Button6, FullLoot_Button7, FullLoot_Button8, FullLoot_Button9, FullLoot_Button10, FullLoot_Button11, FullLoot_Button12,
FullLoot_Button13, FullLoot_Button14, FullLoot_Button15, FullLoot_Button16, FullLoot_Button17, FullLoot_Button18, FullLoot_Button19,
FullLoot_Button20, FullLoot_Button21, FullLoot_Button22, FullLoot_Button23, FullLoot_Button24, FullLoot_Button25}
local FullLoot_TextTable = {FullLoot_Text1, FullLoot_Text2, FullLoot_Text3, FullLoot_Text4, FullLoot_Text5,
FullLoot_Text6, FullLoot_Text7, FullLoot_Text8, FullLoot_Text9, FullLoot_Text10, FullLoot_Text11, FullLoot_Text12,
FullLoot_Text13, FullLoot_Text14, FullLoot_Text15, FullLoot_Text16, FullLoot_Text17, FullLoot_Text18, FullLoot_Text19,
FullLoot_Text20, FullLoot_Text21, FullLoot_Text22, FullLoot_Text23, FullLoot_Text24, FullLoot_Text25}
function MyHandlers.ReceiveItems(player,itemNumber, itemList, objectid)
itemHoldList = {}
playerKilledName = nil
objectPass = objectid
nullItems = 25 - itemNumber
if playerKilledName ~= nil then
FullLootFrame_TitleText:SetText("|cff230d21"..playerKilledName.."'s Belongings|r")
else
FullLootFrame_TitleText:SetText("Unclaimed Belongings")
end
repeat
local FullLoot_Button_null = FullLoot_ButtonTable[itemNumber + nullItems]
local FullLoot_Text_null = FullLoot_TextTable[itemNumber + nullItems]
local FullLootIconTable_null = FullLootIconTable[itemNumber + nullItems]
FullLoot_Button_null:Hide()
FullLoot_Text_null:Hide()
FullLootIconTable_null:Hide()
nullItems = nullItems - 1
until(nullItems <= 0)
if itemNumber > 0 then
if itemList[itemNumber][1] ~= nil and itemList[itemNumber][2] ~= nil and itemList[itemNumber][3] ~= nil then
repeat
local FullLoot_Button = FullLoot_ButtonTable[itemNumber]
local FullLoot_Text = FullLoot_TextTable[itemNumber]
local FullLoot_Icon = FullLootIconTable[itemNumber]
FullLoot_Button:SetSize(256, 52)
FullLoot_Button:SetPoint("TOP", 0, (-10-((itemNumber-1)*64)))
FullLoot_Button:EnableMouse(true)
FullLoot_Button:SetHighlightTexture("Interface/Buttons/UI-Listbox-Highlight")
FullLoot_Button:SetBackdrop({
bgFile = "Interface\\AddOns\\AwAddons\\Textures\\Misc\\lootbg",
insets = {
left = -102,
right = -102,
top = -34,
bottom = -34}
})
item_idd = itemList[itemNumber][2]
item_name = itemList[itemNumber][1]
item_stuff = itemList[itemNumber][3]
table.insert (itemHoldList, {FullLoot_Button, item_idd, item_name, item_stuff})
function FullLoot_Button_Tooltip_OnEnter(self, motion)
local item_rec = "Error, no item found"
for i, v in ipairs(itemHoldList) do
if v[1] == self then
item_rec = v[2]
break
end
end
GameTooltip:SetOwner(self,"ANCHOR_RIGHT")
GameTooltip:SetHyperlink("item:"..item_rec..":0:0:0:0:0:0:0")
GameTooltip:Show()
end
FullLoot_Button:SetScript("OnEnter", FullLoot_Button_Tooltip_OnEnter)
function FullLoot_Button_Tooltip_OnLeave(self, motion)
GameTooltip:Hide()
end
FullLoot_Button:SetScript("OnLeave", FullLoot_Button_Tooltip_OnLeave)
FullLoot_Text:SetFont("Fonts\\FRIZQT__.TTF", 14)
FullLoot_Text:SetSize(200, 20)
FullLoot_Text:SetPoint("CENTER", 20, 0)
FullLoot_Text:SetShadowOffset(1, -1)
local texture_x = "Interface\\Icons\\INV_Chest_Samurai"
local name_x, link_x, quality_x, iLevel_x, reqLevel_x, class_x, subclass_x, maxStack_x, equipSlot_x, texture_x2, vendorPrice_x = GetItemInfo(itemList[itemNumber][2])
if (texture_x2) then
texture_x = texture_x2
end
FullLoot_Icon:SetWidth(32);
FullLoot_Icon:SetHeight(34);
FullLoot_Icon:SetTexture(texture_x)
FullLoot_Icon:SetPoint("LEFT", 8, 0)
FullLoot_Text:SetText(itemList[itemNumber][1].." x"..itemList[itemNumber][3]) -- edited
FullLoot_Text:SetJustifyH("LEFT")
function ClickItem(self)
local item_rec = "Error, no item found"
local item_link = 0
local item_stuffy = 0
local bag1, _ = GetContainerNumFreeSlots(0)
local bag2, _ = GetContainerNumFreeSlots(1)
local bag3, _ = GetContainerNumFreeSlots(2)
local bag4, _ = GetContainerNumFreeSlots(3)
local bag5, _ = GetContainerNumFreeSlots(4)
local slots_open = bag1+bag2+bag3+bag4+bag5
bagslot_free = true
if slots_open == 0 then
bagslot_free = false
end
if bagslot_free == true then
for i, v in ipairs(itemHoldList) do
if v[1] == self then
item_rec = v[2]
item_link = v[3]
item_stuffy = v[4]
break
end
end
FullLoot_Button:Hide()
FullLoot_Text:SetText("|cff9d9d9dLooted Item|r")
FullLoot_Button:Disable()
AIO.Handle("PvP", "AddPlayerItem", item_rec, item_stuffy, objectPass)
else
print("|cffFFFF00You don't have enough space in bags|r")
end
end
FullLoot_Button:SetScript("OnMouseUp", ClickItem)
FullLoot_Button:Show()
FullLoot_Text:Show()
FullLoot_Icon:Show()
itemNumber = itemNumber - 1
until(itemNumber <= 0)
else
local FullLoot_Button_null = FullLoot_ButtonTable[itemNumber]
local FullLoot_Text_null = FullLoot_TextTable[itemNumber]
local FullLootIconTable_null = FullLootIconTable[itemNumber]
FullLoot_Button_null:Hide()
FullLoot_Text_null:Hide()
FullLootIconTable_null:Hide()
itemNumber = itemNumber - 1
end
end
FullLootFrame:Show()
end

434
hardcore_pvp/PvPServer.lua Normal file
View File

@@ -0,0 +1,434 @@
local AIO = AIO or require("AIO")
local MyHandlers = AIO.AddHandlers("PvP", {})
--local guid_linking_table = {}
item_table = {}
local prohibited_items = {
6948,
597600,
597601,
977020,
977021,
5863,
22115,
22048,
21984,
22047,
22046,
800096,
98457,
977025,
23720,
69228,
38576,
54811,
33225,
977019,
777998,
}
local dropmodifier = 5
local item_looted = {}
--local playerdeath = true
--local creaturedeath = true
--local leveldiff = 6
-- this function is never called for some unknown reason, known bug with ElunaCore
--[[function Remove_FullLootContainer(event, delay, call, object)
print("I got here!")
print("I got here!")
local nearbyplayers = object:GetPlayersInRange(100)
for k, v in pairs(nearbyplayers) do
v:SendBroadcastMessage("|CFFFF8040The sack of items turns to dust, and blows away with the wind.|r")
end
object:Despawn()
object:RemoveFromWorld(false)
FullLootFrame:Hide()
guid_linking_table[object:GetGUIDLow()] = nil
item_table[object:GetGUIDLow()] = nil
print("Chest removed from world")
end]]--
local SafeCostModifier = 3540
function SafeSlotGetLostCost(item)
local cost = nil
cost = item:GetItemLevel() * SafeCostModifier -- Temporary was 2285
return cost
end
local function PVP_ItemCheck(item, target)
for k,v in pairs(prohibited_items) do
if (item:GetEntry() == v) then
return false
end
end -- check for special item ids
if (target:HasQuestForItem(item:GetEntry()) or (item:IsBag()==true)) then
return false
end -- check for bags and quest items
local mv = WorldDBQuery("SELECT bonding FROM item_template WHERE entry = "..item:GetEntry().."")
if (mv:GetInt32(0) >= 4) then
return false
end
return true
end
local function EntropyPvP(event, pKiller, pKilled)
--PLAYER_EVENT_ON_KILLED_BY_CREATURE
if pKiller:ToCreature() then
if not(pKiller:GetOwner()) then
return false
end
if not(pKiller:GetOwner():ToPlayer()) then
return false
end
pKiller = pKiller:GetOwner():ToPlayer()
end
--PLAYER_EVENT_ON_KILLED_BY_CREATURE
math.random(1,10)
local check_safe = false
local pKiller_loc = pKiller:GetMapId()
local pKiller_zone = pKiller:GetZoneId()
local items_droplist = {}
local spawnType = 2
local instanceID = pKiller:GetInstanceId()
local DropGold = 0
for i,v in ipairs(safety_ids) do
if v == pKiller_loc then
check_safe = true
break
end
end
for k,z in ipairs(nocapzones) do
if z == pKiller_zone then
setcap = true
else
setcap = false
end
end
if setcap == true then
leveldiff = 255
else
leveldiff = 5
end --some checks for safe zones and other stuff
if not (pKilled == pKiller) then -- if player commited suicide, no drop
-- check for honorless target
if pKilled:HasAura(2479) == false then
if (check_safe == false and instanceID == 0) then -- begin main action
if (((pKiller:GetLevel()-pKilled:GetLevel())<=leveldiff) and ((pKiller:GetLevel()-pKilled:GetLevel())>=(leveldiff * -1))) then -- level difference check
local pKilledGUID = pKilled:GetGUIDLow()
local pKillerGUID = pKiller:GetGUIDLow()
local x,y,z,o = pKilled:GetX(),pKilled:GetY(),pKilled:GetZ(),pKilled:GetO()
local ContainerID = 818001
local FullLootContainer = PerformIngameSpawn(spawnType,ContainerID,pKiller_loc,instanceID, x, y, z, o) --Spawn a Sack of Belongings
item_table[FullLootContainer:GetGUIDLow()] = {}
-- my updated part
local amountofdroppeditems = math.ceil(pKilled:GetLevel()/dropmodifier)
if (amountofdroppeditems >= 1) then
--list of items player have
for i = 1, 8 do
math.random(1,10)
slot = math.random(0,38)
if (pKilled:GetItemByPos(255, slot)) then
if not(pKilled:HasQuestForItem(pKilled:GetItemByPos(255, slot):GetEntry())) and not(pKilled:GetItemByPos(255, slot):IsBag()==true) then
table.insert(items_droplist, {255,slot})
end
end
end
for slot = 0,35 do
for bag = 19,22 do
if (pKilled:GetItemByPos(bag, slot)) then
if not(pKilled:HasQuestForItem(pKilled:GetItemByPos(bag, slot):GetEntry())) and not(pKilled:GetItemByPos(bag, slot):IsBag()==true) then
table.insert(items_droplist, {bag,slot})
end
end
end
end
-- list is done
if (items_droplist[1]) then
for i = 1, amountofdroppeditems do
math.random(1,10)
local itemslot_temp = math.random(1,#items_droplist)
local item = pKilled:GetItemByPos(items_droplist[itemslot_temp][1],items_droplist[itemslot_temp][2])
if (item) then
local itemcount = math.random(1,item:GetCount())
if (PVP_ItemCheck(item,pKilled)) then
-- Get Money for item part--
--SQL CHECK IF ITEM IS "SAFE"
local SafeSQL = nil
if ((items_droplist[itemslot_temp][2]<19) and (items_droplist[itemslot_temp][1] == 255)) then
SafeSQL = CharDBQuery("SELECT slot"..items_droplist[itemslot_temp][2].." FROM custom_iteminsurance WHERE playerguid = "..pKilled:GetGUIDLow()..";")
end
local DropSafeCost = SafeSlotGetLostCost(item)
if (SafeSQL and (SafeSQL:GetInt32(0) == 1) and (pKilled:GetCoinage() >= DropSafeCost)) then
pKilled:ModifyMoney(-DropSafeCost)
pKiller:ModifyMoney(DropSafeCost)
DropGold = DropGold + DropSafeCost
else
if (item:GetClass() == 2 or item:GetClass() == 4) then
if (item:GetEnchantmentId(5) == 0 or item:GetEnchantmentId(5) == nil) then
table.insert (item_table[FullLootContainer:GetGUIDLow()], {item:GetItemLink(), item:GetEntry(), itemcount, pKilled:GetName()})
else
table.insert (item_table[FullLootContainer:GetGUIDLow()], {item:GetItemLink(), item:GetEntry(), itemcount, pKilled:GetName(), item:GetEnchantmentId(5)})
end
else
table.insert (item_table[FullLootContainer:GetGUIDLow()], {item:GetItemLink(), item:GetEntry(), itemcount, pKilled:GetName()})
end
pKilled:RemoveItem(item:GetEntry(), itemcount)
end
else
amountofdroppeditems = amountofdroppeditems+1
end
end
end
end
end
if not(item_table[FullLootContainer:GetGUIDLow()][1]) then
FullLootContainer:Despawn()
FullLootContainer:RemoveFromWorld(true)
end
end -- end of lvl diff check
end -- end of main action
end -- end of aura check
else
pKilled:SendBroadcastMessage("You have commited suicide, none of your items were lost")
end -- end of suicide check
if (DropGold > 0) then
local gold,silver,copper = GetGoldForMoney(DropGold)
pKiller:SendBroadcastMessage("You recieved |cffFFFFFF"..gold.."|TInterface\\MONEYFRAME\\UI-GoldIcon.blp:11:11:0:-1|t "..silver.."|TInterface\\MONEYFRAME\\UI-SilverIcon.blp:11:11:0:-1|t "..copper.."|TInterface\\MONEYFRAME\\UI-CopperIcon.blp:11:11:0:-1|t|r from killing this player")
pKilled:SendBroadcastMessage("You lost |cffFFFFFF"..gold.."|TInterface\\MONEYFRAME\\UI-GoldIcon.blp:11:11:0:-1|t "..silver.."|TInterface\\MONEYFRAME\\UI-SilverIcon.blp:11:11:0:-1|t "..copper.."|TInterface\\MONEYFRAME\\UI-CopperIcon.blp:11:11:0:-1|t|r but saved your items by Fel Commutation")
end
end
--[[local function CreatureDeath (event, pKiller, pKilled)
local check_safe = false
local pKilled_loc = pKilled:GetMapId()
local spawnType = 2
local instanceID = pKilled:GetInstanceId()
for i,v in ipairs(safety_ids) do
if v == pKilled_loc then
check_safe = true
break
end
end
if (pKiller:GetOwner() == nil or pKiller:GetOwner() == 0) then
petkill = false
--print("No Owner")
else
local plrs = pKiller:GetPlayersInRange(20)
for h,p in pairs(plrs) do
if p == pKiller:GetOwner() then
petkill = true
print("Has owner")
end
end
end
if petkill == false then
npcleveldiff = 255
else
npcleveldiff = 6
end
if (creaturedeath==true and check_safe == false and instanceID == 0 and ((pKiller:GetLevel()-pKilled:GetLevel())<=npcleveldiff))then
local pKilledGUID = pKilled:GetGUIDLow()
local x,y,z,o = pKilled:GetX(),pKilled:GetY(),pKilled:GetZ(),pKilled:GetO()
local ContainerID = 818001
local kill_message = math.random(1,6)
local FullLootContainer = PerformIngameSpawn(spawnType,ContainerID,pKilled_loc,instanceID, x, y, z, o, false, 10) --Spawn a Sack of Belongings
guid_linking_table[FullLootContainer:GetGUIDLow()] = pKilled:GetGUIDLow()
--Get Items
local bagslot = 255
local inven_ticker = 0
local item_ticker = 0
local maxitems = 25 --Equal to amount of buttons that I have declared.
item_table[FullLootContainer:GetGUIDLow()] = {}
remove_table[FullLootContainer:GetGUIDLow()] = {}
repeat
local SlotRange = 35
inven_ticker = inven_ticker+1
local bagToTake = math.random(3)
if bagToTake < 3 then
SlotRange = 38
bagToTake = 255
else
bagToTake = math.random(4)
if petkill == true then
bagToTake = bagToTake + 6
else
bagToTake = bagToTake + 6
end
end
local slotToTake = math.random(SlotRange)
local checkitem = pKilled:GetItemByPos(bagToTake, slotToTake)
if not(checkitem) then
return false
end
safe_to_take = true
if petkill == false then
if checkitem:GetClass() == 12 then
safe_to_take = false
elseif checkitem:GetClass() == 0 then
if checkitem:GetDisplayId() == 34802 then
safe_to_take = false
end
end
end
if petkill == false then
if (checkitem~=nil) and (checkitem:IsBag()==false) and (checkitem:GetEntry()~=6948) and safe_to_take == true then
item_ticker = item_ticker+1
if (checkitem:GetClass() == 2 or checkitem:GetClass() == 4) then
if (checkitem:GetEnchantmentId(5) == 0 or checkitem:GetEnchantmentId(5) == nil) then
table.insert (item_table[FullLootContainer:GetGUIDLow()], {checkitem:GetItemLink(), checkitem:GetEntry(), pKilled:GetItemCount(checkitem:GetEntry()), pKilled:GetName()})
else
table.insert (item_table[FullLootContainer:GetGUIDLow()], {checkitem:GetItemLink(), checkitem:GetEntry(), pKilled:GetItemCount(checkitem:GetEntry()), pKilled:GetName(), checkitem:GetEnchantmentId(5)})
end
end
table.insert (remove_table[FullLootContainer:GetGUIDLow()], {item_ticker, false})
pKilled:RemoveItem(checkitem:GetEntry(), pKilled:GetItemCount(checkitem:GetEntry()))
end
else
if (checkitem ~= 0) then -- Checks to make sure player has an item
if (checkitem~=nil) and (checkitem:IsBag()==false) and (checkitem:GetEntry()~=6948) then
item_ticker = item_ticker+1
if (checkitem:GetClass() == 2 or checkitem:GetClass() == 4) then
if (checkitem:GetEnchantmentId(5) == 0 or checkitem:GetEnchantmentId(5) == nil) then
table.insert (item_table[FullLootContainer:GetGUIDLow()], {checkitem:GetItemLink(), checkitem:GetEntry(), pKilled:GetItemCount(checkitem:GetEntry()), pKilled:GetName()})
else
table.insert (item_table[FullLootContainer:GetGUIDLow()], {checkitem:GetItemLink(), checkitem:GetEntry(), pKilled:GetItemCount(checkitem:GetEntry()), pKilled:GetName(), checkitem:GetEnchantmentId(5)})
end
end
table.insert (remove_table[FullLootContainer:GetGUIDLow()], {item_ticker, false})
pKilled:RemoveItem(checkitem:GetEntry(), pKilled:GetItemCount(checkitem:GetEntry()))
end
end
end
until (inven_ticker>=38) or (item_ticker>=maxitems)
end
if petkill == true then
local killed_color = ClassColorCodes[pKilled:GetClass()]
local killer_color = ClassColorCodes[pKiller:GetOwner():GetClass()]
local killerguild_name = ", a Lone Wolf"
local killedguild_name = ", a Lone Wolf"
--Kill Announcer
local DeathAnnouncements = {
"[PvP]: |CFF"..killed_color..""..pKilled:GetName().."|r"..killedguild_name..", was slain by |CFF"..killer_color..""..pKiller:GetOwner():GetName().."|r"..killerguild_name.."!",
"[PvP]: |CFF"..killed_color..""..pKilled:GetName().."|r"..killedguild_name..", met the maker to the hand of |CFF"..killer_color..""..pKiller:GetOwner():GetName().."|r"..killerguild_name.."!",
"[PvP]: |CFF"..killed_color..""..pKilled:GetName().."|r"..killedguild_name..", was vanquished by |CFF"..killer_color..""..pKiller:GetOwner():GetName().."|r"..killerguild_name.."!",
"[PvP]: |CFF"..killed_color..""..pKilled:GetName().."|r"..killedguild_name..", has fallen to |CFF"..killer_color..""..pKiller:GetOwner():GetName().."|r"..killerguild_name.."!",
"[PvP]: |CFF"..killed_color..""..pKilled:GetName().."|r"..killedguild_name..", died a swift death, courtesy of |CFF"..killer_color..""..pKiller:GetOwner():GetName().."|r"..killerguild_name..".",
"[PvP]: |CFF"..killed_color..""..pKilled:GetName().."|r"..killedguild_name..", wanted a piece of |CFF"..killer_color..""..pKiller:GetOwner():GetName().."|r"..killerguild_name..", but bit off a little more than they could chew!"
}
if (pKilled == pKiller) then
EnableDeathAnnouncer = false
else
if (EnableDeathAnnouncer==true) then
local DeathAnnounce_Roll = math.random(1,6)
SendWorldMessage(DeathAnnouncements[DeathAnnounce_Roll])
end
end
end
end]]--
local function Init_FullLootFrame(event, player, object)
local itemNumber = 0
local playerKilledName = "h"
local itemList = {}
local objectid = object:GetGUIDLow()
for k, v in ipairs(item_table[objectid]) do
if v[1] ~= nil then
table.insert (itemList, v)
itemNumber = itemNumber + 1
end
end
sendItemsToPlayer(AIO.Msg(), player, itemNumber, itemList, objectid):Send(player)
end
function sendItemsToPlayer(msg, player, itemNumber, itemList, playerKilledName, object)
return msg:Add("PvP", "ReceiveItems", itemNumber, itemList, playerKilledName)
end
function MyHandlers.AddPlayerItem(player, itemEntry, itemCount, object)
--AIO ADDITIONAL CHECK--
local expectedData = {"number","number","number"}
local values = {itemEntry,itemCount,object}
if not(DataTypeCheck(expectedData, values)) then
return false
end
--MAIN ACTION--
for i,v in pairs(item_table[object]) do
if v[2] == itemEntry then
-- check the possibility to add item
if (player:AddItem(itemEntry, itemCount)) then
item_table[object][i][2] = nil
item_table[object][i][1] = nil
item_table[object][i][3] = nil
if (item_table[object][i][5] ~= nil or item_table[object][i][5] ~= 0) then
player:GetItemByEntry(itemEntry):SetEnchantment(item_table[object][i][5], 5)
item_table[object][i][5] = nil
end
else
player:SendBroadcastMessage("You don't have enough space in bags")
end
end
end
end
local function Container_Interact(event, player, object)
if (item_looted[object:GetGUIDLow()]) then
return false
end
table.insert(item_looted, object:GetGUIDLow())
Init_FullLootFrame(event, player, object)
object:Despawn()
object:RemoveFromWorld(false)
return false
end
RegisterPlayerEvent(8, EntropyPvP)
RegisterPlayerEvent(6, EntropyPvP)
RegisterGameObjectGossipEvent(818001, 1, Container_Interact)
--[[Demonic rune fix
local function DemonicRuneFix(event, player, spell, skipCheck)
if not(spell:GetEntry() == 16666) then
return false
end
if player:IsDead() then
print("you died by using demonic rune")
end
end
RegisterPlayerEvent(5, DemonicRuneFix)]]--

Some files were not shown because too many files have changed in this diff Show More