mirror of
https://github.com/araxiaonline/wow.ets.modules.git
synced 2026-06-13 02:32:21 -04:00
Added transpiled modules for ease of copy grab
This commit is contained in:
2630
dist/common/lualib_bundle.lua
vendored
Normal file
2630
dist/common/lualib_bundle.lua
vendored
Normal file
File diff suppressed because it is too large
Load Diff
97
dist/module/commands/set-xp-rate/set-xp-rate.lua
vendored
Normal file
97
dist/module/commands/set-xp-rate/set-xp-rate.lua
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local Map = ____lualib.Map
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local __TS__StringIncludes = ____lualib.__TS__StringIncludes
|
||||
local __TS__StringSplit = ____lualib.__TS__StringSplit
|
||||
local __TS__ParseInt = ____lualib.__TS__ParseInt
|
||||
local ____exports = {}
|
||||
local ____stats = require("shared.stats")
|
||||
local PlayerStats = ____stats.PlayerStats
|
||||
--- Configuration options
|
||||
local MAX_XP_RATE = 5
|
||||
local xpCmd = "#xprate"
|
||||
local showXPcmd = "#xprate show"
|
||||
local setXPcmd = "#xprate set"
|
||||
local XP_RATE_SETTING = "xp_rate"
|
||||
local xpRateCache = __TS__New(Map)
|
||||
local function XPRateHandler(____, event, player, message)
|
||||
if __TS__StringIncludes(message, xpCmd) then
|
||||
local args = __TS__StringSplit(message, " ")
|
||||
local cmd = args[2]
|
||||
local playerCustom = __TS__New(PlayerStats, player)
|
||||
playerCustom:load()
|
||||
if cmd == "show" then
|
||||
local xpRate = xpRateCache:get(player:GetGUIDLow())
|
||||
if xpRate ~= nil then
|
||||
player:SendBroadcastMessage(("Your current XP rate is " .. tostring(xpRate)) .. "x")
|
||||
else
|
||||
player:SendBroadcastMessage("Your current XP rate is 1x")
|
||||
end
|
||||
elseif cmd == "set" then
|
||||
local rate = args[3]
|
||||
local rateNum = __TS__ParseInt(rate)
|
||||
if rateNum > MAX_XP_RATE then
|
||||
player:SendNotification(("You cannot set your XP rate higher then " .. tostring(MAX_XP_RATE)) .. "x")
|
||||
return false
|
||||
end
|
||||
playerCustom:setStat(XP_RATE_SETTING, rateNum)
|
||||
playerCustom:save()
|
||||
xpRateCache:set(
|
||||
player:GetGUIDLow(),
|
||||
rateNum
|
||||
)
|
||||
player:SendBroadcastMessage(("Your XP rate has been set to " .. tostring(rateNum)) .. "x")
|
||||
else
|
||||
player:SendBroadcastMessage(("Usage: " .. xpCmd) .. " [show|set] [rate]")
|
||||
end
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
--- Gives players extra XP based on their rate
|
||||
--
|
||||
-- @param event \
|
||||
-- @param player
|
||||
-- @param amount
|
||||
-- @param victim
|
||||
local function XPBonus(____, event, player, amount, victim)
|
||||
local xpRate = xpRateCache:get(player:GetGUIDLow())
|
||||
if xpRate and xpRate > 1 then
|
||||
player:GiveXP(amount * xpRate)
|
||||
end
|
||||
end
|
||||
local function XPRateLoader(____, event, player)
|
||||
local playerCustom = __TS__New(PlayerStats, player)
|
||||
playerCustom:load()
|
||||
local xpRate = playerCustom:getStat(XP_RATE_SETTING)
|
||||
if xpRate then
|
||||
xpRateCache:set(
|
||||
player:GetGUIDLow(),
|
||||
xpRate.value
|
||||
)
|
||||
else
|
||||
xpRateCache:set(
|
||||
player:GetGUIDLow(),
|
||||
1
|
||||
)
|
||||
end
|
||||
end
|
||||
RegisterPlayerEvent(
|
||||
12,
|
||||
function(...) return XPBonus(nil, ...) end
|
||||
)
|
||||
RegisterPlayerEvent(
|
||||
18,
|
||||
function(...) return XPRateHandler(nil, ...) end
|
||||
)
|
||||
RegisterPlayerEvent(
|
||||
3,
|
||||
function(...) return XPRateLoader(nil, ...) end
|
||||
)
|
||||
RegisterServerEvent(
|
||||
33,
|
||||
function(...)
|
||||
xpRateCache = PlayerStats:GetStatsByType("player", XP_RATE_SETTING)
|
||||
end
|
||||
)
|
||||
return ____exports
|
||||
149
dist/module/gameobjects/soulswapper/soulswapper.lua
vendored
Normal file
149
dist/module/gameobjects/soulswapper/soulswapper.lua
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local ____exports = {}
|
||||
local ____money = require("shared.money")
|
||||
local ToGold = ____money.ToGold
|
||||
local ToCopper = ____money.ToCopper
|
||||
local ____account = require("shared.account")
|
||||
local AccountInfo = ____account.AccountInfo
|
||||
--- This is the list of item classes that are allowed to be sent to other characters.
|
||||
--
|
||||
-- @link https://www.azerothcore.org/wiki/item_template
|
||||
local ALLOWED_ITEM_CLASSES = {2, 4, 9}
|
||||
--- This is the number of characters an account can have.
|
||||
local ALLOWED_ACCOUNT_CHARS = 15
|
||||
--- Base price for sending an item multipliers will be added on top
|
||||
local SOULSWAP_BASE_PRICE = ToCopper(nil, 20)
|
||||
--- The level the discount for sending items is no longer applied
|
||||
local NO_DISCOUNT_LEVEL = 70
|
||||
--- Discount percentage applied per 10 levels
|
||||
local DISCOUNT_ADJ = 3
|
||||
--- The id of the object that will interact with the player to handle the soulswap
|
||||
local INTERACTIVE_OBJECT = 750000
|
||||
local selectedItem = {}
|
||||
local function getCost(self, guid, player)
|
||||
local itemGuid = GetItemGUID(guid)
|
||||
local theItem = player:GetItemByGUID(itemGuid)
|
||||
local discount = 1
|
||||
local iLevelModifer = theItem:GetItemLevel() / 40
|
||||
if player:GetLevel() < NO_DISCOUNT_LEVEL then
|
||||
discount = (NO_DISCOUNT_LEVEL - player:GetLevel()) * DISCOUNT_ADJ
|
||||
end
|
||||
if discount > 100 then
|
||||
discount = 90
|
||||
end
|
||||
return SOULSWAP_BASE_PRICE * iLevelModifer * ((100 - discount) / 100)
|
||||
end
|
||||
local function GossipHello(____, event, player, gameobject)
|
||||
player:GossipClearMenu()
|
||||
local items = 0
|
||||
do
|
||||
local i = 23
|
||||
while i <= 38 do
|
||||
local item = player:GetItemByPos(255, i)
|
||||
if item ~= nil then
|
||||
local itemClass = item:GetClass()
|
||||
if item:IsSoulBound() and __TS__ArrayIncludes(ALLOWED_ITEM_CLASSES, itemClass) then
|
||||
local quality = item:GetQuality()
|
||||
local quantity = item:GetCount()
|
||||
local cost = getCost(
|
||||
nil,
|
||||
item:GetGUIDLow(),
|
||||
player
|
||||
)
|
||||
if quality > 2 and quantity == 1 then
|
||||
items = items + 1
|
||||
player:GossipMenuAddItem(
|
||||
1,
|
||||
((("Item: " .. item:GetItemLink()) .. " (") .. tostring(ToGold(nil, cost))) .. "g)",
|
||||
1,
|
||||
item:GetGUIDLow(),
|
||||
nil,
|
||||
nil
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
if items == 0 then
|
||||
player:SendNotification("You have no soulbound items in your backback to send to your other characters.")
|
||||
end
|
||||
player:GossipMenuAddItem(1, "Stop using the device", 1, 50500)
|
||||
player:GossipSendMenu(1000, gameobject, 10000)
|
||||
return true
|
||||
end
|
||||
local function GossipSelect(____, event, player, creature, selection, action, code, menuId)
|
||||
local account = __TS__New(
|
||||
AccountInfo,
|
||||
player:GetAccountId()
|
||||
)
|
||||
local characters = account:GetCharacters()
|
||||
if action == 50500 then
|
||||
player:GossipClearMenu()
|
||||
player:GossipComplete()
|
||||
return true
|
||||
end
|
||||
if action > ALLOWED_ACCOUNT_CHARS then
|
||||
do
|
||||
local numC = 0
|
||||
while numC < #characters do
|
||||
local name = characters[numC + 1].name
|
||||
if name ~= player:GetName() then
|
||||
local cost = getCost(nil, action, player)
|
||||
player:GossipMenuAddItem(
|
||||
2,
|
||||
"Send to: " .. name,
|
||||
2,
|
||||
numC + 1,
|
||||
nil,
|
||||
("Are you sure you will to rebind this item? The item will be mailed to " .. name) .. "?",
|
||||
cost
|
||||
)
|
||||
end
|
||||
numC = numC + 1
|
||||
end
|
||||
end
|
||||
selectedItem[player:GetName()] = action
|
||||
player:GossipSendMenu(1000, creature, 10000)
|
||||
end
|
||||
if action <= ALLOWED_ACCOUNT_CHARS then
|
||||
local itemToChange = selectedItem[player:GetName()]
|
||||
local itemGuid = GetItemGUID(itemToChange)
|
||||
local PlayerItem = player:GetItemByGUID(itemGuid)
|
||||
print((("Item Info: " .. PlayerItem:GetOwner():GetName()) .. " owns ") .. PlayerItem:GetName())
|
||||
local newItemGuid = SendMail(
|
||||
"Item Rebound " .. PlayerItem:GetName(),
|
||||
"Soulbinder has sent you a gift " .. PlayerItem:GetName(),
|
||||
characters[action].guid,
|
||||
player:GetGUIDLow(),
|
||||
41,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
PlayerItem:GetEntry(),
|
||||
1
|
||||
)
|
||||
player:RemoveItem(
|
||||
PlayerItem,
|
||||
PlayerItem:GetEntry(),
|
||||
1
|
||||
)
|
||||
player:GossipClearMenu()
|
||||
player:GossipComplete()
|
||||
end
|
||||
return true
|
||||
end
|
||||
RegisterGameObjectGossipEvent(
|
||||
INTERACTIVE_OBJECT,
|
||||
1,
|
||||
function(...) return GossipHello(nil, ...) end
|
||||
)
|
||||
RegisterGameObjectGossipEvent(
|
||||
INTERACTIVE_OBJECT,
|
||||
2,
|
||||
function(...) return GossipSelect(nil, ...) end
|
||||
)
|
||||
return ____exports
|
||||
43
dist/module/gameplay/achievement-tokens/achievement-tokens.lua
vendored
Normal file
43
dist/module/gameplay/achievement-tokens/achievement-tokens.lua
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
--- CONFIG OPTIONS
|
||||
--
|
||||
-- @returns
|
||||
AWARD_RATE = 5
|
||||
TOKEN_ID = 910001
|
||||
REWARD_CHAR_GUID = 2506
|
||||
--- On Achivement complete the system will reward the player with tokens based on the AWARD_RATE
|
||||
-- set above
|
||||
-- Default is 5 Achievement Points = 1 Token
|
||||
--
|
||||
-- IE)
|
||||
-- 10 Achievement Points = 2 Tokens
|
||||
-- 50 Achievement Points = 10 Tokens
|
||||
--
|
||||
-- @param event : number
|
||||
-- @param player : Player
|
||||
-- @param achievement : Achievement
|
||||
-- @returns boolean
|
||||
achievementComplete = function(____, event, player, achievement)
|
||||
local id = achievement:GetId()
|
||||
local query = WorldDBQuery("SELECT Points from achievements where ID=" .. tostring(id))
|
||||
local points = query:GetUInt32(0)
|
||||
if points ~= nil then
|
||||
local tokens = math.ceil(points / AWARD_RATE)
|
||||
SendMail(
|
||||
"Your achievement token reward!",
|
||||
"You earned it now spend it!",
|
||||
player:GetGUIDLow(),
|
||||
REWARD_CHAR_GUID,
|
||||
41,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
TOKEN_ID,
|
||||
tokens
|
||||
)
|
||||
end
|
||||
return true
|
||||
end
|
||||
RegisterPlayerEvent(
|
||||
45,
|
||||
function(...) return achievementComplete(_G, ...) end
|
||||
)
|
||||
33
dist/module/gameplay/worgoblin/worgoblin.lua
vendored
Normal file
33
dist/module/gameplay/worgoblin/worgoblin.lua
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
local ____exports = {}
|
||||
local ____money = require("shared.money")
|
||||
local ToCopper = ____money.ToCopper
|
||||
RegisterPlayerEvent(
|
||||
30,
|
||||
function(event, player)
|
||||
if player:GetRace() == 12 then
|
||||
player:LearnSpell(20577)
|
||||
player:LearnSpell(33697)
|
||||
player:SetLevel(20)
|
||||
player:Teleport(
|
||||
0,
|
||||
-10728.057617,
|
||||
-1131.12085,
|
||||
27.594067,
|
||||
1.180833
|
||||
)
|
||||
player:ModifyMoney(ToCopper(nil, 100))
|
||||
end
|
||||
if player:GetRace() == 9 then
|
||||
player:SetLevel(20)
|
||||
player:ModifyMoney(ToCopper(nil, 100))
|
||||
player:Teleport(
|
||||
1,
|
||||
-1049.596,
|
||||
-3645.963,
|
||||
23.878,
|
||||
4.468
|
||||
)
|
||||
end
|
||||
end
|
||||
)
|
||||
return ____exports
|
||||
29
dist/module/shared/account.lua
vendored
Normal file
29
dist/module/shared/account.lua
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__Class = ____lualib.__TS__Class
|
||||
local ____exports = {}
|
||||
____exports.AccountInfo = __TS__Class()
|
||||
local AccountInfo = ____exports.AccountInfo
|
||||
AccountInfo.name = "AccountInfo"
|
||||
function AccountInfo.prototype.____constructor(self, accountId)
|
||||
self.accountId = accountId
|
||||
end
|
||||
function AccountInfo.prototype.GetAccountMoney(self)
|
||||
local result = CharDBQuery("SELECT SUM(Money) as AccountMoney from acore_characters.characters WHERE account = " .. tostring(self.accountId))
|
||||
local row = result:GetRow()
|
||||
return row.AccountMoney
|
||||
end
|
||||
function AccountInfo.prototype.GetCharacters(self)
|
||||
local result = CharDBQuery("SELECT guid, name from characters WHERE account = " .. tostring(self.accountId))
|
||||
local characters = {}
|
||||
do
|
||||
local i = 0
|
||||
while i < result:GetRowCount() do
|
||||
local row = result:GetRow()
|
||||
characters[#characters + 1] = {guid = row.guid, name = row.name}
|
||||
result:NextRow()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
return characters
|
||||
end
|
||||
return ____exports
|
||||
33
dist/module/shared/money.lua
vendored
Normal file
33
dist/module/shared/money.lua
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local ____exports = {}
|
||||
local ____account = require("shared.account")
|
||||
local AccountInfo = ____account.AccountInfo
|
||||
____exports.GOLD_TO_COPPER = 10000
|
||||
--- Converts a copper cost to gold
|
||||
--
|
||||
-- @param cost <number> Cost of item in copper
|
||||
-- @returns number
|
||||
function ____exports.ToGold(self, cost)
|
||||
return math.floor(cost / ____exports.GOLD_TO_COPPER)
|
||||
end
|
||||
--- Converts a gold cost to copper
|
||||
--
|
||||
-- @param gold <number> Cost of item in gold
|
||||
-- @returns number
|
||||
function ____exports.ToCopper(self, gold)
|
||||
return gold * ____exports.GOLD_TO_COPPER
|
||||
end
|
||||
--- Gets a scaling tax for players to help with balancing the economy for guild features.
|
||||
--
|
||||
-- @param player Player
|
||||
-- @param tax amount of tax against player to levy number (0-100)
|
||||
-- @returns number result in copper
|
||||
function ____exports.GetPlayerTax(self, player, tax)
|
||||
local account = __TS__New(
|
||||
AccountInfo,
|
||||
player:GetAccountId()
|
||||
)
|
||||
return tax / 100 * account:GetAccountMoney()
|
||||
end
|
||||
return ____exports
|
||||
129
dist/module/shared/stats.lua
vendored
Normal file
129
dist/module/shared/stats.lua
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__Class = ____lualib.__TS__Class
|
||||
local Map = ____lualib.Map
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local __TS__Iterator = ____lualib.__TS__Iterator
|
||||
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
||||
local ____exports = {}
|
||||
--- Config
|
||||
local PLAYER_TYPE = "player"
|
||||
____exports.StatEvents = {TOKEN_CREATED = "token_created", TICKETS_AWARDED = "darkmoon_tickets_awarded"}
|
||||
--- Adds stats to database based on type of stat.
|
||||
____exports.Stats = __TS__Class()
|
||||
local Stats = ____exports.Stats
|
||||
Stats.name = "Stats"
|
||||
function Stats.prototype.____constructor(self, entity)
|
||||
self.stats = __TS__New(Map)
|
||||
self.entity = entity
|
||||
self:load()
|
||||
end
|
||||
function Stats.GetStatsByType(self, ____type, name)
|
||||
local result = CharDBQuery(((("SELECT id, name, value, updated FROM " .. ____type) .. "_stats WHERE name = '") .. name) .. "'")
|
||||
local stats = __TS__New(Map)
|
||||
if not result then
|
||||
return stats
|
||||
end
|
||||
do
|
||||
local i = 0
|
||||
while i < result:GetRowCount() do
|
||||
local row = result:GetRow()
|
||||
stats:set(row.id, row.value)
|
||||
result:NextRow()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
return stats
|
||||
end
|
||||
function Stats.prototype.load(self)
|
||||
local result = CharDBQuery((("SELECT id, name, value, updated FROM " .. self.entity.type) .. "_stats WHERE id = ") .. tostring(self.entity.id))
|
||||
if not result then
|
||||
return false
|
||||
end
|
||||
do
|
||||
local i = 0
|
||||
while i < result:GetRowCount() do
|
||||
local row = result:GetRow()
|
||||
local stat = {
|
||||
name = row.name,
|
||||
type = self.entity.type,
|
||||
value = row.value,
|
||||
updated = row.updated,
|
||||
loaded = true
|
||||
}
|
||||
self.stats:set(stat.name, stat)
|
||||
result:NextRow()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
function Stats.prototype.save(self)
|
||||
for ____, stat in __TS__Iterator(self.stats:values()) do
|
||||
if not stat.loaded then
|
||||
CharDBExecute(((((((((("INSERT INTO " .. self.entity.type) .. "_stats (id, name, value, updated) VALUES (") .. tostring(self.entity.id)) .. ", '") .. stat.name) .. "', ") .. tostring(stat.value)) .. ", ") .. tostring(stat.updated)) .. ")")
|
||||
PrintDebug((((((("Inserted " .. stat.name) .. " for ") .. self.entity.type) .. " ") .. tostring(self.entity.id)) .. " with value ") .. tostring(stat.value))
|
||||
else
|
||||
CharDBExecute(((((((((("UPDATE " .. self.entity.type) .. "_stats SET value = ") .. tostring(stat.value)) .. ", updated = ") .. tostring(stat.updated)) .. " WHERE id = ") .. tostring(self.entity.id)) .. " AND name = '") .. stat.name) .. "'")
|
||||
PrintDebug((((((("Updated " .. stat.name) .. " for ") .. self.entity.type) .. " ") .. tostring(self.entity.id)) .. " to ") .. tostring(stat.value))
|
||||
end
|
||||
end
|
||||
end
|
||||
function Stats.prototype.getStat(self, name)
|
||||
return self.stats:get(name)
|
||||
end
|
||||
function Stats.prototype.setStat(self, name, value)
|
||||
local stat = self.stats:get(name)
|
||||
if stat then
|
||||
stat.value = value
|
||||
stat.updated = GetGameTime(nil)
|
||||
else
|
||||
self.stats:set(
|
||||
name,
|
||||
{
|
||||
name = name,
|
||||
type = PLAYER_TYPE,
|
||||
value = value,
|
||||
updated = GetGameTime(nil),
|
||||
loaded = false
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
function Stats.prototype.increment(self, name, amount)
|
||||
if amount == nil then
|
||||
amount = 1
|
||||
end
|
||||
local stat = self.stats:get(name)
|
||||
if stat then
|
||||
stat.value = stat.value + amount
|
||||
stat.updated = GetGameTime(nil)
|
||||
else
|
||||
self.stats:set(
|
||||
name,
|
||||
{
|
||||
name = name,
|
||||
type = PLAYER_TYPE,
|
||||
value = 0,
|
||||
updated = GetGameTime(nil),
|
||||
loaded = false
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
--- Custom player stats that will be
|
||||
____exports.PlayerStats = __TS__Class()
|
||||
local PlayerStats = ____exports.PlayerStats
|
||||
PlayerStats.name = "PlayerStats"
|
||||
__TS__ClassExtends(PlayerStats, ____exports.Stats)
|
||||
function PlayerStats.prototype.____constructor(self, player)
|
||||
PlayerStats.____super.prototype.____constructor(
|
||||
self,
|
||||
{
|
||||
id = player:GetGUID(),
|
||||
type = PLAYER_TYPE
|
||||
}
|
||||
)
|
||||
self.playerStats = {}
|
||||
self.player = player
|
||||
end
|
||||
return ____exports
|
||||
23
dist/module/shared/triggers.lua
vendored
Normal file
23
dist/module/shared/triggers.lua
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
local ____exports = {}
|
||||
--- Sets a player trigger boolean that can be retieved later as needed
|
||||
--
|
||||
-- @param charTrigger TriggerInput
|
||||
function ____exports.SetTrigger(self, charTrigger)
|
||||
local sql = ("INSERT INTO player_trigger (triggerName, characterGuid, isSet) " .. ((((("VALUES (\"" .. charTrigger.triggerName) .. "\", ") .. tostring(charTrigger.characterGuid)) .. ", ") .. tostring(charTrigger.isSet)) .. ")") .. "ON DUPLICATE KEY UPDATE isSet=" .. tostring(charTrigger.isSet)
|
||||
CharDBExecute(sql)
|
||||
end
|
||||
--- Will return the value of the trigger if it exists, otherwise it will return false
|
||||
--
|
||||
-- @param charGuid number
|
||||
-- @param triggerName string
|
||||
-- @returns boolean
|
||||
function ____exports.GetTrigger(self, charGuid, triggerName)
|
||||
local sql = (("SELECT isSet from player_trigger WHERE triggerName=\"" .. triggerName) .. "\" and characterGuid=") .. tostring(charGuid)
|
||||
local result = CharDBQuery(sql)
|
||||
if result and result:GetRowCount() > 0 then
|
||||
return result:GetBool(0)
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
return ____exports
|
||||
19
dist/module/shared/ui-utils.lua
vendored
Normal file
19
dist/module/shared/ui-utils.lua
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
local ____exports = {}
|
||||
function ____exports.colors(self, name)
|
||||
local colors = {
|
||||
GREY = "|cff999999",
|
||||
RED = "|cffff0000",
|
||||
WHITE = "|cffFFFFFF",
|
||||
GREEN = "|cff1eff00",
|
||||
PURPLE = "|cff9F3FFF",
|
||||
BLUE = "|cff0070dd",
|
||||
ORANGE = "|cffFF8400"
|
||||
}
|
||||
local keyName = string.upper(name)
|
||||
if colors[keyName] then
|
||||
return colors[keyName]
|
||||
else
|
||||
return colors.WHITE
|
||||
end
|
||||
end
|
||||
return ____exports
|
||||
194
dist/module/special/gambler/gambler.client.lua
vendored
Normal file
194
dist/module/special/gambler/gambler.client.lua
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
---
|
||||
|
||||
local AIO = AIO or require("AIO")
|
||||
if not AIO.AddAddon() then
|
||||
--- Configuration options
|
||||
local LOW_BET_SIZE_GOLD = 20
|
||||
local HIGH_BET_SIZE_GOLD = 100
|
||||
local gamblerHandlers = AIO.AddHandlers("GamblerMain", {})
|
||||
local classImages = {
|
||||
"Interface/Gambler/druid",
|
||||
"Interface/Gambler/deathknight",
|
||||
"Interface/Gambler/hunter",
|
||||
"Interface/Gambler/mage",
|
||||
"Interface/Gambler/paladin",
|
||||
"Interface/Gambler/priest",
|
||||
"Interface/Gambler/rogue",
|
||||
"Interface/Gambler/shaman",
|
||||
"Interface/Gambler/warlock",
|
||||
"Interface/Gambler/warrior"
|
||||
}
|
||||
local slotSpin = {}
|
||||
local multiplier = 1
|
||||
local function getRandomClassImage(self)
|
||||
local spinIndex = math.floor(math.random() * #classImages)
|
||||
slotSpin[#slotSpin + 1] = spinIndex
|
||||
return classImages[spinIndex + 1]
|
||||
end
|
||||
local function resetSpin(self)
|
||||
slotSpin = {}
|
||||
end
|
||||
local function determineWin(self)
|
||||
local win = 0
|
||||
local gold = 0
|
||||
local tokens = 0
|
||||
if slotSpin[1] == 1 and slotSpin[2] == 1 and slotSpin[3] == 1 then
|
||||
if multiplier == 3 then
|
||||
tokens = 100
|
||||
end
|
||||
gold = multiplier * 5000
|
||||
win = 2
|
||||
end
|
||||
if slotSpin[1] == slotSpin[2] and slotSpin[2] == slotSpin[3] then
|
||||
if multiplier == 3 then
|
||||
tokens = 50
|
||||
end
|
||||
gold = multiplier * 1000
|
||||
win = 1
|
||||
end
|
||||
if slotSpin[1] == slotSpin[2] and slotSpin[3] == 1 or slotSpin[1] == slotSpin[3] and slotSpin[2] == 1 or slotSpin[2] == slotSpin[3] and slotSpin[1] == 1 or slotSpin[1] == 1 and slotSpin[2] == 1 or slotSpin[1] == 1 and slotSpin[3] == 1 or slotSpin[2] == 1 and slotSpin[3] == 1 then
|
||||
if multiplier == 3 then
|
||||
tokens = 20
|
||||
end
|
||||
gold = multiplier * 500
|
||||
win = 1
|
||||
end
|
||||
if slotSpin[1] == slotSpin[2] and win == 0 then
|
||||
gold = multiplier * 100
|
||||
win = 1
|
||||
if slotSpin[2] == 1 then
|
||||
if multiplier == 3 then
|
||||
tokens = 3
|
||||
end
|
||||
gold = multiplier * 250
|
||||
win = 1
|
||||
end
|
||||
end
|
||||
if (slotSpin[1] == 1 or slotSpin[2] == 1 or slotSpin[3] == 1) and win == 0 then
|
||||
if multiplier == 3 then
|
||||
tokens = 0
|
||||
gold = 200
|
||||
else
|
||||
tokens = 0
|
||||
gold = 40
|
||||
end
|
||||
win = 1
|
||||
end
|
||||
if win > 0 then
|
||||
PlaySoundFile("Sound\\Interface\\LootCoinLarge.wav", "Master")
|
||||
AIO.Handle("GamblerMain", "AwardSlotWin", gold, tokens)
|
||||
end
|
||||
return win
|
||||
end
|
||||
local function SpinSlots(self, SlotFrame, Slot)
|
||||
local timer = 1
|
||||
local counter = 1
|
||||
PlaySoundFile("Sound\\Doodad\\GnomeMachine02StandLoop.wav", "Master")
|
||||
SlotFrame:SetScript(
|
||||
"OnUpdate",
|
||||
function(frame, elapsed)
|
||||
timer = timer + elapsed
|
||||
if timer > 0.2 then
|
||||
counter = counter + 1
|
||||
resetSpin(_G)
|
||||
timer = 0
|
||||
Slot[1]:SetTexture(getRandomClassImage(_G))
|
||||
Slot[2]:SetTexture(getRandomClassImage(_G))
|
||||
Slot[3]:SetTexture(getRandomClassImage(_G))
|
||||
if counter > 22 then
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
determineWin(_G)
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
local function ShowSlots(self, player)
|
||||
local GamblerMainFrame = CreateFrame("Frame", "GamblerMainFrame", UIParent, "UIPanelDialogTemplate")
|
||||
GamblerMainFrame:SetSize(512, 324)
|
||||
GamblerMainFrame:SetMovable(false)
|
||||
GamblerMainFrame:SetPoint("CENTER")
|
||||
GamblerMainFrame:EnableMouse(true)
|
||||
GamblerMainFrame:EnableKeyboard(true)
|
||||
GamblerMainFrame:Hide()
|
||||
local Title = GamblerMainFrame:CreateFontString("TitleFrame", "OVERLAY", "GameFontHighlight")
|
||||
Title:SetPoint("TOPLEFT", 15, -10)
|
||||
Title:SetText("Heros Slots")
|
||||
Title:SetFont("Fonts\\FRIZQT__.TTF", 10)
|
||||
local Slots = CreateFrame("Frame", "SlotsFrame", GamblerMainFrame)
|
||||
Slots:SetSize(420, 160)
|
||||
Slots:SetPoint("CENTER", 0, 25)
|
||||
Slots:SetFrameLevel(1)
|
||||
Slots:SetBackdrop({
|
||||
bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
|
||||
edgeFile = "Interface/DialogFrame/UI-DialogBox-Border",
|
||||
tile = true,
|
||||
tileSize = 32,
|
||||
edgeSize = 32,
|
||||
insets = {left = 11, right = 12, top = 12, bottom = 11}
|
||||
})
|
||||
local Slot1 = Slots:CreateTexture("Slot1Texture", nil, Slots)
|
||||
Slot1:SetSize(128, 128)
|
||||
Slot1:SetAlpha(0.85)
|
||||
Slot1:SetPoint("TOPLEFT", 13, -16)
|
||||
Slot1:SetTexture(getRandomClassImage(_G))
|
||||
local Slot1Point, Slot1Region, Slot1RelPoint, x1offset, y1offset = Slot1:GetPoint()
|
||||
local Slot2 = Slots:CreateTexture("Slot2Texture", nil, Slots)
|
||||
Slot2:SetSize(128, 128)
|
||||
Slot2:SetAlpha(0.85)
|
||||
Slot2:SetPoint(
|
||||
"TOPLEFT",
|
||||
Slot1Region,
|
||||
Slot1RelPoint,
|
||||
x1offset + 128 + 5,
|
||||
y1offset
|
||||
)
|
||||
Slot2:SetTexture(getRandomClassImage(_G))
|
||||
local Slot2Point, Slot2Region, Slot2RelPoint, x2offset, y2offset = Slot2:GetPoint()
|
||||
local Slot3 = Slots:CreateTexture("Slot3Texture", nil, Slots)
|
||||
Slot3:SetSize(128, 128)
|
||||
Slot3:SetAlpha(0.85)
|
||||
Slot3:SetPoint(
|
||||
"TOPLEFT",
|
||||
Slot2Region,
|
||||
Slot2RelPoint,
|
||||
x2offset + 128 + 5,
|
||||
y2offset
|
||||
)
|
||||
Slot3:SetTexture(getRandomClassImage(_G))
|
||||
local SpinButton = CreateFrame("Button", "SpinButtonLow", GamblerMainFrame, "UIPanelButtonTemplate")
|
||||
SpinButton:SetSize(128, 32)
|
||||
SpinButton:SetPoint("CENTER", -80, -80)
|
||||
SpinButton:SetText(("Bet " .. tostring(LOW_BET_SIZE_GOLD)) .. "g Spin")
|
||||
SpinButton:SetFrameLevel(2)
|
||||
SpinButton:SetScript(
|
||||
"OnClick",
|
||||
function(frame, mouse, button)
|
||||
resetSpin(_G)
|
||||
multiplier = 1
|
||||
AIO.Handle("GamblerMain", "PayForSpin", LOW_BET_SIZE_GOLD * 10000)
|
||||
end
|
||||
)
|
||||
local SpinButtonHigh = CreateFrame("Button", "SpinButtonHigh", GamblerMainFrame, "UIPanelButtonTemplate")
|
||||
SpinButtonHigh:SetSize(128, 32)
|
||||
SpinButtonHigh:SetPoint("CENTER", 80, -80)
|
||||
SpinButtonHigh:SetText(("Bet " .. tostring(HIGH_BET_SIZE_GOLD)) .. "g Spin")
|
||||
SpinButtonHigh:SetFrameLevel(2)
|
||||
SpinButtonHigh:SetScript(
|
||||
"OnClick",
|
||||
function(frame, mouse, button)
|
||||
resetSpin(_G)
|
||||
multiplier = 3
|
||||
AIO.Handle("GamblerMain", "PayForSpin", HIGH_BET_SIZE_GOLD * 10000)
|
||||
end
|
||||
)
|
||||
gamblerHandlers.StartSpin = function(____, player)
|
||||
SpinSlots(_G, Slots, {Slot1, Slot2, Slot3})
|
||||
end
|
||||
GamblerMainFrame:Show()
|
||||
return GamblerMainFrame
|
||||
end
|
||||
gamblerHandlers.ShowFrame = function(____, player)
|
||||
ShowSlots(_G, player)
|
||||
end
|
||||
end
|
||||
70
dist/module/special/gambler/gambler.server.lua
vendored
Normal file
70
dist/module/special/gambler/gambler.server.lua
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
|
||||
local AIO = AIO or require("AIO")
|
||||
--- Game Object that will start the slot machine up
|
||||
SLOT_GAME_OBJECT = 750001
|
||||
--- Token Id of the currency you want to aware the players.
|
||||
TOKEB_ID = 910001
|
||||
ShowGambler = function(____, event, player, command)
|
||||
if command == "gamble" then
|
||||
AIO.Handle(player, "GamblerMain", "ShowFrame")
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function PayForSpin(player, cost)
|
||||
local money = player:GetCoinage()
|
||||
if money >= cost then
|
||||
player:ModifyMoney(cost * -1)
|
||||
AIO.Handle(player, "GamblerMain", "StartSpin")
|
||||
else
|
||||
player:SendNotification("You don't have enough money to spin the slots!")
|
||||
player:PlayDirectSound(8959, player)
|
||||
end
|
||||
end
|
||||
function AwardSlotWin(player, gold, tokens)
|
||||
player:ModifyMoney(gold * 10000)
|
||||
if tokens > 0 then
|
||||
player:AddItem(TOKEB_ID, tokens)
|
||||
end
|
||||
if tokens > 75 then
|
||||
player:SendChatMessageToPlayer(
|
||||
1,
|
||||
0,
|
||||
((("|cff1eff00I HIT THE JACKPOT! I won " .. tostring(gold)) .. " gold and ") .. tostring(tokens)) .. " tokens!",
|
||||
player
|
||||
)
|
||||
else
|
||||
if tokens > 0 then
|
||||
player:SendChatMessageToPlayer(
|
||||
1,
|
||||
0,
|
||||
((("|cff1eff00I won " .. tostring(gold)) .. " gold and ") .. tostring(tokens)) .. " tokens!",
|
||||
player
|
||||
)
|
||||
else
|
||||
player:SendChatMessageToPlayer(
|
||||
1,
|
||||
0,
|
||||
("|cff1eff00I won " .. tostring(gold)) .. " gold",
|
||||
player
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
SendSlotStart = function(____, event, gameobject, player)
|
||||
AIO.Handle(player, "GamblerMain", "ShowFrame")
|
||||
return true
|
||||
end
|
||||
gamblerHandlers = AIO.AddHandlers("GamblerMain", {PayForSpin = PayForSpin, AwardSlotWin = AwardSlotWin})
|
||||
RegisterPlayerEvent(
|
||||
42,
|
||||
function(...) return ShowGambler(_G, ...) end
|
||||
)
|
||||
RegisterGameObjectEvent(
|
||||
SLOT_GAME_OBJECT,
|
||||
14,
|
||||
function(...) return SendSlotStart(_G, ...) end
|
||||
)
|
||||
Reference in New Issue
Block a user