repo_name stringlengths 6 69 | path stringlengths 6 178 | copies stringclasses 278
values | size stringlengths 4 7 | content stringlengths 671 917k | license stringclasses 15
values |
|---|---|---|---|---|---|
dalqak/slf | plugins/all.lua | 1321 | 4661 | do
data = load_data(_config.moderation.data)
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'Chat stats:\n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
local function get_group_type(target)
local data = load_data(_config.moderation.data)
local group_type = data[tostring(target)]['group_type']
if not group_type or group_type == nil then
return 'No group type available.'
end
return group_type
end
local function show_group_settings(target)
local data = load_data(_config.moderation.data)
if data[tostring(target)] then
if data[tostring(target)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local settings = data[tostring(target)]['settings']
local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX
return text
end
local function get_description(target)
local data = load_data(_config.moderation.data)
local data_cat = 'description'
if not data[tostring(target)][data_cat] then
return 'No description available.'
end
local about = data[tostring(target)][data_cat]
return about
end
local function get_rules(target)
local data = load_data(_config.moderation.data)
local data_cat = 'rules'
if not data[tostring(target)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(target)][data_cat]
return rules
end
local function modlist(target)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] or not data[tostring(groups)][tostring(target)] then
return 'Group is not added or is Realm.'
end
if next(data[tostring(target)]['moderators']) == nil then
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators :\n'
for k,v in pairs(data[tostring(target)]['moderators']) do
message = message ..i..' - @'..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function get_link(target)
local data = load_data(_config.moderation.data)
local group_link = data[tostring(target)]['settings']['set_link']
if not group_link or group_link == nil then
return "No link"
end
return "Group link:\n"..group_link
end
local function all(target, receiver)
local text = "All the things I know about this group\n\n"
local group_type = get_group_type(target)
text = text.."Group Type: \n"..group_type
local settings = show_group_settings(target)
text = text.."\n\nGroup settings: \n"..settings
local rules = get_rules(target)
text = text.."\n\nRules: \n"..rules
local description = get_description(target)
text = text.."\n\nAbout: \n"..description
local modlist = modlist(target)
text = text.."\n\nMods: \n"..modlist
local link = get_link(target)
text = text.."\n\nLink: \n"..link
local stats = chat_stats(target)
text = text.."\n\n"..stats
local ban_list = ban_list(target)
text = text.."\n\n"..ban_list
local file = io.open("./groups/all/"..target.."all.txt", "w")
file:write(text)
file:flush()
file:close()
send_document(receiver,"./groups/all/"..target.."all.txt", ok_cb, false)
return
end
function run(msg, matches)
if matches[1] == "all" and matches[2] and is_owner2(msg.from.id, matches[2]) then
local receiver = get_receiver(msg)
local target = matches[2]
return all(target, receiver)
end
if not is_owner(msg) then
return
end
if matches[1] == "all" and not matches[2] then
local receiver = get_receiver(msg)
if not is_owner(msg) then
return
end
return all(msg.to.id, receiver)
end
end
return {
patterns = {
"^[!/](all)$",
"^[!/](all) (%d+)$"
},
run = run
}
end
| agpl-3.0 |
lichtl/darkstar | scripts/globals/weaponskills/heavy_swing.lua | 25 | 1367 | -----------------------------------
-- Heavy Swing
-- Staff weapon skill
-- Skill Level: 5
-- Deacription:Delivers a single-hit attack. Damage varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Thunder Gorget.
-- Aligned with the Thunder Belt.
-- Element: None
-- Modifiers: STR:30%
-- 100%TP 200%TP 300%TP
-- 1.00 1.25 2.25
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {};
params.numHits = 1;
params.ftp100 = 1; params.ftp200 = 1.25; params.ftp300 = 2.25;
params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 1.0;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, tp, primary, action, taChar, params);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/summon.lua | 10 | 9706 |
require("scripts/globals/common")
require("scripts/globals/status")
require("scripts/globals/msg")
function getSummoningSkillOverCap(avatar)
local summoner = avatar:getMaster()
local summoningSkill = summoner:getSkillLevel(dsp.skill.SUMMONING_MAGIC)
local maxSkill = summoner:getMaxSkillLevel(avatar:getMainLvl(), dsp.job.SMN, dsp.skill.SUMMONING_MAGIC)
return math.max(summoningSkill - maxSkill, 0)
end
function AvatarPhysicalMove(avatar,target,skill,numberofhits,accmod,dmgmod,dmgmodsubsequent,tpeffect,mtp100,mtp200,mtp300)
local returninfo = {}
local acc = avatar:getACC() + utils.clamp(getSummoningSkillOverCap(avatar), 0, 200)
local eva = target:getEVA()
local dmg = avatar:getWeaponDmg()
local minFstr, maxFstr = avatarFSTR(avatar:getStat(dsp.mod.STR), target:getStat(dsp.mod.VIT))
local ratio = avatar:getStat(dsp.mod.ATT) / target:getStat(dsp.mod.DEF)
-- Note: Avatars do not have any level correction. This is why they are so good on Wyrms! // https://kegsay.livejournal.com/tag/smn!
local hitrate = utils.clamp(acc - eva, 20, 95)
-- add on native crit hit rate (guesstimated, it actually follows an exponential curve)
local critrate = (avatar:getStat(dsp.mod.DEX) - target:getStat(dsp.mod.AGI)) * 0.005 -- assumes +0.5% crit rate per 1 dDEX
critrate = critrate + avatar:getMod(dsp.mod.CRITHITRATE) / 100
critrate = utils.clamp(critrate, 0.05, 0.2);
-- Applying pDIF
if ratio <= 1 then
maxRatio = 1
minRatio = 1/3
elseif ratio < 1.6 then
maxRatio = (2 * ratio + 1) / 3
minRatio = (7 * ratio - 4) / 9
elseif ratio <= 1.8 then
maxRatio = 1.8
minRatio = 1
elseif ratio < 3.6 then
maxRatio = 2.4 * ratio - 2.52
minRatio = 5 * ratio / 3 - 2
else
maxRatio = 4.2
minRatio = 4
end
-- start the hits
local hitsdone = 1
local hitslanded = 0
local hitdmg = 0
local finaldmg = 0
if math.random() < hitrate then
hitdmg = avatarHitDmg(dmg, minRatio, maxRatio, minFstr, maxFstr, critrate)
finaldmg = finaldmg + hitdmg * dmgmod
hitslanded = hitslanded + 1
end
while hitsdone < numberofhits do
if math.random() < hitrate then
hitdmg = avatarHitDmg(dmg, minRatio, maxRatio, minFstr, maxFstr, critrate)
finaldmg = finaldmg + hitdmg * dmgmodsubsequent
hitslanded = hitslanded + 1
end
hitsdone = hitsdone + 1
end
-- all hits missed
if hitslanded == 0 or finaldmg == 0 then
finaldmg = 0
hitslanded = 0
skill:setMsg(dsp.msg.basic.SKILL_MISS)
-- some hits hit
else
target:wakeUp()
end
-- apply ftp bonus
if tpeffect == TP_DMG_BONUS then
finaldmg = finaldmg * avatarFTP(skill:getTP(), mtp100, mtp200, mtp300)
end
returninfo.dmg = finaldmg
returninfo.hitslanded = hitslanded
return returninfo
end
-- minFstr = dSTR/4 + 0.5
-- maxFstr = dSTR/4 + 0.25
function avatarFSTR(att_str, def_vit)
local dSTR = att_str - def_vit
return math.floor(dSTR / 4 + 0.5), math.floor(dSTR / 4 + 0.25)
end
function avatarHitDmg(dmg, pdifMin, pdifMax, fstrMin, fstrMax, critrate)
local fstr = math.random(fstrMin, fstrMax)
local pdif = math.random(pdifMin * 1000, pdifMax * 1000) / 1000
if math.random() < critrate then
pdif = math.min(pdif + 1, 4.2)
end
return (dmg + fstr) * pdif
end
function AvatarFinalAdjustments(dmg,mob,skill,target,skilltype,skillparam,shadowbehav)
-- physical attack missed, skip rest
if skilltype == dsp.attackType.PHYSICAL and dmg == 0 then
return 0
end
-- set message to damage
-- this is for AoE because its only set once
skill:setMsg(dsp.msg.basic.DAMAGE)
--Handle shadows depending on shadow behaviour / skilltype
if shadowbehav < 5 and shadowbehav ~= MOBPARAM_IGNORE_SHADOWS then --remove 'shadowbehav' shadows.
targShadows = target:getMod(dsp.mod.UTSUSEMI)
shadowType = dsp.mod.UTSUSEMI
if targShadows == 0 then --try blink, as utsusemi always overwrites blink this is okay
targShadows = target:getMod(dsp.mod.BLINK)
shadowType = dsp.mod.BLINK
end
if targShadows > 0 then
-- Blink has a VERY high chance of blocking tp moves, so im assuming its 100% because its easier!
if targShadows >= shadowbehav then --no damage, just suck the shadows
skill:setMsg(dsp.msg.basic.SHADOW_ABSORB)
target:setMod(shadowType, targShadows - shadowbehav)
if shadowType == dsp.mod.UTSUSEMI then --update icon
effect = target:getStatusEffect(dsp.effect.COPY_IMAGE)
if effect ~= nil then
if targShadows - shadowbehav == 0 then
target:delStatusEffect(dsp.effect.COPY_IMAGE)
target:delStatusEffect(dsp.effect.BLINK)
elseif targShadows - shadowbehav == 1 then
effect:setIcon(dsp.effect.COPY_IMAGE)
elseif targShadows - shadowbehav == 2 then
effect:setIcon(dsp.effect.COPY_IMAGE_2)
elseif targShadows - shadowbehav == 3 then
effect:setIcon(dsp.effect.COPY_IMAGE_3)
end
end
end
return shadowbehav
else -- less shadows than this move will take, remove all and factor damage down
dmg = dmg * (shadowbehav - targShadows) / shadowbehav
target:setMod(dsp.mod.UTSUSEMI, 0)
target:setMod(dsp.mod.BLINK, 0)
target:delStatusEffect(dsp.effect.COPY_IMAGE)
target:delStatusEffect(dsp.effect.BLINK)
end
end
elseif shadowbehav == MOBPARAM_WIPE_SHADOWS then --take em all!
target:setMod(dsp.mod.UTSUSEMI, 0)
target:setMod(dsp.mod.BLINK, 0)
target:delStatusEffect(dsp.effect.COPY_IMAGE)
target:delStatusEffect(dsp.effect.BLINK)
end
-- handle Third Eye using shadowbehav as a guide
teye = target:getStatusEffect(dsp.effect.THIRD_EYE)
if teye ~= nil and skilltype == dsp.attackType.PHYSICAL then --T.Eye only procs when active with PHYSICAL stuff
if shadowbehav == MOBPARAM_WIPE_SHADOWS then --e.g. aoe moves
target:delStatusEffect(dsp.effect.THIRD_EYE)
elseif shadowbehav ~= MOBPARAM_IGNORE_SHADOWS then --it can be absorbed by shadows
--third eye doesnt care how many shadows, so attempt to anticipate, but reduce
--chance of anticipate based on previous successful anticipates.
prevAnt = teye:getPower()
if prevAnt == 0 then
--100% proc
teye:setPower(1)
skill:setMsg(dsp.msg.basic.ANTICIPATE)
return 0
end
if math.random() * 10 < 8 - prevAnt then
--anticipated!
teye:setPower(prevAnt+1)
skill:setMsg(dsp.msg.basic.ANTICIPATE)
return 0
end
target:delStatusEffect(dsp.effect.THIRD_EYE)
end
end
--TODO: Handle anything else (e.g. if you have Magic Shield and its a Magic skill, then do 0 damage.
if skilltype == dsp.attackType.PHYSICAL and target:hasStatusEffect(dsp.effect.PHYSICAL_SHIELD) then
return 0
end
if skilltype == dsp.attackType.RANGED and target:hasStatusEffect(dsp.effect.ARROW_SHIELD) then
return 0
end
-- handle elemental resistence
if skilltype == dsp.attackType.MAGICAL and target:hasStatusEffect(dsp.effect.MAGIC_SHIELD) then
return 0
end
-- handling phalanx
dmg = dmg - target:getMod(dsp.mod.PHALANX)
if dmg < 0 then
return 0
end
--handle invincible
if target:hasStatusEffect(dsp.effect.INVINCIBLE) and skilltype == dsp.attackType.PHYSICAL then
return 0
end
-- handle pd
if target:hasStatusEffect(dsp.effect.PERFECT_DODGE) or target:hasStatusEffect(dsp.effect.TOO_HIGH) and skilltype == dsp.attackType.PHYSICAL then
return 0
end
-- Calculate Blood Pact Damage before stoneskin
dmg = dmg + dmg * mob:getMod(dsp.mod.BP_DAMAGE) / 100
-- handling stoneskin
dmg = utils.stoneskin(target, dmg)
return dmg
end
-- returns true if mob attack hit
-- used to stop tp move status effects
function AvatarPhysicalHit(skill, dmg)
-- if message is not the default. Then there was a miss, shadow taken etc
return skill:getMsg() == dsp.msg.basic.DAMAGE
end
function avatarFTP(tp,ftp1,ftp2,ftp3)
if tp < 1000 then
tp = 1000
end
if tp >= 1000 and tp < 2000 then
return ftp1 + (ftp2 - ftp1) / 100 * (tp - 1000)
elseif tp >= 2000 and tp <= 3000 then
-- generate a straight line between ftp2 and ftp3 and find point @ tp
return ftp2 + (ftp3 - ftp2) / 100 * (tp - 2000)
end
return 1 -- no ftp mod
end
-- Checks if the summoner is in a Trial Size Avatar Mini Fight (used to restrict summoning while in bcnm)
function avatarMiniFightCheck(caster)
local result = 0
local bcnmid
if caster:hasStatusEffect(dsp.effect.BATTLEFIELD) then
bcnmid = caster:getStatusEffect(dsp.effect.BATTLEFIELD):getPower()
if bcnmid == 418 or bcnmid == 609 or bcnmid == 450 or bcnmid == 482 or bcnmid == 545 or bcnmid == 578 then -- Mini Avatar Fights
result = 40 -- Cannot use <spell> in this area.
end
end
return result
end
| gpl-3.0 |
thermofisherlsms/xcalibur-workbench | mdiNotebook.lua | 1 | 9336 | -- Copyright (c) 2016 Thermo Fisher Scientific
--
-- 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.
-- mdiNotebook.lua
-- Container object for MDI dialog
-- OO structure from http://lua-users.org/wiki/ObjectOrientationTutorial
-- Load necessary libraries
local templates = require("templates")
local RawFile = require("LuaRawFile")
-- Get assemblies
-- Get constructors
local ContextMenuStrip = luanet.import_type("System.Windows.Forms.ContextMenuStrip")
local Form = luanet.import_type("System.Windows.Forms.Form")
local TabControl = luanet.import_type("System.Windows.Forms.TabControl")
local ToolStripMenuItem = luanet.import_type("System.Windows.Forms.ToolStripMenuItem")
-- Get enumerations
local DockStyle = luanet.import_type("System.Windows.Forms.DockStyle")
local MouseButtons = luanet.import_type("System.Windows.Forms.MouseButtons")
local TabAlignment = luanet.import_type("System.Windows.Forms.TabAlignment")
-- local variables
-- forward declarations for local functions
local noteBookActivated, noteBookClosed
-- local functions
local function DeleteActivePageCB(sender, args)
local self = sender.Tag -- Tag is the mdiNotebook
self:RemovePage(self.pageList.active)
end
-- Start of the mdiPage object
local mdiNoteBook = {}
mdiNoteBook.__index = mdiNoteBook
-- Table for controlling all displayed pages
local noteBookList = {} -- Contains all notebooks
noteBookList.active = false -- will contain the active notebook
-- The notebook list can be accessed either from any notebook
-- or it can be accessed directly from the results of the
-- require ("mdiNoteBook") return value
mdiNoteBook.noteBookList = noteBookList
setmetatable(mdiNoteBook, {
__call = function (cls, ...)
local self = setmetatable({}, cls)
self:_init(...)
return self
end,})
---Create a new object of the class
function mdiNoteBook:_init(args)
args = args or {}
self:CreateForm(args) -- Create the MDI Form
-- Add to the noteBookList
-- Do this after creating the form
table.insert(noteBookList, self)
noteBookList.active = self
-- Add page list
self.pageList = {}
self.pageList.active = false
if args.rawFile then -- if rawfile specified
self.rawFile = args.rawFile -- just use it
elseif args.fileName then -- otherwise if fileName specified
if not self:OpenFile(args.fileName) then -- try to open it
return nil
end
end
-- Add pages if function is provided
if args.AddPages then args.AddPages(self) end
self.form:Show()
end
-- Loop through the notebooks to find a match
-- and then set the active notebook
-- The sender is the MDI Form, so note the use of . instead of :
function mdiNoteBook.ActivatedCB(sender, args)
noteBookList.active = sender.Tag
end
function mdiNoteBook:AddPage(page)
self.tabControl.TabPages:Add(page.pageControl)
table.insert(self.pageList, page)
self.pageList.active = page
end
function mdiNoteBook:Close()
-- This will trigger the ClosedCB() below
self.form:Close() -- Close the form
return
end
-- The sender is the MDI Form, so note the use of . instead of :
function mdiNoteBook.ClosedCB(sender, args)
local thisNoteBook = sender.Tag -- Get the parent notebook for the form
-- Remove the notebook from the noteBookList
for index, noteBook in ipairs(noteBookList) do
if thisNoteBook == noteBook then
table.remove(noteBookList, index)
noteBookList.active = false
break
end
end
-- If no rawFile, then we are done
local rawFile = thisNoteBook.rawFile
if not rawFile then return end
-- If the raw file is used anywhere else, we are done
for index, noteBook in ipairs(noteBookList) do
if noteBook.rawFile == rawFile then return end
end
-- Finally, close the raw file
rawFile:Close()
return
end
function mdiNoteBook:CreateForm(args)
args = args or {}
local mdiForm = Form()
mdiForm.MdiParent = mainForm
mdiForm.Activated:Add(mdiNoteBook.ActivatedCB)
mdiForm.Closed:Add(mdiNoteBook.ClosedCB)
mdiForm.Text = self:GetFormTitle(args)
mdiForm.Height = args.height or 0.8 * mainForm.Height
mdiForm.Width = args.width or 0.8* mainForm.Width
mdiForm.Tag = self -- Set tag for referencing in callback
self.form = mdiForm
-- Create the Tab Control
local tabControl = TabControl()
self.tabControl = tabControl
tabControl.Parent = mdiForm
tabControl.Dock = DockStyle.Fill
tabControl.Alignment = TabAlignment.Right
tabControl.Tag = self
local menu = ContextMenuStrip() -- Get a ContextMenuStrip
tabControl.ContextMenuStrip = menu
local item = ToolStripMenuItem("Delete Active Page") -- Get a ToolStripMenuItem
item.Click:Add(DeleteActivePageCB) -- Add a callback
item.Tag = self -- Set tag to the page
menu.Items:Add(item) -- Add it to the menu
end
-- Dispose of all .NET objects
function mdiNoteBook:Dispose()
print ("Disposing pages")
for index, page in ipairs(self.pageList) do
page:Dispose()
end
end
function mdiNoteBook:GetFormTitle(args)
args = args or {}
local title
if args.title then -- Supplied title is most important
title = args.title
elseif args.fileName then -- then use file name
title = args.fileName
else -- otherwise use a generic name
title = "NoteBook"
end
-- Loop through and compare to current titles
local testCount = 1
while not titleOK do
local testTitle = title
local titleMatched = false
if testCount > 1 then testTitle = testTitle .. "_" .. tostring(testCount) end
for index, noteBook in ipairs(noteBookList) do
if testTitle == noteBook.form.Text then
titleMatched = true
break
end
end
if not titleMatched then return testTitle end
testCount = testCount + 1
end
end
function mdiNoteBook:GetUniquePageName(baseName)
local i = 1
while true do
local pageName = string.format("%s_%d", baseName, i)
local unique = true
for index, page in ipairs(self.pageList) do
if pageName == page.pageControl.Text then
unique = false
break
end
end
if unique then return pageName end
i = i + 1
end
end
function mdiNoteBook:OpenFile(fileName)
self.rawFile = RawFile.New(fileName)
if type(self.rawFile) ~= "userdata" then
print ("Unable to open " .. fileName)
print (self.rawFile)
return nil
end
self.rawFile:Open()
if not self.rawFile.IsOpen then
print ("Unable to open " .. self.rawFile)
return nil
end
self.fullFileName = fileName
-- Find a backslash followed by anthing other than a backslash,
-- right before the end of the string
local index = string.find(fileName, "\\[^\\]*$")
if index then
self.pathName = string.sub(fileName, 1, index)
self.fileName = string.sub(fileName, index + 1)
end
return true
end
function mdiNoteBook:RemovePage(page)
-- This likely leaks memory associated with this page
-- and associated .NET objects but it shouldn't happen
-- too frequently, so it should be relatively safe.
local activeIndex
for pageIndex, thisPage in ipairs(self.pageList) do
if thisPage == page then
activeIndex = pageIndex
break
end
end
table.remove(self.pageList, activeIndex)
self.tabControl.TabPages:Remove(page.pageControl)
end
-- The following are not meant to be part of the mdiNoteBook object
-- but are instead ways to access the active objects. Thus they
-- use "." notation instead of ":" notation, but can be called either way.
function mdiNoteBook.GetActiveNoteBook()
return noteBookList.active
end
function mdiNoteBook.GetActivePage()
local activeNotebook = mdiNoteBook.GetActiveNoteBook()
if not activeNotebook then return false end
return activeNotebook.pageList.active
end
function mdiNoteBook.GetActivePane()
local activePage = mdiNoteBook.GetActivePage()
if not activePage then return false end
-- Not all pages have panes
if not activePage.paneList then return false end
return activePage.paneList.active
end
return mdiNoteBook | mit |
RunAwayDSP/darkstar | scripts/zones/Chamber_of_Oracles/npcs/Pedestal_of_Fire.lua | 9 | 2176 | -----------------------------------
-- Area: Chamber of Oracles
-- NPC: Pedestal of Fire
-- Involved in Zilart Mission 7
-- !pos 199 -2 36 168
-------------------------------------
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
local ID = require("scripts/zones/Chamber_of_Oracles/IDs");
-------------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local ZilartStatus = player:getCharVar("ZilartStatus");
if (player:getCurrentMission(ZILART) == dsp.mission.id.zilart.THE_CHAMBER_OF_ORACLES) then
if (player:hasKeyItem(dsp.ki.FIRE_FRAGMENT)) then
player:delKeyItem(dsp.ki.FIRE_FRAGMENT);
player:setCharVar("ZilartStatus",ZilartStatus + 1);
player:messageSpecial(ID.text.YOU_PLACE_THE,dsp.ki.FIRE_FRAGMENT);
if (ZilartStatus == 255) then
player:startEvent(1);
end
elseif (ZilartStatus == 255) then -- Execute cutscene if the player is interrupted.
player:startEvent(1);
else
player:messageSpecial(ID.text.IS_SET_IN_THE_PEDESTAL,dsp.ki.FIRE_FRAGMENT);
end
elseif (player:hasCompletedMission(ZILART,dsp.mission.id.zilart.THE_CHAMBER_OF_ORACLES)) then
player:messageSpecial(ID.text.HAS_LOST_ITS_POWER,dsp.ki.FIRE_FRAGMENT);
else
player:messageSpecial(ID.text.PLACED_INTO_THE_PEDESTAL);
end
end;
function onEventUpdate(player,csid,option)
-- printf("onUpdate CSID: %u",csid);
-- printf("onUpdate RESULT: %u",option);
end;
function onEventFinish(player,csid,option)
-- printf("onFinish CSID: %u",csid);
-- printf("onFinish RESULT: %u",option);
if (csid == 1) then
player:addTitle(dsp.title.LIGHTWEAVER);
player:setCharVar("ZilartStatus",0);
player:addKeyItem(dsp.ki.PRISMATIC_FRAGMENT);
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.PRISMATIC_FRAGMENT);
player:completeMission(ZILART,dsp.mission.id.zilart.THE_CHAMBER_OF_ORACLES);
player:addMission(ZILART,dsp.mission.id.zilart.RETURN_TO_DELKFUTTS_TOWER);
end
end;
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/Bastok_Markets/npcs/Harmodios.lua | 9 | 1815 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Harmodios
-- Standard Merchant NPC
-- !pos -79.928 -4.824 -135.114 235
-----------------------------------
local ID = require("scripts/zones/Bastok_Markets/IDs")
require("scripts/globals/quests")
require("scripts/globals/shop")
function onTrigger(player,npc)
local WildcatBastok = player:getCharVar("WildcatBastok")
if player:getQuestStatus(BASTOK,dsp.quest.id.bastok.LURE_OF_THE_WILDCAT) == QUEST_ACCEPTED and not player:getMaskBit(WildcatBastok,10) then
player:startEvent(430)
elseif player:getCharVar("comebackQueenCS") == 1 then
player:startEvent(490)
else
local stock =
{
17347, 990, 1, -- Piccolo
17344, 219, 2, -- Cornette
17353, 43, 2, -- Maple Harp
5041, 69120, 2, -- Scroll of Vital Etude
5042, 66240, 2, -- Scroll of Swift Etude
5043, 63360, 2, -- Scroll of Sage Etude
5044, 56700, 2, -- Scroll of Logical Etude
5039, 79560, 2, -- Scroll of Herculean Etude
5040, 76500, 2, -- Scroll of Uncanny Etude
17351, 4644, 3, -- Gemshorn
17345, 43, 3, -- Flute
5045, 54000, 3, -- Scroll of Bewitching Etude
}
player:showText(npc, ID.text.HARMODIOS_SHOP_DIALOG)
dsp.shop.nation(player, stock, dsp.nation.BASTOK)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 430 then
player:setMaskBit(player:getCharVar("WildcatBastok"),"WildcatBastok",10,true)
elseif csid == 490 then
player:startEvent(491)
elseif csid == 491 then
player:setCharVar("comebackQueenCS", 2)
end
end
| gpl-3.0 |
ld-test/lluv | examples/pipe_echo_srv.lua | 4 | 1042 | local uv = require "lluv"
local function on_write(cli, err)
if err then
cli:close()
if err:name() ~= "EOF" then
print("************************************")
print("ERROR: ", err)
print("************************************")
end
return
end
end
local function on_read(cli, err, data)
if err then
cli:close()
if err:name() ~= "EOF" then
print("************************************")
print("ERROR: ", err)
print("************************************")
end
return
end
cli:write(data, on_write)
end
local function on_connection(srv, err)
if err then
print("LISTEN:", err)
srv:close()
return
end
local cli, err = srv:accept()
if not cli then
print("ACCEPT: ", err)
return
end
cli:start_read(on_read)
end
uv.pipe()
:bind("\\\\.\\pipe\\sock.echo", function(srv, err, addr)
if err then
print("Can not bind:", tostring(err))
return srv:close()
end
print("Bind on: " .. addr)
srv:listen(on_connection)
end)
uv.run()
| mit |
RunAwayDSP/darkstar | scripts/globals/spells/bluemagic/jettatura.lua | 12 | 1450 | -----------------------------------------
-- Spell: Jettatura
-- Enemies within a fan-shaped area originating from the caster are frozen with fear
-- Spell cost: 37 MP
-- Monster Type: Birds
-- Spell Type: Magical (Dark)
-- Blue Magic Points: 4
-- Stat Bonus: MP+15
-- Level: 48
-- Casting Time: 0.5 seconds
-- Recast Time: 2:00
-- Magic Bursts on: Compression, Gravitation, Darkness
-- Combos: None
-----------------------------------------
require("scripts/globals/bluemagic")
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0
end
function onSpellCast(caster,target,spell)
local params = {}
params.attribute = dsp.mod.INT
params.skillType = dsp.skill.BLUE_MAGIC
params.effect = dsp.effect.TERROR
local resist = applyResistance(caster, target, spell, params)
local duration = 5 * resist
if (resist > 0.5) then -- Do it!
if (target:isFacing(caster)) then
if (target:addStatusEffect(params.effect,1,0,duration)) then
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB_IS)
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST)
end
return params.effect
end
| gpl-3.0 |
lichtl/darkstar | scripts/zones/AlTaieu/mobs/JoL_Qn_hpemde.lua | 15 | 1512 | -----------------------------------
-- Area: Al'Taieu
-- MOB: Qn'hpemde
-- Jailor of Love Pet version
-----------------------------------
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
mob:AnimationSub(6); -- Mouth Closed
end;
-----------------------------------
-- onMobFight
-----------------------------------
function onMobFight(mob, target)
local changeTime = mob:getLocalVar("changeTime");
if (mob:AnimationSub() == 6 and mob:getBattleTime() - changeTime > 30) then
mob:AnimationSub(3); -- Mouth Open
mob:addMod(MOD_ATTP, 100);
mob:addMod(MOD_DEFP, -50);
mob:addMod(MOD_DMGMAGIC, -50);
mob:setLocalVar("changeTime", mob:getBattleTime());
elseif (mob:AnimationSub() == 3 and mob:getBattleTime() - changeTime > 30) then
mob:AnimationSub(6); -- Mouth Closed
mob:addMod(MOD_ATTP, -100);
mob:addMod(MOD_DEFP, 50);
mob:addMod(MOD_DMGMAGIC, 50);
mob:setLocalVar("changeTime", mob:getBattleTime());
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
local JoL = GetMobByID(16912848);
local HPEMDES = JoL:getLocalVar("JoL_Qn_hpemde_Killed");
JoL:setLocalVar("JoL_Qn_hpemde_Killed", HPEMDES+1);
end; | gpl-3.0 |
lichtl/darkstar | scripts/globals/items/dish_of_spaghetti_vongole_rosso_+1.lua | 18 | 1650 | -----------------------------------------
-- ID: 5198
-- Item: Dish of Spaghetti Vongole Rosso +1
-- Food Effect: 60Min, All Races
-----------------------------------------
-- Health % 20
-- Health Cap 95
-- Vitality 2
-- Mind -1
-- Defense % 25
-- Defense Cap 35
-- Store TP 6
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,3600,5198);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_FOOD_HPP, 20);
target:addMod(MOD_FOOD_HP_CAP, 95);
target:addMod(MOD_VIT, 2);
target:addMod(MOD_MND, -1);
target:addMod(MOD_FOOD_DEFP, 25);
target:addMod(MOD_FOOD_DEF_CAP, 35);
target:addMod(MOD_STORETP, 6);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_FOOD_HPP, 20);
target:delMod(MOD_FOOD_HP_CAP, 95);
target:delMod(MOD_VIT, 2);
target:delMod(MOD_MND, -1);
target:delMod(MOD_FOOD_DEFP, 25);
target:delMod(MOD_FOOD_DEF_CAP, 35);
target:delMod(MOD_STORETP, 6);
end;
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/mobskills/cyclonic_torrent.lua | 11 | 1102 | ---------------------------------------------
-- Cyclonic Torrent
--
-- Description: Area of Effect damage plus Mute to those in range.
-- Type: Enfeebling
-- Utsusemi/Blink absorb: Wipes Shadows
-- Range: 20' radial
-- Notes: Only used by Urd, Verthandi, and Carabosse.
---------------------------------------------
require("scripts/globals/monstertpmoves")
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/msg")
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0
end
function onMobWeaponSkill(target, mob, skill)
local numhits = 1
local accmod = 1
local dmgmod = 2.5
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.PHYSICAL,dsp.damageType.BLUNT,MOBPARAM_WIPE_SHADOWS)
target:takeDamage(dmg, mob, dsp.attackType.PHYSICAL, dsp.damageType.BLUNT)
local typeEffect = dsp.effect.MUTE
MobStatusEffectMove(mob, target, typeEffect, 1, 0, 60)
return dmg
end
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/Dangruf_Wadi/npcs/qm3.lua | 9 | 2636 | -----------------------------------
-- NPC: ??? (QM3)
-- Type: Saltvix (dice roll game part 1)
-- !pos -367.367 2.999 229.020 191
-- Involved in quest "As Thick As Thieves"
-----------------------------------
local ID = require("scripts/zones/Dangruf_Wadi/IDs")
require("scripts/globals/npc_util")
require("scripts/globals/quests")
-----------------------------------
function onTrade(player,npc,trade)
local thickAsThievesGamblingCS = player:getCharVar("thickAsThievesGamblingCS")
if npcUtil.tradeHas(trade, 936) then -- Trade 1x rock slat
if thickAsThievesGamblingCS == 2 then
local rand1 = math.random(1,999)
local rand2 = math.random(1,999)
if (rand1 > rand2) then
player:messageSpecial(ID.text.YOU_PLACE_ITEM,0,936)
player:startEvent(136,1092,0,rand1,rand2) -- complete 1/3 gamble mini quest
else
player:messageSpecial(ID.text.YOU_PLACE_ITEM,0,936)
player:startEvent(139,0,0,rand1,rand2) -- player looses
end
elseif thickAsThievesGamblingCS == -1 then -- player previously lost to this goblin
local rand1 = math.random(1,999)
local rand2 = math.random(1,999)
if (rand1 > rand2) then
player:messageSpecial(ID.text.YOU_PLACE_ITEM,0,936)
player:startEvent(142,1092,0,rand1,rand2) -- complete 1/3 gamble mini quest
else
player:messageSpecial(ID.text.YOU_PLACE_ITEM,0,936)
player:startEvent(145,0,0,rand1,rand2) -- player looses
end
elseif thickAsThievesGamblingCS > 2 then
player:messageSpecial(ID.text.BEAT_SALTVIX)
end
end
end
function onTrigger(player,npc)
player:messageSpecial(ID.text.CRYSTALLINE_DUST)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if (csid == 139 or csid == 136 or csid == 142 or csid == 145) and option == 2 then -- player gives up
player:confirmTrade()
player:messageSpecial(ID.text.YOU_GAVE_UP)
player:setCharVar("thickAsThievesGamblingCS",-1)
elseif (csid == 139 or csid == 145) and option == 1 then -- player looses dice game
player:confirmTrade()
player:messageSpecial(ID.text.GOBLIN_BEAT_YOU)
player:setCharVar("thickAsThievesGamblingCS",-1)
elseif (csid == 136 or csid == 142) and option == 0 then -- player wins dice game
player:confirmTrade()
player:messageSpecial(ID.text.YOU_BEAT_GOBLIN)
player:setCharVar("thickAsThievesGamblingCS",3)
end
end | gpl-3.0 |
OctoEnigma/shiny-octo-system | lua/vgui/spawnicon.lua | 1 | 7337 |
local PANEL = {}
AccessorFunc( PANEL, "m_strModelName", "ModelName" )
AccessorFunc( PANEL, "m_iSkin", "SkinID" )
AccessorFunc( PANEL, "m_strBodyGroups", "BodyGroup" )
AccessorFunc( PANEL, "m_strIconName", "IconName" )
function PANEL:Init()
self:SetDoubleClickingEnabled( false )
self:SetText( "" )
self.Icon = vgui.Create( "ModelImage", self )
self.Icon:SetMouseInputEnabled( false )
self.Icon:SetKeyboardInputEnabled( false )
self:SetSize( 64, 64 )
self.m_strBodyGroups = "000000000"
end
function PANEL:DoRightClick()
local pCanvas = self:GetSelectionCanvas()
if ( IsValid( pCanvas ) && pCanvas:NumSelectedChildren() > 0 ) then
return hook.Run( "SpawnlistOpenGenericMenu", pCanvas )
end
self:OpenMenu()
end
function PANEL:DoClick()
end
function PANEL:OpenMenu()
end
function PANEL:Paint( w, h )
self.OverlayFade = math.Clamp( ( self.OverlayFade or 0 ) - RealFrameTime() * 640 * 2, 0, 255 )
if ( dragndrop.IsDragging() || !self:IsHovered() ) then return end
self.OverlayFade = math.Clamp( self.OverlayFade + RealFrameTime() * 640 * 8, 0, 255 )
end
local border = 4
local border_w = 5
local matHover = Material( "gui/sm_hover.png", "nocull" )
local boxHover = GWEN.CreateTextureBorder( border, border, 64 - border * 2, 64 - border * 2, border_w, border_w, border_w, border_w, matHover )
function PANEL:PaintOver( w, h )
if ( self.OverlayFade > 0 ) then
boxHover( 0, 0, w, h, Color( 255, 255, 255, self.OverlayFade ) )
end
self:DrawSelections()
end
function PANEL:PerformLayout()
if ( self:IsDown() && !self.Dragging ) then
self.Icon:StretchToParent( 6, 6, 6, 6 )
else
self.Icon:StretchToParent( 0, 0, 0, 0 )
end
end
function PANEL:SetSpawnIcon( name )
self.m_strIconName = name
self.Icon:SetSpawnIcon( name )
end
function PANEL:SetBodyGroup( k, v )
if ( k < 0 ) then return end
if ( k > 9 ) then return end
if ( v < 0 ) then return end
if ( v > 9 ) then return end
self.m_strBodyGroups = self.m_strBodyGroups:SetChar( k + 1, v )
end
function PANEL:SetModel( mdl, iSkin, BodyGorups )
if ( !mdl ) then debug.Trace() return end
self:SetModelName( mdl )
self:SetSkinID( iSkin )
if ( tostring( BodyGorups ):len() != 9 ) then
BodyGorups = "000000000"
end
self.m_strBodyGroups = BodyGorups
self.Icon:SetModel( mdl, iSkin, BodyGorups )
if ( iSkin && iSkin > 0 ) then
self:SetTooltip( Format( "%s (Skin %i)", mdl, iSkin + 1 ) )
else
self:SetTooltip( Format( "%s", mdl ) )
end
end
function PANEL:RebuildSpawnIcon()
self.Icon:RebuildSpawnIcon()
end
function PANEL:RebuildSpawnIconEx( t )
self.Icon:RebuildSpawnIconEx( t )
end
function PANEL:ToTable( bigtable )
local tab = {}
tab.type = "model"
tab.model = self:GetModelName()
if ( self:GetSkinID() != 0 ) then
tab.skin = self:GetSkinID()
end
if ( self:GetBodyGroup() != "000000000" ) then
tab.body = "B" .. self:GetBodyGroup()
end
if ( self:GetWide() != 64 ) then
tab.wide = self:GetWide()
end
if ( self:GetTall() != 64 ) then
tab.tall = self:GetTall()
end
table.insert( bigtable, tab )
end
function PANEL:Copy()
local copy = vgui.Create( "SpawnIcon", self:GetParent() )
copy:SetModel( self:GetModelName(), self:GetSkinID() )
copy:CopyBase( self )
copy.DoClick = self.DoClick
copy.OpenMenu = self.OpenMenu
return copy
end
-- Icon has been editied, they changed the skin
-- what should we do?
function PANEL:SkinChanged( i )
-- Change the skin, and change the model
-- this way we can edit the spawnmenu....
self:SetSkinID( i )
self:SetModel( self:GetModelName(), self:GetSkinID(), self:GetBodyGroup() )
end
function PANEL:BodyGroupChanged( k, v )
self:SetBodyGroup( k, v )
self:SetModel( self:GetModelName(), self:GetSkinID(), self:GetBodyGroup() )
end
vgui.Register( "SpawnIcon", PANEL, "DButton" )
--
-- Action on creating a model from the spawnlist
--
spawnmenu.AddContentType( "model", function( container, obj )
local icon = vgui.Create( "SpawnIcon", container )
if ( obj.body ) then
obj.body = string.Trim( tostring(obj.body), "B" )
end
if ( obj.wide ) then
icon:SetWide( obj.wide )
end
if ( obj.tall ) then
icon:SetTall( obj.tall )
end
icon:InvalidateLayout( true )
icon:SetModel( obj.model, obj.skin or 0, obj.body )
icon:SetTooltip( string.Replace( string.GetFileFromFilename(obj.model), ".mdl", "" ) )
icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav") RunConsoleCommand( "gm_spawn", icon:GetModelName(), icon:GetSkinID() or 0, icon:GetBodyGroup() or "" ) end
icon.OpenMenu = function( icon )
local menu = DermaMenu()
menu:AddOption( "Copy to Clipboard", function() SetClipboardText( string.gsub(obj.model, "\\", "/") ) end )
menu:AddOption( "Spawn using Toolgun", function() RunConsoleCommand( "gmod_tool", "creator" ) RunConsoleCommand( "creator_type", "4" ) RunConsoleCommand( "creator_name", obj.model ) end )
local submenu = menu:AddSubMenu( "Re-Render", function() icon:RebuildSpawnIcon() end )
submenu:AddOption( "This Icon", function() icon:RebuildSpawnIcon() end )
submenu:AddOption( "All Icons", function() container:RebuildAll() end )
menu:AddOption( "Edit Icon", function()
local editor = vgui.Create( "IconEditor" )
editor:SetIcon( icon )
editor:Refresh()
editor:MakePopup()
editor:Center()
end )
local ChangeIconSize = function( w, h )
icon:SetSize( w, h )
icon:InvalidateLayout( true )
container:OnModified()
container:Layout()
icon:SetModel( obj.model, obj.skin or 0, obj.body )
end
local submenu = menu:AddSubMenu( "Resize", function() end )
submenu:AddOption( "64 x 64 (default)", function() ChangeIconSize( 64, 64 ) end )
submenu:AddOption( "64 x 128", function() ChangeIconSize( 64, 128 ) end )
submenu:AddOption( "64 x 256", function() ChangeIconSize( 64, 256 ) end )
submenu:AddOption( "64 x 512", function() ChangeIconSize( 64, 512 ) end )
submenu:AddSpacer()
submenu:AddOption( "128 x 64", function() ChangeIconSize( 128, 64 ) end )
submenu:AddOption( "128 x 128", function() ChangeIconSize( 128, 128 ) end )
submenu:AddOption( "128 x 256", function() ChangeIconSize( 128, 256 ) end )
submenu:AddOption( "128 x 512", function() ChangeIconSize( 128, 512 ) end )
submenu:AddSpacer()
submenu:AddOption( "256 x 64", function() ChangeIconSize( 256, 64 ) end )
submenu:AddOption( "256 x 128", function() ChangeIconSize( 256, 128 ) end )
submenu:AddOption( "256 x 256", function() ChangeIconSize( 256, 256 ) end )
submenu:AddOption( "256 x 512", function() ChangeIconSize( 256, 512 ) end )
submenu:AddSpacer()
submenu:AddOption( "512 x 64", function() ChangeIconSize( 512, 64 ) end )
submenu:AddOption( "512 x 128", function() ChangeIconSize( 512, 128 ) end )
submenu:AddOption( "512 x 256", function() ChangeIconSize( 512, 256 ) end )
submenu:AddOption( "512 x 512", function() ChangeIconSize( 512, 512 ) end )
menu:AddSpacer()
menu:AddOption( "Delete", function() icon:Remove() hook.Run( "SpawnlistContentChanged" ) end )
menu:Open()
end
icon:InvalidateLayout( true )
if ( IsValid( container ) ) then
container:Add( icon )
end
/*
if ( iSkin != 0 ) then return end
local iSkinCount = NumModelSkins( strModel )
if ( iSkinCount <= 1 ) then return end
for i=1, iSkinCount-1, 1 do
self:AddModel( strModel, i )
end
*/
return icon
end )
| mit |
lichtl/darkstar | scripts/zones/Kazham/npcs/Vah_Keshura.lua | 17 | 1073 | -----------------------------------
-- Area: Kazham
-- NPC: Vah Keshura
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/zones/Kazham/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("BathedInScent") == 1) then
player:startEvent(0x00BB); -- scent from Blue Rafflesias
else
player:startEvent(0x007C);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/weaponskills/seraph_blade.lua | 10 | 1346 | -----------------------------------
-- Seraph Blade
-- Sword weapon skill
-- Skill Level: 125
-- Deals light elemental damage to enemy. Damage varies with TP.
-- Ignores shadows.
-- Aligned with the Soil Gorget.
-- Aligned with the Soil Belt.
-- Element: Light
-- Modifiers: STR:40% MND:40%
-- 100%TP 200%TP 300%TP
-- 1.125 2.625 4.125
-----------------------------------
require("scripts/globals/magic")
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/weaponskills")
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.ftp100 = 1 params.ftp200 = 2.5 params.ftp300 = 3
params.str_wsc = 0.3 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.0 params.mnd_wsc = 0.3 params.chr_wsc = 0.0
params.ele = dsp.magic.ele.LIGHT
params.skill = dsp.skill.SWORD
params.includemab = true
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 1.125 params.ftp200 = 2.625 params.ftp300 = 4.125
params.str_wsc = 0.4 params.mnd_wsc = 0.4
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, params, tp, action, primary)
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
amin1717/RivasBot | plugins/admin.lua | 230 | 6382 | local function set_bot_photo(msg, success, result)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/bot.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
set_profile_photo(file, ok_cb, false)
send_large_msg(receiver, 'Photo changed!', ok_cb, false)
redis:del("bot:photo")
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
local function parsed_url(link)
local parsed_link = URL.parse(link)
local parsed_path = URL.parse_path(parsed_link.path)
return parsed_path[2]
end
local function get_contact_list_callback (cb_extra, success, result)
local text = " "
for k,v in pairs(result) do
if v.print_name and v.id and v.phone then
text = text..string.gsub(v.print_name , "_" , " ").." ["..v.id.."] = "..v.phone.."\n"
end
end
local file = io.open("contact_list.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"contact_list.txt", ok_cb, false)--.txt format
local file = io.open("contact_list.json", "w")
file:write(json:encode_pretty(result))
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"contact_list.json", ok_cb, false)--json format
end
local function user_info_callback(cb_extra, success, result)
result.access_hash = nil
result.flags = nil
result.phone = nil
if result.username then
result.username = '@'..result.username
end
result.print_name = result.print_name:gsub("_","")
local text = serpent.block(result, {comment=false})
text = text:gsub("[{}]", "")
text = text:gsub('"', "")
text = text:gsub(",","")
if cb_extra.msg.to.type == "chat" then
send_large_msg("chat#id"..cb_extra.msg.to.id, text)
else
send_large_msg("user#id"..cb_extra.msg.to.id, text)
end
end
local function get_dialog_list_callback(cb_extra, success, result)
local text = ""
for k,v in pairs(result) do
if v.peer then
if v.peer.type == "chat" then
text = text.."group{"..v.peer.title.."}["..v.peer.id.."]("..v.peer.members_num..")"
else
if v.peer.print_name and v.peer.id then
text = text.."user{"..v.peer.print_name.."}["..v.peer.id.."]"
end
if v.peer.username then
text = text.."("..v.peer.username..")"
end
if v.peer.phone then
text = text.."'"..v.peer.phone.."'"
end
end
end
if v.message then
text = text..'\nlast msg >\nmsg id = '..v.message.id
if v.message.text then
text = text .. "\n text = "..v.message.text
end
if v.message.action then
text = text.."\n"..serpent.block(v.message.action, {comment=false})
end
if v.message.from then
if v.message.from.print_name then
text = text.."\n From > \n"..string.gsub(v.message.from.print_name, "_"," ").."["..v.message.from.id.."]"
end
if v.message.from.username then
text = text.."( "..v.message.from.username.." )"
end
if v.message.from.phone then
text = text.."' "..v.message.from.phone.." '"
end
end
end
text = text.."\n\n"
end
local file = io.open("dialog_list.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"dialog_list.txt", ok_cb, false)--.txt format
local file = io.open("dialog_list.json", "w")
file:write(json:encode_pretty(result))
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"dialog_list.json", ok_cb, false)--json format
end
local function run(msg,matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local group = msg.to.id
if not is_admin(msg) then
return
end
if msg.media then
if msg.media.type == 'photo' and redis:get("bot:photo") then
if redis:get("bot:photo") == 'waiting' then
load_photo(msg.id, set_bot_photo, msg)
end
end
end
if matches[1] == "setbotphoto" then
redis:set("bot:photo", "waiting")
return 'Please send me bot photo now'
end
if matches[1] == "markread" then
if matches[2] == "on" then
redis:set("bot:markread", "on")
return "Mark read > on"
end
if matches[2] == "off" then
redis:del("bot:markread")
return "Mark read > off"
end
return
end
if matches[1] == "pm" then
send_large_msg("user#id"..matches[2],matches[3])
return "Msg sent"
end
if matches[1] == "block" then
if is_admin2(matches[2]) then
return "You can't block admins"
end
block_user("user#id"..matches[2],ok_cb,false)
return "User blocked"
end
if matches[1] == "unblock" then
unblock_user("user#id"..matches[2],ok_cb,false)
return "User unblocked"
end
if matches[1] == "import" then--join by group link
local hash = parsed_url(matches[2])
import_chat_link(hash,ok_cb,false)
end
if matches[1] == "contactlist" then
get_contact_list(get_contact_list_callback, {target = msg.from.id})
return "I've sent contact list with both json and text format to your private"
end
if matches[1] == "delcontact" then
del_contact("user#id"..matches[2],ok_cb,false)
return "User "..matches[2].." removed from contact list"
end
if matches[1] == "dialoglist" then
get_dialog_list(get_dialog_list_callback, {target = msg.from.id})
return "I've sent dialog list with both json and text format to your private"
end
if matches[1] == "whois" then
user_info("user#id"..matches[2],user_info_callback,{msg=msg})
end
return
end
return {
patterns = {
"^[!/](pm) (%d+) (.*)$",
"^[!/](import) (.*)$",
"^[!/](unblock) (%d+)$",
"^[!/](block) (%d+)$",
"^[!/](markread) (on)$",
"^[!/](markread) (off)$",
"^[!/](setbotphoto)$",
"%[(photo)%]",
"^[!/](contactlist)$",
"^[!/](dialoglist)$",
"^[!/](delcontact) (%d+)$",
"^[!/](whois) (%d+)$"
},
run = run,
}
--By @imandaneshi :)
--https://github.com/SEEDTEAM/TeleSeed/blob/master/plugins/admin.lua
| gpl-2.0 |
lichtl/darkstar | scripts/zones/Aydeewa_Subterrane/mobs/Pandemonium_Warden.lua | 12 | 11865 | -----------------------------------
-- Area: Aydeewa Subterrane
-- ZNM: Pandemonium_Warden
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onMobInitialize Action
-----------------------------------
function onMobInitialize(mob)
end;
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
-- Make sure model is reset back to start
mob:setModelId(1839);
-- Two hours to forced depop
mob:setLocalVar("PWardenDespawnTime", os.time(t) + 7200);
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
-- pop pets
for i = 17056170, 17056177, 1 do
SpawnMob(i):updateEnmity(target);
GetMobByID(i):setModelId(1841);
end
end;
-----------------------------------
-- onMobFight
-----------------------------------
function onMobFight(mob,target)
local depopTime = mob:getLocalVar("PWardenDespawnTime");
local mobHPP = mob:getHPP();
local change = mob:getLocalVar("change");
local petIDs = {17056170,17056171,17056172,17056173,17056174,17056175,17056176,17056177};
local petStatus = {GetMobAction(petIDs[1]),GetMobAction(petIDs[2]),GetMobAction(petIDs[3]),GetMobAction(petIDs[4]),GetMobAction(petIDs[5]),GetMobAction(petIDs[6]),GetMobAction(petIDs[7]),GetMobAction(petIDs[8])};
local TP = mob:getLocalVar("TP");
------------------------ Notes ------------------------
-- I can't help but think this could be better executed with a single set of logic checks and a table of HP and skin values.
-- Just the same, at least his pets respawn every form, and he doesn't get stuck.
-- There are two sets of PW in the mobids. It's entirely possible SE did this fight by swapping between the two somehow.
-- Some sources claim he should linger in Dverger form and throw off a few TP moves between forms.
-- Should end up in "mini-dverger" form at the end.
-- Using custom mobskill scripts so we don't clutter up existing scritps with a bunch of onMobSkillChecks.
------------------------ FORM CHANGES ------------------------
if (mobHPP <= 15 and change == 13) then -- Final Form, pets take Dvger form as well
mob:setModelId(1839);
mob:setLocalVar("change", 14);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1840);
end
elseif (mobHPP <= 26 and change == 12) then -- Khim and Co.
mob:setModelId(1805);
mob:setLocalVar("change", 13);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1746);
end;
elseif (mobHPP <= 28 and change == 11) then -- Normal Form
mob:setModelId(1839);
mob:setLocalVar("change", 12);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1841);
end
if (TP <= 5) then
mob:useMobAbility(2114);
mob:setLocalVar("TP", 6)
end
elseif (mobHPP <= 38 and change == 10) then -- Hydra and Co.
mob:setModelId(1796);
mob:setLocalVar("change", 11);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(421);
end
elseif (mobHPP <= 40 and change == 9) then -- Normal Form
mob:setModelId(1839);
mob:setLocalVar("change", 10);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1841);
end
if (TP <= 4) then
mob:useMobAbility(2116);
mob:setLocalVar("TP", 5)
end
elseif (mobHPP <= 50 and change == 8) then -- Cerb and Co.
mob:setModelId(1793);
mob:setLocalVar("change", 9);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(281);
end;
elseif (mobHPP <= 52 and change == 7) then -- Normal Form
mob:setModelId(1839);
mob:setLocalVar("change", 8);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1841);
end
if (TP <= 3) then
mob:useMobAbility(2117);
mob:setLocalVar("TP", 4)
end
elseif (mobHPP <= 62 and change == 6) then -- Troll and Co.
mob:setModelId(1867);
mob:setLocalVar("change", 7);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1680);
end
elseif (mobHPP <= 64 and change == 5) then -- Normal Form
mob:setModelId(1839);
mob:setLocalVar("change", 6);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1841);
end
if (TP <= 2) then
mob:useMobAbility(2118);
mob:setLocalVar("TP", 3)
end
elseif (mobHPP <= 74 and change == 4) then -- Lamia and Co.
mob:setModelId(1865);
mob:setLocalVar("change", 5);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1643);
end
elseif (mobHPP <= 76 and change == 3) then -- Normal Form
mob:setModelId(1839);
mob:setLocalVar("change", 4);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1841);
end
if (TP <= 1) then
mob:useMobAbility(2119);
mob:setLocalVar("TP", 2)
end
elseif (mobHPP <= 86 and change == 2) then -- Mamool and Co.
mob:setModelId(1863);
mob:setLocalVar("change", 3);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1639);
end
elseif (mobHPP <= 88 and change == 1) then -- Normal Form
mob:setModelId(1839);
mob:setLocalVar("change", 2);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1841);
end
if (TP <= 0) then
mob:useMobAbility(2113);
mob:setLocalVar("TP", 1)
end
elseif (mobHPP <= 98 and change == 0) then -- Chariots
mob:setModelId(1825);
mob:setLocalVar("change", 1);
for i = 1, 8 do
if petStatus[i] == 0 then
SpawnMob(petIDs[i]):updateEnmity(target);
end
GetMobByID(petIDs[i]):setModelId(1820);
end
end
------------------------ Keep pets active ------------------------
-- Pets probably shouldn't despawn for this, but proof otherwise should remove this code.
for i = 1, 8 do
if (petStatus[i] == 16 or petStatus[i] == 18) then -- idle or disengaging pet
GetMobByID(petIDs[i]):updateEnmity(target);
end
end
-- Repops pets sets model and sets them agro..
-- This is TeoTwawki's loop for respawning pets, I left it here in case
-- someone ever wants it
-- if (mob:getLocalVar("repopPets") == 1) then
-- for i = 1, 8 do
-- if petStatus[i] == 0 then
-- SpawnMob(petIDs[i]):updateEnmity(target);
-- end
-- if (GetMobByID(petIDs[i]):getModelId() ~= mob:getLocalVar("petsModelId")) then
-- GetMobByID(petIDs[i]):setModelId(petsModelId);
-- end
-- end
-- mob:setLocalVar("repopPets", 0);
-- end
------------------------ Despawn timer ------------------------
if (os.time(t) > depopTime and mob:actionQueueEmpty() == true) then
for i=17056170, 17056186 do
DespawnMob(i);
end
printf("Timer expired at %i. Despawning Pandemonium Warden.", depopTime);
end
-- Very much early code. Couldn't find a way to depop the mob after AF pacts had executed. As such, doesn't work.
-- Obviously, you have to move the Avatars to their own family, and give them access to AFlows via a new set of moves.
-- Might be able to cheat by giving them a copy AFlow (change the name!) that despawns the mob once completed.
-- Rearranging the skins may be necessary to use this trick efficiently on more SMNs.
-- Either that, or probably somewhat complex core code. Avatars may not always be mobid+1.
-- It wasn't clear if the avatars were a separate pop, or if all dead lamps should revive, go avatar, and AFlow.
--[[
------------------------ Astral Flow Logic ------------------------
-- Missing the log message for players. Needs to be handled in the core somehow.
-- Possibly supposed to use twice per trigger? Did not check too far on this. Sounds fun.
if (mobHP <= (mobMaxHP * 0.75) and target:getMaskBit(PWardenAstralFlows,3) == false) then
for i=17056178, 17056186 do
local rannum = math.random(0,7);
local avatar = GetMobByID(i);
avatar:changeSkin(23 + rannum); -- Random avatar skin
SpawnMob(i):updateEnmity(target);
avatar:useMobAbility(912);
DespawnMob(i);
end
PWardenAstralFlows = PWardenAstralFlows + 4;
-- 23 = Shiva, 628 Diamond Dust
-- 24 = Ramuh, 637 Judgement Bolt
-- 25 = Titan, 601 Earthen Fury
-- 26 = Ifrit, 592 Inferno
-- 27 = Leviathan, 610 Tidal Wave
-- 28 = Garuda, 619 Aerial Blast
-- 29 = Fenrir, 583 Howling Moon
-- 30 = Carbuncle, 656 Searing Light
-- 31 = Diabolos
-- 646 = wyvern breath. Need to find diabolos.
elseif (mobHP <= (mobMaxHP * 0.5) and target:getMaskBit(PWardenAstralFlows,2) == false) then
for i=17056178, 17056186 do
local rannum = math.random(0,7);
local avatar = GetMobByID(i);
avatar:changeSkin(23 + rannum); -- Random avatar skin
SpawnMob(i):updateEnmity(target);
avatar:useMobAbility(912);
DespawnMob(i);
end
PWardenAstralFlows = PWardenAstralFlows + 2;
elseif (mobHP <= (mobMaxHP * 0.25) and target:getMaskBit(PWardenAstralFlows,1) == false) then
for i=17056178, 17056186 do
local rannum = math.random(0,7);
local avatar = GetMobByID(i);
avatar:changeSkin(23 + rannum); -- Random avatar skin
SpawnMob(i):updateEnmity(target);
avatar:useMobAbility(912);
DespawnMob(i);
end
PWardenAstralFlows = PWardenAstralFlows + 1;
end
]]--
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
-- TODO: Death speech.
player:addTitle(PANDEMONIUM_QUELLER);
end;
| gpl-3.0 |
master00041/anti-self | plugins/silent_gp.lua | 6 | 1276 | do
local function pre_process(msg)
local hash = 'mate:'..msg.to.id
if redis:get(hash) and msg.from.id and msg.to.type == 'channel' and not is_sudo(msg) then
delete_msg(msg.id, ok_cb, false)
return "silent all was locked"
end
return msg
end
local function run(msg, matches)
channel_id = msg.to.id
if matches[1] == 'silent' and is_sudo(msg) then
local hash = 'mate:'..msg.to.id
redis:set(hash, true)
return "Silent All Has Been Enabled"
elseif matches[1] == 'unsilent' and is_sudo(msg) then
local hash = 'mate:'..msg.to.id
redis:del(hash)
return "Silent All Has Been Disabled"
end
if matches[1] == 'status' then
local hash = 'mate:'..msg.to.id
if redis:get(hash) then
return "Silent All Is Enable"
else
return "Silent All Is Disable"
end
end
end
return {
patterns = {
'^[/!#](silent) all$',
'^[/!#](unsilent) all$',
'^[/!#]silent (status)$',
},
run = run,
pre_process = pre_process
}
end
--fix for channel by @telemanager_ch
--Tnx to Sbss Team
| gpl-2.0 |
DrYaling/eluna-trinitycore | src/server/scripts/Scripts-master/eluna_globals.lua | 1 | 75340 | --[[
EmuDevs <http:emudevs.com/forum.php>
Eluna Lua Engine <https://github.com/ElunaLuaEngine/Eluna>
Eluna Scripts <https://github.com/ElunaLuaEngine/Scripts>
Eluna Wiki <http://wiki.emudevs.com/doku.php?id=eluna>
Eluna Globals
Copyright (C) 2014 EmuDevs <http://www.emudevs.com/>
--]]
--------------------------------------------------------
--[[
COMMON
--]]
--------------------------------------------------------
-- TIME CONSTANTS
MINUTE = 60
HOUR = MINUTE*60
DAY = HOUR*24
WEEK = DAY*7
MONTH = DAY*30
YEAR = MONTH*12
IN_MILLISECONDS = 1000
-- LOCALE CONSTANTS
LOCALE_enUS = 0
LOCALE_koKR = 1
LOCALE_frFR = 2
LOCALE_deDE = 3
LOCALE_zhCN = 4
LOCALE_zhTW = 5
LOCALE_esES = 6
LOCALE_esMX = 7
LOCALE_ruRU = 8
MAX_LOCALES = 8 -- MAX LOCALES
TOTAL_LOCALES = 9 -- TOTAL LOCALES
-- ACCOUNT TYPES
SEC_PLAYER = 0
SEC_MODERATOR = 1
SEC_GAMEMASTER = 2
SEC_ADMINISTRATOR = 3
SEC_CONSOLE = 4 -- must be always last in list, accounts must have less security level always also
--------------------------------------------------------
--[[
OBJECT FIELDS
--]]
--------------------------------------------------------
-- OBJECT FIELD TYPES
OBJECT_FIELD_GUID = 0x0000 -- Size: 2, Type: LONG, Flags: PUBLIC
OBJECT_FIELD_TYPE = 0x0002 -- Size: 1, Type: INT, Flags: PUBLIC
OBJECT_FIELD_ENTRY = 0x0003 -- Size: 1, Type: INT, Flags: PUBLIC
OBJECT_FIELD_SCALE_X = 0x0004 -- Size: 1, Type: FLOAT, Flags: PUBLIC
OBJECT_FIELD_PADDING = 0x0005 -- Size: 1, Type: INT, Flags: NONE
local OBJECT_END = 0x0006
local ITEM_END = OBJECT_END + 0x003A
local UNIT_END = OBJECT_END + 0x008E
local PLAYER_END = UNIT_END + 0x049A
local GAMEOBJECT_END = OBJECT_END + 0x000C
local DYNAMICOBJECT_END = OBJECT_END + 0x0006
local CORPSE_END = OBJECT_END + 0x001E
-- ITEM FIELD TYPES
ITEM_FIELD_OWNER = OBJECT_END + 0x0000 -- Size: 2, Type: LONG, Flags: PUBLIC
ITEM_FIELD_CONTAINED = OBJECT_END + 0x0002 -- Size: 2, Type: LONG, Flags: PUBLIC
ITEM_FIELD_CREATOR = OBJECT_END + 0x0004 -- Size: 2, Type: LONG, Flags: PUBLIC
ITEM_FIELD_GIFTCREATOR = OBJECT_END + 0x0006 -- Size: 2, Type: LONG, Flags: PUBLIC
ITEM_FIELD_STACK_COUNT = OBJECT_END + 0x0008 -- Size: 1, Type: INT, Flags: OWNER, ITEM_OWNER
ITEM_FIELD_DURATION = OBJECT_END + 0x0009 -- Size: 1, Type: INT, Flags: OWNER, ITEM_OWNER
ITEM_FIELD_SPELL_CHARGES = OBJECT_END + 0x000A -- Size: 5, Type: INT, Flags: OWNER, ITEM_OWNER
ITEM_FIELD_FLAGS = OBJECT_END + 0x000F -- Size: 1, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_1_1 = OBJECT_END + 0x0010 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_1_3 = OBJECT_END + 0x0012 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_2_1 = OBJECT_END + 0x0013 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_2_3 = OBJECT_END + 0x0015 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_3_1 = OBJECT_END + 0x0016 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_3_3 = OBJECT_END + 0x0018 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_4_1 = OBJECT_END + 0x0019 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_4_3 = OBJECT_END + 0x001B -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_5_1 = OBJECT_END + 0x001C -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_5_3 = OBJECT_END + 0x001E -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_6_1 = OBJECT_END + 0x001F -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_6_3 = OBJECT_END + 0x0021 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_7_1 = OBJECT_END + 0x0022 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_7_3 = OBJECT_END + 0x0024 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_8_1 = OBJECT_END + 0x0025 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_8_3 = OBJECT_END + 0x0027 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_9_1 = OBJECT_END + 0x0028 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_9_3 = OBJECT_END + 0x002A -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_10_1 = OBJECT_END + 0x002B -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_10_3 = OBJECT_END + 0x002D -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_11_1 = OBJECT_END + 0x002E -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_11_3 = OBJECT_END + 0x0030 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_12_1 = OBJECT_END + 0x0031 -- Size: 2, Type: INT, Flags: PUBLIC
ITEM_FIELD_ENCHANTMENT_12_3 = OBJECT_END + 0x0033 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
ITEM_FIELD_PROPERTY_SEED = OBJECT_END + 0x0034 -- Size: 1, Type: INT, Flags: PUBLIC
ITEM_FIELD_RANDOM_PROPERTIES_ID = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
ITEM_FIELD_DURABILITY = OBJECT_END + 0x0036 -- Size: 1, Type: INT, Flags: OWNER, ITEM_OWNER
ITEM_FIELD_MAXDURABILITY = OBJECT_END + 0x0037 -- Size: 1, Type: INT, Flags: OWNER, ITEM_OWNER
ITEM_FIELD_CREATE_PLAYED_TIME = OBJECT_END + 0x0038 -- Size: 1, Type: INT, Flags: PUBLIC
ITEM_FIELD_PAD = OBJECT_END + 0x0039 -- Size: 1, Type: INT, Flags: NONE
-- CONTAINER FIELD TYPES
CONTAINER_FIELD_NUM_SLOTS = ITEM_END + 0x0000 -- Size: 1, Type: INT, Flags: PUBLIC
CONTAINER_ALIGN_PAD = ITEM_END + 0x0001 -- Size: 1, Type: BYTES, Flags: NONE
CONTAINER_FIELD_SLOT_1 = ITEM_END + 0x0002 -- Size: 72, Type: LONG, Flags: PUBLIC
CONTAINER_END = ITEM_END + 0x004A
-- UNIT FIELD TYPES
UNIT_FIELD_CHARM = OBJECT_END + 0x0000 -- Size: 2, Type: LONG, Flags: PUBLIC
UNIT_FIELD_SUMMON = OBJECT_END + 0x0002 -- Size: 2, Type: LONG, Flags: PUBLIC
UNIT_FIELD_CRITTER = OBJECT_END + 0x0004 -- Size: 2, Type: LONG, Flags: PRIVATE
UNIT_FIELD_CHARMEDBY = OBJECT_END + 0x0006 -- Size: 2, Type: LONG, Flags: PUBLIC
UNIT_FIELD_SUMMONEDBY = OBJECT_END + 0x0008 -- Size: 2, Type: LONG, Flags: PUBLIC
UNIT_FIELD_CREATEDBY = OBJECT_END + 0x000A -- Size: 2, Type: LONG, Flags: PUBLIC
UNIT_FIELD_TARGET = OBJECT_END + 0x000C -- Size: 2, Type: LONG, Flags: PUBLIC
UNIT_FIELD_CHANNEL_OBJECT = OBJECT_END + 0x000E -- Size: 2, Type: LONG, Flags: PUBLIC
UNIT_CHANNEL_SPELL = OBJECT_END + 0x0010 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_BYTES_0 = OBJECT_END + 0x0011 -- Size: 1, Type: BYTES, Flags: PUBLIC
UNIT_FIELD_HEALTH = OBJECT_END + 0x0012 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER1 = OBJECT_END + 0x0013 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER2 = OBJECT_END + 0x0014 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER3 = OBJECT_END + 0x0015 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER4 = OBJECT_END + 0x0016 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER5 = OBJECT_END + 0x0017 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER6 = OBJECT_END + 0x0018 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER7 = OBJECT_END + 0x0019 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXHEALTH = OBJECT_END + 0x001A -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXPOWER1 = OBJECT_END + 0x001B -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXPOWER2 = OBJECT_END + 0x001C -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXPOWER3 = OBJECT_END + 0x001D -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXPOWER4 = OBJECT_END + 0x001E -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXPOWER5 = OBJECT_END + 0x001F -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXPOWER6 = OBJECT_END + 0x0020 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MAXPOWER7 = OBJECT_END + 0x0021 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER = OBJECT_END + 0x0022 -- Size: 7, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER = OBJECT_END + 0x0029 -- Size: 7, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_LEVEL = OBJECT_END + 0x0030 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_FACTIONTEMPLATE = OBJECT_END + 0x0031 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_VIRTUAL_ITEM_SLOT_ID = OBJECT_END + 0x0032 -- Size: 3, Type: INT, Flags: PUBLIC
UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_FLAGS_2 = OBJECT_END + 0x0036 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_AURASTATE = OBJECT_END + 0x0037 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_BASEATTACKTIME = OBJECT_END + 0x0038 -- Size: 2, Type: INT, Flags: PUBLIC
UNIT_FIELD_RANGEDATTACKTIME = OBJECT_END + 0x003A -- Size: 1, Type: INT, Flags: PRIVATE
UNIT_FIELD_BOUNDINGRADIUS = OBJECT_END + 0x003B -- Size: 1, Type: FLOAT, Flags: PUBLIC
UNIT_FIELD_COMBATREACH = OBJECT_END + 0x003C -- Size: 1, Type: FLOAT, Flags: PUBLIC
UNIT_FIELD_DISPLAYID = OBJECT_END + 0x003D -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_NATIVEDISPLAYID = OBJECT_END + 0x003E -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MOUNTDISPLAYID = OBJECT_END + 0x003F -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_MINDAMAGE = OBJECT_END + 0x0040 -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER, PARTY_LEADER
UNIT_FIELD_MAXDAMAGE = OBJECT_END + 0x0041 -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER, PARTY_LEADER
UNIT_FIELD_MINOFFHANDDAMAGE = OBJECT_END + 0x0042 -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER, PARTY_LEADER
UNIT_FIELD_MAXOFFHANDDAMAGE = OBJECT_END + 0x0043 -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER, PARTY_LEADER
UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044 -- Size: 1, Type: BYTES, Flags: PUBLIC
UNIT_FIELD_PETNUMBER = OBJECT_END + 0x0045 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_PET_NAME_TIMESTAMP = OBJECT_END + 0x0046 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_PETEXPERIENCE = OBJECT_END + 0x0047 -- Size: 1, Type: INT, Flags: OWNER
UNIT_FIELD_PETNEXTLEVELEXP = OBJECT_END + 0x0048 -- Size: 1, Type: INT, Flags: OWNER
UNIT_DYNAMIC_FLAGS = OBJECT_END + 0x0049 -- Size: 1, Type: INT, Flags: DYNAMIC
UNIT_MOD_CAST_SPEED = OBJECT_END + 0x004A -- Size: 1, Type: FLOAT, Flags: PUBLIC
UNIT_CREATED_BY_SPELL = OBJECT_END + 0x004B -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_NPC_FLAGS = OBJECT_END + 0x004C -- Size: 1, Type: INT, Flags: DYNAMIC
UNIT_NPC_EMOTESTATE = OBJECT_END + 0x004D -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_STAT0 = OBJECT_END + 0x004E -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_STAT1 = OBJECT_END + 0x004F -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_STAT2 = OBJECT_END + 0x0050 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_STAT3 = OBJECT_END + 0x0051 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_STAT4 = OBJECT_END + 0x0052 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_POSSTAT0 = OBJECT_END + 0x0053 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_POSSTAT1 = OBJECT_END + 0x0054 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_POSSTAT2 = OBJECT_END + 0x0055 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_POSSTAT3 = OBJECT_END + 0x0056 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_POSSTAT4 = OBJECT_END + 0x0057 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_NEGSTAT0 = OBJECT_END + 0x0058 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_NEGSTAT1 = OBJECT_END + 0x0059 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_NEGSTAT2 = OBJECT_END + 0x005A -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_NEGSTAT3 = OBJECT_END + 0x005B -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_NEGSTAT4 = OBJECT_END + 0x005C -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_RESISTANCES = OBJECT_END + 0x005D -- Size: 7, Type: INT, Flags: PRIVATE, OWNER, PARTY_LEADER
UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE = OBJECT_END + 0x0064 -- Size: 7, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE = OBJECT_END + 0x006B -- Size: 7, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_BASE_MANA = OBJECT_END + 0x0072 -- Size: 1, Type: INT, Flags: PUBLIC
UNIT_FIELD_BASE_HEALTH = OBJECT_END + 0x0073 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
UNIT_FIELD_ATTACK_POWER = OBJECT_END + 0x0075 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_ATTACK_POWER_MODS = OBJECT_END + 0x0076 -- Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER
UNIT_FIELD_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x0077 -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_RANGED_ATTACK_POWER = OBJECT_END + 0x0078 -- Size: 1, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_RANGED_ATTACK_POWER_MODS = OBJECT_END + 0x0079 -- Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER
UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x007A -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_MINRANGEDDAMAGE = OBJECT_END + 0x007B -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_MAXRANGEDDAMAGE = OBJECT_END + 0x007C -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_POWER_COST_MODIFIER = OBJECT_END + 0x007D -- Size: 7, Type: INT, Flags: PRIVATE, OWNER
UNIT_FIELD_POWER_COST_MULTIPLIER = OBJECT_END + 0x0084 -- Size: 7, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_MAXHEALTHMODIFIER = OBJECT_END + 0x008B -- Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER
UNIT_FIELD_HOVERHEIGHT = OBJECT_END + 0x008C -- Size: 1, Type: FLOAT, Flags: PUBLIC
UNIT_FIELD_PADDING = OBJECT_END + 0x008D -- Size: 1, Type: INT, Flags: NONE
PLAYER_DUEL_ARBITER = UNIT_END + 0x0000 -- Size: 2, Type: LONG, Flags: PUBLIC
PLAYER_FLAGS = UNIT_END + 0x0002 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_GUILDID = UNIT_END + 0x0003 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_GUILDRANK = UNIT_END + 0x0004 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_BYTES = UNIT_END + 0x0005 -- Size: 1, Type: BYTES, Flags: PUBLIC
PLAYER_BYTES_2 = UNIT_END + 0x0006 -- Size: 1, Type: BYTES, Flags: PUBLIC
PLAYER_BYTES_3 = UNIT_END + 0x0007 -- Size: 1, Type: BYTES, Flags: PUBLIC
PLAYER_DUEL_TEAM = UNIT_END + 0x0008 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_GUILD_TIMESTAMP = UNIT_END + 0x0009 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_QUEST_LOG_1_1 = UNIT_END + 0x000A -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_1_2 = UNIT_END + 0x000B -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_1_3 = UNIT_END + 0x000C -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_1_4 = UNIT_END + 0x000E -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_2_1 = UNIT_END + 0x000F -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_2_2 = UNIT_END + 0x0010 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_2_3 = UNIT_END + 0x0011 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_2_5 = UNIT_END + 0x0013 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_3_1 = UNIT_END + 0x0014 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_3_2 = UNIT_END + 0x0015 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_3_3 = UNIT_END + 0x0016 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_3_5 = UNIT_END + 0x0018 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_4_1 = UNIT_END + 0x0019 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_4_2 = UNIT_END + 0x001A -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_4_3 = UNIT_END + 0x001B -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_4_5 = UNIT_END + 0x001D -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_5_1 = UNIT_END + 0x001E -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_5_2 = UNIT_END + 0x001F -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_5_3 = UNIT_END + 0x0020 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_5_5 = UNIT_END + 0x0022 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_6_1 = UNIT_END + 0x0023 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_6_2 = UNIT_END + 0x0024 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_6_3 = UNIT_END + 0x0025 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_6_5 = UNIT_END + 0x0027 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_7_1 = UNIT_END + 0x0028 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_7_2 = UNIT_END + 0x0029 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_7_3 = UNIT_END + 0x002A -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_7_5 = UNIT_END + 0x002C -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_8_1 = UNIT_END + 0x002D -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_8_2 = UNIT_END + 0x002E -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_8_3 = UNIT_END + 0x002F -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_8_5 = UNIT_END + 0x0031 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_9_1 = UNIT_END + 0x0032 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_9_2 = UNIT_END + 0x0033 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_9_3 = UNIT_END + 0x0034 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_9_5 = UNIT_END + 0x0036 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_10_1 = UNIT_END + 0x0037 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_10_2 = UNIT_END + 0x0038 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_10_3 = UNIT_END + 0x0039 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_10_5 = UNIT_END + 0x003B -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_11_1 = UNIT_END + 0x003C -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_11_2 = UNIT_END + 0x003D -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_11_3 = UNIT_END + 0x003E -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_11_5 = UNIT_END + 0x0040 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_12_1 = UNIT_END + 0x0041 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_12_2 = UNIT_END + 0x0042 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_12_3 = UNIT_END + 0x0043 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_12_5 = UNIT_END + 0x0045 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_13_1 = UNIT_END + 0x0046 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_13_2 = UNIT_END + 0x0047 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_13_3 = UNIT_END + 0x0048 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_13_5 = UNIT_END + 0x004A -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_14_1 = UNIT_END + 0x004B -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_14_2 = UNIT_END + 0x004C -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_14_3 = UNIT_END + 0x004D -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_14_5 = UNIT_END + 0x004F -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_15_1 = UNIT_END + 0x0050 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_15_2 = UNIT_END + 0x0051 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_15_3 = UNIT_END + 0x0052 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_15_5 = UNIT_END + 0x0054 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_16_1 = UNIT_END + 0x0055 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_16_2 = UNIT_END + 0x0056 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_16_3 = UNIT_END + 0x0057 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_16_5 = UNIT_END + 0x0059 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_17_1 = UNIT_END + 0x005A -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_17_2 = UNIT_END + 0x005B -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_17_3 = UNIT_END + 0x005C -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_17_5 = UNIT_END + 0x005E -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_18_1 = UNIT_END + 0x005F -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_18_2 = UNIT_END + 0x0060 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_18_3 = UNIT_END + 0x0061 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_18_5 = UNIT_END + 0x0063 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_19_1 = UNIT_END + 0x0064 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_19_2 = UNIT_END + 0x0065 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_19_3 = UNIT_END + 0x0066 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_19_5 = UNIT_END + 0x0068 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_20_1 = UNIT_END + 0x0069 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_20_2 = UNIT_END + 0x006A -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_20_3 = UNIT_END + 0x006B -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_20_5 = UNIT_END + 0x006D -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_21_1 = UNIT_END + 0x006E -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_21_2 = UNIT_END + 0x006F -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_21_3 = UNIT_END + 0x0070 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_21_5 = UNIT_END + 0x0072 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_22_1 = UNIT_END + 0x0073 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_22_2 = UNIT_END + 0x0074 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_22_3 = UNIT_END + 0x0075 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_22_5 = UNIT_END + 0x0077 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_23_1 = UNIT_END + 0x0078 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_23_2 = UNIT_END + 0x0079 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_23_3 = UNIT_END + 0x007A -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_23_5 = UNIT_END + 0x007C -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_24_1 = UNIT_END + 0x007D -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_24_2 = UNIT_END + 0x007E -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_24_3 = UNIT_END + 0x007F -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_24_5 = UNIT_END + 0x0081 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_25_1 = UNIT_END + 0x0082 -- Size: 1, Type: INT, Flags: PARTY_MEMBER
PLAYER_QUEST_LOG_25_2 = UNIT_END + 0x0083 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_QUEST_LOG_25_3 = UNIT_END + 0x0084 -- Size: 2, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_QUEST_LOG_25_5 = UNIT_END + 0x0086 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_VISIBLE_ITEM_1_ENTRYID = UNIT_END + 0x0087 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_1_ENCHANTMENT = UNIT_END + 0x0088 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_2_ENTRYID = UNIT_END + 0x0089 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_2_ENCHANTMENT = UNIT_END + 0x008A -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_3_ENTRYID = UNIT_END + 0x008B -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_3_ENCHANTMENT = UNIT_END + 0x008C -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_4_ENTRYID = UNIT_END + 0x008D -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_4_ENCHANTMENT = UNIT_END + 0x008E -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_5_ENTRYID = UNIT_END + 0x008F -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_5_ENCHANTMENT = UNIT_END + 0x0090 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_6_ENTRYID = UNIT_END + 0x0091 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_6_ENCHANTMENT = UNIT_END + 0x0092 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_7_ENTRYID = UNIT_END + 0x0093 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_7_ENCHANTMENT = UNIT_END + 0x0094 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_8_ENTRYID = UNIT_END + 0x0095 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_8_ENCHANTMENT = UNIT_END + 0x0096 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_9_ENTRYID = UNIT_END + 0x0097 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_9_ENCHANTMENT = UNIT_END + 0x0098 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_10_ENTRYID = UNIT_END + 0x0099 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_10_ENCHANTMENT = UNIT_END + 0x009A -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_11_ENTRYID = UNIT_END + 0x009B -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_11_ENCHANTMENT = UNIT_END + 0x009C -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_12_ENTRYID = UNIT_END + 0x009D -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_12_ENCHANTMENT = UNIT_END + 0x009E -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_13_ENTRYID = UNIT_END + 0x009F -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_13_ENCHANTMENT = UNIT_END + 0x00A0 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_14_ENTRYID = UNIT_END + 0x00A1 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_14_ENCHANTMENT = UNIT_END + 0x00A2 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_15_ENTRYID = UNIT_END + 0x00A3 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_15_ENCHANTMENT = UNIT_END + 0x00A4 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_16_ENTRYID = UNIT_END + 0x00A5 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_16_ENCHANTMENT = UNIT_END + 0x00A6 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_17_ENTRYID = UNIT_END + 0x00A7 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_17_ENCHANTMENT = UNIT_END + 0x00A8 -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_18_ENTRYID = UNIT_END + 0x00A9 -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_18_ENCHANTMENT = UNIT_END + 0x00AA -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_19_ENTRYID = UNIT_END + 0x00AB -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_VISIBLE_ITEM_19_ENCHANTMENT = UNIT_END + 0x00AC -- Size: 1, Type: TWO_SHORT, Flags: PUBLIC
PLAYER_CHOSEN_TITLE = UNIT_END + 0x00AD -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_FAKE_INEBRIATION = UNIT_END + 0x00AE -- Size: 1, Type: INT, Flags: PUBLIC
PLAYER_FIELD_PAD_0 = UNIT_END + 0x00AF -- Size: 1, Type: INT, Flags: NONE
PLAYER_FIELD_INV_SLOT_HEAD = UNIT_END + 0x00B0 -- Size: 46, Type: LONG, Flags: PRIVATE
PLAYER_FIELD_PACK_SLOT_1 = UNIT_END + 0x00DE -- Size: 32, Type: LONG, Flags: PRIVATE
PLAYER_FIELD_BANK_SLOT_1 = UNIT_END + 0x00FE -- Size: 56, Type: LONG, Flags: PRIVATE
PLAYER_FIELD_BANKBAG_SLOT_1 = UNIT_END + 0x0136 -- Size: 14, Type: LONG, Flags: PRIVATE
PLAYER_FIELD_VENDORBUYBACK_SLOT_1 = UNIT_END + 0x0144 -- Size: 24, Type: LONG, Flags: PRIVATE
PLAYER_FIELD_KEYRING_SLOT_1 = UNIT_END + 0x015C -- Size: 64, Type: LONG, Flags: PRIVATE
PLAYER_FIELD_CURRENCYTOKEN_SLOT_1 = UNIT_END + 0x019C -- Size: 64, Type: LONG, Flags: PRIVATE
PLAYER_FARSIGHT = UNIT_END + 0x01DC -- Size: 2, Type: LONG, Flags: PRIVATE
PLAYER__FIELD_KNOWN_TITLES = UNIT_END + 0x01DE -- Size: 2, Type: LONG, Flags: PRIVATE
PLAYER__FIELD_KNOWN_TITLES1 = UNIT_END + 0x01E0 -- Size: 2, Type: LONG, Flags: PRIVATE
PLAYER__FIELD_KNOWN_TITLES2 = UNIT_END + 0x01E2 -- Size: 2, Type: LONG, Flags: PRIVATE
PLAYER_FIELD_KNOWN_CURRENCIES = UNIT_END + 0x01E4 -- Size: 2, Type: LONG, Flags: PRIVATE
PLAYER_XP = UNIT_END + 0x01E6 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_NEXT_LEVEL_XP = UNIT_END + 0x01E7 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_SKILL_INFO_1_1 = UNIT_END + 0x01E8 -- Size: 384, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_CHARACTER_POINTS1 = UNIT_END + 0x0368 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_CHARACTER_POINTS2 = UNIT_END + 0x0369 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_TRACK_CREATURES = UNIT_END + 0x036A -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_TRACK_RESOURCES = UNIT_END + 0x036B -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_BLOCK_PERCENTAGE = UNIT_END + 0x036C -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_DODGE_PERCENTAGE = UNIT_END + 0x036D -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_PARRY_PERCENTAGE = UNIT_END + 0x036E -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_EXPERTISE = UNIT_END + 0x036F -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_OFFHAND_EXPERTISE = UNIT_END + 0x0370 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_CRIT_PERCENTAGE = UNIT_END + 0x0371 -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_RANGED_CRIT_PERCENTAGE = UNIT_END + 0x0372 -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_OFFHAND_CRIT_PERCENTAGE = UNIT_END + 0x0373 -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_SPELL_CRIT_PERCENTAGE1 = UNIT_END + 0x0374 -- Size: 7, Type: FLOAT, Flags: PRIVATE
PLAYER_SHIELD_BLOCK = UNIT_END + 0x037B -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_SHIELD_BLOCK_CRIT_PERCENTAGE = UNIT_END + 0x037C -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_EXPLORED_ZONES_1 = UNIT_END + 0x037D -- Size: 128, Type: BYTES, Flags: PRIVATE
PLAYER_REST_STATE_EXPERIENCE = UNIT_END + 0x03FD -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_COINAGE = UNIT_END + 0x03FE -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_MOD_DAMAGE_DONE_POS = UNIT_END + 0x03FF -- Size: 7, Type: INT, Flags: PRIVATE
PLAYER_FIELD_MOD_DAMAGE_DONE_NEG = UNIT_END + 0x0406 -- Size: 7, Type: INT, Flags: PRIVATE
PLAYER_FIELD_MOD_DAMAGE_DONE_PCT = UNIT_END + 0x040D -- Size: 7, Type: INT, Flags: PRIVATE
PLAYER_FIELD_MOD_HEALING_DONE_POS = UNIT_END + 0x0414 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_MOD_HEALING_PCT = UNIT_END + 0x0415 -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_FIELD_MOD_HEALING_DONE_PCT = UNIT_END + 0x0416 -- Size: 1, Type: FLOAT, Flags: PRIVATE
PLAYER_FIELD_MOD_TARGET_RESISTANCE = UNIT_END + 0x0417 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE = UNIT_END + 0x0418 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_BYTES = UNIT_END + 0x0419 -- Size: 1, Type: BYTES, Flags: PRIVATE
PLAYER_AMMO_ID = UNIT_END + 0x041A -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_SELF_RES_SPELL = UNIT_END + 0x041B -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_PVP_MEDALS = UNIT_END + 0x041C -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_BUYBACK_PRICE_1 = UNIT_END + 0x041D -- Size: 12, Type: INT, Flags: PRIVATE
PLAYER_FIELD_BUYBACK_TIMESTAMP_1 = UNIT_END + 0x0429 -- Size: 12, Type: INT, Flags: PRIVATE
PLAYER_FIELD_KILLS = UNIT_END + 0x0435 -- Size: 1, Type: TWO_SHORT, Flags: PRIVATE
PLAYER_FIELD_TODAY_CONTRIBUTION = UNIT_END + 0x0436 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_YESTERDAY_CONTRIBUTION = UNIT_END + 0x0437 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_LIFETIME_HONORABLE_KILLS = UNIT_END + 0x0438 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_BYTES2 = UNIT_END + 0x0439 -- Size: 1, Type: 6, Flags: PRIVATE
PLAYER_FIELD_WATCHED_FACTION_INDEX = UNIT_END + 0x043A -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_COMBAT_RATING_1 = UNIT_END + 0x043B -- Size: 25, Type: INT, Flags: PRIVATE
PLAYER_FIELD_ARENA_TEAM_INFO_1_1 = UNIT_END + 0x0454 -- Size: 21, Type: INT, Flags: PRIVATE
PLAYER_FIELD_HONOR_CURRENCY = UNIT_END + 0x0469 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_ARENA_CURRENCY = UNIT_END + 0x046A -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_MAX_LEVEL = UNIT_END + 0x046B -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_FIELD_DAILY_QUESTS_1 = UNIT_END + 0x046C -- Size: 25, Type: INT, Flags: PRIVATE
PLAYER_RUNE_REGEN_1 = UNIT_END + 0x0485 -- Size: 4, Type: FLOAT, Flags: PRIVATE
PLAYER_NO_REAGENT_COST_1 = UNIT_END + 0x0489 -- Size: 3, Type: INT, Flags: PRIVATE
PLAYER_FIELD_GLYPH_SLOTS_1 = UNIT_END + 0x048C -- Size: 6, Type: INT, Flags: PRIVATE
PLAYER_FIELD_GLYPHS_1 = UNIT_END + 0x0492 -- Size: 6, Type: INT, Flags: PRIVATE
PLAYER_GLYPHS_ENABLED = UNIT_END + 0x0498 -- Size: 1, Type: INT, Flags: PRIVATE
PLAYER_PET_SPELL_POWER = UNIT_END + 0x0499 -- Size: 1, Type: INT, Flags: PRIVATE
-- GAMEOBJECT FIELD TYPES
OBJECT_FIELD_CREATED_BY = OBJECT_END + 0x0000 -- Size: 2, Type: LONG, Flags: PUBLIC
GAMEOBJECT_DISPLAYID = OBJECT_END + 0x0002 -- Size: 1, Type: INT, Flags: PUBLIC
GAMEOBJECT_FLAGS = OBJECT_END + 0x0003 -- Size: 1, Type: INT, Flags: PUBLIC
GAMEOBJECT_PARENTROTATION = OBJECT_END + 0x0004 -- Size: 4, Type: FLOAT, Flags: PUBLIC
GAMEOBJECT_DYNAMIC = OBJECT_END + 0x0008 -- Size: 1, Type: TWO_SHORT, Flags: DYNAMIC
GAMEOBJECT_FACTION = OBJECT_END + 0x0009 -- Size: 1, Type: INT, Flags: PUBLIC
GAMEOBJECT_LEVEL = OBJECT_END + 0x000A -- Size: 1, Type: INT, Flags: PUBLIC
GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B -- Size: 1, Type: BYTES, Flags: PUBLIC
-- DYNAMIC FIELD TYPES
DYNAMICOBJECT_CASTER = OBJECT_END + 0x0000 -- Size: 2, Type: LONG, Flags: PUBLIC
DYNAMICOBJECT_BYTES = OBJECT_END + 0x0002 -- Size: 1, Type: BYTES, Flags: PUBLIC
DYNAMICOBJECT_SPELLID = OBJECT_END + 0x0003 -- Size: 1, Type: INT, Flags: PUBLIC
DYNAMICOBJECT_RADIUS = OBJECT_END + 0x0004 -- Size: 1, Type: FLOAT, Flags: PUBLIC
DYNAMICOBJECT_CASTTIME = OBJECT_END + 0x0005 -- Size: 1, Type: INT, Flags: PUBLIC
-- CORPSE FIELD TYPES
CORPSE_FIELD_OWNER = OBJECT_END + 0x0000 -- Size: 2, Type: LONG, Flags: PUBLIC
CORPSE_FIELD_PARTY = OBJECT_END + 0x0002 -- Size: 2, Type: LONG, Flags: PUBLIC
CORPSE_FIELD_DISPLAY_ID = OBJECT_END + 0x0004 -- Size: 1, Type: INT, Flags: PUBLIC
CORPSE_FIELD_ITEM = OBJECT_END + 0x0005 -- Size: 19, Type: INT, Flags: PUBLIC
CORPSE_FIELD_BYTES_1 = OBJECT_END + 0x0018 -- Size: 1, Type: BYTES, Flags: PUBLIC
CORPSE_FIELD_BYTES_2 = OBJECT_END + 0x0019 -- Size: 1, Type: BYTES, Flags: PUBLIC
CORPSE_FIELD_GUILD = OBJECT_END + 0x001A -- Size: 1, Type: INT, Flags: PUBLIC
CORPSE_FIELD_FLAGS = OBJECT_END + 0x001B -- Size: 1, Type: INT, Flags: PUBLIC
CORPSE_FIELD_DYNAMIC_FLAGS = OBJECT_END + 0x001C -- Size: 1, Type: INT, Flags: DYNAMIC
CORPSE_FIELD_PAD = OBJECT_END + 0x001D -- Size: 1, Type: INT, Flags: NONE
--------------------------------------------------------
--[[
ITEM PROTOTYPES
--]]
--------------------------------------------------------
MAX_ITEM_PROTO_DAMAGES = 2
MAX_ITEM_PROTO_SOCKETS = 3
MAX_ITEM_PROTO_SPELLS = 5
MAX_ITEM_PROTO_STATS = 10
-- ITEM MOD TYPES
ITEM_MOD_MANA = 0
ITEM_MOD_HEALTH = 1
ITEM_MOD_AGILITY = 3
ITEM_MOD_STRENGTH = 4
ITEM_MOD_INTELLECT = 5
ITEM_MOD_SPIRIT = 6
ITEM_MOD_STAMINA = 7
ITEM_MOD_DEFENSE_SKILL_RATING = 12
ITEM_MOD_DODGE_RATING = 13
ITEM_MOD_PARRY_RATING = 14
ITEM_MOD_BLOCK_RATING = 15
ITEM_MOD_HIT_MELEE_RATING = 16
ITEM_MOD_HIT_RANGED_RATING = 17
ITEM_MOD_HIT_SPELL_RATING = 18
ITEM_MOD_CRIT_MELEE_RATING = 19
ITEM_MOD_CRIT_RANGED_RATING = 20
ITEM_MOD_CRIT_SPELL_RATING = 21
ITEM_MOD_HIT_TAKEN_MELEE_RATING = 22
ITEM_MOD_HIT_TAKEN_RANGED_RATING = 23
ITEM_MOD_HIT_TAKEN_SPELL_RATING = 24
ITEM_MOD_CRIT_TAKEN_MELEE_RATING = 25
ITEM_MOD_CRIT_TAKEN_RANGED_RATING = 26
ITEM_MOD_CRIT_TAKEN_SPELL_RATING = 27
ITEM_MOD_HASTE_MELEE_RATING = 28
ITEM_MOD_HASTE_RANGED_RATING = 29
ITEM_MOD_HASTE_SPELL_RATING = 30
ITEM_MOD_HIT_RATING = 31
ITEM_MOD_CRIT_RATING = 32
ITEM_MOD_HIT_TAKEN_RATING = 33
ITEM_MOD_CRIT_TAKEN_RATING = 34
ITEM_MOD_RESILIENCE_RATING = 35
ITEM_MOD_HASTE_RATING = 36
ITEM_MOD_EXPERTISE_RATING = 37
ITEM_MOD_ATTACK_POWER = 38
ITEM_MOD_RANGED_ATTACK_POWER = 39
ITEM_MOD_SPELL_HEALING_DONE = 41
ITEM_MOD_SPELL_DAMAGE_DONE = 42
ITEM_MOD_MANA_REGENERATION = 43
ITEM_MOD_ARMOR_PENETRATION_RATING = 44
ITEM_MOD_SPELL_POWER = 45
ITEM_MOD_HEALTH_REGEN = 46
ITEM_MOD_SPELL_PENETRATION = 47
ITEM_MOD_BLOCK_VALUE = 48
MAX_ITEM_MOD = 49 -- MAX ITEM MOD
-- ITEM SPELL TRIGGER TYPES
ITEM_SPELLTRIGGER_ON_USE = 0
ITEM_SPELLTRIGGER_ON_EQUIP = 1
ITEM_SPELLTRIGGER_CHANCE_ON_HIT = 2
ITEM_SPELLTRIGGER_SOULSTONE = 4
ITEM_SPELLTRIGGER_ON_NO_DELAY_USE = 5
ITEM_SPELLTRIGGER_LEARN_SPELL_ID = 6
-- ITEM BONDING TYPES
NO_BIND = 0
BIND_WHEN_PICKED_UP = 1
BIND_WHEN_EQUIPED = 2
BIND_WHEN_USE = 3
BIND_QUEST_ITEM = 4
BIND_QUEST_ITEM1 = 5
-- ITEM PROTO FLAGS
ITEM_PROTO_FLAG_UNK1 = 0x00000001
ITEM_PROTO_FLAG_CONJURED = 0x00000002 -- Conjured item
ITEM_PROTO_FLAG_OPENABLE = 0x00000004 -- Item can be right clicked to open for loot
ITEM_PROTO_FLAG_HEROIC = 0x00000008 -- Makes green "Heroic" text appear on item
ITEM_PROTO_FLAG_DEPRECATED = 0x00000010 -- Cannot equip or use
ITEM_PROTO_FLAG_INDESTRUCTIBLE = 0x00000020 -- Item can not be destroyed except by using spell (item can be reagent for spell)
ITEM_PROTO_FLAG_UNK2 = 0x00000040
ITEM_PROTO_FLAG_NO_EQUIP_COOLDOWN = 0x00000080 -- No default 30 seconds cooldown when equipped
ITEM_PROTO_FLAG_UNK3 = 0x00000100
ITEM_PROTO_FLAG_WRAPPER = 0x00000200 -- Item can wrap other items
ITEM_PROTO_FLAG_UNK4 = 0x00000400
ITEM_PROTO_FLAG_PARTY_LOOT = 0x00000800 -- Looting this item does not remove it from available loot
ITEM_PROTO_FLAG_REFUNDABLE = 0x00001000 -- Item can be returned to vendor for its original cost (extended cost)
ITEM_PROTO_FLAG_CHARTER = 0x00002000 -- Item is guild or arena charter
ITEM_PROTO_FLAG_UNK5 = 0x00004000 -- Only readable items have this (but not all)
ITEM_PROTO_FLAG_UNK6 = 0x00008000
ITEM_PROTO_FLAG_UNK7 = 0x00010000
ITEM_PROTO_FLAG_UNK8 = 0x00020000
ITEM_PROTO_FLAG_PROSPECTABLE = 0x00040000 -- Item can be prospected
ITEM_PROTO_FLAG_UNIQUE_EQUIPPED = 0x00080000 -- You can only equip one of these
ITEM_PROTO_FLAG_UNK9 = 0x00100000
ITEM_PROTO_FLAG_USEABLE_IN_ARENA = 0x00200000 -- Item can be used during arena match
ITEM_PROTO_FLAG_THROWABLE = 0x00400000 -- Some Thrown weapons have it (and only Thrown) but not all
ITEM_PROTO_FLAG_USABLE_WHEN_SHAPESHIFTED = 0x00800000 -- Item can be used in shapeshift forms
ITEM_PROTO_FLAG_UNK10 = 0x01000000
ITEM_PROTO_FLAG_SMART_LOOT = 0x02000000 -- Profession recipes: can only be looted if you meet requirements and don't already know it
ITEM_PROTO_FLAG_NOT_USEABLE_IN_ARENA = 0x04000000 -- Item cannot be used in arena
ITEM_PROTO_FLAG_BIND_TO_ACCOUNT = 0x08000000 -- Item binds to account and can be sent only to your own characters
ITEM_PROTO_FLAG_TRIGGERED_CAST = 0x10000000 -- Spell is cast with triggered flag
ITEM_PROTO_FLAG_MILLABLE = 0x20000000 -- Item can be milled
ITEM_PROTO_FLAG_UNK11 = 0x40000000
ITEM_PROTO_FLAG_UNK12 = 0x80000000
-- ITEM FIELD FLAGS
ITEM_FLAG_SOULBOUND = 0x00000001 -- Item is soulbound and cannot be traded
ITEM_FLAG_UNK1 = 0x00000002
ITEM_FLAG_UNLOCKED = 0x00000004 -- Item had lock but can be opened now
ITEM_FLAG_WRAPPED = 0x00000008 -- Item is wrapped and contains another item
ITEM_FLAG_UNK2 = 0x00000010
ITEM_FLAG_UNK3 = 0x00000020
ITEM_FLAG_UNK4 = 0x00000040
ITEM_FLAG_UNK5 = 0x00000080
ITEM_FLAG_BOP_TRADEABLE = 0x00000100 -- Allows trading soulbound items
ITEM_FLAG_READABLE = 0x00000200 -- Opens text page when right clicked
ITEM_FLAG_UNK6 = 0x00000400
ITEM_FLAG_UNK7 = 0x00000800
ITEM_FLAG_REFUNDABLE = 0x00001000 -- Item can be returned to vendor for its original cost (extended cost)
ITEM_FLAG_UNK8 = 0x00002000
ITEM_FLAG_UNK9 = 0x00004000
ITEM_FLAG_UNK10 = 0x00008000
ITEM_FLAG_UNK11 = 0x00010000
ITEM_FLAG_UNK12 = 0x00020000
ITEM_FLAG_UNK13 = 0x00040000
ITEM_FLAG_UNK14 = 0x00080000
ITEM_FLAG_UNK15 = 0x00100000
ITEM_FLAG_UNK16 = 0x00200000
ITEM_FLAG_UNK17 = 0x00400000
ITEM_FLAG_UNK18 = 0x00800000
ITEM_FLAG_UNK19 = 0x01000000
ITEM_FLAG_UNK20 = 0x02000000
ITEM_FLAG_UNK21 = 0x04000000
ITEM_FLAG_UNK22 = 0x08000000
ITEM_FLAG_UNK23 = 0x10000000
ITEM_FLAG_UNK24 = 0x20000000
ITEM_FLAG_UNK25 = 0x40000000
ITEM_FLAG_UNK26 = 0x80000000
ITEM_FLAG_MAIL_TEXT_MASK = 786944
-- ITEM FLAGS EXTRA
ITEM_FLAGS_EXTRA_HORDE_ONLY = 0x00000001
ITEM_FLAGS_EXTRA_ALLIANCE_ONLY = 0x00000002
ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD = 0x00000004 -- when item uses extended cost, gold is also required
ITEM_FLAGS_EXTRA_NEED_ROLL_DISABLED = 0x00000100
-- ITEM FLAGS CUSTOM
ITEM_FLAGS_CU_DURATION_REAL_TIME = 0x0001 -- Item duration will tick even if player is offline
ITEM_FLAGS_CU_IGNORE_QUEST_STATUS = 0x0002 -- No quest status will be checked when this item drops
ITEM_FLAGS_CU_FOLLOW_LOOT_RULES = 0x0004 -- Item will always follow group/master/need before greed looting rules
-- ITEM CLASS
ITEM_CLASS_CONSUMABLE = 0
ITEM_CLASS_CONTAINER = 1
ITEM_CLASS_WEAPON = 2
ITEM_CLASS_GEM = 3
ITEM_CLASS_ARMOR = 4
ITEM_CLASS_REAGENT = 5
ITEM_CLASS_PROJECTILE = 6
ITEM_CLASS_TRADE_GOODS = 7
ITEM_CLASS_GENERIC = 8
ITEM_CLASS_RECIPE = 9
ITEM_CLASS_MONEY = 10
ITEM_CLASS_QUIVER = 11
ITEM_CLASS_QUEST = 12
ITEM_CLASS_KEY = 13
ITEM_CLASS_PERMANENT = 14
ITEM_CLASS_MISC = 15
ITEM_CLASS_GLYPH = 16
MAX_ITEM_CLASS = 17 -- MAX ITEM CLASS
-- ITEM SUBCLASS CONSUMABLE
ITEM_SUBCLASS_CONSUMABLE = 0
ITEM_SUBCLASS_POTION = 1
ITEM_SUBCLASS_ELIXIR = 2
ITEM_SUBCLASS_FLASK = 3
ITEM_SUBCLASS_SCROLL = 4
ITEM_SUBCLASS_FOOD = 5
ITEM_SUBCLASS_ITEM_ENHANCEMENT = 6
ITEM_SUBCLASS_BANDAGE = 7
ITEM_SUBCLASS_CONSUMABLE_OTHER = 8
MAX_ITEM_SUBCLASS_CONSUMABLE = 9 -- MAX ITEM SUBCLASS CONSUMABLE
-- ITEM SUBCLASS CONTAINER
ITEM_SUBCLASS_CONTAINER = 0
ITEM_SUBCLASS_SOUL_CONTAINER = 1
ITEM_SUBCLASS_HERB_CONTAINER = 2
ITEM_SUBCLASS_ENCHANTING_CONTAINER = 3
ITEM_SUBCLASS_ENGINEERING_CONTAINER = 4
ITEM_SUBCLASS_GEM_CONTAINER = 5
ITEM_SUBCLASS_MINING_CONTAINER = 6
ITEM_SUBCLASS_LEATHERWORKING_CONTAINER = 7
ITEM_SUBCLASS_INSCRIPTION_CONTAINER = 8
MAX_ITEM_SUBCLASS_CONTAINER = 9 -- MAX ITEM SUBCLASS CONTAINER
-- ITEM SUBCLASS WEAPON
ITEM_SUBCLASS_WEAPON_AXE = 0
ITEM_SUBCLASS_WEAPON_AXE2 = 1
ITEM_SUBCLASS_WEAPON_BOW = 2
ITEM_SUBCLASS_WEAPON_GUN = 3
ITEM_SUBCLASS_WEAPON_MACE = 4
ITEM_SUBCLASS_WEAPON_MACE2 = 5
ITEM_SUBCLASS_WEAPON_POLEARM = 6
ITEM_SUBCLASS_WEAPON_SWORD = 7
ITEM_SUBCLASS_WEAPON_SWORD2 = 8
ITEM_SUBCLASS_WEAPON_obsolete = 9
ITEM_SUBCLASS_WEAPON_STAFF = 10
ITEM_SUBCLASS_WEAPON_EXOTIC = 11
ITEM_SUBCLASS_WEAPON_EXOTIC2 = 12
ITEM_SUBCLASS_WEAPON_FIST = 13
ITEM_SUBCLASS_WEAPON_MISC = 14
ITEM_SUBCLASS_WEAPON_DAGGER = 15
ITEM_SUBCLASS_WEAPON_THROWN = 16
ITEM_SUBCLASS_WEAPON_SPEAR = 17
ITEM_SUBCLASS_WEAPON_CROSSBOW = 18
ITEM_SUBCLASS_WEAPON_WAND = 19
ITEM_SUBCLASS_WEAPON_FISHING_POLE = 20
MAX_ITEM_SUBCLASS_WEAPON = 21 -- MAX ITEM SUBCLASS WEAPON
-- ITEM SUBCLASS GEM
ITEM_SUBCLASS_GEM_RED = 0
ITEM_SUBCLASS_GEM_BLUE = 1
ITEM_SUBCLASS_GEM_YELLOW = 2
ITEM_SUBCLASS_GEM_PURPLE = 3
ITEM_SUBCLASS_GEM_GREEN = 4
ITEM_SUBCLASS_GEM_ORANGE = 5
ITEM_SUBCLASS_GEM_META = 6
ITEM_SUBCLASS_GEM_SIMPLE = 7
ITEM_SUBCLASS_GEM_PRISMATIC = 8
MAX_ITEM_SUBCLASS_GEM = 9 -- MAX ITEM SUBCLASS GEM
-- ITEM SUBCLASS ARMOR
ITEM_SUBCLASS_ARMOR_MISC = 0
ITEM_SUBCLASS_ARMOR_CLOTH = 1
ITEM_SUBCLASS_ARMOR_LEATHER = 2
ITEM_SUBCLASS_ARMOR_MAIL = 3
ITEM_SUBCLASS_ARMOR_PLATE = 4
ITEM_SUBCLASS_ARMOR_BUCKLER = 5
ITEM_SUBCLASS_ARMOR_SHIELD = 6
ITEM_SUBCLASS_ARMOR_LIBRAM = 7
ITEM_SUBCLASS_ARMOR_IDOL = 8
ITEM_SUBCLASS_ARMOR_TOTEM = 9
ITEM_SUBCLASS_ARMOR_SIGIL = 10
MAX_ITEM_SUBCLASS_ARMOR = 11 -- MAX ITEM SUBCLASS ARMOR
-- ITEM SUBCLASS REAGENT
ITEM_SUBCLASS_REAGENT = 0
MAX_ITEM_SUBCLASS_REAGENT = 1 -- MAX ITEM SUBCLASS REAGENT
-- ITEM SUBCLASS PROJECTILE
ITEM_SUBCLASS_WAND = 0
ITEM_SUBCLASS_BOLT = 1
ITEM_SUBCLASS_ARROW = 2
ITEM_SUBCLASS_BULLET = 3
ITEM_SUBCLASS_THROWN = 4
MAX_ITEM_SUBCLASS_PROJECTILE = 5 -- MAX ITEM SUBCLASS PROJECTILE
-- ITEM SUBCLASS TRADE GOODS
ITEM_SUBCLASS_TRADE_GOODS = 0
ITEM_SUBCLASS_PARTS = 1
ITEM_SUBCLASS_EXPLOSIVES = 2
ITEM_SUBCLASS_DEVICES = 3
ITEM_SUBCLASS_JEWELCRAFTING = 4
ITEM_SUBCLASS_CLOTH = 5
ITEM_SUBCLASS_LEATHER = 6
ITEM_SUBCLASS_METAL_STONE = 7
ITEM_SUBCLASS_MEAT = 8
ITEM_SUBCLASS_HERB = 9
ITEM_SUBCLASS_ELEMENTAL = 10
ITEM_SUBCLASS_TRADE_GOODS_OTHER = 11
ITEM_SUBCLASS_ENCHANTING = 12
ITEM_SUBCLASS_MATERIAL = 13
ITEM_SUBCLASS_ARMOR_ENCHANTMENT = 14
ITEM_SUBCLASS_WEAPON_ENCHANTMENT = 15
MAX_ITEM_SUBCLASS_TRADE_GOODS = 16 -- MAX ITEM SUBCLASS TRADE GOODS
-- ITEM SUBCLASS GENERIC
ITEM_SUBCLASS_GENERIC = 0
MAX_ITEM_SUBCLASS_GENERIC = 1 -- MAX ITEM SUBCLASS GENERIC
-- ITEM SUBCLASS RECIPE
ITEM_SUBCLASS_BOOK = 0
ITEM_SUBCLASS_LEATHERWORKING_PATTERN = 1
ITEM_SUBCLASS_TAILORING_PATTERN = 2
ITEM_SUBCLASS_ENGINEERING_SCHEMATIC = 3
ITEM_SUBCLASS_BLACKSMITHING = 4
ITEM_SUBCLASS_COOKING_RECIPE = 5
ITEM_SUBCLASS_ALCHEMY_RECIPE = 6
ITEM_SUBCLASS_FIRST_AID_MANUAL = 7
ITEM_SUBCLASS_ENCHANTING_FORMULA = 8
ITEM_SUBCLASS_FISHING_MANUAL = 9
ITEM_SUBCLASS_JEWELCRAFTING_RECIPE = 10
MAX_ITEM_SUBCLASS_RECIPE = 11 -- MAX ITEM SUBCLASS RECIPE
-- ITEM SUBCLASS MONEY
ITEM_SUBCLASS_MONEY = 0
MAX_ITEM_SUBCLASS_MONEY = 1 -- MAX ITEM SUBCLASS MONEY
-- ITEM SUBCLASS QUIVER
ITEM_SUBCLASS_QUIVER0 = 0
ITEM_SUBCLASS_QUIVER1 = 1
ITEM_SUBCLASS_QUIVER = 2
ITEM_SUBCLASS_AMMO_POUCH = 3
MAX_ITEM_SUBCLASS_QUIVER = 4 -- MAX ITEM SUBCLASS QUIVER
-- ITEM SUBCLASS QUEST
ITEM_SUBCLASS_QUEST = 0
MAX_ITEM_SUBCLASS_QUEST = 1 -- MAX ITEM SUBCLASS QUEST
-- ITEM SUBCLASS KEY
ITEM_SUBCLASS_KEY = 0
ITEM_SUBCLASS_LOCKPICK = 1
MAX_ITEM_SUBCLASS_KEY = 2 -- MAX ITEM SUBCLASS KEY
-- ITEM SUBCLASS PERMANENT
ITEM_SUBCLASS_PERMANENT = 0
MAX_ITEM_SUBCLASS_PERMANENT = 1 -- MAX ITEM SUBCLASS PERMANENT
-- ITEM SUBCLASS JUNK
ITEM_SUBCLASS_JUNK = 0
ITEM_SUBCLASS_JUNK_REAGENT = 1
ITEM_SUBCLASS_JUNK_PET = 2
ITEM_SUBCLASS_JUNK_HOLIDAY = 3
ITEM_SUBCLASS_JUNK_OTHER = 4
ITEM_SUBCLASS_JUNK_MOUNT = 5
MAX_ITEM_SUBCLASS_JUNK = 6 -- MAX ITEM SUBCLASS JUNK
-- ITEM SUBCLASS GLYPH
ITEM_SUBCLASS_GLYPH_WARRIOR = 1
ITEM_SUBCLASS_GLYPH_PALADIN = 2
ITEM_SUBCLASS_GLYPH_HUNTER = 3
ITEM_SUBCLASS_GLYPH_ROGUE = 4
ITEM_SUBCLASS_GLYPH_PRIEST = 5
ITEM_SUBCLASS_GLYPH_DEATH_KNIGHT = 6
ITEM_SUBCLASS_GLYPH_SHAMAN = 7
ITEM_SUBCLASS_GLYPH_MAGE = 8
ITEM_SUBCLASS_GLYPH_WARLOCK = 9
ITEM_SUBCLASS_GLYPH_DRUID = 11
MAX_ITEM_SUBCLASS_GLYPH = 12 -- MAX ITEM SUBCLASS GLYPH
-- BAG FAMILY MASK
BAG_FAMILY_MASK_NONE = 0x00000000
BAG_FAMILY_MASK_ARROWS = 0x00000001
BAG_FAMILY_MASK_BULLETS = 0x00000002
BAG_FAMILY_MASK_SOUL_SHARDS = 0x00000004
BAG_FAMILY_MASK_LEATHERWORKING_SUPP = 0x00000008
BAG_FAMILY_MASK_INSCRIPTION_SUPP = 0x00000010
BAG_FAMILY_MASK_HERBS = 0x00000020
BAG_FAMILY_MASK_ENCHANTING_SUPP = 0x00000040
BAG_FAMILY_MASK_ENGINEERING_SUPP = 0x00000080
BAG_FAMILY_MASK_KEYS = 0x00000100
BAG_FAMILY_MASK_GEMS = 0x00000200
BAG_FAMILY_MASK_MINING_SUPP = 0x00000400
BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT = 0x00000800
BAG_FAMILY_MASK_VANITY_PETS = 0x00001000
BAG_FAMILY_MASK_CURRENCY_TOKENS = 0x00002000
BAG_FAMILY_MASK_QUEST_ITEMS = 0x00004000
-- SOCKET COLORS
SOCKET_COLOR_META = 1
SOCKET_COLOR_RED = 2
SOCKET_COLOR_YELLOW = 4
SOCKET_COLOR_BLUE = 8
SOCKET_COLOR_ALL = 15
-- INVENTORY TYPES
INVTYPE_NON_EQUIP = 0
INVTYPE_HEAD = 1
INVTYPE_NECK = 2
INVTYPE_SHOULDERS = 3
INVTYPE_BODY = 4
INVTYPE_CHEST = 5
INVTYPE_WAIST = 6
INVTYPE_LEGS = 7
INVTYPE_FEET = 8
INVTYPE_WRISTS = 9
INVTYPE_HANDS = 10
INVTYPE_FINGER = 11
INVTYPE_TRINKET = 12
INVTYPE_WEAPON = 13
INVTYPE_SHIELD = 14
INVTYPE_RANGED = 15
INVTYPE_CLOAK = 16
INVTYPE_2HWEAPON = 17
INVTYPE_BAG = 18
INVTYPE_TABARD = 19
INVTYPE_ROBE = 20
INVTYPE_WEAPONMAINHAND = 21
INVTYPE_WEAPONOFFHAND = 22
INVTYPE_HOLDABLE = 23
INVTYPE_AMMO = 24
INVTYPE_THROWN = 25
INVTYPE_RANGEDRIGHT = 26
INVTYPE_QUIVER = 27
INVTYPE_RELIC = 28
MAX_INVTYPE = 29 -- MAX INVENTORY TYPE
--------------------------------------------------------
--[[
VEHICLE DEFINES
--]]
--------------------------------------------------------
-- VEHICLE POWER TYPE
POWER_STEAM = 61
POWER_PYRITE = 41
POWER_HEAT = 101
POWER_OOZE = 121
POWER_BLOOD = 141
POWER_WRATH = 142
-- VEHICLE FLAGS
VEHICLE_FLAG_NO_STRAFE = 0x00000001 -- Sets MOVEFLAG2_NO_STRAFE
VEHICLE_FLAG_NO_JUMPING = 0x00000002 -- Sets MOVEFLAG2_NO_JUMPING
VEHICLE_FLAG_FULLSPEEDTURNING = 0x00000004 -- Sets MOVEFLAG2_FULLSPEEDTURNING
VEHICLE_FLAG_ALLOW_PITCHING = 0x00000010 -- Sets MOVEFLAG2_ALLOW_PITCHING
VEHICLE_FLAG_FULLSPEEDPITCHING = 0x00000020 -- Sets MOVEFLAG2_FULLSPEEDPITCHING
VEHICLE_FLAG_CUSTOM_PITCH = 0x00000040 -- If set use pitchMin and pitchMax from DBC, otherwise pitchMin = -pi/2, pitchMax = pi/2
VEHICLE_FLAG_ADJUST_AIM_ANGLE = 0x00000400 -- Lua_IsVehicleAimAngleAdjustable
VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800 -- Lua_IsVehicleAimPowerAdjustable
-- VEHICLE SPELLS
VEHICLE_SPELL_RIDE_HARDCODED = 46598
VEHICLE_SPELL_PARACHUTE = 45472
--------------------------------------------------------
--[[
WEATHER STATES
--]]
--------------------------------------------------------
WEATHER_STATE_FINE = 0
WEATHER_STATE_FOG = 1
WEATHER_STATE_LIGHT_RAIN = 3
WEATHER_STATE_MEDIUM_RAIN = 4
WEATHER_STATE_HEAVY_RAIN = 5
WEATHER_STATE_LIGHT_SNOW = 6
WEATHER_STATE_MEDIUM_SNOW = 7
WEATHER_STATE_HEAVY_SNOW = 8
WEATHER_STATE_LIGHT_SANDSTORM = 22
WEATHER_STATE_MEDIUM_SANDSTORM = 41
WEATHER_STATE_HEAVY_SANDSTORM = 42
WEATHER_STATE_THUNDERS = 86
WEATHER_STATE_BLACKRAIN = 90
WEATHER_STATE_BLACKSNOW = 106
-- WEATHER SEASONS
WEATHER_SEASONS = 4
--------------------------------------------------------
--[[
LOOT
--]]
--------------------------------------------------------
-- LOOT TYPES
LOOT_CORPSE = 1
LOOT_PICKPOCKETING = 2
LOOT_FISHING = 3
LOOT_DISENCHANTING = 4
LOOT_SKINNING = 6
LOOT_PROSPECTING = 7
LOOT_MILLING = 8
LOOT_FISHINGHOLE = 20 -- unsupported by client, sending LOOT_FISHING instead
LOOT_INSIGNIA = 21 -- unsupported by client, sending LOOT_CORPSE instead
-- LOOT SLOT TYPES
LOOT_SLOT_TYPE_ALLOW_LOOT = 0 -- player can loot the item.
LOOT_SLOT_TYPE_ROLL_ONGOING = 1 -- roll is ongoing. player cannot loot.
LOOT_SLOT_TYPE_MASTER = 2 -- item can only be distributed by group loot master.
LOOT_SLOT_TYPE_LOCKED = 3 -- item is shown in red. player cannot loot.
LOOT_SLOT_TYPE_OWNER = 4 -- ignore binding confirmation and etc, for single player looting
-- LOOT METHOD
FREE_FOR_ALL = 0
ROUND_ROBIN = 1
MASTER_LOOT = 2
GROUP_LOOT = 3
NEED_BEFORE_GREED = 4
-- PERMISSION TYPES
ALL_PERMISSION = 0
GROUP_PERMISSION = 1
MASTER_PERMISSION = 2
ROUND_ROBIN_PERMISSION = 3
OWNER_PERMISSION = 4
NONE_PERMISSION = 5
-- ROLL TYPES
ROLL_PASS = 0
ROLL_NEED = 1
ROLL_GREED = 2
ROLL_DISENCHANT = 3
MAX_ROLL_TYPE = 4
-- ROLL MASK
ROLL_FLAG_TYPE_PASS = 0x01
ROLL_FLAG_TYPE_NEED = 0x02
ROLL_FLAG_TYPE_GREED = 0x04
ROLL_FLAG_TYPE_DISENCHANT = 0x08
ROLL_ALL_TYPE_NO_DISENCHANT = 0x07
ROLL_ALL_TYPE_MASK = 0x0F
--------------------------------------------------------
--[[
LFG
--]]
--------------------------------------------------------
-- CLASS NEEDED
LFG_TANKS_OR_HEALERS_NEEDED = 1
LFG_DPS_NEEDED = 3
-- LFG ROLES
PLAYER_ROLE_NONE = 0x00
PLAYER_ROLE_LEADER = 0x01
PLAYER_ROLE_TANK = 0x02
PLAYER_ROLE_HEALER = 0x04
PLAYER_ROLE_DAMAGE = 0x08
-- LFG UPDATE TYPES
LFG_UPDATETYPE_DEFAULT = 0 -- Internal Use
LFG_UPDATETYPE_LEADER_UNK1 = 1 -- FIXME: At group leave
LFG_UPDATETYPE_ROLECHECK_ABORTED = 4
LFG_UPDATETYPE_JOIN_QUEUE = 5
LFG_UPDATETYPE_ROLECHECK_FAILED = 6
LFG_UPDATETYPE_REMOVED_FROM_QUEUE = 7
LFG_UPDATETYPE_PROPOSAL_FAILED = 8
LFG_UPDATETYPE_PROPOSAL_DECLINED = 9
LFG_UPDATETYPE_GROUP_FOUND = 10
LFG_UPDATETYPE_ADDED_TO_QUEUE = 12
LFG_UPDATETYPE_PROPOSAL_BEGIN = 13
LFG_UPDATETYPE_UPDATE_STATUS = 14
LFG_UPDATETYPE_GROUP_MEMBER_OFFLINE = 15
LFG_UPDATETYPE_GROUP_DISBAND_UNK16 = 16 -- FIXME: Sometimes at group disband
-- LFG STATES
LFG_STATE_NONE = 0 -- Not using LFG / LFR
LFG_STATE_ROLECHECK = 1 -- Rolecheck active
LFG_STATE_QUEUED = 2 -- Queued
LFG_STATE_PROPOSAL = 3 -- Proposal active
LFG_STATE_BOOT = 4 -- Vote kick active
LFG_STATE_DUNGEON = 5 -- In LFG Group, in a Dungeon
LFG_STATE_FINISHED_DUNGEON = 6 -- In LFG Group, in a finished Dungeon
LFG_STATE_RAIDBROWSER = 7 -- Using Raid finder
-- LFG LOCK STATUS TYPES
LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION = 1
LFG_LOCKSTATUS_TOO_LOW_LEVEL = 2
LFG_LOCKSTATUS_TOO_HIGH_LEVEL = 3
LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE = 4
LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE = 5
LFG_LOCKSTATUS_RAID_LOCKED = 6
LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL = 1001
LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL = 1002
LFG_LOCKSTATUS_QUEST_NOT_COMPLETED = 1022
LFG_LOCKSTATUS_MISSING_ITEM = 1025
LFG_LOCKSTATUS_NOT_IN_SEASON = 1031
LFG_LOCKSTATUS_MISSING_ACHIEVEMENT = 1034
-- LFG ANSWER
LFG_ANSWER_PENDING = -1
LFG_ANSWER_DENY = 0
LFG_ANSWER_AGREE = 1
-- LFG GROUP TYPE
LFG_GROUP_MAX_KICKS = 3
-- LFG OPTIONS
LFG_OPTION_ENABLE_DUNGEON_FINDER = 0x01
LFG_OPTION_ENABLE_RAID_BROWSER = 0x02
-- LFG MGR TYPES
LFG_TIME_ROLECHECK = 45 * IN_MILLISECONDS
LFG_TIME_BOOT = 120
LFG_TIME_PROPOSAL = 45
LFG_QUEUEUPDATE_INTERVAL = 15 * IN_MILLISECONDS
LFG_SPELL_DUNGEON_COOLDOWN = 71328
LFG_SPELL_DUNGEON_DESERTER = 71041
LFG_SPELL_LUCK_OF_THE_DRAW = 72221
LFG_GROUP_KICK_VOTES_NEEDED = 3
-- LFG FLAGS
LFG_FLAG_UNK1 = 0x1
LFG_FLAG_UNK2 = 0x2
LFG_FLAG_SEASONAL = 0x4
LFG_FLAG_UNK3 = 0x8
-- LFG TYPES
LFG_TYPE_NONE = 0
LFG_TYPE_DUNGEON = 1
LFG_TYPE_RAID = 2
LFG_TYPE_HEROIC = 5
LFG_TYPE_RANDOM = 6
-- LFG PROPOSAL STATE
LFG_PROPOSAL_INITIATING = 0
LFG_PROPOSAL_FAILED = 1
LFG_PROPOSAL_SUCCESS = 2
-- LFG TELEPORT ERRORS
LFG_TELEPORTERROR_OK = 0 -- Internal use
LFG_TELEPORTERROR_PLAYER_DEAD = 1
LFG_TELEPORTERROR_FALLING = 2
LFG_TELEPORTERROR_IN_VEHICLE = 3
LFG_TELEPORTERROR_FATIGUE = 4
LFG_TELEPORTERROR_INVALID_LOCATION = 6
LFG_TELEPORTERROR_CHARMING = 8 -- FIXME - It can be 7 or 8 (Need proper data)
-- LFG JOIN RESULTS
LFG_JOIN_OK = 0 -- Joined (no client msg)
LFG_JOIN_FAILED = 1 -- RoleCheck Failed
LFG_JOIN_GROUPFULL = 2 -- Your group is full
LFG_JOIN_INTERNAL_ERROR = 4 -- Internal LFG Error
LFG_JOIN_NOT_MEET_REQS = 5 -- You do not meet the requirements for the chosen dungeons
LFG_JOIN_PARTY_NOT_MEET_REQS = 6 -- One or more party members do not meet the requirements for the chosen dungeons
LFG_JOIN_MIXED_RAID_DUNGEON = 7 -- You cannot mix dungeons, raids, and random when picking dungeons
LFG_JOIN_MULTI_REALM = 8 -- The dungeon you chose does not support players from multiple realms
LFG_JOIN_DISCONNECTED = 9 -- One or more party members are pending invites or disconnected
LFG_JOIN_PARTY_INFO_FAILED = 10 -- Could not retrieve information about some party members
LFG_JOIN_DUNGEON_INVALID = 11 -- One or more dungeons was not valid
LFG_JOIN_DESERTER = 12 -- You can not queue for dungeons until your deserter debuff wears off
LFG_JOIN_PARTY_DESERTER = 13 -- One or more party members has a deserter debuff
LFG_JOIN_RANDOM_COOLDOWN = 14 -- You can not queue for random dungeons while on random dungeon cooldown
LFG_JOIN_PARTY_RANDOM_COOLDOWN = 15 -- One or more party members are on random dungeon cooldown
LFG_JOIN_TOO_MUCH_MEMBERS = 16 -- You can not enter dungeons with more that 5 party members
LFG_JOIN_USING_BG_SYSTEM = 17 -- You can not use the dungeon system while in BG or arenas
-- LFG ROLE CHECK STATE
LFG_ROLECHECK_DEFAULT = 0 -- Internal use = Not initialized.
LFG_ROLECHECK_FINISHED = 1 -- Role check finished
LFG_ROLECHECK_INITIALITING = 2 -- Role check begins
LFG_ROLECHECK_MISSING_ROLE = 3 -- Someone didn't selected a role after 2 mins
LFG_ROLECHECK_WRONG_ROLES = 4 -- Can't form a group with that role selection
LFG_ROLECHECK_ABORTED = 5 -- Someone leave the group
LFG_ROLECHECK_NO_ROLE = 6 -- Someone selected no role
--------------------------------------------------------
--[[
MAIL
--]]
--------------------------------------------------------
-- MAIL MESSAGE TYPES
MAIL_NORMAL = 0
MAIL_AUCTION = 2
MAIL_CREATURE = 3 -- client send CMSG_CREATURE_QUERY on this mailmessagetype
MAIL_GAMEOBJECT = 4 -- client send CMSG_GAMEOBJECT_QUERY on this mailmessagetype
MAIL_CALENDAR = 5
-- MAIL STATE
MAIL_STATE_UNCHANGED = 1
MAIL_STATE_CHANGED = 2
MAIL_STATE_DELETED = 3
-- MAIL SHOW FLAGS
MAIL_SHOW_UNK0 = 0x0001
MAIL_SHOW_DELETE = 0x0002 -- forced show delete button instead return button
MAIL_SHOW_AUCTION = 0x0004 -- from old comment
MAIL_SHOW_UNK2 = 0x0008 -- unknown, COD will be shown even without that flag
MAIL_SHOW_RETURN = 0x0010
-- MAIL CHECK MASK
MAIL_CHECK_MASK_NONE = 0x00
MAIL_CHECK_MASK_READ = 0x01
MAIL_CHECK_MASK_RETURNED = 0x02 -- This mail was returned. Do not allow returning mail back again.
MAIL_CHECK_MASK_COPIED = 0x04 -- This mail was copied. Do not allow making a copy of items in mail.
MAIL_CHECK_MASK_COD_PAYMENT = 0x08
MAIL_CHECK_MASK_HAS_BODY = 0x10 -- This mail has body text.
-- MAIL STATIONARY TYPES
MAIL_STATIONERY_TEST = 1
MAIL_STATIONERY_DEFAULT = 41
MAIL_STATIONERY_GM = 61
MAIL_STATIONERY_AUCTION = 62
MAIL_STATIONERY_VAL = 64 -- Valentine
MAIL_STATIONERY_CHR = 65 -- Christmas
MAIL_STATIONERY_ORP = 67 -- Orphan
--------------------------------------------------------
--[[
MOTION (MOVEMENT)
--]]
--------------------------------------------------------
-- MOVEMENT GENERATOR TYPES
IDLE_MOTION_TYPE = 0 -- IdleMovementGenerator.h
RANDOM_MOTION_TYPE = 1 -- RandomMovementGenerator.h
WAYPOINT_MOTION_TYPE = 2 -- WaypointMovementGenerator.h
MAX_DB_MOTION_TYPE = 3 -- *** this and below motion types can't be set in DB.
ANIMAL_RANDOM_MOTION_TYPE = MAX_DB_MOTION_TYPE -- AnimalRandomMovementGenerator.h
CONFUSED_MOTION_TYPE = 4 -- ConfusedMovementGenerator.h
CHASE_MOTION_TYPE = 5 -- TargetedMovementGenerator.h
HOME_MOTION_TYPE = 6 -- HomeMovementGenerator.h
FLIGHT_MOTION_TYPE = 7 -- WaypointMovementGenerator.h
POINT_MOTION_TYPE = 8 -- PointMovementGenerator.h
FLEEING_MOTION_TYPE = 9 -- FleeingMovementGenerator.h
DISTRACT_MOTION_TYPE = 10 -- IdleMovementGenerator.h
ASSISTANCE_MOTION_TYPE= 11 -- PointMovementGenerator.h (first part of flee for assistance)
ASSISTANCE_DISTRACT_MOTION_TYPE = 12 -- IdleMovementGenerator.h (second part of flee for assistance)
TIMED_FLEEING_MOTION_TYPE = 13 -- FleeingMovementGenerator.h (alt.second part of flee for assistance)
FOLLOW_MOTION_TYPE = 14
ROTATE_MOTION_TYPE = 15
EFFECT_MOTION_TYPE = 16
NULL_MOTION_TYPE = 17
-- MOVEMENT SLOTS
MOTION_SLOT_IDLE = 0
MOTION_SLOT_ACTIVE = 1
MOTION_SLOT_CONTROLLED = 2
MAX_MOTION_SLOT = 3 -- MAX MOTION SLOT
--------------------------------------------------------
--[[
OBJECT
--]]
--------------------------------------------------------
-- OBJECT TYPE MASK
TYPEMASK_OBJECT = 0x0001
TYPEMASK_ITEM = 0x0002
TYPEMASK_CONTAINER = 0x0006 -- TYPEMASK_ITEM | 0x0004
TYPEMASK_UNIT = 0x0008 -- creature
TYPEMASK_PLAYER = 0x0010
TYPEMASK_GAMEOBJECT = 0x0020
TYPEMASK_DYNAMICOBJECT = 0x0040
TYPEMASK_CORPSE = 0x0080
TYPEMASK_SEER = 88
-- OBJECT TYPE ID
TYPEID_OBJECT = 0
TYPEID_ITEM = 1
TYPEID_CONTAINER = 2
TYPEID_UNIT = 3
TYPEID_PLAYER = 4
TYPEID_GAMEOBJECT = 5
TYPEID_DYNAMICOBJECT = 6
TYPEID_CORPSE = 7
-- TEMP SUMMON TYPES
TEMPSUMMON_TIMED_OR_DEAD_DESPAWN = 1 -- despawns after a specified time OR when the creature disappears
TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN = 2 -- despawns after a specified time OR when the creature dies
TEMPSUMMON_TIMED_DESPAWN = 3 -- despawns after a specified time
TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT = 4 -- despawns after a specified time after the creature is out of combat
TEMPSUMMON_CORPSE_DESPAWN = 5 -- despawns instantly after death
TEMPSUMMON_CORPSE_TIMED_DESPAWN = 6 -- despawns after a specified time after death
TEMPSUMMON_DEAD_DESPAWN = 7 -- despawns when the creature disappears
TEMPSUMMON_MANUAL_DESPAWN = 8 -- despawns when UnSummon() is called
-- PHASEMASK
PHASEMASK_NORMAL = 0x00000001
PHASEMASK_ANYWHERE = 0xFFFFFFFF
-- OBJECT GUID
HIGHGUID_ITEM = 0x4000
HIGHGUID_CONTAINER = 0x4000
HIGHGUID_PLAYER = 0x0000
HIGHGUID_GAMEOBJECT = 0xF110
HIGHGUID_TRANSPORT = 0xF120
HIGHGUID_UNIT = 0xF130
HIGHGUID_PET = 0xF140
HIGHGUID_VEHICLE = 0xF150
HIGHGUID_DYNAMICOBJECT = 0xF100
HIGHGUID_CORPSE = 0xF101
HIGHGUID_MO_TRANSPORT = 0x1FC0
HIGHGUID_GROUP = 0x1F50 | gpl-2.0 |
RunAwayDSP/darkstar | scripts/zones/Grand_Palace_of_HuXzoi/mobs/Eoghrah.lua | 9 | 2620 | -----------------------------------
-- Area: Grand Palace of Hu'Xzoi
-- Mob: Eo'ghrah
-----------------------------------
require("scripts/globals/status");
-----------------------------------
function onMobSpawn(mob)
-- Set core Skin and mob elemental resist/weakness; other elements set to 0.
-- Set to non aggro.
mob:AnimationSub(0);
mob:setAggressive(0);
mob:setLocalVar("roamTime", os.time());
mob:setLocalVar("form2",math.random(2,3));
local skin = math.random(1161,1168);
mob:setModelId(skin);
if (skin == 1161) then -- Fire
mob:setMod(dsp.mod.ICERES, 27);
mob:setMod(dsp.mod.WATERRES, -27);
elseif (skin == 1164) then --Earth
mob:setMod(dsp.mod.THUNDERRES, 27);
mob:setMod(dsp.mod.WINDRES, -27);
elseif (skin == 1162) then -- Water
mob:setMod(dsp.mod.THUNDERRES, -27);
mob:setMod(dsp.mod.FIRERES, 27);
elseif (skin == 1163) then -- Wind
mob:setMod(dsp.mod.ICERES, -27);
mob:setMod(dsp.mod.EARTHRES, 27);
elseif (skin == 1166) then --Ice
mob:setMod(dsp.mod.WINDRES, 27);
mob:setMod(dsp.mod.FIRERES, -27);
elseif (skin == 1165) then --Lightning
mob:setMod(dsp.mod.WATERRES, 27);
mob:setMod(dsp.mod.EARTHRES, -27);
elseif (skin == 1167) then --Light
mob:setMod(dsp.mod.LIGHTRES, 27);
mob:setMod(dsp.mod.DARKRES, -27);
elseif (skin == 1168) then --Dark
mob:setMod(dsp.mod.DARKRES, 27);
mob:setMod(dsp.mod.LIGHTRES, -27);
end;
end;
function onMobRoam(mob)
local roamTime = mob:getLocalVar("roamTime");
if (mob:AnimationSub() == 0 and os.time() - roamTime > 60) then
mob:AnimationSub(mob:getLocalVar("form2"));
mob:setLocalVar("roamTime", os.time());
mob:setAggressive(1);
elseif (mob:AnimationSub() == mob:getLocalVar("form2") and os.time() - roamTime > 60) then
mob:AnimationSub(0);
mob:setAggressive(0);
mob:setLocalVar("roamTime", os.time());
end
end;
function onMobFight(mob,target)
local changeTime = mob:getLocalVar("changeTime");
if (mob:AnimationSub() == 0 and mob:getBattleTime() - changeTime > 60) then
mob:AnimationSub(mob:getLocalVar("form2"));
mob:setAggressive(1);
mob:setLocalVar("changeTime", mob:getBattleTime());
elseif (mob:AnimationSub() == mob:getLocalVar("form2") and mob:getBattleTime() - changeTime > 60) then
mob:AnimationSub(0);
mob:setAggressive(0);
mob:setLocalVar("changeTime", mob:getBattleTime());
end
end;
function onMobDeath(mob, player, isKiller)
end;
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Misareaux_Coast/npcs/HomePoint#1.lua | 18 | 1271 | -----------------------------------
-- Area: Misareaux Coast
-- NPC: HomePoint#1
-- @pos -65 -17.5 563 25
-----------------------------------
package.loaded["scripts/zones/Misareaux_Coast/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Misareaux_Coast/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fd, 25);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fd) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/items/sleep_bolt.lua | 12 | 1175 | -----------------------------------------
-- ID: 18149
-- Item: Sleep Bolt
-- Additional Effect: Sleep
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------------
function onAdditionalEffect(player,target,damage)
local chance = 95
if (target:getMainLvl() > player:getMainLvl()) then
chance = chance - 5 * (target:getMainLvl() - player:getMainLvl())
chance = utils.clamp(chance, 5, 95)
end
if (math.random(0,99) >= chance) then
return 0,0,0
else
local duration = 25
if (target:getMainLvl() > player:getMainLvl()) then
duration = duration - (target:getMainLvl() - player:getMainLvl())
end
duration = utils.clamp(duration,1,25)
duration = duration * applyResistanceAddEffect(player,target,dsp.magic.ele.LIGHT,0)
if (not target:hasStatusEffect(dsp.effect.SLEEP_I)) then
target:addStatusEffect(dsp.effect.SLEEP_I, 1, 0, duration)
end
return dsp.subEffect.SLEEP, dsp.msg.basic.ADD_EFFECT_STATUS, dsp.effect.SLEEP_I
end
end | gpl-3.0 |
lichtl/darkstar | scripts/zones/Palborough_Mines/npcs/Old_Toolbox.lua | 17 | 1411 | -----------------------------------
-- Area: Palborough Mines
-- NPC: Old Toolbox
-- Continues Quest: The Eleventh's Hour
-----------------------------------
package.loaded["scripts/zones/Palborough_Mines/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Palborough_Mines/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(BASTOK,THE_ELEVENTH_S_HOUR) == QUEST_ACCEPTED and player:hasKeyItem(OLD_TOOLBOX) == false) then
player:startEvent(0x0017);
else
player:startEvent(0x0016);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID2: %u",csid);
-- printf("RESULT2: %u",option);
if (csid == 0x0017 and option == 0) then
player:addKeyItem(OLD_TOOLBOX);
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
Gathros/algorithm-archive | contents/huffman_encoding/code/lua/huffman.lua | 2 | 3078 | local function frequency_array(str)
-- Collect all frequency values into a dict
local map = {}
for c in str:gmatch(".") do -- Iterate over each character in str
map[c] = (map[c] or 0) + 1 -- Increment map[c] (default 0) by 1
end
-- We have a dict of frequencies but we want it in a sorted list
-- Dump each key value pair into an array
local arr = {}
for k, v in pairs(map) do
arr[#arr + 1] = {k, v}
end
table.sort(arr, function(a, b) return a[2] > b[2] end) -- Sort by frequency descending
return arr
end
local function build_huffman_tree(message)
if #message == 0 then return end
local freq = frequency_array(message)
while #freq > 1 do -- Repeat until we have only 1 node
-- Take two of the least frequent nodes
local node1, node2 = table.remove(freq), table.remove(freq)
-- Group node values in first index, and sum of node frequencies in second
local node3 = { {node1[1], node2[1] }, node1[2] + node2[2] }
local i = 1
while i <= #freq and freq[i][2] <= node3[2] do -- Sorted insertion, faster than inserting then sorting again
i = i + 1
end
table.insert(freq, i, node3)
end
return freq[1][1] -- Return value of only element in freq array
end
local function _create_codebook(node, codebook, code)
if not node then
return
elseif type(node) == "string" then
codebook[node] = code -- if node is a leaf then add it to codebook
else
_create_codebook(node[1], codebook, code .. "0") -- Left side
_create_codebook(node[2], codebook, code .. "1") -- Right side
end
end
local function create_codebook(tree)
local codebook = {}
_create_codebook(tree, codebook, "")
return codebook
end
local function huffman_encode(codebook, message)
local encoded_chars = {}
for c in message:gmatch(".") do -- Iterate over each character in message
encoded_chars[#encoded_chars + 1] = codebook[c]
end
return table.concat(encoded_chars) -- table.concat to avoid slow string bufferin
end
local function _huffman_decode(node, bitstring, i)
if type(node) == "string" then
return node, i -- If it's a leaf node then return the value along with the next bit to read
end
if bitstring:sub(i, i) == "0" then
return _huffman_decode(node[1], bitstring, i + 1) -- If it's 0 traverse down the left side
elseif bitstring:sub(i, i) == "1" then
return _huffman_decode(node[2], bitstring, i + 1) -- If it's 1 traverse down the right side
end
end
local function huffman_decode(tree, bitstring)
-- i is the current position in the bitstring, we can track which bit we are to look at next without using string.sub
local decoded_chars, i = {}, 1
while i <= #bitstring do
decoded_chars[#decoded_chars + 1], i = _huffman_decode(tree, bitstring, i)
end
return table.concat(decoded_chars)
end
local message = "bibbity_bobbity"
local tree = build_huffman_tree(message)
local codebook = create_codebook(tree)
local bitstring = huffman_encode(codebook, message)
print("Encoded: " .. bitstring)
print("Decoded: " .. huffman_decode(tree, bitstring))
| mit |
lichtl/darkstar | scripts/zones/Korroloka_Tunnel/npcs/qm2.lua | 14 | 3352 | -----------------------------------
-- Area: Korroloka Tunnel
-- NPC: ??? (qm2)
-- Involved In Quest: Ayame and Kaede
-- @pos -208 -9 176 173
-----------------------------------
package.loaded["scripts/zones/Korroloka_Tunnel/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Korroloka_Tunnel/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(BASTOK,AYAME_AND_KAEDE) == QUEST_ACCEPTED) then
if (player:getVar("AyameAndKaede_Event") == 2 and player:hasKeyItem(STRANGELY_SHAPED_CORAL) == false) then
local leechesDespawned = (GetMobAction(17486187) == 0 and GetMobAction(17486188) == 0 and GetMobAction(17486189) == 0);
local spawnTime = player:getVar("KorrolokaLeeches_Spawned");
local canSpawn = (leechesDespawned and (os.time() - spawnTime) > 30);
local killedLeeches = player:getVar("KorrolokaLeeches");
if (killedLeeches >= 1) then
if ((killedLeeches == 3 and (os.time() - player:getVar("KorrolokaLeeches_Timer") < 30)) or (killedLeeches < 3 and leechesDespawned and (os.time() - spawnTime) < 30)) then
player:addKeyItem(STRANGELY_SHAPED_CORAL);
player:messageSpecial(KEYITEM_OBTAINED,STRANGELY_SHAPED_CORAL);
player:setVar("KorrolokaLeeches",0);
player:setVar("KorrolokaLeeches_Spawned",0);
player:setVar("KorrolokaLeeches_Timer",0);
elseif (leechesDespawned) then
SpawnMob(17486187); -- Despawn after 3 minutes (-12 seconds for despawn delay).
SpawnMob(17486188);
SpawnMob(17486189);
player:setVar("KorrolokaLeeches",0);
player:setVar("KorrolokaLeeches_Spawned",os.time()+180);
player:messageSpecial(SENSE_OF_BOREBODING);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
elseif (canSpawn) then
SpawnMob(17486187); -- Despawn after 3 minutes (-12 seconds for despawn delay).
SpawnMob(17486188);
SpawnMob(17486189);
player:setVar("KorrolokaLeeches_Spawned",os.time()+180);
player:messageSpecial(SENSE_OF_BOREBODING);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
OctoEnigma/shiny-octo-system | gamemodes/darkrp/gamemode/modules/money/sv_interface.lua | 13 | 1964 | DarkRP.PLAYER.addMoney = DarkRP.stub{
name = "addMoney",
description = "Give money to a player.",
parameters = {
{
name = "amount",
description = "The amount of money to give to the player. A negative amount means you're substracting money.",
type = "number",
optional = false
}
},
returns = {
},
metatable = DarkRP.PLAYER
}
DarkRP.PLAYER.payDay = DarkRP.stub{
name = "payDay",
description = "Give a player their salary.",
parameters = {
},
returns = {
},
metatable = DarkRP.PLAYER
}
DarkRP.payPlayer = DarkRP.stub{
name = "payPlayer",
description = "Make one player give money to the other player.",
parameters = {
{
name = "sender",
description = "The player who gives the money.",
type = "Player",
optional = false
},
{
name = "receiver",
description = "The player who receives the money.",
type = "Player",
optional = false
},
{
name = "amount",
description = "The amount of money.",
type = "number",
optional = false
}
},
returns = {
},
metatable = DarkRP
}
DarkRP.createMoneyBag = DarkRP.stub{
name = "createMoneyBag",
description = "Create a money bag.",
parameters = {
{
name = "pos",
description = "The The position where the money bag is to be spawned.",
type = "Vector",
optional = false
},
{
name = "amount",
description = "The amount of money.",
type = "number",
optional = false
}
},
returns = {
{
name = "moneybag",
description = "The money bag entity.",
type = "Entity"
}
},
metatable = DarkRP
}
| mit |
lichtl/darkstar | scripts/zones/Inner_Horutoto_Ruins/npcs/_5c5.lua | 14 | 2062 | -----------------------------------
-- Area: Inner Horutoto Ruins
-- NPC: Gate: Magical Gizmo
-- Involved In Mission: The Horutoto Ruins Experiment
-- @pos 419 0 -27 192
-----------------------------------
package.loaded["scripts/zones/Inner_Horutoto_Ruins/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/zones/Inner_Horutoto_Ruins/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getCurrentMission(WINDURST) == THE_HORUTOTO_RUINS_EXPERIMENT and player:getVar("MissionStatus") == 1) then
player:startEvent(0x002A);
else
player:showText(npc,DOOR_FIRMLY_CLOSED);
end
return 1;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x002A) then
player:setVar("MissionStatus",2);
-- Generate a random value to use for the next part of the mission
-- where you have to examine 6 Magical Gizmo's, each of them having
-- a number from 1 to 6 (Remember, setting 0 deletes the var)
local random_value = math.random(1,6);
player:setVar("MissionStatus_rv",random_value); -- 'rv' = random value
player:setVar("MissionStatus_op1",1);
player:setVar("MissionStatus_op2",1);
player:setVar("MissionStatus_op3",1);
player:setVar("MissionStatus_op4",1);
player:setVar("MissionStatus_op5",1);
player:setVar("MissionStatus_op6",1);
end
end; | gpl-3.0 |
padrinoo/padrino15 | plugins/search_youtube.lua | 674 | 1270 | do
local google_config = load_from_file('data/google.lua')
local function httpsRequest(url)
print(url)
local res,code = https.request(url)
if code ~= 200 then return nil end
return json:decode(res)
end
local function searchYoutubeVideos(text)
local url = 'https://www.googleapis.com/youtube/v3/search?'
url = url..'part=snippet'..'&maxResults=4'..'&type=video'
url = url..'&q='..URL.escape(text)
if google_config.api_keys then
local i = math.random(#google_config.api_keys)
local api_key = google_config.api_keys[i]
if api_key then
url = url.."&key="..api_key
end
end
local data = httpsRequest(url)
if not data then
print("HTTP Error")
return nil
elseif not data.items then
return nil
end
return data.items
end
local function run(msg, matches)
local text = ''
local items = searchYoutubeVideos(matches[1])
if not items then
return "Error!"
end
for k,item in pairs(items) do
text = text..'http://youtu.be/'..item.id.videoId..' '..
item.snippet.title..'\n\n'
end
return text
end
return {
description = "Search video on youtube and send it.",
usage = "!youtube [term]: Search for a youtube video and send it.",
patterns = {
"^!youtube (.*)"
},
run = run
}
end
| gpl-2.0 |
RunAwayDSP/darkstar | scripts/zones/Tavnazian_Safehold/npcs/Justinius.lua | 9 | 1569 | -----------------------------------
-- Area: Tavnazian Safehold
-- NPC: Justinius
-- Involved in mission : COP2-3
-- !pos 76 -34 68 26
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/missions");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
if (player:getCurrentMission(COP) == dsp.mission.id.cop.DISTANT_BELIEFS and player:getCharVar("PromathiaStatus") == 3) then
player:startEvent(113);
elseif (player:getCurrentMission(COP) == dsp.mission.id.cop.SHELTERING_DOUBT and player:getCharVar("PromathiaStatus") == 2) then
player:startEvent(109);
elseif (player:getCurrentMission(COP) == dsp.mission.id.cop.THE_SAVAGE and player:getCharVar("PromathiaStatus") == 2) then
player:startEvent(110);
else
player:startEvent(123);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 113) then
player:setCharVar("PromathiaStatus",0);
player:completeMission(COP,dsp.mission.id.cop.DISTANT_BELIEFS);
player:addMission(COP,dsp.mission.id.cop.AN_ETERNAL_MELODY);
elseif (csid == 109) then
player:setCharVar("PromathiaStatus",3);
elseif (csid == 110) then
player:setCharVar("PromathiaStatus",0);
player:completeMission(COP,dsp.mission.id.cop.THE_SAVAGE);
player:addMission(COP,dsp.mission.id.cop.THE_SECRETS_OF_WORSHIP);
player:addTitle(dsp.title.NAGMOLADAS_UNDERLING);
end
end; | gpl-3.0 |
lichtl/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Romaa_Mihgo.lua | 14 | 1060 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Romaa Mihgo
-- Type: Standard NPC
-- @zone 94
-- @pos -1.967 -3 -26.337
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x000b);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
SendCroissant/ggut | game/dota_addons/barebones/scripts/vscripts/libraries/timers.lua | 6 | 6434 | TIMERS_VERSION = "1.03"
--[[
-- A timer running every second that starts immediately on the next frame, respects pauses
Timers:CreateTimer(function()
print ("Hello. I'm running immediately and then every second thereafter.")
return 1.0
end
)
-- A timer which calls a function with a table context
Timers:CreateTimer(GameMode.someFunction, GameMode)
-- A timer running every second that starts 5 seconds in the future, respects pauses
Timers:CreateTimer(5, function()
print ("Hello. I'm running 5 seconds after you called me and then every second thereafter.")
return 1.0
end
)
-- 10 second delayed, run once using gametime (respect pauses)
Timers:CreateTimer({
endTime = 10, -- when this timer should first execute, you can omit this if you want it to run first on the next frame
callback = function()
print ("Hello. I'm running 10 seconds after when I was started.")
end
})
-- 10 second delayed, run once regardless of pauses
Timers:CreateTimer({
useGameTime = false,
endTime = 10, -- when this timer should first execute, you can omit this if you want it to run first on the next frame
callback = function()
print ("Hello. I'm running 10 seconds after I was started even if someone paused the game.")
end
})
-- A timer running every second that starts after 2 minutes regardless of pauses
Timers:CreateTimer("uniqueTimerString3", {
useGameTime = false,
endTime = 120,
callback = function()
print ("Hello. I'm running after 2 minutes and then every second thereafter.")
return 1
end
})
-- A timer using the old style to repeat every second starting 5 seconds ahead
Timers:CreateTimer("uniqueTimerString3", {
useOldStyle = true,
endTime = GameRules:GetGameTime() + 5,
callback = function()
print ("Hello. I'm running after 5 seconds and then every second thereafter.")
return GameRules:GetGameTime() + 1
end
})
]]
TIMERS_THINK = 0.01
if Timers == nil then
print ( '[Timers] creating Timers' )
Timers = {}
Timers.__index = Timers
end
function Timers:new( o )
o = o or {}
setmetatable( o, Timers )
return o
end
function Timers:_xpcall (f, ...)
print(f)
print({...})
PrintTable({...})
local result = xpcall (function () return f(unpack(arg)) end,
function (msg)
-- build the error message
return msg..'\n'..debug.traceback()..'\n'
end)
print(result)
PrintTable(result)
if not result[1] then
-- throw an error
end
-- remove status code
table.remove (result, 1)
return unpack (result)
end
function Timers:start()
Timers = self
self.timers = {}
local ent = Entities:CreateByClassname("info_target") -- Entities:FindByClassname(nil, 'CWorld')
ent:SetThink("Think", self, "timers", TIMERS_THINK)
end
function Timers:Think()
if GameRules:State_Get() >= DOTA_GAMERULES_STATE_POST_GAME then
return
end
-- Track game time, since the dt passed in to think is actually wall-clock time not simulation time.
local now = GameRules:GetGameTime()
-- Process timers
for k,v in pairs(Timers.timers) do
local bUseGameTime = true
if v.useGameTime ~= nil and v.useGameTime == false then
bUseGameTime = false
end
local bOldStyle = false
if v.useOldStyle ~= nil and v.useOldStyle == true then
bOldStyle = true
end
local now = GameRules:GetGameTime()
if not bUseGameTime then
now = Time()
end
if v.endTime == nil then
v.endTime = now
end
-- Check if the timer has finished
if now >= v.endTime then
-- Remove from timers list
Timers.timers[k] = nil
-- Run the callback
local status, nextCall
if v.context then
status, nextCall = xpcall(function() return v.callback(v.context, v) end, function (msg)
return msg..'\n'..debug.traceback()..'\n'
end)
else
status, nextCall = xpcall(function() return v.callback(v) end, function (msg)
return msg..'\n'..debug.traceback()..'\n'
end)
end
-- Make sure it worked
if status then
-- Check if it needs to loop
if nextCall then
-- Change its end time
if bOldStyle then
v.endTime = v.endTime + nextCall - now
else
v.endTime = v.endTime + nextCall
end
Timers.timers[k] = v
end
-- Update timer data
--self:UpdateTimerData()
else
-- Nope, handle the error
Timers:HandleEventError('Timer', k, nextCall)
end
end
end
return TIMERS_THINK
end
function Timers:HandleEventError(name, event, err)
print(err)
-- Ensure we have data
name = tostring(name or 'unknown')
event = tostring(event or 'unknown')
err = tostring(err or 'unknown')
-- Tell everyone there was an error
--Say(nil, name .. ' threw an error on event '..event, false)
--Say(nil, err, false)
-- Prevent loop arounds
if not self.errorHandled then
-- Store that we handled an error
self.errorHandled = true
end
end
function Timers:CreateTimer(name, args, context)
if type(name) == "function" then
if args ~= nil then
context = args
end
args = {callback = name}
name = DoUniqueString("timer")
elseif type(name) == "table" then
args = name
name = DoUniqueString("timer")
elseif type(name) == "number" then
args = {endTime = name, callback = args}
name = DoUniqueString("timer")
end
if not args.callback then
print("Invalid timer created: "..name)
return
end
local now = GameRules:GetGameTime()
if args.useGameTime ~= nil and args.useGameTime == false then
now = Time()
end
if args.endTime == nil then
args.endTime = now
elseif args.useOldStyle == nil or args.useOldStyle == false then
args.endTime = now + args.endTime
end
args.context = context
Timers.timers[name] = args
return name
end
function Timers:RemoveTimer(name)
Timers.timers[name] = nil
end
function Timers:RemoveTimers(killAll)
local timers = {}
if not killAll then
for k,v in pairs(Timers.timers) do
if v.persist then
timers[k] = v
end
end
end
Timers.timers = timers
end
if not Timers.timers then Timers:start() end | apache-2.0 |
lichtl/darkstar | scripts/globals/spells/bio_iii.lua | 26 | 2604 | -----------------------------------------
-- Spell: Bio III
-- Deals dark damage that weakens an enemy's attacks and gradually reduces its HP.
-- caster:getMerit() returns a value which is equal to the number of merit points TIMES the value of each point
-- Bio III value per point is '30' This is a constant set in the table 'merits'
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
--calculate raw damage
local basedmg = caster:getSkillLevel(DARK_MAGIC_SKILL) / 4;
local dmg = calculateMagicDamage(basedmg,3,caster,spell,target,DARK_MAGIC_SKILL,MOD_INT,false);
-- Softcaps at 32, should always do at least 1
if (dmg > 62) then
dmg = 62;
end
if (dmg < 1) then
dmg = 1;
end
--get resist multiplier (1x if no resist)
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),DARK_MAGIC_SKILL,1.0);
--get the resisted damage
dmg = dmg*resist;
--add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
dmg = addBonuses(caster,spell,target,dmg);
--add in target adjustment
dmg = adjustForTarget(target,dmg,spell:getElement());
--add in final adjustments including the actual damage dealt
local final = finalMagicAdjustments(caster,target,spell,dmg);
-- Calculate duration.
local duration = caster:getMerit(MERIT_BIO_III);
if (duration == 0) then --if caster has the spell but no merits in it, they are either a mob or we assume they are GM or otherwise gifted with max duration
duration = 150;
end
-- Check for Dia.
local dia = target:getStatusEffect(EFFECT_DIA);
-- Calculate DoT (rough, though fairly accurate)
local dotdmg = 4 + math.floor(caster:getSkillLevel(DARK_MAGIC_SKILL) / 60);
-- Do it!
if (dia == nil or (BIO_OVERWRITE == 0 and dia:getPower() <= 3) or (BIO_OVERWRITE == 1 and dia:getPower() < 3)) then
target:delStatusEffect(EFFECT_BIO); -- delete old bio
target:addStatusEffect(EFFECT_BIO,dotdmg,3,duration,FLAG_ERASABLE, 15);
end
--Try to kill same tier Dia (default behavior)
if (DIA_OVERWRITE == 1 and dia ~= nil) then
if (dia:getPower() <= 3) then
target:delStatusEffect(EFFECT_DIA);
end
end
return final;
end;
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/Dragons_Aery/mobs/Fafnir.lua | 11 | 1693 | -----------------------------------
-- Area: Dragons Aery
-- HNM: Fafnir
-----------------------------------
local ID = require("scripts/zones/Dragons_Aery/IDs")
mixins = {require("scripts/mixins/rage")}
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/titles")
-----------------------------------
function onMobSpawn(mob)
if LandKingSystem_NQ > 0 or LandKingSystem_HQ > 0 then
GetNPCByID(ID.npc.FAFNIR_QM):setStatus(dsp.status.DISAPPEAR)
end
if LandKingSystem_HQ == 0 then
SetDropRate(918,3340,0) -- do not drop cup_of_sweet_tea
end
mob:setLocalVar("[rage]timer", 3600) -- 60 minutes
end
function onMobDeath(mob, player, isKiller)
player:addTitle(dsp.title.FAFNIR_SLAYER)
end
function onMobDespawn(mob)
local ToD = GetServerVariable("[POP]Nidhogg")
local kills = GetServerVariable("[PH]Nidhogg")
local popNow = (math.random(1,5) == 3 or kills > 6)
if LandKingSystem_HQ ~= 1 and ToD <= os.time() and popNow then
-- 0 = timed spawn, 1 = force pop only, 2 = BOTH
if LandKingSystem_NQ == 0 then
DisallowRespawn(ID.mob.FAFNIR, true)
end
DisallowRespawn(ID.mob.NIDHOGG, false)
UpdateNMSpawnPoint(ID.mob.NIDHOGG)
GetMobByID(ID.mob.NIDHOGG):setRespawnTime(75600 + math.random(0, 6) * 1800) -- 21 - 24 hours with half hour windows
else
if LandKingSystem_NQ ~= 1 then
UpdateNMSpawnPoint(ID.mob.FAFNIR)
GetMobByID(ID.mob.FAFNIR):setRespawnTime(75600 + math.random(0, 6) * 1800) -- 21 - 24 hours with half hour windows
SetServerVariable("[PH]Nidhogg", kills + 1)
end
end
end
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/Stellar_Fulcrum/Zone.lua | 9 | 1365 | -----------------------------------
--
-- Zone: Stellar_Fulcrum
--
-----------------------------------
local ID = require("scripts/zones/Stellar_Fulcrum/IDs")
require("scripts/globals/conquest")
require("scripts/globals/missions")
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1, -522, -2, -49, -517, -1, -43); -- To Upper Delkfutt's Tower
zone:registerRegion(2, 318, -3, 2, 322, 1, 6); -- Exit BCNM to ?
end;
function onConquestUpdate(zone, updatetype)
dsp.conq.onConquestUpdate(zone, updatetype)
end;
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getCurrentMission(ZILART) == dsp.mission.id.zilart.RETURN_TO_DELKFUTTS_TOWER and player:getCharVar("ZilartStatus") == 2) then
cs = 0;
end
return cs;
end;
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
[1] = function (x)
player:startEvent(8);
end,
[2] = function (x)
player:startEvent(8);
end,
}
end;
function onRegionLeave(player,region)
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 8 and option == 1) then
player:setPos(-370, -178, -40, 243, 158);
elseif (csid == 0) then
player:setCharVar("ZilartStatus",3);
end
end; | gpl-3.0 |
taiha/luci | applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/df.lua | 73 | 1370 | -- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
m = Map("luci_statistics",
translate("DF Plugin Configuration"),
translate(
"The df plugin collects statistics about the disk space " ..
"usage on different devices, mount points or filesystem types."
))
-- collectd_df config section
s = m:section( NamedSection, "collectd_df", "luci_statistics" )
-- collectd_df.enable
enable = s:option( Flag, "enable", translate("Enable this plugin") )
enable.default = 0
-- collectd_df.devices (Device)
devices = s:option( Value, "Devices", translate("Monitor devices") )
devices.default = "/dev/mtdblock/4"
devices.optional = true
devices:depends( "enable", 1 )
-- collectd_df.mountpoints (MountPoint)
mountpoints = s:option( Value, "MountPoints", translate("Monitor mount points") )
mountpoints.default = "/overlay"
mountpoints.optional = true
mountpoints:depends( "enable", 1 )
-- collectd_df.fstypes (FSType)
fstypes = s:option( Value, "FSTypes", translate("Monitor filesystem types") )
fstypes.default = "tmpfs"
fstypes.optional = true
fstypes:depends( "enable", 1 )
-- collectd_df.ignoreselected (IgnoreSelected)
ignoreselected = s:option( Flag, "IgnoreSelected", translate("Monitor all except specified") )
ignoreselected.default = 0
ignoreselected:depends( "enable", 1 )
return m
| apache-2.0 |
lichtl/darkstar | scripts/zones/Port_Bastok/npcs/Agapito.lua | 14 | 1947 | -----------------------------------
-- Area: Port Bastok
-- NPC: Agapito
-- Start & Finishes Quest: The Stars of Ifrit
-- @zone 236
-- @pos -72.093 -3.097 9.309
-----------------------------------
package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Port_Bastok/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local TheStarsOfIfrit = player:getQuestStatus(BASTOK,THE_STARS_OF_IFRIT);
if (player:getFameLevel(BASTOK) >= 3 and TheStarsOfIfrit == QUEST_AVAILABLE and player:hasKeyItem(AIRSHIP_PASS) == true) then
player:startEvent(0x00b4);
elseif (TheStarsOfIfrit == QUEST_ACCEPTED and player:hasKeyItem(CARRIER_PIGEON_LETTER) == true) then
player:startEvent(0x00b5);
else
player:startEvent(0x0011);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x00b4) then
player:addQuest(BASTOK,THE_STARS_OF_IFRIT);
elseif (csid == 0x00b5) then
player:addGil(GIL_RATE*2100);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*2100);
player:addFame(BASTOK,100);
player:addTitle(STAR_OF_IFRIT);
player:completeQuest(BASTOK,THE_STARS_OF_IFRIT);
end
end;
| gpl-3.0 |
punisherbot/he | plugins/Boobs.lua | 731 | 1601 | do
-- Recursive function
local function getRandomButts(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.obutts.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt <= 3 then
print('Cannot get that butts, trying another one...')
return getRandomButts(attempt)
end
return 'http://media.obutts.ru/' .. data.preview
end
local function getRandomBoobs(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.oboobs.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then
print('Cannot get that boobs, trying another one...')
return getRandomBoobs(attempt)
end
return 'http://media.oboobs.ru/' .. data.preview
end
local function run(msg, matches)
local url = nil
if matches[1] == "!boobs" then
url = getRandomBoobs()
end
if matches[1] == "!butts" then
url = getRandomButts()
end
if url ~= nil then
local receiver = get_receiver(msg)
send_photo_from_url(receiver, url)
else
return 'Error getting boobs/butts for you, please try again later.'
end
end
return {
description = "Gets a random boobs or butts pic",
usage = {
"!boobs: Get a boobs NSFW image. 🔞",
"!butts: Get a butts NSFW image. 🔞"
},
patterns = {
"^!boobs$",
"^!butts$"
},
run = run
}
end
| gpl-2.0 |
sjznxd/lc-20130222 | applications/luci-wshaper/luasrc/model/cbi/wshaper.lua | 53 | 2056 | --[[
LuCI - Lua Configuration Interface
Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
]]--
require("luci.tools.webadmin")
m = Map("wshaper", translate("Wondershaper"),
translate("Wondershaper uses traffic shaping to ensure low latencies for interactive traffic even when your " ..
"internet connection is highly saturated."))
s = m:section(NamedSection, "settings", "wshaper", translate("Wondershaper settings"))
s.anonymous = true
network = s:option(ListValue, "network", translate("Interface"))
luci.tools.webadmin.cbi_add_networks(network)
uplink = s:option(Value, "uplink", translate("Uplink"), translate("Upstream bandwidth in kbit/s"))
uplink.optional = false
uplink.datatype = "uinteger"
uplink.default = "240"
uplink = s:option(Value, "downlink", translate("Downlink"), translate("Downstream bandwidth in kbit/s"))
uplink.optional = false
uplink.datatype = "uinteger"
uplink.default = "200"
nopriohostsrc = s:option(DynamicList, "nopriohostsrc", translate("Low priority hosts (Source)"), translate("Host or Network in CIDR notation."))
nopriohostsrc.optional = true
nopriohostsrc.datatype = ipaddr
nopriohostsrc.placeholder = "10.0.0.1/32"
nopriohostdst = s:option(DynamicList, "nopriohostdst", translate("Low priority hosts (Destination)"), translate("Host or Network in CIDR notation."))
nopriohostdst.optional = true
nopriohostdst.datatype = ipaddr
nopriohostdst.placeholder = "10.0.0.1/32"
noprioportsrc = s:option(DynamicList, "noprioportsrc", translate("Low priority source ports"))
noprioportsrc.optional = true
noprioportsrc.datatype = "range(0,65535)"
noprioportsrc.placeholder = "21"
noprioportdst = s:option(DynamicList, "noprioportdst", translate("Low priority destination ports"))
noprioportdst.optional = true
noprioportdst.datatype = "range(0,65535)"
noprioportdst.placeholder = "21"
return m
| apache-2.0 |
RunAwayDSP/darkstar | scripts/zones/Waughroon_Shrine/bcnms/worms_turn.lua | 9 | 1066 | -----------------------------------
-- The Worm's Turn
-- Waughroon Shrine BCNM40, Star Orb
-- !additem 1131
-----------------------------------
require("scripts/globals/battlefield")
-----------------------------------
function onBattlefieldInitialise(battlefield)
battlefield:setLocalVar("loot", 1)
end
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player, battlefield)
end
function onBattlefieldEnter(player, battlefield)
end
function onBattlefieldLeave(player, battlefield, leavecode)
if leavecode == dsp.battlefield.leaveCode.WON then
local name, clearTime, partySize = battlefield:getRecord()
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 1, battlefield:getLocalVar("[cs]bit"), 0)
elseif leavecode == dsp.battlefield.leaveCode.LOST then
player:startEvent(32002)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
end
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/spells/kurayami_ni.lua | 12 | 1357 | -----------------------------------------
-- Spell: Kurayami:Ni
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0
end
function onSpellCast(caster,target,spell)
-- Base Stats
local dINT = (caster:getStat(dsp.mod.INT) - target:getStat(dsp.mod.INT))
--Duration Calculation
local duration = 300
local params = {}
params.attribute = dsp.mod.INT
params.skillType = dsp.skill.NINJUTSU
params.bonus = 0
duration = duration * applyResistance(caster, target, spell, params)
--Kurayami base power is 30 and is not affected by resistaces.
local power = 30
--Calculates resist chanve from Reist Blind
if (math.random(0,100) >= target:getMod(dsp.mod.BLINDRES)) then
if (duration >= 150) then
if (target:addStatusEffect(dsp.effect.BLINDNESS,power,0,duration)) then
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB_IS)
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST_2)
end
return dsp.effect.BLINDNESS
end
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/items/winterflower.lua | 11 | 1056 | -----------------------------------------
-- ID: 5907
-- Item: Winterflower
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Agility +3
-- Intelligence +5
-- Charisma -5
-- Resist Virus +20
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,300,5907)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.AGI, 3)
target:addMod(dsp.mod.INT, 5)
target:addMod(dsp.mod.CHR, -5)
target:addMod(dsp.mod.VIRUSRES, 20)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.AGI, 3)
target:delMod(dsp.mod.INT, 5)
target:delMod(dsp.mod.CHR, -5)
target:delMod(dsp.mod.VIRUSRES, 20)
end
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Dynamis-Xarcabard/mobs/Marquis_Orias.lua | 23 | 1532 | -----------------------------------
-- Area: Dynamis Xarcabard
-- MOB: Marquis Orias
-----------------------------------
require("scripts/globals/dynamis");
require("scripts/zones/Dynamis-Xarcabard/TextIDs");
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
local Animate_Trigger = GetServerVariable("[DynaXarcabard]Boss_Trigger");
if (mob:isInBattlefieldList() == false) then
mob:addInBattlefieldList();
Animate_Trigger = Animate_Trigger + 16;
SetServerVariable("[DynaXarcabard]Boss_Trigger",Animate_Trigger);
if (Animate_Trigger == 32767) then
SpawnMob(17330911); -- 142
SpawnMob(17330912); -- 143
SpawnMob(17330177); -- Dynamis Lord
GetMobByID(17330183):setSpawn(-364,-35.661,17.254); -- Set Ying and Yang's spawn points to their initial spawn point.
GetMobByID(17330184):setSpawn(-364,-35.974,24.254);
SpawnMob(17330183);
SpawnMob(17330184);
activateAnimatedWeapon(); -- Change subanim of all animated weapon
end
end
if (Animate_Trigger == 32767) then
player:messageSpecial(PRISON_OF_SOULS_HAS_SET_FREE);
end
end; | gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/items/bowl_of_navarin.lua | 11 | 1731 | -----------------------------------------
-- ID: 4439
-- Item: Bowl of Navarin
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Health % 3 (cap 130)
-- Strength 3
-- Agility 1
-- Vitality 1
-- Intelligence -1
-- Attack % 27
-- Attack Cap 30
-- Evasion 5
-- Ranged ATT % 27
-- Ranged ATT Cap 30
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,10800,4439)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.FOOD_HPP, 3)
target:addMod(dsp.mod.FOOD_HP_CAP, 130)
target:addMod(dsp.mod.STR, 3)
target:addMod(dsp.mod.AGI, 1)
target:addMod(dsp.mod.VIT, 1)
target:addMod(dsp.mod.INT, -1)
target:addMod(dsp.mod.FOOD_ATTP, 27)
target:addMod(dsp.mod.FOOD_ATT_CAP, 30)
target:addMod(dsp.mod.EVA, 5)
target:addMod(dsp.mod.FOOD_RATTP, 27)
target:addMod(dsp.mod.FOOD_RATT_CAP, 30)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 3)
target:delMod(dsp.mod.FOOD_HP_CAP, 130)
target:delMod(dsp.mod.STR, 3)
target:delMod(dsp.mod.AGI, 1)
target:delMod(dsp.mod.VIT, 1)
target:delMod(dsp.mod.INT, -1)
target:delMod(dsp.mod.FOOD_ATTP, 27)
target:delMod(dsp.mod.FOOD_ATT_CAP, 30)
target:delMod(dsp.mod.EVA, 5)
target:delMod(dsp.mod.FOOD_RATTP, 27)
target:delMod(dsp.mod.FOOD_RATT_CAP, 30)
end
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/Windurst_Waters/npcs/Chomoro-Kyotoro.lua | 9 | 1200 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Chomoro-Kyotoro
-- Involved in Quest: Making the Grade
-- !pos 133 -5 167 238
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
-- needs check for dsp.ki.TATTERED_TEST_SHEET then sets to var 3
if (player:getQuestStatus(WINDURST,dsp.quest.id.windurst.MAKING_THE_GRADE) == QUEST_ACCEPTED) then
local prog = player:getCharVar("QuestMakingTheGrade_prog");
if (prog == 0) then
player:startEvent(454);
elseif (prog == 1) then
player:startEvent(457);
elseif (prog == 2) then
player:startEvent(460);
else
player:startEvent(461);
end
else
player:startEvent(432);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 460) then
player:setCharVar("QuestMakingTheGrade_prog",3);
player:delKeyItem(dsp.ki.TATTERED_TEST_SHEET);
end
end; | gpl-3.0 |
lichtl/darkstar | scripts/zones/Upper_Jeuno/npcs/Paya-Sabya.lua | 14 | 1345 | -----------------------------------
-- Area: Upper Jeuno
-- NPC: Paya-Sabya
-- Involved in Mission: Magicite
-- @zone 244
-- @pos 9 1 70
-----------------------------------
package.loaded["scripts/zones/Upper_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/zones/Upper_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(SILVER_BELL) and player:hasKeyItem(YAGUDO_TORCH) == false and player:getVar("YagudoTorchCS") == 0) then
player:startEvent(0x0050);
else
player:startEvent(0x004f);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0050) then
player:setVar("YagudoTorchCS",1);
end
end; | gpl-3.0 |
lichtl/darkstar | scripts/zones/LaLoff_Amphitheater/Zone.lua | 30 | 1744 | -----------------------------------
--
-- Zone: LaLoff_Amphitheater (180)
--
-----------------------------------
package.loaded["scripts/zones/LaLoff_Amphitheater/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/LaLoff_Amphitheater/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(189.849,-176.455,346.531,244);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
lichtl/darkstar | scripts/globals/weaponskills/tachi_jinpu.lua | 23 | 1422 | -----------------------------------
-- Tachi Jinpu
-- Great Katana weapon skill
-- Skill level: 150
-- Two-hit attack. Deals Physical and wind elemental damage to enemy. Additonal Effect Damage varies with TP.
-- Will stack with Sneak Attack and Souleater.
-- Aligned with the Breeze Gorget & Shadow Gorget.
-- Aligned with the Breeze Belt & Shadow Belt.
-- Element: Wind
-- Modifiers: STR:30%
-- 100%TP 200%TP 300%TP
-- .5 .75 1.00
-----------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {};
params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1;
params.str_wsc = 0.4; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.ele = ELE_WIND;
params.skill = SKILL_GKT;
params.includemab = true;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 0.5; params.ftp200 = 0.75; params.ftp300 = 1;
params.str_wsc = 0.3;
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, tp, primary, action, params);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
wsmithril/awesome | luadoc/awesome.lua | 2 | 2139 | --- awesome core API
-- @author Julien Danjou <julien@danjou.info>
-- @copyright 2008-2009 Julien Danjou
module("awesome")
--- awesome global table.
-- @field version The version of awesome.
-- @field release The release name of awesome.
-- @field conffile The configuration file which has been loaded.
-- @field startup True if we are still in startup, false otherwise.
-- @field startup_errors Error message for errors that occured during startup.
-- @field composite_manager_running True if a composite manager is running.
-- @class table
-- @name awesome
--- Quit awesome.
-- @name quit
-- @class function
--- Execute another application, probably a window manager, to replace
-- awesome.
-- @param cmd The command line to execute.
-- @name exec
-- @class function
--- Restart awesome.
-- @name restart
-- @class function
--- Spawn a program.
-- @param cmd The command to launch. Either a string or a table of strings.
-- @param use_sn Use startup-notification, true or false, default to true.
-- @return Process ID if everything is OK, or an error string if an error occured.
--- Load an image
-- @param name The file name
-- @return A cairo image surface as light user datum
-- @name load_image
-- @class function
--- Register a new xproperty.
-- @param name The name of the X11 property
-- @param type One of "string", "number" or "boolean"
-- @name register_xproperty
-- @class function
--- Change a xproperty.
-- @param name The name of the X11 property
-- @param value The new value for the property
-- @name set_xproperty
-- @class function
--- Get the value of a xproperty.
-- @param name The name of the X11 property
-- @name get_xproperty
-- @class function
--- Add a global signal.
-- @param name A string with the event name.
-- @param func The function to call.
-- @name connect_signal
-- @class function
--- Remove a global signal.
-- @param name A string with the event name.
-- @param func The function to call.
-- @name disconnect_signal
-- @class function
--- Emit a global signal.
-- @param name A string with the event name.
-- @param ... Signal arguments.
-- @name emit_signal
-- @class function
| gpl-2.0 |
scscgit/scsc_wildstar_addons | BGChron/libs/PixiePlot/PixiePlot.lua | 1 | 33878 | -----------------------------------------------------------------------------------------------------------------------
-- Plotter for WildStar. Supports line, stem, bar, scatter, polar, and parametric plots.
-- Copyright (c) NCsoft. All rights reserved
-- @author draftomatic
-----------------------------------------------------------------------------------------------------------------------
-- PixiePlot is converted to a constructor object, so call it directly to get a new plotter.
local PixiePlot = {}
-- A couple colors
local clrWhite = {
a = 1,
r = 1,
g = 1,
b = 1
}
local clrGrey = {
a = 1,
r = 0.6,
g = 0.6,
b = 0.6
}
local clrClear = {
a = 0,
r = 1,
g = 1,
b = 1
}
--- Constants
-- Plotting Styles
PixiePlot.LINE = 1
PixiePlot.STEM = 2
PixiePlot.SCATTER = 3
PixiePlot.PIE = 4
-- Coordinate Systems
PixiePlot.CARTESIAN = 1
PixiePlot.POLAR = 2
-- Bar graph orientations
PixiePlot.HORIZONTAL = 1
PixiePlot.VERTICAL = 2
-- Window Overlay event types
PixiePlot.MOUSE_DOWN = 1
PixiePlot.MOUSE_UP = 2
PixiePlot.MOUSE_ENTER = 3
PixiePlot.MOUSE_EXIT = 4
-- Coordinate System Conversion
local function cartToPol(x, y)
return math.sqrt(math.pow(x,2) + math.pow(y,2)), math.atan2(y,x)
end
local function polToCart(th, r)
return r*math.cos(th), r*math.sin(th)
end
--- Sets all plotting options (replaces current options).
-- @param tOpt Plotting options.
function PixiePlot:SetOptions(tOpt)
self.tOpt = tOpt
end
--- Sets a plotting option by name. For a full list of option names and values, see the main PixiePlot section.
-- @param strName The option name.
-- @param opt The option value.
-- @see PixiePlot
function PixiePlot:SetOption(strName, opt)
self.tOpt[strName] = opt
end
--- Sets the x-distance between dataSet values. Does not apply to scatter plots.
-- @param fInterval The x-distance between dataSet values.
function PixiePlot:SetXInterval(fInterval)
self.fXInterval = fInterval
end
--- Sets the minimum (bottom) X bound for the viewbox.
-- @param fXMin The minimum x-value to display in the viewbox.
function PixiePlot:SetXMin(fXMin)
self.fXMin = fXMin
end
--- Sets the minimum (bottom) X bound for the viewbox.
-- @param fXMax The maximum x-value to display in the viewbox.
function PixiePlot:SetXMax(fXMax)
self.fXMax = fXMax
end
--- Sets the minimum (bottom) Y bound for the viewbox.
-- @param fYMin The minimum y-value to display in the viewbox.
function PixiePlot:SetYMin(fYMin)
self.fYMin = fYMin
end
--- Sets the minimum (bottom) Y bound for the viewbox.
-- @param fYMax The maximum y-value to display in the viewbox.
function PixiePlot:SetYMax(fYMax)
self.fYMax = fYMax
end
--- Redraws graph using current dataSets and settings.
function PixiePlot:Redraw()
-- Reset Pixies
self.wnd:DestroyAllPixies()
if self.nDataSets > 0 then
-- Draw axes
if self.tOpt.bDrawXAxis then
self:DrawXAxis()
end
if self.tOpt.bDrawYAxis then
self:DrawYAxis()
end
-- Draw DataSets
local i = 1
for _,dataSet in pairs(self.dataSets) do
local color = self.tOpt.aPlotColors[i]
self:PlotDataSet(dataSet, color, i-1)
i = i + 1
end
-- Draw labels
if self.tOpt.bDrawXAxisLabel then
self:DrawXAxisLabel()
end
if self.tOpt.bDrawYAxisLabel then
self:DrawYAxisLabel()
end
if self.tOpt.bDrawXValueLabels then
self:DrawXValueLabels()
end
if self.tOpt.bDrawYValueLabels then
if self.tOpt.ePlotStyle == self.BAR and self.tOpt.eBarOrientation == self.HORIZONTAL then
self:DrawXValueLabels(self.fYMax - self.fYMin)
else
self:DrawYValueLabels()
end
end
-- Draw grid lines
if self.tOpt.bDrawXGridLines then
self:DrawXGridLines()
end
if self.tOpt.bDrawYGridLines then
self:DrawYGridLines()
end
end
end
--- Adds a dataset to plot on the next Redraw.
-- @param dataSet An array of data to plot. The general format is as follows:
-- dataSet = {xStart = xStart, values = {}}
-- xStart is the x-value of the first values element. This parameter allows you to shift the x position of the
-- graph (for pieceswise plotting, or for lining up dataSets of different length and start position). Generally
-- xStart will be the same for all dataSets.
--
-- If ePlotStyle equals BAR, LINE, or STEM, values is an array of numbers representing y-values, e.g.:
-- {-4, 5, 0, 3, 8}
-- If ePlotStyle == SCATTER, values is an array of tables with x- and y-values, e.g.:
-- {{x=0,y=0},{x=1,y=2}, ...}
function PixiePlot:AddDataSet(dataSet)
--Print("Adding " .. #dataSet.values .. " values")
self:UpdateMinMaxValues(dataSet)
--Print(self.fXMin .. " " ..self.fXMax .. " " ..self.fYMin .. " " .. self.fYMax)
self.dataSets[self.nDataSets + 1] = dataSet
self.nDataSets = self.nDataSets + 1
return self.nDataSets
end
--- Removes all dataSets
function PixiePlot:RemoveAllDataSets()
self.nDataSets = 0
self.nNumDataSets = 0
self.dataSets = {}
self.fXMin = nil
self.fXMax = nil
self.fYMin = nil
self.fYMax = nil
end
--- Removes a dataSet by id
-- @param nDataSetId The id of the dataSet that was returned from @see AddDataSet().
function PixiePlot:RemoveDataSet(nDataSetId)
self.dataSets[nDataSetId] = nil
end
--- Plots the given dataSet with current options.
-- @param dataSet An array of values. Uses self.xInterval for timestep.
-- @param color The color of the current dataSet.
-- @param nBarIndex The index of the current bar graph (used only for multiple bar plot dataSets)
function PixiePlot:PlotDataSet(dataSet, color, nBarIndex)
local maxWidth = self.wnd:GetWidth() - self.tOpt.fYLabelMargin - self.tOpt.fPlotMargin
local maxHeight = self.wnd:GetHeight() - self.tOpt.fXLabelMargin - self.tOpt.fPlotMargin
local clrSymbol = self.tOpt.clrSymbol
if clrSymbol == nil then
clrSymbol = color
end
local ePlotStyle = self.tOpt.ePlotStyle
-- Line Plot
if ePlotStyle == self.LINE or ePlotStyle == self.STEM then
local fXRange = self.fXMax - self.fXMin
local fYRange = self.fYMax - self.fYMin
if self.tOpt.eCoordinateSystem == self.CARTESIAN then
local xOffset = (dataSet.xStart - self.fXMin) / fXRange * maxWidth
--Print(xOffset)
local xIntervalWidth = maxWidth / (#dataSet.values - 1)
local vPrev
-- Line
for i, v in ipairs(dataSet.values) do
if v == math.huge then v = 0 end
if ePlotStyle == self.LINE then
if i > 1 then
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + xOffset + (i - 2) * xIntervalWidth,
y1 = self.tOpt.fXLabelMargin + (vPrev - self.fYMin) / fYRange * maxHeight,
x2 = self.tOpt.fYLabelMargin + xOffset + (i - 1) * xIntervalWidth,
y2 = self.tOpt.fXLabelMargin + (v - self.fYMin) / fYRange * maxHeight
},
"",
self.tOpt.fLineWidth,
self.tOpt.strLineSprite,
color
)
end
elseif ePlotStyle == self.STEM then
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + xOffset + (i - 1) * xIntervalWidth,
y1 = self.tOpt.fXLabelMargin + (0 - self.fYMin) / (self.fYMax - self.fYMin) * maxHeight,
x2 = self.tOpt.fYLabelMargin + xOffset + (i - 1) * xIntervalWidth,
y2 = self.tOpt.fXLabelMargin + (v - self.fYMin) / fYRange * maxHeight
},
"",
self.tOpt.fLineWidth,
self.tOpt.strLineSprite,
color
)
end
vPrev = v
end
-- Symbol
if self.tOpt.bDrawSymbol then
for i, v in ipairs(dataSet.values) do
if v == math.huge then v = 0 end
local fSymbolSize = self.tOpt.fSymbolSize
if fSymbolSize == nil then
fSymbolSize = self.tOpt.fLineWidth * 2
end
--Print(v .. "/" .. fYRange .. " out of " .. maxHeight)
local tPos = {
x = self.tOpt.fYLabelMargin + xOffset + (i - 1) * xIntervalWidth,
y = self.tOpt.fXLabelMargin + (v - self.fYMin) / fYRange * maxHeight
}
self:DrawSymbol(
tPos,
fSymbolSize,
self.tOpt.strSymbolSprite,
clrSymbol
)
-- Window Overlay
if self.tOpt.bWndOverlays then
local wnd = self:AddWindowOverlay(tPos, self.tOpt.fWndOverlaySize)
local tData = {
i = i,
x = (i - 1) * self.fXInterval + dataSet.xStart,
y = v
}
wnd:SetData(tData)
if self.tOpt.wndOverlayLoadCallback then
self.tOpt.wndOverlayLoadCallback(tData, wnd)
end
end
end
end
elseif self.tOpt.eCoordinateSystem == self.POLAR then
local vPrev
for i, v in ipairs(dataSet.values) do
if v == math.huge then v = 0 end
local vPol = v
local xActual = dataSet.xStart + (i - 2) * self.fXInterval
xActual, v = polToCart(xActual, v)
if ePlotStyle == self.LINE then
if i > 1 then
local xActualPrev = dataSet.xStart + (i - 3) * self.fXInterval
xActualPrev, vPrev = polToCart(xActualPrev, vPrev)
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + (xActualPrev - self.fXMin) / fXRange * maxWidth,
y1 = self.tOpt.fXLabelMargin + (vPrev - self.fYMin) / fYRange * maxHeight,
x2 = self.tOpt.fYLabelMargin + (xActual - self.fXMin) / fXRange * maxWidth,
y2 = self.tOpt.fXLabelMargin + (v - self.fYMin) / fYRange * maxHeight
},
"",
self.tOpt.fLineWidth,
self.tOpt.strLineSprite,
color
)
end
elseif ePlotStyle == self.STEM then
--local xActual = dataSet.xStart + (i - 2) * self.fXInterval
--xActual, v = polToCart(xActual, v)
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + (0 - self.fXMin) / (self.fXMax - self.fXMin) * maxWidth,
y1 = self.tOpt.fXLabelMargin + (0 - self.fYMin) / (self.fYMax - self.fYMin) * maxHeight,
x2 = self.tOpt.fYLabelMargin + (xActual - self.fXMin) / fXRange * maxWidth,
y2 = self.tOpt.fXLabelMargin + (v - self.fYMin) / fYRange * maxHeight
},
"",
self.tOpt.fLineWidth,
self.tOpt.strLineSprite,
color
)
end
vPrev = vPol
end
-- Symbol
if self.tOpt.bDrawSymbol then
for i, v in ipairs(dataSet.values) do
if v == math.huge then v = 0 end
local xActual = dataSet.xStart + (i - 2) * self.fXInterval
local xCart, vCart = polToCart(xActual, v)
local fSymbolSize = self.tOpt.fSymbolSize
if fSymbolSize == nil then
fSymbolSize = self.tOpt.fLineWidth * 2
end
--Print(vCart .. "/" .. fYRange .. " out of " .. maxHeight)
local tPos = {
x = self.tOpt.fYLabelMargin + (xCart - self.fXMin) / fXRange * maxWidth,
y = self.tOpt.fXLabelMargin + (vCart - self.fYMin) / fYRange * maxHeight
}
self:DrawSymbol(
tPos,
fSymbolSize,
self.tOpt.strSymbolSprite,
clrSymbol
)
-- Window Overlay
if self.tOpt.bWndOverlays then
local wnd = self:AddWindowOverlay(tPos, self.tOpt.fWndOverlaySize)
local tData = {
i = i,
x = (i - 1) * self.fXInterval + dataSet.xStart,
y = v
}
wnd:SetData(tData)
if self.tOpt.wndOverlayLoadCallback then
self.tOpt.wndOverlayLoadCallback(tData, wnd)
end
end
end
end
end
elseif ePlotStyle == self.SCATTER then
local fXRange = self.fXMax - self.fXMin
local fYRange = self.fYMax - self.fYMin
if self.tOpt.bScatterLine == true then
local vPrev
for i, v in ipairs(dataSet.values) do
if self.tOpt.eCoordinateSystem == self.POLAR then
v.x, v.y = polToCart(v.x, v.y)
end
if i > 1 then
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + (vPrev.x - self.fXMin) / fXRange * maxWidth,
y1 = self.tOpt.fXLabelMargin + (vPrev.y - self.fYMin) / fYRange * maxHeight,
x2 = self.tOpt.fYLabelMargin + (v.x - self.fXMin) / fXRange * maxWidth,
y2 = self.tOpt.fXLabelMargin + (v.y - self.fYMin) / fYRange * maxHeight
},
"",
self.tOpt.fLineWidth,
self.tOpt.strLineSprite,
color
)
end
vPrev = v
end
end
local fSymbolSize = self.tOpt.fSymbolSize
if fSymbolSize == nil then
fSymbolSize = self.tOpt.fLineWidth * 2
end
for i, v in pairs(dataSet.values) do
--local x = self.tOpt.fYLabelMargin + (v.x - self.fXMin) / fXRange * maxWidth
--local y = self.tOpt.fXLabelMargin + (v.y - self.fYMin) / fYRange * maxHeight
--Print("x: " .. v.x - self.fXMin .. "/" .. fXRange .. " out of " .. maxWidth)
--Print("y: " .. v.y - self.fYMin .. "/" .. fYRange .. " out of " .. maxHeight)
--Print("(" .. x .. ", " .. y .. ") in " .. "(" .. maxWidth .. ", " .. maxHeight .. ")")
local tPos = {
x = self.tOpt.fYLabelMargin + (v.x - self.fXMin) / fXRange * maxWidth,
y = self.tOpt.fXLabelMargin + (v.y - self.fYMin) / fYRange * maxHeight
}
self:DrawSymbol(
tPos,
fSymbolSize,
self.tOpt.strSymbolSprite,
clrSymbol
)
-- Window Overlay
if self.tOpt.bWndOverlays then
local wnd = self:AddWindowOverlay(tPos, self.tOpt.fWndOverlaySize)
local tData = {
i = i,
x = v.x,
y = v.y
}
wnd:SetData(tData)
if self.tOpt.wndOverlayLoadCallback then
self.tOpt.wndOverlayLoadCallback(tData, wnd)
end
end
end
elseif self.tOpt.ePlotStyle == self.BAR then
--Print("drawing " .. #dataSet.values .. " bars")
if self.tOpt.eBarOrientation == self.VERTICAL then
local fXIntervalWidth = (maxWidth - self.tOpt.fBarMargin - ((#dataSet.values-1) * self.tOpt.fBarSpacing)) / #dataSet.values
local fTotalBarWidth = fXIntervalWidth / self:GetTableSize(self.dataSets)
local fActualBarWidth = fTotalBarWidth - 2*self.tOpt.fBarMargin
for i,v in ipairs(dataSet.values) do
--Print(v .. "/" .. self.fYMax .. " out of " .. maxHeight)
local label
if dataSet.labels ~= nil then label = dataSet.labels[i] else label = "" end
self:DrawRectangle({
x1 = self.tOpt.fYLabelMargin + self.tOpt.fBarMargin + (i-1) * self.tOpt.fBarSpacing + (i-1) * fXIntervalWidth + fTotalBarWidth * nBarIndex,
y1 = 1 + self.tOpt.fXLabelMargin,
x2 = self.tOpt.fYLabelMargin + self.tOpt.fBarMargin + (i-1) * self.tOpt.fBarSpacing + (i-1) * fXIntervalWidth + fTotalBarWidth * nBarIndex + self.tOpt.fBarMargin + fActualBarWidth,
y2 = 1 + self.tOpt.fXLabelMargin + (v / self.fYMax) * maxHeight
},
self.tOpt.strBarSprite,
color,
self.tOpt.clrBarLabel,
label)
end
else
local fYIntervalHeight = (maxHeight - self.tOpt.fBarMargin - ((#dataSet.values-1) * self.tOpt.fBarSpacing)) / #dataSet.values
local fTotalBarHeight = fYIntervalHeight / self:GetTableSize(self.dataSets)
local fActualBarHeight = fTotalBarHeight - 2*self.tOpt.fBarMargin
for i,v in ipairs(dataSet.values) do
--Print(v .. "/" .. self.fYMax .. " out of " .. maxWidth)
local label
if dataSet.labels ~= nil then label = dataSet.labels[i] else label = "" end
self:DrawRectangle({
y1 = self.tOpt.fXLabelMargin + self.tOpt.fBarMargin + (i-1) * self.tOpt.fBarSpacing + (i-1) * fYIntervalHeight + fTotalBarHeight * nBarIndex,
x1 = 1 + self.tOpt.fYLabelMargin,
y2 = self.tOpt.fXLabelMargin + self.tOpt.fBarMargin + (i-1) * self.tOpt.fBarSpacing + (i-1) * fYIntervalHeight + fTotalBarHeight * nBarIndex + self.tOpt.fBarMargin + fActualBarHeight,
x2 = 1 + self.tOpt.fYLabelMargin + (v / self.fYMax) * maxWidth
},
self.tOpt.strBarSprite,
color,
self.tOpt.clrBarLabel,
label)
end
end
end
end
--- Draws X axis with current options.
function PixiePlot:DrawXAxis()
if self.tOpt.ePlotStyle == self.BAR then
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin,
y1 = self.tOpt.fXLabelMargin,
x2 = self.wnd:GetWidth() - self.tOpt.fPlotMargin,
y2 = self.tOpt.fXLabelMargin
},
"",
self.tOpt.fYAxisWidth,
nil,
self.tOpt.clrYAxis
)
else
if self.fYMin <= 0 and self.fYMax >= 0 then
local maxHeight = self.wnd:GetHeight() - self.tOpt.fXLabelMargin - self.tOpt.fPlotMargin
local yPos = (0 - self.fYMin) / (self.fYMax - self.fYMin) * maxHeight
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin,
y1 = self.tOpt.fXLabelMargin + yPos,
x2 = self.wnd:GetWidth() - self.tOpt.fPlotMargin,
y2 = self.tOpt.fXLabelMargin + yPos
},
"",
self.tOpt.fXAxisWidth,
nil,
self.tOpt.clrXAxis
)
end
end
end
--- Draws Y axis with current options.
function PixiePlot:DrawYAxis()
if self.tOpt.ePlotStyle == self.BAR then
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin,
y1 = self.tOpt.fXLabelMargin,
x2 = self.tOpt.fYLabelMargin,
y2 = self.wnd:GetHeight() - self.tOpt.fPlotMargin
},
"",
self.tOpt.fYAxisWidth,
nil,
self.tOpt.clrYAxis
)
else
if self.fXMin <= 0 and self.fXMax >= 0 then
local maxWidth = self.wnd:GetWidth() - self.tOpt.fYLabelMargin - self.tOpt.fPlotMargin
local xPos = (0 - self.fXMin) / (self.fXMax - self.fXMin) * maxWidth
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + xPos,
y1 = self.tOpt.fXLabelMargin,
x2 = self.tOpt.fYLabelMargin + xPos,
y2 = self.wnd:GetHeight() - self.tOpt.fPlotMargin
},
"",
self.tOpt.fYAxisWidth,
nil,
self.tOpt.clrYAxis
)
end
end
end
--- Draws X labels with current options.
function PixiePlot:DrawXAxisLabel()
self:DrawLine(
{
x1 = self.wnd:GetWidth() - self.tOpt.fPlotMargin - self.tOpt.fXAxisLabelOffset,
y1 = self.tOpt.fXLabelMargin / 2,
x2 = self.wnd:GetWidth() - self.tOpt.fPlotMargin,
y2 = self.tOpt.fXLabelMargin / 2,
},
self.tOpt.strXLabel,
10,
nil,
self.tOpt.clrXAxisLabel
)
end
--- Draws Y labels with current options.
function PixiePlot:DrawYAxisLabel()
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin / 3,
y1 = self.wnd:GetHeight() - self.tOpt.fPlotMargin - self.tOpt.fYAxisLabelOffset,
x2 = self.tOpt.fYLabelMargin / 3,
y2 = self.wnd:GetHeight() - self.tOpt.fPlotMargin,
},
self.tOpt.strYLabel,
10,
nil,
self.tOpt.clrYAxisLabel
)
end
--- Draws X value labels with current options.
function PixiePlot:DrawXValueLabels(fXRange)
local maxWidth = self.wnd:GetWidth() - self.tOpt.fYLabelMargin - self.tOpt.fPlotMargin
if fXRange == nil then
fXRange = self.fXMax - self.fXMin
end
local nLabels = self.tOpt.nXValueLabels
local fInterval = fXRange / nLabels
for i=0,nLabels do
local fPos = i * fInterval / fXRange * maxWidth
local fValue = self.fXMin + i * fInterval --* self.fXInterval
local strValue
if self.tOpt.xValueFormatter ~= nil then
strValue = self.tOpt.xValueFormatter(fValue)
else
strValue = string.format("%." .. self.tOpt.nXLabelDecimals .. "f", fValue)
if strValue == "-0.0" then strValue = "0.0" end
if strValue == "-0" then strValue = "0" end
end
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + fPos - self.tOpt.fXValueLabelTilt,
y1 = 0,
x2 = self.tOpt.fYLabelMargin + fPos,
y2 = self.tOpt.fXLabelMargin - 10
},
strValue,
20,
nil,
self.tOpt.clrXValueBackground,
self.tOpt.clrXValueLabel
)
end
end
--- Draws Y value labels with current options.
function PixiePlot:DrawYValueLabels(fYRange)
local maxHeight = self.wnd:GetHeight() - self.tOpt.fXLabelMargin - self.tOpt.fPlotMargin
if fYRange == nil then
fYRange = self.fYMax - self.fYMin
end
local nLabels = self.tOpt.nYValueLabels
local fInterval = fYRange / nLabels
for i=0,nLabels do
local fPos = i * fInterval / fYRange * maxHeight
local fValue = self.fYMin + i * fInterval
local strValue
if self.tOpt.yValueFormatter ~= nil then
strValue = self.tOpt.yValueFormatter(fValue)
else
strValue = string.format("%." .. self.tOpt.nYLabelDecimals .. "f", fValue)
if strValue == "-0.0" then strValue = "0.0" end
if strValue == "-0" then strValue = "0" end
end
self:DrawLine(
{
x1 = 0,
y1 = self.tOpt.fXLabelMargin + fPos - self.tOpt.fYValueLabelTilt,
x2 = self.tOpt.fYLabelMargin - 10,
y2 = self.tOpt.fXLabelMargin + fPos
},
strValue,
20,
nil,
self.tOpt.clrYValueBackground,
self.tOpt.clrYValueLabel
)
end
end
--- Draws X (vertical) grid lines with current options.
function PixiePlot:DrawXGridLines()
local nLabels = self.tOpt.nXValueLabels
local maxWidth = self.wnd:GetWidth() - self.tOpt.fYLabelMargin - self.tOpt.fPlotMargin
local maxHeight = self.wnd:GetHeight() - self.tOpt.fXLabelMargin - self.tOpt.fPlotMargin
if self.tOpt.eCoordinateSystem == self.CARTESIAN or self.tOpt.bPolarGridLines == false then
local fXRange = self.fXMax - self.fXMin
local fInterval = fXRange / nLabels
for i=0,nLabels do
local fPos = i * fInterval / fXRange * maxWidth
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin + fPos,
y1 = self.tOpt.fXLabelMargin,
x2 = self.tOpt.fYLabelMargin + fPos,
y2 = self.wnd:GetHeight() - self.tOpt.fPlotMargin
},
"",
self.tOpt.fXGridLineWidth,
nil,
self.tOpt.clrXGridLine
)
end
elseif self.tOpt.eCoordinateSystem == self.POLAR and self.tOpt.bPolarGridLines == true then
local x1 = (0 - self.fXMin) / (self.fXMax - self.fXMin) * maxWidth + self.tOpt.fYLabelMargin
local y1 = (0 - self.fYMin) / (self.fYMax - self.fYMin) * maxHeight + self.tOpt.fXLabelMargin
local fInterval = 2*math.pi / nLabels
for i=0,nLabels-1 do
local angle = fInterval * i
local x2, y2 = polToCart(angle, 99999) -- Hack
self:DrawLine(
{
x1 = x1,
y1 = y1,
x2 = x2,
y2 = y2
},
"",
self.tOpt.fXGridLineWidth,
nil,
self.tOpt.clrXGridLine
)
end
end
end
--- Draws Y (horizontal) grid lines with current options.
function PixiePlot:DrawYGridLines()
local maxHeight = self.wnd:GetHeight() - self.tOpt.fXLabelMargin - self.tOpt.fPlotMargin
local fYRange = self.fYMax - self.fYMin
local nLabels = self.tOpt.nYValueLabels
local fInterval = fYRange / nLabels
for i=0,nLabels do
local fPos = i * fInterval / fYRange * maxHeight
self:DrawLine(
{
x1 = self.tOpt.fYLabelMargin,
y1 = self.tOpt.fXLabelMargin + fPos,
x2 = self.wnd:GetWidth() - self.tOpt.fPlotMargin,
y2 = self.tOpt.fXLabelMargin + fPos
},
"",
self.tOpt.fYGridLineWidth,
nil,
self.tOpt.clrYGridLine
)
end
end
--- Adds a line to the canvas.
-- Flips y-axis.
-- @param line A table containing x1,y1,x2,y2 coordinates for the line.
-- @param width Width of the line.
-- @param sprite Sprite to use.
-- @param color A table with keys a, r, g, b. Values should be numbers 0.0-1.0.
function PixiePlot:DrawLine(line, text, width, sprite, color, clrText)
--Print("Drawing line starting at: " .. line.x1 .. ", " .. line.y1)
local nPixieId = self.wnd:AddPixie({
strText = text,
strFont = self.tOpt.strLabelFont,
bLine = true,
fWidth = width,
strSprite = sprite,
cr = color,
crText = clrText,
loc = {
fPoints = {0,0,0,0},
nOffsets = {
line.x1,
self.wnd:GetHeight() - line.y1,
line.x2,
self.wnd:GetHeight() - line.y2
}
},
flagsText = {
DT_RIGHT = true--,
--DT_VCENTER = true
}
})
end
--- Adds a symbol to the canvas.
-- Flips y-axis.
-- @param pos A table containing x1,y1,x2,y2 coordinates for the symbol.
-- @param size Width and height of the symbol.
-- @param sprite Sprite to use.
-- @param color A table with keys a, r, g, b. Values should be numbers 0.0-1.0
function PixiePlot:DrawSymbol(pos, size, sprite, color)
--Print("Drawing symbol at: " .. pos.x .. ", " .. pos.y)
--Print("Pixie color: " ..
local nPixieId = self.wnd:AddPixie({
strText = "",
bLine = false,
--fWidth = width,
strSprite = sprite,
cr = color,
loc = {
fPoints = {0,0,0,0},
nOffsets = {
pos.x - size/2,
self.wnd:GetHeight() - (pos.y + size/2),
pos.x + size/2,
self.wnd:GetHeight() - (pos.y - size/2)
}
}
})
--Print("Symbol pixieid: " .. tostring(nPixieId))
end
--- Adds a data point tooltip.
-- Flips y-axis.
-- @param pos A table containing x1,y1,x2,y2 coordinates for the tooltip.
-- @param size Width and height of the tooltip.
function PixiePlot:AddWindowOverlay(pos, size)
local XmlDocument = Apollo.GetPackage("Drafto:Lib:XmlDocument-1.0").tPackage
if not XmlDocument then return end
local tDoc = XmlDocument.NewForm()
local tForm = tDoc:NewFormNode("PixiePlotOverlay", {
TooltipType = "OnCursor",
AnchorPoints = {0,0,0,0},
AnchorOffsets = {
pos.x - size/2,
self.wnd:GetHeight() - (pos.y + size/2),
pos.x + size/2,
self.wnd:GetHeight() - (pos.y - size/2)
}
})
tDoc:GetRoot():AddChild(tForm)
local wnd = tDoc:LoadForm("PixiePlotOverlay", self.wnd, self)
if not wnd then
return
end
wnd:AddEventHandler("MouseButtonUp", "OnWndMouseUp", self)
wnd:AddEventHandler("MouseButtonDown", "OnWndMouseDown", self)
wnd:AddEventHandler("MouseEnter", "OnWndMouseEnter", self)
wnd:AddEventHandler("MouseExit", "OnWndMouseExit", self)
wnd:Show(true)
return wnd
end
--- Adds a rectangle to the canvas.
-- Flips y-axis.
-- @param pos A table containing x1,y1,x2,y2 coordinates for the rectangle.
-- @param sprite Sprite to use.
-- @param color A table with keys a, r, g, b. Values should be numbers 0.0-1.0
function PixiePlot:DrawRectangle(rect, sprite, color, clrText, text)
--Print("Drawing rect: " .. rect.x1 .. ", " .. rect.y1 .." -> " .. rect.x2 .. ", " .. rect.y2)
-- Draw rectangle
local nPixieId = self.wnd:AddPixie({
bLine = false,
strSprite = sprite,
cr = color,
loc = {
fPoints = {0,0,0,0},
nOffsets = {
rect.x1,
self.wnd:GetHeight() - rect.y2,
rect.x2,
self.wnd:GetHeight() - rect.y1
}
},
flagsText = {
DT_VCENTER = true
},
fRotation = 0
})
-- Draw text as a separate pixie so it doesn't get cut off by short bars
if text ~= nil then
local x1, x2, y1, y2, lineWidth, DT_VCENTER
if self.tOpt.eBarOrientation == self.VERTICAL then
local width = rect.x2 - rect.x1
lineWidth = 1
x1 = rect.x1 + width / 2 - 10
x2 = x1
y2 = rect.y1 + 3
y1 = self.wnd:GetHeight() - self.tOpt.fPlotMargin
DT_VCENTER = true
else
local height = rect.y2 - rect.y1
lineWidth = 1
y1 = rect.y1 + height / 2 + 10
y2 = y1
x1 = rect.x1 + 3
x2 = self.wnd:GetWidth() - self.tOpt.fPlotMargin
DT_VCENTER = false
end
local nPixieId = self.wnd:AddPixie({
strText = text,
strFont = self.tOpt.strBarFont,
bLine = true,
fWidth = lineWidth,
strSprite = "WhiteFill",
cr = clrClear,
crText = clrText,
loc = {
fPoints = {0,0,0,0},
nOffsets = {
x1,
self.wnd:GetHeight() - y2,
x2,
self.wnd:GetHeight() - y1
}
},
flagsText = {
DT_VCENTER = false
},
fRotation = 0
})
end
end
--- Updates max/min viewbox values using the given dataSet.
-- @param dataSet The dataSet to update max/min values with.
function PixiePlot:UpdateMinMaxValues(dataSet)
if self.tOpt.ePlotStyle == self.LINE or self.tOpt.ePlotStyle == self.STEM then
for i,v in ipairs(dataSet.values) do
if v == math.huge then v = 0 end
local x = dataSet.xStart + (i - 1) * self.fXInterval
if self.tOpt.eCoordinateSystem == self.POLAR then
x = dataSet.xStart + (i - 2) * self.fXInterval
x, v = polToCart(x, v)
end
if self.fXMin == nil or x < self.fXMin then self.fXMin = x end
if self.fXMax == nil or x > self.fXMax then self.fXMax = x end
if self.fYMin == nil or v < self.fYMin then self.fYMin = v end
if self.fYMax == nil or v > self.fYMax then self.fYMax = v end
end
elseif self.tOpt.ePlotStyle == self.SCATTER then
for i,v in pairs(dataSet.values) do
if v == math.huge then v = 0 end
if self.fXMin == nil or v.x < self.fXMin then self.fXMin = v.x end
if self.fXMax == nil or v.x > self.fXMax then self.fXMax = v.x end
if self.fYMin == nil or v.y < self.fYMin then self.fYMin = v.y end
if self.fYMax == nil or v.y > self.fYMax then self.fYMax = v.y end
end
elseif self.tOpt.ePlotStyle == self.BAR then
self.fXMin = 0
self.fXMax = 1
self.fYMin = 0
self.nNumDataSets = self.nNumDataSets + 1
for i,v in ipairs(dataSet.values) do
if self.fYMax == nil or v > self.fYMax then self.fYMax = v end
end
end
end
--- Internal event handler for data point events
function PixiePlot:OnWndMouseDown(wndHandler, wndControl)
if wndHandler ~= wndControl then return end
local tData = wndHandler:GetData()
if tData and self.tOpt.wndOverlayMouseEventCallback then
self.tOpt.wndOverlayMouseEventCallback(tData, PixiePlot.MOUSE_DOWN)
end
end
--- Internal event handler for data point events
function PixiePlot:OnWndMouseUp(wndHandler, wndControl)
if wndHandler ~= wndControl then return end
local tData = wndHandler:GetData()
if tData and self.tOpt.wndOverlayMouseEventCallback then
self.tOpt.wndOverlayMouseEventCallback(tData, PixiePlot.MOUSE_UP)
end
end
--- Internal event handler for data point events
function PixiePlot:OnWndMouseEnter(wndHandler, wndControl)
if wndHandler ~= wndControl then return end
local tData = wndHandler:GetData()
if tData and self.tOpt.wndOverlayMouseEventCallback then
self.tOpt.wndOverlayMouseEventCallback(tData, PixiePlot.MOUSE_ENTER)
end
end
--- Internal event handler for data point events
function PixiePlot:OnWndMouseExit(wndHandler, wndControl)
if wndHandler ~= wndControl then return end
local tData = wndHandler:GetData()
if tData and self.tOpt.wndOverlayMouseEventCallback then
self.tOpt.wndOverlayMouseEventCallback(tData, PixiePlot.MOUSE_EXIT)
end
end
--- Generates a dataSet from the given function(s). If func2 is given, the dataSet will be for a scatter plot.
-- @param fXStart The starting x-value.
-- @param fXEnd The ending x-value.
-- @param fXInterval The x-interval to use.
-- @param func The function to use for generating y-values, or x-values in a scatter plot if func2 is given.
-- @param func (optional) The function to use for generating y-values in a scatter plot.
function PixiePlot:GenerateDataSet(fXStart, fXEnd, fXInterval, func, func2)
local dataSet = {
xStart = fXStart,
values = {}
}
for x=fXStart,fXEnd,fXInterval do
if func2 then
table.insert(dataSet.values, {
x = func(x),
y = func2(x)
})
else
table.insert(dataSet.values, func(x))
end
end
return dataSet
end
--- Utility for getting number of keys in a table
function PixiePlot:GetTableSize(tbl)
local count = 0
for _ in pairs(tbl) do count = count + 1 end
return count
end
-- "Constructor"
-- @deprecated Use PixiePlot:New(wndContainer, tOpt)
-- @param wndContainer The container for the graph. All of its content may be used so don't put anything in it; just a background.
setmetatable(PixiePlot, {
__call = function(self, wndContainer, tOpt)
local pp = {
wnd = wndContainer
}
-- Plotting variables
pp.dataSets = {} -- This is not an array, though it does use integer keys.
pp.nNumDataSets = 0 -- Current number of dataSets (only used for bar graphs)
pp.nDataSets = 0 -- Counter for dataSet id's
pp.fXInterval = 1 -- x-distance between dataSet values
pp.fXMin = nil -- Left plot viewbox bound
pp.fXMax = nil -- Right plot viewbox bound
pp.fYMin = nil -- Top plot viewbox bound
pp.fYMax = nil -- Bottom plot viewbox bound
-- Plotting Options
if tOpt then
pp.tOpt = tOpt
else
pp.tOpt = tDefaultOptions
end
return setmetatable(pp, {__index = PixiePlot})
end
})
-- Default options
local tDefaultOptions = {
ePlotStyle = PixiePlot.LINE,
eCoordinateSystem = PixiePlot.CARTESIAN,
fYLabelMargin = 25,
fXLabelMargin = 25,
fPlotMargin = 10,
strXLabel = "",
strYLabel = "",
bDrawXAxisLabel = false,
bDrawYAxisLabel = false,
nXValueLabels = 8,
nYValueLabels = 8,
bDrawXValueLabels = false,
bDrawYValueLabels = false,
bPolarGridLines = false,
bDrawXGridLines = false,
bDrawYGridLines = false,
fXGridLineWidth = 1,
fYGridLineWidth = 1,
clrXGridLine = clrGrey,
clrYGridLine = clrGrey,
clrXAxisLabel = clrClear,
clrYAxisLabel = clrClear,
clrXValueLabel = clrWhite,
clrYValueLabel = clrWhite,
clrXValueBackground = clrClear,
clrYValueBackground = clrClear,
fXAxisLabelOffset = 170,
fYAxisLabelOffset = 120,
strLabelFont = "CRB_Interface9",
fXValueLabelTilt = 20,
fYValueLabelTilt = 0,
nXLabelDecimals = 1,
nYLabelDecimals = 1,
xValueFormatter = nil,
yValueFormatter = nil,
bDrawXAxis = true,
bDrawYAxis = true,
clrXAxis = clrWhite,
clrYAxis = clrWhite,
fXAxisWidth = 2,
fYAxisWidth = 2,
bDrawSymbol = true,
fSymbolSize = nil,
strSymbolSprite = "WhiteCircle",
clrSymbol = nil,
strLineSprite = nil,
fLineWidth = 3,
bScatterLine = false,
fBarMargin = 5, -- Space between bars in each group
fBarSpacing = 20, -- Space between groups of bars
fBarOrientation = PixiePlot.VERTICAL,
strBarSprite = "WhiteFill",
strBarFont = "CRB_Interface11",
clrBarLabel = clrWhite,
bWndOverlays = false,
fWndOverlaySize = 6,
wndOverlayMouseEventCallback = nil,
wndOverlayLoadCallback = nil,
aPlotColors = {
{a=1,r=0.858,g=0.368,b=0.53},
{a=1,r=0.363,g=0.858,b=0.500},
{a=1,r=0.858,g=0.678,b=0.368},
{a=1,r=0.368,g=0.796,b=0.858},
{a=1,r=0.58,g=0.29,b=0.89},
{a=1,r=0.27,g=0.78,b=0.20}
}
}
--- Better Constructor
-- @param wndContainer the Window in which to draw the plot
-- @param tOpt The options table to use. It must be completely filled out! If nil, default options are used (recommended).
function PixiePlot:New(wndContainer, tOpt)
-- Make a new PixiePlot object
local this = {
wnd = wndContainer
}
-- Set plotting variables
this.dataSets = {} -- This is not an array, though it does use integer keys.
this.nNumDataSets = 0 -- Current number of dataSets (only used for bar graphs)
this.nDataSets = 0 -- Counter for dataSet id's
this.fXInterval = 1 -- x-distance between dataSet values
this.fXMin = nil -- Left plot viewbox bound
this.fXMax = nil -- Right plot viewbox bound
this.fYMin = nil -- Top plot viewbox bound
this.fYMax = nil -- Bottom plot viewbox bound
-- Set plotting options
if tOpt then
this.tOpt = tOpt
else
this.tOpt = tDefaultOptions
end
-- Inheritance
setmetatable(this, self)
self.__index = self
return this
end
-- Register Library
Apollo.RegisterPackage(PixiePlot, "Drafto:Lib:PixiePlot-1.4", 4, {"Drafto:Lib:XmlDocument-1.0"})
| mit |
Benjarobbi/UzzBott | plugins/moderation.lua | 2 | 6182 | do
local function modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
return 'Group is already added.'
end
-- create data array in moderation.json
data[tostring(msg.to.id)] = {
moderators ={},
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'no',
lock_member = 'no'
}
}
save_data(_config.moderation.data, data)
return 'Group has been added.'
end
local function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return 'Group has been removed'
end
local function promote(msg, member)
local data = load_data(_config.moderation.data)
local data_cat = 'moderators'
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
-- created automatically on !modadd
--if not data[tostring(msg.to.id)][data_cat] then
-- data[tostring(msg.to.id)][data_cat] = {}
-- save_data(_config.moderation.data, data)
--end
if data[tostring(msg.to.id)][data_cat][tostring(member)] then
return member..' is already a moderator.'
end
data[tostring(msg.to.id)][data_cat][tostring(member)] = member -- harusnya user.id atau data lain
save_data(_config.moderation.data, data)
return '@'..member..' has been promoted.'
end
local function demote(msg, member)
local data = load_data(_config.moderation.data)
local data_cat = 'moderators'
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
if not data[tostring(msg.to.id)][data_cat][tostring(member)] then
return member..' is not a moderator.'
end
data[tostring(msg.to.id)][data_cat][tostring(member)] = nil
save_data(_config.moderation.data, data)
return '@'..member..' has been demoted.'
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
local data_cat = 'moderators'
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)][data_cat]) == nil then --fix way
return 'No moderator in this group.'
end
local message = 'List of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)][data_cat]) do
message = message .. '- ' .. v .. ' \n'
end
return message
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id -- admin_id kedua harusnya nama
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Bot admins:\n'
for k,v in pairs(data[tostring(admins)]) do
--message = message .. '- ' .. k .. v .. ' \n'
message = message .. '- ' .. v .. ' \n'
end
return message
end
function run(msg, matches)
if msg.to.type == 'user' then
return "Only works on group"
end
if matches[1] == 'modadd' then
print("group "..msg.to.print_name.."("..msg.to.id..") added")
--vardump(msg)
return modadd(msg)
end
if matches[1] == 'modrem' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'promote' and matches[2] then
local member = string.gsub(matches[2], "@", "")
print("User "..member.." has been promoted")
return promote(msg, member)
end
if matches[1] == 'demote' and matches[2] then
local member = string.gsub(matches[2], "@", "")
print("user "..member.." has been demoted")
return demote(msg, member)
end
if matches[1] == 'modlist' then
return modlist(msg)
end
if matches[1] == 'adminprom' then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
end
if matches[1] == 'admindem' then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted from admin")
return admin_demote(msg, admin_id)
end
if matches[1] == 'adminlist' then
return admin_list(msg)
end
end
return {
description = "Moderation plugin",
usage = {
"!modadd : Add group to moderation list",
"!modrem : Remove group from moderation list",
"!promote <@username> : Promote user as moderator",
"!demote <@username> : demote user from moderator",
"!modlist : List of moderators",
},
patterns = {
"^!(modadd)$",
"^!(modrem)$",
"^!(promote) (.*)$",
"^!(demote) (.*)$",
"^!(modlist)$",
"^!(adminprom) (%d+)$", -- sudoers only
"^!(admindem) (%d+)$", -- sudoers only
"^!(adminlist)$",
},
run = run,
moderated = true
}
end | gpl-2.0 |
lichtl/darkstar | scripts/zones/Nashmau/npcs/Kyokyoroon.lua | 14 | 1755 | -----------------------------------
-- Area: Nashmau
-- NPC: Kyokyoroon
-- Standard Info NPC
-- @pos 18.020 -6.000 10.467 53
-----------------------------------
package.loaded["scripts/zones/Nashmau/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/zones/Nashmau/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(AHT_URHGAN,RAT_RACE) == QUEST_ACCEPTED and player:getVar("ratraceCS") == 5) then
if (trade:hasItemQty(5595,1) and trade:getItemCount() == 1) then
player:startEvent(0x0137);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local ratRaceProg = player:getVar("ratraceCS");
if (ratRaceProg == 5) then
player:startEvent(0x0107);
elseif (ratRaceProg == 6) then
player:startEvent(0x0013c);
elseif (player:getQuestStatus(AHT_URHGAN,RAT_RACE) == QUEST_COMPLETED) then
player:startEvent(0x013d);
else
player:startEvent(0x0107);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0137) then
player:tradeComplete();
player:setVar("ratraceCS",6);
end
end;
| gpl-3.0 |
Benjarobbi/UzzBott | plugins/get.lua | 613 | 1067 | local function get_variables_hash(msg)
if msg.to.type == 'chat' then
return 'chat:'..msg.to.id..':variables'
end
if msg.to.type == 'user' then
return 'user:'..msg.from.id..':variables'
end
end
local function list_variables(msg)
local hash = get_variables_hash(msg)
if hash then
local names = redis:hkeys(hash)
local text = ''
for i=1, #names do
text = text..names[i]..'\n'
end
return text
end
end
local function get_value(msg, var_name)
local hash = get_variables_hash(msg)
if hash then
local value = redis:hget(hash, var_name)
if not value then
return'Not found, use "!get" to list variables'
else
return var_name..' => '..value
end
end
end
local function run(msg, matches)
if matches[2] then
return get_value(msg, matches[2])
else
return list_variables(msg)
end
end
return {
description = "Retrieves variables saved with !set",
usage = "!get (value_name): Returns the value_name value.",
patterns = {
"^(!get) (.+)$",
"^!get$"
},
run = run
}
| gpl-2.0 |
RunAwayDSP/darkstar | scripts/zones/Horlais_Peak/bcnms/rank_2_mission.lua | 9 | 1630 | -----------------------------------
-- Rank 2 Final Mission
-- Horlais Peak mission battlefield
-----------------------------------
require("scripts/globals/battlefield")
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
-----------------------------------
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player, battlefield)
end
function onBattlefieldEnter(player, battlefield)
end
function onBattlefieldLeave(player, battlefield, leavecode)
if leavecode == dsp.battlefield.leaveCode.WON then
local name, clearTime, partySize = battlefield:getRecord()
local arg8 = player:hasCompletedMission(player:getNation(), 5) and 1 or 0
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 1, battlefield:getLocalVar("[cs]bit"), arg8)
elseif leavecode == dsp.battlefield.leaveCode.LOST then
player:startEvent(32002)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if csid == 32001 then
if
(
player:getCurrentMission(WINDURST) == dsp.mission.id.windurst.THE_THREE_KINGDOMS_SANDORIA2 or
player:getCurrentMission(BASTOK) == dsp.mission.id.bastok.THE_EMISSARY_SANDORIA2
) and
player:getCharVar("MissionStatus") == 9
then
npcUtil.giveKeyItem(player, dsp.ki.KINDRED_CREST)
player:setCharVar("MissionStatus", 10)
end
end
end
| gpl-3.0 |
lichtl/darkstar | scripts/globals/items/serving_of_bavarois.lua | 18 | 1192 | -----------------------------------------
-- ID: 5729
-- Item: serving_of_bavarois
-- Food Effect: 3Hrs, All Races
-----------------------------------------
-- HP 20
-- Intelligence 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5729);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 20);
target:addMod(MOD_INT, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 20);
target:delMod(MOD_INT, 3);
end;
| gpl-3.0 |
taiha/luci | modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/backupfiles.lua | 75 | 2451 | -- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
if luci.http.formvalue("cbid.luci.1._list") then
luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=list")
elseif luci.http.formvalue("cbid.luci.1._edit") then
luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=edit")
return
end
m = SimpleForm("luci", translate("Backup file list"))
m:append(Template("admin_system/backupfiles"))
if luci.http.formvalue("display") ~= "list" then
f = m:section(SimpleSection, nil, translate("This is a list of shell glob patterns for matching files and directories to include during sysupgrade. Modified files in /etc/config/ and certain other configurations are automatically preserved."))
l = f:option(Button, "_list", translate("Show current backup file list"))
l.inputtitle = translate("Open list...")
l.inputstyle = "apply"
c = f:option(TextValue, "_custom")
c.rmempty = false
c.cols = 70
c.rows = 30
c.cfgvalue = function(self, section)
return nixio.fs.readfile("/etc/sysupgrade.conf")
end
c.write = function(self, section, value)
value = value:gsub("\r\n?", "\n")
return nixio.fs.writefile("/etc/sysupgrade.conf", value)
end
else
m.submit = false
m.reset = false
f = m:section(SimpleSection, nil, translate("Below is the determined list of files to backup. It consists of changed configuration files marked by opkg, essential base files and the user defined backup patterns."))
l = f:option(Button, "_edit", translate("Back to configuration"))
l.inputtitle = translate("Close list...")
l.inputstyle = "link"
d = f:option(DummyValue, "_detected")
d.rawhtml = true
d.cfgvalue = function(s)
local list = io.popen(
"( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
"/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
"opkg list-changed-conffiles ) | sort -u"
)
if list then
local files = { "<ul>" }
while true do
local ln = list:read("*l")
if not ln then
break
else
files[#files+1] = "<li>"
files[#files+1] = luci.util.pcdata(ln)
files[#files+1] = "</li>"
end
end
list:close()
files[#files+1] = "</ul>"
return table.concat(files, "")
end
return "<em>" .. translate("No files found") .. "</em>"
end
end
return m
| apache-2.0 |
RunAwayDSP/darkstar | scripts/zones/Windurst_Woods/npcs/Ibwam.lua | 9 | 4123 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Ibwam
-- Type: Warp NPC
-- !pos -25.655 1.749 -60.651 241
-----------------------------------
local ID = require("scripts/zones/Windurst_Woods/IDs")
require("scripts/globals/teleports")
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
require("scripts/globals/settings")
require("scripts/globals/quests")
-----------------------------------
--[[
Bitmask Designations:
Windurst Woods (Working in a circuit from Ibwam)
00001 (H-10) Soni-Muni (Bomingo Round, walking the rim of the fountain)
00002 (J-13) Etsa Rhuyuli (atop the Auction House)
00004 (I-10) Cayu Pensharhumi (at the arch in the corridor west of Leviathan's Gate)
00008 (I-5) Umumu (Mithra Groves, at the arch next to the dhalmels.)
00010 (J-3) Nanaa Mihgo (Mithra Groves. North-most cluster)
Windurst Walls (Counter-clockwise)
00020 (J-11) Yoriri (on top of the Auction House)
00040 (K-7) Shantotto (in Shantotto's Manor)
00080 (J-6) Moan-Maon (just west of the Consulate of Jeuno, at the pathway that leads to it)
00100 (H-3) Chomomo (on the East side behind the House of the Hero, go on the path leading North from Gerun-Garun)
00200 (F-5) Naih Arihmepp (wanders along the path by Yoran-Oran's Manor)
Windurst Waters (All NPCs are in North Waters) (North to South)
00400 (G-4) Npopo (right by the gate to Sarutabaruta)
00800 (F-8) Lago-Charago (on top of the Optistery)
01000 (G-9) Amagusa-Chigurusa (South-east part of Huntsman's Court area, top left corner of G-9)
02000 (F-9) Funpo-Shipo (walks along the path outside Timbre Timbers Tavern, on the north side)
04000 (F-10) Kyume-Romeh (bottom floor of Timbre Timber Tavern)
Port Windurst (West to East)
08000 (E-7) Kunchichi (a magic-caster inside the Orastery)
10000 (E-7) Yaman-Hachuman (inside the Orastery, east wall)
20000 (F-6) Choyi Totlihpa (southeast of Consulate of Bastok, entrance of the pathway tunnel)
40000 (G-7) Three of Clubs (standing guard leading to the dock/pier with the Magic/Weapon-Armor shops)
80000 (M-6) Yujuju (outside the Air Travel Agency)
]]--
function onTrade(player,npc,trade)
if npcUtil.tradeHas(trade, {{"gil", 300}}) and player:getQuestStatus(WINDURST,dsp.quest.id.windurst.LURE_OF_THE_WILDCAT) == QUEST_COMPLETED and player:getCurrentMission(TOAU) > dsp.mission.id.toau.IMMORTAL_SENTRIES then
-- Needs a check for at least traded an invitation card to Naja Salaheem
player:startEvent(794)
end
end
function onTrigger(player,npc)
local lureWindurst = player:getQuestStatus(WINDURST,dsp.quest.id.windurst.LURE_OF_THE_WILDCAT)
local wildcatWindurst = player:getCharVar("WildcatWindurst")
if lureWindurst ~= QUEST_COMPLETED and ENABLE_TOAU == 1 then
if lureWindurst == QUEST_AVAILABLE then
player:startEvent(736)
else
if wildcatWindurst == 0 then
player:startEvent(737)
elseif player:isMaskFull(wildcatWindurst,20) then
player:startEvent(739)
else
player:startEvent(738)
end
end
elseif player:getCurrentMission(TOAU) >= dsp.mission.id.toau.PRESIDENT_SALAHEEM then
player:startEvent(793)
else
player:startEvent(740)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 736 then
player:addQuest(WINDURST,dsp.quest.id.windurst.LURE_OF_THE_WILDCAT)
player:setCharVar("WildcatWindurst", 0)
npcUtil.giveKeyItem(player, dsp.ki.GREEN_SENTINEL_BADGE)
elseif csid == 739 and npcUtil.completeQuest(player, WINDURST, dsp.quest.id.windurst.LURE_OF_THE_WILDCAT, {fame=150, keyItem=dsp.ki.GREEN_INVITATION_CARD, var="WildcatWindurst"}) then
player:delKeyItem(dsp.ki.GREEN_SENTINEL_BADGE)
player:messageSpecial(ID.text.KEYITEM_LOST,dsp.ki.GREEN_SENTINEL_BADGE)
elseif csid == 794 then
player:confirmTrade()
dsp.teleport.to(player, dsp.teleport.id.WHITEGATE)
end
end | gpl-3.0 |
lichtl/darkstar | scripts/zones/Northern_San_dOria/npcs/Esqualea.lua | 17 | 1452 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Esqualea
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Northern_San_dOria/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
local FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
local count = trade:getItemCount();
local MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x029e);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Abyssea-Uleguerand/npcs/qm17.lua | 14 | 1404 | -----------------------------------
-- Zone: Abyssea-Uleguerand
-- NPC: qm17 (???)
-- Spawns Isgebind
-- @pos ? ? ? 253
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/status");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
--[[
if (GetMobAction(17813920) == ACTION_NONE) then -- NM not already spawned from this
if (player:hasKeyItem(BEGRIMED_DRAGON_HIDE)) then
player:startEvent(1020, BEGRIMED_DRAGON_HIDE); -- Ask if player wants to use KIs
else
player:startEvent(1025, BEGRIMED_DRAGON_HIDE); -- Do not ask, because player is missing at least 1.
end
end
]]
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID2: %u",csid);
-- printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 1020 and option == 1) then
SpawnMob(17813920):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe)
player:delKeyItem(BEGRIMED_DRAGON_HIDE);
end
end;
| gpl-3.0 |
lichtl/darkstar | scripts/globals/weaponskills/rudras_storm.lua | 22 | 1737 | -----------------------------------
-- Rudra's Storm
-- Dagger weapon skill
-- Skill level: N/A
-- Deals triple damage and weighs target down (duration: 60s). Damage varies with TP.
-- Aligned with the Aqua Gorget, Snow Gorget & Shadow Gorget.
-- Aligned with the Aqua Belt, Snow Belt & Shadow Belt.
-- Element: None
-- Modifiers: DEX:80%
-- 100%TP 200%TP 300%TP
-- 6 15 19.5
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {};
params.numHits = 1;
params.ftp100 = 3.25; params.ftp200 = 4.25; params.ftp300 = 5.25;
params.str_wsc = 0.0; params.dex_wsc = 0.6; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 5; params.ftp200 = 10.19; params.ftp300 = 13;
params.dex_wsc = 0.8;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, tp, primary, action, taChar, params);
-- EFFECT_WEIGHT power value is equal to lead breath as per bg-wiki: http://www.bg-wiki.com/bg/Rudra%27s_Storm
if (damage > 0 and target:hasStatusEffect(EFFECT_WEIGHT) == false) then
target:addStatusEffect(EFFECT_WEIGHT, 50, 0, 60);
end
return tpHits, extraHits, criticalHit, damage;
end | gpl-3.0 |
lichtl/darkstar | scripts/globals/mobskills/Final_Retribution.lua | 31 | 1048 | ---------------------------------------------
-- Final Retribution
-- Family: Corse
-- Description: Damages enemies in an area of effect. Additional effect: Stun
-- Type: Physical
-- Utsusemi/Blink absorb: 1-3 shadows
-- Range: Radial
-- Notes: Only used by some notorious monsters like Xolotl.
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local numhits = 1;
local accmod = 1;
local dmgmod = 3.2;
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,MOBPARAM_3_SHADOW);
local typeEffect = EFFECT_STUN;
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, 1, 0, 4);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
OctoEnigma/shiny-octo-system | gamemodes/terrortown/gamemode/init.lua | 1 | 29345 | ---- Trouble in Terrorist Town
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_hud.lua")
AddCSLuaFile("cl_msgstack.lua")
AddCSLuaFile("cl_hudpickup.lua")
AddCSLuaFile("cl_keys.lua")
AddCSLuaFile("cl_wepswitch.lua")
AddCSLuaFile("cl_awards.lua")
AddCSLuaFile("cl_scoring_events.lua")
AddCSLuaFile("cl_scoring.lua")
AddCSLuaFile("cl_popups.lua")
AddCSLuaFile("cl_equip.lua")
AddCSLuaFile("equip_items_shd.lua")
AddCSLuaFile("cl_help.lua")
AddCSLuaFile("cl_scoreboard.lua")
AddCSLuaFile("cl_tips.lua")
AddCSLuaFile("cl_voice.lua")
AddCSLuaFile("scoring_shd.lua")
AddCSLuaFile("util.lua")
AddCSLuaFile("lang_shd.lua")
AddCSLuaFile("corpse_shd.lua")
AddCSLuaFile("player_ext_shd.lua")
AddCSLuaFile("weaponry_shd.lua")
AddCSLuaFile("cl_radio.lua")
AddCSLuaFile("cl_radar.lua")
AddCSLuaFile("cl_tbuttons.lua")
AddCSLuaFile("cl_disguise.lua")
AddCSLuaFile("cl_transfer.lua")
AddCSLuaFile("cl_search.lua")
AddCSLuaFile("cl_targetid.lua")
AddCSLuaFile("vgui/ColoredBox.lua")
AddCSLuaFile("vgui/SimpleIcon.lua")
AddCSLuaFile("vgui/ProgressBar.lua")
AddCSLuaFile("vgui/ScrollLabel.lua")
AddCSLuaFile("vgui/sb_main.lua")
AddCSLuaFile("vgui/sb_row.lua")
AddCSLuaFile("vgui/sb_team.lua")
AddCSLuaFile("vgui/sb_info.lua")
include("shared.lua")
include("karma.lua")
include("entity.lua")
include("scoring_shd.lua")
include("radar.lua")
include("admin.lua")
include("traitor_state.lua")
include("propspec.lua")
include("weaponry.lua")
include("gamemsg.lua")
include("ent_replace.lua")
include("scoring.lua")
include("corpse.lua")
include("player_ext_shd.lua")
include("player_ext.lua")
include("player.lua")
CreateConVar("ttt_roundtime_minutes", "10", FCVAR_NOTIFY)
CreateConVar("ttt_preptime_seconds", "30", FCVAR_NOTIFY)
CreateConVar("ttt_posttime_seconds", "30", FCVAR_NOTIFY)
CreateConVar("ttt_firstpreptime", "60")
local ttt_haste = CreateConVar("ttt_haste", "1", FCVAR_NOTIFY)
CreateConVar("ttt_haste_starting_minutes", "5", FCVAR_NOTIFY)
CreateConVar("ttt_haste_minutes_per_death", "0.5", FCVAR_NOTIFY)
CreateConVar("ttt_spawn_wave_interval", "0")
CreateConVar("ttt_traitor_pct", "0.25")
CreateConVar("ttt_traitor_max", "32")
CreateConVar("ttt_detective_pct", "0.13", FCVAR_NOTIFY)
CreateConVar("ttt_detective_max", "32")
CreateConVar("ttt_detective_min_players", "8")
CreateConVar("ttt_detective_karma_min", "600")
-- Traitor credits
CreateConVar("ttt_credits_starting", "2")
CreateConVar("ttt_credits_award_pct", "0.35")
CreateConVar("ttt_credits_award_size", "1")
CreateConVar("ttt_credits_award_repeat", "1")
CreateConVar("ttt_credits_detectivekill", "1")
CreateConVar("ttt_credits_alonebonus", "1")
-- Detective credits
CreateConVar("ttt_det_credits_starting", "1")
CreateConVar("ttt_det_credits_traitorkill", "0")
CreateConVar("ttt_det_credits_traitordead", "1")
CreateConVar("ttt_use_weapon_spawn_scripts", "1")
CreateConVar("ttt_weapon_spawn_count", "0")
CreateConVar("ttt_round_limit", "6", FCVAR_ARCHIVE + FCVAR_NOTIFY + FCVAR_REPLICATED)
CreateConVar("ttt_time_limit_minutes", "75", FCVAR_NOTIFY + FCVAR_REPLICATED)
CreateConVar("ttt_idle_limit", "180", FCVAR_NOTIFY)
CreateConVar("ttt_voice_drain", "0", FCVAR_NOTIFY)
CreateConVar("ttt_voice_drain_normal", "0.2", FCVAR_NOTIFY)
CreateConVar("ttt_voice_drain_admin", "0.05", FCVAR_NOTIFY)
CreateConVar("ttt_voice_drain_recharge", "0.05", FCVAR_NOTIFY)
CreateConVar("ttt_namechange_kick", "1", FCVAR_NOTIFY)
CreateConVar("ttt_namechange_bantime", "10")
local ttt_detective = CreateConVar("ttt_sherlock_mode", "1", FCVAR_ARCHIVE + FCVAR_NOTIFY)
local ttt_minply = CreateConVar("ttt_minimum_players", "2", FCVAR_ARCHIVE + FCVAR_NOTIFY)
-- debuggery
local ttt_dbgwin = CreateConVar("ttt_debug_preventwin", "0")
-- Localise stuff we use often. It's like Lua go-faster stripes.
local math = math
local table = table
local net = net
local player = player
local timer = timer
local util = util
-- Pool some network names.
util.AddNetworkString("TTT_RoundState")
util.AddNetworkString("TTT_RagdollSearch")
util.AddNetworkString("TTT_GameMsg")
util.AddNetworkString("TTT_GameMsgColor")
util.AddNetworkString("TTT_RoleChat")
util.AddNetworkString("TTT_TraitorVoiceState")
util.AddNetworkString("TTT_LastWordsMsg")
util.AddNetworkString("TTT_RadioMsg")
util.AddNetworkString("TTT_ReportStream")
util.AddNetworkString("TTT_LangMsg")
util.AddNetworkString("TTT_ServerLang")
util.AddNetworkString("TTT_Equipment")
util.AddNetworkString("TTT_Credits")
util.AddNetworkString("TTT_Bought")
util.AddNetworkString("TTT_BoughtItem")
util.AddNetworkString("TTT_InterruptChat")
util.AddNetworkString("TTT_PlayerSpawned")
util.AddNetworkString("TTT_PlayerDied")
util.AddNetworkString("TTT_CorpseCall")
util.AddNetworkString("TTT_ClearClientState")
util.AddNetworkString("TTT_PerformGesture")
util.AddNetworkString("TTT_Role")
util.AddNetworkString("TTT_RoleList")
util.AddNetworkString("TTT_ConfirmUseTButton")
util.AddNetworkString("TTT_C4Config")
util.AddNetworkString("TTT_C4DisarmResult")
util.AddNetworkString("TTT_C4Warn")
util.AddNetworkString("TTT_ShowPrints")
util.AddNetworkString("TTT_ScanResult")
util.AddNetworkString("TTT_FlareScorch")
util.AddNetworkString("TTT_Radar")
---- Round mechanics
function GM:Initialize()
MsgN("Trouble In Terrorist Town gamemode initializing...")
ShowVersion()
-- Force friendly fire to be enabled. If it is off, we do not get lag compensation.
RunConsoleCommand("mp_friendlyfire", "1")
-- Default crowbar unlocking settings, may be overridden by config entity
GAMEMODE.crowbar_unlocks = {
[OPEN_DOOR] = true,
[OPEN_ROT] = true,
[OPEN_BUT] = true,
[OPEN_NOTOGGLE]= true
};
-- More map config ent defaults
GAMEMODE.force_plymodel = ""
GAMEMODE.propspec_allow_named = true
GAMEMODE.MapWin = WIN_NONE
GAMEMODE.AwardedCredits = false
GAMEMODE.AwardedCreditsDead = 0
GAMEMODE.round_state = ROUND_WAIT
GAMEMODE.FirstRound = true
GAMEMODE.RoundStartTime = 0
GAMEMODE.DamageLog = {}
GAMEMODE.LastRole = {}
GAMEMODE.playermodel = GetRandomPlayerModel()
GAMEMODE.playercolor = COLOR_WHITE
-- Delay reading of cvars until config has definitely loaded
GAMEMODE.cvar_init = false
SetGlobalFloat("ttt_round_end", -1)
SetGlobalFloat("ttt_haste_end", -1)
-- For the paranoid
math.randomseed(os.time())
WaitForPlayers()
if cvars.Number("sv_alltalk", 0) > 0 then
ErrorNoHalt("TTT WARNING: sv_alltalk is enabled. Dead players will be able to talk to living players. TTT will now attempt to set sv_alltalk 0.\n")
RunConsoleCommand("sv_alltalk", "0")
end
local cstrike = false
for _, g in pairs(engine.GetGames()) do
if g.folder == 'cstrike' then cstrike = true end
end
if not cstrike then
ErrorNoHalt("TTT WARNING: CS:S does not appear to be mounted by GMod. Things may break in strange ways. Server admin? Check the TTT readme for help.\n")
end
end
-- Used to do this in Initialize, but server cfg has not always run yet by that
-- point.
function GM:InitCvars()
MsgN("TTT initializing convar settings...")
-- Initialize game state that is synced with client
SetGlobalInt("ttt_rounds_left", GetConVar("ttt_round_limit"):GetInt())
GAMEMODE:SyncGlobals()
KARMA.InitState()
self.cvar_init = true
end
function GM:InitPostEntity()
WEPS.ForcePrecache()
end
function GM:GetGameDescription() return self.Name end
-- Convar replication is broken in gmod, so we do this.
-- I don't like it any more than you do, dear reader.
function GM:SyncGlobals()
SetGlobalBool("ttt_detective", ttt_detective:GetBool())
SetGlobalBool("ttt_haste", ttt_haste:GetBool())
SetGlobalInt("ttt_time_limit_minutes", GetConVar("ttt_time_limit_minutes"):GetInt())
SetGlobalBool("ttt_highlight_admins", GetConVar("ttt_highlight_admins"):GetBool())
SetGlobalBool("ttt_locational_voice", GetConVar("ttt_locational_voice"):GetBool())
SetGlobalInt("ttt_idle_limit", GetConVar("ttt_idle_limit"):GetInt())
SetGlobalBool("ttt_voice_drain", GetConVar("ttt_voice_drain"):GetBool())
SetGlobalFloat("ttt_voice_drain_normal", GetConVar("ttt_voice_drain_normal"):GetFloat())
SetGlobalFloat("ttt_voice_drain_admin", GetConVar("ttt_voice_drain_admin"):GetFloat())
SetGlobalFloat("ttt_voice_drain_recharge", GetConVar("ttt_voice_drain_recharge"):GetFloat())
end
function SendRoundState(state, ply)
net.Start("TTT_RoundState")
net.WriteUInt(state, 3)
return ply and net.Send(ply) or net.Broadcast()
end
-- Round state is encapsulated by set/get so that it can easily be changed to
-- eg. a networked var if this proves more convenient
function SetRoundState(state)
GAMEMODE.round_state = state
SCORE:RoundStateChange(state)
SendRoundState(state)
end
function GetRoundState()
return GAMEMODE.round_state
end
local function EnoughPlayers()
local ready = 0
-- only count truly available players, ie. no forced specs
for _, ply in pairs(player.GetAll()) do
if IsValid(ply) and ply:ShouldSpawn() then
ready = ready + 1
end
end
return ready >= ttt_minply:GetInt()
end
-- Used to be in Think/Tick, now in a timer
function WaitingForPlayersChecker()
if GetRoundState() == ROUND_WAIT then
if EnoughPlayers() then
timer.Create("wait2prep", 1, 1, PrepareRound)
timer.Stop("waitingforply")
end
end
end
-- Start waiting for players
function WaitForPlayers()
SetRoundState(ROUND_WAIT)
if not timer.Start("waitingforply") then
timer.Create("waitingforply", 2, 0, WaitingForPlayersChecker)
end
end
-- When a player initially spawns after mapload, everything is a bit strange;
-- just making him spectator for some reason does not work right. Therefore,
-- we regularly check for these broken spectators while we wait for players
-- and immediately fix them.
function FixSpectators()
for k, ply in pairs(player.GetAll()) do
if ply:IsSpec() and not ply:GetRagdollSpec() and ply:GetMoveType() < MOVETYPE_NOCLIP then
ply:Spectate(OBS_MODE_ROAMING)
end
end
end
-- Used to be in think, now a timer
local function WinChecker()
if GetRoundState() == ROUND_ACTIVE then
if CurTime() > GetGlobalFloat("ttt_round_end", 0) then
EndRound(WIN_TIMELIMIT)
else
local win = hook.Call("TTTCheckForWin", GAMEMODE)
if win != WIN_NONE then
EndRound(win)
end
end
end
end
local function NameChangeKick()
if not GetConVar("ttt_namechange_kick"):GetBool() then
timer.Remove("namecheck")
return
end
if GetRoundState() == ROUND_ACTIVE then
for _, ply in pairs(player.GetHumans()) do
if ply.spawn_nick then
if ply.has_spawned and ply.spawn_nick != ply:Nick() then
local t = GetConVar("ttt_namechange_bantime"):GetInt()
local msg = "Changed name during a round"
if t > 0 then
ply:KickBan(t, msg)
else
ply:Kick(msg)
end
end
else
ply.spawn_nick = ply:Nick()
end
end
end
end
function StartNameChangeChecks()
if not GetConVar("ttt_namechange_kick"):GetBool() then return end
-- bring nicks up to date, may have been changed during prep/post
for _, ply in pairs(player.GetAll()) do
ply.spawn_nick = ply:Nick()
end
if not timer.Exists("namecheck") then
timer.Create("namecheck", 3, 0, NameChangeKick)
end
end
function StartWinChecks()
if not timer.Start("winchecker") then
timer.Create("winchecker", 1, 0, WinChecker)
end
end
function StopWinChecks()
timer.Stop("winchecker")
end
local function CleanUp()
local et = ents.TTT
-- if we are going to import entities, it's no use replacing HL2DM ones as
-- soon as they spawn, because they'll be removed anyway
et.SetReplaceChecking(not et.CanImportEntities(game.GetMap()))
et.FixParentedPreCleanup()
game.CleanUpMap()
et.FixParentedPostCleanup()
-- Strip players now, so that their weapons are not seen by ReplaceEntities
for k,v in pairs(player.GetAll()) do
if IsValid(v) then
v:StripWeapons()
end
end
-- a different kind of cleanup
util.SafeRemoveHook("PlayerSay", "ULXMeCheck")
end
local function SpawnEntities()
local et = ents.TTT
-- Spawn weapons from script if there is one
local import = et.CanImportEntities(game.GetMap())
if import then
et.ProcessImportScript(game.GetMap())
else
-- Replace HL2DM/ZM ammo/weps with our own
et.ReplaceEntities()
-- Populate CS:S/TF2 maps with extra guns
et.PlaceExtraWeapons()
end
-- Finally, get players in there
SpawnWillingPlayers()
end
local function StopRoundTimers()
-- remove all timers
timer.Stop("wait2prep")
timer.Stop("prep2begin")
timer.Stop("end2begin")
timer.Stop("winchecker")
end
-- Make sure we have the players to do a round, people can leave during our
-- preparations so we'll call this numerous times
local function CheckForAbort()
if not EnoughPlayers() then
LANG.Msg("round_minplayers")
StopRoundTimers()
WaitForPlayers()
return true
end
return false
end
function GM:TTTDelayRoundStartForVote()
-- Can be used for custom voting systems
--return true, 30
return false
end
function PrepareRound()
-- Check playercount
if CheckForAbort() then return end
local delay_round, delay_length = hook.Call("TTTDelayRoundStartForVote", GAMEMODE)
if delay_round then
delay_length = delay_length or 30
LANG.Msg("round_voting", {num = delay_length})
timer.Create("delayedprep", delay_length, 1, PrepareRound)
return
end
-- Cleanup
CleanUp()
GAMEMODE.MapWin = WIN_NONE
GAMEMODE.AwardedCredits = false
GAMEMODE.AwardedCreditsDead = 0
SCORE:Reset()
-- Update damage scaling
KARMA.RoundBegin()
-- New look. Random if no forced model set.
GAMEMODE.playermodel = GAMEMODE.force_plymodel == "" and GetRandomPlayerModel() or GAMEMODE.force_plymodel
GAMEMODE.playercolor = hook.Call("TTTPlayerColor", GAMEMODE, GAMEMODE.playermodel)
if CheckForAbort() then return end
-- Schedule round start
local ptime = GetConVar("ttt_preptime_seconds"):GetInt()
if GAMEMODE.FirstRound then
ptime = GetConVar("ttt_firstpreptime"):GetInt()
GAMEMODE.FirstRound = false
end
-- Piggyback on "round end" time global var to show end of phase timer
SetRoundEnd(CurTime() + ptime)
timer.Create("prep2begin", ptime, 1, BeginRound)
-- Mute for a second around traitor selection, to counter a dumb exploit
-- related to traitor's mics cutting off for a second when they're selected.
timer.Create("selectmute", ptime - 1, 1, function() MuteForRestart(true) end)
LANG.Msg("round_begintime", {num = ptime})
SetRoundState(ROUND_PREP)
-- Delay spawning until next frame to avoid ent overload
timer.Simple(0.01, SpawnEntities)
-- Undo the roundrestart mute, though they will once again be muted for the
-- selectmute timer.
timer.Create("restartmute", 1, 1, function() MuteForRestart(false) end)
net.Start("TTT_ClearClientState") net.Broadcast()
-- In case client's cleanup fails, make client set all players to innocent role
timer.Simple(1, SendRoleReset)
-- Tell hooks and map we started prep
hook.Call("TTTPrepareRound")
ents.TTT.TriggerRoundStateOutputs(ROUND_PREP)
end
function SetRoundEnd(endtime)
SetGlobalFloat("ttt_round_end", endtime)
end
function IncRoundEnd(incr)
SetRoundEnd(GetGlobalFloat("ttt_round_end", 0) + incr)
end
function TellTraitorsAboutTraitors()
local traitornicks = {}
for k,v in pairs(player.GetAll()) do
if v:IsTraitor() then
table.insert(traitornicks, v:Nick())
end
end
-- This is ugly as hell, but it's kinda nice to filter out the names of the
-- traitors themselves in the messages to them
for k,v in pairs(player.GetAll()) do
if v:IsTraitor() then
if #traitornicks < 2 then
LANG.Msg(v, "round_traitors_one")
return
else
local names = ""
for i,name in pairs(traitornicks) do
if name != v:Nick() then
names = names .. name .. ", "
end
end
names = string.sub(names, 1, -3)
LANG.Msg(v, "round_traitors_more", {names = names})
end
end
end
end
function SpawnWillingPlayers(dead_only)
local plys = player.GetAll()
local wave_delay = GetConVar("ttt_spawn_wave_interval"):GetFloat()
-- simple method, should make this a case of the other method once that has
-- been tested.
if wave_delay <= 0 or dead_only then
for k, ply in pairs(player.GetAll()) do
if IsValid(ply) then
ply:SpawnForRound(dead_only)
end
end
else
-- wave method
local num_spawns = #GetSpawnEnts()
local to_spawn = {}
for _, ply in RandomPairs(plys) do
if IsValid(ply) and ply:ShouldSpawn() then
table.insert(to_spawn, ply)
GAMEMODE:PlayerSpawnAsSpectator(ply)
end
end
local sfn = function()
local c = 0
-- fill the available spawnpoints with players that need
-- spawning
while c < num_spawns and #to_spawn > 0 do
for k, ply in pairs(to_spawn) do
if IsValid(ply) and ply:SpawnForRound() then
-- a spawn ent is now occupied
c = c + 1
end
-- Few possible cases:
-- 1) player has now been spawned
-- 2) player should remain spectator after all
-- 3) player has disconnected
-- In all cases we don't need to spawn them again.
table.remove(to_spawn, k)
-- all spawn ents are occupied, so the rest will have
-- to wait for next wave
if c >= num_spawns then
break
end
end
end
MsgN("Spawned " .. c .. " players in spawn wave.")
if #to_spawn == 0 then
timer.Remove("spawnwave")
MsgN("Spawn waves ending, all players spawned.")
end
end
MsgN("Spawn waves starting.")
timer.Create("spawnwave", wave_delay, 0, sfn)
-- already run one wave, which may stop the timer if everyone is spawned
-- in one go
sfn()
end
end
local function InitRoundEndTime()
-- Init round values
local endtime = CurTime() + (GetConVar("ttt_roundtime_minutes"):GetInt() * 60)
if HasteMode() then
endtime = CurTime() + (GetConVar("ttt_haste_starting_minutes"):GetInt() * 60)
-- this is a "fake" time shown to innocents, showing the end time if no
-- one would have been killed, it has no gameplay effect
SetGlobalFloat("ttt_haste_end", endtime)
end
SetRoundEnd(endtime)
end
function BeginRound()
GAMEMODE:SyncGlobals()
if CheckForAbort() then return end
AnnounceVersion()
InitRoundEndTime()
if CheckForAbort() then return end
-- Respawn dumb people who died during prep
SpawnWillingPlayers(true)
-- Remove their ragdolls
ents.TTT.RemoveRagdolls(true)
if CheckForAbort() then return end
-- Select traitors & co. This is where things really start so we can't abort
-- anymore.
SelectRoles()
LANG.Msg("round_selected")
SendFullStateUpdate()
-- Edge case where a player joins just as the round starts and is picked as
-- traitor, but for whatever reason does not get the traitor state msg. So
-- re-send after a second just to make sure everyone is getting it.
timer.Simple(1, SendFullStateUpdate)
timer.Simple(10, SendFullStateUpdate)
SCORE:HandleSelection() -- log traitors and detectives
-- Give the StateUpdate messages ample time to arrive
timer.Simple(1.5, TellTraitorsAboutTraitors)
timer.Simple(2.5, ShowRoundStartPopup)
-- Start the win condition check timer
StartWinChecks()
StartNameChangeChecks()
timer.Create("selectmute", 1, 1, function() MuteForRestart(false) end)
GAMEMODE.DamageLog = {}
GAMEMODE.RoundStartTime = CurTime()
-- Sound start alarm
SetRoundState(ROUND_ACTIVE)
LANG.Msg("round_started")
ServerLog("Round proper has begun...\n")
GAMEMODE:UpdatePlayerLoadouts() -- needs to happen when round_active
hook.Call("TTTBeginRound")
ents.TTT.TriggerRoundStateOutputs(ROUND_BEGIN)
end
function PrintResultMessage(type)
ServerLog("Round ended.\n")
if type == WIN_TIMELIMIT then
LANG.Msg("win_time")
ServerLog("Result: timelimit reached, traitors lose.\n")
elseif type == WIN_TRAITOR then
LANG.Msg("win_traitor")
ServerLog("Result: traitors win.\n")
elseif type == WIN_INNOCENT then
LANG.Msg("win_innocent")
ServerLog("Result: innocent win.\n")
else
ServerLog("Result: unknown victory condition!\n")
end
end
function CheckForMapSwitch()
-- Check for mapswitch
local rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6) - 1)
SetGlobalInt("ttt_rounds_left", rounds_left)
local time_left = math.max(0, (GetConVar("ttt_time_limit_minutes"):GetInt() * 60) - CurTime())
local switchmap = false
local nextmap = string.upper(game.GetMapNext())
if rounds_left <= 0 then
LANG.Msg("limit_round", {mapname = nextmap})
switchmap = true
elseif time_left <= 0 then
LANG.Msg("limit_time", {mapname = nextmap})
switchmap = true
end
if switchmap then
timer.Stop("end2prep")
timer.Simple(15, game.LoadNextMap)
else
LANG.Msg("limit_left", {num = rounds_left,
time = math.ceil(time_left / 60),
mapname = nextmap})
end
end
function EndRound(type)
PrintResultMessage(type)
-- first handle round end
SetRoundState(ROUND_POST)
local ptime = math.max(5, GetConVar("ttt_posttime_seconds"):GetInt())
LANG.Msg("win_showreport", {num = ptime})
timer.Create("end2prep", ptime, 1, PrepareRound)
-- Piggyback on "round end" time global var to show end of phase timer
SetRoundEnd(CurTime() + ptime)
timer.Create("restartmute", ptime - 1, 1, function() MuteForRestart(true) end)
-- Stop checking for wins
StopWinChecks()
-- We may need to start a timer for a mapswitch, or start a vote
CheckForMapSwitch()
KARMA.RoundEnd()
-- now handle potentially error prone scoring stuff
-- register an end of round event
SCORE:RoundComplete(type)
-- update player scores
SCORE:ApplyEventLogScores(type)
-- send the clients the round log, players will be shown the report
SCORE:StreamToClients()
-- server plugins might want to start a map vote here or something
-- these hooks are not used by TTT internally
hook.Call("TTTEndRound", GAMEMODE, type)
ents.TTT.TriggerRoundStateOutputs(ROUND_POST, type)
end
function GM:MapTriggeredEnd(wintype)
self.MapWin = wintype
end
-- The most basic win check is whether both sides have one dude alive
function GM:TTTCheckForWin()
if ttt_dbgwin:GetBool() then return WIN_NONE end
if GAMEMODE.MapWin == WIN_TRAITOR or GAMEMODE.MapWin == WIN_INNOCENT then
local mw = GAMEMODE.MapWin
GAMEMODE.MapWin = WIN_NONE
return mw
end
local traitor_alive = false
local innocent_alive = false
for k,v in pairs(player.GetAll()) do
if v:Alive() and v:IsTerror() then
if v:GetTraitor() then
traitor_alive = true
else
innocent_alive = true
end
end
if traitor_alive and innocent_alive then
return WIN_NONE --early out
end
end
if traitor_alive and not innocent_alive then
return WIN_TRAITOR
elseif not traitor_alive and innocent_alive then
return WIN_INNOCENT
elseif not innocent_alive then
-- ultimately if no one is alive, traitors win
return WIN_TRAITOR
end
return WIN_NONE
end
local function GetTraitorCount(ply_count)
-- get number of traitors: pct of players rounded down
local traitor_count = math.floor(ply_count * GetConVar("ttt_traitor_pct"):GetFloat())
-- make sure there is at least 1 traitor
traitor_count = math.Clamp(traitor_count, 1, GetConVar("ttt_traitor_max"):GetInt())
return traitor_count
end
local function GetDetectiveCount(ply_count)
if ply_count < GetConVar("ttt_detective_min_players"):GetInt() then return 0 end
local det_count = math.floor(ply_count * GetConVar("ttt_detective_pct"):GetFloat())
-- limit to a max
det_count = math.Clamp(det_count, 1, GetConVar("ttt_detective_max"):GetInt())
return det_count
end
function SelectRoles()
local choices = {}
local prev_roles = {
[ROLE_INNOCENT] = {},
[ROLE_TRAITOR] = {},
[ROLE_DETECTIVE] = {}
};
if not GAMEMODE.LastRole then GAMEMODE.LastRole = {} end
for k,v in pairs(player.GetAll()) do
-- everyone on the spec team is in specmode
if IsValid(v) and (not v:IsSpec()) then
-- save previous role and sign up as possible traitor/detective
local r = GAMEMODE.LastRole[v:SteamID()] or v:GetRole() or ROLE_INNOCENT
table.insert(prev_roles[r], v)
table.insert(choices, v)
end
v:SetRole(ROLE_INNOCENT)
end
-- determine how many of each role we want
local choice_count = #choices
local traitor_count = GetTraitorCount(choice_count)
local det_count = GetDetectiveCount(choice_count)
if choice_count == 0 then return end
-- first select traitors
local ts = 0
while ts < traitor_count do
-- select random index in choices table
local pick = math.random(1, #choices)
-- the player we consider
local pply = choices[pick]
-- make this guy traitor if he was not a traitor last time, or if he makes
-- a roll
if IsValid(pply) and
((not table.HasValue(prev_roles[ROLE_TRAITOR], pply)) or (math.random(1, 3) == 2)) then
pply:SetRole(ROLE_TRAITOR)
table.remove(choices, pick)
ts = ts + 1
end
end
-- now select detectives, explicitly choosing from players who did not get
-- traitor, so becoming detective does not mean you lost a chance to be
-- traitor
local ds = 0
local min_karma = GetConVarNumber("ttt_detective_karma_min") or 0
while (ds < det_count) and (#choices >= 1) do
-- sometimes we need all remaining choices to be detective to fill the
-- roles up, this happens more often with a lot of detective-deniers
if #choices <= (det_count - ds) then
for k, pply in pairs(choices) do
if IsValid(pply) then
pply:SetRole(ROLE_DETECTIVE)
end
end
break -- out of while
end
local pick = math.random(1, #choices)
local pply = choices[pick]
-- we are less likely to be a detective unless we were innocent last round
if (IsValid(pply) and
((pply:GetBaseKarma() > min_karma and
table.HasValue(prev_roles[ROLE_INNOCENT], pply)) or
math.random(1,3) == 2)) then
-- if a player has specified he does not want to be detective, we skip
-- him here (he might still get it if we don't have enough
-- alternatives)
if not pply:GetAvoidDetective() then
pply:SetRole(ROLE_DETECTIVE)
ds = ds + 1
end
table.remove(choices, pick)
end
end
GAMEMODE.LastRole = {}
for _, ply in pairs(player.GetAll()) do
-- initialize credit count for everyone based on their role
ply:SetDefaultCredits()
-- store a steamid -> role map
GAMEMODE.LastRole[ply:SteamID()] = ply:GetRole()
end
end
local function ForceRoundRestart(ply, command, args)
-- ply is nil on dedicated server console
if (not IsValid(ply)) or ply:IsAdmin() or ply:IsSuperAdmin() or cvars.Bool("sv_cheats", 0) then
LANG.Msg("round_restart")
StopRoundTimers()
-- do prep
PrepareRound()
else
ply:PrintMessage(HUD_PRINTCONSOLE, "You must be a GMod Admin or SuperAdmin on the server to use this command, or sv_cheats must be enabled.")
end
end
concommand.Add("ttt_roundrestart", ForceRoundRestart)
-- Version announce also used in Initialize
function ShowVersion(ply)
local text = Format("This is TTT version %s\n", GAMEMODE.Version)
if IsValid(ply) then
ply:PrintMessage(HUD_PRINTNOTIFY, text)
else
Msg(text)
end
end
concommand.Add("ttt_version", ShowVersion)
function AnnounceVersion()
local text = Format("You are playing %s, version %s.\n", GAMEMODE.Name, GAMEMODE.Version)
-- announce to players
for k, ply in pairs(player.GetAll()) do
if IsValid(ply) then
ply:PrintMessage(HUD_PRINTTALK, text)
end
end
end
| mit |
NiLuJe/koreader | frontend/ui/elements/menu_activate.lua | 4 | 1859 | local InfoMessage = require("ui/widget/infomessage")
local UIManager = require("ui/uimanager")
local _ = require("gettext")
return {
text = _("Activate menu"),
sub_item_table = {
{
text = _("With a tap"),
checked_func = function()
return G_reader_settings:readSetting("activate_menu") ~= "swipe"
end,
callback = function()
if G_reader_settings:readSetting("activate_menu") ~= "swipe" then
G_reader_settings:saveSetting("activate_menu", "swipe")
else
G_reader_settings:saveSetting("activate_menu", "swipe_tap")
end
UIManager:show(InfoMessage:new{
text = _("This will take effect on next restart."),
})
end,
},
{
text = _("With a swipe"),
checked_func = function()
return G_reader_settings:readSetting("activate_menu") ~= "tap"
end,
callback = function()
if G_reader_settings:readSetting("activate_menu") ~= "tap" then
G_reader_settings:saveSetting("activate_menu", "tap")
else
G_reader_settings:saveSetting("activate_menu", "swipe_tap")
end
UIManager:show(InfoMessage:new{
text = _("This will take effect on next restart."),
})
end,
separator = true,
},
{
text = _("Auto-show bottom menu"),
checked_func = function()
return G_reader_settings:nilOrTrue("show_bottom_menu")
end,
callback = function()
G_reader_settings:flipNilOrTrue("show_bottom_menu")
end,
},
}
}
| agpl-3.0 |
teamactivebot/seed | plugins/stats.lua | 79 | 4014 | do
-- Returns a table with `name` and `msgs`
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(receiver, chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'Users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w")
file:write(text)
file:flush()
file:close()
send_document(receiver,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false)
return --text
end
local function chat_stats2(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'Users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == 'teleseed' then -- Put everything you like :)
local about = _config.about_text
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /teleseed ")
return about
end
if matches[1]:lower() == "statslist" then
if not is_momod(msg) then
return "For mods only !"
end
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats2(chat_id)
end
if matches[1]:lower() == "stats" then
if not matches[2] then
if not is_momod(msg) then
return "For mods only !"
end
if msg.to.type == 'chat' or msg.to.type == 'channel' then
local receiver = get_receiver(msg)
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats(receiver, chat_id)
else
return
end
end
if matches[2] == "teleseed" then -- Put everything you like :)
if not is_admin1(msg) then
return "For admins only !"
else
return bot_stats()
end
end
if matches[2] == "group" then
if not is_admin1(msg) then
return "For admins only !"
else
return chat_stats(matches[3])
end
end
end
end
return {
patterns = {
"^[#!/]([Ss]tats)$",
"^[#!/]([Ss]tatslist)$",
"^[#!/]([Ss]tats) (group) (%d+)",
"^[#!/]([Ss]tats) (teleseed)",
"^[#!/]([Tt]eleseed)"
},
run = run
}
end | gpl-2.0 |
lichtl/darkstar | scripts/globals/items/bibikibo.lua | 18 | 1308 | -----------------------------------------
-- ID: 4314
-- Item: Bibikibo
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity 1
-- Mind -3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0
if (target:getRace() ~= 7) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_FISH) == 1) then
result = 0;
end
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,4314);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 1);
target:addMod(MOD_MND, -3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 1);
target:delMod(MOD_MND, -3);
end;
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/items/dish_of_homemade_carbonara.lua | 11 | 1599 | -----------------------------------------
-- ID: 5706
-- Item: dish_of_homemade_carbonara
-- Food Effect: 30Min, All Races
-----------------------------------------
-- CHR +1
-- Accuracy +12% (cap 80)
-- Attack +10% (cap 40)
-- Ranged Accuracy +12% (cap 80)
-- Ranged Attack +10% (cap 40)
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,5706)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.CHR, 1)
target:addMod(dsp.mod.FOOD_ACCP, 12)
target:addMod(dsp.mod.FOOD_ACC_CAP, 80)
target:addMod(dsp.mod.FOOD_ATTP, 10)
target:addMod(dsp.mod.FOOD_ATT_CAP, 40)
target:addMod(dsp.mod.FOOD_RACCP, 12)
target:addMod(dsp.mod.FOOD_RACC_CAP, 80)
target:addMod(dsp.mod.FOOD_RATTP, 10)
target:addMod(dsp.mod.FOOD_RATT_CAP, 40)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.CHR, 1)
target:delMod(dsp.mod.FOOD_ACCP, 12)
target:delMod(dsp.mod.FOOD_ACC_CAP, 80)
target:delMod(dsp.mod.FOOD_ATTP, 10)
target:delMod(dsp.mod.FOOD_ATT_CAP, 40)
target:delMod(dsp.mod.FOOD_RACCP, 12)
target:delMod(dsp.mod.FOOD_RACC_CAP, 80)
target:delMod(dsp.mod.FOOD_RATTP, 10)
target:delMod(dsp.mod.FOOD_RATT_CAP, 40)
end
| gpl-3.0 |
lichtl/darkstar | scripts/globals/mobskills/Crosswind.lua | 35 | 1039 | ---------------------------------------------
-- Crosswind
--
-- Description: Deals Wind damage to enemies within a fan-shaped area. Additional effect: Knockback
-- Type: Breath
-- Utsusemi/Blink absorb: Ignores shadows
-- Range: Unknown cone
-- Notes:
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if(mob:getFamily() == 91) then
local mobSkin = mob:getModelId();
if (mobSkin == 1746) then
return 0;
else
return 1;
end
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local dmgmod = 1;
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3,ELE_WIND,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_WIND,MOBPARAM_IGNORE_SHADOWS);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/mobskills/tachi_yukikaze.lua | 11 | 1087 | ---------------------------------------------
-- Tachi: Yukikaze
--
-- Description: Blinds target. Damage varies with TP.
-- Type: Physical
-- Shadow per hit
-- Range: Melee
---------------------------------------------
require("scripts/globals/monstertpmoves")
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/msg")
function onMobSkillCheck(target,mob,skill)
mob:messageBasic(dsp.msg.basic.READIES_WS, 0, 690+256)
return 0
end
function onMobWeaponSkill(target, mob, skill)
local numhits = 1
local accmod = 1
local dmgmod = 3
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_DMG_VARIES,1.56,1.88,2.50)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.PHYSICAL,dsp.damageType.SLASHING,info.hitslanded)
MobStatusEffectMove(mob, target, dsp.effect.BLINDNESS, 25, 0, 60)
-- Never actually got a good damage sample. Putting it between Gekko and Kasha.
target:takeDamage(dmg, mob, dsp.attackType.PHYSICAL, dsp.damageType.SLASHING)
return dmg
end
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Cloister_of_Storms/Zone.lua | 30 | 1738 | -----------------------------------
--
-- Zone: Cloister_of_Storms (202)
--
-----------------------------------
package.loaded["scripts/zones/Cloister_of_Storms/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Cloister_of_Storms/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(517.957,-18.013,540.045,0);
end
return cs;
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
master00041/anti-self | bot/utils.lua | 473 | 24167 | URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
ltn12 = require "ltn12"
serpent = require "serpent"
feedparser = require "feedparser"
json = (loadfile "./libs/JSON.lua")()
mimetype = (loadfile "./libs/mimetype.lua")()
redis = (loadfile "./libs/redis.lua")()
JSON = (loadfile "./libs/dkjson.lua")()
http.TIMEOUT = 10
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
end
if msg.to.type == 'chat' then
return 'chat#id'..msg.to.id
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
end
function is_chat_msg( msg )
if msg.to.type == 'chat' then
return true
end
return false
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
-- Eg: foo.var
local file_name = url:match("[^%w]+([%.%w]+)$")
-- Any delimited alphanumeric on the url
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
file_name = disposition:match('filename=([^;]+)') or file_name
end
return file_name
end
-- Saves file to /tmp/. If file_name isn't provided,
-- will get the text after the last "/" for filename
-- and content-type for extension
function download_to_file(url, file_name)
print("url to download: "..url)
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
-- nil, code, headers, status
local response = nil
if url:starts('https') then
options.redirect = false
response = {https.request(options)}
else
response = {http.request(options)}
end
local code = response[2]
local headers = response[3]
local status = response[4]
if code ~= 200 then return nil end
file_name = file_name or get_http_file_name(url, headers)
local file_path = "/tmp/"..file_name
print("Saved to: "..file_path)
file = io.open(file_path, "w+")
file:write(table.concat(respbody))
file:close()
return file_path
end
function vardump(value)
print(serpent.block(value, {comment=false}))
end
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end
-- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
function run_command(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
-- User has privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Save into file the data serialized for lua.
-- Set uglify true to minify the file.
function serialize_to_file(data, file, uglify)
file = io.open(file, 'w+')
local serialized
if not uglify then
serialized = serpent.block(data, {
comment = false,
name = '_'
})
else
serialized = serpent.dump(data)
end
file:write(serialized)
file:close()
end
-- Returns true if the string is empty
function string:isempty()
return self == nil or self == ''
end
-- Returns true if the string is blank
function string:isblank()
self = self:trim()
return self:isempty()
end
-- DEPRECATED!!!!!
function string.starts(String, Start)
print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead")
return Start == string.sub(String,1,string.len(Start))
end
-- Returns true if String starts with Start
function string:starts(text)
return text == string.sub(self,1,string.len(text))
end
-- Send image to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_photo(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function,
cb_extra = cb_extra
}
-- Call to remove with optional callback
send_photo(receiver, file_path, cb_function, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, cb_function, cb_extra)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil
}
send_photos_from_url_callback(cb_extra)
end
-- Use send_photos_from_url.
-- This function might be difficult to understand.
function send_photos_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path
}
-- Send first and postpone the others as callback
send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra)
end
-- Callback to remove a file
function rmtmp_cb(cb_extra, success, result)
local file_path = cb_extra.file_path
local cb_function = cb_extra.cb_function or ok_cb
local cb_extra = cb_extra.cb_extra
if file_path ~= nil then
os.remove(file_path)
print("Deleted: "..file_path)
end
-- Finally call the callback
cb_function(cb_extra, success, result)
end
-- Send document to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_document(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function or ok_cb,
cb_extra = cb_extra or false
}
-- Call to remove with optional callback
send_document(receiver, file_path, rmtmp_cb, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
local file_path = download_to_file(url, false)
print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end
-- Check if user can use the plugin and warns user
-- Returns true if user was warned and false if not warned (is allowed)
function warns_user_not_allowed(plugin, msg)
if not user_allowed(plugin, msg) then
local text = 'This plugin requires privileged user'
local receiver = get_receiver(msg)
send_msg(receiver, text, ok_cb, false)
return true
else
return false
end
end
-- Check if user can use the plugin
function user_allowed(plugin, msg)
if plugin.privileged and not is_sudo(msg) then
return false
end
return true
end
function send_order_msg(destination, msgs)
local cb_extra = {
destination = destination,
msgs = msgs
}
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
send_large_msg_callback(cb_extra, true)
end
-- If text is longer than 4096 chars, send multiple msg.
-- https://core.telegram.org/method/messages.sendMessage
function send_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
send_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
send_msg(destination, my_text, send_large_msg_callback, cb_extra)
end
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
end
-- nil
end
-- Function to read data from files
function load_from_file(file, default_data)
local f = io.open(file, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
default_data = default_data or {}
serialize_to_file(default_data, file)
print ('Created file', file)
else
print ('Data loaded from file', file)
f:close()
end
return loadfile (file)()
end
-- See http://stackoverflow.com/a/14899740
function unescape_html(str)
local map = {
["lt"] = "<",
["gt"] = ">",
["amp"] = "&",
["quot"] = '"',
["apos"] = "'"
}
new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s)
var = map[s] or n == "#" and string.char(s)
var = var or n == "#x" and string.char(tonumber(s,16))
var = var or orig
return var
end)
return new
end
--Check if this chat is realm or not
function is_realm(msg)
local var = false
local realms = 'realms'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(realms)] then
if data[tostring(realms)][tostring(msg.to.id)] then
var = true
end
return var
end
end
--Check if this chat is a group or not
function is_group(msg)
local var = false
local groups = 'groups'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(msg.to.id)] then
var = true
end
return var
end
end
function savelog(group, logtxt)
local text = (os.date("[ %c ]=> "..logtxt.."\n \n"))
local file = io.open("./groups/logs/"..group.."log.txt", "a")
file:write(text)
file:close()
end
function user_print_name(user)
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
--Check if user is the owner of that group or not
function is_owner(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_owner2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is admin or not
function is_admin(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_admin2(user_id)
local var = false
local data = load_data(_config.moderation.data)
local user = user_id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is the mod of that group or not
function is_momod(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['moderators'] then
if data[tostring(msg.to.id)]['moderators'][tostring(user)] then
var = true
end
end
end
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_momod2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
local usert = user_id
if data[tostring(group_id)] then
if data[tostring(group_id)]['moderators'] then
if data[tostring(group_id)]['moderators'][tostring(usert)] then
var = true
end
end
end
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == usert then
var = true
end
end
return var
end
-- Returns the name of the sender
function kick_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_owner2(user_id, chat_id) then -- Ignore admins
return
end
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, true)
end
-- Ban
function ban_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'banned:'..chat_id
redis:sadd(hash, user_id)
-- Kick from chat
kick_user(user_id, chat_id)
end
-- Global ban
function banall_user(user_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'gbanned'
redis:sadd(hash, user_id)
end
-- Global unban
function unbanall_user(user_id)
--Save on redis
local hash = 'gbanned'
redis:srem(hash, user_id)
end
-- Check if user_id is banned in chat_id or not
function is_banned(user_id, chat_id)
--Save on redis
local hash = 'banned:'..chat_id
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Check if user_id is globally banned or not
function is_gbanned(user_id)
--Save on redis
local hash = 'gbanned'
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Returns chat_id ban list
function ban_list(chat_id)
local hash = 'banned:'..chat_id
local list = redis:smembers(hash)
local text = "Ban list !\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
-- vardump(user_info)
if user_info then
if user_info.username then
user = '@'..user_info.username
elseif user_info.print_name and not user_info.username then
user = string.gsub(user_info.print_name, "_", " ")
else
user = ''
end
text = text..k.." - "..user.." ["..v.."]\n"
end
end
return text
end
-- Returns globally ban list
function banall_list()
local hash = 'gbanned'
local list = redis:smembers(hash)
local text = "global bans !\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
-- vardump(user_info)
if user_info then
if user_info.username then
user = '@'..user_info.username
elseif user_info.print_name and not user_info.username then
user = string.gsub(user_info.print_name, "_", " ")
else
user = ''
end
text = text..k.." - "..user.." ["..v.."]\n"
end
end
return text
end
-- /id by reply
function get_message_callback_id(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
send_large_msg(chat, result.from.id)
else
return 'Use This in Your Groups'
end
end
-- kick by reply for mods and owner
function Kick_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't kick myself"
end
if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
else
return 'Use This in Your Groups'
end
end
-- Kick by reply for admins
function Kick_by_reply_admins(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't kick myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
else
return 'Use This in Your Groups'
end
end
--Ban by reply for admins
function ban_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't ban myself"
end
if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
ban_user(result.from.id, result.to.id)
send_large_msg(chat, "User "..result.from.id.." Banned")
else
return 'Use This in Your Groups'
end
end
-- Ban by reply for admins
function ban_by_reply_admins(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't ban myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
ban_user(result.from.id, result.to.id)
send_large_msg(chat, "User "..result.from.id.." Banned")
else
return 'Use This in Your Groups'
end
end
-- Unban by reply
function unban_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't unban myself"
end
send_large_msg(chat, "User "..result.from.id.." Unbanned")
-- Save on redis
local hash = 'banned:'..result.to.id
redis:srem(hash, result.from.id)
else
return 'Use This in Your Groups'
end
end
function banall_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't banall myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
local name = user_print_name(result.from)
banall_user(result.from.id)
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered")
else
return 'Use This in Your Groups'
end
end
| gpl-2.0 |
yariplus/love-demos | love-slider/Clickables.lua | 1 | 1081 | -- A clickable area of an entity.
local Clickable = {}
Clickable.x = 0
Clickable.y = 0
Clickable.w = 64
Clickable.h = 64
Clickable.click = function() end
function Clickable:new(o)
o = o or {}
setmetatable(o, {__index = self})
return o
end
-- A collection of clickable areas for an entity.
local Clickables = {}
function Clickables:click(x, y, button)
for i = 1, #self.clickables do
if x > self.entity.sprite.x + self.clickables[i].x and
x < self.entity.sprite.x + self.clickables[i].x + self.clickables[i].w and
y > self.entity.sprite.y + self.clickables[i].y and
y < self.entity.sprite.y + self.clickables[i].y + self.clickables[i].h then
self.clickables[i].click()
end
end
end
function Clickables:addClickableArea(x, y, w, h, click)
local clickable = Clickable:new({
x = x,
y = y,
w = w,
h = h,
click = click
})
table.insert(self.clickables, clickable)
return clickable
end
function Clickables:new(entity)
local o = {entity=entity}
o.clickables = o.clickables or {}
setmetatable(o, {__index = self})
return o
end
return Clickables
| cc0-1.0 |
teamactivebot/seed | plugins/supergroup.lua | 2 | 97791 | --Begin supergrpup.lua
--Check members #Add supergroup
local function check_member_super(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
if success == 0 then
send_large_msg(receiver, "Promote me to admin first!")
end
for k,v in pairs(result) do
local member_id = v.peer_id
if member_id ~= our_id then
-- SuperGroup configuration
data[tostring(msg.to.id)] = {
group_type = 'SuperGroup',
long_id = msg.to.peer_id,
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.title, '_', ' '),
lock_arabic = 'no',
lock_link = "no",
flood = 'yes',
lock_spam = 'yes',
lock_sticker = 'no',
member = 'no',
public = 'no',
lock_rtl = 'no',
lock_tgservice = 'yes',
lock_contacts = 'no',
strict = 'no'
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
local text = 'SuperGroup has been added!'
return reply_msg(msg.id, text, ok_cb, false)
end
end
end
--Check Members #rem supergroup
local function check_member_superrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local text = 'SuperGroup has been removed'
return reply_msg(msg.id, text, ok_cb, false)
end
end
end
--Function to Add supergroup
local function superadd(msg)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
channel_get_users(receiver, check_member_super,{receiver = receiver, data = data, msg = msg})
end
--Function to remove supergroup
local function superrem(msg)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
channel_get_users(receiver, check_member_superrem,{receiver = receiver, data = data, msg = msg})
end
--Get and output admins and bots in supergroup
local function callback(cb_extra, success, result)
local i = 1
local chat_name = string.gsub(cb_extra.msg.to.print_name, "_", " ")
local member_type = cb_extra.member_type
local text = member_type.." for "..chat_name..":\n"
for k,v in pairsByKeys(result) do
if not v.first_name then
name = " "
else
vname = v.first_name:gsub("", "")
name = vname:gsub("_", " ")
end
text = text.."\n"..i.." - "..name.."["..v.peer_id.."]"
i = i + 1
end
send_large_msg(cb_extra.receiver, text)
end
--Get and output info about supergroup
local function callback_info(cb_extra, success, result)
local title ="Info for SuperGroup: ["..result.title.."]\n\n"
local admin_num = "Admin count: "..result.admins_count.."\n"
local user_num = "User count: "..result.participants_count.."\n"
local kicked_num = "Kicked user count: "..result.kicked_count.."\n"
local channel_id = "ID: "..result.peer_id.."\n"
if result.username then
channel_username = "Username: @"..result.username
else
channel_username = ""
end
local text = title..admin_num..user_num..kicked_num..channel_id..channel_username
send_large_msg(cb_extra.receiver, text)
end
--Get and output members of supergroup
local function callback_who(cb_extra, success, result)
local text = "Members for "..cb_extra.receiver
local i = 1
for k,v in pairsByKeys(result) do
if not v.print_name then
name = " "
else
vname = v.print_name:gsub("", "")
name = vname:gsub("_", " ")
end
if v.username then
username = " @"..v.username
else
username = ""
end
text = text.."\n"..i.." - "..name.." "..username.." [ "..v.peer_id.." ]\n"
--text = text.."\n"..username
i = i + 1
end
local file = io.open("./groups/lists/supergroups/"..cb_extra.receiver..".txt", "w")
file:write(text)
file:flush()
file:close()
send_document(cb_extra.receiver,"./groups/lists/supergroups/"..cb_extra.receiver..".txt", ok_cb, false)
post_msg(cb_extra.receiver, text, ok_cb, false)
end
--Get and output list of kicked users for supergroup
local function callback_kicked(cb_extra, success, result)
--vardump(result)
local text = "Kicked Members for SuperGroup "..cb_extra.receiver.."\n\n"
local i = 1
for k,v in pairsByKeys(result) do
if not v.print_name then
name = " "
else
vname = v.print_name:gsub("", "")
name = vname:gsub("_", " ")
end
if v.username then
name = name.." @"..v.username
end
text = text.."\n"..i.." - "..name.." [ "..v.peer_id.." ]\n"
i = i + 1
end
local file = io.open("./groups/lists/supergroups/kicked/"..cb_extra.receiver..".txt", "w")
file:write(text)
file:flush()
file:close()
send_document(cb_extra.receiver,"./groups/lists/supergroups/kicked/"..cb_extra.receiver..".txt", ok_cb, false)
--send_large_msg(cb_extra.receiver, text)
end
--Begin supergroup locks
local function lock_group_links(msg, data, target)
if not is_momod(msg) then
return
end
local group_link_lock = data[tostring(target)]['settings']['lock_link']
if group_link_lock == 'yes' then
return 'Link posting is already locked'
else
data[tostring(target)]['settings']['lock_link'] = 'yes'
save_data(_config.moderation.data, data)
return 'Link posting has been locked'
end
end
local function unlock_group_links(msg, data, target)
if not is_momod(msg) then
return
end
local group_link_lock = data[tostring(target)]['settings']['lock_link']
if group_link_lock == 'no' then
return 'Link posting is not locked'
else
data[tostring(target)]['settings']['lock_link'] = 'no'
save_data(_config.moderation.data, data)
return 'Link posting has been unlocked'
end
end
local function lock_group_all(msg, data, target)
if not is_momod(msg) then
return
end
local group_all_lock = data[tostring(target)]['settings']['all']
if group_all_lock == 'yes' then
return 'all setting is already locked'
else
data[tostring(target)]['settings']['all'] = 'yes'
save_data(_config.moderation.data, data)
return 'all setting has been locked'
end
end
local function unlock_group_all(msg, data, target)
if not is_momod(msg) then
return
end
local group_all_lock = data[tostring(target)]['settings']['all']
if group_all_lock == 'no' then
return 'all setting is not locked'
else
data[tostring(target)]['settings']['all'] = 'no'
save_data(_config.moderation.data, data)
return 'all setting has been unlocked'
end
end
local function lock_group_etehad(msg, data, target)
if not is_momod(msg) then
return
end
local group_etehad_lock = data[tostring(target)]['settings']['etehad']
if group_etehad_lock == 'yes' then
return 'etehad setting is already locked'
else
data[tostring(target)]['settings']['etehad'] = 'yes'
save_data(_config.moderation.data, data)
return 'etehad setting has been locked'
end
end
local function unlock_group_etehad(msg, data, target)
if not is_momod(msg) then
return
end
local group_etehad_lock = data[tostring(target)]['settings']['etehad']
if group_etehad_lock == 'no' then
return 'etehad setting is not locked'
else
data[tostring(target)]['settings']['etehad'] = 'no'
save_data(_config.moderation.data, data)
return 'etehad setting has been unlocked'
end
end
local function lock_group_leave(msg, data, target)
if not is_momod(msg) then
return
end
local group_leave_lock = data[tostring(target)]['settings']['leave']
if group_leave_lock == 'yes' then
return 'leave is already locked'
else
data[tostring(target)]['settings']['leave'] = 'yes'
save_data(_config.moderation.data, data)
return 'leave has been locked'
end
end
local function unlock_group_leave(msg, data, target)
if not is_momod(msg) then
return
end
local group_leave_lock = data[tostring(target)]['settings']['leave']
if group_leave_lock == 'no' then
return 'leave is not locked'
else
data[tostring(target)]['settings']['leave'] = 'no'
save_data(_config.moderation.data, data)
return 'leave has been unlocked'
end
end
local function lock_group_operator(msg, data, target)
if not is_momod(msg) then
return
end
local group_operator_lock = data[tostring(target)]['settings']['operator']
if group_operator_lock == 'yes' then
return 'operator is already locked'
else
data[tostring(target)]['settings']['operator'] = 'yes'
save_data(_config.moderation.data, data)
return 'operator has been locked'
end
end
local function unlock_group_operator(msg, data, target)
if not is_momod(msg) then
return
end
local group_operator_lock = data[tostring(target)]['settings']['operator']
if group_operator_lock == 'no' then
return 'operator is not locked'
else
data[tostring(target)]['settings']['operator'] = 'no'
save_data(_config.moderation.data, data)
return 'operator has been unlocked'
end
end
local function lock_group_reply(msg, data, target)
if not is_momod(msg) then
return
end
local group_reply_lock = data[tostring(target)]['settings']['reply']
if group_reply_lock == 'yes' then
return 'reply is already locked'
else
data[tostring(target)]['settings']['reply'] = 'yes'
save_data(_config.moderation.data, data)
return 'reply has been locked'
end
end
local function unlock_group_reply(msg, data, target)
if not is_momod(msg) then
return
end
local group_reply_lock = data[tostring(target)]['settings']['reply']
if group_reply_lock == 'no' then
return 'reply is not locked'
else
data[tostring(target)]['settings']['reply'] = 'no'
save_data(_config.moderation.data, data)
return 'reply has been unlocked'
end
end
local function lock_group_username(msg, data, target)
if not is_momod(msg) then
return
end
local group_username_lock = data[tostring(target)]['settings']['username']
if group_username_lock == 'yes' then
return 'username is already locked'
else
data[tostring(target)]['settings']['username'] = 'yes'
save_data(_config.moderation.data, data)
return 'username has been locked'
end
end
local function unlock_group_username(msg, data, target)
if not is_momod(msg) then
return
end
local group_username_lock = data[tostring(target)]['settings']['username']
if group_username_lock == 'no' then
return 'username is not locked'
else
data[tostring(target)]['settings']['username'] = 'no'
save_data(_config.moderation.data, data)
return 'username has been unlocked'
end
end
local function lock_group_media(msg, data, target)
if not is_momod(msg) then
return
end
local group_media_lock = data[tostring(target)]['settings']['media']
if group_media_lock == 'yes' then
return 'media is already locked'
else
data[tostring(target)]['settings']['media'] = 'yes'
save_data(_config.moderation.data, data)
return 'media has been locked'
end
end
local function unlock_group_media(msg, data, target)
if not is_momod(msg) then
return
end
local group_media_lock = data[tostring(target)]['settings']['media']
if group_media_lock == 'no' then
return 'media is not locked'
else
data[tostring(target)]['settings']['media'] = 'no'
save_data(_config.moderation.data, data)
return 'media has been unlocked'
end
end
local function lock_group_fosh(msg, data, target)
if not is_momod(msg) then
return
end
local group_fosh_lock = data[tostring(target)]['settings']['fosh']
if group_fosh_lock == 'yes' then
return 'fosh is already locked'
else
data[tostring(target)]['settings']['fosh'] = 'yes'
save_data(_config.moderation.data, data)
return 'fosh has been locked'
end
end
local function unlock_group_fosh(msg, data, target)
if not is_momod(msg) then
return
end
local group_fosh_lock = data[tostring(target)]['settings']['fosh']
if group_fosh_lock == 'no' then
return 'fosh is not locked'
else
data[tostring(target)]['settings']['fosh'] = 'no'
save_data(_config.moderation.data, data)
return 'fosh has been unlocked'
end
end
local function lock_group_join(msg, data, target)
if not is_momod(msg) then
return
end
local group_join_lock = data[tostring(target)]['settings']['join']
if group_join_lock == 'yes' then
return 'join is already locked'
else
data[tostring(target)]['settings']['join'] = 'yes'
save_data(_config.moderation.data, data)
return 'join has been locked'
end
end
local function unlock_group_join(msg, data, target)
if not is_momod(msg) then
return
end
local group_join_lock = data[tostring(target)]['settings']['join']
if group_join_lock == 'no' then
return 'join is not locked'
else
data[tostring(target)]['settings']['join'] = 'no'
save_data(_config.moderation.data, data)
return 'join has been unlocked'
end
end
local function lock_group_fwd(msg, data, target)
if not is_momod(msg) then
return
end
local group_fwd_lock = data[tostring(target)]['settings']['fwd']
if group_fwd_lock == 'yes' then
return 'fwd is already locked'
else
data[tostring(target)]['settings']['fwd'] = 'yes'
save_data(_config.moderation.data, data)
return 'fwd has been locked'
end
end
local function unlock_group_fwd(msg, data, target)
if not is_momod(msg) then
return
end
local group_fwd_lock = data[tostring(target)]['settings']['fwd']
if group_fwd_lock == 'no' then
return 'fwd is not locked'
else
data[tostring(target)]['settings']['fwd'] = 'no'
save_data(_config.moderation.data, data)
return 'fwd has been unlocked'
end
end
local function lock_group_english(msg, data, target)
if not is_momod(msg) then
return
end
local group_english_lock = data[tostring(target)]['settings']['english']
if group_english_lock == 'yes' then
return 'english is already locked'
else
data[tostring(target)]['settings']['english'] = 'yes'
save_data(_config.moderation.data, data)
return 'english has been locked'
end
end
local function unlock_group_english(msg, data, target)
if not is_momod(msg) then
return
end
local group_english_lock = data[tostring(target)]['settings']['english']
if group_english_lock == 'no' then
return 'english is not locked'
else
data[tostring(target)]['settings']['english'] = 'no'
save_data(_config.moderation.data, data)
return 'english has been unlocked'
end
end
local function lock_group_emoji(msg, data, target)
if not is_momod(msg) then
return
end
local group_emoji_lock = data[tostring(target)]['settings']['emoji']
if group_emoji_lock == 'yes' then
return 'emoji is already locked'
else
data[tostring(target)]['settings']['emoji'] = 'yes'
save_data(_config.moderation.data, data)
return 'emoji has been locked'
end
end
local function unlock_group_emoji(msg, data, target)
if not is_momod(msg) then
return
end
local group_emoji_lock = data[tostring(target)]['settings']['emoji']
if group_emoji_lock == 'no' then
return 'emoji is not locked'
else
data[tostring(target)]['settings']['emoji'] = 'no'
save_data(_config.moderation.data, data)
return 'emoji has been unlocked'
end
end
local function lock_group_tag(msg, data, target)
if not is_momod(msg) then
return
end
local group_tag_lock = data[tostring(target)]['settings']['tag']
if group_tag_lock == 'yes' then
return 'tag is already locked'
else
data[tostring(target)]['settings']['tag'] = 'yes'
save_data(_config.moderation.data, data)
return 'tag has been locked'
end
end
local function unlock_group_tag(msg, data, target)
if not is_momod(msg) then
return
end
local group_tag_lock = data[tostring(target)]['settings']['tag']
if group_tag_lock == 'no' then
return 'tag is not locked'
else
data[tostring(target)]['settings']['tag'] = 'no'
save_data(_config.moderation.data, data)
return 'tag has been unlocked'
end
end
local function unlock_group_all(msg, data, target)
if not is_momod(msg) then
return
end
local group_all_lock = data[tostring(target)]['settings']['all']
if group_all_lock == 'no' then
return 'all setting is not locked'
else
data[tostring(target)]['settings']['all'] = 'no'
save_data(_config.moderation.data, data)
return 'all setting has been unlocked'
end
end
local function lock_group_spam(msg, data, target)
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Owners only!"
end
local group_spam_lock = data[tostring(target)]['settings']['lock_spam']
if group_spam_lock == 'yes' then
return 'SuperGroup spam is already locked'
else
data[tostring(target)]['settings']['lock_spam'] = 'yes'
save_data(_config.moderation.data, data)
return 'SuperGroup spam has been locked'
end
end
local function unlock_group_spam(msg, data, target)
if not is_momod(msg) then
return
end
local group_spam_lock = data[tostring(target)]['settings']['lock_spam']
if group_spam_lock == 'no' then
return 'SuperGroup spam is not locked'
else
data[tostring(target)]['settings']['lock_spam'] = 'no'
save_data(_config.moderation.data, data)
return 'SuperGroup spam has been unlocked'
end
end
local function lock_group_flood(msg, data, target)
if not is_momod(msg) then
return
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Flood is already locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Flood has been locked'
end
end
local function unlock_group_flood(msg, data, target)
if not is_momod(msg) then
return
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Flood has been unlocked'
end
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic/Persian is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic/Persian has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
if not is_momod(msg) then
return
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'SuperGroup members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'SuperGroup members has been locked'
end
local function unlock_group_membermod(msg, data, target)
if not is_momod(msg) then
return
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'SuperGroup members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'SuperGroup members has been unlocked'
end
end
local function lock_group_rtl(msg, data, target)
if not is_momod(msg) then
return
end
local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl']
if group_rtl_lock == 'yes' then
return 'RTl is already locked'
else
data[tostring(target)]['settings']['lock_rtl'] = 'yes'
save_data(_config.moderation.data, data)
return 'RTL has been locked'
end
end
local function unlock_group_rtl(msg, data, target)
if not is_momod(msg) then
return
end
local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl']
if group_rtl_lock == 'no' then
return 'RTL is already unlocked'
else
data[tostring(target)]['settings']['lock_rtl'] = 'no'
save_data(_config.moderation.data, data)
return 'RTL has been unlocked'
end
end
local function lock_group_tgservice(msg, data, target)
if not is_momod(msg) then
return
end
local group_tgservice_lock = data[tostring(target)]['settings']['lock_tgservice']
if group_tgservice_lock == 'yes' then
return 'Tgservice is already locked'
else
data[tostring(target)]['settings']['lock_tgservice'] = 'yes'
save_data(_config.moderation.data, data)
return 'Tgservice has been locked'
end
end
local function unlock_group_tgservice(msg, data, target)
if not is_momod(msg) then
return
end
local group_tgservice_lock = data[tostring(target)]['settings']['lock_tgservice']
if group_tgservice_lock == 'no' then
return 'TgService Is Not Locked!'
else
data[tostring(target)]['settings']['lock_tgservice'] = 'no'
save_data(_config.moderation.data, data)
return 'Tgservice has been unlocked'
end
end
local function lock_group_sticker(msg, data, target)
if not is_momod(msg) then
return
end
local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker']
if group_sticker_lock == 'yes' then
return 'Sticker posting is already locked'
else
data[tostring(target)]['settings']['lock_sticker'] = 'yes'
save_data(_config.moderation.data, data)
return 'Sticker posting has been locked'
end
end
local function unlock_group_sticker(msg, data, target)
if not is_momod(msg) then
return
end
local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker']
if group_sticker_lock == 'no' then
return 'Sticker posting is already unlocked'
else
data[tostring(target)]['settings']['lock_sticker'] = 'no'
save_data(_config.moderation.data, data)
return 'Sticker posting has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_contacts(msg, data, target)
if not is_momod(msg) then
return
end
local group_rtl_lock = data[tostring(target)]['settings']['lock_contacts']
if group_contacts_lock == 'yes' then
return 'Contact posting is already locked'
else
data[tostring(target)]['settings']['lock_contacts'] = 'yes'
save_data(_config.moderation.data, data)
return 'Contact posting has been locked'
end
end
local function unlock_group_contacts(msg, data, target)
if not is_momod(msg) then
return
end
local group_contacts_lock = data[tostring(target)]['settings']['lock_contacts']
if group_contacts_lock == 'no' then
return 'Contact posting is already unlocked'
else
data[tostring(target)]['settings']['lock_contacts'] = 'no'
save_data(_config.moderation.data, data)
return 'Contact posting has been unlocked'
end
end
local function enable_strict_rules(msg, data, target)
if not is_momod(msg) then
return
end
local group_strict_lock = data[tostring(target)]['settings']['strict']
if group_strict_lock == 'yes' then
return 'Settings are already strictly enforced'
else
data[tostring(target)]['settings']['strict'] = 'yes'
save_data(_config.moderation.data, data)
return 'Settings will be strictly enforced'
end
end
local function disable_strict_rules(msg, data, target)
if not is_momod(msg) then
return
end
local group_strict_lock = data[tostring(target)]['settings']['strict']
if group_strict_lock == 'no' then
return 'Settings are not strictly enforced'
else
data[tostring(target)]['settings']['strict'] = 'no'
save_data(_config.moderation.data, data)
return 'Settings will not be strictly enforced'
end
end
--End supergroup locks
--'Set supergroup rules' function
local function set_rulesmod(msg, data, target)
if not is_momod(msg) then
return
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'SuperGroup rules set'
end
--'Get supergroup rules' function
local function get_rules(msg, data)
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)][data_cat]
local group_name = data[tostring(msg.to.id)]['settings']['set_name']
local rules = group_name..' rules:\n\n'..rules:gsub("/n", " ")
return rules
end
--Set supergroup to public or not public function
local function set_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_public_lock = data[tostring(target)]['settings']['public']
local long_id = data[tostring(target)]['long_id']
if not long_id then
data[tostring(target)]['long_id'] = msg.to.peer_id
save_data(_config.moderation.data, data)
end
if group_public_lock == 'yes' then
return 'Group is already public'
else
data[tostring(target)]['settings']['public'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'SuperGroup is now: public'
end
local function unset_public_membermod(msg, data, target)
if not is_momod(msg) then
return
end
local group_public_lock = data[tostring(target)]['settings']['public']
local long_id = data[tostring(target)]['long_id']
if not long_id then
data[tostring(target)]['long_id'] = msg.to.peer_id
save_data(_config.moderation.data, data)
end
if group_public_lock == 'no' then
return 'Group is not public'
else
data[tostring(target)]['settings']['public'] = 'no'
data[tostring(target)]['long_id'] = msg.to.long_id
save_data(_config.moderation.data, data)
return 'SuperGroup is now: not public'
end
end
--Show supergroup settings; function
function show_supergroup_settingsmod(msg, target)
if not is_momod(msg) then
return
end
local data = load_data(_config.moderation.data)
if data[tostring(target)] then
if data[tostring(target)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local bots_protection = "Yes"
if data[tostring(target)]['settings']['lock_bots'] then
bots_protection = data[tostring(target)]['settings']['lock_bots']
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['public'] then
data[tostring(target)]['settings']['public'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['lock_rtl'] then
data[tostring(target)]['settings']['lock_rtl'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['lock_tgservice'] then
data[tostring(target)]['settings']['lock_tgservice'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['tag'] then
data[tostring(target)]['settings']['tag'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['emoji'] then
data[tostring(target)]['settings']['emoji'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['english'] then
data[tostring(target)]['settings']['english'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['fwd'] then
data[tostring(target)]['settings']['fwd'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['reply'] then
data[tostring(target)]['settings']['reply'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['join'] then
data[tostring(target)]['settings']['join'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['fosh'] then
data[tostring(target)]['settings']['fosh'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['username'] then
data[tostring(target)]['settings']['username'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['media'] then
data[tostring(target)]['settings']['media'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['leave'] then
data[tostring(target)]['settings']['leave'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['lock_member'] then
data[tostring(target)]['settings']['lock_member'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['all'] then
data[tostring(target)]['settings']['all'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['operator'] then
data[tostring(target)]['settings']['operator'] = 'no'
end
end
if data[tostring(target)]['settings'] then
if not data[tostring(target)]['settings']['etehad'] then
data[tostring(target)]['settings']['etehad'] = 'no'
end
end
local gp_type = data[tostring(msg.to.id)]['group_type']
local settings = data[tostring(target)]['settings']
local text = "____________________\n⚙SuperGroup settings⚙:⬇️\n____________________\n>Lock links : "..settings.lock_link.."\n>Lock contacts: "..settings.lock_contacts.."\n>Lock flood: "..settings.flood.."\n>Flood sensitivity : "..NUM_MSG_MAX.."\n>Lock spam: "..settings.lock_spam.."\n>Lock Arabic: "..settings.lock_arabic.."\n>Lock Member: "..settings.lock_member.."\n>Lock RTL: "..settings.lock_rtl.."\n>Lock Tgservice: "..settings.lock_tgservice.."\n>Lock sticker: "..settings.lock_sticker.."\n>Lock tag(#): "..settings.tag.."\n>Lock emoji: "..settings.emoji.."\n>Lock english: "..settings.english.."\n>Lock fwd(forward): "..settings.fwd.."\n>Lock reply: "..settings.reply.."\n>Lock join: "..settings.join.."\n>Lock username(@): "..settings.username.."\n>Lock media: "..settings.media.."\n>Lock fosh: "..settings.fosh.."\n>Lock leave: "..settings.leave.."\n>Lock bots: "..bots_protection.."\n>Lock operator: "..settings.operator.."\n____________________\n⚙Easy Sweet&Faster Switch⚙:⬇️\n____________________\n>Switch Model Etehad: "..settings.etehad.."\n>Lock all: "..settings.all.."\n____________________\nℹ️About Groupℹ️:⬇️\n____________________\n>group type: "..gp_type.."\n>Public: "..settings.public.."\n>Strict settings: "..settings.strict.."\n____________________\n>>bot version : v2.9<<\n>>>👑MeGa shield👑<<<\n>>@shieldTM<<"
return text
end
local function promote_admin(receiver, member_username, user_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'channel#id', '')
local member_tag_username = string.gsub(member_username, '@', '(at)')
if not data[group] then
return
end
if data[group]['moderators'][tostring(user_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(user_id)] = member_tag_username
save_data(_config.moderation.data, data)
end
local function demote_admin(receiver, member_username, user_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'channel#id', '')
if not data[group] then
return
end
if not data[group]['moderators'][tostring(user_id)] then
return send_large_msg(receiver, member_tag_username..' is not a moderator.')
end
data[group]['moderators'][tostring(user_id)] = nil
save_data(_config.moderation.data, data)
end
local function promote2(receiver, member_username, user_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'channel#id', '')
local member_tag_username = string.gsub(member_username, '@', '(at)')
if not data[group] then
return send_large_msg(receiver, 'SuperGroup is not added.')
end
if data[group]['moderators'][tostring(user_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(user_id)] = member_tag_username
save_data(_config.moderation.data, data)
send_large_msg(receiver, member_username..' has been promoted.')
end
local function demote2(receiver, member_username, user_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'channel#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(user_id)] then
return send_large_msg(receiver, member_tag_username..' is not a moderator.')
end
data[group]['moderators'][tostring(user_id)] = nil
save_data(_config.moderation.data, data)
send_large_msg(receiver, member_username..' has been demoted.')
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
local groups = "groups"
if not data[tostring(groups)][tostring(msg.to.id)] then
return 'SuperGroup is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
-- Start by reply actions
function get_message_callback(extra, success, result)
local get_cmd = extra.get_cmd
local msg = extra.msg
local data = load_data(_config.moderation.data)
local print_name = user_print_name(msg.from):gsub("", "")
local name_log = print_name:gsub("_", " ")
if get_cmd == "id" and not result.action then
local channel = 'channel#id'..result.to.peer_id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id for: ["..result.from.peer_id.."]")
id1 = send_large_msg(channel, result.from.peer_id)
elseif get_cmd == 'id' and result.action then
local action = result.action.type
if action == 'chat_add_user' or action == 'chat_del_user' or action == 'chat_rename' or action == 'chat_change_photo' then
if result.action.user then
user_id = result.action.user.peer_id
else
user_id = result.peer_id
end
local channel = 'channel#id'..result.to.peer_id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id by service msg for: ["..user_id.."]")
id1 = send_large_msg(channel, user_id)
end
elseif get_cmd == "idfrom" then
local channel = 'channel#id'..result.to.peer_id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id for msg fwd from: ["..result.fwd_from.peer_id.."]")
id2 = send_large_msg(channel, result.fwd_from.peer_id)
elseif get_cmd == 'channel_block' and not result.action then
local member_id = result.from.peer_id
local channel_id = result.to.peer_id
if member_id == msg.from.id then
return send_large_msg("channel#id"..channel_id, "Leave using kickme command")
end
if is_momod2(member_id, channel_id) and not is_admin2(msg.from.id) then
return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins")
end
if is_admin2(member_id) then
return send_large_msg("channel#id"..channel_id, "You can't kick other admins")
end
--savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..user_id.."] by reply")
kick_user(member_id, channel_id)
elseif get_cmd == 'channel_block' and result.action and result.action.type == 'chat_add_user' then
local user_id = result.action.user.peer_id
local channel_id = result.to.peer_id
if member_id == msg.from.id then
return send_large_msg("channel#id"..channel_id, "Leave using kickme command")
end
if is_momod2(member_id, channel_id) and not is_admin2(msg.from.id) then
return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins")
end
if is_admin2(member_id) then
return send_large_msg("channel#id"..channel_id, "You can't kick other admins")
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..user_id.."] by reply to sev. msg.")
kick_user(user_id, channel_id)
elseif get_cmd == "del" then
delete_msg(result.id, ok_cb, false)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted a message by reply")
elseif get_cmd == "setadmin" then
local user_id = result.from.peer_id
local channel_id = "channel#id"..result.to.peer_id
channel_set_admin(channel_id, "user#id"..user_id, ok_cb, false)
if result.from.username then
text = "@"..result.from.username.." set as an admin"
else
text = "[ "..user_id.." ]set as an admin"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set: ["..user_id.."] as admin by reply")
send_large_msg(channel_id, text)
elseif get_cmd == "demoteadmin" then
local user_id = result.from.peer_id
local channel_id = "channel#id"..result.to.peer_id
if is_admin2(result.from.peer_id) then
return send_large_msg(channel_id, "You can't demote global admins!")
end
channel_demote(channel_id, "user#id"..user_id, ok_cb, false)
if result.from.username then
text = "@"..result.from.username.." has been demoted from admin"
else
text = "[ "..user_id.." ] has been demoted from admin"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted: ["..user_id.."] from admin by reply")
send_large_msg(channel_id, text)
elseif get_cmd == "setowner" then
local group_owner = data[tostring(result.to.peer_id)]['set_owner']
if group_owner then
local channel_id = 'channel#id'..result.to.peer_id
if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then
local user = "user#id"..group_owner
channel_demote(channel_id, user, ok_cb, false)
end
local user_id = "user#id"..result.from.peer_id
channel_set_admin(channel_id, user_id, ok_cb, false)
data[tostring(result.to.peer_id)]['set_owner'] = tostring(result.from.peer_id)
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set: ["..result.from.peer_id.."] as owner by reply")
if result.from.username then
text = "@"..result.from.username.." [ "..result.from.peer_id.." ] added as owner"
else
text = "[ "..result.from.peer_id.." ] added as owner"
end
send_large_msg(channel_id, text)
end
elseif get_cmd == "promote" then
local receiver = result.to.peer_id
local full_name = (result.from.first_name or '')..' '..(result.from.last_name or '')
local member_name = full_name:gsub("", "")
local member_username = member_name:gsub("_", " ")
if result.from.username then
member_username = '@'.. result.from.username
end
local member_id = result.from.peer_id
if result.to.peer_type == 'channel' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted mod: @"..member_username.."["..result.from.peer_id.."] by reply")
promote2("channel#id"..result.to.peer_id, member_username, member_id)
--channel_set_mod(channel_id, user, ok_cb, false)
end
elseif get_cmd == "demote" then
local full_name = (result.from.first_name or '')..' '..(result.from.last_name or '')
local member_name = full_name:gsub("", "")
local member_username = member_name:gsub("_", " ")
if result.from.username then
member_username = '@'.. result.from.username
end
local member_id = result.from.peer_id
--local user = "user#id"..result.peer_id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted mod: @"..member_username.."["..user_id.."] by reply")
demote2("channel#id"..result.to.peer_id, member_username, member_id)
--channel_demote(channel_id, user, ok_cb, false)
elseif get_cmd == 'mute_user' then
if result.service then
local action = result.action.type
if action == 'chat_add_user' or action == 'chat_del_user' or action == 'chat_rename' or action == 'chat_change_photo' then
if result.action.user then
user_id = result.action.user.peer_id
end
end
if action == 'chat_add_user_link' then
if result.from then
user_id = result.from.peer_id
end
end
else
user_id = result.from.peer_id
end
local receiver = extra.receiver
local chat_id = msg.to.id
print(user_id)
print(chat_id)
if is_muted_user(chat_id, user_id) then
unmute_user(chat_id, user_id)
send_large_msg(receiver, "["..user_id.."] removed from the muted user list")
elseif is_admin1(msg) then
mute_user(chat_id, user_id)
send_large_msg(receiver, " ["..user_id.."] added to the muted user list")
end
end
end
-- End by reply actions
--By ID actions
local function cb_user_info(extra, success, result)
local receiver = extra.receiver
local user_id = result.peer_id
local get_cmd = extra.get_cmd
local data = load_data(_config.moderation.data)
--[[if get_cmd == "setadmin" then
local user_id = "user#id"..result.peer_id
channel_set_admin(receiver, user_id, ok_cb, false)
if result.username then
text = "@"..result.username.." has been set as an admin"
else
text = "[ "..result.peer_id.." ] has been set as an admin"
end
send_large_msg(receiver, text)]]
if get_cmd == "demoteadmin" then
if is_admin2(result.peer_id) then
return send_large_msg(receiver, "You can't demote global admins!")
end
local user_id = "user#id"..result.peer_id
channel_demote(receiver, user_id, ok_cb, false)
if result.username then
text = "@"..result.username.." has been demoted from admin"
send_large_msg(receiver, text)
else
text = "[ "..result.peer_id.." ] has been demoted from admin"
send_large_msg(receiver, text)
end
elseif get_cmd == "promote" then
if result.username then
member_username = "@"..result.username
else
member_username = string.gsub(result.print_name, '_', ' ')
end
promote2(receiver, member_username, user_id)
elseif get_cmd == "demote" then
if result.username then
member_username = "@"..result.username
else
member_username = string.gsub(result.print_name, '_', ' ')
end
demote2(receiver, member_username, user_id)
end
end
-- Begin resolve username actions
local function callbackres(extra, success, result)
local member_id = result.peer_id
local member_username = "@"..result.username
local get_cmd = extra.get_cmd
if get_cmd == "res" then
local user = result.peer_id
local name = string.gsub(result.print_name, "_", " ")
local channel = 'channel#id'..extra.channelid
send_large_msg(channel, user..'\n'..name)
return user
elseif get_cmd == "id" then
local user = result.peer_id
local channel = 'channel#id'..extra.channelid
send_large_msg(channel, user)
return user
elseif get_cmd == "invite" then
local receiver = extra.channel
local user_id = "user#id"..result.peer_id
channel_invite(receiver, user_id, ok_cb, false)
--[[elseif get_cmd == "channel_block" then
local user_id = result.peer_id
local channel_id = extra.channelid
local sender = extra.sender
if member_id == sender then
return send_large_msg("channel#id"..channel_id, "Leave using kickme command")
end
if is_momod2(member_id, channel_id) and not is_admin2(sender) then
return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins")
end
if is_admin2(member_id) then
return send_large_msg("channel#id"..channel_id, "You can't kick other admins")
end
kick_user(user_id, channel_id)
elseif get_cmd == "setadmin" then
local user_id = "user#id"..result.peer_id
local channel_id = extra.channel
channel_set_admin(channel_id, user_id, ok_cb, false)
if result.username then
text = "@"..result.username.." has been set as an admin"
send_large_msg(channel_id, text)
else
text = "@"..result.peer_id.." has been set as an admin"
send_large_msg(channel_id, text)
end
elseif get_cmd == "setowner" then
local receiver = extra.channel
local channel = string.gsub(receiver, 'channel#id', '')
local from_id = extra.from_id
local group_owner = data[tostring(channel)]['set_owner']
if group_owner then
local user = "user#id"..group_owner
if not is_admin2(group_owner) and not is_support(group_owner) then
channel_demote(receiver, user, ok_cb, false)
end
local user_id = "user#id"..result.peer_id
channel_set_admin(receiver, user_id, ok_cb, false)
data[tostring(channel)]['set_owner'] = tostring(result.peer_id)
save_data(_config.moderation.data, data)
savelog(channel, name_log.." ["..from_id.."] set ["..result.peer_id.."] as owner by username")
if result.username then
text = member_username.." [ "..result.peer_id.." ] added as owner"
else
text = "[ "..result.peer_id.." ] added as owner"
end
send_large_msg(receiver, text)
end]]
elseif get_cmd == "promote" then
local receiver = extra.channel
local user_id = result.peer_id
--local user = "user#id"..result.peer_id
promote2(receiver, member_username, user_id)
--channel_set_mod(receiver, user, ok_cb, false)
elseif get_cmd == "demote" then
local receiver = extra.channel
local user_id = result.peer_id
local user = "user#id"..result.peer_id
demote2(receiver, member_username, user_id)
elseif get_cmd == "demoteadmin" then
local user_id = "user#id"..result.peer_id
local channel_id = extra.channel
if is_admin2(result.peer_id) then
return send_large_msg(channel_id, "You can't demote global admins!")
end
channel_demote(channel_id, user_id, ok_cb, false)
if result.username then
text = "@"..result.username.." has been demoted from admin"
send_large_msg(channel_id, text)
else
text = "@"..result.peer_id.." has been demoted from admin"
send_large_msg(channel_id, text)
end
local receiver = extra.channel
local user_id = result.peer_id
demote_admin(receiver, member_username, user_id)
elseif get_cmd == 'mute_user' then
local user_id = result.peer_id
local receiver = extra.receiver
local chat_id = string.gsub(receiver, 'channel#id', '')
if is_muted_user(chat_id, user_id) then
unmute_user(chat_id, user_id)
send_large_msg(receiver, " ["..user_id.."] removed from muted user list")
elseif is_owner(extra.msg) then
mute_user(chat_id, user_id)
send_large_msg(receiver, " ["..user_id.."] added to muted user list")
end
end
end
--End resolve username actions
--Begin non-channel_invite username actions
local function in_channel_cb(cb_extra, success, result)
local get_cmd = cb_extra.get_cmd
local receiver = cb_extra.receiver
local msg = cb_extra.msg
local data = load_data(_config.moderation.data)
local print_name = user_print_name(cb_extra.msg.from):gsub("", "")
local name_log = print_name:gsub("_", " ")
local member = cb_extra.username
local memberid = cb_extra.user_id
if member then
text = 'No user @'..member..' in this SuperGroup.'
else
text = 'No user ['..memberid..'] in this SuperGroup.'
end
if get_cmd == "channel_block" then
for k,v in pairs(result) do
vusername = v.username
vpeer_id = tostring(v.peer_id)
if vusername == member or vpeer_id == memberid then
local user_id = v.peer_id
local channel_id = cb_extra.msg.to.id
local sender = cb_extra.msg.from.id
if user_id == sender then
return send_large_msg("channel#id"..channel_id, "Leave using kickme command")
end
if is_momod2(user_id, channel_id) and not is_admin2(sender) then
return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins")
end
if is_admin2(user_id) then
return send_large_msg("channel#id"..channel_id, "You can't kick other admins")
end
if v.username then
text = ""
savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: @"..v.username.." ["..v.peer_id.."]")
else
text = ""
savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..v.peer_id.."]")
end
kick_user(user_id, channel_id)
return
end
end
elseif get_cmd == "setadmin" then
for k,v in pairs(result) do
vusername = v.username
vpeer_id = tostring(v.peer_id)
if vusername == member or vpeer_id == memberid then
local user_id = "user#id"..v.peer_id
local channel_id = "channel#id"..cb_extra.msg.to.id
channel_set_admin(channel_id, user_id, ok_cb, false)
if v.username then
text = "@"..v.username.." ["..v.peer_id.."] has been set as an admin"
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin @"..v.username.." ["..v.peer_id.."]")
else
text = "["..v.peer_id.."] has been set as an admin"
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin "..v.peer_id)
end
if v.username then
member_username = "@"..v.username
else
member_username = string.gsub(v.print_name, '_', ' ')
end
local receiver = channel_id
local user_id = v.peer_id
promote_admin(receiver, member_username, user_id)
end
send_large_msg(channel_id, text)
return
end
elseif get_cmd == 'setowner' then
for k,v in pairs(result) do
vusername = v.username
vpeer_id = tostring(v.peer_id)
if vusername == member or vpeer_id == memberid then
local channel = string.gsub(receiver, 'channel#id', '')
local from_id = cb_extra.msg.from.id
local group_owner = data[tostring(channel)]['set_owner']
if group_owner then
if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then
local user = "user#id"..group_owner
channel_demote(receiver, user, ok_cb, false)
end
local user_id = "user#id"..v.peer_id
channel_set_admin(receiver, user_id, ok_cb, false)
data[tostring(channel)]['set_owner'] = tostring(v.peer_id)
save_data(_config.moderation.data, data)
savelog(channel, name_log.."["..from_id.."] set ["..v.peer_id.."] as owner by username")
if result.username then
text = member_username.." ["..v.peer_id.."] added as owner"
else
text = "["..v.peer_id.."] added as owner"
end
end
elseif memberid and vusername ~= member and vpeer_id ~= memberid then
local channel = string.gsub(receiver, 'channel#id', '')
local from_id = cb_extra.msg.from.id
local group_owner = data[tostring(channel)]['set_owner']
if group_owner then
if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then
local user = "user#id"..group_owner
channel_demote(receiver, user, ok_cb, false)
end
data[tostring(channel)]['set_owner'] = tostring(memberid)
save_data(_config.moderation.data, data)
savelog(channel, name_log.."["..from_id.."] set ["..memberid.."] as owner by username")
text = "["..memberid.."] added as owner"
end
end
end
end
send_large_msg(receiver, text)
end
--End non-channel_invite username actions
--'Set supergroup photo' function
local function set_supergroup_photo(msg, success, result)
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)] then
return
end
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/channel_photo_'..msg.to.id..'.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
channel_set_photo(receiver, file, ok_cb, false)
data[tostring(msg.to.id)]['settings']['set_photo'] = file
save_data(_config.moderation.data, data)
send_large_msg(receiver, 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
--Run function
local function run(msg, matches)
if msg.to.type == 'chat' then
if matches[1] == 'tosuper' then
if not is_admin1(msg) then
return
end
local receiver = get_receiver(msg)
chat_upgrade(receiver, ok_cb, false)
end
elseif msg.to.type == 'channel'then
if matches[1] == 'tosuper' then
if not is_admin1(msg) then
return
end
return "Already a SuperGroup"
end
end
if msg.to.type == 'channel' then
local support_id = msg.from.id
local receiver = get_receiver(msg)
local print_name = user_print_name(msg.from):gsub("", "")
local name_log = print_name:gsub("_", " ")
local data = load_data(_config.moderation.data)
if matches[1] == 'add' and not matches[2] then
if not is_admin1(msg) and not is_support(support_id) then
return
end
if is_super_group(msg) then
return reply_msg(msg.id, 'SuperGroup is already added.', ok_cb, false)
end
print("SuperGroup "..msg.to.print_name.."("..msg.to.id..") added")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] added SuperGroup")
superadd(msg)
set_mutes(msg.to.id)
channel_set_admin(receiver, 'user#id'..msg.from.id, ok_cb, false)
end
if matches[1] == 'rem' and is_admin1(msg) and not matches[2] then
if not is_super_group(msg) then
return reply_msg(msg.id, 'SuperGroup is not added.', ok_cb, false)
end
print("SuperGroup "..msg.to.print_name.."("..msg.to.id..") removed")
superrem(msg)
rem_mutes(msg.to.id)
end
if not data[tostring(msg.to.id)] then
return
end
if matches[1] == "gpinfo" then
if not is_owner(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup info")
channel_info(receiver, callback_info, {receiver = receiver, msg = msg})
end
if matches[1] == "admins" then
if not is_owner(msg) and not is_support(msg.from.id) then
return
end
member_type = 'Admins'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup Admins list")
admins = channel_get_admins(receiver,callback, {receiver = receiver, msg = msg, member_type = member_type})
end
if matches[1] == "owner" then
local group_owner = data[tostring(msg.to.id)]['set_owner']
if not group_owner then
return "no owner,ask admins in support groups to set owner for your SuperGroup"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
return "SuperGroup owner is ["..group_owner..']'
end
if matches[1] == "modlist" then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
-- channel_get_admins(receiver,callback, {receiver = receiver})
end
if matches[1] == "bots" and is_momod(msg) then
member_type = 'Bots'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup bots list")
channel_get_bots(receiver, callback, {receiver = receiver, msg = msg, member_type = member_type})
end
if matches[1] == "who" and not matches[2] and is_momod(msg) then
local user_id = msg.from.peer_id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup users list")
channel_get_users(receiver, callback_who, {receiver = receiver})
end
if matches[1] == "kicked" and is_momod(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested Kicked users list")
channel_get_kicked(receiver, callback_kicked, {receiver = receiver})
end
if matches[1] == 'del' and is_momod(msg) then
if type(msg.reply_id) ~= "nil" then
local cbreply_extra = {
get_cmd = 'del',
msg = msg
}
delete_msg(msg.id, ok_cb, false)
get_message(msg.reply_id, get_message_callback, cbreply_extra)
end
end
if matches[1] == 'block' or matches[1] == 'kick' and is_momod(msg) then
if type(msg.reply_id) ~= "nil" then
local cbreply_extra = {
get_cmd = 'channel_block',
msg = msg
}
get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif matches[1] == 'block' or matches[1] == 'kick' and string.match(matches[2], '^%d+$') then
--[[local user_id = matches[2]
local channel_id = msg.to.id
if is_momod2(user_id, channel_id) and not is_admin2(user_id) then
return send_large_msg(receiver, "You can't kick mods/owner/admins")
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: [ user#id"..user_id.." ]")
kick_user(user_id, channel_id)]]
local get_cmd = 'channel_block'
local msg = msg
local user_id = matches[2]
channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id})
elseif msg.text:match("@[%a%d]") then
--[[local cbres_extra = {
channelid = msg.to.id,
get_cmd = 'channel_block',
sender = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: @"..username)
resolve_username(username, callbackres, cbres_extra)]]
local get_cmd = 'channel_block'
local msg = msg
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username})
end
end
if matches[1] == 'id' then
if type(msg.reply_id) ~= "nil" and is_momod(msg) and not matches[2] then
local cbreply_extra = {
get_cmd = 'id',
msg = msg
}
get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif type(msg.reply_id) ~= "nil" and matches[2] == "from" and is_momod(msg) then
local cbreply_extra = {
get_cmd = 'idfrom',
msg = msg
}
get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif msg.text:match("@[%a%d]") then
local cbres_extra = {
channelid = msg.to.id,
get_cmd = 'id'
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested ID for: @"..username)
resolve_username(username, callbackres, cbres_extra)
else
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup ID")
return ">Your Name: " ..string.gsub(msg.from.print_name, "_", " ").. "\n>Your Username: @"..(msg.from.username or '----').."\n>Your ID: "..msg.from.id.."\n\n>SuperGroup Name: " ..string.gsub(msg.to.print_name, "_", " ").. "\n>SuperGroup ID: "..msg.to.id
end
end
if matches[1] == 'kickme' then
if msg.to.type == 'channel' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] left via kickme")
channel_kick("channel#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false)
end
end
if matches[1] == 'newlink' and is_momod(msg)then
local function callback_link (extra , success, result)
local receiver = get_receiver(msg)
if success == 0 then
send_large_msg(receiver, '*Error: Failed to retrieve link* \nReason: Not creator.\n\nIf you have the link, please use /setlink to set it')
data[tostring(msg.to.id)]['settings']['set_link'] = nil
save_data(_config.moderation.data, data)
else
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] attempted to create a new SuperGroup link")
export_channel_link(receiver, callback_link, false)
end
if matches[1] == 'setlink' and is_owner(msg) then
data[tostring(msg.to.id)]['settings']['set_link'] = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send the new group link now'
end
if msg.text then
if msg.text:match("^(https://telegram.me/joinchat/%S+)$") and data[tostring(msg.to.id)]['settings']['set_link'] == 'waiting' and is_owner(msg) then
data[tostring(msg.to.id)]['settings']['set_link'] = msg.text
save_data(_config.moderation.data, data)
return "New link set"
end
end
if matches[1] == 'link' then
if not is_momod(msg) then
return
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first!\n\nOr if I am not creator use /setlink to set your link"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == "invite" and is_sudo(msg) then
local cbres_extra = {
channel = get_receiver(msg),
get_cmd = "invite"
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] invited @"..username)
resolve_username(username, callbackres, cbres_extra)
end
if matches[1] == 'res' and is_owner(msg) then
local cbres_extra = {
channelid = msg.to.id,
get_cmd = 'res'
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] resolved username: @"..username)
resolve_username(username, callbackres, cbres_extra)
end
--[[if matches[1] == 'kick' and is_momod(msg) then
local receiver = channel..matches[3]
local user = "user#id"..matches[2]
chaannel_kick(receiver, user, ok_cb, false)
end]]
if matches[1] == 'setadmin' then
if not is_support(msg.from.id) and not is_owner(msg) then
return
end
if type(msg.reply_id) ~= "nil" then
local cbreply_extra = {
get_cmd = 'setadmin',
msg = msg
}
setadmin = get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif matches[1] == 'setadmin' and string.match(matches[2], '^%d+$') then
--[[] local receiver = get_receiver(msg)
local user_id = "user#id"..matches[2]
local get_cmd = 'setadmin'
user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd})]]
local get_cmd = 'setadmin'
local msg = msg
local user_id = matches[2]
channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id})
elseif matches[1] == 'setadmin' and not string.match(matches[2], '^%d+$') then
--[[local cbres_extra = {
channel = get_receiver(msg),
get_cmd = 'setadmin'
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin @"..username)
resolve_username(username, callbackres, cbres_extra)]]
local get_cmd = 'setadmin'
local msg = msg
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username})
end
end
if matches[1] == 'demoteadmin' then
if not is_support(msg.from.id) and not is_owner(msg) then
return
end
if type(msg.reply_id) ~= "nil" then
local cbreply_extra = {
get_cmd = 'demoteadmin',
msg = msg
}
demoteadmin = get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif matches[1] == 'demoteadmin' and string.match(matches[2], '^%d+$') then
local receiver = get_receiver(msg)
local user_id = "user#id"..matches[2]
local get_cmd = 'demoteadmin'
user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd})
elseif matches[1] == 'demoteadmin' and not string.match(matches[2], '^%d+$') then
local cbres_extra = {
channel = get_receiver(msg),
get_cmd = 'demoteadmin'
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted admin @"..username)
resolve_username(username, callbackres, cbres_extra)
end
end
if matches[1] == 'setowner' and is_owner(msg) then
if type(msg.reply_id) ~= "nil" then
local cbreply_extra = {
get_cmd = 'setowner',
msg = msg
}
setowner = get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif matches[1] == 'setowner' and string.match(matches[2], '^%d+$') then
--[[ local group_owner = data[tostring(msg.to.id)]['set_owner']
if group_owner then
local receiver = get_receiver(msg)
local user_id = "user#id"..group_owner
if not is_admin2(group_owner) and not is_support(group_owner) then
channel_demote(receiver, user_id, ok_cb, false)
end
local user = "user#id"..matches[2]
channel_set_admin(receiver, user, ok_cb, false)
data[tostring(msg.to.id)]['set_owner'] = tostring(matches[2])
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = "[ "..matches[2].." ] added as owner"
return text
end]]
local get_cmd = 'setowner'
local msg = msg
local user_id = matches[2]
channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id})
elseif matches[1] == 'setowner' and not string.match(matches[2], '^%d+$') then
local get_cmd = 'setowner'
local msg = msg
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username})
end
end
if matches[1] == 'promote' then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner/admin can promote"
end
if type(msg.reply_id) ~= "nil" then
local cbreply_extra = {
get_cmd = 'promote',
msg = msg
}
promote = get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif matches[1] == 'promote' and string.match(matches[2], '^%d+$') then
local receiver = get_receiver(msg)
local user_id = "user#id"..matches[2]
local get_cmd = 'promote'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted user#id"..matches[2])
user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd})
elseif matches[1] == 'promote' and not string.match(matches[2], '^%d+$') then
local cbres_extra = {
channel = get_receiver(msg),
get_cmd = 'promote',
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @"..username)
return resolve_username(username, callbackres, cbres_extra)
end
end
if matches[1] == 'mp' and is_sudo(msg) then
channel = get_receiver(msg)
user_id = 'user#id'..matches[2]
channel_set_mod(channel, user_id, ok_cb, false)
return "ok"
end
if matches[1] == 'md' and is_sudo(msg) then
channel = get_receiver(msg)
user_id = 'user#id'..matches[2]
channel_demote(channel, user_id, ok_cb, false)
return "ok"
end
if matches[1] == 'demote' then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner/support/admin can promote"
end
if type(msg.reply_id) ~= "nil" then
local cbreply_extra = {
get_cmd = 'demote',
msg = msg
}
demote = get_message(msg.reply_id, get_message_callback, cbreply_extra)
elseif matches[1] == 'demote' and string.match(matches[2], '^%d+$') then
local receiver = get_receiver(msg)
local user_id = "user#id"..matches[2]
local get_cmd = 'demote'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted user#id"..matches[2])
user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd})
elseif not string.match(matches[2], '^%d+$') then
local cbres_extra = {
channel = get_receiver(msg),
get_cmd = 'demote'
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @"..username)
return resolve_username(username, callbackres, cbres_extra)
end
end
if matches[1] == "setname" and is_momod(msg) then
local receiver = get_receiver(msg)
local set_name = string.gsub(matches[2], '_', '')
savelog(msg.to.id, name_log.." ["..msg.from.id.."] renamed SuperGroup to: "..matches[2])
rename_channel(receiver, set_name, ok_cb, false)
end
if msg.service and msg.action.type == 'chat_rename' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] renamed SuperGroup to: "..msg.to.title)
data[tostring(msg.to.id)]['settings']['set_name'] = msg.to.title
save_data(_config.moderation.data, data)
end
if matches[1] == "setabout" and is_momod(msg) then
local receiver = get_receiver(msg)
local about_text = matches[2]
local data_cat = 'description'
local target = msg.to.id
data[tostring(target)][data_cat] = about_text
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup description to: "..about_text)
channel_set_about(receiver, about_text, ok_cb, false)
return "Description has been set.\n\nSelect the chat again to see the changes."
end
if matches[1] == "setusername" and is_admin1(msg) then
local function ok_username_cb (extra, success, result)
local receiver = extra.receiver
if success == 1 then
send_large_msg(receiver, "SuperGroup username Set.\n\nSelect the chat again to see the changes.")
elseif success == 0 then
send_large_msg(receiver, "Failed to set SuperGroup username.\nUsername may already be taken.\n\nNote: Username can use a-z, 0-9 and underscores.\nMinimum length is 5 characters.")
end
end
local username = string.gsub(matches[2], '@', '')
channel_set_username(receiver, username, ok_username_cb, {receiver=receiver})
end
if matches[1] == 'setrules' and is_momod(msg) then
rules = matches[2]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[2].."]")
return set_rulesmod(msg, data, target)
end
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_momod(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set new SuperGroup photo")
load_photo(msg.id, set_supergroup_photo, msg)
return
end
end
if matches[1] == 'setphoto' and is_momod(msg) then
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] started setting new SuperGroup photo")
return 'Please send the new group photo now'
end
if matches[1] == 'clean' then
if not is_momod(msg) then
return
end
if not is_momod(msg) then
return "Only owner can clean"
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then
return 'No moderator(s) in this SuperGroup.'
end
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
return 'Modlist has been cleaned'
end
if matches[2] == 'rules' then
local data_cat = 'rules'
if data[tostring(msg.to.id)][data_cat] == nil then
return "Rules have not been set"
end
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
return 'Rules have been cleaned'
end
if matches[2] == 'about' then
local receiver = get_receiver(msg)
local about_text = ' '
local data_cat = 'description'
if data[tostring(msg.to.id)][data_cat] == nil then
return 'About is not set'
end
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
channel_set_about(receiver, about_text, ok_cb, false)
return "About has been cleaned"
end
if matches[2] == 'silentlist' then
chat_id = msg.to.id
local hash = 'mute_user:'..chat_id
redis:del(hash)
return "silentlist Cleaned"
end
if matches[2] == 'username' and is_admin1(msg) then
local function ok_username_cb (extra, success, result)
local receiver = extra.receiver
if success == 1 then
send_large_msg(receiver, "SuperGroup username cleaned.")
elseif success == 0 then
send_large_msg(receiver, "Failed to clean SuperGroup username.")
end
end
local username = ""
channel_set_username(receiver, username, ok_username_cb, {receiver=receiver})
end
end
if matches[1] == 'lock' and is_momod(msg) then
local target = msg.to.id
if matches[2] == 'all' then
local safemode ={
lock_group_links(msg, data, target),
lock_group_tag(msg, data, target),
lock_group_spam(msg, data, target),
lock_group_flood(msg, data, target),
lock_group_arabic(msg, data, target),
lock_group_membermod(msg, data, target),
lock_group_rtl(msg, data, target),
lock_group_tgservice(msg, data, target),
lock_group_sticker(msg, data, target),
lock_group_contacts(msg, data, target),
lock_group_english(msg, data, target),
lock_group_fwd(msg, data, target),
lock_group_reply(msg, data, target),
lock_group_join(msg, data, target),
lock_group_emoji(msg, data, target),
lock_group_username(msg, data, target),
lock_group_fosh(msg, data, target),
lock_group_media(msg, data, target),
lock_group_leave(msg, data, target),
lock_group_bots(msg, data, target),
lock_group_operator(msg, data, target),
}
return lock_group_all(msg, data, target), safemode
end
if matches[2] == 'etehad' then
local etehad ={
unlock_group_links(msg, data, target),
lock_group_tag(msg, data, target),
lock_group_spam(msg, data, target),
lock_group_flood(msg, data, target),
unlock_group_arabic(msg, data, target),
lock_group_membermod(msg, data, target),
unlock_group_rtl(msg, data, target),
lock_group_tgservice(msg, data, target),
lock_group_sticker(msg, data, target),
unlock_group_contacts(msg, data, target),
unlock_group_english(msg, data, target),
unlock_group_fwd(msg, data, target),
unlock_group_reply(msg, data, target),
lock_group_join(msg, data, target),
unlock_group_emoji(msg, data, target),
unlock_group_username(msg, data, target),
lock_group_fosh(msg, data, target),
unlock_group_media(msg, data, target),
lock_group_leave(msg, data, target),
lock_group_bots(msg, data, target),
unlock_group_operator(msg, data, target),
}
return lock_group_etehad(msg, data, target), etehad
end
if matches[2] == 'links' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked link posting ")
return lock_group_links(msg, data, target)
end
if matches[2] == 'join' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked join ")
return lock_group_join(msg, data, target)
end
if matches[2] == 'tag' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked tag ")
return lock_group_tag(msg, data, target)
end
if matches[2] == 'spam' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked spam ")
return lock_group_spam(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_flood(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2]:lower() == 'rtl' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked rtl chars. in names")
return lock_group_rtl(msg, data, target)
end
if matches[2] == 'tgservice' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked Tgservice Actions")
return lock_group_tgservice(msg, data, target)
end
if matches[2] == 'sticker' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked sticker posting")
return lock_group_sticker(msg, data, target)
end
if matches[2] == 'contacts' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked contact posting")
return lock_group_contacts(msg, data, target)
end
if matches[2] == 'strict' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked enabled strict settings")
return enable_strict_rules(msg, data, target)
end
if matches[2] == 'english' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked english")
return lock_group_english(msg, data, target)
end
if matches[2] == 'fwd' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked fwd")
return lock_group_fwd(msg, data, target)
end
if matches[2] == 'reply' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked reply")
return lock_group_reply(msg, data, target)
end
if matches[2] == 'emoji' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked emoji")
return lock_group_emoji(msg, data, target)
end
if matches[2] == 'fosh' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked fosh")
return lock_group_fosh(msg, data, target)
end
if matches[2] == 'media' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked media")
return lock_group_media(msg, data, target)
end
if matches[2] == 'username' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked username")
return lock_group_username(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leave")
return lock_group_leave(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots")
return lock_group_bots(msg, data, target)
end
if matches[2] == 'operator' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked operator")
return lock_group_operator(msg, data, target)
end
end
if matches[1] == 'unlock' and is_momod(msg) then
local target = msg.to.id
if matches[2] == 'all' then
local dsafemode ={
unlock_group_links(msg, data, target),
unlock_group_tag(msg, data, target),
unlock_group_spam(msg, data, target),
unlock_group_flood(msg, data, target),
unlock_group_arabic(msg, data, target),
unlock_group_membermod(msg, data, target),
unlock_group_rtl(msg, data, target),
unlock_group_tgservice(msg, data, target),
unlock_group_sticker(msg, data, target),
unlock_group_contacts(msg, data, target),
unlock_group_english(msg, data, target),
unlock_group_fwd(msg, data, target),
unlock_group_reply(msg, data, target),
unlock_group_join(msg, data, target),
unlock_group_emoji(msg, data, target),
unlock_group_username(msg, data, target),
unlock_group_fosh(msg, data, target),
unlock_group_media(msg, data, target),
unlock_group_leave(msg, data, target),
unlock_group_bots(msg, data, target),
unlock_group_operator(msg, data, target),
}
return unlock_group_all(msg, data, target), dsafemode
end
if matches[2] == 'etehad' then
local detehad ={
lock_group_links(msg, data, target),
unlock_group_tag(msg, data, target),
lock_group_spam(msg, data, target),
lock_group_flood(msg, data, target),
unlock_group_arabic(msg, data, target),
unlock_group_membermod(msg, data, target),
unlock_group_rtl(msg, data, target),
unlock_group_tgservice(msg, data, target),
unlock_group_sticker(msg, data, target),
unlock_group_contacts(msg, data, target),
unlock_group_english(msg, data, target),
unlock_group_fwd(msg, data, target),
unlock_group_reply(msg, data, target),
unlock_group_join(msg, data, target),
unlock_group_emoji(msg, data, target),
unlock_group_username(msg, data, target),
unlock_group_fosh(msg, data, target),
unlock_group_media(msg, data, target),
unlock_group_leave(msg, data, target),
unlock_group_bots(msg, data, target),
unlock_group_operator(msg, data, target),
}
return unlock_group_etehad(msg, data, target), detehad
end
if matches[2] == 'links' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked link posting")
return unlock_group_links(msg, data, target)
end
if matches[2] == 'join' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked join")
return unlock_group_join(msg, data, target)
end
if matches[2] == 'tag' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked tag")
return unlock_group_tag(msg, data, target)
end
if matches[2] == 'spam' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked spam")
return unlock_group_spam(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood")
return unlock_group_flood(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked Arabic")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2]:lower() == 'rtl' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked RTL chars. in names")
return unlock_group_rtl(msg, data, target)
end
if matches[2] == 'tgservice' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked tgservice actions")
return unlock_group_tgservice(msg, data, target)
end
if matches[2] == 'sticker' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked sticker posting")
return unlock_group_sticker(msg, data, target)
end
if matches[2] == 'contacts' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked contact posting")
return unlock_group_contacts(msg, data, target)
end
if matches[2] == 'strict' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked disabled strict settings")
return disable_strict_rules(msg, data, target)
end
if matches[2] == 'english' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked english")
return unlock_group_english(msg, data, target)
end
if matches[2] == 'fwd' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked fwd")
return unlock_group_fwd(msg, data, target)
end
if matches[2] == 'reply' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked reply")
return unlock_group_reply(msg, data, target)
end
if matches[2] == 'emoji' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked disabled emoji")
return unlock_group_emoji(msg, data, target)
end
if matches[2] == 'fosh' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked fosh")
return unlock_group_fosh(msg, data, target)
end
if matches[2] == 'media' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked media")
return unlock_group_media(msg, data, target)
end
if matches[2] == 'username' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked disabled username")
return unlock_group_username(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leave")
return unlock_group_leave(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots")
return unlock_group_bots(msg, data, target)
end
if matches[2] == 'operator' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked operator")
return unlock_group_operator(msg, data, target)
end
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return
end
if tonumber(matches[2]) < 1 or tonumber(matches[2]) > 200 then
return "Wrong number,range is [1-200]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Flood has been set to: '..matches[2]
end
if matches[1] == 'public' and is_momod(msg) then
local target = msg.to.id
if matches[2] == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public")
return set_public_membermod(msg, data, target)
end
if matches[2] == 'no' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: not public")
return unset_public_membermod(msg, data, target)
end
end
if matches[1] == 'mute' and is_owner(msg) then
local chat_id = msg.to.id
if matches[2] == 'audio' then
local msg_type = 'Audio'
if not is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type)
mute(chat_id, msg_type)
return msg_type.." has been muted"
else
return "SuperGroup mute "..msg_type.." is already on"
end
end
if matches[2] == 'photo' then
local msg_type = 'Photo'
if not is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type)
mute(chat_id, msg_type)
return msg_type.." has been muted"
else
return "SuperGroup mute "..msg_type.." is already on"
end
end
if matches[2] == 'video' then
local msg_type = 'Video'
if not is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type)
mute(chat_id, msg_type)
return msg_type.." has been muted"
else
return "SuperGroup mute "..msg_type.." is already on"
end
end
if matches[2] == 'gifs' then
local msg_type = 'Gifs'
if not is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type)
mute(chat_id, msg_type)
return msg_type.." have been muted"
else
return "SuperGroup mute "..msg_type.." is already on"
end
end
if matches[2] == 'documents' then
local msg_type = 'Documents'
if not is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type)
mute(chat_id, msg_type)
return msg_type.." have been muted"
else
return "SuperGroup mute "..msg_type.." is already on"
end
end
if matches[2] == 'text' then
local msg_type = 'Text'
if not is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type)
mute(chat_id, msg_type)
return msg_type.." has been muted"
else
return "Mute "..msg_type.." is already on"
end
end
if matches[2] == 'all' then
local msg_type = 'All'
if not is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type)
mute(chat_id, msg_type)
return "Mute "..msg_type.." has been enabled"
else
return "Mute "..msg_type.." is already on"
end
end
end
if matches[1] == 'unmute' and is_momod(msg) then
local chat_id = msg.to.id
if matches[2] == 'audio' then
local msg_type = 'Audio'
if is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type)
unmute(chat_id, msg_type)
return msg_type.." has been unmuted"
else
return "Mute "..msg_type.." is already off"
end
end
if matches[2] == 'photo' then
local msg_type = 'Photo'
if is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type)
unmute(chat_id, msg_type)
return msg_type.." has been unmuted"
else
return "Mute "..msg_type.." is already off"
end
end
if matches[2] == 'video' then
local msg_type = 'Video'
if is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type)
unmute(chat_id, msg_type)
return msg_type.." has been unmuted"
else
return "Mute "..msg_type.." is already off"
end
end
if matches[2] == 'gifs' then
local msg_type = 'Gifs'
if is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type)
unmute(chat_id, msg_type)
return msg_type.." have been unmuted"
else
return "Mute "..msg_type.." is already off"
end
end
if matches[2] == 'documents' then
local msg_type = 'Documents'
if is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type)
unmute(chat_id, msg_type)
return msg_type.." have been unmuted"
else
return "Mute "..msg_type.." is already off"
end
end
if matches[2] == 'text' then
local msg_type = 'Text'
if is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute message")
unmute(chat_id, msg_type)
return msg_type.." has been unmuted"
else
return "Mute text is already off"
end
end
if matches[2] == 'all' then
local msg_type = 'All'
if is_muted(chat_id, msg_type..': yes') then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type)
unmute(chat_id, msg_type)
return "Mute "..msg_type.." has been disabled"
else
return "Mute "..msg_type.." is already disabled"
end
end
end
if matches[1] == "silent" or matches[1] == "unsilent" and is_momod(msg) then
local chat_id = msg.to.id
local hash = "mute_user"..chat_id
local user_id = ""
if type(msg.reply_id) ~= "nil" then
local receiver = get_receiver(msg)
local get_cmd = "mute_user"
muteuser = get_message(msg.reply_id, get_message_callback, {receiver = receiver, get_cmd = get_cmd, msg = msg})
elseif matches[1] == "silent" or matches[1] == "unsilent" and string.match(matches[2], '^%d+$') then
local user_id = matches[2]
if is_muted_user(chat_id, user_id) then
unmute_user(chat_id, user_id)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] removed ["..user_id.."] from the muted users list")
return "["..user_id.."] removed from the muted users list"
elseif is_momod(msg) then
mute_user(chat_id, user_id)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] added ["..user_id.."] to the muted users list")
return "["..user_id.."] added to the muted user list"
end
elseif matches[1] == "silent" or matches[1] == "unsilent" and not string.match(matches[2], '^%d+$') then
local receiver = get_receiver(msg)
local get_cmd = "mute_user"
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
resolve_username(username, callbackres, {receiver = receiver, get_cmd = get_cmd, msg=msg})
end
end
if matches[1] == "muteslist" and is_momod(msg) then
local chat_id = msg.to.id
if not has_mutes(chat_id) then
set_mutes(chat_id)
return mutes_list(chat_id)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup muteslist")
return mutes_list(chat_id)
end
if matches[1] == "silentlist" and is_momod(msg) then
local chat_id = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup mutelist")
return muted_user_list(chat_id)
end
if matches[1] == 'settings' and is_momod(msg) then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup settings ")
return show_supergroup_settingsmod(msg, target)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'help' and not is_owner(msg) then
text = "Message /superhelp to @antispam_shield in private for SuperGroup help"
reply_msg(msg.id, text, ok_cb, false)
elseif matches[1] == 'help' and is_owner(msg) then
local name_log = user_print_name(msg.from)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /superhelp")
return super_help()
end
if matches[1] == 'peer_id' and is_admin1(msg)then
text = msg.to.peer_id
reply_msg(msg.id, text, ok_cb, false)
post_large_msg(receiver, text)
end
if matches[1] == 'msg.to.id' and is_admin1(msg) then
text = msg.to.id
reply_msg(msg.id, text, ok_cb, false)
post_large_msg(receiver, text)
end
--Admin Join Service Message
if msg.service then
local action = msg.action.type
if action == 'chat_add_user_link' then
if is_owner2(msg.from.id) then
local receiver = get_receiver(msg)
local user = "user#id"..msg.from.id
savelog(msg.to.id, name_log.." Admin ["..msg.from.id.."] joined the SuperGroup via link")
channel_set_admin(receiver, user, ok_cb, false)
end
if is_support(msg.from.id) and not is_owner2(msg.from.id) then
local receiver = get_receiver(msg)
local user = "user#id"..msg.from.id
savelog(msg.to.id, name_log.." Support member ["..msg.from.id.."] joined the SuperGroup")
channel_set_mod(receiver, user, ok_cb, false)
end
end
if action == 'chat_add_user' then
if is_owner2(msg.action.user.id) then
local receiver = get_receiver(msg)
local user = "user#id"..msg.action.user.id
savelog(msg.to.id, name_log.." Admin ["..msg.action.user.id.."] added to the SuperGroup by [ "..msg.from.id.." ]")
channel_set_admin(receiver, user, ok_cb, false)
end
if is_support(msg.action.user.id) and not is_owner2(msg.action.user.id) then
local receiver = get_receiver(msg)
local user = "user#id"..msg.action.user.id
savelog(msg.to.id, name_log.." Support member ["..msg.action.user.id.."] added to the SuperGroup by [ "..msg.from.id.." ]")
channel_set_mod(receiver, user, ok_cb, false)
end
end
end
if matches[1] == 'msg.to.peer_id' then
post_large_msg(receiver, msg.to.peer_id)
end
end
end
local function pre_process(msg)
if not msg.text and msg.media then
msg.text = '['..msg.media.type..']'
end
return msg
end
return {
patterns = {
"^[#!/]([Aa]dd)$",
"^[#!/]([Rr]em)$",
"^[#!/]([Mm]ove) (.*)$",
"^[#!/]([Gg]pinfo)$",
"^[#!/]([Aa]dmins)$",
"^[#!/]([Oo]wner)$",
"^[#!/]([Mm]odlist)$",
"^[#!/]([Bb]ots)$",
"^[#!/]([Ww]ho)$",
"^[#!/]([Kk]icked)$",
"^[#!/]([Bb]lock) (.*)",
"^[#!/]([Bb]lock)",
"^[#!/]([Kk]ick) (.*)",
"^[#!/]([Kk]ick)",
"^[#!/]([Tt]osuper)$",
"^[#!/]([Ii][Dd])$",
"^[#!/]([Ii][Dd]) (.*)$",
"^[#!/]([Kk]ickme)$",
"^[#!/]([Nn]ewlink)$",
"^[#!/]([Ss]etlink)$",
"^[#!/]([Ll]ink)$",
"^[#!/]([Rr]es) (.*)$",
"^[#!/]([Ss]etadmin) (.*)$",
"^[#!/]([Ss]etadmin)",
"^[#!/]([Dd]emoteadmin) (.*)$",
"^[#!/]([Dd]emoteadmin)",
"^[#!/]([Ss]etowner) (.*)$",
"^[#!/]([Ss]etowner)$",
"^[#!/]([Pp]romote) (.*)$",
"^[#!/]([Pp]romote)",
"^[#!/]([Dd]emote) (.*)$",
"^[#!/]([Dd]emote)",
"^[#!/]([Ss]etname) (.*)$",
"^[#!/]([Ss]etabout) (.*)$",
"^[#!/]([Ss]etrules) (.*)$",
"^[#!/]([Ss]etphoto)$",
"^[#!/]([Ss]etusername) (.*)$",
"^[#!/]([Dd]el)$",
"^[#!/]([Ll]ock) (.*)$",
"^[#!/]([Uu]nlock) (.*)$",
"^[#!/]([Mm]ute) ([^%s]+)$",
"^[#!/]([Uu]nmute) ([^%s]+)$",
"^[#!/]([Ss]ilent)$",
"^[#!/]([Ss]ilent) (.*)$",
"^[#!/]([Uu]nsilent)$",
"^[#!/]([Uu]nsilent) (.*)$",
"^[#!/]([Pp]ublic) (.*)$",
"^[#!/]([Ss]ettings)$",
"^[#!/]([Rr]ules)$",
"^[#!/]([Ss]etflood) (%d+)$",
"^[#!/]([Cc]lean) (.*)$",
"^[#!/]([Hh]elp)$",
"^[#!/]([Mm]uteslist)$",
"^[#!/]([Ss]ilentlist)$",
"[#!/](mp) (.*)",
"[#!/](md) (.*)",
"^(https://telegram.me/joinchat/%S+)$",
"msg.to.peer_id",
"%[(document)%]",
"%[(photo)%]",
"%[(video)%]",
"%[(audio)%]",
"%[(contact)%]",
"^!!tgservice (.+)$",
},
run = run,
pre_process = pre_process
}
| gpl-2.0 |
lichtl/darkstar | scripts/zones/Abyssea-Grauberg/Zone.lua | 33 | 1488 | -----------------------------------
--
-- Zone: Abyssea - Grauberg
--
-----------------------------------
package.loaded["scripts/zones/Abyssea-Grauberg/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Abyssea-Grauberg/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-555,31,-760,0);
end
if (player:getQuestStatus(ABYSSEA, THE_TRUTH_BECKONS) == QUEST_ACCEPTED
and player:getVar("1stTimeAyssea") == 0) then
player:setVar("1stTimeAyssea",1);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/effects/tabula_rasa.lua | 12 | 3502 | -----------------------------------
--
--
--
-----------------------------------
function onEffectGain(target,effect)
local regen = effect:getSubPower()
local helix = effect:getPower()
if (target:hasStatusEffect(dsp.effect.LIGHT_ARTS) or target:hasStatusEffect(dsp.effect.ADDENDUM_WHITE)) then
target:addMod(dsp.mod.BLACK_MAGIC_COST, -30)
target:addMod(dsp.mod.BLACK_MAGIC_CAST, -30)
target:addMod(dsp.mod.BLACK_MAGIC_RECAST, -30)
target:addMod(dsp.mod.LIGHT_ARTS_REGEN, math.ceil(regen/1.5))
target:addMod(dsp.mod.REGEN_DURATION, math.ceil((regen*2)/1.5))
target:addMod(dsp.mod.HELIX_EFFECT, helix)
target:addMod(dsp.mod.HELIX_DURATION, 108)
elseif (target:hasStatusEffect(dsp.effect.DARK_ARTS) or target:hasStatusEffect(dsp.effect.ADDENDUM_BLACK)) then
target:addMod(dsp.mod.WHITE_MAGIC_COST, -30)
target:addMod(dsp.mod.WHITE_MAGIC_CAST, -30)
target:addMod(dsp.mod.WHITE_MAGIC_RECAST, -30)
target:addMod(dsp.mod.LIGHT_ARTS_REGEN, regen)
target:addMod(dsp.mod.REGEN_DURATION, regen*2)
target:addMod(dsp.mod.HELIX_EFFECT, math.ceil(helix/1.5))
target:addMod(dsp.mod.HELIX_DURATION, 36)
else
target:addMod(dsp.mod.BLACK_MAGIC_COST, -10)
target:addMod(dsp.mod.BLACK_MAGIC_CAST, -10)
target:addMod(dsp.mod.BLACK_MAGIC_RECAST, -10)
target:addMod(dsp.mod.WHITE_MAGIC_COST, -10)
target:addMod(dsp.mod.WHITE_MAGIC_CAST, -10)
target:addMod(dsp.mod.WHITE_MAGIC_RECAST, -10)
target:addMod(dsp.mod.LIGHT_ARTS_REGEN, regen)
target:addMod(dsp.mod.REGEN_DURATION, regen*2)
target:addMod(dsp.mod.HELIX_EFFECT, helix)
target:addMod(dsp.mod.HELIX_DURATION, 108)
end
end
function onEffectTick(target,effect)
end
function onEffectLose(target,effect)
local regen = effect:getSubPower()
local helix = effect:getPower()
if (target:hasStatusEffect(dsp.effect.LIGHT_ARTS) or target:hasStatusEffect(dsp.effect.ADDENDUM_WHITE)) then
target:delMod(dsp.mod.BLACK_MAGIC_COST, -30)
target:delMod(dsp.mod.BLACK_MAGIC_CAST, -30)
target:delMod(dsp.mod.BLACK_MAGIC_RECAST, -30)
target:delMod(dsp.mod.LIGHT_ARTS_REGEN, math.ceil(regen/1.5))
target:delMod(dsp.mod.REGEN_DURATION, math.ceil((regen*2)/1.5))
target:delMod(dsp.mod.HELIX_EFFECT, helix)
target:delMod(dsp.mod.HELIX_DURATION, 108)
elseif (target:hasStatusEffect(dsp.effect.DARK_ARTS) or target:hasStatusEffect(dsp.effect.ADDENDUM_BLACK)) then
target:delMod(dsp.mod.WHITE_MAGIC_COST, -30)
target:delMod(dsp.mod.WHITE_MAGIC_CAST, -30)
target:delMod(dsp.mod.WHITE_MAGIC_RECAST, -30)
target:delMod(dsp.mod.LIGHT_ARTS_REGEN, regen)
target:delMod(dsp.mod.REGEN_DURATION, regen*2)
target:delMod(dsp.mod.HELIX_EFFECT, math.ceil(helix/1.5))
target:delMod(dsp.mod.HELIX_DURATION, 36)
else
target:delMod(dsp.mod.BLACK_MAGIC_COST, -10)
target:delMod(dsp.mod.BLACK_MAGIC_CAST, -10)
target:delMod(dsp.mod.BLACK_MAGIC_RECAST, -10)
target:delMod(dsp.mod.WHITE_MAGIC_COST, -10)
target:delMod(dsp.mod.WHITE_MAGIC_CAST, -10)
target:delMod(dsp.mod.WHITE_MAGIC_RECAST, -10)
target:delMod(dsp.mod.LIGHT_ARTS_REGEN, regen)
target:delMod(dsp.mod.REGEN_DURATION, regen*2)
target:delMod(dsp.mod.HELIX_EFFECT, helix)
target:delMod(dsp.mod.HELIX_DURATION, 108)
end
end | gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/West_Ronfaure/IDs.lua | 8 | 3945 | -----------------------------------
-- Area: West_Ronfaure
-----------------------------------
require("scripts/globals/zone")
-----------------------------------
zones = zones or {}
zones[dsp.zone.WEST_RONFAURE] =
{
text =
{
ITEM_CANNOT_BE_OBTAINED = 6404, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6410, -- Obtained: <item>.
GIL_OBTAINED = 6411, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6413, -- Obtained key item: <keyitem>.
KEYITEM_LOST = 6414, -- Lost key item: <keyitem>.
CONQUEST_BASE = 7071, -- Tallying conquest results...
FISHING_MESSAGE_OFFSET = 7230, -- You can't fish here.
DIG_THROW_AWAY = 7243, -- You dig up <item>, but your inventory is full. You regretfully throw the <item> away.
FIND_NOTHING = 7245, -- You dig and you dig, but find nothing.
GACHEMAGE_DIALOG = 7331, -- Orcish scouts lurk in the shadows. Consider yourself warned!
COLMAIE_DIALOG = 7331, -- Orcish scouts lurk in the shadows. Consider yourself warned!
ADALEFONT_DIALOG = 7332, -- If you sense danger, just flee into the city. I'll not endanger myself on your account!
LAILLERA_DIALOG = 7333, -- I mustn't chat while on duty. Sorry.
PICKPOCKET_GACHEMAGE = 7334, -- A pickpocket? Now that you mention it, I did see a woman flee the city. She ran west.
PICKPOCKET_ADALEFONT = 7335, -- What, someone picked your pocket? And you call yourself an adventurer!
PALCOMONDAU_REPORT = 7377, -- Scout reporting! All is quiet on the road to Ghelsba!
PALCOMONDAU_DIALOG = 7378, -- Let me be! I must patrol the road to Ghelsba.
ZOVRIACE_REPORT = 7380, -- Scout reporting! All is quiet on the roads to La Theine!
ZOVRIACE_DIALOG = 7382, -- Let me be! I return to Southgate with word on La Theine.
DISMAYED_CUSTOMER = 7408, -- You find some worthless scraps of paper.
CONQUEST = 7530, -- You've earned conquest points!
PLAYER_OBTAINS_ITEM = 8048, -- <name> obtains <item>!
UNABLE_TO_OBTAIN_ITEM = 8049, -- You were unable to obtain the item.
PLAYER_OBTAINS_TEMP_ITEM = 8050, -- <name> obtains the temporary item: <item>!
ALREADY_POSSESS_TEMP = 8051, -- You already possess that temporary item.
NO_COMBINATION = 8056, -- You were unable to enter a combination.
REGIME_REGISTERED = 10421, -- New training regime registered!
COMMON_SENSE_SURVIVAL = 12422, -- It appears that you have arrived at a new survival guide provided by the Adventurers' Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
},
mob =
{
FUNGUS_BEETLE_PH =
{
[17187046] = 17187047, -- -133.001 -20.636 -141.110
[17187115] = 17187047, -- -287.202 -20.826 -199.075
[17187114] = 17187047, -- -295.626 -21.389 -192.191
},
JAGGEDY_EARED_JACK_PH =
{
[17187110] = 17187111, -- -262.780 -22.384 -253.873
[17187109] = 17187111, -- -267.389 -21.669 -252.720
[17187108] = 17187111, -- -273.558 -19.943 -284.081
[17187042] = 17187111, -- -248.681 -21.336 -163.987
[17187154] = 17187111, -- -329.892 -9.702 -313.713
[17187152] = 17187111, -- -278.421 -11.691 -351.425
[17187132] = 17187111, -- -204.492 -20.754 -324.770
},
MARAUDER_DVOGZOG = 17187273,
},
npc =
{
CASKET_BASE = 17187500,
SIGNPOST_OFFSET = 17187538,
OVERSEER_BASE = 17187558,
},
}
return zones[dsp.zone.WEST_RONFAURE]
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Port_Jeuno/npcs/Challoux.lua | 17 | 1132 | -----------------------------------
-- Area: Port Jeuno
-- NPC: Challoux
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil;
require("scripts/zones/Port_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,CHALLOUX_SHOP_DIALOG);
stock = {0x11C1,62, --Gysahl Greens
0x0348,4, --Chocobo Feather
0x439B,9} --Dart
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Abyssea-Vunkerl/npcs/qm11.lua | 14 | 1345 | -----------------------------------
-- Zone: Abyssea-Vunkerl
-- NPC: qm11 (???)
-- Spawns Pascerpot
-- @pos ? ? ? 217
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
--[[
if (trade:hasItemQty(3108,1) and trade:getItemCount() == 1) then -- Player has all the required items.
if (GetMobAction(17666497) == ACTION_NONE) then -- Mob not already spawned from this
SpawnMob(17666497):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe)
player:tradeComplete();
end
end
]]
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(1010, 3108); -- Inform player what items they need.
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/Norg/npcs/_700.lua | 9 | 2624 | -----------------------------------
-- Area: Norg
-- NPC: Oaken door (Gilgamesh's room)
-- !pos 97 -7 -12 252
-----------------------------------
require("scripts/globals/missions");
require("scripts/globals/settings");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local ZilartMission = player:getCurrentMission(ZILART);
local currentMission = player:getCurrentMission(BASTOK);
local ZilartStatus = player:getCharVar("ZilartStatus");
-- Checked here to be fair to new players
local DMEarrings = 0;
for i=14739, 14743 do
if (player:hasItem(i)) then
DMEarrings = DMEarrings + 1;
end
end
if (ZilartMission == dsp.mission.id.zilart.WELCOME_TNORG) then
player:startEvent(2); -- Zilart Missions 2
elseif (ZilartMission == dsp.mission.id.zilart.ROMAEVE and player:getCharVar("ZilartStatus") <= 1) then
player:startEvent(3); -- Zilart Missions 9
elseif (ZilartMission == dsp.mission.id.zilart.THE_HALL_OF_THE_GODS) then
player:startEvent(169); -- Zilart Missions 11
elseif (currentMission == dsp.mission.id.bastok.THE_PIRATE_S_COVE and player:getCharVar("MissionStatus") == 1) then
player:startEvent(98); -- Bastok Mission 6-2
elseif (ZilartMission == dsp.mission.id.zilart.THE_SEALED_SHRINE and ZilartStatus == 0 and DMEarrings <= NUMBER_OF_DM_EARRINGS) then
player:startEvent(172);
else
player:startEvent(5);
end
return 1;
end;
-- 175 5 2 3 169 172 206 235
-- 175 0 2 3 4 7 8 9 10 98 99 29 12 13
-- 146 158 164 169 170 171 172 173 176 177 232 233 234
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 2 and option == 0) then
player:completeMission(ZILART,dsp.mission.id.zilart.WELCOME_TNORG);
player:addMission(ZILART,dsp.mission.id.zilart.KAZAMS_CHIEFTAINESS);
elseif (csid == 3 and option == 0) then
player:setCharVar("ZilartStatus",0);
player:completeMission(ZILART,dsp.mission.id.zilart.ROMAEVE);
player:addMission(ZILART,dsp.mission.id.zilart.THE_TEMPLE_OF_DESOLATION);
elseif (csid == 169 and option == 0) then
player:completeMission(ZILART,dsp.mission.id.zilart.THE_HALL_OF_THE_GODS);
player:addMission(ZILART,dsp.mission.id.zilart.THE_MITHRA_AND_THE_CRYSTAL);
elseif (csid == 98) then
player:setCharVar("MissionStatus",2);
elseif (csid == 172 and bit.band(option, 0x40000000) == 0) then
player:setCharVar("ZilartStatus",1);
end
end; | gpl-3.0 |
lichtl/darkstar | scripts/globals/items/kalamar.lua | 18 | 1307 | -----------------------------------------
-- ID: 5448
-- Item: Kalamar
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity 3
-- Mind -5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0
if (target:getRace() ~= 7) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_FISH) == 1) then
result = 0;
end
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5448);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 3);
target:addMod(MOD_MND, -5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 3);
target:delMod(MOD_MND, -5);
end;
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Valkurm_Dunes/npcs/Fighting_Ant_IM.lua | 14 | 3326 | -----------------------------------
-- Area: Valkurm Dunes
-- NPC: Fighting Ant, I.M.
-- Border Conquest Guards
-- @pos 908.245 -1.171 -411.504 103
-----------------------------------
package.loaded["scripts/zones/Valkurm_Dunes/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Valkurm_Dunes/TextIDs");
local guardnation = NATION_BASTOK; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = ZULKHEIM;
local csid = 0x7ff8;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
taiha/luci | modules/luci-base/luasrc/model/network.lua | 4 | 36490 | -- Copyright 2009-2015 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
local type, next, pairs, ipairs, loadfile, table, select
= type, next, pairs, ipairs, loadfile, table, select
local tonumber, tostring, math = tonumber, tostring, math
local require = require
local nxo = require "nixio"
local nfs = require "nixio.fs"
local ipc = require "luci.ip"
local sys = require "luci.sys"
local utl = require "luci.util"
local dsp = require "luci.dispatcher"
local uci = require "luci.model.uci"
local lng = require "luci.i18n"
local jsc = require "luci.jsonc"
module "luci.model.network"
IFACE_PATTERNS_VIRTUAL = { }
IFACE_PATTERNS_IGNORE = { "^wmaster%d", "^wifi%d", "^hwsim%d", "^imq%d", "^ifb%d", "^mon%.wlan%d", "^sit%d", "^gre%d", "^gretap%d", "^ip6gre%d", "^ip6tnl%d", "^tunl%d", "^lo$" }
IFACE_PATTERNS_WIRELESS = { "^wlan%d", "^wl%d", "^ath%d", "^%w+%.network%d" }
protocol = utl.class()
local _protocols = { }
local _interfaces, _bridge, _switch, _tunnel, _swtopo
local _ubusnetcache, _ubusdevcache, _ubuswificache
local _uci
function _filter(c, s, o, r)
local val = _uci:get(c, s, o)
if val then
local l = { }
if type(val) == "string" then
for val in val:gmatch("%S+") do
if val ~= r then
l[#l+1] = val
end
end
if #l > 0 then
_uci:set(c, s, o, table.concat(l, " "))
else
_uci:delete(c, s, o)
end
elseif type(val) == "table" then
for _, val in ipairs(val) do
if val ~= r then
l[#l+1] = val
end
end
if #l > 0 then
_uci:set(c, s, o, l)
else
_uci:delete(c, s, o)
end
end
end
end
function _append(c, s, o, a)
local val = _uci:get(c, s, o) or ""
if type(val) == "string" then
local l = { }
for val in val:gmatch("%S+") do
if val ~= a then
l[#l+1] = val
end
end
l[#l+1] = a
_uci:set(c, s, o, table.concat(l, " "))
elseif type(val) == "table" then
local l = { }
for _, val in ipairs(val) do
if val ~= a then
l[#l+1] = val
end
end
l[#l+1] = a
_uci:set(c, s, o, l)
end
end
function _stror(s1, s2)
if not s1 or #s1 == 0 then
return s2 and #s2 > 0 and s2
else
return s1
end
end
function _get(c, s, o)
return _uci:get(c, s, o)
end
function _set(c, s, o, v)
if v ~= nil then
if type(v) == "boolean" then v = v and "1" or "0" end
return _uci:set(c, s, o, v)
else
return _uci:delete(c, s, o)
end
end
function _wifi_iface(x)
local _, p
for _, p in ipairs(IFACE_PATTERNS_WIRELESS) do
if x:match(p) then
return true
end
end
return false
end
function _wifi_state(key, val, field)
local radio, radiostate, ifc, ifcstate
if not next(_ubuswificache) then
_ubuswificache = utl.ubus("network.wireless", "status", {}) or {}
-- workaround extended section format
for radio, radiostate in pairs(_ubuswificache) do
for ifc, ifcstate in pairs(radiostate.interfaces) do
if ifcstate.section and ifcstate.section:sub(1, 1) == '@' then
local s = _uci:get_all('wireless.%s' % ifcstate.section)
if s then
ifcstate.section = s['.name']
end
end
end
end
end
for radio, radiostate in pairs(_ubuswificache) do
for ifc, ifcstate in pairs(radiostate.interfaces) do
if ifcstate[key] == val then
return ifcstate[field]
end
end
end
end
function _wifi_lookup(ifn)
-- got a radio#.network# pseudo iface, locate the corresponding section
local radio, ifnidx = ifn:match("^(%w+)%.network(%d+)$")
if radio and ifnidx then
local sid = nil
local num = 0
ifnidx = tonumber(ifnidx)
_uci:foreach("wireless", "wifi-iface",
function(s)
if s.device == radio then
num = num + 1
if num == ifnidx then
sid = s['.name']
return false
end
end
end)
return sid
-- looks like wifi, try to locate the section via ubus state
elseif _wifi_iface(ifn) then
return _wifi_state("ifname", ifn, "section")
end
end
function _iface_virtual(x)
local _, p
for _, p in ipairs(IFACE_PATTERNS_VIRTUAL) do
if x:match(p) then
return true
end
end
return false
end
function _iface_ignore(x)
local _, p
for _, p in ipairs(IFACE_PATTERNS_IGNORE) do
if x:match(p) then
return true
end
end
return false
end
function init(cursor)
_uci = cursor or _uci or uci.cursor()
_interfaces = { }
_bridge = { }
_switch = { }
_tunnel = { }
_swtopo = { }
_ubusnetcache = { }
_ubusdevcache = { }
_ubuswificache = { }
-- read interface information
local n, i
for n, i in ipairs(nxo.getifaddrs()) do
local name = i.name:match("[^:]+")
if _iface_virtual(name) then
_tunnel[name] = true
end
if _tunnel[name] or not (_iface_ignore(name) or _iface_virtual(name)) then
_interfaces[name] = _interfaces[name] or {
idx = i.ifindex or n,
name = name,
rawname = i.name,
flags = { },
ipaddrs = { },
ip6addrs = { }
}
if i.family == "packet" then
_interfaces[name].flags = i.flags
_interfaces[name].stats = i.data
_interfaces[name].macaddr = i.addr
elseif i.family == "inet" then
_interfaces[name].ipaddrs[#_interfaces[name].ipaddrs+1] = ipc.IPv4(i.addr, i.netmask)
elseif i.family == "inet6" then
_interfaces[name].ip6addrs[#_interfaces[name].ip6addrs+1] = ipc.IPv6(i.addr, i.netmask)
end
end
end
-- read bridge informaton
local b, l
for l in utl.execi("brctl show") do
if not l:match("STP") then
local r = utl.split(l, "%s+", nil, true)
if #r == 4 then
b = {
name = r[1],
id = r[2],
stp = r[3] == "yes",
ifnames = { _interfaces[r[4]] }
}
if b.ifnames[1] then
b.ifnames[1].bridge = b
end
_bridge[r[1]] = b
elseif b then
b.ifnames[#b.ifnames+1] = _interfaces[r[2]]
b.ifnames[#b.ifnames].bridge = b
end
end
end
-- read switch topology
local boardinfo = jsc.parse(nfs.readfile("/etc/board.json") or "")
if type(boardinfo) == "table" and type(boardinfo.switch) == "table" then
local switch, layout
for switch, layout in pairs(boardinfo.switch) do
if type(layout) == "table" and type(layout.ports) == "table" then
local _, port
local ports = { }
local nports = { }
local netdevs = { }
for _, port in ipairs(layout.ports) do
if type(port) == "table" and
type(port.num) == "number" and
(type(port.role) == "string" or
type(port.device) == "string")
then
local spec = {
num = port.num,
role = port.role or "cpu",
index = port.index or port.num
}
if port.device then
spec.device = port.device
spec.tagged = port.need_tag
netdevs[tostring(port.num)] = port.device
end
ports[#ports+1] = spec
if port.role then
nports[port.role] = (nports[port.role] or 0) + 1
end
end
end
table.sort(ports, function(a, b)
if a.role ~= b.role then
return (a.role < b.role)
end
return (a.index < b.index)
end)
local pnum, role
for _, port in ipairs(ports) do
if port.role ~= role then
role = port.role
pnum = 1
end
if role == "cpu" then
port.label = "CPU (%s)" % port.device
elseif nports[role] > 1 then
port.label = "%s %d" %{ role:upper(), pnum }
pnum = pnum + 1
else
port.label = role:upper()
end
port.role = nil
port.index = nil
end
_swtopo[switch] = {
ports = ports,
netdevs = netdevs
}
end
end
end
return _M
end
function save(self, ...)
_uci:save(...)
_uci:load(...)
end
function commit(self, ...)
_uci:commit(...)
_uci:load(...)
end
function ifnameof(self, x)
if utl.instanceof(x, interface) then
return x:name()
elseif utl.instanceof(x, protocol) then
return x:ifname()
elseif type(x) == "string" then
return x:match("^[^:]+")
end
end
function get_protocol(self, protoname, netname)
local v = _protocols[protoname]
if v then
return v(netname or "__dummy__")
end
end
function get_protocols(self)
local p = { }
local _, v
for _, v in ipairs(_protocols) do
p[#p+1] = v("__dummy__")
end
return p
end
function register_protocol(self, protoname)
local proto = utl.class(protocol)
function proto.__init__(self, name)
self.sid = name
end
function proto.proto(self)
return protoname
end
_protocols[#_protocols+1] = proto
_protocols[protoname] = proto
return proto
end
function register_pattern_virtual(self, pat)
IFACE_PATTERNS_VIRTUAL[#IFACE_PATTERNS_VIRTUAL+1] = pat
end
function has_ipv6(self)
return nfs.access("/proc/net/ipv6_route")
end
function add_network(self, n, options)
local oldnet = self:get_network(n)
if n and #n > 0 and n:match("^[a-zA-Z0-9_]+$") and not oldnet then
if _uci:section("network", "interface", n, options) then
return network(n)
end
elseif oldnet and oldnet:is_empty() then
if options then
local k, v
for k, v in pairs(options) do
oldnet:set(k, v)
end
end
return oldnet
end
end
function get_network(self, n)
if n and _uci:get("network", n) == "interface" then
return network(n)
end
end
function get_networks(self)
local nets = { }
local nls = { }
_uci:foreach("network", "interface",
function(s)
nls[s['.name']] = network(s['.name'])
end)
local n
for n in utl.kspairs(nls) do
nets[#nets+1] = nls[n]
end
return nets
end
function del_network(self, n)
local r = _uci:delete("network", n)
if r then
_uci:delete_all("network", "alias",
function(s) return (s.interface == n) end)
_uci:delete_all("network", "route",
function(s) return (s.interface == n) end)
_uci:delete_all("network", "route6",
function(s) return (s.interface == n) end)
_uci:foreach("wireless", "wifi-iface",
function(s)
local net
local rest = { }
for net in utl.imatch(s.network) do
if net ~= n then
rest[#rest+1] = net
end
end
if #rest > 0 then
_uci:set("wireless", s['.name'], "network",
table.concat(rest, " "))
else
_uci:delete("wireless", s['.name'], "network")
end
end)
end
return r
end
function rename_network(self, old, new)
local r
if new and #new > 0 and new:match("^[a-zA-Z0-9_]+$") and not self:get_network(new) then
r = _uci:section("network", "interface", new, _uci:get_all("network", old))
if r then
_uci:foreach("network", "alias",
function(s)
if s.interface == old then
_uci:set("network", s['.name'], "interface", new)
end
end)
_uci:foreach("network", "route",
function(s)
if s.interface == old then
_uci:set("network", s['.name'], "interface", new)
end
end)
_uci:foreach("network", "route6",
function(s)
if s.interface == old then
_uci:set("network", s['.name'], "interface", new)
end
end)
_uci:foreach("wireless", "wifi-iface",
function(s)
local net
local list = { }
for net in utl.imatch(s.network) do
if net == old then
list[#list+1] = new
else
list[#list+1] = net
end
end
if #list > 0 then
_uci:set("wireless", s['.name'], "network",
table.concat(list, " "))
end
end)
_uci:delete("network", old)
end
end
return r or false
end
function get_interface(self, i)
if _interfaces[i] or _wifi_iface(i) then
return interface(i)
else
local ifc
local num = { }
_uci:foreach("wireless", "wifi-iface",
function(s)
if s.device then
num[s.device] = num[s.device] and num[s.device] + 1 or 1
if s['.name'] == i then
ifc = interface(
"%s.network%d" %{s.device, num[s.device] })
return false
end
end
end)
return ifc
end
end
function get_interfaces(self)
local iface
local ifaces = { }
local nfs = { }
-- find normal interfaces
_uci:foreach("network", "interface",
function(s)
for iface in utl.imatch(s.ifname) do
if not _iface_ignore(iface) and not _iface_virtual(iface) and not _wifi_iface(iface) then
nfs[iface] = interface(iface)
end
end
end)
for iface in utl.kspairs(_interfaces) do
if not (nfs[iface] or _iface_ignore(iface) or _iface_virtual(iface) or _wifi_iface(iface)) then
nfs[iface] = interface(iface)
end
end
-- find vlan interfaces
_uci:foreach("network", "switch_vlan",
function(s)
if type(s.ports) ~= "string" or
type(s.device) ~= "string" or
type(_swtopo[s.device]) ~= "table"
then
return
end
local pnum, ptag
for pnum, ptag in s.ports:gmatch("(%d+)([tu]?)") do
local netdev = _swtopo[s.device].netdevs[pnum]
if netdev then
if not nfs[netdev] then
nfs[netdev] = interface(netdev)
end
_switch[netdev] = true
if ptag == "t" then
local vid = tonumber(s.vid or s.vlan)
if vid ~= nil and vid >= 0 and vid <= 4095 then
local iface = "%s.%d" %{ netdev, vid }
if not nfs[iface] then
nfs[iface] = interface(iface)
end
_switch[iface] = true
end
end
end
end
end)
for iface in utl.kspairs(nfs) do
ifaces[#ifaces+1] = nfs[iface]
end
-- find wifi interfaces
local num = { }
local wfs = { }
_uci:foreach("wireless", "wifi-iface",
function(s)
if s.device then
num[s.device] = num[s.device] and num[s.device] + 1 or 1
local i = "%s.network%d" %{ s.device, num[s.device] }
wfs[i] = interface(i)
end
end)
for iface in utl.kspairs(wfs) do
ifaces[#ifaces+1] = wfs[iface]
end
return ifaces
end
function ignore_interface(self, x)
return _iface_ignore(x)
end
function get_wifidev(self, dev)
if _uci:get("wireless", dev) == "wifi-device" then
return wifidev(dev)
end
end
function get_wifidevs(self)
local devs = { }
local wfd = { }
_uci:foreach("wireless", "wifi-device",
function(s) wfd[#wfd+1] = s['.name'] end)
local dev
for _, dev in utl.vspairs(wfd) do
devs[#devs+1] = wifidev(dev)
end
return devs
end
function get_wifinet(self, net)
local wnet = _wifi_lookup(net)
if wnet then
return wifinet(wnet)
end
end
function add_wifinet(self, net, options)
if type(options) == "table" and options.device and
_uci:get("wireless", options.device) == "wifi-device"
then
local wnet = _uci:section("wireless", "wifi-iface", nil, options)
return wifinet(wnet)
end
end
function del_wifinet(self, net)
local wnet = _wifi_lookup(net)
if wnet then
_uci:delete("wireless", wnet)
return true
end
return false
end
function get_status_by_route(self, addr, mask)
local _, object
for _, object in ipairs(utl.ubus()) do
local net = object:match("^network%.interface%.(.+)")
if net then
local s = utl.ubus(object, "status", {})
if s and s.route then
local rt
for _, rt in ipairs(s.route) do
if not rt.table and rt.target == addr and rt.mask == mask then
return net, s
end
end
end
end
end
end
function get_status_by_address(self, addr)
local _, object
for _, object in ipairs(utl.ubus()) do
local net = object:match("^network%.interface%.(.+)")
if net then
local s = utl.ubus(object, "status", {})
if s and s['ipv4-address'] then
local a
for _, a in ipairs(s['ipv4-address']) do
if a.address == addr then
return net, s
end
end
end
if s and s['ipv6-address'] then
local a
for _, a in ipairs(s['ipv6-address']) do
if a.address == addr then
return net, s
end
end
end
end
end
end
function get_wannet(self)
local net, stat = self:get_status_by_route("0.0.0.0", 0)
return net and network(net, stat.proto)
end
function get_wandev(self)
local _, stat = self:get_status_by_route("0.0.0.0", 0)
return stat and interface(stat.l3_device or stat.device)
end
function get_wan6net(self)
local net, stat = self:get_status_by_route("::", 0)
return net and network(net, stat.proto)
end
function get_wan6dev(self)
local _, stat = self:get_status_by_route("::", 0)
return stat and interface(stat.l3_device or stat.device)
end
function get_switch_topologies(self)
return _swtopo
end
function network(name, proto)
if name then
local p = proto or _uci:get("network", name, "proto")
local c = p and _protocols[p] or protocol
return c(name)
end
end
function protocol.__init__(self, name)
self.sid = name
end
function protocol._get(self, opt)
local v = _uci:get("network", self.sid, opt)
if type(v) == "table" then
return table.concat(v, " ")
end
return v or ""
end
function protocol._ubus(self, field)
if not _ubusnetcache[self.sid] then
_ubusnetcache[self.sid] = utl.ubus("network.interface.%s" % self.sid,
"status", { })
end
if _ubusnetcache[self.sid] and field then
return _ubusnetcache[self.sid][field]
end
return _ubusnetcache[self.sid]
end
function protocol.get(self, opt)
return _get("network", self.sid, opt)
end
function protocol.set(self, opt, val)
return _set("network", self.sid, opt, val)
end
function protocol.ifname(self)
local ifname
if self:is_floating() then
ifname = self:_ubus("l3_device")
else
ifname = self:_ubus("device")
end
if not ifname then
local num = { }
_uci:foreach("wireless", "wifi-iface",
function(s)
if s.device then
num[s.device] = num[s.device]
and num[s.device] + 1 or 1
local net
for net in utl.imatch(s.network) do
if net == self.sid then
ifname = "%s.network%d" %{ s.device, num[s.device] }
return false
end
end
end
end)
end
return ifname
end
function protocol.proto(self)
return "none"
end
function protocol.get_i18n(self)
local p = self:proto()
if p == "none" then
return lng.translate("Unmanaged")
elseif p == "static" then
return lng.translate("Static address")
elseif p == "dhcp" then
return lng.translate("DHCP client")
else
return lng.translate("Unknown")
end
end
function protocol.type(self)
return self:_get("type")
end
function protocol.name(self)
return self.sid
end
function protocol.uptime(self)
return self:_ubus("uptime") or 0
end
function protocol.expires(self)
local u = self:_ubus("uptime")
local d = self:_ubus("data")
if type(u) == "number" and type(d) == "table" and
type(d.leasetime) == "number"
then
local r = (d.leasetime - (u % d.leasetime))
return r > 0 and r or 0
end
return -1
end
function protocol.metric(self)
return self:_ubus("metric") or 0
end
function protocol.ipaddr(self)
local addrs = self:_ubus("ipv4-address")
return addrs and #addrs > 0 and addrs[1].address
end
function protocol.ipaddrs(self)
local addrs = self:_ubus("ipv4-address")
local rv = { }
if type(addrs) == "table" then
local n, addr
for n, addr in ipairs(addrs) do
rv[#rv+1] = "%s/%d" %{ addr.address, addr.mask }
end
end
return rv
end
function protocol.netmask(self)
local addrs = self:_ubus("ipv4-address")
return addrs and #addrs > 0 and
ipc.IPv4("0.0.0.0/%d" % addrs[1].mask):mask():string()
end
function protocol.gwaddr(self)
local _, route
for _, route in ipairs(self:_ubus("route") or { }) do
if route.target == "0.0.0.0" and route.mask == 0 then
return route.nexthop
end
end
end
function protocol.dnsaddrs(self)
local dns = { }
local _, addr
for _, addr in ipairs(self:_ubus("dns-server") or { }) do
if not addr:match(":") then
dns[#dns+1] = addr
end
end
return dns
end
function protocol.ip6addr(self)
local addrs = self:_ubus("ipv6-address")
if addrs and #addrs > 0 then
return "%s/%d" %{ addrs[1].address, addrs[1].mask }
else
addrs = self:_ubus("ipv6-prefix-assignment")
if addrs and #addrs > 0 then
return "%s/%d" %{ addrs[1].address, addrs[1].mask }
end
end
end
function protocol.ip6addrs(self)
local addrs = self:_ubus("ipv6-address")
local rv = { }
local n, addr
if type(addrs) == "table" then
for n, addr in ipairs(addrs) do
rv[#rv+1] = "%s/%d" %{ addr.address, addr.mask }
end
end
addrs = self:_ubus("ipv6-prefix-assignment")
if type(addrs) == "table" then
for n, addr in ipairs(addrs) do
rv[#rv+1] = "%s1/%d" %{ addr.address, addr.mask }
end
end
return rv
end
function protocol.gw6addr(self)
local _, route
for _, route in ipairs(self:_ubus("route") or { }) do
if route.target == "::" and route.mask == 0 then
return ipc.IPv6(route.nexthop):string()
end
end
end
function protocol.dns6addrs(self)
local dns = { }
local _, addr
for _, addr in ipairs(self:_ubus("dns-server") or { }) do
if addr:match(":") then
dns[#dns+1] = addr
end
end
return dns
end
function protocol.ip6prefix(self)
local prefix = self:_ubus("ipv6-prefix")
if prefix and #prefix > 0 then
return "%s/%d" %{ prefix[1].address, prefix[1].mask }
end
end
function protocol.is_bridge(self)
return (not self:is_virtual() and self:type() == "bridge")
end
function protocol.opkg_package(self)
return nil
end
function protocol.is_installed(self)
return true
end
function protocol.is_virtual(self)
return false
end
function protocol.is_floating(self)
return false
end
function protocol.is_empty(self)
if self:is_floating() then
return false
else
local rv = true
if (self:_get("ifname") or ""):match("%S+") then
rv = false
end
_uci:foreach("wireless", "wifi-iface",
function(s)
local n
for n in utl.imatch(s.network) do
if n == self.sid then
rv = false
return false
end
end
end)
return rv
end
end
function protocol.add_interface(self, ifname)
ifname = _M:ifnameof(ifname)
if ifname and not self:is_floating() then
-- if its a wifi interface, change its network option
local wif = _wifi_lookup(ifname)
if wif then
_append("wireless", wif, "network", self.sid)
-- add iface to our iface list
else
_append("network", self.sid, "ifname", ifname)
end
end
end
function protocol.del_interface(self, ifname)
ifname = _M:ifnameof(ifname)
if ifname and not self:is_floating() then
-- if its a wireless interface, clear its network option
local wif = _wifi_lookup(ifname)
if wif then _filter("wireless", wif, "network", self.sid) end
-- remove the interface
_filter("network", self.sid, "ifname", ifname)
end
end
function protocol.get_interface(self)
if self:is_virtual() then
_tunnel[self:proto() .. "-" .. self.sid] = true
return interface(self:proto() .. "-" .. self.sid, self)
elseif self:is_bridge() then
_bridge["br-" .. self.sid] = true
return interface("br-" .. self.sid, self)
else
local ifn = nil
local num = { }
for ifn in utl.imatch(_uci:get("network", self.sid, "ifname")) do
ifn = ifn:match("^[^:/]+")
return ifn and interface(ifn, self)
end
ifn = nil
_uci:foreach("wireless", "wifi-iface",
function(s)
if s.device then
num[s.device] = num[s.device] and num[s.device] + 1 or 1
local net
for net in utl.imatch(s.network) do
if net == self.sid then
ifn = "%s.network%d" %{ s.device, num[s.device] }
return false
end
end
end
end)
return ifn and interface(ifn, self)
end
end
function protocol.get_interfaces(self)
if self:is_bridge() or (self:is_virtual() and not self:is_floating()) then
local ifaces = { }
local ifn
local nfs = { }
for ifn in utl.imatch(self:get("ifname")) do
ifn = ifn:match("^[^:/]+")
nfs[ifn] = interface(ifn, self)
end
for ifn in utl.kspairs(nfs) do
ifaces[#ifaces+1] = nfs[ifn]
end
local num = { }
local wfs = { }
_uci:foreach("wireless", "wifi-iface",
function(s)
if s.device then
num[s.device] = num[s.device] and num[s.device] + 1 or 1
local net
for net in utl.imatch(s.network) do
if net == self.sid then
ifn = "%s.network%d" %{ s.device, num[s.device] }
wfs[ifn] = interface(ifn, self)
end
end
end
end)
for ifn in utl.kspairs(wfs) do
ifaces[#ifaces+1] = wfs[ifn]
end
return ifaces
end
end
function protocol.contains_interface(self, ifname)
ifname = _M:ifnameof(ifname)
if not ifname then
return false
elseif self:is_virtual() and self:proto() .. "-" .. self.sid == ifname then
return true
elseif self:is_bridge() and "br-" .. self.sid == ifname then
return true
else
local ifn
for ifn in utl.imatch(self:get("ifname")) do
ifn = ifn:match("[^:]+")
if ifn == ifname then
return true
end
end
local wif = _wifi_lookup(ifname)
if wif then
local n
for n in utl.imatch(_uci:get("wireless", wif, "network")) do
if n == self.sid then
return true
end
end
end
end
return false
end
function protocol.adminlink(self)
return dsp.build_url("admin", "network", "network", self.sid)
end
interface = utl.class()
function interface.__init__(self, ifname, network)
local wif = _wifi_lookup(ifname)
if wif then
self.wif = wifinet(wif)
self.ifname = _wifi_state("section", wif, "ifname")
end
self.ifname = self.ifname or ifname
self.dev = _interfaces[self.ifname]
self.network = network
end
function interface._ubus(self, field)
if not _ubusdevcache[self.ifname] then
_ubusdevcache[self.ifname] = utl.ubus("network.device", "status",
{ name = self.ifname })
end
if _ubusdevcache[self.ifname] and field then
return _ubusdevcache[self.ifname][field]
end
return _ubusdevcache[self.ifname]
end
function interface.name(self)
return self.wif and self.wif:ifname() or self.ifname
end
function interface.mac(self)
local mac = self:_ubus("macaddr")
return mac and mac:upper()
end
function interface.ipaddrs(self)
return self.dev and self.dev.ipaddrs or { }
end
function interface.ip6addrs(self)
return self.dev and self.dev.ip6addrs or { }
end
function interface.type(self)
if self.wif or _wifi_iface(self.ifname) then
return "wifi"
elseif _bridge[self.ifname] then
return "bridge"
elseif _tunnel[self.ifname] then
return "tunnel"
elseif self.ifname:match("%.") then
return "vlan"
elseif _switch[self.ifname] then
return "switch"
else
return "ethernet"
end
end
function interface.shortname(self)
if self.wif then
return self.wif:shortname()
else
return self.ifname
end
end
function interface.get_i18n(self)
if self.wif then
return "%s: %s %q" %{
lng.translate("Wireless Network"),
self.wif:active_mode(),
self.wif:active_ssid() or self.wif:active_bssid() or self.wif:id()
}
else
return "%s: %q" %{ self:get_type_i18n(), self:name() }
end
end
function interface.get_type_i18n(self)
local x = self:type()
if x == "wifi" then
return lng.translate("Wireless Adapter")
elseif x == "bridge" then
return lng.translate("Bridge")
elseif x == "switch" then
return lng.translate("Ethernet Switch")
elseif x == "vlan" then
if _switch[self.ifname] then
return lng.translate("Switch VLAN")
else
return lng.translate("Software VLAN")
end
elseif x == "tunnel" then
return lng.translate("Tunnel Interface")
else
return lng.translate("Ethernet Adapter")
end
end
function interface.adminlink(self)
if self.wif then
return self.wif:adminlink()
end
end
function interface.ports(self)
local members = self:_ubus("bridge-members")
if members then
local _, iface
local ifaces = { }
for _, iface in ipairs(members) do
ifaces[#ifaces+1] = interface(iface)
end
end
end
function interface.bridge_id(self)
if self.br then
return self.br.id
else
return nil
end
end
function interface.bridge_stp(self)
if self.br then
return self.br.stp
else
return false
end
end
function interface.is_up(self)
return self:_ubus("up") or false
end
function interface.is_bridge(self)
return (self:type() == "bridge")
end
function interface.is_bridgeport(self)
return self.dev and self.dev.bridge and true or false
end
function interface.tx_bytes(self)
local stat = self:_ubus("statistics")
return stat and stat.tx_bytes or 0
end
function interface.rx_bytes(self)
local stat = self:_ubus("statistics")
return stat and stat.rx_bytes or 0
end
function interface.tx_packets(self)
local stat = self:_ubus("statistics")
return stat and stat.tx_packets or 0
end
function interface.rx_packets(self)
local stat = self:_ubus("statistics")
return stat and stat.rx_packets or 0
end
function interface.get_network(self)
return self:get_networks()[1]
end
function interface.get_networks(self)
if not self.networks then
local nets = { }
local _, net
for _, net in ipairs(_M:get_networks()) do
if net:contains_interface(self.ifname) or
net:ifname() == self.ifname
then
nets[#nets+1] = net
end
end
table.sort(nets, function(a, b) return a.sid < b.sid end)
self.networks = nets
return nets
else
return self.networks
end
end
function interface.get_wifinet(self)
return self.wif
end
wifidev = utl.class()
function wifidev.__init__(self, dev)
self.sid = dev
self.iwinfo = dev and sys.wifi.getiwinfo(dev) or { }
end
function wifidev.get(self, opt)
return _get("wireless", self.sid, opt)
end
function wifidev.set(self, opt, val)
return _set("wireless", self.sid, opt, val)
end
function wifidev.name(self)
return self.sid
end
function wifidev.hwmodes(self)
local l = self.iwinfo.hwmodelist
if l and next(l) then
return l
else
return { b = true, g = true }
end
end
function wifidev.get_i18n(self)
local t = "Generic"
if self.iwinfo.type == "wl" then
t = "Broadcom"
end
local m = ""
local l = self:hwmodes()
if l.a then m = m .. "a" end
if l.b then m = m .. "b" end
if l.g then m = m .. "g" end
if l.n then m = m .. "n" end
if l.ac then m = "ac" end
return "%s 802.11%s Wireless Controller (%s)" %{ t, m, self:name() }
end
function wifidev.is_up(self)
if _ubuswificache[self.sid] then
return (_ubuswificache[self.sid].up == true)
end
return false
end
function wifidev.get_wifinet(self, net)
if _uci:get("wireless", net) == "wifi-iface" then
return wifinet(net)
else
local wnet = _wifi_lookup(net)
if wnet then
return wifinet(wnet)
end
end
end
function wifidev.get_wifinets(self)
local nets = { }
_uci:foreach("wireless", "wifi-iface",
function(s)
if s.device == self.sid then
nets[#nets+1] = wifinet(s['.name'])
end
end)
return nets
end
function wifidev.add_wifinet(self, options)
options = options or { }
options.device = self.sid
local wnet = _uci:section("wireless", "wifi-iface", nil, options)
if wnet then
return wifinet(wnet, options)
end
end
function wifidev.del_wifinet(self, net)
if utl.instanceof(net, wifinet) then
net = net.sid
elseif _uci:get("wireless", net) ~= "wifi-iface" then
net = _wifi_lookup(net)
end
if net and _uci:get("wireless", net, "device") == self.sid then
_uci:delete("wireless", net)
return true
end
return false
end
wifinet = utl.class()
function wifinet.__init__(self, net, data)
self.sid = net
local n = 0
local num = { }
local netid, sid
_uci:foreach("wireless", "wifi-iface",
function(s)
n = n + 1
if s.device then
num[s.device] = num[s.device] and num[s.device] + 1 or 1
if s['.name'] == self.sid then
sid = "@wifi-iface[%d]" % n
netid = "%s.network%d" %{ s.device, num[s.device] }
return false
end
end
end)
if sid then
local _, k, r, i
for k, r in pairs(_ubuswificache) do
if type(r) == "table" and
type(r.interfaces) == "table"
then
for _, i in ipairs(r.interfaces) do
if type(i) == "table" and i.section == sid then
self._ubusdata = {
radio = k,
dev = r,
net = i
}
end
end
end
end
end
local dev = _wifi_state("section", self.sid, "ifname") or netid
self.netid = netid
self.wdev = dev
self.iwinfo = dev and sys.wifi.getiwinfo(dev) or { }
end
function wifinet.ubus(self, ...)
local n, v = self._ubusdata
for n = 1, select('#', ...) do
if type(v) == "table" then
v = v[select(n, ...)]
else
return nil
end
end
return v
end
function wifinet.get(self, opt)
return _get("wireless", self.sid, opt)
end
function wifinet.set(self, opt, val)
return _set("wireless", self.sid, opt, val)
end
function wifinet.mode(self)
return self:ubus("net", "config", "mode") or self:get("mode") or "ap"
end
function wifinet.ssid(self)
return self:ubus("net", "config", "ssid") or self:get("ssid")
end
function wifinet.bssid(self)
return self:ubus("net", "config", "bssid") or self:get("bssid")
end
function wifinet.network(self)
local net, networks = nil, { }
for net in utl.imatch(self:ubus("net", "config", "network") or self:get("network")) do
networks[#networks+1] = net
end
return networks
end
function wifinet.id(self)
return self.netid
end
function wifinet.name(self)
return self.sid
end
function wifinet.ifname(self)
local ifname = self:ubus("net", "ifname") or self.iwinfo.ifname
if not ifname or ifname:match("^wifi%d") or ifname:match("^radio%d") then
ifname = self.wdev
end
return ifname
end
function wifinet.get_device(self)
local dev = self:ubus("radio") or self:get("device")
return dev and wifidev(dev) or nil
end
function wifinet.is_up(self)
local ifc = self:get_interface()
return (ifc and ifc:is_up() or false)
end
function wifinet.active_mode(self)
local m = self.iwinfo.mode or self:ubus("net", "config", "mode") or self:get("mode") or "ap"
if m == "ap" then m = "Master"
elseif m == "sta" then m = "Client"
elseif m == "adhoc" then m = "Ad-Hoc"
elseif m == "mesh" then m = "Mesh"
elseif m == "monitor" then m = "Monitor"
end
return m
end
function wifinet.active_mode_i18n(self)
return lng.translate(self:active_mode())
end
function wifinet.active_ssid(self)
return self.iwinfo.ssid or self:ubus("net", "config", "ssid") or self:get("ssid")
end
function wifinet.active_bssid(self)
return self.iwinfo.bssid or self:ubus("net", "config", "bssid") or self:get("bssid")
end
function wifinet.active_encryption(self)
local enc = self.iwinfo and self.iwinfo.encryption
return enc and enc.description or "-"
end
function wifinet.assoclist(self)
return self.iwinfo.assoclist or { }
end
function wifinet.frequency(self)
local freq = self.iwinfo.frequency
if freq and freq > 0 then
return "%.03f" % (freq / 1000)
end
end
function wifinet.bitrate(self)
local rate = self.iwinfo.bitrate
if rate and rate > 0 then
return (rate / 1000)
end
end
function wifinet.channel(self)
return self.iwinfo.channel or self:ubus("dev", "config", "channel") or
tonumber(self:get("channel"))
end
function wifinet.signal(self)
return self.iwinfo.signal or 0
end
function wifinet.noise(self)
return self.iwinfo.noise or 0
end
function wifinet.country(self)
return self.iwinfo.country or self:ubus("dev", "config", "country") or "00"
end
function wifinet.txpower(self)
local pwr = (self.iwinfo.txpower or 0)
return pwr + self:txpower_offset()
end
function wifinet.txpower_offset(self)
return self.iwinfo.txpower_offset or 0
end
function wifinet.signal_level(self, s, n)
if self:active_bssid() ~= "00:00:00:00:00:00" then
local signal = s or self:signal()
local noise = n or self:noise()
if signal < 0 and noise < 0 then
local snr = -1 * (noise - signal)
return math.floor(snr / 5)
else
return 0
end
else
return -1
end
end
function wifinet.signal_percent(self)
local qc = self.iwinfo.quality or 0
local qm = self.iwinfo.quality_max or 0
if qc > 0 and qm > 0 then
return math.floor((100 / qm) * qc)
else
return 0
end
end
function wifinet.shortname(self)
return "%s %q" %{
lng.translate(self:active_mode()),
self:active_ssid() or self:active_bssid() or self:id()
}
end
function wifinet.get_i18n(self)
return "%s: %s %q (%s)" %{
lng.translate("Wireless Network"),
lng.translate(self:active_mode()),
self:active_ssid() or self:active_bssid() or self:id(),
self:ifname()
}
end
function wifinet.adminlink(self)
return dsp.build_url("admin", "network", "wireless", self.netid)
end
function wifinet.get_network(self)
return self:get_networks()[1]
end
function wifinet.get_networks(self)
local nets = { }
local net
for net in utl.imatch(self:ubus("net", "config", "network") or self:get("network")) do
if _uci:get("network", net) == "interface" then
nets[#nets+1] = network(net)
end
end
table.sort(nets, function(a, b) return a.sid < b.sid end)
return nets
end
function wifinet.get_interface(self)
return interface(self:ifname())
end
-- setup base protocols
_M:register_protocol("static")
_M:register_protocol("dhcp")
_M:register_protocol("none")
-- load protocol extensions
local exts = nfs.dir(utl.libpath() .. "/model/network")
if exts then
local ext
for ext in exts do
if ext:match("%.lua$") then
require("luci.model.network." .. ext:gsub("%.lua$", ""))
end
end
end
| apache-2.0 |
RunAwayDSP/darkstar | scripts/globals/items/galette_des_rois.lua | 11 | 1198 | -----------------------------------------
-- ID: 5875
-- Item: Galette Des Rois
-- Food Effect: 180 Min, All Races
-----------------------------------------
-- HP +8
-- MP +3% (cap13)
-- Intelligence +2
-- Random Jewel
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) then
result = dsp.msg.basic.IS_FULL
end
if target:getFreeSlotsCount() == 0 then
result = dsp.msg.basic.ITEM_NO_USE_INVENTORY
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,10800,5875)
local rand = math.random(784,815)
target:addItem(rand) -- Random Jewel
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.HP, 8)
target:addMod(dsp.mod.FOOD_MPP, 3)
target:addMod(dsp.mod.FOOD_MP_CAP, 13)
target:addMod(dsp.mod.INT, 2)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 8)
target:delMod(dsp.mod.FOOD_MPP, 3)
target:delMod(dsp.mod.FOOD_MP_CAP, 13)
target:delMod(dsp.mod.INT, 2)
end
| gpl-3.0 |
Startg/permag | plugins/lock-fosh.lua | 24 | 2263 | local function pre_process(msg)
local chkfosh = redis:hget('settings:fosh',msg.chat_id_)
if not chkfosh then
redis:hset('settings:fosh',msg.chat_id_,'off')
end
end
local function run(msg, matches)
--Commands --دستورات فعال و غیرفعال کردن فحش
if matches[1]:lower() == 'unlock' then
if matches[2]:lower() == 'fosh' then
if not is_mod(msg) then return end
local fosh = redis:hget('settings:fosh',msg.chat_id_)
if fosh == 'on' then
redis:hset('settings:fosh',msg.chat_id_,'off')
return ''
elseif fosh == 'off' then
return ''
end
end
end
if matches[1]:lower() == 'lock' then
if matches[2]:lower() == 'fosh' then
if not is_mod(msg) then return end
local fosh = redis:hget('settings:fosh',msg.chat_id_)
if fosh == 'off' then
redis:hset('settings:fosh',msg.chat_id_,'on')
return ''
elseif fosh == 'on' then
return ''
end
end
end
--Delete words contains --حذف پیامهای فحش
if not is_mod(msg) then
local fosh = redis:hget('settings:fosh',msg.chat_id_)
if fosh == 'on' then
tdcli.deleteMessages(msg.chat_id_, {[0] = msg.id_}, dl_cb, nil)
end
end
end
return {
patterns = {
"(ک*س)$",
"کیر",
"کص",
"کــــــــــیر",
"کــــــــــــــــــــــــــــــیر",
"کـیـــــــــــــــــــــــــــــــــــــــــــــــــــر",
"ک×یر",
"ک÷یر",
"ک*ص",
"کــــــــــیرر",
"kir",
"kos",
"گوساله",
"gosale",
"gusale",
"جاکش",
"قرمساق",
"دیوس",
"دیوص",
"dayus",
"dayos",
"dayu3",
"10yus",
"10yu3",
"daus",
"dau3",
"تخمی",
"حرومزاده",
"حروم زاده",
"harumzade",
"haromzade",
"haroomzade",
"lashi",
"لاشی",
"لاشي",
"جنده",
"jende",
"tokhmi",
"madarjende",
"kharkosde",
"خارکسده",
"خوارکسده",
"خارکصده",
"خوارکصده",
"kharko3de",
"مادرجنده",
--Commands ##Don't change this##
"^[!/#]([Ll][Oo][Cc][Kk]) (.*)$",
"^[!/#]([Uu][Nn][Ll][Oo][Cc][Kk]) (.*)$",
------------End----------------
},
run = run,
pre_process = pre_process
}
-- http://permag.ir
-- @permag_ir
-- @permag_bots
| gpl-3.0 |
ld-test/phpass | src/phpass.lua | 3 | 2740 | -- lua-phpass, Lua implementation of the portable
-- PHP password hashing framework
-- Copyright (C) 2015 Boris Nagaev
-- See the LICENSE file for terms of use.
local phpass = {}
-- Encoding. Not base64!
local itoa64_ = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ..
'abcdefghijklmnopqrstuvwxyz'
local function itoa64(index)
return itoa64_:sub(index + 1, index + 1)
end
local function unItoa64(char)
return itoa64_:find(char) - 1
end
local function encode64(data)
local outp = ''
local cur = 1
while cur <= #data do
local value = data:byte(cur)
outp = outp .. itoa64(value % 64)
cur = cur + 1
if cur <= #data then
value = value + data:byte(cur) * 256
end
outp = outp .. itoa64(math.floor(value / 2^6) % 2^6)
if cur > #data then
break
end
cur = cur + 1
if cur <= #data then
value = value + data:byte(cur) * 256^2
end
outp = outp .. itoa64(math.floor(value / 2^12) % 2^6)
if cur > #data then
break
end
cur = cur + 1
outp = outp .. itoa64(math.floor(value / 2^18) % 2^6)
end
return outp
end
local function startsWith(str, prefix)
return str:sub(1, prefix:len()) == prefix
end
local function md5(data)
local md5object = require("crypto").digest.new('md5')
local raw = true
return md5object:final(data, raw)
end
local function randomBytes(number)
return require("crypto").rand.bytes(number)
end
local function cryptPrivate(pw, setting)
local outp = startsWith(setting, '*0')
and '*1' or '*0'
if not startsWith(setting, '$P$') and
not startsWith(setting, '$H$') then
return outp
end
local count_code = setting:sub(4, 4)
local count_log2 = unItoa64(count_code)
if count_log2 < 7 or count_log2 > 30 then
return outp
end
local count = 2 ^ count_log2
local salt = setting:sub(5, 12)
if #salt ~= 8 then
return outp
end
assert(type(pw) == 'string')
local hx = md5(salt .. pw)
for i = 1, count do
hx = md5(hx .. pw)
end
return setting:sub(1, 12) .. encode64(hx)
end
function phpass.checkPassword(pw, stored_hash)
local hx = cryptPrivate(pw, stored_hash)
return hx == stored_hash
end
local function gensaltPrivate(count_log2)
if not count_log2 then
count_log2 = 16
end
local count_code = itoa64(count_log2)
local format = '$P$%s%s'
local salt = encode64(randomBytes(6))
return format:format(count_code, salt)
end
function phpass.hashPassword(pw, count_log2)
local setting = gensaltPrivate(count_log2)
return cryptPrivate(pw, setting)
end
return phpass
| mit |
arpanpal010/awesome | obvious/io/init.lua | 1 | 2063 | -----------------------------------
-- Author: Uli Schlachter --
-- Copyright 2009 Uli Schlachter --
-----------------------------------
local io = io
local setmetatable = setmetatable
local tonumber = tonumber
local pairs = pairs
local lib = {
widget = require("obvious.lib.widget")
}
module("obvious.io")
local function info(dev)
local f = io.open("/proc/diskstats")
local line
if f == nil then
return ret
end
line = f:read()
while line and not line:match(dev) do
line = f:read()
end
f:close()
if not line then
return nil
end
local ret = { }
-- each time matches() is called it returns the next number from line
local matches = line:gmatch("%d+")
-- First two are device numbers, skip them
matches()
matches()
ret.reads_completed = tonumber(matches())
ret.reads_merged = tonumber(matches())
ret.reads_sectors = tonumber(matches())
ret.reads_time_ms = tonumber(matches())
ret.writes_completed = tonumber(matches())
ret.writes_merged = tonumber(matches())
ret.writes_sectors = tonumber(matches())
ret.writes_time_ms = tonumber(matches())
ret.in_progress = tonumber(matches())
ret.time_ms = tonumber(matches())
ret.time_ms_weight = tonumber(matches())
return ret
end
local function get_increase(data)
local last = data.last
local cur = info(data.device)
if not cur then
return nil
end
data.last = cur
-- Fake for starting
if last == nil then
last = cur
end
local ret = { }
for k, v in pairs(cur) do
ret[k] = cur[k] - last[k]
end
return ret
end
local function get(data)
local val = get_increase(data)
if not val then
return
end
return val.writes_sectors + val.reads_sectors
end
local function get_data_source(device)
local device = device or "sda"
local ret = {}
ret.get = get
ret.device = device
return lib.widget.from_data_source(ret)
end
setmetatable(_M, { __call = function (_, ...) return get_data_source(...) end })
-- vim:ft=lua:ts=2:sw=2:sts=2:tw=80:fenc=utf-8:et
| mit |
RunAwayDSP/darkstar | scripts/globals/spells/bluemagic/cimicine_discharge.lua | 12 | 1471 | -----------------------------------------
-- Spell: Cimicine Discharge
-- Reduces the attack speed of enemies within range
-- Spell cost: 32 MP
-- Monster Type: Vermin
-- Spell Type: Magical (Earth)
-- Blue Magic Points: 3
-- Stat Bonus: DEX+1, AGI+2
-- Level: 78
-- Casting Time: 3 seconds
-- Recast Time: 20 seconds
--
-- Combos: Magic Burst Bonus
-----------------------------------------
require("scripts/globals/bluemagic")
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
require("scripts/globals/status")
-----------------------------------------
function onMagicCastingCheck(caster, target, spell)
return 0
end
function onSpellCast(caster, target, spell)
local pINT = caster:getStat(dsp.mod.INT)
local mINT = target:getStat(dsp.mod.INT)
local dINT = pINT - mINT
local params = {}
params.diff = nil
params.attribute = dsp.mod.INT
params.skillType = dsp.skill.BLUE_MAGIC
params.bonus = 0
params.effect = nil
local resist = applyResistance(caster, target, spell, params)
if resist < 0.5 then
spell:setMsg(dsp.msg.basic.MAGIC_RESIST); --resist message
else
if target:addStatusEffect(dsp.effect.SLOW, 2000, 0, getBlueEffectDuration(caster, resist, dsp.effect.SLOW)) then
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB_IS)
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
end
return dsp.effect.SLOW
end
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Metalworks/npcs/Fariel.lua | 15 | 2148 | -----------------------------------
-- Area: Metalworks
-- NPC: Fariel
-- Type: Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Metalworks/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Metalworks/TextIDs");
require("scripts/globals/pathfind");
local path = {
53.551208, -14.000000, -7.162227,
54.111534, -14.000000, -6.227105,
54.075279, -14.000000, -5.139729,
53.565350, -14.000000, 6.000605,
52.636345, -14.000000, 6.521872,
51.561535, -14.000000, 6.710593,
50.436523, -14.000000, 6.835652,
41.754219, -14.000000, 7.686310,
41.409531, -14.000000, 6.635177,
41.351002, -14.000000, 5.549131,
41.341057, -14.000000, 4.461191,
41.338020, -14.000000, -9.138797,
42.356136, -14.000000, -9.449953,
43.442558, -14.000000, -9.409095,
44.524868, -14.000000, -9.298069,
53.718494, -14.000000, -8.260445,
54.082706, -14.000000, -7.257769,
54.110283, -14.000000, -6.170790,
54.073116, -14.000000, -5.083439,
53.556625, -14.000000, 6.192736,
52.545383, -14.000000, 6.570893,
51.441212, -14.000000, 6.730487,
50.430820, -14.000000, 6.836911,
41.680725, -14.000000, 7.693455,
41.396103, -14.000000, 6.599321,
41.349224, -14.000000, 5.512603,
41.340771, -14.000000, 4.424644
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(pathfind.first(path));
onPath(npc);
end;
function onPath(npc)
pathfind.patrol(npc, path);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x02C2);
npc:wait(-1);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,npc)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
npc:wait(0);
end;
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Temple_of_Uggalepih/mobs/Manipulator.lua | 17 | 2255 | ----------------------------------
-- Area: Temple of Uggalipeh
-- NM: Manipulator
-- Notes: Paths around the 2 staircases
-----------------------------------
local path =
{
-17.930, -8.500, -93.215,
-18.553, -7.713, -91.224,
-20.226, -6.250, -89.091,
-21.651, -5.005, -87.401,
-23.137, -3.917, -85.818,
-24.750, -2.650, -84.440,
-26.487, -1.300, -83.362,
-28.366, -0.068, -82.488,
-30.361, 0.500, -81.880,
-32.450, 0.500, -81.498,
-34.553, 0.500, -81.367,
-36.575, 0.500, -81.401,
-38.601, 0.500, -81.632,
-40.699, 0.500, -82.133,
-43.542, -1.300, -83.312,
-45.403, -2.650, -84.455,
-47.108, -3.804, -85.804,
-48.567, -4.900, -87.243,
-49.894, -6.250, -88.891,
-50.957, -7.518, -90.686,
-51.714, -8.500, -92.696,
-52.136, -8.500, -94.655,
-52.358, -8.500, -96.757,
-52.482, -8.500, -99.253,
-52.530, -8.500, -102.142,
-52.409, -8.500, -104.364,
-51.995, -8.500, -106.498,
-51.329, -7.998, -108.403,
-50.419, -6.700, -110.216,
-49.221, -5.514, -111.939,
-47.741, -4.367, -113.588,
-46.122, -3.100, -115.009,
-44.418, -1.750, -116.181,
-42.611, -0.797, -117.185,
-40.653, 0.500, -117.857,
-38.622, 0.500, -118.275,
-36.614, 0.500, -118.518,
-34.459, 0.500, -118.650,
-32.303, 0.500, -118.591,
-30.276, 0.500, -118.249,
-28.199, -0.318, -117.605,
-26.325, -1.300, -116.748,
-24.522, -2.650, -115.637,
-22.911, -3.550, -114.378,
-21.430, -4.900, -112.942,
-20.121, -6.250, -111.382,
-18.967, -7.150, -109.509,
-18.191, -8.500, -107.518,
-17.743, -8.500, -105.495,
-17.541, -8.500, -103.466,
-17.497, -8.500, -101.427,
-17.408, -8.500, -97.263,
-17.573, -8.500, -95.179
};
function onMobSpawn(mob)
onMobRoam(mob); -- what?
end;
function onPath(mob)
pathfind.patrol(mob, path);
end;
function onMobRoam(mob)
-- move to start position if not moving
if (mob:isFollowingPath() == false) then
mob:pathThrough(pathfind.first(path));
end
end;
function onMobDeath(mob, player, isKiller)
end;
function onMobDespawn(mob)
-- Set Manipulator's spawnpoint and respawn time
mob:setRespawnTime(7200); -- 2 hours
end;
| gpl-3.0 |
Benjarobbi/UzzBott | plugins/img_google.lua | 660 | 3196 | do
local mime = require("mime")
local google_config = load_from_file('data/google.lua')
local cache = {}
--[[
local function send_request(url)
local t = {}
local options = {
url = url,
sink = ltn12.sink.table(t),
method = "GET"
}
local a, code, headers, status = http.request(options)
return table.concat(t), code, headers, status
end]]--
local function get_google_data(text)
local url = "http://ajax.googleapis.com/ajax/services/search/images?"
url = url.."v=1.0&rsz=5"
url = url.."&q="..URL.escape(text)
url = url.."&imgsz=small|medium|large"
if google_config.api_keys then
local i = math.random(#google_config.api_keys)
local api_key = google_config.api_keys[i]
if api_key then
url = url.."&key="..api_key
end
end
local res, code = http.request(url)
if code ~= 200 then
print("HTTP Error code:", code)
return nil
end
local google = json:decode(res)
return google
end
-- Returns only the useful google data to save on cache
local function simple_google_table(google)
local new_table = {}
new_table.responseData = {}
new_table.responseDetails = google.responseDetails
new_table.responseStatus = google.responseStatus
new_table.responseData.results = {}
local results = google.responseData.results
for k,result in pairs(results) do
new_table.responseData.results[k] = {}
new_table.responseData.results[k].unescapedUrl = result.unescapedUrl
new_table.responseData.results[k].url = result.url
end
return new_table
end
local function save_to_cache(query, data)
-- Saves result on cache
if string.len(query) <= 7 then
local text_b64 = mime.b64(query)
if not cache[text_b64] then
local simple_google = simple_google_table(data)
cache[text_b64] = simple_google
end
end
end
local function process_google_data(google, receiver, query)
if google.responseStatus == 403 then
local text = 'ERROR: Reached maximum searches per day'
send_msg(receiver, text, ok_cb, false)
elseif google.responseStatus == 200 then
local data = google.responseData
if not data or not data.results or #data.results == 0 then
local text = 'Image not found.'
send_msg(receiver, text, ok_cb, false)
return false
end
-- Random image from table
local i = math.random(#data.results)
local url = data.results[i].unescapedUrl or data.results[i].url
local old_timeout = http.TIMEOUT or 10
http.TIMEOUT = 5
send_photo_from_url(receiver, url)
http.TIMEOUT = old_timeout
save_to_cache(query, google)
else
local text = 'ERROR!'
send_msg(receiver, text, ok_cb, false)
end
end
function run(msg, matches)
local receiver = get_receiver(msg)
local text = matches[1]
local text_b64 = mime.b64(text)
local cached = cache[text_b64]
if cached then
process_google_data(cached, receiver, text)
else
local data = get_google_data(text)
process_google_data(data, receiver, text)
end
end
return {
description = "Search image with Google API and sends it.",
usage = "!img [term]: Random search an image with Google API.",
patterns = {
"^!img (.*)$"
},
run = run
}
end
| gpl-2.0 |
RunAwayDSP/darkstar | scripts/zones/Gustav_Tunnel/npcs/qm2.lua | 9 | 1354 | -----------------------------------
-- Area: Gustav tunnel
-- NPC: qm2 (???)
-- Note: Part of mission "The Salt of the Earth"
-- !pos -130 1.256 252.696 212
-----------------------------------
local ID = require("scripts/zones/Gustav_Tunnel/IDs");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local basty = player:getCurrentMission(BASTOK);
local soteStat = player:getCharVar("BASTOK91");
local anyPlasmsAlive = false;
for i = ID.mob.GIGAPLASM, ID.mob.GIGAPLASM + 14 do
if (GetMobByID(i):isAlive()) then
anyPlasmsAlive = true;
break;
end
end
if (basty == dsp.mission.id.bastok.THE_SALT_OF_THE_EARTH and soteStat == 2 and not anyPlasmsAlive) then
SpawnMob(ID.mob.GIGAPLASM):updateClaim(player);
elseif (basty == dsp.mission.id.bastok.THE_SALT_OF_THE_EARTH and soteStat == 3 and not player:hasKeyItem(dsp.ki.MIRACLESALT)) then
player:addKeyItem(dsp.ki.MIRACLESALT);
player:messageSpecial(ID.text.KEYITEM_OBTAINED, dsp.ki.MIRACLESALT);
else
player:messageSpecial(ID.text.NOTHING_OUT_OF_ORDINARY);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
end;
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Norg/TextIDs.lua | 7 | 2337 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6401; -- You cannot obtain the item <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6406; -- Obtained: <item>.
GIL_OBTAINED = 6407; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6409; -- Obtained key item: <keyitem>.
FISHING_MESSAGE_OFFSET = 6654; -- You can't fish here.
HOMEPOINT_SET = 2; -- Home point set!
DOOR_IS_LOCKED = 10351; -- The door is locked tight.
-- Other Texts
SPASIJA_DELIVERY_DIALOG = 10345; -- Hiya! I can deliver packages to anybody, anywhere, anytime. What do you say?
PALEILLE_DELIVERY_DIALOG = 10346; -- We can deliver parcels to any residence in Vana'diel.
-- Quest Dialog
YOU_CAN_NOW_BECOME_A_SAMURAI = 10194; -- You can now become a samurai.
CARRYING_TOO_MUCH_ALREADY = 10195; -- I wish to give you your reward, but you seem to be carrying too much already. Come back when you have more room in your pack.
SPASIJA_DIALOG = 10345; -- Hiya! I can deliver packages to anybody, anywhere, anytime. What do you say?
PALEILLE_DIALOG = 10346; -- We can deliver parcels to any residence in Vana'diel.
AVATAR_UNLOCKED = 10465; -- You are now able to summon
NOMAD_MOOGLE_DIALOG = 10533; -- I'm a traveling moogle, kupo. I help adventurers in the Outlands access items they have stored in a Mog House elsewhere, kupo.
FOUIVA_DIALOG = 10557; -- Oi 'av naw business wi' de likes av you.
-- Shop Texts
JIROKICHI_SHOP_DIALOG = 10341; -- Heh-heh-heh. Feast your eyes on these beauties. You won't find stuff like this anywhere!
VULIAIE_SHOP_DIALOG = 10342; -- Please, stay and have a look. You may find something you can only buy here.
ACHIKA_SHOP_DIALOG = 10343; -- Can I interest you in some armor forged in the surrounding regions?
CHIYO_SHOP_DIALOG = 10344; -- Magic scrolls! Magic scrolls! We've got parchment hot off the sheep!
SOLBYMAHOLBY_SHOP_DIALOG = 10571; -- Hiya! My name's Solby-Maholby! I'm new here, so they put me on tooty-fruity shop duty. I'll give you a super-duper deal on unwanted items!
-- conquest Base
CONQUEST_BASE = 6495; -- Tallying conquest results...
-- Porter Moogle
RETRIEVE_DIALOG_ID = 11272; -- You retrieve$ from the porter moogle's care.
| gpl-3.0 |
lichtl/darkstar | scripts/globals/weaponskills/gust_slash.lua | 23 | 1283 | -----------------------------------
-- Gust Slash
-- Dagger weapon skill
-- Skill level: 40
-- Deals wind elemental damage. Damage varies with TP.
-- Will not stack with Sneak Attack.
-- Aligned with the Breeze Gorget.
-- Aligned with the Breeze Belt.
-- Element: Wind
-- Modifiers: DEX:20% ; INT:20%
-- 100%TP 200%TP 300%TP
-- 1.00 2.00 2.50
-----------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {};
params.ftp100 = 1; params.ftp200 = 2; params.ftp300 = 2.5;
params.str_wsc = 0.0; params.dex_wsc = 0.2; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.2; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.ele = ELE_WIND;
params.skill = SKILL_DAG;
params.includemab = true;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.dex_wsc = 0.4; params.int_wsc = 0.4;
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, tp, primary, action, params);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
lichtl/darkstar | scripts/zones/Phomiuna_Aqueducts/npcs/qm4.lua | 14 | 1031 | -----------------------------------
-- Area: Phomiuna Aqueducts
-- NPC: qm4 (???)
-- Notes: Opens west door @ J-9
-- @pos 92.542 -25.907 26.548 27
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local DoorOffset = npc:getID() - 1;
if (GetNPCByID(DoorOffset):getAnimation() == 9) then
GetNPCByID(DoorOffset):openDoor(7); -- _0rj
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
lichtl/darkstar | scripts/zones/Castle_Zvahl_Keep/Zone.lua | 19 | 3875 | -----------------------------------
--
-- Zone: Castle_Zvahl_Keep (162)
--
-----------------------------------
package.loaded["scripts/zones/Castle_Zvahl_Keep/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Castle_Zvahl_Keep/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1, -301,-50,-22, -297,-49,-17); -- central porter on map 3
zone:registerRegion(2, -275,-54,3, -271,-53,7); -- NE porter on map 3
zone:registerRegion(3, -275,-54,-47, -271,-53,-42); -- SE porter on map 3
zone:registerRegion(4, -330,-54,3, -326,-53,7); -- NW porter on map 3
zone:registerRegion(5, -328,-54,-47, -324,-53,-42); -- SW porter on map 3
zone:registerRegion(6, -528,-74,84, -526,-73,89); -- N porter on map 4
zone:registerRegion(7, -528,-74,30, -526,-73,36); -- S porter on map 4
UpdateTreasureSpawnPoint(17441084);
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-555.996,-71.691,59.989,254);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
---------------------------------
[1] = function (x) --
---------------------------------
player:startEvent(0x0000); -- ports player to far NE corner
end,
---------------------------------
[2] = function (x) --
---------------------------------
player:startEvent(0x0002); -- ports player to
end,
---------------------------------
[3] = function (x) --
---------------------------------
player:startEvent(0x0001); -- ports player to far SE corner
end,
---------------------------------
[4] = function (x) --
---------------------------------
player:startEvent(0x0001); -- ports player to far SE corner
end,
---------------------------------
[5] = function (x) --
---------------------------------
player:startEvent(0x0005); -- ports player to H-7 on map 4 (south or north part, randomly)
end,
---------------------------------
[6] = function (x) --
---------------------------------
player:startEvent(0x0006); -- ports player to position "A" on map 2
end,
---------------------------------
[7] = function (x) --
---------------------------------
player:startEvent(0x0007); -- ports player to position G-8 on map 2
end,
default = function (x)
-- print("default");
end,
}
end;
-----------------------------------
-- onRegionLeave
-----------------------------------
function onRegionLeave(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
RunAwayDSP/darkstar | scripts/globals/mobskills/enervation.lua | 12 | 1332 | ---------------------------------------------
-- Enervation
--
-- Description: Lowers the defense and magical defense of enemies within range.
-- Type: Magical (Dark)
---------------------------------------------
require("scripts/globals/monstertpmoves")
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/msg")
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:getFamily() == 91) then
local mobSkin = mob:getModelId()
if (mobSkin == 1680) then
return 0
else
return 1
end
end
return 0
end
function onMobWeaponSkill(target, mob, skill)
local typeEffect = dsp.effect.DEFENSE_DOWN
local silenced = false
local blinded = false
silenced = MobStatusEffectMove(mob, target, dsp.effect.DEFENSE_DOWN, 10, 0, 120)
blinded = MobStatusEffectMove(mob, target, dsp.effect.MAGIC_DEF_DOWN, 8, 0, 120)
skill:setMsg(dsp.msg.basic.SKILL_ENFEEB_IS)
-- display silenced first, else blind
if (silenced == dsp.msg.basic.SKILL_ENFEEB_IS) then
typeEffect = dsp.effect.DEFENSE_DOWN
elseif (blinded == dsp.msg.basic.SKILL_ENFEEB_IS) then
typeEffect = dsp.effect.MAGIC_DEF_DOWN
else
skill:setMsg(dsp.msg.basic.SKILL_MISS)
end
return typeEffect
end
| gpl-3.0 |
we20/ping | plugins/webshot.lua | 919 | 1473 | local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php'
local function get_webshot_url(param)
local response_body = {}
local request_constructor = {
url = url,
method = "GET",
sink = ltn12.sink.table(response_body),
headers = {
referer = base,
dnt = "1",
origin = base,
["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
},
redirect = false
}
local arguments = {
urlparam = param,
size = "FULL"
}
request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok or response_code ~= 200 then
return nil
end
local response = table.concat(response_body)
return string.match(response, "href='(.-)'")
end
local function run(msg, matches)
local find = get_webshot_url(matches[1])
if find then
local imgurl = base .. find
local receiver = get_receiver(msg)
send_photo_from_url(receiver, imgurl)
end
end
return {
description = "Send an screenshot of a website.",
usage = {
"!webshot [url]: Take an screenshot of the web and send it back to you."
},
patterns = {
"^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
| gpl-2.0 |
lichtl/darkstar | scripts/zones/Sacrarium/Zone.lua | 19 | 3611 | -----------------------------------
--
-- Zone: Sacrarium (28)
--
-----------------------------------
package.loaded["scripts/zones/Sacrarium/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/zones/Sacrarium/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
-- Set random variable for determining Old Prof. Mariselle's spawn location
local rand = math.random((2),(7));
SetServerVariable("Old_Prof_Spawn_Location", rand);
UpdateTreasureSpawnPoint(16892179);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-219.996,-18.587,82.795,64);
end
-- ZONE LEVEL RESTRICTION
if (ENABLE_COP_ZONE_CAP == 1) then
player:addStatusEffect(EFFECT_LEVEL_RESTRICTION,50,0,0);
end
return cs;
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onGameDay
-----------------------------------
function onGameDay()
-- Labyrinth
local day = VanadielDayElement() ;
local tbl;
local SacrariumWallOffset = 16892109;
if (day == 3 or day == 7) then
tbl = {9,9,8,8,9,9,8,9,8,8,9,8,8,8,9,8,9,8};
elseif (day == 1 or day == 5) then
tbl = {9,9,8,9,8,8,8,8,9,9,9,8,9,8,8,8,8,9};
elseif (day == 0 or day == 4) then
tbl = {8,9,8,9,8,9,9,8,9,9,8,8,9,8,8,8,8,9};
else
tbl = {9,8,9,9,8,9,8,8,9,8,8,9,8,9,8,9,8,8};
end
GetNPCByID(SacrariumWallOffset):setAnimation(tbl[1]);
GetNPCByID(SacrariumWallOffset+6):setAnimation(tbl[2]);
GetNPCByID(SacrariumWallOffset+12):setAnimation(tbl[3]);
GetNPCByID(SacrariumWallOffset+13):setAnimation(tbl[4]);
GetNPCByID(SacrariumWallOffset+1):setAnimation(tbl[5]);
GetNPCByID(SacrariumWallOffset+7):setAnimation(tbl[6]);
GetNPCByID(SacrariumWallOffset+14):setAnimation(tbl[7]);
GetNPCByID(SacrariumWallOffset+2):setAnimation(tbl[8]);
GetNPCByID(SacrariumWallOffset+8):setAnimation(tbl[9]);
GetNPCByID(SacrariumWallOffset+9):setAnimation(tbl[10]);
GetNPCByID(SacrariumWallOffset+3):setAnimation(tbl[11]);
GetNPCByID(SacrariumWallOffset+15):setAnimation(tbl[12]);
GetNPCByID(SacrariumWallOffset+16):setAnimation(tbl[13]);
GetNPCByID(SacrariumWallOffset+10):setAnimation(tbl[14]);
GetNPCByID(SacrariumWallOffset+4):setAnimation(tbl[15]);
GetNPCByID(SacrariumWallOffset+17):setAnimation(tbl[16]);
GetNPCByID(SacrariumWallOffset+11):setAnimation(tbl[17]);
GetNPCByID(SacrariumWallOffset+5):setAnimation(tbl[18]);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
RunAwayDSP/darkstar | scripts/zones/Yhoator_Jungle/npcs/qm3.lua | 6 | 1078 | -----------------------------------
-- Area: Yhoator Jungle
-- NPC: ??? (qm3)
-- Involved in Quest: True will
-- !pos 203 0.1 82 124
-----------------------------------
local ID = require("scripts/zones/Yhoator_Jungle/IDs")
require("scripts/globals/keyitems")
require("scripts/globals/npc_util")
require("scripts/globals/quests")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
if player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.TRUE_WILL) == QUEST_ACCEPTED and not player:hasKeyItem(dsp.ki.OLD_TRICK_BOX) then
if player:getCharVar("trueWillKilledNM") > 0 then
npcUtil.giveKeyItem(player, dsp.ki.OLD_TRICK_BOX)
player:setCharVar("trueWillKilledNM", 0)
else
npcUtil.popFromQM(player, npc, {ID.mob.KAPPA_AKUSO, ID.mob.KAPPA_BONZE, ID.mob.KAPPA_BIWA}, { hide = 0 })
end
else
player:messageSpecial(ID.text.NOTHING_OUT_OF_ORDINARY)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
OctoEnigma/shiny-octo-system | gamemodes/base/entities/entities/base_entity/outputs.lua | 2 | 2376 |
-- This is called from ENT:KeyValue(key,value) to store the output from
-- the map, it could also be called from ENT:AcceptInput I think, so if
-- ent_fire addoutput is used, we can store that too (that hasn't been
-- tested though).
-- Usage: self:StoreOutput("<name of output>","<entities to fire>,<input name>,<param>,<delay>,<times to be used>")
-- If called from ENT:KeyValue, then the first parameter is the key, and
-- the second is value.
function ENT:StoreOutput( name, info )
local rawData = string.Explode( ",", info )
local Output = {}
Output.entities = rawData[1] or ""
Output.input = rawData[2] or ""
Output.param = rawData[3] or ""
Output.delay = tonumber( rawData[4] ) or 0
Output.times = tonumber( rawData[5] ) or -1
self.m_tOutputs = self.m_tOutputs or {}
self.m_tOutputs[ name ] = self.m_tOutputs[ name ] or {}
table.insert( self.m_tOutputs[ name ], Output )
end
-- Nice helper function, this does all the work. Returns false if the
-- output should be removed from the list.
local function FireSingleOutput( output, this, activator, data )
if ( output.times == 0 ) then return false end
local entitiesToFire = {}
if ( output.entities == "!activator" ) then
entitiesToFire = { activator }
elseif ( output.entities == "!self" ) then
entitiesToFire = { this }
elseif ( output.entities == "!player" ) then
entitiesToFire = player.GetAll()
else
entitiesToFire = ents.FindByName( output.entities )
end
for _, ent in pairs( entitiesToFire ) do
if ( output.delay == 0 ) then
if ( IsValid( ent ) ) then
ent:Input( output.input, activator, this, data or output.param )
end
else
timer.Simple( output.delay, function()
if ( IsValid( ent ) ) then
ent:Input( output.input, activator, this, data or output.param )
end
end )
end
end
if ( output.times ~= -1 ) then
output.times = output.times - 1
end
return ( output.times > 0 ) || ( output.times == -1 )
end
-- This function is used to trigger an output.
function ENT:TriggerOutput( name, activator, data )
if ( !self.m_tOutputs ) then return end
if ( !self.m_tOutputs[ name ] ) then return end
local OutputList = self.m_tOutputs[ name ]
for idx = #OutputList, 1, -1 do
if ( OutputList[ idx ] and !FireSingleOutput( OutputList[ idx ], self.Entity, activator, data ) ) then
self.m_tOutputs[ name ][ idx ] = nil
end
end
end
| mit |
RunAwayDSP/darkstar | scripts/zones/Temenos/mobs/Temenos_Aern.lua | 9 | 1920 | -----------------------------------
-- Area: Temenos
-- Mob: Temenos Aern
-----------------------------------
require("scripts/globals/limbus");
-----------------------------------
function onMobDeath(mob, player, isKiller)
local mobID = mob:getID();
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
switch (mobID): caseof {
[16929054] = function (x)
GetNPCByID(16928768+197):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+197):setStatus(dsp.status.NORMAL);
end,
[16929060] = function (x)
GetNPCByID(16928768+199):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+199):setStatus(dsp.status.NORMAL);
end,
[16929065] = function (x)
GetNPCByID(16928768+200):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+200):setStatus(dsp.status.NORMAL);
end,
[16929075] = function (x)
GetNPCByID(16928768+201):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+201):setStatus(dsp.status.NORMAL);
end,
[16929083] = function (x)
GetNPCByID(16928768+202):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+202):setStatus(dsp.status.NORMAL);
end,
}
local leftAern=0;
local AernList = {16929053,16929054,16929055,16929057,16929058,16929060,16929061,16929062,16929063,
16929064,16929065,16929066,16929069,16929071,16929072,16929073,16929075,16929076,
16929077,16929078,16929079,16929082,16929083,16929084,16929085,16929086,16929087};
for n=1,27,1 do
if ( GetMobByID(AernList[n]):isAlive() ) then
leftAern=leftAern+1;
end
end
--print("leftAern" ..leftAern);
if (leftAern == 0 and isKiller == true) then
GetMobByID(16929088):setSpawn(mobX,mobY,mobZ);
GetMobByID(16929088):setPos(mobX,mobY,mobZ);
SpawnMob(16929088):updateEnmity(player);
end
end;
| gpl-3.0 |
lichtl/darkstar | scripts/globals/items/wild_pineapple.lua | 18 | 1180 | -----------------------------------------
-- ID: 4598
-- Item: wild_pineapple
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Agility -5
-- Intelligence 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,4598);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, -5);
target:addMod(MOD_INT, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, -5);
target:delMod(MOD_INT, 3);
end;
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.