content
stringlengths
5
1.05M
-- Copyright 2021 - Deviap (deviap.com) -- Author(s): Sanjay-B(Sanjay) -- Creates the Develop page. local card = require("devgit:source/libraries/UI/components/cards/editApp.lua") local gridLayout = require("devgit:source/libraries/UI/constraints/controllers/gridLayout.lua") local primaryButton = require("devgit:source/libraries/UI/components/buttons/primaryButton.lua") local secondaryButton = require("devgit:source/libraries/UI/components/buttons/secondaryButton.lua") return { default = false, construct = function(parent) local scrollContainer = core.construct("guiScrollView", { parent = parent, position = guiCoord(0, 0, 0, 0), size = guiCoord(1, 0, 1, 0), scrollbarColour = colour.hex("#212121"), scrollbarRadius = 0, scrollbarWidth = 2, scrollbarAlpha = 0 }) local heading = core.construct("guiTextBox", { parent = scrollContainer, text = "Develop", position = guiCoord(0, 11, 0, 4), size = guiCoord(1, 0, 0, 78), textSize = 38, textFont = "deviap:fonts/openSansExtraBold.ttf", backgroundAlpha = 0 }) local subheading1 = core.construct("guiTextBox", { parent = scrollContainer, text = "Options", position = guiCoord(0, 11, 0, 50), size = guiCoord(1, 0, 0, 78), textSize = 20, textAlpha = 0.8, textFont = "deviap:fonts/openSansSemiBold.ttf", backgroundAlpha = 0 }) primaryButton { parent = scrollContainer, position = guiCoord(0, 11, 0, 80), text = "OPEN UNPACKED APP", textAlign = "middle", strokeRadius = 5 }.state.subscribe(function(state) if state.active then core.apps:promptAppDirectory() end end) secondaryButton { parent = scrollContainer, position = guiCoord(0, 11, 0, 135), text = "OPEN SUITE", textAlign = "middle", strokeRadius = 5 }.state.subscribe(function(state) if state.active then self. require("degit:source/suite/main.lua") end end) local subheading2 = core.construct("guiTextBox", { parent = scrollContainer, text = "Apps", position = guiCoord(0, 11, 0, 200), size = guiCoord(1, 0, 0, 78), textSize = 20, textAlpha = 0.8, textFont = "deviap:fonts/openSansSemiBold.ttf", backgroundAlpha = 0 }) local layout = gridLayout() layout.container.parent = scrollContainer layout.container.position = guiCoord(0, 10, 0, 230) layout.container.size = guiCoord(1, -20, 1, -240) layout.container.canvasSize = guiCoord(0, 0, 0, 0) layout.container.backgroundColour = colour.hex("#FF0000") layout.container.backgroundAlpha = 0 layout.container.scrollbarAlpha = 0 layout.rows = 1 layout.columns = 8 layout.cellSize = vector2(100, 130) layout.cellSpacing = vector2(10, 10) layout.fitX = false layout.fitY = false layout.wrap = true core.http:get("https://deviap.com/api/v1/users/"..(core.networking.localClient.id).."/apps", {["Authorization"] = "Bearer " .. core.engine:getUserToken()}, function(status, body) local response = core.json:decode(body) for index, entry in pairs(response) do card { parent = layout.container, title = (string.len(entry["name"]) > 15 and string.sub(entry["name"], 1, 12).."...") or entry["name"], name = entry["username"], thumbnail = "https://cdn.deviap.com/"..(entry["icon"] or "") }.container:on("mouseLeftUp", function() -- Route to suite to open the app specifically end) end end) end }
local function init() require 'verdverm.vim'.init() require 'verdverm.packer'.init() require 'verdverm.cue'.init() require 'verdverm.venn'.init() end return { init = init, }
local map = vim.api.nvim_set_keymap -- moving up and down the right way map("n", "j", "gj", { noremap = true, silent = true }) map("n", "k", "gk", { noremap = true, silent = true }) -- disable dead keys map("n", "<Up>", "<Nop>", { noremap = true, silent = true }) map("n", "<Down>", "<Nop>", { noremap = true, silent = true }) map("n", "<Left>", "<Nop>", { noremap = true, silent = true }) map("n", "<Right>", "<Nop>", { noremap = true, silent = true }) map("i", "<Up>", "<Nop>", { noremap = true, silent = true }) map("i", "<Down>", "<Nop>", { noremap = true, silent = true }) map("i", "<Left>", "<Nop>", { noremap = true, silent = true }) map("i", "<Right>", "<Nop>", { noremap = true, silent = true }) map("n", "Q", "<Nop>", { noremap = true, silent = true }) map("n", "<C-z>", "<Nop>", { noremap = true, silent = true }) -- save as root map("c", "w!!", "w !sudo tee % >/dev/null<CR>:e!<CR><CR>", { noremap = true }) -- open vim config map("n", "<Leader>rc", ":e $MYVIMRC<CR>", { noremap = true }) -- keep visual selection when indenting map("v", "<", "<gv", { noremap = true, silent = true }) map("v", ">", ">gv", { noremap = true, silent = true }) -- deal with clipboard map("n", "<Leader>y", '"+y', { noremap = true }) map("v", "<Leader>y", '"+y', { noremap = true }) map("n", "<Leader>p", '"+p', { noremap = true }) map("v", "<Leader>p", '"+p', { noremap = true }) map("n", "<Leader>P", '"+P', { noremap = true }) -- buffer navigation map("n", "<Leader>,", "<C-^>", { noremap = true }) map("n", "<Leader>ls", ":buffers<CR>", { noremap = true }) map("n", "gb", ":bnext<CR>", { noremap = true }) map("n", "gB", ":bprev<CR>", { noremap = true }) -- search and replace the word under cursor map("n", "<Leader>*", ":%s/<C-r><C-w>//<Left>", { noremap = true })
-- Zone: Kuftal Tunnel (174) -- Desc: this file contains functions that are shared by multiple luas in this zone's directory ----------------------------------- local ID = require("scripts/zones/Kuftal_Tunnel/IDs") require("scripts/globals/status") ----------------------------------- KUFTAL_TUNNEL = { --[[.............................................................................................. move Phantom Worm QM ..............................................................................................]] movePhantomWormQM = function() local npc = GetNPCByID(ID.npc.PHANTOM_WORM_QM) switch (math.random(1, 16)): caseof { [1] = function (x) npc:setPos(75.943, 29.969, 118.854) end, [2] = function (x) npc:setPos(75.758, 30.000, 125.815) end, [3] = function (x) npc:setPos(65.222, 29.364, 131.645) end, [4] = function (x) npc:setPos(53.088, 25.033, 138.725) end, [5] = function (x) npc:setPos(85.658, 30.155, 123.941) end, [6] = function (x) npc:setPos(91.153, 30.146, 113.657) end, [7] = function (x) npc:setPos(86.549, 29.875, 107.232) end, [8] = function (x) npc:setPos(94.763, 29.054, 105.138) end, [9] = function (x) npc:setPos(102.719, 26.751, 102.816) end, [10] = function (x) npc:setPos(71.571, 30.241, 110.704) end, [11] = function (x) npc:setPos(65.642, 28.018, 99.2442) end, [12] = function (x) npc:setPos(62.090, 25.421, 93.4702) end, [13] = function (x) npc:setPos(60.740, 22.638, 86.1781) end, [14] = function (x) npc:setPos(80.460, 30.293, 112.721) end, [15] = function (x) npc:setPos(76.929, 30.050, 127.630) end, [16] = function (x) npc:setPos(68.810, 30.175, 123.516) end, } npc:timer(5000, function(npc) KUFTAL_TUNNEL.movePhantomWormQM() end) end } return KUFTAL_TUNNEL
-- This projects ports to Mote the excellent tutorial found here: -- -- https://codeincomplete.com/posts/tiny-platformer/ -- -- This tutorial is well worth reading. Though it is written in ActionScript, -- the concepts are portable to any development environment used for making games. -- -- This project loads a tmx file, but only uses the first layer. -- -- This project does not rely on the Mote entity system, and instead it -- implements a separate physics sim more amenable to platforming gameplay. -- -- The player keeps a redundant copy of tuning constants so that UpdateActor() -- can be written in anticipation of adding different types of actors later that -- may have different tuning values so that they behave differently from the player. -- tuning parameters for player input GRAVITY = 1.2 MAX_SPEED = { x = 3.4375, y = 6.3 } LINEAR_ACCELERATION = 0.625 -- how fast the player accelerates when walking FRICTION = 2 JUMP_IMPULSE = 25 FALLING_FRICTION_SCALE = 0.5 FALLING_ACCELERATION_SCALE = 0.5 SETTLE_TOLERANCE = 0.11 -- higher number indicates max penetration for player to snap to grid when coming to a stop. -- helper functions function getCell(x, y) return map.tiles[1][(x + (y * map.width)) + 1] -- +1 because of lua array indexing end function InitActor(actor, x, y) actor.x = x actor.y = y actor.left = false actor.right = false actor.jump = false actor.jumping = false actor.falling = false actor.velocity = { x = 0, y = 0 } actor.acceleration = { x = 0, y = 0 } actor.friction = FRICTION actor.linearAcceleration = LINEAR_ACCELERATION actor.maxVelocityX = MAX_SPEED.x actor.maxVelocityY = MAX_SPEED.y actor.jumpImpulse = JUMP_IMPULSE end function UpdatePlayerInput() player.left = false player.right = false player.jump = false if IsKeyDown(SDL_SCANCODE_LEFT) then player.left = true end if IsKeyDown(SDL_SCANCODE_RIGHT) then player.right = true end if IsKeyDown(SDL_SCANCODE_SPACE) then player.jump = true end end function UpdateActor(actor) local wasLeft = actor.velocity.x < 0 local wasRight = actor.velocity.x > 0 local falling = actor.falling local friction = actor.friction * Pick(falling, FALLING_FRICTION_SCALE, 1.0) local acceleration = actor.linearAcceleration * Pick(falling, FALLING_ACCELERATION_SCALE, 1.0) actor.acceleration.x = 0 actor.acceleration.y = GRAVITY if actor.left then actor.acceleration.x = actor.acceleration.x - acceleration elseif wasLeft then actor.acceleration.x = actor.acceleration.x + friction end if actor.right then actor.acceleration.x = actor.acceleration.x + acceleration elseif wasRight then actor.acceleration.x = actor.acceleration.x - friction end --start jumping? if actor.jump and not actor.jumping and not falling then actor.acceleration.y = actor.acceleration.y - actor.jumpImpulse actor.jumping = true end local dt = GetFrameTime() / 100.0 actor.x = actor.x + actor.velocity.x * dt actor.y = actor.y + actor.velocity.y * dt actor.velocity.x = Clamp(actor.velocity.x + actor.acceleration.x * dt, -actor.maxVelocityX, actor.maxVelocityX) actor.velocity.y = Clamp(actor.velocity.y + actor.acceleration.y * dt, -actor.maxVelocityY, actor.maxVelocityY) --clamp x velocity to prevent jiggle when changing directions if (wasLeft and actor.velocity.x > 0) or (wasRight and actor.velocity.x < 0) then actor.velocity.x = 0 end local tileX = math.floor(actor.x) local tileY = math.floor(actor.y) -- how deeply are we penetrating other tiles? nx = math.fmod(actor.x, 1) ny = math.fmod(actor.y, 1) local cell = getCell(tileX, tileY) local cellRight = getCell(tileX + 1, tileY) local cellDown = getCell(tileX, tileY + 1) local cellDiag = getCell(tileX + 1, tileY + 1) if Contains(map.walkable, cell) then cell = nil end if Contains(map.walkable, cellRight) then cellRight = nil end if Contains(map.walkable, cellDown) then cellDown = nil end if Contains(map.walkable, cellDiag) then cellDiag = nil end if actor.velocity.y > 0 then if (cellDown and not cell) or (cellDiag and not cellRight and nx > 0) then actor.y = tileY actor.velocity.y = 0 actor.falling = false actor.jumping = false ny = 0 end elseif actor.velocity.y < 0 then if (cell and not cellDown) or (cellRight and not cellDiag and nx > 0) then actor.y = tileY + 1 actor.velocity.y = 0 cell = cellDown cellRight = cellDiag ny = 0 end end if actor.velocity.x > 0 then if (cellRight and not cell) or (cellDiag and not cellDown and ny > 0) then actor.x = tileX actor.velocity.x = 0 end elseif actor.velocity.x < 0 then if (cell and not cellRight) or (cellDown and not cellDiag and ny > 0) then actor.x = tileX + 1 actor.velocity.x = 0 end end actor.falling = not (cellDown or (nx > 0 and cellDiag)) -- let the actor tend to settle aligned to the grid so that it can fit through one-tile holes. if actor.velocity.x == 0 and actor.velocity.y == 0 and math.fmod(actor.x, 1) < SETTLE_TOLERANCE then actor.x = math.floor(actor.x) end end function DrawWorld() for y = 0, map.height - 1 do for x = 0, map.width - 1 do local tileImageIndex = map.tiles[1][(x + y * map.width) + 1] DrawImageFrame(tileImage, x * map.tileSize, y * map.tileSize, map.tileSize, map.tileSize, tileImageIndex - 1, 0, 1) end end end function DrawPlayer() SetDrawColor(255, 255, 255, 255) FillRect(player.x * map.tileSize, player.y * map.tileSize, map.tileSize, map.tileSize) end -- core functions function Start() LoadTmxFile(assetDirectory .. "maps/platformer.tmx") -- This example can handle maps with different tile sizes. For example, comment out the previous LoadTmxFile() call and uncomment this: -- LoadTmxFile(assetDirectory .. "maps/platformer32.tmx") map.walkable = {1, 2} --indices of tiles that the player and other actors can walk through. CreateWindow(map.width * map.tileSize, map.height * map.tileSize) SetWindowTitle("Platformer") tileImage = LoadImage(map.tileAtlas) player = {} InitActor(player, 10, 22) end function Update() UpdatePlayerInput() UpdateActor(player) end function Draw() DrawWorld() DrawPlayer() end
local type = type local assert = assert local find = string.find local urldecode = require "url".decode local codes = { [301] = "301 Moved Permanently", -- (永久移动) [302] = "302 Found", -- (发现) [303] = "303 See Other", -- (查看其他) [307] = "307 Temporary Redirect", -- (临时重定向) [308] = "308 Permanent Redirect", -- (永久重定向) } ---comment 检查状态码是否在指定范围内 ---@param code number @HTTP状态码 ---@return boolean | integer local function check_code(code) return codes[code] and code or nil end ---comment 检查重定向的url是否合法. ---@param url string @合法的路由或http[s]地址 ---@return boolean | string local function check_url(url) if type(url) ~= "string" or url == "" then return false end url = urldecode(url) if find(url, "^/.*") then return url end if find(url, "^http[s]?://.*") then return url end return false end ---comment 让注册的`USE`/`API`路由可以合法的重定向. ---@param code integer @HTTP状态码. ---@param url string @需要重定向的`URL`. return function (code, url) return { __OPCODE__ = -65536, __CODE__ = assert(check_code(code), "Invalid http code.") , __MSG__ = assert(check_url(url), "Invalid url") } end
--[[ Name: "sh_ks_teargrenade.lua". Product: "HL2 RP". --]] local ITEM = {}; -- Set some information. ITEM.base = "grenade_base"; ITEM.name = "Tear Grenade"; ITEM.cost = 50; ITEM.model = "models/items/grenadeammo.mdl"; ITEM.weight = 0.8; ITEM.uniqueID = "ks_teargrenade"; ITEM.business = true; ITEM.vocations = {VOC_CPA_EPU, VOC_OTA_OWC}; ITEM.description = "A dirty tube of dust, is this supposed to be a grenade?"; -- Register the item. kuroScript.item.Register(ITEM);
math.randomseed(os.time()) local function random_color() color={} for i=1, 3 do color[i]=math.random(0, 255) end return color end local function random_colors(k) local random_colors={} for i=1, k or 10000 do table.insert(random_colors, random_color()) end return random_colors end local function test_correctness() local k=0 for i = 1, 1000 do local colors=random_colors(1000) local tree=kd_closest_color_finder(colors) local color=random_color() --colors[math.random(1, 20)] local linear, lin_distance=linear_closest_color_finder(colors)(color) local kd, kd_distance=tree(color) if lin_distance == kd_distance then k=k+1 end end print(tostring(k).." of 1000 samples") end local function test_performance() local color=random_color() --colors[math.random(1, 20)] local colors=random_colors(10000) local tree=kd_closest_color_finder(colors) local linear=linear_closest_color_finder(colors) for _, tree in ipairs({tree, linear}) do local x = os.clock() local s = 0 for i = 1, 1000 do kd, kd_distance=tree(color) end print(string.format("elapsed time: %.2f", os.clock() - x)) end end print("Closest Color Finder Test : ") test_correctness() test_performance() local function test_texture_reader() image = read_texture(get_resource("voxelizer", "test/image.png")) print("Texture Reader Test : ") print(color_to_number(color_to_table(get_texture_color_at(image, 0, 0))) == 0x00000000) print(color_to_number(color_to_table(get_texture_color_at(image, 1, 0))) == 0xFFFF0000) print(color_to_number(color_to_table(get_texture_color_at(image, 0, 1))) == 0xFF00FF00) print(color_to_number(color_to_table(get_texture_color_at(image, 1, 1))) == 0xFF0000FF) end test_texture_reader() local function test_nodemap_reader() print("Nodemap Reader Test : ") local color_to_cid = read_node_map(modlib.file.read("/usr/share/games/minetest/minetestmapper-colors.txt")) for c, cid in pairs(color_to_cid) do print(string.format("%x", c).." -> "..minetest.get_name_from_content_id(cid)) end end test_nodemap_reader()
--[[ --===================================================================-- Description: HPC Stats Script (Standalone), Phasor V2+ Copyright (c) 2016-2018 * Author: Jericho Crosby * IGN: Chalwk * Version: 4.0.1 (Heavily Modified) * Written and Created by Jericho Crosby * Credits to the original creator(s): SlimJim | Kennan -- You can optionally define game mode settings in: -- Default Game Mode = 'Zombies_Stats' -- * function SetVehicleSettings() --===================================================================-- ]]-- BLUE_TEAM = 1 RED_TEAM = 1 - BLUE_TEAM AnnounceRank = true default_script_prefix = "* " phasor_privatesay = privatesay phasor_say = say game_started = false processid = 0 kill_count = 0 New_Game_Timer = 0 cur_players = 0 cur_red_count = 0 cur_blue_count = 0 time = { } -- Declare time. Used for player's time spent in server. kills = { } avenge = { } killers = { } xcoords = { } -- Declare x coords. Used for distance traveled. ycoords = { } -- Declare y coords. Used for distance traveled. zcoords = { } -- Declare z coords. Used for distance traveled. messages = { } jointime = { } -- Declare Jointime. Used for a player's time spent in server. hash_table = { } last_damage = { } kill_command_count = { } function say(message, script_prefix) if GAME == "PC" then phasor_say((script_prefix or default_script_prefix) .. " " .. message, false) else phasor_say(message, false) end end function privatesay(player, message, script_prefix) if GAME == "PC" then phasor_privatesay(player, (script_prefix or default_script_prefix) .. " " .. message, false) else phasor_privatesay(player, message, false) end end function Say(message, time, exception) time = time or 3 for i = 0, 15 do if getplayer(i) and exception ~= i then privateSay(i, message, time) end end end function privateSay(player, message, time) local time = time or 3 if message then sendconsoletext(player, message, time) end end function GetGameAddresses(GAME) if GAME == "PC" then oddball_globals = 0x639E18 slayer_globals = 0x63A0E8 name_base = 0x745D4A specs_addr = 0x662D04 hashcheck_addr = 0x59c280 versioncheck_addr = 0x5152E7 map_pointer = 0x63525c gametype_base = 0x671340 gametime_base = 0x671420 machine_pointer = 0x745BA0 timelimit_address = 0x626630 special_chars = 0x517D6B gametype_patch = 0x481F3C devmode_patch1 = 0x4A4DBF devmode_patch2 = 0x4A4E7F hash_duplicate_patch = 0x59C516 else oddball_globals = 0x5BDEB8 slayer_globals = 0x5BE108 name_base = 0x6C7B6A specs_addr = 0x5E6E63 hashcheck_addr = 0x530130 versioncheck_addr = 0x4CB587 map_pointer = 0x5B927C gametype_base = 0x5F5498 gametime_base = 0x5F55BC machine_pointer = 0x6C7980 timelimit_address = 0x5AA5B0 special_chars = 0x4CE0CD gametype_patch = 0x45E50C devmode_patch1 = 0x47DF0C devmode_patch2 = 0x47DFBC hash_duplicate_patch = 0x5302E6 end end function GetRequiredVersion() return 200 end function OnScriptLoad(processId, game, persistent) if game == true or game == "PC" then GAME = "PC" else GAME = "CE" end GetGameAddresses(GAME) if persistent == true then -- Script does not support persistence, therefore terminate. registertimer(2300, "Terminate", { "=============================================================", " ~~~~~~~~~~~~~~~~~~~WARNING~~~~~~~~~~~~~~~~~~", " ~~~~~~~PERSISTENCE MODE NOT SUPPORTED~~~~~~", " ~~~~~~~~~~~~~SCRIPT CANNOT BE USED~~~~~~~~", "=============================================================" }) end if readbyte(gametype_base, 0x34) == 2 -- Slayer or readbyte(gametype_base, 0x34) == 3 -- Oddball or readbyte(gametype_base, 0x34) == 4 -- King of the Hill or readbyte(gametype_base, 0x34) == 5-- Race then registertimer(2300, "Terminate", { "=============================================================", " ~~~~~~~~~~~~~~~~WARNING~~~~~~~~~~~~~~~~~", " ~~~~~This script only supports CTF!~~~~~", " ~~~~~~~~~~SCRIPT CANNOT BE USED~~~~~~~~~", "=============================================================" }) end gametype = readbyte(gametype_base + 0x30) ------------------------------------------- -- OPEN FILES: -- Stats.txt -- KillStats.txt -- Sprees.txt -- Medals.txt -- Extra.txt -- CompletedMedals.txt OpenFiles() ------------------------------------------- processid = processId SERVER_NAME = getservername() game_started = true if game == "PC" then gametype_base = 0x671340 elseif game == "CE" then gametype_base = 0x5F5498 end -- Recalculate team counters. cur_blue_count = getteamsize(BLUE_TEAM) cur_red_count = getteamsize(RED_TEAM) cur_players = cur_blue_count + cur_red_count end function OnScriptUnload() -- Save Tables table.save(sprees, "Sprees.txt") table.save(medals, "Medals.txt") table.save(stats, "Stats.txt") end function Terminate(id, count, message) if message then for v = 1, #message do hprintf(message[v]) end end svcmd("sv_end_game") return 0 end function OnNewGame(map) -- Map Name map_name = tostring(map) -- Reset Variables cur_blue_count = 0 cur_red_count = 0 cur_players = 0 -- Game hasn't started yet. (Not until the timer counts down) game_started = false -- Initialize Countdown new_game_timer = registertimer(1000, "CountdownToGameStart") Rule_Timer = registertimer(1000, "RuleTimer") gametype = readbyte(gametype_base + 0x30, 0x0) end function OnGameEnd(stage) -- stage 1: F1 Screen -- stage 2: PGCR Appears -- stage 3: Players may quit if stage == 1 then -- < Remove Timers if New_Game_Timer then New_Game_Timer = nil end if credit_timer then credit_timer = nil end if Rule_Timer then Rule_Timer = nil end -- > registertimer(10, "AssistDelay") for i = 0, 15 do if getplayer(i) then -- Verify Red Team if getteam(i) == RED_TEAM then changescore(i, 50, plus) -- If a human survives the game without dying, then reward them 50+ cR SendMessage(i, "Awarded: +50 (cR) - Survivor") killstats[gethash(i)].total.credits = killstats[gethash(i)].total.credits + 50 end -- If the palyer has less than 3 kills on game end, then award them 15+ cR if readword(getplayer(i) + 0xAE) < 3 then -- player deaths changescore(i, 15, plus) SendMessage(i, "Awarded: +15 (cR) - Less then 3 Deaths") killstats[gethash(i)].total.credits = killstats[gethash(i)].total.credits + 15 end extra[gethash(i)].woops.gamesplayed = extra[gethash(i)].woops.gamesplayed + 1 time = os.time() - jointime[gethash(i)] extra[gethash(i)].woops.time = extra[gethash(i)].woops.time + time end end end if stage == 1 then table.save(killstats, "KillStats.txt") table.save(extra, "Extra.txt") table.save(done, "CompletedMedals.txt") end if stage == 2 then table.save(sprees, "Sprees.txt") end if stage == 3 then table.save(stats, "Stats.txt") table.save(medals, "Medals.txt") table.save(extra, "Extra.txt") end game_started = false end function OnServerChat(player, type, message) local Message = string.lower(message) local t = tokenizestring(Message, " ") local count = #t if player ~= nil then local hash = gethash(player) if Message == "@kill" then -- Verify Red Team if getteam(player) ~= RED_TEAM then if isplayerdead(player) == false then if kill_command_count[hash] <= 5 then kill_command_count[hash] = kill_command_count[hash] + 1 kill(player) say(getname(player) .. " killed themself.") else privatesay(player, "You are only allowed to kill yourself 5 times in a match!") end else privatesay(player, "You are dead! You can not kill yourself!") end else privatesay(player, "You are a Human, you can not kill yourself.") end return false elseif Message == "@stuck" then sendconsoletext(player, "If you are stuck in the wall you can :") sendconsoletext(player, "1. Get out of your vehicle and walk.") sendconsoletext(player, "2. Type \"@kill\" and respawn again.") return false elseif Message == "@info" then privatesay(player, "\"@weapons\": Will display stats for eash weapon.") privatesay(player, "\"@stats\": Will display about your kills, deaths etc.") privatesay(player, "\"@sprees\": Will display info about your Killing Spreees.") privatesay(player, "\"@rank\": Will display info about your rank.") privatesay(player, "\"@medals\": Will display info about your medals.") return false elseif Message == "@weapons" then -- ========================================================================================================================================================================= privatesay(player, "Assault Rifle: " .. stats[hash].kills.assaultrifle .. " | Banshee: " .. stats[hash].kills.banshee .. " | Banshee Fuel Rod: " .. stats[hash].kills.bansheefuelrod .. " | Chain Hog: " .. stats[hash].kills.chainhog) privatesay(player, "EMP Blast: " .. extra[hash].woops.empblast .. " | Flame Thrower: " .. stats[hash].kills.flamethrower .. " | Frag Grenade: " .. stats[hash].kills.fragnade .. " | Fuel Rod: " .. stats[hash].kills.fuelrod) privatesay(player, "Ghost: " .. stats[hash].kills.ghost .. " | Melee: " .. stats[hash].kills.melee .. " | Needler: " .. stats[hash].kills.needler .. " | People Splattered: " .. stats[hash].kills.splatter) privatesay(player, "Pistol: " .. stats[hash].kills.pistol .. " | Plasma Grenade: " .. stats[hash].kills.plasmanade .. " | Plasma Pistol: " .. stats[hash].kills.plasmapistol .. " | Plasma Rifle: " .. stats[hash].kills.plasmarifle) privatesay(player, "Rocket Hog: " .. extra[hash].woops.rockethog .. " | Rocket Launcher: " .. stats[hash].kills.rocket .. " | Shotgun: " .. stats[hash].kills.shotgun .. " | Sniper Rifle: " .. stats[hash].kills.sniper) privatesay(player, "Stuck Grenade: " .. stats[hash].kills.grenadestuck .. " | Tank Machine Gun: " .. stats[hash].kills.tankmachinegun .. " | Tank Shell: " .. stats[hash].kills.tankshell .. " | Turret: " .. stats[hash].kills.turret) -- ========================================================================================================================================================================= return false elseif Message == "@stats" then local Player_KDR = RetrievePlayerKDR(player) local cpm = math.round(killstats[hash].total.credits / extra[hash].woops.gamesplayed, 2) if cpm == 0 or cpm == nil then cpm = "No credits earned" end local days, hours, minutes, seconds = secondsToTime(extra[hash].woops.time, 4) -- ========================================================================================================================================================================= privatesay(player, "Kills: " .. killstats[hash].total.kills .. " | Deaths: " .. killstats[hash].total.deaths .. " | Assists: " .. killstats[hash].total.assists) privatesay(player, "KDR: " .. Player_KDR .. " | Suicides: " .. killstats[hash].total.suicides .. " | Betrays: " .. killstats[hash].total.betrays) privatesay(player, "Games Played: " .. extra[hash].woops.gamesplayed .. " | Time in Server: " .. days .. "d " .. hours .. "h " .. minutes .. "m " .. seconds .. "s") privatesay(player, "Distance Traveled: " .. math.round(extra[hash].woops.distance / 1000, 2) .. " kilometers | Credits Per Map: " .. cpm) -- ========================================================================================================================================================================= return false elseif Message == "@sprees" then -- ========================================================================================================================================================================= privatesay(player, "Double Kill: " .. sprees[hash].count.double .. " | Triple Kill: " .. sprees[hash].count.triple .. " | Overkill: " .. sprees[hash].count.overkill .. " | Killtacular: " .. sprees[hash].count.killtacular) privatesay(player, "Killtrocity: " .. sprees[hash].count.killtrocity .. " | Killimanjaro " .. sprees[hash].count.killimanjaro .. " | Killtastrophe: " .. sprees[hash].count.killtastrophe .. " | Killpocalypse: " .. sprees[hash].count.killpocalypse) privatesay(player, "Killionaire: " .. sprees[hash].count.killionaire .. " | Kiling Spree " .. sprees[hash].count.killingspree .. " | Killing Frenzy: " .. sprees[hash].count.killingfrenzy .. " | Running Riot: " .. sprees[hash].count.runningriot) privatesay(player, "Rampage: " .. sprees[hash].count.rampage .. " | Untouchable: " .. sprees[hash].count.untouchable .. " | Invincible: " .. sprees[hash].count.invincible .. " | Anomgstopkillingme: " .. sprees[hash].count.anomgstopkillingme) privatesay(player, "Unfrigginbelievable: " .. sprees[hash].count.unfrigginbelievable .. " | Minutes as Last Man Standing: " .. sprees[hash].count.timeaslms) -- ========================================================================================================================================================================= return false elseif Message == "@rank" then local credits = { } for k, _ in pairs(killstats) do table.insert(credits, { ["hash"] = k, ["credits"] = killstats[k].total.credits }) end table.sort(credits, function(a, b) return a.credits > b.credits end) for k, v in ipairs(credits) do if hash == credits[k].hash then local until_next_rank = CreditsUntilNextPromo(player) -- ========================================================================================================================================================================= privatesay(player, "You are ranked " .. k .. " out of " .. #credits .. "!") privatesay(player, "Credits: " .. killstats[hash].total.credits .. " | Rank: " .. killstats[hash].total.rank) privatesay(player, "Credits Until Next Rank: " .. until_next_rank) -- ========================================================================================================================================================================= end end return false elseif Message == "@medals" then -- ========================================================================================================================================================================= privatesay(player, "Any Spree: " .. medals[hash].class.sprees .. " (" .. medals[hash].count.sprees .. ") | Assistant: " .. medals[hash].class.assists .. " (" .. medals[hash].count.assists .. ") | Close Quarters: " .. medals[hash].class.closequarters .. " (" .. medals[hash].count.assists .. ")") privatesay(player, "Crack Shot: " .. medals[hash].class.crackshot .. " (" .. medals[hash].count.crackshot .. ") | Downshift: " .. medals[hash].class.downshift .. " (" .. medals[hash].count.downshift .. ") | Grenadier: " .. medals[hash].class.grenadier .. " (" .. medals[hash].count.grenadier .. ")") privatesay(player, "Heavy Weapons: " .. medals[hash].class.heavyweapons .. " (" .. medals[hash].count.heavyweapons .. ") | Jack of all Trades: " .. medals[hash].class.jackofalltrades .. " (" .. medals[hash].count.jackofalltrades .. ") | Mobile Asset: " .. medals[hash].class.mobileasset .. " (" .. medals[hash].count.moblieasset .. ")") privatesay(player, "Multi Kill: " .. medals[hash].class.multikill .. " (" .. medals[hash].count.multikill .. ") | Sidearm: " .. medals[hash].class.sidearm .. " (" .. medals[hash].count.sidearm .. ") | Trigger Man: " .. medals[hash].class.triggerman .. " (" .. medals[hash].count.triggerman .. ")") -- ========================================================================================================================================================================= return false end if t[1] == "@weapons" then if t[2] then local rcon_id = tonumber(t[2]) if rcon_id then local Player = rresolveplayer(rcon_id) if Player then local hash = gethash(Player) if hash then privatesay(player, getname(Player) .. "'s Weapon Stats") privatesay(player, "Assault Rifle: " .. stats[hash].kills.assaultrifle .. " | Banshee: " .. stats[hash].kills.banshee .. " | Banshee Fuel Rod: " .. stats[hash].kills.bansheefuelrod .. " | Chain Hog: " .. stats[hash].kills.chainhog) privatesay(player, "EMP Blast: " .. extra[hash].woops.empblast .. " | Flame Thrower: " .. stats[hash].kills.flamethrower .. " | Frag Grenade: " .. stats[hash].kills.fragnade .. " | Fuel Rod: " .. stats[hash].kills.fuelrod) privatesay(player, "Ghost: " .. stats[hash].kills.ghost .. " | Melee: " .. stats[hash].kills.melee .. " | Needler: " .. stats[hash].kills.needler .. " | People Splattered: " .. stats[hash].kills.splatter) privatesay(player, "Pistol: " .. stats[hash].kills.pistol .. " | Plasma Grenade: " .. stats[hash].kills.plasmanade .. " | Plasma Pistol: " .. stats[hash].kills.plasmapistol .. " | Plasma Rifle: " .. stats[hash].kills.plasmarifle) privatesay(player, "Rocket Hog: " .. extra[hash].woops.rockethog .. " | Rocket Launcher: " .. stats[hash].kills.rocket .. " | Shotgun: " .. stats[hash].kills.shotgun .. " | Sniper Rifle: " .. stats[hash].kills.sniper) privatesay(player, "Stuck Grenade: " .. stats[hash].kills.grenadestuck .. " | Tank Machine Gun: " .. stats[hash].kills.tankmachinegun .. " | Tank Shell: " .. stats[hash].kills.tankshell .. " | Turret: " .. stats[hash].kills.turret) -- ========================================================================================================================================================================= else privatesay(player, "Script Error! Please try again!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats! They must be in the server!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats!") end end return false elseif t[1] == "@stats" then if t[2] then local rcon_id = tonumber(t[2]) if rcon_id then local Player = rresolveplayer(rcon_id) if Player then local hash = gethash(Player) if hash then local Player_KDR = RetrievePlayerKDR(Player) local cpm = math.round(killstats[hash].total.credits / extra[hash].woops.gamesplayed, 2) if cpm == 0 or cpm == nil then cpm = "No credits earned" end local days, hours, minutes, seconds = secondsToTime(extra[hash].woops.time, 4) -- ========================================================================================================================================================================= privatesay(player, getname(Player) .. "'s Stats.") privatesay(player, "Kills: " .. killstats[hash].total.kills .. " | Deaths: " .. killstats[hash].total.deaths .. " | Assists: " .. killstats[hash].total.assists) privatesay(player, "KDR: " .. Player_KDR .. " | Suicides: " .. killstats[hash].total.suicides .. " | Betrays: " .. killstats[hash].total.betrays) privatesay(player, "Games Played: " .. extra[hash].woops.gamesplayed .. " | Time in Server: " .. days .. "d " .. hours .. "h " .. minutes .. "m " .. seconds .. "s") privatesay(player, "Distance Traveled: " .. math.round(extra[hash].woops.distance / 1000, 2) .. " kilometers | Credits Per Map: " .. cpm) -- ========================================================================================================================================================================= else privatesay(player, "Script Error! Please try again!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats! They must be in the server!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats!") end end return false elseif t[1] == "@sprees" then if t[2] then local rcon_id = tonumber(t[2]) if rcon_id then local Player = rresolveplayer(rcon_id) if Player then local hash = gethash(Player) if hash then -- ========================================================================================================================================================================= privatesay(player, getname(Player) .. "'s Spree Stats.") privatesay(player, "Double Kill: " .. sprees[hash].count.double .. " | Triple Kill: " .. sprees[hash].count.triple .. " | Overkill: " .. sprees[hash].count.overkill .. " | Killtacular: " .. sprees[hash].count.killtacular) privatesay(player, "Killtrocity: " .. sprees[hash].count.killtrocity .. " | Killimanjaro " .. sprees[hash].count.killimanjaro .. " | Killtastrophe: " .. sprees[hash].count.killtastrophe .. " | Killpocalypse: " .. sprees[hash].count.killpocalypse) privatesay(player, "Killionaire: " .. sprees[hash].count.killionaire .. " | Kiling Spree " .. sprees[hash].count.killingspree .. " | Killing Frenzy: " .. sprees[hash].count.killingfrenzy .. " | Running Riot: " .. sprees[hash].count.runningriot) privatesay(player, "Rampage: " .. sprees[hash].count.rampage .. " | Untouchable: " .. sprees[hash].count.untouchable .. " | Invincible: " .. sprees[hash].count.invincible .. " | Anomgstopkillingme: " .. sprees[hash].count.anomgstopkillingme) privatesay(player, "Unfrigginbelievable: " .. sprees[hash].count.unfrigginbelievable .. " | Minutes as Last Man Standing: " .. sprees[hash].count.timeaslms) -- ========================================================================================================================================================================= else privatesay(player, "Script Error! Please try again!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats! They must be in the server!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats!") end end return false elseif t[1] == "@rank" then if t[2] then local rcon_id = tonumber(t[2]) if rcon_id then local Player = rresolveplayer(rcon_id) if Player then local hash = gethash(Player) if hash then local credits = { } for k, _ in pairs(killstats) do table.insert(credits, { ["hash"] = k, ["credits"] = killstats[k].total.credits }) end table.sort(credits, function(a, b) return a.credits > b.credits end) for k, v in ipairs(credits) do if hash == credits[k].hash then local until_next_rank = CreditsUntilNextPromo(Player) if until_next_rank == nil then until_next_rank = "Unknown - " .. getname(Player) .. " is a new player" end -- ========================================================================================================================================================================= privatesay(player, getname(Player) .. " is ranked " .. k .. " out of " .. #credits .. "!") privatesay(player, "Credits: " .. killstats[hash].total.credits .. " | Rank: " .. killstats[hash].total.rank) privatesay(player, "Credits Until Next Rank: " .. until_next_rank) -- ========================================================================================================================================================================= end end else privatesay(player, "Script Error! Please try again!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats! They must be in the server!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats!") end end return false elseif t[1] == "@medals" then if t[2] then local rcon_id = tonumber(t[2]) if rcon_id then local Player = rresolveplayer(rcon_id) if Player then local hash = gethash(Player) if hash then -- ========================================================================================================================================================================= privatesay(player, getname(Player) .. "'s Medal Stats.") privatesay(player, "Any Spree: " .. medals[hash].class.sprees .. " (" .. medals[hash].count.sprees .. ") | Assistant: " .. medals[hash].class.assists .. " (" .. medals[hash].count.assists .. ") | Close Quarters: " .. medals[hash].class.closequarters .. " (" .. medals[hash].count.assists .. ")") privatesay(player, "Crack Shot: " .. medals[hash].class.crackshot .. " (" .. medals[hash].count.crackshot .. ") | Downshift: " .. medals[hash].class.downshift .. " (" .. medals[hash].count.downshift .. ") | Grenadier: " .. medals[hash].class.grenadier .. " (" .. medals[hash].count.grenadier .. ")") privatesay(player, "Heavy Weapons: " .. medals[hash].class.heavyweapons .. " (" .. medals[hash].count.heavyweapons .. ") | Jack of all Trades: " .. medals[hash].class.jackofalltrades .. " (" .. medals[hash].count.jackofalltrades .. ") | Mobile Asset: " .. medals[hash].class.mobileasset .. " (" .. medals[hash].count.moblieasset .. ")") privatesay(player, "Multi Kill: " .. medals[hash].class.multikill .. " (" .. medals[hash].count.multikill .. ") | Sidearm: " .. medals[hash].class.sidearm .. " (" .. medals[hash].count.sidearm .. ") | Trigger Man: " .. medals[hash].class.triggerman .. " (" .. medals[hash].count.triggerman .. ")") -- ========================================================================================================================================================================= else privatesay(player, "Script Error! Please try again!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats! They must be in the server!") end else privatesay(player, "Please enter a number between 1 and 16 to view their stats!") end end return false end end end function OnPlayerJoin(player) DeclearNewPlayerStats(gethash(player)) kill_command_count[gethash(player)] = 0 credit_timer = registertimer(60000, "CreditTimer", player) -- Update the player counts cur_players = cur_players + 1 GetMedalClasses(player) local alreadyExists = false GetPlayerRank(player) jointime[gethash(player)] = os.time() xcoords[gethash(player)] = readfloat(getplayer(player) + 0xF8) ycoords[gethash(player)] = readfloat(getplayer(player) + 0xFC) zcoords[gethash(player)] = readfloat(getplayer(player) + 0x100) -- 'SERVER_NAME' will print the name of the server to the joining player - as defined in the .init. privatesay(player, "Welcome to " .. SERVER_NAME) local thisTeamSize = 0 killers[player] = { } if AnnounceRank == true then AnnouncePlayerRank(player) end if table.find(hash_table, gethash(player), false) then for k, v in pairs(hash_table) do if v ~= getteam(player) then changeteam(player, true) end privatesay(player, REJOIN_MESSAGE) alreadyEsists = true break end end if alreadyExists == false then hash_table[gethash(player)] = getteam(player) end -- Verify Blue Team if getteam(player) == BLUE_TEAM then -- Add one to player count (blue) cur_blue_count = cur_blue_count + 1 -- Update Counts thisTeamSize = cur_blue_count else -- Add one to player count (red) cur_red_count = cur_red_count + 1 -- Update Counts thisTeamSize = cur_red_count end end function getteamplay() -- Confirmed. (Off = 0) (On = 1) if readbyte(gametype_base + 0x34) == 1 then return true else return false end end function OnPlayerLeave(player) cur_players = cur_players - 1 hash_table[gethash(player)] = getteam(player) kills[gethash(player)] = 0 extra[gethash(player)].woops.time = extra[gethash(player)].woops.time + os.time() - jointime[gethash(player)] -- Verify Blue Team if getteam(player) == BLUE_TEAM then -- Take one away from player count (blue) cur_blue_count = cur_blue_count - 1 -- Verify Red Team elseif getteam(player) == RED_TEAM then -- Take one away from player count (red) cur_red_count = cur_red_count - 1 end end function OnPlayerKill(killer, victim, mode) if mode == 4 then local hash = gethash(killer) local vhash = gethash(victim) local m_player = getplayer(killer) local m_object = getobject(readdword(m_player + 0x34)) if last_damage[vhash] then if string.find(last_damage[vhash], "melee") then medals[hash].count.closequarters = medals[hash].count.closequarters + 1 stats[hash].kills.melee = stats[hash].kills.melee + 1 elseif last_damage[vhash] == "globals\\vehicle_collision" then stats[hash].kills.splatter = stats[hash].kills.splatter + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "vehicles\\banshee\\mp_fuel rod explosion" then stats[hash].kills.bansheefuelrod = stats[hash].kills.bansheefuelrod + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "vehicles\\banshee\\banshee bolt" then stats[hash].kills.banshee = stats[hash].kills.banshee + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "vehicles\\c gun turret\\mp bolt" then stats[hash].kills.turret = stats[hash].kills.turret + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "vehicles\\ghost\\ghost bolt" then stats[hash].kills.ghost = stats[hash].kills.ghost + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "vehicles\\scorpion\\bullet" then stats[hash].kills.tankmachinegun = stats[hash].kills.tankmachinegun + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "vehicles\\scorpion\\shell explosion" then stats[hash].kills.tankshell = stats[hash].kills.tankshell + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "vehicles\\warthog\\bullet" then stats[hash].kills.chainhog = stats[hash].kills.chainhog + 1 medals[hash].count.moblieasset = medals[hash].count.moblieasset + 1 elseif last_damage[vhash] == "weapons\\assault rifle\\bullet" then stats[hash].kills.assaultrifle = stats[hash].kills.assaultrifle + 1 medals[hash].count.triggerman = medals[hash].count.triggerman + 1 elseif last_damage[vhash] == "weapons\\flamethrower\\burning" or last_damage[vhash] == "weapons\\flamethrower\\explosion" or last_damage[vhash] == "weapons\\flamethrower\\impact damage" then medals[hash].count.heavyweapons = medals[hash].count.heavyweapons + 1 stats[hash].kills.flamethrower = stats[hash].kills.flamethrower + 1 elseif last_damage[vhash] == "weapons\\frag grenade\\explosion" then medals[hash].count.grenadier = medals[hash].count.grenadier + 1 stats[hash].kills.fragnade = stats[hash].kills.fragnade + 1 elseif last_damage[vhash] == "weapons\\needler\\detonation damage" or last_damage[vhash] == "weapons\\needler\\explosion" or last_damage[vhash] == "weapons\\needler\\impact damage" then medals[hash].count.triggerman = medals[hash].count.triggerman + 1 stats[hash].kills.needler = stats[hash].kills.needler + 1 elseif last_damage[vhash] == "weapons\\pistol\\bullet" then stats[hash].kills.pistol = stats[hash].kills.pistol + 1 medals[hash].count.sidearm = medals[hash].count.sidearm + 1 elseif last_damage[vhash] == "weapons\\plasma grenade\\attached" then medals[hash].count.grenadier = medals[hash].count.grenadier + 1 stats[hash].kills.grenadestuck = stats[hash].kills.grenadestuck + 1 elseif last_damage[vhash] == "weapons\\plasma grenade\\explosion" then medals[hash].count.grenadier = medals[hash].count.grenadier + 1 stats[hash].kills.plasmanade = stats[hash].kills.plasmanade + 1 elseif last_damage[vhash] == "weapons\\plasma pistol\\bolt" then stats[hash].kills.plasmapistol = stats[hash].kills.plasmapistol + 1 medals[hash].count.sidearm = medals[hash].count.sidearm + 1 elseif last_damage[vhash] == "weapons\\plasma rifle\\charged bolt" then extra[hash].woops.empblast = extra[hash].woops.empblast + 1 medals[hash].count.jackofalltrades = medals[hash].count.jackofalltrades + 1 -- EMP Blast elseif last_damage[vhash] == "weapons\\plasma rifle\\bolt" then stats[hash].kills.plasmarifle = stats[hash].kills.plasmarifle + 1 medals[hash].count.triggerman = medals[hash].count.triggerman + 1 elseif last_damage[vhash] == "weapons\\plasma_cannon\\effects\\plasma_cannon_explosion" or last_damage[vhash] == "weapons\\plasma_cannon\\impact damage" then medals[hash].count.heavyweapons = medals[hash].count.heavyweapons + 1 stats[hash].kills.fuelrod = stats[hash].kills.fuelrod + 1 elseif last_damage[vhash] == "weapons\\rocket launcher\\explosion" then if m_object then if readbyte(m_object + 0x2A0) == 1 then -- obj_crouch extra[hash].woops.rockethog = extra[hash].woops.rockethog + 1 else medals[hash].count.heavyweapons = medals[hash].count.heavyweapons + 1 stats[hash].kills.rocket = stats[hash].kills.rocket + 1 end else medals[hash].count.heavyweapons = medals[hash].count.heavyweapons + 1 stats[hash].kills.rocket = stats[hash].kills.rocket + 1 end elseif last_damage[vhash] == "weapons\\shotgun\\pellet" then medals[hash].count.closequarters = medals[hash].count.closequarters + 1 stats[hash].kills.shotgun = stats[hash].kills.shotgun + 1 elseif last_damage[vhash] == "weapons\\sniper rifle\\sniper bullet" then medals[hash].count.crackshot = medals[hash].count.crackshot + 1 stats[hash].kills.sniper = stats[hash].kills.sniper + 1 elseif last_damage[vhash] == "backtap" then medals[hash].count.closequarters = medals[hash].count.closequarters + 1 stats[hash].kills.melee = stats[hash].kills.melee + 1 end end end if game_started == true then -- mode 0: Killed by server if mode == 0 then killstats[gethash(victim)].total.deaths = killstats[gethash(victim)].total.deaths + 1 -- mode 1: Killed by fall damage elseif mode == 1 then killstats[gethash(victim)].total.deaths = killstats[gethash(victim)].total.deaths + 1 -- mode 2: Killed by guardians elseif mode == 2 then killstats[gethash(victim)].total.deaths = killstats[gethash(victim)].total.deaths + 1 -- mode 3: Killed by vehicle elseif mode == 3 then killstats[gethash(victim)].total.deaths = killstats[gethash(victim)].total.deaths + 1 -- mode 4: Killed by killer elseif mode == 4 then if table.find(killers[victim], killer, false) == nil then table.insert(killers[victim], killer) end killstats[gethash(killer)].total.kills = killstats[gethash(killer)].total.kills + 1 killstats[gethash(victim)].total.deaths = killstats[gethash(victim)].total.deaths + 1 -- Verify Blue Team if getteam(killer) == BLUE_TEAM then changescore(killer, 15, plus) SendMessage(killer, "Rewarded: +15 (cR) - Kill") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 15 end if readword(getplayer(killer) + 0x9C) == 10 then changescore(killer, 5, plus) SendMessage(killer, "Rewarded: +5 (cR) - 10 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 elseif readword(getplayer(killer) + 0x9C) == 20 then changescore(killer, 5, plus) SendMessage(killer, "Rewarded: +5 (cR) - 20 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 elseif readword(getplayer(killer) + 0x9C) == 30 then changescore(killer, 5, plus) SendMessage(killer, "Rewarded: +5 (cR) - 30 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 elseif readword(getplayer(killer) + 0x9C) == 40 then changescore(killer, 5, plus) SendMessage(killer, "Rewarded: +5 (cR) - 40 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 elseif readword(getplayer(killer) + 0x9C) == 50 then changescore(killer, 10, plus) SendMessage(killer, "Rewarded: +10 (cR) - 50 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 elseif readword(getplayer(killer) + 0x9C) == 60 then changescore(killer, 10, plus) SendMessage(killer, "Rewarded: +10 (cR) - 60 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 elseif readword(getplayer(killer) + 0x9C) == 70 then changescore(killer, 10, plus) SendMessage(killer, "Rewarded: +10 (cR) - 70 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 elseif readword(getplayer(killer) + 0x9C) == 80 then changescore(killer, 10, plus) SendMessage(killer, "Rewarded: +10 (cR) - 80 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 elseif readword(getplayer(killer) + 0x9C) == 90 then changescore(killer, 10, plus) SendMessage(killer, "Rewarded: +10 (cR) - 90 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 elseif readword(getplayer(killer) + 0x9C) == 100 then changescore(killer, 20, plus) SendMessage(killer, "Rewarded: +20 (cR) - 100 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 20 elseif readword(getplayer(killer) + 0x9C) > 100 then changescore(killer, 5, plus) SendMessage(killer, "Rewarded: +5 (cR) - More then 100 Kills") killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 end local hash = gethash(killer) if readword(getplayer(killer) + 0x98) == 2 then -- if multi kill is equal to 2 then SendMessage(killer, "Rewarded: +8 (cR) - Double Kill") changescore(killer, 8, plus) killstats[hash].total.credits = killstats[hash].total.credits + 8 sprees[hash].count.double = sprees[hash].count.double + 1 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) == 3 then -- if multi kill is equal to 3 then SendMessage(killer, "Rewarded: +10 (cR) - Triple Kill") changescore(killer, 10, plus) sprees[hash].count.triple = sprees[hash].count.triple + 1 killstats[hash].total.credits = killstats[hash].total.credits + 10 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) == 4 then -- if multi kill is equal to 4 then SendMessage(killer, "Rewarded: +12 (cR) - Overkill") changescore(killer, 12, plus) sprees[hash].count.overkill = sprees[hash].count.overkill + 1 killstats[hash].total.credits = killstats[hash].total.credits + 12 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) == 5 then -- if multi kill is equal to 5 then SendMessage(killer, "Rewarded: +14 (cR) - Killtacular") changescore(killer, 14, plus) sprees[hash].count.killtacular = sprees[hash].count.killtacular + 1 killstats[hash].total.credits = killstats[hash].total.credits + 14 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) == 6 then -- if multi kill is equal to 6 then SendMessage(killer, "Rewarded: +16 (cR) - Killtrocity") changescore(killer, 16, plus) sprees[hash].count.killtrocity = sprees[hash].count.killtrocity + 1 killstats[hash].total.credits = killstats[hash].total.credits + 16 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) == 7 then -- if multi kill is equal to 7 then SendMessage(killer, "Rewarded: +18 (cR) - Killimanjaro") changescore(killer, 18, plus) sprees[hash].count.killimanjaro = sprees[hash].count.killimanjaro + 1 killstats[hash].total.credits = killstats[hash].total.credits + 18 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) == 8 then -- if multi kill is equal to 8 then SendMessage(killer, "Rewarded: +20 (cR) - Killtastrophe") changescore(killer, 20, plus) sprees[hash].count.killtastrophe = sprees[hash].count.killtastrophe + 1 killstats[hash].total.credits = killstats[hash].total.credits + 20 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) == 9 then -- if multi kill is equal to 9 then privatesay(killer, "Rewarded: +22 (cR) - Killpocalypse") changescore(killer, 22, plus) sprees[hash].count.killpocalypse = sprees[hash].count.killpocalypse + 1 killstats[hash].total.credits = killstats[hash].total.credits + 22 medals[hash].count.multikill = medals[hash].count.multikill + 1 elseif readword(getplayer(killer) + 0x98) >= 10 then -- if multi kill is equal to 10 or more then SendMessage(killer, "Rewarded: +25 (cR) - Killionaire") changescore(killer, 25, plus) sprees[hash].count.killionaire = sprees[hash].count.killionaire + 1 killstats[hash].total.credits = killstats[hash].total.credits + 25 medals[hash].count.multikill = medals[hash].count.multikill + 1 end if readword(getplayer(killer) + 0x96) == 5 then -- if killing spree is 5 then SendMessage(killer, "Rewarded: +5 (cR) - Killing Spree") changescore(killer, 5, plus) sprees[hash].count.killingspree = sprees[hash].count.killingspree + 1 killstats[hash].total.credits = killstats[hash].total.credits + 5 medals[hash].count.sprees = medals[hash].count.sprees + 1 elseif readword(getplayer(killer) + 0x96) == 10 then -- if killing spree is 10 then SendMessage(killer, "Rewarded: +10 (cR) - Killing Frenzy") changescore(killer, 10, plus) sprees[hash].count.killingfrenzy = sprees[hash].count.killingfrenzy + 1 killstats[hash].total.credits = killstats[hash].total.credits + 10 medals[hash].count.sprees = medals[hash].count.sprees + 1 elseif readword(getplayer(killer) + 0x96) == 15 then -- if killing spree is 15 then SendMessage(killer, "Rewarded: +15 (cR) - Running Riot") changescore(killer, 15, plus) sprees[hash].count.runningriot = sprees[hash].count.runningriot + 1 killstats[hash].total.credits = killstats[hash].total.credits + 15 medals[hash].count.sprees = medals[hash].count.sprees + 1 elseif readword(getplayer(killer) + 0x96) == 20 then -- if killing spree is 20 then SendMessage(killer, "Rewarded: +20 (cR) - Rampage") changescore(killer, 20, plus) sprees[hash].count.rampage = sprees[hash].count.rampage + 1 killstats[hash].total.credits = killstats[hash].total.credits + 20 medals[hash].count.sprees = medals[hash].count.sprees + 1 elseif readword(getplayer(killer) + 0x96) == 25 then -- if killing spree is 25 then SendMessage(killer, "Rewarded: +25 (cR) - Untouchable") changescore(killer, 25, plus) sprees[hash].count.untouchable = sprees[hash].count.untouchable + 1 killstats[hash].total.credits = killstats[hash].total.credits + 25 medals[hash].count.sprees = medals[hash].count.sprees + 1 elseif readword(getplayer(killer) + 0x96) == 30 then -- if killing spree is 30 then SendMessage(killer, "Rewarded: +30 (cR) - Invincible") changescore(killer, 30, plus) sprees[hash].count.invincible = sprees[hash].count.invincible + 1 killstats[hash].total.credits = killstats[hash].total.credits + 30 medals[hash].count.sprees = medals[hash].count.sprees + 1 elseif readword(getplayer(killer) + 0x96) == 35 then -- if killing spree is 35 then SendMessage(killer, "Rewarded: +35 (cR) - Anomgstopkillingme") changescore(killer, 35, plus) sprees[hash].count.anomgstopkillingme = sprees[hash].count.anomgstopkillingme + 1 killstats[hash].total.credits = killstats[hash].total.credits + 35 medals[hash].count.sprees = medals[hash].count.sprees + 1 elseif readword(getplayer(killer) + 0x96) >= 40 and sprees % 5 == 0 then -- if killing spree is 40 or more (Every 5 it will say this after 40) then SendMessage(killer, "Rewarded: +40 (cR) - Unfrigginbelievable") changescore(killer, 40, plus) sprees[hash].count.unfrigginbelievable = sprees[hash].count.unfrigginbelievable + 1 killstats[hash].total.credits = killstats[hash].total.credits + 40 medals[hash].count.sprees = medals[hash].count.sprees + 1 end -- Revenge for k, v in pairs(killers[killer]) do if v == victim then table.remove(killers[killer], k) medals[gethash(killer)].count.jackofalltrades = medals[gethash(killer)].count.jackofalltrades + 1 killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 SendMessage(killer, "Rewarded: +10 (cR) - Revenge") changescore(killer, 10, plus) end end -- Killed from the Grave if isplayerdead(killer) == true then medals[gethash(killer)].count.jackofalltrades = medals[gethash(killer)].count.jackofalltrades + 1 killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 SendMessage(killer, "Rewarded: +10 (cR) - Killed from the Grave") changescore(killer, 10, plus) end -- Downshift if getplayer(killer) then if killer ~= nil then local objectid = getplayerobjectid(killer) if objectid ~= nil then local m_object = getobject(objectid) local kvehicleid = readdword(m_object + 0x11C) local seat_index = readword(m_object + 0x2F0) if kvehicleid ~= nil then if seat_index == 1 or seat_index == 2 or seat_index == 3 or seat_index == 4 then for i = 0, 15 do if getplayer(i) then local m_object = getobject(getplayerobjectid(i)) local loopvehicleid = readdword(m_object + 0x11C) local seat_index = readword(m_object + 0x2F0) if kvehicleid == loopvehicleid then if seat_index == 0 then if getteam(killer) == getteam(i) then medals[gethash(i)].count.downshift = medals[gethash(i)].count.downshift + 1 killstats[gethash(i)].total.credits = killstats[gethash(i)].total.credits + 5 SendMessage(i, "Awarded: +5 (cR) - Downshift") changescore(i, 5, plus) end end end end end end end end end end -- Avenge for i = 0, 15 do if getplayer(i) then if i ~= victim then if gethash(i) then if getteam(i) == getteam(victim) then avenge[gethash(i)] = gethash(killer) end end end end end if avenge[gethash(killer)] == gethash(victim) then medals[gethash(killer)].count.jackofalltrades = medals[gethash(killer)].count.jackofalltrades + 1 killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 SendMessage(killer, "Rewarded: +5 (cR) - Avenger") changescore(killer, 5, plus) end -- Killjoy if killer then kills[gethash(killer)] = kills[gethash(killer)] or 1 end if killer and victim then -- Works if kills[gethash(victim)] ~= nil then if kills[gethash(victim)] >= 5 then medals[gethash(killer)].count.jackofalltrades = medals[gethash(killer)].count.jackofalltrades + 1 killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 SendMessage(killer, "Rewarded: +5 (cR) - Killjoy") changescore(killer, 5, plus) end end end kills[gethash(victim)] = 0 -- Reload This local object = getplayerobjectid(victim) local m_object = getobject(object) local reloading = readbyte(m_object + 0x2A4) if reloading == 5 then SendMessage(killer, "Rewarded: +5 (cR) - Reload This!") medals[gethash(killer)].count.jackofalltrades = medals[gethash(killer)].count.jackofalltrades + 1 killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 5 changescore(killer, 5, plus) end -- First Strike kill_count = kill_count + 1 if kill_count == 1 then medals[gethash(killer)].count.jackofalltrades = medals[gethash(killer)].count.jackofalltrades + 1 killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 SendMessage(killer, "Rewarded: +10 (cR) - First Strike") changescore(killer, 10, plus) end registertimer(10, "CloseCall", killer) -- mode 5: Betrayed by killer elseif mode == 5 then killstats[gethash(victim)].total.deaths = killstats[gethash(victim)].total.deaths + 1 killstats[gethash(killer)].total.betrays = killstats[gethash(killer)].total.betrays + 1 -- mode 6: Suicide elseif mode == 6 then killstats[gethash(victim)].total.suicides = killstats[gethash(victim)].total.suicides + 1 -- Verify Red Team if getteam(victim) == RED_TEAM then end end -- mode 4: Killed by killer if mode == 4 then GetPlayerRank(killer) registertimer(10, "LevelUp", killer) end end end function OnDamageLookup(receiver, causer, mapId) local tagname, tagtype = gettaginfo(mapId) if causer ~= nil then if getobject(causer) then local cplayer = objectaddrtoplayer(causer) else local cplayer = nil end end if string.find(tagname, "melee") then odl_multiplier(500) end if cplayer ~= nil then if getteam(cplayer) ~= nil then -- Verify Red Team if getteam(cplayer) == RED_TEAM then local modifier = 1.0 odl_multiplier(modifier) end end end end function OnDamageApplication(receiving, causing, tagid, hit, backtap) if receiving then local r_object = getobject(receiving) if r_object then local receiver = objectaddrtoplayer(r_object) if receiver then if not backtap then local tagname, tagtype = gettaginfo(tagid) last_damage[gethash(receiver)] = tagname else last_damage[gethash(receiver)] = "melee" end end end end end function OnClientUpdate(player) GivePlayerMedals(player) if getplayerobjectid(player) then local x, y, z = getobjectcoords(getplayerobjectid(player)) if xcoords[gethash(player)] then local x_dist = x - xcoords[gethash(player)] local y_dist = y - ycoords[gethash(player)] local z_dist = z - zcoords[gethash(player)] local dist = math.sqrt(x_dist ^ 2 + y_dist ^ 2 + z_dist ^ 2) extra[gethash(player)].woops.distance = extra[gethash(player)].woops.distance + dist end xcoords[gethash(player)] = x ycoords[gethash(player)] = y zcoords[gethash(player)] = z end end function table.save(t, filename) local dir = getprofilepath() local file = io.open(dir .. "\\data\\" .. filename, "w") local spaces = 0 local function tab() local str = "" for i = 1, spaces do str = str .. " " end return str end local function format(t) spaces = spaces + 4 local str = "{ " for k, v in opairs(t) do -- Key datatypes if type(k) == "string" then k = string.format("%q", k) elseif k == math.inf then k = "1 / 0" end -- Value datatypes if type(v) == "string" then v = string.format("%q", v) elseif v == math.inf then v = "1 / 0" end if type(v) == "table" then if table.len(v) > 0 then str = str .. "\n" .. tab() .. "[" .. k .. "] = " .. format(v) .. "," else str = str .. "\n" .. tab() .. "[" .. k .. "] = {}," end else str = str .. "\n" .. tab() .. "[" .. k .. "] = " .. tostring(v) .. "," end end spaces = spaces - 4 return string.sub(str, 1, string.len(str) - 1) .. "\n" .. tab() .. "}" end file:write("return " .. format(t)) file:close() end function opairs(t) local keys = { } for k, v in pairs(t) do table.insert(keys, k) end table.sort(keys, function(a, b) if type(a) == "number" and type(b) == "number" then return a < b end an = string.lower(tostring(a)) bn = string.lower(tostring(b)) if an ~= bn then return an < bn else return tostring(a) < tostring(b) end end) local count = 1 return function() if table.unpack(keys) then local key = keys[count] local value = t[key] count = count + 1 return key, value end end end function table.load(filename) local dir = getprofilepath() local file = loadfile(dir .. "\\data\\" .. filename) if file then return file() or { } end return { } end function table.len(t) local count = 0 for k, v in pairs(t) do count = count + 1 end return count end function adjustedtimestamp() local strMonth = os.date("%m") local strYear = os.date("%Y") local strMin = os.date("%M") local strSec = os.date("%S") local intDay = tonumber(os.date("%d")) local intHour = tonumber(os.date("%H")) if intHour < 7 then local intDiff = 7 - intHour intHour = 24 - intDiff intDay = intDay - 1 elseif intHour >= 7 then intHour = intHour - 7 end local strMonthFinal = string.format("%02.0f", strMonth) local strYearFinal = string.format("%04.0f", strYear) local strMinFinal = string.format("%02.0f", strMin) local strSecFinal = string.format("%02.0f", strSec) local intDayFinal = string.format("%02.0f", intDay) local intHourFinal = string.format("%02.0f", intHour) local temp = "[" .. strMonthFinal .. "/" .. intDayFinal .. "/" .. strYearFinal .. " " .. intHourFinal .. ":" .. strMinFinal .. ":" .. strSecFinal .. "]" local timestamp = tostring(temp) return timestamp end function isplayerdead(player) local m_objectId = getplayerobjectid(player) if m_objectId then local m_object = getobject(m_objectId) if m_object then return false else return true end end end function isplayerinvis(player) if player ~= nil then local m_playerObjId = readdword(getplayer(player) + 0x34) local m_object = getobject(m_playerObjId) local obj_invis_scale = readfloat(m_object + 0x37C) if obj_invis_scale == 0 then return false else return true end end end function CreditTimer(id, count, player) if game_started == true then if getplayer(player) then SendMessage(player, "Rewarded: +15 (cR) - 1 Minute in Server") changescore(player, 15, plus) if killstats[gethash(player)].total.credits ~= nil then killstats[gethash(player)].total.credits = killstats[gethash(player)].total.credits + 15 else killstats[gethash(player)].total.credits = 15 end end return true else return false end end function AssistDelay(id, count) for i = 0, 15 do if getplayer(i) then if gethash(i) then if readword(getplayer(i) + 0xA4) ~= 0 then killstats[gethash(i)].total.assists = killstats[gethash(i)].total.assists + readword(getplayer(i) + 0xA4) medals[gethash(i)].count.assists = medals[gethash(i)].count.assists + readword(getplayer(i) + 0xA4) if (readword(getplayer(i) + 0xA4) * 3) ~= 0 then killstats[gethash(i)].total.credits = killstats[gethash(i)].total.credits + (readword(getplayer(i) + 0xA4) * 3) changescore(i, (readword(getplayer(i) + 0xA4) * 3), plus) end if readword(getplayer(i) + 0xA4) == 1 then SendMessage(i, "Awarded: +" .. (readword(getplayer(i) + 0xA4) * 3) .. " (cR) - " .. readword(getplayer(i) + 0xA4) .. " Assist") else SendMessage(i, "Awarded: +" .. (readword(getplayer(i) + 0xA4) * 3) .. " (cR) - " .. readword(getplayer(i) + 0xA4) .. " Assists") end end end end end end function CloseCall(id, count, killer) -- Cleared if getplayer(killer) then if killer ~= nil then local objectid = getplayerobjectid(killer) if objectid ~= nil then local m_object = getobject(objectid) local shields = readfloat(m_object + 0xE4) local health = readfloat(m_object + 0xE0) if shields ~= nil then if shields == 0 then if health then if health ~= 1 then medals[gethash(killer)].count.jackofalltrades = medals[gethash(killer)].count.jackofalltrades + 1 killstats[gethash(killer)].total.credits = killstats[gethash(killer)].total.credits + 10 SendMessage(killer, "Rewarded: +10 (cR) - Close Call") changescore(killer, 10, plus) end end end end end end end end function CountdownToGameStart(id, count) if count == 6 then say("Begin!") hprintf("Begin!") if cur_players ~= 0 then for i = 0, 15 do if getplayer(i) then if getteam(i) ~= nil then end end end -- Set counters so ChangeTeam wont end the game cur_blue_count = 16 cur_red_count = 16 -- Reset the map if map_name ~= "bloodgulch" or map_name ~= "sidewinder" or map_name ~= "boardingaction" then svcmd("sv_map_reset") else for i = 0, 15 do if getplayer(i) ~= nil then end end end end -- Assume the game is running. game_started = true return false -- remove timer else say("The game will start in: " .. 6 - count) hprintf("The game will start in: " .. 6 - count) return true -- Keep Timer end end -- Rounds the number function round(num) under = math.floor(num) upper = math.floor(num) + 1 underV = -(under - num) upperV = upper - num if (upperV > underV) then return under else return upper end end function OpenFiles() stats = table.load("Stats.txt") killstats = table.load("KillStats.txt") sprees = table.load("Sprees.txt") medals = table.load("Medals.txt") extra = table.load("Extra.txt") done = table.load("CompletedMedals.txt") end function RetrievePlayerKDR(player) local Player_KDR = nil if killstats[gethash(player)].total.kills ~= 0 then if killstats[gethash(player)].total.deaths ~= 0 then local kdr = killstats[gethash(player)].total.kills / killstats[gethash(player)].total.deaths Player_KDR = math.round(kdr, 2) else Player_KDR = "No Deaths" end else Player_KDR = "No Kills" end return Player_KDR end function DeclearNewPlayerStats(hash) if stats[hash] == nil then stats[hash] = { } stats[hash].kills = { } stats[hash].kills.melee = 0 stats[hash].kills.fragnade = 0 stats[hash].kills.plasmanade = 0 stats[hash].kills.grenadestuck = 0 stats[hash].kills.sniper = 0 stats[hash].kills.shotgun = 0 stats[hash].kills.rocket = 0 stats[hash].kills.fuelrod = 0 stats[hash].kills.plasmarifle = 0 stats[hash].kills.plasmapistol = 0 stats[hash].kills.pistol = 0 stats[hash].kills.needler = 0 stats[hash].kills.flamethrower = 0 stats[hash].kills.flagmelee = 0 stats[hash].kills.oddballmelee = 0 stats[hash].kills.assaultrifle = 0 stats[hash].kills.chainhog = 0 stats[hash].kills.tankshell = 0 stats[hash].kills.tankmachinegun = 0 stats[hash].kills.ghost = 0 stats[hash].kills.turret = 0 stats[hash].kills.bansheefuelrod = 0 stats[hash].kills.banshee = 0 stats[hash].kills.splatter = 0 end if killstats[hash] == nil then killstats[hash] = { } killstats[hash].total = { } killstats[hash].total.kills = 0 killstats[hash].total.deaths = 0 killstats[hash].total.assists = 0 killstats[hash].total.suicides = 0 killstats[hash].total.betrays = 0 killstats[hash].total.credits = 0 killstats[hash].total.rank = 0 end if sprees[hash] == nil then sprees[hash] = { } sprees[hash].count = { } sprees[hash].count.double = 0 sprees[hash].count.triple = 0 sprees[hash].count.overkill = 0 sprees[hash].count.killtacular = 0 sprees[hash].count.killtrocity = 0 sprees[hash].count.killimanjaro = 0 sprees[hash].count.killtastrophe = 0 sprees[hash].count.killpocalypse = 0 sprees[hash].count.killionaire = 0 sprees[hash].count.killingspree = 0 sprees[hash].count.killingfrenzy = 0 sprees[hash].count.runningriot = 0 sprees[hash].count.rampage = 0 sprees[hash].count.untouchable = 0 sprees[hash].count.invincible = 0 sprees[hash].count.anomgstopkillingme = 0 sprees[hash].count.unfrigginbelievable = 0 sprees[hash].count.timeaslms = 0 end if medals[hash] == nil then medals[hash] = { } medals[hash].count = { } medals[hash].class = { } medals[hash].count.sprees = 0 medals[hash].class.sprees = "Iron" medals[hash].count.assists = 0 medals[hash].class.assists = "Iron" medals[hash].count.closequarters = 0 medals[hash].class.closequarters = "Iron" medals[hash].count.crackshot = 0 medals[hash].class.crackshot = "Iron" medals[hash].count.downshift = 0 medals[hash].class.downshift = "Iron" medals[hash].count.grenadier = 0 medals[hash].class.grenadier = "Iron" medals[hash].count.heavyweapons = 0 medals[hash].class.heavyweapons = "Iron" medals[hash].count.jackofalltrades = 0 medals[hash].class.jackofalltrades = "Iron" medals[hash].count.moblieasset = 0 medals[hash].class.mobileasset = "Iron" medals[hash].count.multikill = 0 medals[hash].class.multikill = "Iron" medals[hash].count.sidearm = 0 medals[hash].class.sidearm = "Iron" medals[hash].count.triggerman = 0 medals[hash].class.triggerman = "Iron" end if extra[hash] == nil then extra[hash] = { } extra[hash].woops = { } extra[hash].woops.rockethog = 0 extra[hash].woops.falldamage = 0 extra[hash].woops.empblast = 0 extra[hash].woops.gamesplayed = 0 extra[hash].woops.time = 0 extra[hash].woops.distance = 0 end if done[hash] == nil then done[hash] = { } done[hash].medal = { } done[hash].medal.sprees = "False" done[hash].medal.assists = "False" done[hash].medal.closequarters = "False" done[hash].medal.crackshot = "False" done[hash].medal.downshift = "False" done[hash].medal.grenadier = "False" done[hash].medal.heavyweapons = "False" done[hash].medal.jackofalltrades = "False" done[hash].medal.mobileasset = "False" done[hash].medal.multikill = "False" done[hash].medal.sidearm = "False" done[hash].medal.triggerman = "False" end end function AnnouncePlayerRank(player) local rank = nil local total = nil local hash = gethash(player) local credits = { } for k, _ in pairs(killstats) do table.insert(credits, { ["hash"] = k, ["credits"] = killstats[k].total.credits }) end table.sort(credits, function(a, b) return a.credits > b.credits end) for k, v in ipairs(credits) do if hash == credits[k].hash then rank = k total = #credits string = "Server Statistics: You are currently ranked " .. rank .. " out of " .. total .. "." end end return sendconsoletext(player, string) end function table.find(t, v, case) if case == nil then case = true end for k, val in pairs(t) do if case then if v == val then return k end else if string.lower(v) == string.lower(val) then return k end end end end function DestroyGuns(object) for i = 0, 3 do if getobject(object) then local weapID = readdword(getobject(object) + 0x2F8 + i * 4) if getobject(weapID) then destroyobject(weapID) end end end end function math.round(input, precision) return math.floor(input * (10 ^ precision) + 0.5) / (10 ^ precision) end function LevelUp(id, count, killer) local hash = gethash(killer) killstats[hash].total.rank = killstats[hash].total.rank or "Recruit" killstats[hash].total.credits = killstats[hash].total.credits or 0 if killstats[hash].total.rank ~= nil and killstats[hash].total.credits ~= 0 then if killstats[hash].total.rank == "Recruit" and killstats[hash].total.credits > 7500 then killstats[hash].total.rank = "Private" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Private" and killstats[hash].total.credits > 10000 then killstats[hash].total.rank = "Corporal" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Corporal" and killstats[hash].total.credits > 15000 then killstats[hash].total.rank = "Sergeant" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Sergeant" and killstats[hash].total.credits > 20000 then killstats[hash].total.rank = "Sergeant Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Sergeant Grade 1" and killstats[hash].total.credits > 26250 then killstats[hash].total.rank = "Sergeant Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Sergeant Grade 2" and killstats[hash].total.credits > 32500 then killstats[hash].total.rank = "Warrant Officer" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Warrant Officer" and killstats[hash].total.credits > 45000 then killstats[hash].total.rank = "Warrant Officer Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Warrant Officer Grade 1" and killstats[hash].total.credits > 78000 then killstats[hash].total.rank = "Warrant Officer Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Warrant Officer Grade 2" and killstats[hash].total.credits > 111000 then killstats[hash].total.rank = "Warrant Officer Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Warrant Officer Grade 3" and killstats[hash].total.credits > 144000 then killstats[hash].total.rank = "Captain" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Captain" and killstats[hash].total.credits > 210000 then killstats[hash].total.rank = "Captain Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Captain Grade 1" and killstats[hash].total.credits > 233000 then killstats[hash].total.rank = "Captain Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Captain Grade 2" and killstats[hash].total.credits > 256000 then killstats[hash].total.rank = "Captain Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Captain Grade 3" and killstats[hash].total.credits > 279000 then killstats[hash].total.rank = "Major" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Major" and killstats[hash].total.credits > 325000 then killstats[hash].total.rank = "Major Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Major Grade 1" and killstats[hash].total.credits > 350000 then killstats[hash].total.rank = "Major Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Major Grade 2" and killstats[hash].total.credits > 375000 then killstats[hash].total.rank = "Major Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Major Grade 3" and killstats[hash].total.credits > 400000 then killstats[hash].total.rank = "Lt. Colonel" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Lt. Colonel" and killstats[hash].total.credits > 450000 then killstats[hash].total.rank = "Lt. Colonel Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Lt. Colonel Grade 1" and killstats[hash].total.credits > 480000 then killstats[hash].total.rank = "Lt. Colonel Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Lt. Colonel Grade 2" and killstats[hash].total.credits > 510000 then killstats[hash].total.rank = "Lt. Colonel Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Lt. Colonel Grade 3" and killstats[hash].total.credits > 540000 then killstats[hash].total.rank = "Commander" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Commander" and killstats[hash].total.credits > 600000 then killstats[hash].total.rank = "Commander Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Commander Grade 1" and killstats[hash].total.credits > 650000 then killstats[hash].total.rank = "Commander Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Commander Grade 2" and killstats[hash].total.credits > 700000 then killstats[hash].total.rank = "Commander Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Commander Grade 3" and illstats[hash].total.credits > 750000 then killstats[hash].total.rank = "Colonel" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Colonel" and killstats[hash].total.credits > 850000 then killstats[hash].total.rank = "Colonel Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Colonel Grade 1" and killstats[hash].total.credits > 960000 then killstats[hash].total.rank = "Colonel Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Colonel Grade 2" and killstats[hash].total.credits > 1070000 then killstats[hash].total.rank = "Colonel Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Colonel Grade 3" and killstats[hash].total.credits > 1180000 then killstats[hash].total.rank = "Brigadier" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Brigadier" and killstats[hash].total.credits > 1400000 then killstats[hash].total.rank = "Brigadier Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Brigadier Grade 1" and killstats[hash].total.credits > 1520000 then killstats[hash].total.rank = "Brigadier Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Brigadier Grade 2" and killstats[hash].total.credits > 1640000 then killstats[hash].total.rank = "Brigadier Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Brigadier Grade 3" and killstats[hash].total.credits > 1760000 then killstats[hash].total.rank = "General" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "General" and killstats[hash].total.credits > 2000000 then killstats[hash].total.rank = "General Grade 1" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "General Grade 1" and killstats[hash].total.credits > 2200000 then killstats[hash].total.rank = "General Grade 2" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "General Grade 2" and killstats[hash].total.credits > 2350000 then killstats[hash].total.rank = "General Grade 3" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "General Grade 3" and killstats[hash].total.credits > 2500000 then killstats[hash].total.rank = "General Grade 4" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "General Grade 4" and killstats[hash].total.credits > 2650000 then killstats[hash].total.rank = "Field Marshall" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Field Marshall" and killstats[hash].total.credits > 3000000 then killstats[hash].total.rank = "Hero" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Hero" and killstats[hash].total.credits > 3700000 then killstats[hash].total.rank = "Legend" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Legend" and killstats[hash].total.credits > 4600000 then killstats[hash].total.rank = "Mythic" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Mythic" and killstats[hash].total.credits > 5650000 then killstats[hash].total.rank = "Noble" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Noble" and killstats[hash].total.credits > 7000000 then killstats[hash].total.rank = "Eclipse" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Eclipse" and killstats[hash].total.credits > 8500000 then killstats[hash].total.rank = "Nova" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Nova" and killstats[hash].total.credits > 11000000 then killstats[hash].total.rank = "Forerunner" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Forerunner" and killstats[hash].total.credits > 13000000 then killstats[hash].total.rank = "Reclaimer" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") elseif killstats[hash].total.rank == "Reclaimer" and killstats[hash].total.credits > 16500000 then killstats[hash].total.rank = "Inheritor" say(getname(killer) .. " is now a " .. killstats[hash].total.rank .. "!") end end end function GivePlayerMedals(player) local hash = gethash(player) -- Get the player's hash. if hash then if done[hash].medal.sprees == "False" then if medals[hash].class.sprees == "Iron" and medals[hash].count.sprees >= 5 then -- If the class is iron and the count is more then 5, medals[hash].class.sprees = "Bronze" -- Level it up. say(getname(player) .. " has earned a medal : Any Spree Iron!") -- Tell them what they earned. elseif medals[hash].class.sprees == "Bronze" and medals[hash].count.sprees >= 50 then -- If the class is bronze and the count is more then 50. medals[hash].class.sprees = "Silver" -- Level it up. say(getname(player) .. " has earned a medal : Any Spree Bronze!") -- Tell them what they earned. elseif medals[hash].class.sprees == "Silver" and medals[hash].count.sprees >= 250 then -- If the class is silver and the clount is more then 250. medals[hash].class.sprees = "Gold" -- Level it up. say(getname(player) .. " has earned a medal : Any Spree Silver!") -- Tell them what they earned. elseif medals[hash].class.sprees == "Gold" and medals[hash].count.sprees >= 1000 then -- If the class is gold and the count is more then 1000. medals[hash].class.sprees = "Onyx" -- Level it up. say(getname(player) .. " has earned a medal : Any Spree Gold!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Any Spree : Gold") changescore(player, 1000, plus) elseif medals[hash].class.sprees == "Onyx" and medals[hash].count.sprees >= 4000 then -- If the class is onyx and the count is more then 4000. medals[hash].class.sprees = "MAX" -- Level it up. say(getname(player) .. " has earned a medal : Any Spree Onyx!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 2000 privatesay(player, "Rewarded: +2000 cR - Any Spree : Onyx") changescore(player, 2000, plus) elseif medals[hash].class.sprees == "MAX" and medals[hash].count.sprees == 10000 then -- if the class is max and the count is 10000. say(getname(player) .. " has earned a medal : Any Spree MAX!") -- Tell them what they have earned. killstats[hash].total.credits = killstats[hash].total.credits + 3000 privatesay(player, "Rewarded: +3000 cR - Any Spree : MAX") changescore(player, 3000, plus) done[hash].medal.sprees = "True" end end if done[hash].medal.assists == "False" then if medals[hash].class.assists == "Iron" and medals[hash].count.assists >= 50 then -- If the class is iron and the count is more then 50. medals[hash].class.assists = "Bronze" -- Level it up. say(getname(player) .. " has earned a medal : Assistant Iron!") -- Tell them what they earned. elseif medals[hash].class.assists == "Bronze" and medals[hash].count.assists >= 250 then -- If the class is bronze and the count is more then 250. medals[hash].class.assists = "Silver" -- Level it up. say(getname(player) .. " has earned a medal : Assistant Bronze!") -- Tell them what they earned. elseif medals[hash].class.assists == "Silver" and medals[hash].count.assists >= 1000 then -- If the class is silver and the count is more then 1000. medals[hash].class.assists = "Gold" -- Level it up. say(getname(player) .. " has earned a medal : Assistant Silver!") -- Tell them what they earned. elseif medals[hash].class.assists == "Gold" and medals[hash].count.assists >= 4000 then -- If the class is gold and the count is more then 4000. medals[hash].class.assists = "Onyx" -- Level it up. say(getname(player) .. " has earned a medal : Assistant Gold!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Assistant : Gold") changescore(player, 1500, plus) elseif medals[hash].class.assists == "Onyx" and medals[hash].count.assists >= 8000 then -- If the class is onyx and the count is more then 8000. medals[hash].class.assists = "MAX" -- Level it up. say(getname(player) .. " has earned a medal : Assistant Onyx!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 2500 privatesay(player, "Rewarded: +2500 cR - Assistant : Onyx") changescore(player, 2500, plus) elseif medals[hash].class.assists == "MAX" and medals[hash].count.assists == 20000 then -- If the class is max and the count is 20000. say(getname(player) .. " has earned a medal : Assistant MAX!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 3500 privatesay(player, "Rewarded: +3500 cR - Assistant : MAX") changescore(player, 3500, plus) done[hash].medal.assists = "True" end end if done[hash].medal.closequarters == "False" then if medals[hash].class.closequarters == "Iron" and medals[hash].count.closequarters >= 50 then -- If the class is iron and the count is more then 50. medals[hash].class.closequarters = "Bronze" -- Level it up. say(getname(player) .. " has earned a medal : Close Quarters Iron!") -- Tell them what they earned. elseif medals[hash].class.closequarters == "Bronze" and medals[hash].count.closequarters >= 125 then -- If the class is bronze and the count is more then 125. medals[hash].class.closequarters = "Silver" -- Level it up. say(getname(player) .. " has earned a medal : Close Quarters Bronze!") -- Tell them what they earned. elseif medals[hash].class.closequarters == "Silver" and medals[hash].count.closequarters >= 400 then -- If the class is silver and the count is more then 400. medals[hash].class.closequarters = "Gold" -- Level it up. say(getname(player) .. " has earned a medal : Close Quarters Silver!") -- Tell them what they earned. elseif medals[hash].class.closequarters == "Gold" and medals[hash].count.closequarters >= 1600 then -- If the class is gold and the count is more then 1600. medals[hash].class.closequarters = "Onyx" -- Level it up. say(getname(player) .. " has earned a medal : Close Quarters Gold!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 750 privatesay(player, "Rewarded: +750 cR - Close Quarters : Gold") changescore(player, 750, plus) elseif medals[hash].class.closequarters == "Onyx" and medals[hash].count.closequarters >= 4000 then -- If the class is onyx and the count is more then 4000. medals[hash].class.closequarters = "MAX" -- Level it up. say(getname(player) .. " has earned a medal : Close Quarters Onyx!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Close Quarters : Onyx") changescore(player, 1500, plus) elseif medals[hash].class.closequarters == "MAX" and medals[hash].count.closequarters == 8000 then -- If the class is max and the count is 8000. say(getname(player) .. " has earned a medal : Close Quarters MAX!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 2250 privatesay(player, "2250 cR - Close Quarters : MAX") changescore(player, 2250, plus) done[hash].medal.closequarters = "True" end end if done[hash].medal.crackshot == "False" then if medals[hash].class.crackshot == "Iron" and medals[hash].count.crackshot >= 100 then -- If the class is iron and the count is more then 100 . medals[hash].class.crackshot = "Bronze" -- Level it up. say(getname(player) .. " has earned a medal : Crack Shot Iron!") -- Tell them what they earned. elseif medals[hash].class.crackshot == "Bronze" and medals[hash].count.crackshot >= 500 then -- If the class is bronze and the count is more then 500. medals[hash].class.crackshot = "Silver" -- Level it up. say(getname(player) .. " has earned a medal : Crack Shot Bronze!") -- Tell them what they earned. elseif medals[hash].class.crackshot == "Silver" and medals[hash].count.crackshot >= 4000 then -- If the class is silver and the count is more then 4000. medals[hash].class.crackshot = "Gold" -- Level it up. say(getname(player) .. " has earned a medal : Crack Shot Silver!") -- Tell them what they earned. elseif medals[hash].class.crackshot == "Gold" and medals[hash].count.crackshot >= 10000 then -- If the class is gold and the count is more then 10000. medals[hash].class.crackshot = "Onyx" -- Level it up. say(getname(player) .. " has earned a medal : Crack Shot Gold!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Crack Shot : Gold") changescore(player, 1000, plus) elseif medals[hash].class.crackshot == "Onyx" and medals[hash].count.crackshot >= 20000 then -- If the class is onyx and the count is more then 20000. medals[hash].class.crackshot = "MAX" -- Level it up. say(getname(player) .. " has earned a medal : Crack Shot Onyx!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 2000 privatesay(player, "Rewarded: +2000 cR - Crack Shot : Onyx") changescore(player, 2000, plus) elseif medals[hash].class.crackshot == "MAX" and medals[hash].count.crackshot == 32000 then -- If the class is max and the count is 32000. say(getname(player) .. " has earned a medal : Crack Shot MAX!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 3000 privatesay(player, "Rewarded: +3000 cR - Crack Shot : MAX") changescore(player, 3000, plus) done[hash].medal.crackshot = "True" end end if done[hash].medal.downshift == "False" then if medals[hash].class.downshift == "Iron" and medals[hash].count.downshift >= 5 then -- If the class is iron and count is more then 5. medals[hash].class.downshift = "Bronze" -- Level it up. say(getnamye(player) .. " has earned a medal : Downshift Iron!") -- Tell them what they earned. elseif medals[hash].class.downshift == "Bronze" and medals[hash].count.downshift >= 50 then -- If the class is bronze and count is more then 50. medals[hash].class.downshift = "Silver" -- Level it up say(getname(player) .. " has earned a medal : Downshift Bronze!") -- Tell them what the earned. elseif medals[hash].class.downshift == "Silver" and medals[hash].count.downshift >= 750 then -- If the class is silver and count is more then 750. medals[hash].class.downshift = "Gold" -- Level it up. say(getname(player) .. " has earned a medal : Downshift Silver!") -- Tell them what they earned. elseif medals[hash].class.downshift == "Gold" and medals[hash].count.downshift >= 4000 then -- If the class is gold and count is more then 4000. medals[hash].class.downshift = "Onyx" -- Level it up. say(getname(player) .. " has earned a medal : Downshift Gold!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 500 privatesay(player, "Rewarded: +500 cR - Downshift : Gold") changescore(player, 500, plus) elseif medals[hash].class.downshift == "Onyx" and medals[hash].count.downshift >= 8000 then -- If the class is onyx and count is more then 8000. medals[hash].class.downshift = "MAX" -- Level it up. say(getname(player) .. " has earned a medal : Downshift Onyx!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Downshift : Onyx") changescore(player, 1000, plus) elseif medals[hash].class.downshift == "MAX" and medals[hash].count.downshift == 20000 then -- If the class is max and count is 20000. say(getname(player) .. " has earned a medal : Downshift MAX!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Downshift : MAX") changescore(player, 1500, plus) done[hash].medal.downshift = "True" end end if done[hash].medal.grenadier == "False" then if medals[hash].class.grenadier == "Iron" and medals[hash].count.grenadier >= 25 then -- If the class is iron and count is more then 25. medals[hash].class.grenadier = "Bronze" -- Level it up. say(getname(player) .. " has earned a medal : Grenadier Iron!") -- Tell them what they earned. elseif medals[hash].class.grenadier == "Bronze" and medals[hash].count.grenadier >= 125 then -- If the class is bronze and count is more then 125. medals[hash].class.grenadier = "Silver" -- Level it up. say(getname(player) .. " has earned a medal : Grenadier Bronze!") -- Tell them what they earned. elseif medals[hash].class.grenadier == "Silver" and medals[hash].count.grenadier >= 500 then -- If the class is silver and count is more then 500. medals[hash].class.grenadier = "Gold" -- Level it up. say(getname(player) .. " has earned a medal : Grenadier Silver!") -- Tell them what they earned. elseif medals[hash].class.grenadier == "Gold" and medals[hash].count.grenadier >= 4000 then -- If the class is gold and count is more then 4000. medals[hash].class.grenadier = "Onyx" -- Level it up. say(getname(player) .. " has earned a medal : Grenadier Gold!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 750 privatesay(player, "Rewarded: +750 cR - Grenadier : Gold") changescore(player, 750, plus) elseif medals[hash].class.grenadier == "Onyx" and medals[hash].count.grenadier >= 8000 then -- If the class is onyx and count is more then 8000. medals[hash].class.grenadier = "MAX" -- Level it up say(getname(player) .. " has earned a medal : Grenadier Onyx!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Grenadier : Onyx") changescore(player, 1500, plus) elseif medals[hash].class.grenadier == "MAX" and medals[hash].count.grenadier == 14000 then -- If the class is max and count is 14000. say(getname(player) .. " has earned a medal : Grenadier MAX!") -- Tell them what they earned. killstats[hash].total.credits = killstats[hash].total.credits + 2250 privatesay(player, "Rewarded: +2250 cR - Grenadier : MAX") changescore(player, 2250, plus) done[hash].medal.grenadier = "True" end end if done[hash].medal.heavyweapons == "False" then if medals[hash].class.heavyweapons == "Iron" and medals[hash].count.heavyweapons >= 25 then medals[hash].class.heavyweapons = "Bronze" say(getname(player) .. " has earned a medal : Heavy Weapon Iron!") elseif medals[hash].class.heavyweapons == "Bronze" and medals[hash].count.heavyweapons >= 150 then medals[hash].class.heavyweapons = "Silver" say(getname(player) .. " has earned a medal : Heavy Weapon Bronze!") elseif medals[hash].class.heavyweapons == "Silver" and medals[hash].count.heavyweapons >= 750 then medals[hash].class.heavyweapons = "Gold" say(getname(player) .. " has earned a medal : Heavy Weapon Silver!") elseif medals[hash].class.heavyweapons == "Gold" and medals[hash].count.heavyweapons >= 3000 then medals[hash].class.heavyweapons = "Onyx" say(getname(player) .. " has earned a medal : Heavy Weapon Gold!") killstats[hash].total.credits = killstats[hash].total.credits + 500 privatesay(player, "Rewarded: +500 cR - Heavy Weapon : Gold") changescore(player, 500, plus) elseif medals[hash].class.heavyweapons == "Onyx" and medals[hash].count.heavyweapons >= 7000 then medals[hash].class.heavyweapons = "MAX" say(getname(player) .. " has earned a medal : Heavy Weapon Onyx!") killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Heavy Weapon : Onyx") changescore(player, 1000, plus) elseif medals[hash].class.heavyweapons == "MAX" and medals[hash].count.heavyweapons == 14000 then say(getname(player) .. " has earned a medal : Heavy Weapon MAX!") killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Heavy Weapon : MAX") changescore(player, 1500, plus) done[hash].medal.heavyweapons = "True" end end if done[hash].medal.jackofalltrades == "False" then if medals[hash].class.jackofalltrades == "Iron" and medals[hash].count.jackofalltrades >= 50 then -- Create the jackofalltrades count table. medals[hash].class.jackofalltrades = "Bronze" say(getname(player) .. " has earned a medal : Jack of all Trades Iron!") elseif medals[hash].class.jackofalltrades == "Bronze" and medals[hash].count.jackofalltrades >= 125 then medals[hash].class.jackofalltrades = "Silver" say(getname(player) .. " has earned a medal : Jack of all Trades Bronze!") elseif medals[hash].class.jackofalltrades == "Silver" and medals[hash].count.jackofalltrades >= 400 then medals[hash].class.jackofalltrades = "Gold" say(getname(player) .. " has earned a medal : Jack of all Trades Silver!") elseif medals[hash].class.jackofalltrades == "Gold" and medals[hash].count.jackofalltrades >= 1600 then medals[hash].class.jackofalltrades = "Onyx" say(getname(player) .. " has earned a medal : Jack of all Trades Gold!") killstats[hash].total.credits = killstats[hash].total.credits + 500 privatesay(player, "Rewarded: +500 cR - Jack of all Trades : Gold") changescore(player, 500, plus) elseif medals[hash].class.jackofalltrades == "Onyx" and medals[hash].count.jackofalltrades >= 4800 then medals[hash].class.jackofalltrades = "MAX" say(getname(player) .. " has earned a medal : Jack of all Trades Onyx!") killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Jack of all Trades : Onyx") changescore(player, 1000, plus) elseif medals[hash].class.jackofalltrades == "MAX" and medals[hash].count.jackofalltrades == 9600 then say(getname(player) .. " has earned a medal : Jack of all Trades MAX!") killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Jack of all Trades : MAX") changescore(player, 1500, plus) done[hash].medal.jackofalltrades = "True" end end if done[hash].medal.mobileasset == "False" then if medals[hash].class.mobileasset == "Iron" and medals[hash].count.moblieasset >= 25 then medals[hash].class.mobileasset = "Bronze" say(getname(player) .. " has earned a medal : Mobile Asset Iron!") elseif medals[hash].class.mobileasset == "Bronze" and medals[hash].count.moblieasset >= 125 then medals[hash].class.mobileasset = "Silver" say(getname(player) .. " has earned a medal : Mobile Asset Bronze!") elseif medals[hash].class.mobileasset == "Silver" and medals[hash].count.moblieasset >= 500 then medals[hash].class.mobileasset = "Gold" say(getname(player) .. " has earned a medal : Mobile Asset Silver!") elseif medals[hash].class.mobileasset == "Gold" and medals[hash].count.moblieasset >= 4000 then medals[hash].class.mobileasset = "Onyx" say(getname(player) .. " has earned a medal : Mobile Asset Gold!") killstats[hash].total.credits = killstats[hash].total.credits + 750 privatesay(player, "Rewarded: +750 cR - Mobile Asset : Gold") changescore(player, 750, plus) elseif medals[hash].class.mobileasset == "Onyx" and medals[hash].count.moblieasset >= 8000 then medals[hash].class.mobileasset = "MAX" say(getname(player) .. " has earned a medal : Mobile Asset Onyx!") killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Mobile Asset : Onyx") changescore(player, 1500, plus) elseif medals[hash].class.mobileasset == "MAX" and medals[hash].count.moblieasset == 14000 then say(getname(player) .. " has earned a medal : Mobile Asset MAX!") killstats[hash].total.credits = killstats[hash].total.credits + 2250 privatesay(player, "Rewarded: +2250 cR - Mobile Asset : MAX") changescore(player, 2250, plus) done[hash].medal.mobileasset = "True" end end if done[hash].medal.multikill == "False" then if medals[hash].class.multikill == "Iron" and medals[hash].count.multikill >= 10 then medals[hash].class.multikill = "Bronze" say(getname(player) .. " has earned a medal : Multikill Iron!") elseif medals[hash].class.multikill == "Bronze" and medals[hash].count.multikill >= 125 then medals[hash].class.multikill = "Silver" say(getname(player) .. " has earned a medal : Multikill Bronze!") elseif medals[hash].class.multikill == "Silver" and medals[hash].count.multikill >= 500 then medals[hash].class.multikill = "Gold" say(getname(player) .. " has earned a medal : Multikill Silver!") elseif medals[hash].class.multikill == "Gold" and medals[hash].count.multikill >= 2500 then medals[hash].class.multikill = "Onyx" say(getname(player) .. " has earned a medal : Multikill Gold!") killstats[hash].total.credits = killstats[hash].total.credits + 500 privatesay(player, "Rewarded: +500 cR - Multikill : Gold") changescore(player, 500, plus) elseif medals[hash].class.multikill == "Onyx" and medals[hash].count.multikill >= 5000 then medals[hash].class.multikill = "MAX" say(getname(player) .. " has earned a medal : Multikill Onyx!") killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Multikill : Onyx") changescore(player, 1000, plus) elseif medals[hash].class.multikill == "MAX" and medals[hash].count.multikill == 15000 then say(getname(player) .. " has earned a mdeal : Multikill MAX!") killstats[hash].total.credits = killstats[hash].total.credits + 1500 privatesay(player, "Rewarded: +1500 cR - Multikill : MAX") changescore(player, 1500, plus) done[hash].medal.multikill = "True" end end if done[hash].medal.sidearm == "False" then if medals[hash].class.sidearm == "Iron" and medals[hash].count.sidearm >= 50 then medals[hash].class.sidearm = "Bronze" say(getname(player) .. " has earned a medal : Sidearm Iron!") elseif medals[hash].class.sidearm == "Bronze" and medals[hash].count.sidearm >= 250 then medals[hash].class.sidearm = "Silver" say(getname(player) .. " has earned a medal : Sidearm Bronze!") elseif medals[hash].class.sidearm == "Silver" and medals[hash].count.sidearm >= 1000 then medals[hash].class.sidearm = "Gold" say(getname(player) .. " has earned a medal : Sidearm Silver!") elseif medals[hash].class.sidearm == "Gold" and medals[hash].count.sidearm >= 4000 then medals[hash].class.sidearm = "Onyx" say(getname(player) .. " has earned a medal : Sidearm Gold!") killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Sidearm : Gold") changescore(player, 1000, plus) elseif medals[hash].class.sidearm == "Onyx" and medals[hash].count.sidearm >= 8000 then medals[hash].class.sidearm = "MAX" say(getname(player) .. " has earned a medal : Sidearm Onyx!") killstats[hash].total.credits = killstats[hash].total.credits + 2000 privatesay(player, "Rewarded: +2000 cR - Sidearm : Onyx") changescore(player, 2000, plus) elseif medals[hash].class.sidearm == "MAX" and medals[hash].count.sidearm == 10000 then say(getname(player) .. " has earned a medal : Sidearm MAX!") killstats[hash].total.credits = killstats[hash].total.credits + 3000 privatesay(player, "Rewarded: +3000 cR - Sidearm : MAX") changescore(player, 3000, plus) done[hash].medal.sidearm = "True" end end if done[hash].medal.triggerman == "False" then if medals[hash].class.triggerman == "Iron" and medals[hash].count.triggerman >= 100 then medals[hash].class.triggerman = "Bronze" say(getname(player) .. " has earned a medal : Triggerman Iron!") elseif medals[hash].class.triggerman == "Bronze" and medals[hash].count.triggerman >= 500 then medals[hash].class.triggerman = "Silver" say(getname(player) .. " has earned a medal : Triggerman Bronze!") elseif medals[hash].class.triggerman == "Silver" and medals[hash].count.triggerman >= 4000 then medals[hash].class.triggerman = "Gold" say(getname(player) .. " has earned a medal : Triggerman Silver!") elseif medals[hash].class.triggerman == "Gold" and medals[hash].count.triggerman >= 10000 then medals[hash].class.triggerman = "Onyx" say(getname(player) .. " has earned a medal : Triggerman Gold!") killstats[hash].total.credits = killstats[hash].total.credits + 1000 privatesay(player, "Rewarded: +1000 cR - Triggerman : Gold") changescore(player, 1000, plus) elseif medals[hash].class.triggerman == "Onyx" and medals[hash].count.triggerman >= 20000 then medals[hash].class.triggerman = "MAX" say(getname(player) .. " has earned a medal : Triggerman Onyx!") killstats[hash].total.credits = killstats[hash].total.credits + 2000 privatesay(player, "Rewarded: +2000 cR - Triggerman : Onyx") changescore(player, 2000, plus) elseif medals[hash].class.triggerman == "MAX" and medals[hash].count.triggerman == 32000 then say(getname(player) .. " has earned a medal : Triggerman MAX!") killstats[hash].total.credits = killstats[hash].total.credits + 3000 privatesay(player, "Rewarded: +3000 cR - Triggerman : MAX") changescore(player, 3000, plus) done[hash].medal.triggerman = "True" end end end end function GetMedalClasses(player) local hash = gethash(player) if medals[hash].count.sprees > 5 and medals[hash].count.sprees < 50 then medals[hash].class.sprees = "Bronze" elseif medals[hash].count.sprees > 50 and medals[hash].count.sprees < 250 then medals[hash].class.sprees = "Silver" elseif medals[hash].count.sprees > 250 and medals[hash].count.sprees < 1000 then medals[hash].class.sprees = "Gold" elseif medals[hash].count.sprees > 1000 and medals[hash].count.sprees < 4000 then medals[hash].class.sprees = "Onyx" elseif medals[hash].count.sprees > 4000 and medals[hash].count.sprees < 10000 then medals[hash].class.sprees = "MAX" elseif medals[hash].count.sprees > 10000 then medals[hash].class.sprees = "MAX" end if medals[hash].count.assists > 50 and medals[hash].count.assists < 250 then medals[hash].class.assists = "Bronze" elseif medals[hash].count.assists > 250 and medals[hash].count.assists < 1000 then medals[hash].class.assists = "Silver" elseif medals[hash].count.assists > 1000 and medals[hash].count.assists < 4000 then medals[hash].class.assists = "Gold" elseif medals[hash].count.assists > 4000 and medals[hash].count.assists < 8000 then medals[hash].class.assists = "Onyx" elseif medals[hash].count.assists > 8000 and medals[hash].count.assists < 20000 then medals[hash].class.assists = "MAX" elseif medals[hash].count.assists > 20000 then medals[hash].class.assists = "MAX" end if medals[hash].count.closequarters > 50 and medals[hash].count.closequarters < 150 then medals[hash].class.closequarters = "Bronze" elseif medals[hash].count.closequarters > 150 and medals[hash].count.closequarters < 400 then medals[hash].class.closequarters = "Silver" elseif medals[hash].count.closequarters > 400 and medals[hash].count.closequarters < 1600 then medals[hash].class.closequarters = "Gold" elseif medals[hash].count.closequarters > 1600 and medals[hash].count.closequarters < 4000 then medals[hash].class.closequarters = "Onyx" elseif medals[hash].count.closequarters > 4000 and medals[hash].count.closequarters < 8000 then medals[hash].count.closequarters = "MAX" elseif medals[hash].count.closequarters > 8000 then medals[hash].count.closequarters = "MAX" end if medals[hash].count.crackshot > 100 and medals[hash].count.crackshot < 500 then medals[hash].class.crackshot = "Bronze" elseif medals[hash].count.crackshot > 500 and medals[hash].count.crackshot < 4000 then medals[hash].class.crackshot = "Silver" elseif medals[hash].count.crackshot > 4000 and medals[hash].count.crackshot < 10000 then medals[hash].class.crackshot = "Gold" elseif medals[hash].count.crackshot > 10000 and medals[hash].count.crackshot < 20000 then medals[hash].class.crackshot = "Onyx" elseif medals[hash].count.crackshot > 20000 and medals[hash].count.crackshot < 32000 then medals[hash].class.crackshot = "MAX" elseif medals[hash].count.crackshot > 32000 then medals[hash].class.crackshot = "MAX" end if medals[hash].count.downshift > 5 and medals[hash].count.downshift < 50 then medals[hash].class.downshift = "Bronze" elseif medals[hash].count.downshift > 50 and medals[hash].count.downshift < 750 then medals[hash].class.downshift = "Silver" elseif medals[hash].count.downshift > 750 and medals[hash].count.downshift < 4000 then medals[hash].class.downshift = "Gold" elseif medals[hash].count.downshift > 4000 and medals[hash].count.downshift < 8000 then medals[hash].class.downshift = "Onyx" elseif medals[hash].count.downshift > 8000 and medals[hash].count.downshift < 20000 then medals[hash].count.downshift = "MAX" elseif medals[hash].count.downshift > 20000 then medals[hash].count.downshift = "MAX" end if medals[hash].count.grenadier > 25 and medals[hash].count.grenadier < 125 then medals[hash].class.grenadier = "Bronze" elseif medals[hash].count.grenadier > 125 and medals[hash].count.grenadier < 500 then medals[hash].class.grenadier = "Silver" elseif medals[hash].count.grenadier > 500 and medals[hash].count.grenadier < 4000 then medals[hash].class.grenadier = "Gold" elseif medals[hash].count.grenadier > 4000 and medals[hash].count.grenadier < 8000 then medals[hash].class.grenadier = "Onyx" elseif medals[hash].count.grenadier > 8000 and medals[hash].count.grenadier < 14000 then medals[hash].class.grenadier = "MAX" elseif medals[hash].count.grenadier > 14000 then medals[hash].class.grenadier = "MAX" end if medals[hash].count.heavyweapons > 25 and medals[hash].count.heavyweapons < 150 then medals[hash].class.heavyweapons = "Bronze" elseif medals[hash].count.heavyweapons > 150 and medals[hash].count.heavyweapons < 750 then medals[hash].class.heavyweapons = "Silver" elseif medals[hash].count.heavyweapons > 750 and medals[hash].count.heavyweapons < 3000 then medals[hash].class.heavyweapons = "Gold" elseif medals[hash].count.heavyweapons > 3000 and medals[hash].count.heavyweapons < 7000 then medals[hash].class.heavyweapons = "Onyx" elseif medals[hash].count.heavyweapons > 7000 and medals[hash].count.heavyweapons < 14000 then medals[hash].class.heavyweapons = "MAX" elseif medals[hash].count.heavyweapons > 14000 then medals[hash].class.heavyweapons = "MAX" end if medals[hash].count.jackofalltrades > 50 and medals[hash].count.jackofalltrades < 125 then medals[hash].class.jackofalltrades = "Bronze" elseif medals[hash].count.jackofalltrades > 125 and medals[hash].count.jackofalltrades < 400 then medals[hash].class.jackofalltrades = "Silver" elseif medals[hash].count.jackofalltrades > 400 and medals[hash].count.jackofalltrades < 1600 then medals[hash].class.jackofalltrades = "Gold" elseif medals[hash].count.jackofalltrades > 1600 and medals[hash].count.jackofalltrades < 4800 then medals[hash].class.jackofalltrades = "Onyx" elseif medals[hash].count.jackofalltrades > 4800 and medals[hash].count.jackofalltrades < 9600 then medals[hash].class.jackofalltrades = "MAX" elseif medals[hash].count.jackofalltrades > 9600 then medals[hash].class.jackofalltrades = "MAX" end if medals[hash].count.moblieasset > 25 and medals[hash].count.moblieasset < 125 then medals[hash].class.mobileasset = "Bronze" -- Declear the medal's class. elseif medals[hash].count.moblieasset > 125 and medals[hash].count.moblieasset < 500 then medals[hash].class.mobileasset = "Silver" -- Declear the medal's class. elseif medals[hash].count.moblieasset > 500 and medals[hash].count.moblieasset < 4000 then medals[hash].class.mobileasset = "Gold" -- Declear the medal's class. elseif medals[hash].count.moblieasset > 4000 and medals[hash].count.moblieasset < 8000 then medals[hash].class.mobileasset = "Onyx" -- Declear the medal's class. elseif medals[hash].count.moblieasset > 8000 and medals[hash].count.moblieasset < 14000 then medals[hash].class.mobileasset = "MAX" -- Declear the medal's class. elseif medals[hash].count.moblieasset > 14000 then medals[hash].class.mobileasset = "MAX" -- Declear the medal's class. end if medals[hash].count.multikill > 10 and medals[hash].count.multikill < 125 then medals[hash].class.multikill = "Bronze" -- Declear the medal's class. elseif medals[hash].count.multikill > 125 and medals[hash].count.multikill < 500 then medals[hash].class.multikill = "Silver" -- Declear the medal's class. elseif medals[hash].count.multikill > 500 and medals[hash].count.multikill < 2500 then medals[hash].class.multikill = "Gold" -- Declear the medal's class. elseif medals[hash].count.multikill > 2500 and medals[hash].count.multikill < 5000 then medals[hash].class.multikill = "Onyx" -- Declear the medal's class. elseif medals[hash].count.multikill > 5000 and medals[hash].count.multikill < 15000 then medals[hash].class.multikill = "MAX" -- Declear the medal's class. elseif medals[hash].count.multikill > 15000 then medals[hash].class.multikill = "MAX" -- Declear the medal's class. end if medals[hash].count.sidearm > 50 and medals[hash].count.sidearm < 250 then medals[hash].class.sidearm = "Bronze" elseif medals[hash].count.sidearm > 250 and medals[hash].count.sidearm < 1000 then medals[hash].class.sidearm = "Silver" elseif medals[hash].count.sidearm > 1000 and medals[hash].count.sidearm < 4000 then medals[hash].class.sidearm = "Gold" elseif medals[hash].count.sidearm > 4000 and medals[hash].count.sidearm < 8000 then medals[hash].class.sidearm = "Onyx" elseif medals[hash].count.sidearm > 8000 and medals[hash].count.sidearm < 10000 then medals[hash].class.sidearm = "MAX" elseif medals[hash].count.sidearm > 10000 then medals[hash].class.sidearm = "MAX" end if medals[hash].count.triggerman > 100 and medals[hash].count.triggerman < 500 then medals[hash].class.triggerman = "Bronze" elseif medals[hash].count.triggerman > 500 and medals[hash].count.triggerman < 4000 then medals[hash].class.triggerman = "Silver" elseif medals[hash].count.triggerman > 4000 and medals[hash].count.triggerman < 10000 then medals[hash].class.triggerman = "Gold" elseif medals[hash].count.triggerman > 10000 and medals[hash].count.triggerman < 20000 then medals[hash].class.triggerman = "Onyx" elseif medals[hash].count.triggerman > 20000 and medals[hash].count.triggerman < 32000 then medals[hash].class.triggerman = "MAX" elseif medals[hash].count.triggerman > 32000 then medals[hash].class.triggerman = "MAX" end end function SendMessage(player, message) if getplayer(player) then sendconsoletext(player, message) end end function GetPlayerRank(player) local hash = gethash(player) -- Get the hash of the player. if hash then killstats[hash].total.credits = killstats[hash].total.credits or 0 if killstats[hash].total.credits > 0 and killstats[hash].total.credits ~= nil and killstats[hash].total.rank ~= nil then if killstats[hash].total.credits >= 0 and killstats[hash].total.credits < 7500 then -- 0 - 7,500 killstats[hash].total.rank = "Recruit" -- Decide his rank. elseif killstats[hash].total.credits > 7500 and killstats[hash].total.credits < 10000 then -- 7,500 - 10,000 killstats[hash].total.rank = "Private" -- Decide his rank. elseif killstats[hash].total.credits > 10000 and killstats[hash].total.credits < 15000 then -- 10,000 - 15,000 killstats[hash].total.rank = "Corporal" -- Decide his rank. elseif killstats[hash].total.credits > 15000 and killstats[hash].total.credits < 20000 then -- 15,000 - 20,000 killstats[hash].total.rank = "Sergeant" -- Decide his rank. elseif killstats[hash].total.credits > 20000 and killstats[hash].total.credits < 26250 then -- 20,000 - 26,250 killstats[hash].total.rank = "Sergeant Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 26250 and killstats[hash].total.credits < 32500 then -- 26,250 - 32,500 killstats[hash].total.rank = "Sergeant Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 32500 and killstats[hash].total.credits < 45000 then -- 32,500 - 45,000 killstats[hash].total.rank = "Warrant Officer" -- Decide his rank. elseif killstats[hash].total.credits > 45000 and killstats[hash].total.credits < 78000 then -- 45,000 - 78,000 killstats[hash].total.rank = "Warrant Officer Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 78000 and killstats[hash].total.credits < 111000 then -- 78,000 - 111,000 killstats[hash].total.rank = "Warrant Officer Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 111000 and killstats[hash].total.credits < 144000 then -- 111,000 - 144,000 killstats[hash].total.rank = "Warrant Officer Grade 3" -- Decide his rank. elseif killstats[hash].total.credits > 144000 and killstats[hash].total.credits < 210000 then -- 144,000 - 210,000 killstats[hash].total.rank = "Captain" -- Decide his rank. elseif killstats[hash].total.credits > 210000 and killstats[hash].total.credits < 233000 then -- 210,000 - 233,000 killstats[hash].total.rank = "Captain Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 233000 and killstats[hash].total.credits < 256000 then -- 233,000 - 256,000 killstats[hash].total.rank = "Captain Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 256000 and killstats[hash].total.credits < 279000 then -- 256,000 - 279,000 killstats[hash].total.rank = "Captain Grade 3" -- Decide his rank. elseif killstats[hash].total.credits > 279000 and killstats[hash].total.credits < 325000 then -- 279,000 - 325,000 killstats[hash].total.rank = "Major" -- Decide his rank. elseif killstats[hash].total.credits > 325000 and killstats[hash].total.credits < 350000 then -- 325,000 - 350,000 killstats[hash].total.rank = "Major Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 350000 and killstats[hash].total.credits < 375000 then -- 350,000 - 375,000 killstats[hash].total.rank = "Major Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 375000 and killstats[hash].total.credits < 400000 then -- 375,000 - 400,000 killstats[hash].total.rank = "Major Grade 3" -- Decide his rank elseif killstats[hash].total.credits > 400000 and killstats[hash].total.credits < 450000 then -- 400,000 - 450,000 killstats[hash].total.rank = "Lt. Colonel" -- Decide his rank. elseif killstats[hash].total.credits > 450000 and killstats[hash].total.credits < 480000 then -- 450,000 - 480,000 killstats[hash].total.rank = "Lt. Colonel Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 480000 and killstats[hash].total.credits < 510000 then -- 480,000 - 510,000 killstats[hash].total.rank = "Lt. Colonel Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 510000 and killstats[hash].total.credits < 540000 then -- 510,000 - 540,000 killstats[hash].total.rank = "Lt. Colonel Grade 3" -- Decide his rank. elseif killstats[hash].total.credits > 540000 and killstats[hash].total.credits < 600000 then -- 540,000 - 600,000 killstats[hash].total.rank = "Commander" -- Decide his rank. elseif killstats[hash].total.credits > 600000 and killstats[hash].total.credits < 650000 then -- 600,000 - 650,000 killstats[hash].total.rank = "Commander Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 650000 and killstats[hash].total.credits < 700000 then -- 650,000 - 700,000 killstats[hash].total.rank = "Commander Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 700000 and killstats[hash].total.credits < 750000 then -- 700,000 - 750,000 killstats[hash].total.rank = "Commander Grade 3" -- Decide his rank elseif killstats[hash].total.credits > 750000 and killstats[hash].total.credits < 850000 then -- 750,000 - 850,000 killstats[hash].total.rank = "Colonel" -- Decide his rank. elseif killstats[hash].total.credits > 850000 and killstats[hash].total.credits < 960000 then -- 850,000 - 960,000 killstats[hash].total.rank = "Colonel Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 960000 and killstats[hash].total.credits < 1070000 then -- 960,000 - 1,070,000 killstats[hash].total.rank = "Colonel Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 1070000 and killstats[hash].total.credits < 1180000 then -- 1,070,000 - 1,180,000 killstats[hash].total.rank = "Colonel Grade 3" -- Decide his rank. elseif killstats[hash].total.credits > 1180000 and killstats[hash].total.credits < 1400000 then -- 1,180,000 - 1,400,000 killstats[hash].total.rank = "Brigadier" -- Decide his rank. elseif killstats[hash].total.credits > 1400000 and killstats[hash].total.credits < 1520000 then -- 1,400,000 - 1,520,000 killstats[hash].total.rank = "Brigadier Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 1520000 and killstats[hash].total.credits < 1640000 then -- 1,520,000 - 1,640,000 killstats[hash].total.rank = "Brigadier Grade 2" -- Decide his rank elseif killstats[hash].total.credits > 1640000 and killstats[hash].total.credits < 1760000 then -- 1,640,000 - 1,760,000 killstats[hash].total.rank = "Brigadier Grade 3" -- Decide his rank. elseif killstats[hash].total.credits > 1760000 and killstats[hash].total.credits < 2000000 then -- 1,760,000 - 2,000,000 killstats[hash].total.rank = "General" -- Decide his rank. elseif killstats[hash].total.credits > 2000000 and killstats[hash].total.credits < 2200000 then -- 2,000,000 - 2,200,000 killstats[hash].total.rank = "General Grade 1" -- Decide his rank. elseif killstats[hash].total.credits > 2200000 and killstats[hash].total.credits < 2350000 then -- 2,200,000 - 2,350,000 killstats[hash].total.rank = "General Grade 2" -- Decide his rank. elseif killstats[hash].total.credits > 2350000 and killstats[hash].total.credits < 2500000 then -- 2,350,000 - 2,500,000 killstats[hash].total.rank = "General Grade 3" -- Decide his rank. elseif killstats[hash].total.credits > 2500000 and killstats[hash].total.credits < 2650000 then -- 2,500,000 - 2,650,000 killstats[hash].total.rank = "General Grade 4" -- Decide his rank. elseif killstats[hash].total.credits > 2650000 and killstats[hash].total.credits < 3000000 then -- 2,650,000 - 3,000,000 killstats[hash].total.rank = "Field Marshall" -- Decide his rank. elseif killstats[hash].total.credits > 3000000 and killstats[hash].total.credits < 3700000 then -- 3,000,000 - 3,700,000 killstats[hash].total.rank = "Hero" -- Decide his rank. elseif killstats[hash].total.credits > 3700000 and killstats[hash].total.credits < 4600000 then -- 3,700,000 - 4,600,000 killstats[hash].total.rank = "Legend" -- Decide his rank. elseif killstats[hash].total.credits > 4600000 and killstats[hash].total.credits < 5650000 then -- 4,600,000 - 5,650,000 killstats[hash].total.rank = "Mythic" -- Decide his rank. elseif killstats[hash].total.credits > 5650000 and killstats[hash].total.credits < 7000000 then -- 5,650,000 - 7,000,000 killstats[hash].total.rank = "Noble" -- Decide his rank. elseif killstats[hash].total.credits > 7000000 and killstats[hash].total.credits < 8500000 then -- 7,000,000 - 8,500,000 killstats[hash].total.rank = "Eclipse" -- Decide his rank. elseif killstats[hash].total.credits > 8500000 and killstats[hash].total.credits < 11000000 then -- 8,500,000 - 11,000,000 killstats[hash].total.rank = "Nova" -- Decide his rank. elseif killstats[hash].total.credits > 11000000 and killstats[hash].total.credits < 13000000 then -- 11,000,000 - 13,000,000 killstats[hash].total.rank = "Forerunner" -- Decide his rank. elseif killstats[hash].total.credits > 13000000 and killstats[hash].total.credits < 16500000 then -- 13,000,000 - 16,500,000 killstats[hash].total.rank = "Reclaimer" -- Decide his rank. elseif killstats[hash].total.credits > 16500000 and killstats[hash].total.credits < 20000000 then -- 16,500,000 - 20,000,000 killstats[hash].total.rank = "Inheritor" -- Decide his rank. end end end end function CreditsUntilNextPromo(player) local hash = gethash(player) killstats[hash].total.rank = killstats[hash].total.rank or "Recruit" killstats[hash].total.credits = killstats[hash].total.credits or 0 if killstats[hash].total.rank == "Recruit" then return 7500 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Private" then return 10000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Corporal" then return 15000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Sergeant" then return 20000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Sergeant Grade 1" then return 26250 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Sergeant Grade 2" then return 32500 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Warrant Officer" then return 45000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Warrant Officer Grade 1" then return 78000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Warrant Officer Grade 2" then return 111000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Warrant Officer Grade 3" then return 144000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Captain" then return 210000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Captain Grade 1" then return 233000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Captain Grade 2" then return 256000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Captain Grade 3" then return 279000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Major" then return 325000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Major Grade 1" then return 350000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Major Grade 2" then return 375000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Major Grade 3" then return 400000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Lt. Colonel" then return 450000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Lt. Colonel Grade 1" then return 480000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Lt. Colonel Grade 2" then return 510000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Lt. Colonel Grade 3" then return 540000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Commander" then return 600000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Commander Grade 1" then return 650000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Commander Grade 2" then return 700000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Commander Grade 3" then return 750000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Colonel" then return 850000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Colonel Grade 1" then return 960000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Colonel Grade 2" then return 1070000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Colonel Grade 3" then return 1180000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Brigadier" then return 1400000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Brigadier Grade 1" then return 1520000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Brigadier Grade 2" then return 1640000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Brigadier Grade 3" then return 1760000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "General" then return 2000000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "General Grade 1" then return 2350000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "General Grade 2" then return 2500000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "General Grade 3" then return 2650000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "General Grade 4" then return 3000000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Field Marshall" then return 3700000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Hero" then return 4600000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Legend" then return 5650000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Mythic" then return 7000000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Noble" then return 8500000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Eclipse" then return 11000000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Nova" then return 13000000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Forerunner" then return 16500000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Reclaimer" then return 20000000 - killstats[hash].total.credits elseif killstats[hash].total.rank == "Inheritor" then return "Ranks Complete" end end function RuleTimer(id, count) local number = getvalidcount(count) if number ~= nil then if number == 1 then say("Blocking Ports / Pathways / Tunnels, Glitching into rocks/trees/out of map is not allowed.") elseif number == 2 then say("Team Grenading / Flipping / Shooting / Meleeing / Ramming is not allowed.") elseif number == 3 then say("Type \"@stuck\" for more indepth rules") elseif number == 4 then say("If you get stuck, you can type \"@stuck\" to find a way out.") elseif number == 5 then say("Type \"@info\" for all the commands to view your stats.") end end return true end function getvalidcount(count) local number = nil if table.find({ "180", "360", "540", "720", "900", "1080" }, count) then number = 1 elseif table.find({ "182", "362", "542", "722", "902", "1082" }, count) then number = 2 elseif table.find({ "184", "364", "544", "724", "904", "1084" }, count) then number = 3 elseif table.find({ "186", "366", "546", "726", "906", "1086" }, count) then number = 4 elseif table.find({ "188", "368", "548", "728", "908", "1088" }, count) then number = 5 end return number end function secondsToTime(seconds, places) local years = math.floor(seconds / (60 * 60 * 24 * 365)) seconds = seconds % (60 * 60 * 24 * 365) local weeks = math.floor(seconds / (60 * 60 * 24 * 7)) seconds = seconds % (60 * 60 * 24 * 7) local days = math.floor(seconds / (60 * 60 * 24)) seconds = seconds % (60 * 60 * 24) local hours = math.floor(seconds / (60 * 60)) seconds = seconds % (60 * 60) local minutes = math.floor(seconds / 60) seconds = seconds % 60 if places == 6 then return string.format("%02d:%02d:%02d:%02d:%02d:%02d", years, weeks, days, hours, minutes, seconds) elseif places == 5 then return string.format("%02d:%02d:%02d:%02d:%02d", weeks, days, hours, minutes, seconds) elseif not places or places == 4 then return days, hours, minutes, seconds elseif places == 3 then return string.format("%02d:%02d:%02d", hours, minutes, seconds) elseif places == 2 then return string.format("%02d:%02d", minutes, seconds) elseif places == 1 then return string.format("%02", seconds) end end WriteLog = function(filename, value) local dir = getprofilepath() .. "\\logs\\" local file = io.open(dir .. filename, "a") if file then local timestamp = os.date("%Y/%m/%d %H:%M:%S") local line = string.format("%s\t%s\n", timestamp, tostring(value)) file:write(line) file:close() end end function setscore(player, score) if tonumber(score) then if gametype == 1 then -- CTF local m_player = getplayer(player) if score >= 0x7FFF then writewordsigned(m_player + 0xC8, 0x0, 0x7FFF) elseif score <= -0x7FFF then writewordsigned(m_player + 0xC8, 0x0, -0x7FFF) else writewordsigned(m_player + 0xC8, 0x0, score) end elseif gametype == 2 then -- Slayer if score >= 0x7FFFFFFF then writedwordsigned(slayer_globals + 0x40 + player * 4, 0x0, 0x7FFFFFFF) elseif score <= -0x7FFFFFFF then writedwordsigned(slayer_globals + 0x40 + player * 4, 0x0, -0x7FFFFFFF) else writedwordsigned(slayer_globals + 0x40 + player * 4, 0x0, score) end elseif gametype == 3 then -- Oddball local oddball_game = readbyte(gametype_base, 0x8C) if oddball_game == 0 or oddball_game == 1 then if score * 30 >= 0x7FFFFFFF then writedwordsigned(oddball_globals + 0x84 + player * 4, 0x0, 0x7FFFFFFF) elseif score * 30 <= -0x7FFFFFFF then writedwordsigned(oddball_globals + 0x84 + player * 4, 0x0, -1 * 0x7FFFFFFF) else writedwordsigned(oddball_globals + 0x84 + player * 4, 0x0, score * 30) end else if score > 0x7FFFFC17 then writedwordsigned(oddball_globals + 0x84 + player * 4, 0x0, 0x7FFFFC17) elseif score <= -0x7FFFFC17 then writedwordsigned(oddball_globals + 0x84 + player * 4, 0x0, -0x7FFFFC17) else writedwordsigned(oddball_globals + 0x84 + player * 4, 0x0, score) end end elseif gametype == 4 then -- KOTH local m_player = getplayer(player) if score * 30 >= 0x7FFF then writewordsigned(m_player, 0xC4, 0x7FFF) elseif score * 30 <= -0x7FFF then writewordsigned(m_player, 0xC4, -0x7FFF) else writewordsigned(m_player, 0xC4, score * 30) end elseif gametype == 5 then -- Race local m_player = getplayer(player) if score >= 0x7FFF then writewordsigned(m_player + 0xC6, 0x0, 0x7FFF) elseif score <= -0x7FFF then writewordsigned(m_player + 0xC6, 0x0, -0x7FFF) else writewordsigned(m_player + 0xC6, 0x0, score) end end end end function writewordsigned(address, offset, word) value = tonumber(word) if value == nil then value = tonumber(word, 16) end if value and value > 0x7FFF then local max = 0xFFFF local difference = max - value value = -1 - difference end writeword(address, offset, value) end function writedwordsigned(address, offset, dword) value = tonumber(dword) if value == nil then value = tonumber(dword, 16) end if value and value > 0x7FFFFFFF then local max = 0xFFFFFFFF local difference = max - value value = -1 - difference end writedword(address, offset, value) end function changescore(player, number, type) local m_player = getplayer(player) if m_player then local player_flag_scores = readword(m_player + 0xC8) if type == plus or type == add then local score = player_flag_scores + number setscore(player, score) elseif type == take or type == minus or type == subtract then local score = player_flag_scores + math.abs(number) setscore(player, score) end end end function readstring(address, length, endian) local char_table = { } local string = "" local offset = offset or 0x0 if length == nil then if readbyte(address + offset + 1) == 0 and readbyte(address + offset) ~= 0 then length = 51000 else length = 256 end end for i = 0, length do if readbyte(address + (offset + i)) ~= 0 then table.insert(char_table, string.char(readbyte(address + (offset + i)))) elseif i % 2 == 0 and readbyte(address + offset + i) == 0 then break end end for k, v in pairs(char_table) do if endian == 1 then string = v .. string else string = string .. v end end return string end -- Credits to the original creator(s): {FC}[Z�]SlimJim -- Credits to Kennan for what ever he did to it. -- This script has been modified and formatted to work as an independant Stats Script, code extracted from the original Zombies & Vehicles Script -- Put together by: Chalwk: (Jericho Crosby)
local ioe = require 'ioe' local types = require 'hj212.types' local tag_finder = require 'hj212.tags.finder' local base = require 'hj212.server.client' local cjson = require 'cjson.safe' local TAG_INFO = {} local function create_tag_input(tag_name) if TAG_INFO[tag_name] then return TAG_INFO[tag_name] end local tag = tag_finder(tag_name) if not tag then TAG_INFO[tag_name] = { name = tag_name, desc = tag_name, vt = 'string' } else local vt = 'string' if tag.format and string.sub(tag.format, 1, 1) == 'N' then vt = 'float' end TAG_INFO[tag_name] = { name = tag_name, desc = tag.desc, unit = tag.unit, vt = vt } end return TAG_INFO[tag_name] end local function create_tag_info(tag_name, info_name) local tag_name = tag_name .. '_' .. info_name if TAG_INFO[tag_name] then return TAG_INFO[tag_name] end local tag = tag_finder(info_name) if not tag then TAG_INFO[tag_name] = { name = tag_name, desc = tag_name, vt = 'string', } else local vt = 'string' if tag.format and string.sub(tag.format, 1, 1) == 'N' then vt = 'float' end TAG_INFO[tag_name] = { name = tag_name, desc = tag.desc, unit = tag.unit, vt = vt } end return TAG_INFO[tag_name] end local client = base:subclass('hj212_server.server.client.base') function client:initialize(server, pfuncs) base.initialize(self, pfuncs) self._server = server self._sn = nil self._log = server:log_api() self._meter_rs = nil -- unknown self._rdata_map = {} self._inputs = { { name = 'RS', desc = 'Meter state', vt = 'int' }, } self._inputs_changed = true self._inputs_cov = {} self._info_map = {} self._info_cov = {} self:add_handler('handler') end function client:sn() return self._sn end function client:set_sn(sn) self._sn = sn end function client:timeout() return 3000 end function client:retry() return 3 end function client:set_dev(dev) self._dev = dev end function client:log_api() return self._server:log_api() end function client:sys_api() return self._server:sys_api() end function client:dump_raw(io, data) return self._server:dump_raw(self._sn, io, data) end function client:log(level, ...) local f = self._log[level] or self._log.debug return f(self._log, ...) end function client:server() return self._server end function client:on_station_create(system, dev_id, passwd, ver) return self._server:create_station(self, system, dev_id, passwd, ver) end function client:on_disconnect() local now = ioe.time() self._meter_rs = nil self._dev:set_input_prop('RS', 'value', types.RS.Stoped, now, -1) for name, rdata in pairs(self._rdata_map) do self._dev:set_input_prop(name, 'value', rdata.value, now, -1) self._dev:set_input_prop(name, 'RDATA', cjson.encode(rdata), now, -1) end return self._server:on_disconnect(self) end function client:on_rdata(name, rdata) if not self._rdata_map[name] then self._inputs_changed = true table.insert(self._inputs, create_tag_input(name)) end table.insert(self._inputs_cov, name) self._rdata_map[name] = { value = assert(rdata.Rtd), value_z = rdata.ZsRtd, value_src = rdata.RtdSrc, timestamp = rdata.SampleTime, flag = rdata.Flag or self:rs_flag() } if not self._meter_rs and (not rdata.Flag or rdata.Flag == 'N') then self._meter_rs = types.RS.Normal self._dev:set_input_prop('RS', 'value', self._meter_rs) end end function client:on_info(name, info_list, no_cov) local changed = false local info = self._info_map[name] if not info then self._info_map[name] = {} info = self._info_map[name] changed = true end for k, v in pairs(info_list) do if info[k] == nil then self._inputs_changed = true table.insert(self._inputs, create_tag_info(name, k)) end info[k] = v end for _, v in ipairs(self._info_cov) do if v == name then return end end table.insert(self._info_cov, name) end function client:on_run() if self._inputs_changed then self._inputs_changed = nil self._dev:mod(self._inputs) self._dev:set_input_prop('RS', 'value', self._meter_rs ~= nil and self._meter_rs or types.RS.Stoped) end for _, name in ipairs(self._inputs_cov) do local rdata = self._rdata_map[name] local quality = (self._meter_rs and self._meter_rs ~= types.RS.Normal) and self._meter_rs or nil self._dev:set_input_prop(name, 'value', rdata.value, nil, quality) self._dev:set_input_prop(name, 'RDATA', rdata, rdata.timestamp) end for _, name in ipairs(self._info_cov) do local info_list = self._info_map[name] --print('INFO', name, cjson.encode(info_list)) self._dev:set_input_prop(name, 'INFO', info_list) for k, v in pairs(info_list) do self._dev:set_input_prop(name..'_'..k, 'value', v) end end self._inputs_cov = {} self._info_cov = {} end function client:set_meter_rs(rs, fire_rdata) assert(rs) self._meter_rs = rs self._dev:set_input_prop('RS', 'value', self._meter_rs) if fire_rdata then for name, rdata in pairs(self._rdata_map) do table.insert(self._inputs_cov, name) end end end function client:rs_flag() if not self._meter_rs then return nil end if self._meter_rs == types.RS.Normal then return nil -- unset the flag end if self._meter_rs == types.RS.Stoped then return types.FLAG.Stoped end if self._meter_rs == types.RS.Calibration then return types.FLAG.Calibration end if self._meter_rs == types.RS.Maintain then return types.FLAG.Maintain end if self._meter_rs == types.RS.Alarm then return types.FLAG.Error end if self._meter_rs == types.RS.Clean then return types.FLAG.Calibration end return types.FLAG.Error end return client
local x = 0 local x2 = 0 for a=1,25 do for b=1,25 do for c=1,25 do for d=1,25 do for e=1,25 do for f=1,25 do --io.write(a,",",b,",",c,",",d,",",e,",",f,",",x,"\n") x = x + 1 x2 = x2 + a + b + c + d + e + f end end end end end end --print(a,",",b,",",c,",",d,",",e,",",f,",",x,"\n") io.write(x,"\n") io.write(x2,"\n")
EPOCH = OPT.epochNumber local best_performance = 0 local train_performance = 0 local eval_performance = 0 local test_performance = 0 for i=OPT.epochNumber, OPT.nEpochs do if OPT.train then train_performance = train() end if OPT.eval and (i == OPT.nEpochs or i % OPT.nEpochsEval == 0) then eval_performance = eval() end if OPT.test and (i == OPT.nEpochs or i % OPT.nEpochsTest == 0) then test_performance = test() end -- Save the model if OPT.saveBest then -- assume larger the performance, better the performance if best_performance < eval_performance then best_performance = eval_performance saveDataParallel(paths.concat(OPT.save, 'best_model.t7'), MODEL) end end if (OPT.train and OPT.nEpochsSave > 0 and (i == OPT.nEpochs or i % OPT.nEpochsSave == 0)) then saveDataParallel(paths.concat(OPT.save, 'model_' .. EPOCH .. '.t7'), MODEL) end EPOCH = EPOCH + 1 end
require('lspconfig').pylsp.setup({ on_attach = require('plugins').lsp_on_attach, capabilities = require('plugins').lsp_capabilities })
mobs:register_mob("mobs:stone_monster", { type = "monster", hp_min = 12, hp_max = 35, exp_min = 3, exp_max = 55, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4}, visual = "mesh", mesh = "mobs_stone_monster.x", textures = {"mobs_stone_monster.png"}, visual_size = {x=3, y=2.6}, makes_footstep_sound = true, view_range = 10, walk_velocity = 0.5, run_velocity = 2, damage = 3, drops = { {name = "default:torch", chance = 70, min = 3, max = 5,}, {name = "default:iron_lump", chance=50, min=1, max=2,}, {name = "default:coal_lump", chance=50, min=1, max=3,}, }, light_resistant = true, armor = 80, drawtype = "front", water_damage = 0, lava_damage = 0, light_damage = 0, attack_type = "dogfight", animation = { speed_normal = 15, speed_run = 15, stand_start = 0, stand_end = 14, walk_start = 15, walk_end = 38, run_start = 40, run_end = 63, punch_start = 40, punch_end = 63, }, sounds = { attack = "mobs_stone_attack", death = "mobs_stone_death", random = "mobs_stone", }, step = 0.5, }) mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 7, -1, 8000, 3, 0)
function onCreate() setProperty('dad.x',40) setProperty('dad.y',-55) end
local Symbol = require(script.Parent.Symbol) -- Marker used to specify that the value is nothing, because nil cannot be -- stored in tables. local None = Symbol.named("None") return None
--[[ quads0 Author: Colton Ogden [email protected] Demonstrates simply drawing a texture. ]] -- Don't do this in a "real" project, I've only done this so we don't need -- to have copies of the extra libraries in every directory. Best practice is -- to set things up so your project works with the default package.path, or -- to only add paths that are inside your package directory. - Chris H. package.path = package.path .. ';../../common/?/?.lua;../../common/?/init.lua' package.path = package.path .. ';../../common/hump/?.lua' package.path = package.path .. ';../../common/knife/?.lua' push = require 'push' function love.load() love.graphics.setDefaultFilter('nearest', 'nearest') texture = love.graphics.newImage('match3.png') push:setupScreen(512, 288, 1280, 720, { fullscreen = false }) end function love.keypressed(key) if key == 'escape' then love.event.quit() end end function love.draw() push:start() love.graphics.draw(texture) push:finish() end
local function from_part(part: BasePart): Region3 return Region3.new(part.Position - part.Size/2, part.Position + part.Size/2) end return from_part
local ANONYMOUS_NAME = "Admin" local PUBLIC_MESSAGE_DEFAULT_COLOR = COLORS.yellow local FIND_LOGS_LIMIT = 50 addEvent("gra.cCommands.execute", true) local commandsData = {} local hcCommandsData = {} local function getAdminGroups(element) local groups = {} for i, group in ipairs(getObjectACLGroups(element)) do groups[i] = aclGroupGetName(group) end return groups end local function formatMessage(message, admin, player) local anonymous = cPersonalSettings.get(admin, "anonymous") local adminName = anonymous and ANONYMOUS_NAME or getPlayerName(admin) local playerName = player and getPlayerName(player) or "player" message = message :gsub("%$player", playerName) :gsub("%$admin", adminName) return message end local function outputConsoleLog(admin, commandName, description) local message = string.format( "COMMANDS: %s: %s BY (%s) %s (Account: '%s' Serial: %s)", commandName, description, table.concat(getAdminGroups(admin), ", "), getPlayerName(admin), getPlayerAccountName(admin) or NIL_TEXT, admin == console and NIL_TEXT or getPlayerSerial(admin) ) return cMessages.outputConsole(message) end local function outputDBLog(admin, commandName, description) return cDB.exec( [[ INSERT INTO command_logs ( timestamp, command, serial, account, name, plain_name, groups, description ) VALUES (?,?,?,?,?,?,?,?) ]], getRealTime().timestamp, commandName, admin == console and "0" or getPlayerSerial(admin), getPlayerAccountName(admin) or nil, getPlayerName(admin), getPlayerName(admin, true), toJSON(getAdminGroups(admin)), description ) end local argParsers = { ["s"] = function(arg) return arg end, ["n"] = function(arg) return tonumber(arg) end, ["b"] = function(arg) return arg == "yes" end, ["nil"] = function(arg) return arg == "none" end, ["s-"] = function(args) return table.concat(args, " ") end, ["ts-"] = function(args) return args end, ["tn-"] = function(args) for i, arg in ipairs(args) do args[i] = tonumber(arg) if not args[i] then return false end end return args end, ["se"] = function(arg) return isValidSerial(arg) and utf8.upper(arg) end, ["ip"] = function(arg) return isValidIP(arg) and arg end, ["du"] = function(arg) return parseDuration(arg) end, ["byte"] = function(arg) arg = tonumber(arg) if not arg then return false end return arg >= 0 and arg <= 255 and arg end, ["P"] = function(arg) local players = getPlayersByPartialName(arg) if not players then return false end if #players == 0 then return false end if #players > 1 then return false, #players.." players found" end return players[1] end, ["T"] = function(arg) return getTeamFromName(arg) end, ["R"] = function(arg) return getResourceFromName(arg) end, ["ven"] = function(arg) return getVehicleModelFromPartialName(utf8.gsub(arg, "_", " ")) end, ["wen"] = function(arg) return getWeaponIDFromPartialName(utf8.gsub(arg, "_", " ")) end, ["skn"] = function(arg) return getPedModelFromPartialName(utf8.gsub(arg, "_", " ")) end, ["fin"] = function(arg) return getFightingStyleFromPartialName(utf8.gsub(arg, "_", " ")) end, ["wan"] = function(arg) return getWalkingStyleFromPartialName(utf8.gsub(arg, "_", " ")) end, ["stn"] = function(arg) return getPedStatFromPartialName(utf8.gsub(arg, "_", " ")) end, ["inn"] = function(arg) return getInteriorLocationFromPartialName(utf8.gsub(arg, "_", " ")) end, ["wrn"] = function(arg) return getWeatherFromPartialName(utf8.gsub(arg, "_", " ")) end, } local function parseArgs(commandName, ...) local args = table.pack(...) local commandData = commandsData[commandName] local result = {} for i, variants in ipairs(commandData.types) do local arg = args[i] if not arg then if i >= commandData.opt then return result end return false, string.format("* Syntax: %s %s", commandName, commandData.syntax) end if utf8.match(variants[1], "-$") then arg = {} for ia = i, args.n do table.insert(arg, args[ia]) end end local parsed, msg = false, nil local isFalse, isNil = false, false for iv, variant in ipairs(variants) do if variant == "b" and arg == "no" then isFalse = true parsed = false elseif variant == "nil" and arg == "none" then isNil = true parsed = nil else parsed, msg = argParsers[variant](arg) end if parsed or isNil or isFalse then break end end if not (parsed or isFalse or isNil) then msg = string.format("%s: invalid %s (arg #%d)", commandName, table.concat(commandData.names[i], "/")..(msg and " ("..msg..")" or ""), i) return false, msg end result[i] = parsed end return result end local function parseSyntax(pattern) local argTypes = {} local argNames = {} local optionalPos = 1 local syntax = "" if not pattern then return argTypes, argNames, optionalPos, syntax end local args = split(pattern, ",") optionalPos = #args + 1 for i, one in ipairs(args) do if utf8.match(one, "^%[") then one = utf8.gsub(one, "^%[", "") args[i] = one optionalPos = i syntax = syntax.."[" end argTypes[i] = {} argNames[i] = {} syntax = syntax.."<" for iv, variant in ipairs(split(one, "|")) do local variantType = utf8.match(variant, ":(.+)$") if not argParsers[variantType] then error(string.format("parse syntax error: %s type not found", variantType), 3) end argTypes[i][iv] = variantType argNames[i][iv] = utf8.match(variant, "^(.+):") end syntax = syntax..table.concat(argNames[i], "/")..">" if i < #args then syntax = syntax.." " end end if optionalPos <= #args then syntax = syntax.."]" end return argTypes, argNames, optionalPos, syntax end local function mainHandler(admin, commandName, args) local commandData = commandsData[commandName] or hcCommandsData[commandName] if not commandData then return warn("command '"..commandName.."' handler not found", 1) and false end local result, resultMessage, publicMessage, playerMessage = commandData.handler(admin, table.unpack(args)) if result == false then return cMessages.outputAdmin(commandName..": "..(resultMessage or "command failed"), admin, COLORS.red) and false end local player = args[1] and type(args[1]) == "userdata" and isElement(args[1]) and getElementType(args[1]) == "player" and args[1] or nil local outputResultMessage = resultMessage and true or false local logMessage = formatMessage(resultMessage or commandName.." executed successfully", admin, player) outputConsoleLog(admin, commandName, logMessage) outputDBLog(admin, commandName, logMessage) if resultMessage then cMessages.outputAdmin(formatMessage(resultMessage, admin, player), admin, COLORS.green) end if publicMessage and not cPersonalSettings.get(admin, "silent") then cMessages.outputPublic(formatMessage(publicMessage, admin, player), root, commandData.color or PUBLIC_MESSAGE_DEFAULT_COLOR) end if playerMessage and player then cMessages.outputPublic(formatMessage(playerMessage, admin, player), player, commandData.color or PUBLIC_MESSAGE_DEFAULT_COLOR) end return true end local function onServerCommand(admin, commandName, ...) if not hasObjectPermissionTo(admin, GENERAL_PERMISSION, false) then return cMessages.outputSecurity("COMMANDS: client $v doesn't have permission $v", admin, GENERAL_PERMISSION) and false end if not hasObjectPermissionTo(admin, "command."..commandName, false) then return cMessages.outputSecurity("COMMANDS: client $v doesn't have permission $v", admin, "command."..commandName) and false end if not commandsData[commandName] then return warn("command '"..commandName.."' handler not found", 1) and false end local args, msg = parseArgs(commandName, ...) if not args then return cMessages.outputAdmin(msg, admin, COLORS.red) and false end return mainHandler(admin, commandName, args) end local function onClientRequest(commandName, ...) local client = client if not client then return cMessages.outputSecurity("COMMANDS: client not found") and false end if source ~= client then return cMessages.outputSecurity("COMMANDS: source $v element is not equal client $v", source, client) and false end if not hasObjectPermissionTo(client, GENERAL_PERMISSION, false) then return cMessages.outputSecurity("COMMANDS: client $v doesn't have permission $v", client, GENERAL_PERMISSION) and false end if not hasObjectPermissionTo(client, "command."..commandName, false) then return cMessages.outputSecurity("COMMANDS: client $v doesn't have permission $v", client, "command."..commandName) and false end return mainHandler(client, commandName, table.pack(...)) end cCommands = {} function cCommands.init() cDB.exec([[ CREATE TABLE IF NOT EXISTS command_logs ( id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp INTEGER NOT NULL, command TEXT NOT NULL, serial TEXT NOT NULL, account TEXT NOT NULL, name TEXT NOT NULL, plain_name TEXT NOT NULL, groups TEXT NOT NULL, description TEXT ) ]]) local publicPermissions = getObjectPermissions("user.*", "command") for commandName, commandData in pairs(commandsData) do if table.index(publicPermissions, "command."..commandName) then cMessages.outputSecurity("COMMANDS: all users have permission to command $v (fix your ACL)", commandName) end addCommandHandler(commandName, onServerCommand, true, true) end for commandName, commandData in pairs(hcCommandsData) do if table.index(publicPermissions, "command."..commandName) then cMessages.outputSecurity("COMMANDS: all users have permission to hardcoded command $v (fix your ACL)", commandName) end end addEventHandler("gra.cCommands.execute", root, onClientRequest) return true end function cCommands.add(commandName, handlerFunction, pattern, description, color, aliases) if not scheck("s,f,?s[2],?t") then return false end if commandsData[commandName] then return warn("command '"..commandName.."' handler is already added", 2) and false end if hcCommandsData[commandName] then return warn("hardcoded command '"..commandName.."' handler is already added", 2) and false end local argTypes, argNames, optionalPos, syntax = parseSyntax(pattern) commandsData[commandName] = { handler = handlerFunction, types = argTypes, names = argNames, opt = optionalPos, syntax = syntax, desc = description, color = color, aliases = aliases } return true end -- need for client execute requests (see "gra.cCommands.execute" event) function cCommands.addHardCoded(commandName, handlerFunction, color) if not scheck("s,f,?t") then return false end if hcCommandsData[commandName] then return warn("hardcoded command '"..commandName.."' handler is already added", 2) and false end if commandsData[commandName] then return warn("command '"..commandName.."' handler is already added", 2) and false end hcCommandsData[commandName] = { handler = handlerFunction, color = color, } return true end function cCommands.findLogs(filter, lastID) if not scheck("?t,?n") then return false end filter = filter or {} local query = cDB.prepare("SELECT * FROM command_logs WHERE id > ?", lastID or 0) if filter.since then query = query..cDB.prepare(" AND timestamp > ?", filter.since) end if filter.before then query = query..cDB.prepare(" AND timestamp < ?", filter.before) end if filter.command then query = query..cDB.prepare(" AND command LIKE ?", "%"..filter.command.."%") end if filter.serial then query = query..cDB.prepare(" AND serial LIKE ?", "%"..filter.serial.."%") end if filter.account then query = query..cDB.prepare(" AND account LIKE ?", "%"..filter.account.."%") end if filter.name then query = query..cDB.prepare(" AND plain_name LIKE ?", "%"..filter.name.."%") end if filter.group then query = query..cDB.prepare(" AND groups LIKE ?", "%"..filter.group.."%") end query = query..cDB.prepare(" LIMIT ?", FIND_LOGS_LIMIT) local result = cDB.query(query) if not result then return result end for i, row in ipairs(result) do row.groups = row.groups and fromJSON(row.groups) or nil end return result end
local h = require("null-ls.helpers") local methods = require("null-ls.methods") local DIAGNOSTICS = methods.internal.DIAGNOSTICS return h.make_builtin({ name = "clang_tidy", method = DIAGNOSTICS, filetypes = { "cpp", "c" }, generator_opts = { command = "clang-tidy", args = { "--quiet", "--checks=-*,modernize-*", "$FILENAME", }, to_stdin = false, from_stderr = false, format = "line", on_output = h.diagnostics.from_pattern( "(%d+):(%d+): (%w+): (.*) %[(.*)%]", { "row", "col", "severity", "message", "code" }, { severities = { note = h.diagnostics.severities["information"], style = h.diagnostics.severities["hint"], performance = h.diagnostics.severities["warning"], portability = h.diagnostics.severities["information"], }, } ), }, factory = h.generator_factory, })
local spell = {} spell = {} spell["numericaltype"] = [[Percentage]] spell["element"] = [[Support]] --a function: cost spell["desc"] = [[Raises damage done with rapiers]] --a function: numberofhits spell["conditional"] = [[if self.weapon.type IS HSWD]] --a function: hitchance spell["target"] = [[Self]] spell["passive"] = true --a function: statuschance spell["name"] = [[1h Swd Master]] --a function: status spell["targetattribute"] = [[Attack]] spell["numericalvalue"] = 100 --a function: costtype return spell
require 'lubyk' flooder = zmq.Pub() print(flooder:port()) i = 0 while true do i = i + 1 flooder:send(i, math.random()) end
pg = pg or {} pg.enemy_data_statistics_200 = { [12300209] = { cannon = 31, hit_growth = 210, rarity = 3, speed_growth = 0, pilot_ai_template_id = 10001, air = 0, luck = 0, dodge = 3, cannon_growth = 2592, speed = 18, reload = 150, reload_growth = 0, dodge_growth = 48, id = 12300209, star = 4, hit = 14, antisub_growth = 0, air_growth = 0, torpedo = 0, base = 225, durability = 1360, armor_growth = 0, torpedo_growth = 0, luck_growth = 0, battle_unit_type = 65, armor = 0, durability_growth = 59840, antiaircraft = 45, antisub = 0, antiaircraft_growth = 3744, appear_fx = { "appearQ" }, equipment_list = { 1100021, 1100626, 1100041, 1100731 }, buff_list = { { ID = 50510, LV = 2 } } }, [12300210] = { cannon = 0, reload = 150, speed_growth = 0, cannon_growth = 0, pilot_ai_template_id = 10001, air = 44, rarity = 3, dodge = 5, torpedo = 0, durability_growth = 54400, antiaircraft = 45, reload_growth = 0, dodge_growth = 72, hit_growth = 210, star = 4, hit = 14, antisub_growth = 0, air_growth = 3627, battle_unit_type = 70, base = 237, durability = 1070, armor_growth = 0, torpedo_growth = 0, luck_growth = 0, speed = 18, luck = 0, id = 12300210, antiaircraft_growth = 3744, antisub = 0, armor = 0, appear_fx = { "appearQ" }, equipment_list = { 1100021, 1100171, 1100796, 1100801, 1100806 } }, [12300211] = { cannon = 0, reload = 150, speed_growth = 0, cannon_growth = 0, pilot_ai_template_id = 20001, air = 0, rarity = 1, dodge = 0, torpedo = 0, durability_growth = 6800, antiaircraft = 0, reload_growth = 0, dodge_growth = 0, speed = 30, star = 1, hit = 8, antisub_growth = 0, air_growth = 0, hit_growth = 120, base = 90, durability = 700, armor_growth = 0, torpedo_growth = 0, luck_growth = 0, antiaircraft_growth = 0, luck = 0, battle_unit_type = 20, id = 12300211, antisub = 0, armor = 0, appear_fx = { "appearsmall" } }, [12300212] = { cannon = 0, battle_unit_type = 35, rarity = 1, speed_growth = 0, pilot_ai_template_id = 20001, air = 0, luck = 0, dodge = 0, wave_fx = "danchuanlanghuaxiao2", cannon_growth = 0, speed = 15, reload_growth = 0, dodge_growth = 0, id = 12300212, star = 1, hit = 8, antisub_growth = 0, air_growth = 0, reload = 150, base = 70, durability = 265, armor_growth = 0, torpedo_growth = 864, luck_growth = 0, hit_growth = 120, armor = 0, torpedo = 30, durability_growth = 2550, antisub = 0, antiaircraft = 0, antiaircraft_growth = 0, appear_fx = { "appearsmall" }, equipment_list = { 1000861 } }, [12300213] = { cannon = 50, reload = 150, speed_growth = 0, cannon_growth = 0, pilot_ai_template_id = 80000, air = 0, rarity = 1, dodge = 0, torpedo = 100, durability_growth = 2550, antiaircraft = 0, reload_growth = 0, dodge_growth = 0, hit_growth = 1200, star = 1, hit = 81, antisub_growth = 0, air_growth = 0, battle_unit_type = 15, base = 80, durability = 70, armor_growth = 0, torpedo_growth = 1080, luck_growth = 0, speed = 30, luck = 0, id = 12300213, antiaircraft_growth = 0, antisub = 0, armor = 0, appear_fx = { "appearsmall" }, equipment_list = { 1000866 } }, [12300214] = { cannon = 5, reload = 150, speed_growth = 0, cannon_growth = 300, pilot_ai_template_id = 10002, air = 0, rarity = 1, dodge = 0, torpedo = 38, durability_growth = 2250, antiaircraft = 0, reload_growth = 0, dodge_growth = 0, hit_growth = 120, star = 2, hit = 8, antisub_growth = 0, air_growth = 0, battle_unit_type = 55, base = 129, durability = 80, armor_growth = 0, torpedo_growth = 3600, luck_growth = 0, speed = 8, luck = 0, id = 12300214, antiaircraft_growth = 0, antisub = 0, armor = 0, equipment_list = { 611241, 611242 } }, [12300221] = { cannon = 55, reload = 150, speed_growth = 0, cannon_growth = 1600, rarity = 3, air = 0, torpedo = 80, dodge = 11, durability_growth = 123200, antiaircraft = 145, luck = 5, reload_growth = 0, dodge_growth = 156, hit_growth = 210, star = 4, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 303, durability = 1420, armor_growth = 0, torpedo_growth = 2000, luck_growth = 0, speed = 20, armor = 0, id = 12300221, antiaircraft_growth = 3600, antisub = 0, appear_fx = { "appearQ" }, equipment_list = { 1100021, 1100176, 1100316, 1100376 } }, [12300222] = { cannon = 55, reload = 150, speed_growth = 0, cannon_growth = 1600, rarity = 3, air = 0, torpedo = 80, dodge = 11, durability_growth = 134400, antiaircraft = 145, luck = 5, reload_growth = 0, dodge_growth = 156, hit_growth = 210, star = 4, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 303, durability = 1550, armor_growth = 0, torpedo_growth = 2000, luck_growth = 0, speed = 20, armor = 0, id = 12300222, antiaircraft_growth = 3600, antisub = 0, appear_fx = { "appearQ" }, equipment_list = { 1100021, 1100176, 1100316, 1100376 } }, [12300223] = { cannon = 95, reload = 150, speed_growth = 0, cannon_growth = 2200, rarity = 3, air = 0, torpedo = 0, dodge = 11, durability_growth = 153600, antiaircraft = 120, luck = 5, reload_growth = 0, dodge_growth = 156, hit_growth = 210, star = 4, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 304, durability = 2410, armor_growth = 0, torpedo_growth = 0, luck_growth = 0, speed = 20, armor = 0, id = 12300223, antiaircraft_growth = 3200, antisub = 0, appear_fx = { "appearQ" }, equipment_list = { 1100026, 1101541, 1101521, 1100526 } }, [12300224] = { cannon = 55, reload = 150, speed_growth = 0, cannon_growth = 1600, rarity = 3, air = 0, torpedo = 80, dodge = 11, durability_growth = 145600, antiaircraft = 145, luck = 5, reload_growth = 0, dodge_growth = 156, hit_growth = 210, star = 4, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 303, durability = 1680, armor_growth = 0, torpedo_growth = 2000, luck_growth = 0, speed = 20, armor = 0, id = 12300224, antiaircraft_growth = 3600, antisub = 0, appear_fx = { "appearQ" }, equipment_list = { 1100021, 1100176, 1100316, 1100376 } }, [12300225] = { cannon = 95, reload = 150, speed_growth = 0, cannon_growth = 2200, rarity = 3, air = 0, torpedo = 0, dodge = 11, durability_growth = 166400, antiaircraft = 120, luck = 5, reload_growth = 0, dodge_growth = 156, hit_growth = 210, star = 4, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 304, durability = 2610, armor_growth = 0, torpedo_growth = 0, luck_growth = 0, speed = 20, armor = 0, id = 12300225, antiaircraft_growth = 3200, antisub = 0, appear_fx = { "appearQ" }, equipment_list = { 1100026, 1101541, 1101521, 1100526 } }, [12300226] = { cannon = 120, hit_growth = 210, rarity = 3, speed_growth = 0, pilot_ai_template_id = 10001, air = 0, luck = 5, dodge = 11, cannon_growth = 3600, speed = 20, reload = 150, reload_growth = 0, dodge_growth = 156, id = 12300226, star = 4, hit = 14, antisub_growth = 0, air_growth = 0, torpedo = 0, base = 366, durability = 3850, armor_growth = 0, torpedo_growth = 0, luck_growth = 0, battle_unit_type = 90, armor = 0, durability_growth = 249600, antiaircraft = 135, antisub = 0, antiaircraft_growth = 3200, appear_fx = { "appearQ" }, equipment_list = { 1100022, 1101526, 1101532, 1101536 }, buff_list = { { ID = 50500, LV = 2 } } }, [12300227] = { cannon = 35, reload = 150, speed_growth = 0, cannon_growth = 800, rarity = 1, air = 0, torpedo = 120, dodge = 5, durability_growth = 22000, antiaircraft = 0, luck = 5, reload_growth = 0, dodge_growth = 72, hit_growth = 210, star = 2, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 369, durability = 660, armor_growth = 0, torpedo_growth = 3600, luck_growth = 0, speed = 12, armor = 0, id = 12300227, antiaircraft_growth = 0, antisub = 0, scale = 150, equipment_list = { 611243, 611244, 611245 } }, [12300228] = { cannon = 35, reload = 150, speed_growth = 0, cannon_growth = 800, rarity = 1, air = 0, torpedo = 120, dodge = 5, durability_growth = 24000, antiaircraft = 0, luck = 5, reload_growth = 0, dodge_growth = 72, hit_growth = 210, star = 2, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 369, durability = 720, armor_growth = 0, torpedo_growth = 3600, luck_growth = 0, speed = 12, armor = 0, id = 12300228, antiaircraft_growth = 0, antisub = 0, scale = 150, equipment_list = { 611243, 611244, 611245 } }, [12300229] = { cannon = 35, reload = 150, speed_growth = 0, cannon_growth = 800, rarity = 1, air = 0, torpedo = 120, dodge = 5, durability_growth = 26000, antiaircraft = 0, luck = 5, reload_growth = 0, dodge_growth = 72, hit_growth = 210, star = 2, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 90, base = 369, durability = 780, armor_growth = 0, torpedo_growth = 3600, luck_growth = 0, speed = 12, armor = 0, id = 12300229, antiaircraft_growth = 0, antisub = 0, scale = 150, equipment_list = { 611243, 611244, 611245 } }, [12300231] = { cannon = 135, reload = 150, speed_growth = 0, cannon_growth = 0, rarity = 5, air = 0, torpedo = 0, dodge = 14, durability_growth = 0, antiaircraft = 145, luck = 8, reload_growth = 0, dodge_growth = 198, hit_growth = 210, star = 6, hit = 14, antisub_growth = 0, air_growth = 0, battle_unit_type = 95, base = 363, durability = 19800, armor_growth = 0, torpedo_growth = 0, luck_growth = 0, speed = 18, armor = 0, id = 12300231, antiaircraft_growth = 0, antisub = 0, appear_fx = { "bossguangxiao", "appearQ" }, equipment_list = { 611061, 611062, 611063, 611064, 611065, 611066 } } } return
--[[ Original textures from Crops Plus mod Copyright (C) 2018 Grizzly Adam https://forum.minetest.net/viewtopic.php?f=9&t=19488 ]] local S = farming.intllib -- potato minetest.register_craftitem("farming:onion", { description = S("Onion"), inventory_image = "crops_onion.png", groups = {seed = 2, food_onion = 1, flammable = 3}, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:onion_1") end, on_use = minetest.item_eat(1), }) -- crop definition local crop_def = { drawtype = "plantlike", tiles = {"crops_onion_plant_1.png"}, paramtype = "light", paramtype2 = "meshoptions", place_param2 = 3, sunlight_propagates = true, waving = 1, walkable = false, buildable_to = true, drop = "", selection_box = farming.select, groups = { snappy = 3, flammable = 3, plant = 1, attached_node = 1, not_in_creative_inventory = 1, growing = 1 }, sounds = default.node_sound_leaves_defaults() } -- stage 1 minetest.register_node("farming:onion_1", table.copy(crop_def)) -- stage 2 crop_def.tiles = {"crops_onion_plant_2.png"} minetest.register_node("farming:onion_2", table.copy(crop_def)) -- stage 3 crop_def.tiles = {"crops_onion_plant_3.png"} minetest.register_node("farming:onion_3", table.copy(crop_def)) -- stage 4 crop_def.tiles = {"crops_onion_plant_4.png"} minetest.register_node("farming:onion_4", table.copy(crop_def)) -- stage 5 crop_def.tiles = {"crops_onion_plant_5.png"} crop_def.groups.growing = 0 crop_def.drop = { max_items = 5, items = { {items = {"farming:onion"}, rarity = 1}, {items = {"farming:onion"}, rarity = 1}, {items = {"farming:onion"}, rarity = 2}, {items = {"farming:onion"}, rarity = 2}, {items = {"farming:onion"}, rarity = 5}, } } minetest.register_node("farming:onion_5", table.copy(crop_def)) -- add to registered_plants farming.registered_plants["farming:onion"] = { crop = "farming:onion", seed = "farming:onion", minlight = 13, maxlight = 15, steps = 5 }
nnoremap("<leader>S", ":lua require('spectre').open()<CR>") -- search current word nnoremap("<leader>sw", ":lua require('spectre').open_visual({select_word=true})<CR>") vnoremap("<leader>s", ":lua require('spectre').open_visual()<CR>") -- search in current file nnoremap("<leader>sp", "viw:lua require('spectre').open_file_search()<cr>")
local Users=box.space.Users function RegisterUser(UserName,Email,Password) local Result if Users.index.Email:get(Email) or Users.index.Name:get(UserName) then return 409 elseif pcall(function() Result=Users:insert{nil,UserName,Email,CryptoPassword(Password),nil,true,nil} end)then return 200 else return 500 end end function Login(Email,Password) local Res=Users.index.Login:get({Email,CryptoPassword(Password)}) local Session=MkSession() if Res and Res[6] and pcall(function() Users.index.Login:update({Email,CryptoPassword(Password)},{{'=',7,Session}}) end) then return 200,{Session=Session} else return 404 end end function NewPassword(Session,OldPassword,NewPassword) return RunWithUser(Session,function(User) if User[4]==CryptoPassword(OldPassword) then Users:update(User[1],{{'=',4,CryptoPassword(NewPassword)}}) return 200 else return 403 end end) end function GetCurrUser(Session) return RunWithUser(Session,function(User) return 200,{ ID=User[1], Name=User[2], Email=User[3], IsAdmin=User[5]=='Admin' or User[5]=='UberAdmin', IsUberAdmin=User[5]=='UberAdmin', Enabled=User[6] } end) end
fx_version 'cerulean' game 'gta5' description 'Enc0ded Persistent Vehicles: https://github.com/enc0ded/enc0ded-persistent-vehicles' version '1.0.0' client_scripts { '@vrp/lib/utils.lua', 'config.lua', 'client/entityiter.lua', 'client/_utils.lua', 'client/main.lua', } server_scripts { '@vrp/lib/utils.lua', 'config.lua', 'server/main.lua', }
local function printUsage() print( "Usages:" ) print( "label get" ) print( "label get <drive>" ) print( "label set <text>" ) print( "label set <drive> <text>" ) print( "label clear" ) print( "label clear <drive>" ) end local function checkDrive( sDrive ) if peripheral.getType( sDrive ) == "drive" then -- Check the disk exists local bData = disk.hasData( sDrive ) if not bData then print( "No disk in "..sDrive.." drive" ) return false end else print( "No disk drive named "..sDrive ) return false end return true end local function get( sDrive ) if sDrive ~= nil then if checkDrive( sDrive ) then local sLabel = disk.getLabel( sDrive ) if sLabel then print( "Disk label is \""..sLabel.."\"" ) else print( "No Disk label" ) end end else local sLabel = os.getComputerLabel() if sLabel then print( "Computer label is \""..sLabel.."\"" ) else print( "No Computer label" ) end end end local function set( sDrive, sText ) if sDrive ~= nil then if checkDrive( sDrive ) then disk.setLabel( sDrive, sText ) local sLabel = disk.getLabel( sDrive ) if sLabel then print( "Disk label set to \""..sLabel.."\"" ) else print( "Disk label cleared" ) end end else os.setComputerLabel( sText ) local sLabel = os.getComputerLabel() if sLabel then print( "Computer label set to \""..sLabel.."\"" ) else print( "Computer label cleared" ) end end end local tArgs = { ... } local sCommand = tArgs[1] if sCommand == "get" then -- Get a label if #tArgs == 1 then get( nil ) elseif #tArgs == 2 then get( tArgs[2] ) else printUsage() end elseif sCommand == "set" then -- Set a label if #tArgs == 2 then set( nil, tArgs[2] ) elseif #tArgs == 3 then set( tArgs[2], tArgs[3] ) else printUsage() end elseif sCommand == "clear" then -- Clear a label if #tArgs == 1 then set( nil, nil ) elseif #tArgs == 2 then set( tArgs[2], nil ) else printUsage() end else printUsage() end
return function(self, birthday) for _, v in pairs(self) do if type(v) == "table" and v.name and v.birthday:match(birthday) then return v end end end
require "util" require "libs/array_pair" -- Sanity: site names aren't allowed to be longer than this, to prevent them -- kicking the buttons off the right edge of the screen local MAX_SITE_NAME_LENGTH = 50 resmon = { on_click = {}, endless_resources = {}, } function string.starts_with(haystack, needle) return string.sub(haystack, 1, string.len(needle)) == needle end function string.ends_with(haystack, needle) return string.sub(haystack, -string.len(needle)) == needle end function resmon.init_globals() for index,_ in pairs(game.players) do resmon.init_player(index) end end function resmon.on_player_created(event) resmon.init_player(event.player_index) end function resmon.init_player(player_index) local player = game.players[player_index] resmon.init_force(player.force) if not global.player_data then global.player_data = {} end local player_data = global.player_data[player_index] if not player_data then player_data = {} end if player_data.expandoed == nil then player_data.expandoed = false end if not player_data.gui_update_ticks or player_data.gui_update_ticks == 60 then player_data.gui_update_ticks = 300 end if not player_data.overlays then player_data.overlays = {} end global.player_data[player_index] = player_data end function resmon.init_force(force) if not global.force_data then global.force_data = {} end local force_data = global.force_data[force.name] if not force_data then force_data = {} end if not force_data.ore_sites then force_data.ore_sites = {} else resmon.migrate_ore_sites(force_data) resmon.migrate_ore_entities(force_data) end global.force_data[force.name] = force_data end local function position_to_string(entity) -- scale it up so (hopefully) any floating point component disappears, -- then force it to be an integer with %d. not using util.positiontostr -- as it uses %g and keeps the floating point component. return string.format("%d,%d", entity.x * 100, entity.y * 100) end function resmon.migrate_ore_entities(force_data) for name, site in pairs(force_data.ore_sites) do if site.known_positions then site.known_positions = nil end if site.entities then site.entity_positions = array_pair.new() for _, ent in pairs(site.entities) do if ent.valid then array_pair.insert(site.entity_positions, ent.position) end end site.entities = nil end if site.entity_positions then site.entity_table = {} site.entity_count = 0 local iter = array_pair.iterator(site.entity_positions) while iter.has_next() do pos = iter.next() local key = position_to_string(pos) site.entity_table[key] = pos site.entity_count = site.entity_count + 1 end site.entity_positions = nil end end end function resmon.migrate_ore_sites(force_data) for name, site in pairs(force_data.ore_sites) do if not site.remaining_permille then site.remaining_permille = math.floor(site.amount * 1000 / site.initial_amount) end if not site.ore_per_minute then site.ore_per_minute = 0 end end end local function find_resource_at(surface, position) -- The position we get is centered in its tile (e.g., {8.5, 17.5}). -- Sometimes, the resource does not cover the center, so search the full tile. local top_left = {x = position.x - 0.5, y = position.y - 0.5} local bottom_right = {x = position.x + 0.5, y = position.y + 0.5} local stuff = surface.find_entities_filtered{area={top_left, bottom_right}, type='resource'} if #stuff < 1 then return nil end return stuff[1] -- there should never be another resource at the exact same coordinates end function resmon.on_built_entity(event) if event.created_entity.name ~= 'resource-monitor' then return end local player = game.players[event.player_index] local player_data = global.player_data[event.player_index] local pos = event.created_entity.position local surface = event.created_entity.surface -- Don't actually place the resource monitor entity if not player.cursor_stack.valid_for_read then player.cursor_stack.set_stack{name="resource-monitor", count=1} elseif player.cursor_stack.name == "resource-monitor" then player.cursor_stack.count = player.cursor_stack.count + 1 end event.created_entity.destroy() local resource = find_resource_at(surface, pos) if not resource then -- if we have an expanding site, submit it. else, just drop the current site if player_data.current_site and player_data.current_site.is_site_expanding then resmon.submit_site(event.player_index) else resmon.clear_current_site(event.player_index) end return end local rescat = resource.prototype.resource_category if rescat and rescat == "sand" then player.print{"YARM-err-sand-is-bad", rescat} return end resmon.add_resource(event.player_index, resource) end function resmon.clear_current_site(player_index) local player = game.players[player_index] local player_data = global.player_data[player_index] player_data.current_site = nil while #player_data.overlays > 0 do table.remove(player_data.overlays).destroy() end end function resmon.add_resource(player_index, entity) local player = game.players[player_index] local player_data = global.player_data[player_index] if player_data.current_site and player_data.current_site.ore_type ~= entity.name then if player_data.current_site.finalizing then resmon.submit_site(player_index) else resmon.clear_current_site(player_index) end end if not player_data.current_site then player_data.current_site = { added_at = game.tick, surface = entity.surface, force = player.force, ore_type = entity.name, ore_name = entity.prototype.localised_name, entity_table = {}, entity_count = 0, initial_amount = 0, amount = 0, extents = { left = entity.position.x, right = entity.position.x, top = entity.position.y, bottom = entity.position.y, }, next_to_scan = {}, entities_to_be_overlaid = {}, next_to_overlay = {}, } if resmon.is_endless_resource(entity.name, entity.prototype) then player_data.current_site.minimum_resource_amount = entity.prototype.minimum_resource_amount end end if player_data.current_site.is_site_expanding then player_data.current_site.has_expanded = true -- relevant for the console output if not player_data.current_site.original_amount then player_data.current_site.original_amount = player_data.current_site.amount end end resmon.add_single_entity(player_index, entity) -- note: resmon.scan_current_site() (via on_tick) will continue the operation from here end function resmon.add_single_entity(player_index, entity) local player_data = global.player_data[player_index] local site = player_data.current_site local entity_pos = entity.position -- Don't re-add the same entity multiple times local key = position_to_string(entity_pos) if site.entity_table[key] then return end if site.finalizing then site.finalizing = false end -- Memorize this entity site.entity_table[key] = entity_pos site.entity_count = site.entity_count + 1 table.insert(site.next_to_scan, entity) site.amount = site.amount + entity.amount -- Resize the site bounds if necessary if entity.position.x < site.extents.left then site.extents.left = entity.position.x elseif entity.position.x > site.extents.right then site.extents.right = entity.position.x end if entity.position.y < site.extents.top then site.extents.top = entity.position.y elseif entity.position.y > site.extents.bottom then site.extents.bottom = entity.position.y end -- Give visible feedback, too resmon.put_marker_at(entity.surface, entity_pos, player_data) end function resmon.put_marker_at(surface, pos, player_data) if math.floor(pos.x) % settings.global["YARM-overlay-step"].value ~= 0 or math.floor(pos.y) % settings.global["YARM-overlay-step"].value ~= 0 then return end local overlay = surface.create_entity{name="rm_overlay", force=game.forces.neutral, position=pos} overlay.minable = false overlay.destructible = false overlay.operable = false table.insert(player_data.overlays, overlay) end local function shift_position(position, direction) if direction == defines.direction.north then return {x = position.x, y = position.y - 1} elseif direction == defines.direction.northeast then return {x = position.x + 1, y = position.y - 1} elseif direction == defines.direction.east then return {x = position.x + 1, y = position.y} elseif direction == defines.direction.southeast then return {x = position.x + 1, y = position.y + 1} elseif direction == defines.direction.south then return {x = position.x, y = position.y + 1} elseif direction == defines.direction.southwest then return {x = position.x - 1, y = position.y + 1} elseif direction == defines.direction.west then return {x = position.x - 1, y = position.y} elseif direction == defines.direction.northwest then return {x = position.x - 1, y = position.y - 1} else return position end end function resmon.scan_current_site(player_index) local site = global.player_data[player_index].current_site local to_scan = math.min(30, #site.next_to_scan) for i = 1, to_scan do local entity = table.remove(site.next_to_scan, 1) local entity_position = entity.position local surface = entity.surface -- Look in every direction around this entity... for _, dir in pairs(defines.direction) do -- ...and if there's a resource, add it local found = find_resource_at(surface, shift_position(entity_position, dir)) if found and found.name == site.ore_type then resmon.add_single_entity(player_index, found) end end end end local function find_center(area) local xpos = (area.left + area.right) / 2 local ypos = (area.top + area.bottom) / 2 return {x = math.floor(xpos), y = math.floor(ypos)} end local function format_number(n) -- credit http://richard.warburton.it local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end local octant_names = { [0] = "E", [1] = "SE", [2] = "S", [3] = "SW", [4] = "W", [5] = "NW", [6] = "N", [7] = "NE", } local function get_octant_name(vector) local radians = math.atan2(vector.y, vector.x) local octant = math.floor( 8 * radians / (2*math.pi) + 8.5 ) % 8 return octant_names[octant] end function resmon.finalize_site(player_index) local player = game.players[player_index] local player_data = global.player_data[player_index] local site = player_data.current_site site.finalizing = true site.finalizing_since = game.tick site.initial_amount = site.amount site.ore_per_minute = 0 site.remaining_permille = 1000 site.center = find_center(site.extents) --[[ don't rename a site we've expanded! (if the site name changes it'll create a new site instead of replacing the existing one) ]] if not site.is_site_expanding then site.name = string.format("%s %d", get_octant_name(site.center), util.distance({x=0, y=0}, site.center)) end resmon.count_deposits(site, site.added_at % settings.global["YARM-ticks-between-checks"].value) end function resmon.submit_site(player_index) local player = game.players[player_index] local player_data = global.player_data[player_index] local force_data = global.force_data[player.force.name] local site = player_data.current_site force_data.ore_sites[site.name] = site resmon.clear_current_site(player_index) if (site.is_site_expanding) then if(site.has_expanded) then local amount_added = site.amount - site.original_amount local sign = amount_added < 0 and '' or '+' -- format_number will handle the negative sign for us (if needed) player.print{"YARM-site-expanded", site.name, format_number(site.amount), site.ore_name, sign..format_number(amount_added)} end --[[ NB: deliberately not outputting anything in the case where the player cancelled (or timed out) a site expansion without expanding anything (to avoid console spam) ]] else player.print{"YARM-site-submitted", site.name, format_number(site.amount), site.ore_name} end -- clear site expanding state so we can re-expand the same site again (and get sensible numbers!) if(site.is_site_expanding) then site.is_site_expanding = nil site.has_expanded = nil site.original_amount = nil end resmon.update_force_members_ui(player) end function resmon.is_endless_resource(ent_name, proto) if resmon.endless_resources[ent_name] ~= nil then return resmon.endless_resources[ent_name] end if not proto then return false end if proto.infinite_resource then resmon.endless_resources[ent_name] = true else resmon.endless_resources[ent_name] = false end return resmon.endless_resources[ent_name] end function resmon.count_deposits(site, update_cycle) if site.iter_fn then resmon.tick_deposit_count(site) return end local site_update_cycle = site.added_at % settings.global["YARM-ticks-between-checks"].value if site_update_cycle ~= update_cycle then return end site.iter_fn, site.iter_state, site.iter_key = pairs(site.entity_table) site.update_amount = 0 end function resmon.tick_deposit_count(site) local key, pos key = site.iter_key for _ = 1, 100 do key, pos = site.iter_fn(site.iter_state, key) if key == nil then resmon.finish_deposit_count(site) return end local ent = site.surface.find_entity(site.ore_type, pos) if ent and ent.valid then site.update_amount = site.update_amount + ent.amount else site.entity_table[key] = nil -- It's permitted to delete from a table being iterated site.entity_count = site.entity_count - 1 end end site.iter_key = key end function resmon.finish_deposit_count(site) site.iter_key = nil site.iter_fn = nil site.iter_state = nil if site.last_ore_check then local delta_ticks = game.tick - site.last_ore_check local delta_ore = site.update_amount - site.amount site.ore_per_minute = math.floor(delta_ore * 3600 / delta_ticks) end site.amount = site.update_amount site.last_ore_check = game.tick site.remaining_permille = math.floor(site.amount * 1000 / site.initial_amount) local entity_prototype = game.entity_prototypes[site.ore_type] if resmon.is_endless_resource(site.ore_type, entity_prototype) then -- calculate remaining permille as: -- how much of the minimum amount does the site have in excess to the site minimum amount? local site_minimum = site.entity_count * site.minimum_resource_amount site.remaining_permille = math.floor(site.amount * 1000 / site_minimum) - 1000 + (settings.global["YARM-endless-resource-base"].value * 10) end script.raise_event(on_site_updated, { force_name = site.force.name, site_name = site.name, amount = site.amount, ore_per_minute = site.ore_per_minute, remaining_permille = site.remaining_permille, ore_type = site.ore_type, }) end local function site_comparator(left, right) if left.remaining_permille ~= right.remaining_permille then return left.remaining_permille < right.remaining_permille elseif left.added_at ~= right.added_at then return left.added_at < right.added_at else return left.name < right.name end end local function ascending_by_ratio(sites) local ordered_sites = {} for _, site in pairs(sites) do table.insert(ordered_sites, site) end table.sort(ordered_sites, site_comparator) local i = 0 local n = #ordered_sites return function() i = i + 1 if i <= n then return ordered_sites[i] end end end function resmon.update_ui(player) local player_data = global.player_data[player.index] local force_data = global.force_data[player.force.name] local root = player.gui.left.YARM_root if not root then root = player.gui.left.add{type="frame", name="YARM_root", direction="horizontal", style="YARM_outer_frame_no_border"} local buttons = root.add{type="flow", name="buttons", direction="vertical", style="YARM_buttons_v"} buttons.add{type="button", name="YARM_expando", style="YARM_expando_short"} end if root.sites and root.sites.valid then root.sites.destroy() end local sites_gui = root.add{type="table", column_count=7, name="sites", style="YARM_site_table"} if force_data and force_data.ore_sites then for site in ascending_by_ratio(force_data.ore_sites) do if not player_data.expandoed and (site.remaining_permille / 10) > game.players[player.index].mod_settings["YARM-warn-percent"].value then break end if site.deleting_since and site.deleting_since + 600 < game.tick then site.deleting_since = nil end local color = resmon.site_color(site, player) local el = nil el = sites_gui.add{type="label", name="YARM_label_site_"..site.name, caption=site.name} el.style.font_color = color el = sites_gui.add{type="label", name="YARM_label_percent_"..site.name, caption=string.format("%.1f%%", site.remaining_permille / 10)} el.style.font_color = color el = sites_gui.add{type="label", name="YARM_label_amount_"..site.name, caption=format_number(site.amount)} el.style.font_color = color el = sites_gui.add{type="label", name="YARM_label_ore_name_"..site.name, caption=site.ore_name} el.style.font_color = color el = sites_gui.add{type="label", name="YARM_label_ore_per_minute_"..site.name, caption={"YARM-ore-per-minute", site.ore_per_minute}} el.style.font_color = color el = sites_gui.add{type="label", name="YARM_label_etd_"..site.name, caption={"YARM-time-to-deplete", resmon.time_to_deplete(site)}} el.style.font_color = color local site_buttons = sites_gui.add{type="flow", name="YARM_site_buttons_"..site.name, direction="horizontal", style="YARM_buttons_h"} if site.deleting_since then site_buttons.add{type="button", name="YARM_delete_site_"..site.name, style="YARM_delete_site_confirm"} elseif player_data.viewing_site == site.name then site_buttons.add{type="button", name="YARM_goto_site_"..site.name, style="YARM_goto_site_cancel"} if player_data.renaming_site == site.name then site_buttons.add{type="button", name="YARM_rename_site_"..site.name, style="YARM_rename_site_cancel"} else site_buttons.add{type="button", name="YARM_rename_site_"..site.name, style="YARM_rename_site"} end else site_buttons.add{type="button", name="YARM_goto_site_"..site.name, style="YARM_goto_site"} site_buttons.add{type="button", name="YARM_delete_site_"..site.name, style="YARM_delete_site"} if site.is_site_expanding then site_buttons.add{type="button", name="YARM_expand_site_"..site.name, style="YARM_expand_site_cancel"} else site_buttons.add{type="button", name="YARM_expand_site_"..site.name, style="YARM_expand_site"} end end end end end function resmon.time_to_deplete(site) if site.ore_per_minute == 0 then return {"YARM-etd-never"} end local minutes = math.floor(site.amount / (-site.ore_per_minute)) local hours = math.floor(minutes / 60) if hours > 0 then return {"", {"YARM-etd-hour-fragment", hours}, " ", {"YARM-etd-minute-fragment", minutes % 60}} elseif minutes > 0 then return {"", {"YARM-etd-minute-fragment", minutes}} else return {"YARM-etd-under-1m"} end end function resmon.site_color(site, player) local warn_permille = 100 local color = { r=math.floor(warn_permille * 255 / site.remaining_permille), g=math.floor(site.remaining_permille * 255 / warn_permille), b=0 } if color.r > 255 then color.r = 255 elseif color.r < 2 then color.r = 2 end if color.g > 255 then color.g = 255 elseif color.g < 2 then color.g = 2 end return color end function resmon.on_click.YARM_rename_confirm(event) local player = game.players[event.player_index] local player_data = global.player_data[event.player_index] local force_data = global.force_data[player.force.name] local old_name = player_data.renaming_site local new_name = player.gui.center.YARM_site_rename.new_name.text if string.len(new_name) > MAX_SITE_NAME_LENGTH then player.print{'YARM-err-site-name-too-long', MAX_SITE_NAME_LENGTH} return end local site = force_data.ore_sites[old_name] force_data.ore_sites[old_name] = nil force_data.ore_sites[new_name] = site site.name = new_name player_data.viewing_site = new_name player_data.renaming_site = nil player.gui.center.YARM_site_rename.destroy() resmon.update_force_members_ui(player) end function resmon.on_click.YARM_rename_cancel(event) local player = game.players[event.player_index] local player_data = global.player_data[event.player_index] player_data.renaming_site = nil player.gui.center.YARM_site_rename.destroy() end function resmon.on_click.rename_site(event) local site_name = string.sub(event.element.name, 1 + string.len("YARM_rename_site_")) local player = game.players[event.player_index] local player_data = global.player_data[event.player_index] if player.gui.center.YARM_site_rename then resmon.on_click.YARM_rename_cancel(event) return end player_data.renaming_site = site_name local root = player.gui.center.add{type="frame", name="YARM_site_rename", caption={"YARM-site-rename-title"}, direction="horizontal"} root.add{type="textfield", name="new_name"}.text = site_name root.add{type="button", name="YARM_rename_confirm", caption={"YARM-site-rename-confirm"}} root.add{type="button", name="YARM_rename_cancel", caption={"YARM-site-rename-cancel"}} resmon.update_force_members_ui(player) end function resmon.on_click.remove_site(event) local site_name = string.sub(event.element.name, 1 + string.len("YARM_delete_site_")) local player = game.players[event.player_index] local force_data = global.force_data[player.force.name] local site = force_data.ore_sites[site_name] if site.deleting_since then force_data.ore_sites[site_name] = nil else site.deleting_since = event.tick end resmon.update_force_members_ui(player) end function resmon.on_click.goto_site(event) local site_name = string.sub(event.element.name, 1 + string.len("YARM_goto_site_")) local player = game.players[event.player_index] local player_data = global.player_data[event.player_index] local force_data = global.force_data[player.force.name] local site = force_data.ore_sites[site_name] -- Don't bodyswap too often, Factorio hates it when you do that. if player_data.last_bodyswap and player_data.last_bodyswap + 10 > event.tick then return end player_data.last_bodyswap = event.tick if player_data.viewing_site == site_name then -- returning to our home body if player_data.real_character == nil or not player_data.real_character.valid then player.print({"YARM-warn-no-return-possible"}) return end player.character = player_data.real_character player_data.remote_viewer.destroy() player_data.real_character = nil player_data.remote_viewer = nil player_data.viewing_site = nil else -- stepping out to a remote viewer: first, be sure you remember your old body if not player_data.real_character or not player_data.real_character.valid then --[[ Abort if the "real" character is missing (e.g., god mode) or isn't a player! NB: this might happen if you use something like The Fat Controller or Command Control and you do NOT want to get stuck not being able to return from those ]] if not player.character or player.character.name ~= "player" then player.print({"YARM-warn-not-in-real-body"}) return elseif player.vehicle then player.print({"YARM-warn-in-vehicle"}) return end player_data.real_character = player.character end player_data.viewing_site = site_name -- make us a viewer and put us in it local viewer = player.surface.create_entity{name="yarm-remote-viewer", position=site.center, force=player.force} viewer.destructible = false player.character = viewer -- don't leave an old one behind if player_data.remote_viewer and player_data.remote_viewer.valid then player_data.remote_viewer.destroy() end player_data.remote_viewer = viewer end resmon.update_force_members_ui(player) end -- one button handler for both the expand_site and expand_site_cancel buttons function resmon.on_click.expand_site(event) local site_name = string.sub(event.element.name, 1 + string.len("YARM_expand_site_")) local player = game.players[event.player_index] local player_data = global.player_data[event.player_index] local force_data = global.force_data[player.force.name] local site = force_data.ore_sites[site_name] local are_we_cancelling_expand = site.is_site_expanding --[[ we want to submit the site if we're cancelling the expansion (mostly because submitting the site cleans up the expansion-related variables on the site) or if we were adding a new site and decide to expand an existing one --]] if are_we_cancelling_expand or player_data.current_site then resmon.submit_site(event.player_index) end --[[ this is to handle cancelling an expansion (by clicking the red button) - submitting the site is all we need to do in this case ]] if are_we_cancelling_expand then resmon.update_force_members_ui(player) return end resmon.pull_YARM_item_to_cursor_if_possible(event.player_index) if player.cursor_stack.valid_for_read and player.cursor_stack.name == "resource-monitor" then site.is_site_expanding = true player_data.current_site = site resmon.update_force_members_ui(player) resmon.start_recreate_overlay_existing_site(event.player_index) end end function resmon.pull_YARM_item_to_cursor_if_possible(player_index) local player = game.players[player_index] if player.cursor_stack.valid_for_read and player.cursor_stack.name == "resource-monitor" then -- happy days! return elseif player.cursor_stack.valid_for_read then -- they've already got something else on their cursor player.print{"YARM-warn-please-empty-cursor"} return elseif player.get_item_count("resource-monitor") == 0 then player.print{"YARM-warn-no-YARM-item"} return end player.remove_item({name="resource-monitor", count=1}) player.cursor_stack.set_stack({name="resource-monitor", count=1}) end function resmon.start_recreate_overlay_existing_site(player_index) local site = global.player_data[player_index].current_site site.is_overlay_being_created = true -- forcible cleanup in case we got interrupted during a previous background overlay attempt site.entities_to_be_overlaid = {} site.entities_to_be_overlaid_count = 0 site.next_to_overlay = {} site.next_to_overlay_count = 0 for key,pos in pairs(site.entity_table) do local ent = site.surface.find_entity(site.ore_type, pos) if ent and ent.valid then site.entities_to_be_overlaid[key] = pos site.entities_to_be_overlaid_count = site.entities_to_be_overlaid_count + 1 end end end function resmon.process_overlay_for_existing_site(player_index) local player_data = global.player_data[player_index] local site = player_data.current_site if site.next_to_overlay_count == 0 then if site.entities_to_be_overlaid_count == 0 then resmon.end_overlay_creation_for_existing_site(player_index) return else local ent_key, ent_pos = next(site.entities_to_be_overlaid) site.next_to_overlay[ent_key] = ent_pos site.next_to_overlay_count = site.next_to_overlay_count + 1 end end local to_scan = math.min(30, site.next_to_overlay_count) for i = 1, to_scan do local ent_key, ent_pos = next(site.next_to_overlay) local entity = site.surface.find_entity(site.ore_type, ent_pos) local entity_position = entity.position local surface = entity.surface local key = position_to_string(entity_position) -- put marker down resmon.put_marker_at(surface, entity_position, player_data) -- remove it from our to-do lists site.entities_to_be_overlaid[key] = nil site.entities_to_be_overlaid_count = site.entities_to_be_overlaid_count - 1 site.next_to_overlay[key] = nil site.next_to_overlay_count = site.next_to_overlay_count - 1 -- Look in every direction around this entity... for _, dir in pairs(defines.direction) do -- ...and if there's a resource that's not already overlaid, add it local found = find_resource_at(surface, shift_position(entity_position, dir)) if found and found.name == site.ore_type then local offsetkey = position_to_string(found.position) if site.entities_to_be_overlaid[offsetkey] ~= nil and site.next_to_overlay[offsetkey] == nil then site.next_to_overlay[offsetkey] = found.position site.next_to_overlay_count = site.next_to_overlay_count + 1 end end end end end function resmon.end_overlay_creation_for_existing_site(player_index) local site = global.player_data[player_index].current_site site.is_overlay_being_created = false site.finalizing = true site.finalizing_since = game.tick end function resmon.update_force_members_ui(player) for _, p in pairs(player.force.players) do resmon.update_ui(p) end end function resmon.on_gui_click(event) if resmon.on_click[event.element.name] then resmon.on_click[event.element.name](event) elseif string.starts_with(event.element.name, "YARM_delete_site_") then resmon.on_click.remove_site(event) elseif string.starts_with(event.element.name, "YARM_rename_site_") then resmon.on_click.rename_site(event) elseif string.starts_with(event.element.name, "YARM_goto_site_") then resmon.on_click.goto_site(event) elseif string.starts_with(event.element.name, "YARM_expand_site_") then resmon.on_click.expand_site(event) end end function resmon.on_click.YARM_expando(event) local player = game.players[event.player_index] local player_data = global.player_data[event.player_index] player_data.expandoed = not player_data.expandoed if player_data.expandoed then player.gui.left.YARM_root.buttons.YARM_expando.style = "YARM_expando_long" else player.gui.left.YARM_root.buttons.YARM_expando.style = "YARM_expando_short" end resmon.update_ui(player) end function resmon.update_players(event) for index, player in pairs(game.players) do local player_data = global.player_data[index] if not player_data then resmon.init_player(index) elseif not player.connected and player_data.current_site then resmon.clear_current_site(index) end if player_data.current_site then local site = player_data.current_site if #site.next_to_scan > 0 then resmon.scan_current_site(index) elseif not site.finalizing then resmon.finalize_site(index) elseif site.finalizing_since + 600 == event.tick then resmon.submit_site(index) end if site.is_overlay_being_created then resmon.process_overlay_for_existing_site(index) end end if event.tick % player_data.gui_update_ticks == 15 + index then resmon.update_ui(player) end end end function resmon.update_forces(event) local update_cycle = event.tick % settings.global["YARM-ticks-between-checks"].value for _, force in pairs(game.forces) do local force_data = global.force_data[force.name] if not force_data then resmon.init_force(force) elseif force_data and force_data.ore_sites then for _, site in pairs(force_data.ore_sites) do resmon.count_deposits(site, update_cycle) end end end end function resmon.on_tick(event) resmon.update_players(event) resmon.update_forces(event) end
--- === hs.doc.hsdocs === --- --- Manage the internal documentation web server. --- --- This module provides functions for managing the Hammerspoon built-in documentation web server. Currently, this is the same documentation available in the Dash docset for Hammerspoon, but does not require third party software for viewing. --- --- Future enhancements to this module under consideration include: --- * Support for third-party modules to add to the documentation set at run-time --- * Markdown/HTML based tutorials and How-To examples --- * Documentation for the LuaSkin Objective-C Framework --- * Lua Reference documentation --- --- The intent of this sub-module is to provide as close a rendering of the same documentation available at the Hammerspoon Github site and Dash documentation as possible in a manner suitable for run-time modification so module developers can test out documentation additions without requiring a complete recompilation of the Hammerspoon source. As always, the most current and official documentation can be found at http://www.hammerspoon.org and in the official Hammerspoon Dash docset. local module = {} -- private variables and methods ----------------------------------------- local USERDATA_TAG = "hs.doc.hsdocs" local settings = require"hs.settings" local image = require"hs.image" local webview = require"hs.webview" local doc = require"hs.doc" local watchable = require"hs.watchable" local timer = require"hs.timer" local host = require"hs.host" local hotkey = require"hs.hotkey" local documentRoot = package.searchpath("hs.doc.hsdocs", package.path):match("^(/.*/).*%.lua$") local osVersion = host.operatingSystemVersion() local toolbarImages = { prevArrow = image.imageFromASCII(".......\n" .. "..3....\n" .. ".......\n" .. "41....1\n" .. ".......\n" .. "..5....\n" .. ".......", { { strokeColor = { white = .5 } }, { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 }, shouldClose = false }, {}, }), nextArrow = image.imageFromASCII(".......\n" .. "....3..\n" .. ".......\n" .. "1....14\n" .. ".......\n" .. "....5..\n" .. ".......", { { strokeColor = { white = .5 } }, { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 }, shouldClose = false }, {} }), lightMode = image.imageFromASCII("1.........2\n" .. "...........\n" .. "...........\n" .. ".....b.....\n" .. "...........\n" .. "...........\n" .. "....e.f....\n" .. "...........\n" .. "...a...c...\n" .. "...........\n" .. "4.........3", { { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 } }, { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 }, shouldClose = false }, { strokeColor = { white = .5 } }, {} }), darkMode = image.imageFromASCII("1.........2\n" .. "...........\n" .. "...........\n" .. ".....b.....\n" .. "...........\n" .. "...........\n" .. "....e.f....\n" .. "...........\n" .. "...a...c...\n" .. "...........\n" .. "4.........3", { { strokeColor = { white = .75 }, fillColor = { alpha = 0.5 } }, { strokeColor = { white = .75 }, fillColor = { alpha = 0.0 }, shouldClose = false }, { strokeColor = { white = .75 } }, {} }), followMode = image.imageFromASCII("2.........3\n" .. "...........\n" .. ".....g.....\n" .. "...........\n" .. "1...f.h...4\n" .. "6...b.c...9\n" .. "...........\n" .. "...a...d...\n" .. "...........\n" .. "7.........8", { { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 }, shouldClose = false }, { strokeColor = { white = .75 }, fillColor = { alpha = 0.5 }, shouldClose = false }, { strokeColor = { white = .75 }, fillColor = { alpha = 0.0 }, shouldClose = false }, { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 }, shouldClose = true }, {} }), noTrackWindow = image.imageFromASCII("1.........2\n" .. "4.........3\n" .. "6.........7\n" .. "...........\n" .. "...........\n" .. "...........\n" .. "...........\n" .. "...........\n" .. "...........\n" .. "9.........8", { { strokeColor = { white = .5 }, fillColor = { alpha = 0.25 }, shouldClose = false }, { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 }}, {} }), trackWindow = image.imageFromASCII("1.......2..\n" .. "4.......3..\n" .. "6.......7.c\n" .. "...........\n" .. "...........\n" .. "...........\n" .. "...........\n" .. "9.......8..\n" .. "...........\n" .. "..a.......b", { { strokeColor = { white = .5 }, fillColor = { alpha = 0.25 }, shouldClose = false }, { strokeColor = { white = .5 }, fillColor = { alpha = 0.0 }}, { strokeColor = { white = .6 }, fillColor = { alpha = 0.0 }, shouldClose = false}, {} }), index = image.imageFromName("statusicon"), help = image.imageFromName(image.systemImageNames.RevealFreestandingTemplate), } local frameTracker = function(cmd, wv, opt) if cmd == "frameChange" and settings.get("_documentationServer.trackBrowserFrameChanges") then settings.set("_documentationServer.browserFrame", opt) elseif cmd == "focusChange" then if module._modalKeys then if opt then module._modalKeys:enter() else module._modalKeys:exit() end end elseif cmd == "close" then if module._modalKeys then module._modalKeys:exit() end end end local updateToolbarIcons = function(toolbar, browser) local historyList = browser:historyList() if historyList.current > 1 then toolbar:modifyItem{ id = "prev", enable = true } else toolbar:modifyItem{ id = "prev", enable = false } end if historyList.current < #historyList then toolbar:modifyItem{ id = "next", enable = true } else toolbar:modifyItem{ id = "next", enable = false } end local mode = module.browserDarkMode() if type(mode) == "nil" then toolbar:modifyItem{ id = "mode", image = toolbarImages.followMode } elseif type(mode) == "boolean" then toolbar:modifyItem{ id = "mode", image = mode and toolbarImages.darkMode or toolbarImages.lightMode } elseif type(mode) == "number" then toolbar:modifyItem{ id = "mode", image = (mode > 50) and toolbarImages.darkMode or toolbarImages.lightMode } end toolbar:modifyItem{ id = "track", image = module.trackBrowserFrame() and toolbarImages.trackWindow or toolbarImages.noTrackWindow } end local makeModuleListForMenu = function() local searchList = {} for i,v in ipairs(doc._jsonForModules) do table.insert(searchList, v.name) end for i,v in ipairs(doc._jsonForSpoons) do table.insert(searchList, "spoon." .. v.name) end table.sort(searchList, function(a, b) return a:lower() < b:lower() end) return searchList end local makeToolbar = function(browser) local toolbar = webview.toolbar.new("hsBrowserToolbar", { { id = "index", label = "Index", image = toolbarImages.index, tooltip = "Display documentation index", }, { id = "navigation", label = "Navigation", groupMembers = { "prev", "next" }, }, { id = "prev", tooltip = "Display previously viewed page in history", image = toolbarImages.prevArrow, enable = false, allowedAlone = false, }, { id = "next", tooltip = "Display next viewed page in history", image = toolbarImages.nextArrow, enable = false, allowedAlone = false, }, { id = "search", tooltip = "Search for a Hammerspoon function or method by name", searchfield = true, searchWidth = 250, searchPredefinedSearches = makeModuleListForMenu(), searchPredefinedMenuTitle = false, searchReleaseFocusOnCallback = true, fn = function(t, w, i, text) if text ~= "" then w:url("http://localhost:" .. tostring(module._server:port()) .. "/module.lp/" .. text) end end, }, { id = "NSToolbarFlexibleSpaceItem" }, { id = "mode", tooltip = "Toggle display mode between System/Dark/Light", image = toolbarImages.followMode, }, { id = "track", tooltip = "Toggle window frame tracking", image = toolbarImages.noTrackWindow, }, { id = "NSToolbarSpaceItem" }, { id = "help", tooltip = "Display Browser Help", image = toolbarImages.help, fn = function(t, w, i) w:evaluateJavaScript("toggleHelp()") end, } }):canCustomize(true) :displayMode("icon") :sizeMode("small") :autosaves(true) :setCallback(function(t, w, i) if i == "prev" then w:goBack() elseif i == "next" then w:goForward() elseif i == "index" then w:url("http://localhost:" .. tostring(module._server:port()) .. "/") elseif i == "mode" then local mode = module.browserDarkMode() if type(mode) == "nil" then module.browserDarkMode(true) elseif type(mode) == "boolean" then if mode then module.browserDarkMode(false) else module.browserDarkMode(nil) end elseif type(mode) == "number" then if mode < 50 then module.browserDarkMode(false) else module.browserDarkMode(true) end else -- shouldn't be possible, but... module.browserDarkMode(nil) end -- w:reload() local current = module.browserDarkMode() if type(current) == "nil" then current = (host.interfaceStyle() == "Dark") end w:evaluateJavaScript("setInvertLevel(" .. (current and "100" or "0") .. ")") module._browser:darkMode(current) elseif i == "track" then local track = module.trackBrowserFrame() if track then module.browserFrame(nil) end module.trackBrowserFrame(not track) else hs.luaSkinLog.wf("%s browser callback received %s and has no handler", USERDATA_TAG, i) end updateToolbarIcons(t, w) end) updateToolbarIcons(toolbar, browser) return toolbar end local defineHotkeys = function() local hk = hotkey.modal.new() hk:bind({"cmd"}, "f", nil, function() module._browser:evaluateJavaScript("toggleFind()") end) hk:bind({"cmd"}, "l", nil, function() if module._browser:attachedToolbar() then module._browser:attachedToolbar():selectSearchField() end end) hk:bind({"cmd"}, "r", nil, function() module._browser:evaluateJavaScript("window.location.reload(true)") end) hk:bind({}, "escape", nil, function() module._browser:evaluateJavaScript([[ document.getElementById("helpStuff").style.display == "block" ]], function(ans1) if ans1 then module._browser:evaluateJavaScript("toggleHelp()") end module._browser:evaluateJavaScript([[ document.getElementById("searcher").style.display == "block" ]], function(ans2) if ans2 then module._browser:evaluateJavaScript("toggleFind()") end if not ans1 and not ans2 then module._browser:hide() hk:exit() end end) end) end) hk:bind({"cmd"}, "g", nil, function() module._browser:evaluateJavaScript([[ document.getElementById("searcher").style.display == "block" ]], function(ans) if ans then module._browser:evaluateJavaScript("searchForText(0)") end end) end) hk:bind({"cmd", "shift"}, "g", nil, function() module._browser:evaluateJavaScript([[ document.getElementById("searcher").style.display == "block" ]], function(ans) if ans then module._browser:evaluateJavaScript("searchForText(1)") end end) end) -- because these would interfere with the search field, we let Javascript handle these, see search.lp -- hk:bind({}, "return", nil, function() end) -- hk:bind({"shift"}, "return", nil, function() end) return hk end local makeBrowser = function() local screen = require"hs.screen" local mainScreenFrame = screen:primaryScreen():frame() local browserFrame = settings.get("_documentationServer.browserFrame") if not (browserFrame and browserFrame.x and browserFrame.y and browserFrame.h and browserFrame.w) then browserFrame = { x = mainScreenFrame.x + 10, y = mainScreenFrame.y + 32, h = mainScreenFrame.h - 42, w = 800 } end local options = { developerExtrasEnabled = true, } if (osVersion["major"] == 10 and osVersion["minor"] > 10) then options.privateBrowsing = true options.applicationName = "Hammerspoon/" .. hs.processInfo.version end -- not used anymore, but just in case, I'm leaving the skeleton here... -- local ucc = webview.usercontent.new("hsdocs"):setCallback(function(obj) ---- if obj.body == "message" then ---- else -- print("~~ hsdocs unexpected ucc callback: ", require("hs.inspect")(obj)) ---- end -- end) -- local browser = webview.new(browserFrame, options, ucc):windowStyle(1+2+4+8) local browser = webview.new(browserFrame, options):windowStyle(1+2+4+8) :allowTextEntry(true) :allowGestures(true) :windowCallback(frameTracker) :navigationCallback(function(a, w, n, e) if e then hs.luaSkinLog.ef("%s browser navigation for %s error:%s", USERDATA_TAG, a, e.localizedDescription) return true end if a == "didFinishNavigation" then updateToolbarIcons(w:attachedToolbar(), w) end end) module._modalKeys = defineHotkeys() browser:attachedToolbar(makeToolbar(browser)) return browser end -- Public interface ------------------------------------------------------ module._moduleListChanges = watchable.watch("hs.doc", "changeCount", function(w, p, k, o, n) if module._browser then module._browser:attachedToolbar():modifyItem{ id = "search", searchPredefinedSearches = makeModuleListForMenu(), } end end) --- hs.doc.hsdocs.interface([interface]) -> currentValue --- Function --- Get or set the network interface that the Hammerspoon documentation web server will be served on --- --- Parameters: --- * interface - an optional string, or nil, specifying the network interface the Hammerspoon documentation web server will be served on. An explicit nil specifies that the web server should listen on all active interfaces for the machine. Defaults to "localhost". --- --- Returns: --- * the current, possibly new, value --- --- Notes: --- * See `hs.httpserver.setInterface` for a description of valid values that can be specified as the `interface` argument to this function. --- * A change to the interface can only occur when the documentation server is not running. If the server is currently active when you call this function with an argument, the server will be temporarily stopped and then restarted after the interface has been changed. --- --- * Changes made with this function are saved with `hs.settings` with the label "_documentationServer.interface" and will persist through a reload or restart of Hammerspoon. module.interface = function(...) local args = table.pack(...) if args.n > 0 then local newValue, needRestart = args[1], false if newValue == nil or type(newValue) == "string" then if module._server then needRestart = true module.stop() end if newValue == nil then settings.set("_documentationServer.interface", true) else settings.set("_documentationServer.interface", newValue) end if needRestart then module.start() end else error("interface must be nil or a string", 2) end end local current = settings.get("_documentationServer.interface") or "localhost" if current == true then return nil -- since nil has no meaning to settings, we use this boolean value as a placeholder else return current end end --- hs.doc.hsdocs.port([value]) -> currentValue --- Function --- Get or set the Hammerspoon documentation server HTTP port. --- --- Parameters: --- * value - an optional number specifying the port for the Hammerspoon documentation web server --- --- Returns: --- * the current, possibly new, value --- --- Notes: --- * The default port number is 12345. --- --- * Changes made with this function are saved with `hs.settings` with the label "_documentationServer.serverPort" and will persist through a reload or restart of Hammerspoon. module.port = function(...) local args = table.pack(...) local value = args[1] if args.n == 1 and (type(value) == "number" or type(value) == "nil") then if module._server then module._server:port(value or 12345) end settings.set("_documentationServer.serverPort", value) end return settings.get("_documentationServer.serverPort") or 12345 end --- hs.doc.hsdocs.start() -> `hs.doc.hsdocs` --- Function --- Start the Hammerspoon internal documentation web server. --- --- Parameters: --- * None --- --- Returns: --- * the table representing the `hs.doc.hsdocs` module --- --- Notes: --- * This function is automatically called, if necessary, when [hs.doc.hsdocs.help](#help) is invoked. --- * The documentation web server can be viewed from a web browser by visiting "http://localhost:port" where `port` is the port the server is running on, 12345 by default -- see [hs.doc.hsdocs.port](#port). module.start = function() if module._server then error("documentation server already running") else module._server = require"hs.httpserver.hsminweb".new(documentRoot) module._server:port(module.port()) :name("Hammerspoon Documentation") :bonjour(true) :luaTemplateExtension("lp") :interface(module.interface()) :directoryIndex{ "index.html", "index.lp", }:start() module._server._logBadTranslations = true module._server._logPageErrorTranslations = true module._server._allowRenderTranslations = true end return module end --- hs.doc.hsdocs.stop() -> `hs.doc.hsdocs` --- Function --- Stop the Hammerspoon internal documentation web server. --- --- Parameters: --- * None --- --- Returns: --- * the table representing the `hs.doc.hsdocs` module module.stop = function() if not module._server then error("documentation server not running") else module._server:stop() module._server = nil end return module end --- hs.doc.hsdocs.help([identifier]) -> nil --- Function --- Display the documentation for the specified Hammerspoon function, or the Table of Contents for the Hammerspoon documentation in a built-in mini browser. --- --- Parameters: --- * an optional string specifying a Hammerspoon module, function, or method to display documentation for. If you leave out this parameter, the table of contents for the Hammerspoon built-in documentation is displayed instead. --- --- Returns: --- * None module.help = function(target) if not module._server then module.start() end local targetURL = "http://localhost:" .. tostring(module._server:port()) .. "/" if type(target) == "string" then targetURL = targetURL .. "module.lp/" .. target elseif type(target) == "table" and target.__path then targetURL = targetURL .. "module.lp/" .. target.__path end if webview and not settings.get("_documentationServer.forceExternalBrowser") then module._browser = module._browser or makeBrowser() module._browser:url(targetURL):show() else local targetApp = settings.get("_documentationServer.forceExternalBrowser") local urlevent = require"hs.urlevent" if type(targetApp) == "boolean" then targetApp = urlevent.getDefaultHandler("http") end if not urlevent.openURLWithBundle(targetURL, targetApp) then hs.luaSkinLog.wf("%s.help - hs.urlevent.openURLWithBundle failed to launch for bundle ID %s", USERDATA_TAG, targetApp) os.execute("/usr/bin/open " .. targetURL) end end end --- hs.doc.hsdocs.browserFrame([frameTable]) -> currentValue --- Function --- Get or set the currently saved initial frame location for the documentation browser. --- --- Parameters: --- * frameTable - a frame table containing x, y, h, and w values specifying the browser's initial position when Hammerspoon starts. --- --- Returns: --- * the current, possibly new, value --- --- Notes: --- * If [hs.doc.hsdocs.trackBrowserFrame](#trackBrowserFrame) is false or nil (the default), then you can use this function to specify the initial position of the documentation browser. --- * If [hs.doc.hsdocs.trackBrowserFrame](#trackBrowserFrame) is true, then this any value set with this function will be overwritten whenever the browser window is moved or resized. --- --- * Changes made with this function are saved with `hs.settings` with the label "_documentationServer.browserFrame" and will persist through a reload or restart of Hammerspoon. module.browserFrame = function(...) local args = table.pack(...) local value = args[1] if args.n == 1 and (type(value) == "table" or type(value) == "nil") then if value and value.x and value.y and value.h and value.w then settings.set("_documentationServer.browserFrame", value) end end return settings.get("_documentationServer.browserFrame") end --- hs.doc.hsdocs.trackBrowserFrame([value]) -> currentValue --- Function --- Get or set whether or not changes in the documentation browsers location and size persist through launches of Hammerspoon. --- --- Parameters: --- * value - an optional boolean specifying whether or not the browsers location should be saved across launches of Hammerspoon. --- --- Returns: --- * the current, possibly new, value --- --- Notes: --- * Changes made with this function are saved with `hs.settings` with the label "_documentationServer.trackBrowserFrameChanges" and will persist through a reload or restart of Hammerspoon. module.trackBrowserFrame = function(...) local args = table.pack(...) if args.n == 1 and (type(args[1]) == "boolean" or type(args[1]) == "nil") then settings.set("_documentationServer.trackBrowserFrameChanges", args[1]) end return settings.get("_documentationServer.trackBrowserFrameChanges") end --- hs.doc.hsdocs.moduleEntitiesInSidebar([value]) -> currentValue --- Function --- Get or set whether or not a module's entity list is displayed as a column on the left of the rendered page. --- --- Parameters: --- * value - an optional boolean specifying whether or not a module's entity list is displayed inline in the documentation (false) or in a sidebar on the left (true). --- --- Returns: --- * the current, possibly new, value --- --- Notes: --- * This is experimental and is disabled by default. It was inspired by a Userscript written by krasnovpro. The original can be found at https://openuserjs.org/scripts/krasnovpro/hammerspoon.org_Documentation/source. --- --- * Changes made with this function are saved with `hs.settings` with the label "_documentationServer.entitiesInSidebar" and will persist through a reload or restart of Hammerspoon. module.moduleEntitiesInSidebar = function(...) local args = table.pack(...) if args.n == 1 and (type(args[1]) == "boolean" or type(args[1]) == "nil") then settings.set("_documentationServer.entitiesInSidebar", args[1]) end return settings.get("_documentationServer.entitiesInSidebar") end --- hs.doc.hsdocs.browserDarkMode([value]) -> currentValue --- Function --- Get or set whether or not the Hammerspoon browser renders output in Dark mode. --- --- Parameters: --- * value - an optional boolean, number, or nil specifying whether or not the documentation browser renders in Dark mode. --- * if value is `true`, then the HTML output will always be inverted --- * if value is `false`, then the HTML output will never be inverted --- * if value is `nil`, then the output will be inverted only when the OS X theme is set to Dark mode --- * if the value is a number between 0 and 100, the number specifies the inversion ratio, where 0 means no inversion, 100 means full inversion, and 50 is completely unreadable because the foreground and background are equally adjusted. --- --- Returns: --- * the current, possibly new, value --- --- Notes: --- * Inversion is applied through the use of CSS filtering, so while numeric values other than 0 (false) and 100 (true) are allowed, the result is generally not what is desired. --- --- * Changes made with this function are saved with `hs.settings` with the label "_documentationServer.invertDocs" and will persist through a reload or restart of Hammerspoon. module.browserDarkMode = function(...) local args = table.pack(...) local value = args[1] if args.n == 1 and ({ ["number"] = 1, ["boolean"] = 1, ["nil"] = 1 })[type(value)] then if type(value) == "number" then value = (value < 0 and 0) or (value > 100 and 100) or value end settings.set("_documentationServer.invertDocs", value) end return settings.get("_documentationServer.invertDocs") end --- hs.doc.hsdocs.forceExternalBrowser([value]) -> currentValue --- Function --- Get or set whether or not [hs.doc.hsdocs.help](#help) uses an external browser. --- --- Parameters: --- * value - an optional boolean or string, default false, specifying whether or not documentation requests will be displayed in an external browser or the internal one handled by `hs.webview`. --- --- Returns: --- * the current, possibly new, value --- --- Notes: --- * If this value is set to true, help requests invoked by [hs.doc.hsdocs.help](#help) will be invoked by your system's default handler for the `http` scheme. --- * If this value is set to a string, the string specifies the bundle ID of an application which will be used to handle the url request for the documentation. The string should match one of the items returned by `hs.urlevent.getAllHandlersForScheme("http")`. --- --- * This behavior is triggered automatically, regardless of this setting, if you are running with a version of OS X prior to 10.10, since `hs.webview` requires OS X 10.10 or later. --- --- * Changes made with this function are saved with `hs.settings` with the label "_documentationServer.forceExternalBrowser" and will persist through a reload or restart of Hammerspoon. module.forceExternalBrowser = function(...) local args = table.pack(...) local value = args[1] if args.n == 1 and (type(value) == "string" or type(value) == "boolean" or type(value) == "nil") then if type(value) == "string" then local validBundleIDs = require"hs.urlevent".getAllHandlersForScheme("http") local found = false for i, v in ipairs(validBundleIDs) do if v == value then found = true break end end if not found then error([[the string must match one of those returned by hs.urlevent.getAllHandlersForScheme("http")]]) end end settings.set("_documentationServer.forceExternalBrowser", args[1]) end return settings.get("_documentationServer.forceExternalBrowser") end -- Return Module Object -------------------------------------------------- return module
---- -- Tests for the xlsxwriter.lua worksheet class. -- -- Copyright 2014-2015, John McNamara, [email protected] -- require "Test.More" require "Test.LongString" plan(20) ---- -- Tests setup. -- local expected local got local caption local Worksheet = require "xlsxwriter.worksheet" local worksheet local SST = require "xlsxwriter.sharedstrings" -- Remove extra whitespace in the formatted XML strings. function _clean_xml_string(s) return (string.gsub(s, ">%s+<", "><")) end ---- -- Test the _write_worksheet() method. -- caption = " \tWorksheet: Worksheet: _assemble_xml_file()" expected = _clean_xml_string([[ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <dimension ref="A1:D3"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="1" max="4" width="17.7109375" customWidth="1"/> </cols> <sheetData> <row r="1" spans="1:4"> <c r="A1" t="s"> <v>0</v> </c> </row> <row r="3" spans="1:4"> <c r="A3" t="s"> <v>1</v> </c> <c r="D3" t="s"> <v>2</v> </c> </row> </sheetData> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> </worksheet>]]) worksheet = Worksheet:new() worksheet:_set_filehandle(io.tmpfile()) worksheet.str_table = SST:new() max_row = 1048576 max_col = 16384 bound_error = -1 -- Test some out of bound values. got = worksheet:write(max_row, 0, 'Foo') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(0, max_col, 'Foo') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(max_row, max_col, 'Foo') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(max_row, 0, 123) is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(0, max_col, 123) is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(max_row, max_col, 123) is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(max_row, 0, nil, 'format') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(0, max_col, nil, 'format') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(max_row, max_col, nil, 'format') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(max_row, 0, '=A1') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(0, max_col, '=A1') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write(max_row, max_col, '=A1') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write_array_formula(0, 0, 0, max_col, '=A1') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write_array_formula(0, 0, max_row, 0, '=A1') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write_array_formula(0, max_col, 0, 0, '=A1') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write_array_formula(max_row, 0, 0, 0, '=A1') is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:write_array_formula(max_row, max_col, max_row, max_col, '=A1') is(got, bound_error, " \ttest write() bounds checks.") -- Column out of bounds. got = worksheet:set_column(6, max_col, 17) is(got, bound_error, " \ttest write() bounds checks.") got = worksheet:set_column(max_col, 6, 17) is(got, bound_error, " \ttest write() bounds checks.") -- Row out of bounds. worksheet:set_row(max_row, 30) -- Reverse man and min column numbers worksheet:set_column(0, 3, 17) -- Write some valid strings. worksheet:write(0, 0, 'Foo') worksheet:write(2, 0, 'Bar') worksheet:write(2, 3, 'Baz') worksheet:select() worksheet:_assemble_xml_file() got = _clean_xml_string(worksheet:_get_data()) is_string(got, expected, caption)
gamestats = {} function gamestats:enter(previous) self.previous = previous self.yModPerc = 100 self.screen = "stats" self.cursorX,self.cursorY=1,1 tween(0.2,self,{yModPerc=0}) output:sound('stoneslideshort',2) self.transY = 0 self.maxTransY = 0 self.sideTransY = 0 self.maxSideTransY = 0 self.achievementCursorY=1 local graveyard = load_graveyard() local wins = load_wins() local gravesayings = {"R.I.P","Here Lies","In Memorium","Always Remembered"} self.graveyard = {} self.wins = {} self.stats = {} --Sorting functions: local sortByDate = function(a,b) return (a.date and a.date or 0) > (b.date and b.date or 0) end local sortByMost = function(a,b) return (a.sortBy and a.sortBy or 0) > (b.sortBy and b.sortBy or 0) end local sortByLeast = function(a,b) return (a.sortBy and a.sortBy or 0) < (b.sortBy and b.sortBy or 0) end --Deal with Stats: if count(achievementList) > 0 then self.stats[1] = {id="achievements",header="Achievements",label = "Achievements",stats={},expand=true} end local abilityStats = {} if totalstats.ability_used then for abil,uses in pairs(totalstats.ability_used) do local id = #abilityStats+1 abilityStats[id] = {} abilityStats[id].ability = abil abilityStats[id].uses = uses abilityStats[id].sortBy = uses end table.sort(abilityStats,sortByMost) local whichAbil = abilityStats[1] and (abilityStats[1].ability == "Possession" or abilityStats[1].ability == "Repair Body") and (abilityStats[2] and (abilityStats[2].ability == "Possession" or abilityStats[2].ability == "Repair Body") and 3 or 2) or 1 end self.stats[#self.stats+1] = {id="abilities",header="Ability Usage",label = (abilityStats[whichAbil] and "Favorite Ability: " .. abilityStats[whichAbil].ability .. " (" .. abilityStats[whichAbil].uses .. " uses)" or "Favorite Abilities"),stats=abilityStats,expand=true} local killStats = {} if totalstats.creature_kills then for creat,kills in pairs(totalstats.creature_kills) do local id = #killStats+1 killStats[id] = {} killStats[id].creat = creat killStats[id].kills = kills killStats[id].sortBy = kills end table.sort(killStats,sortByMost) end self.stats[#self.stats+1] = {id="kills",header="Creature Kills",label=(killStats[1] and "Most Killed Creature: " .. ucfirst(possibleMonsters[killStats[1].creat].name) .. " (" .. killStats[1].kills .. " kills)" or "Kills"),stats=killStats,expand=true} local followerStats = {} if totalstats.thralls then for follower,thralls in pairs(totalstats.thralls) do local id = #followerStats+1 local deaths = (totalstats.creature_ally_deaths and totalstats.creature_ally_deaths[follower] or 0) local kills = (totalstats.allied_creature_kills and totalstats.allied_creature_kills[follower] or 0) local killsPer = round(kills/(thralls or 1)) followerStats[id] = {} followerStats[id].creat = follower followerStats[id].thralls = thralls followerStats[id].kills = kills followerStats[id].deaths = deaths followerStats[id].killsPer = killsPer followerStats[id].sortBy = killsPer end table.sort(followerStats,sortByMost) end self.stats[#self.stats+1] = {id="follower_kills",header="Kills by Followers",label=(followerStats[1] and "Most Effective Follower: " .. ucfirst(possibleMonsters[followerStats[1].creat].name) .. " (" .. followerStats[1].kills .. " Average Kills per Follower)" or "Kills by Followers"),stats=followerStats,expand=true} self.stats[#self.stats+1] = {id="games",label="Total Games Started: " .. (totalstats.games or 0)} self.stats[#self.stats+1] = {id="wins",label="Games Won: " .. (totalstats.wins or 0)} self.stats[#self.stats+1] = {id="losses",label="Games Lost: " .. (totalstats.losses or 0)} self.stats[#self.stats+1] = {id="turns",label="Total Turns Played: " .. (totalstats.turns or 0)} self.stats[#self.stats+1] = {id="turnspergame",label="Average Turns/Game: " .. round((totalstats.turns or 0)/(totalstats.games or 1))} --Deal with Wins: for _, win in pairs(wins) do self.wins[#self.wins+1] = win if win.stats and win.stats.ability_used then win.stats.favoriteAbilityTurns,win.stats.favoriteAbility = get_largest(win.stats.ability_used) end end table.sort(self.wins,sortByDate) --Deal with Deaths: for i,grave in pairs(graveyard) do grave.saying = gravesayings[random(#gravesayings)] self.graveyard[#self.graveyard+1] = grave if grave.stats and grave.stats.ability_used then grave.stats.favoriteAbilityTurns,grave.stats.favoriteAbility = get_largest(grave.stats.ability_used) end end table.sort(self.graveyard,sortByDate) --Last two stats, that depend on wins and losses local totalWinTurns = 0 for _,win in pairs(self.wins) do totalWinTurns = totalWinTurns+(win.stats.turns or 0) end self.stats[#self.stats+1] = {id="turnsperwin",label="Average Turns/Win: " .. (totalstats.wins and round(totalWinTurns/totalstats.wins) or "N/A"),stats={}} local totalLossTurns = 0 for _,grave in pairs(self.graveyard) do totalLossTurns = totalLossTurns+(grave.stats and grave.stats.turns or 0) end self.stats[#self.stats+1] = {id="turnsperloss",label="Average Turns/Loss: " .. round(totalLossTurns/(totalstats.losses or 1)),stats={}} end function gamestats:draw() self.previous:draw() local padding=prefs['noImages'] and 14 or 32 local fontSize = prefs['fontSize'] local uiScale = prefs['uiScale'] or 1 local width, height = math.floor(love.graphics:getWidth()/uiScale),math.floor(love.graphics:getHeight()/uiScale) local mouseX,mouseY = love.mouse.getPosition() mouseX,mouseY = math.floor(mouseX/uiScale),math.floor(mouseY/uiScale) love.graphics.push() love.graphics.scale(uiScale,uiScale) love.graphics.translate(0,height*(self.yModPerc/100)) --Draw top nav bar: output:draw_window(0,0,width-padding,64) self.closebutton = output:closebutton(math.floor(padding/2),math.floor(padding/2)) love.graphics.setFont(fonts.graveFontBig) local buttonWidth = fonts.graveFontBig:getWidth("Stats") self.statsbutton = output:button(padding,padding,buttonWidth,false,(self.cursorY == 1 and self.cursorX == 1 and "hover" or nil),"Stats",true) buttonWidth = fonts.graveFontBig:getWidth("Wins" .. (totalstats.wins and "(" .. totalstats.wins .. ")" or "")) self.winsbutton = output:button(math.floor((width-padding-buttonWidth)/2),padding,buttonWidth,false,(self.cursorY == 1 and self.cursorX == 2 and "hover" or nil),"Wins" .. (totalstats.wins and "(" .. totalstats.wins .. ")" or ""),true) buttonWidth = fonts.graveFontBig:getWidth("Losses" .. (totalstats.losses and "(" .. totalstats.losses .. ")" or "")) self.lossesbutton = output:button(width-padding-buttonWidth,padding,buttonWidth,false,(self.cursorY == 1 and self.cursorX == 3 and "hover" or nil),"Losses" .. (totalstats.losses and "(" .. totalstats.losses .. ")" or ""),true) if self.screen == "stats" then local w1end,w2start,w2end = math.floor(width/2),math.ceil(width/2)+padding,math.ceil(width/2)+math.floor(width/2)-padding local windowY = 64+padding local sidebarX = round(width/2)+padding local stopSelect = sidebarX-padding*2-(self.maxTransY < 0 and 32 or 0) output:draw_window(0,64+padding,sidebarX-padding,height-padding) output:draw_window(sidebarX,64+padding,width-padding,height-padding) love.graphics.setFont(fonts.graveFontBig) love.graphics.printf("Statistics",1,80+padding,sidebarX,"center") love.graphics.setFont(fonts.textFont) if self.maxTransY < 0 then local scrollAmt = self.transY / self.maxTransY self.scrollPositions = output:scrollbar(w1end-padding,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() local function stencilFunc() love.graphics.rectangle("fill",padding,windowY+padding*2,w1end,height-padding-(windowY+padding*2)) end love.graphics.stencil(stencilFunc,"replace",1) love.graphics.setStencilTest("greater",0) love.graphics.translate(0,self.transY) local printY = 80+padding*3 --Display the stat list: for id,stat in ipairs(self.stats) do local expand = false if stat.expand then expand = true end local _,tlines = fonts.textFont:getWrap(stat.label .. (expand and " > " or ""),stopSelect) if self.cursorY-1 == id then setColor(100,100,100,255) love.graphics.rectangle("fill",padding,printY,stopSelect,math.ceil(2+fontSize*#tlines*1.15)) setColor(255,255,255,255) elseif mouseX > padding and mouseX < sidebarX-padding and mouseY > printY and mouseY < math.ceil(printY+fontSize*#tlines*1.15) and stat.expand then setColor(50,50,50,255) love.graphics.rectangle("fill",padding,printY,stopSelect,math.ceil(2+fontSize*#tlines*1.15)) setColor(255,255,255,255) end love.graphics.printf(stat.label .. (expand and " > " or ""),padding,printY,stopSelect) stat.printY=printY printY = printY + math.ceil(fontSize*#tlines*1.25) stat.maxY=printY self.maxTransY = height-printY-fontSize end--end stat for love.graphics.pop() love.graphics.setStencilTest() --Display the selected stat: local stat = self.stats[self.cursorY-1] if stat and stat.expand then love.graphics.setFont(fonts.graveFontBig) love.graphics.printf(stat.header or "Stat?",sidebarX,80+padding,width-sidebarX,"center") love.graphics.setFont(fonts.textFont) local function stencilFunc() love.graphics.rectangle("fill",sidebarX,80+padding*2,width-sidebarX,height-padding*2-98) end love.graphics.stencil(stencilFunc,"replace",1) love.graphics.setStencilTest("greater",0) if stat.id == "achievements" and count(achievementList) > 0 then if self.maxSideTransY < 0 then local scrollAmt = self.sideTransY / self.maxSideTransY self.sideScrollPositions = output:scrollbar(width-padding*2,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() love.graphics.translate(0,self.sideTransY) local printY = 96+padding*(prefs['noImages'] and 6 or 3) local printX = sidebarX+64 local gridX,gridY=1,1 local maxGridX=nil local largestY=64 local lastY=0 local selectedAchievement=nil for id,achiev in pairs(achievementList) do local _, nlines = fonts.textFont:getWrap(achiev.name,128) local maxY = printY+#nlines*fontSize achiev.maxY = maxY local isMouse = (mouseX > printX-32 and mouseX < printX+96 and mouseY > printY-32+self.sideTransY and mouseY < maxY+self.sideTransY) local selected = (gridX == self.cursorX-1 and gridY == (self.achievementCursorY or 1)) or isMouse achiev.selected = selected if selected then if isMouse or selectedAchievement == nil then selectedAchievement = id end setColor(100,100,100,255) love.graphics.rectangle('fill',printX-8,printY-16,80,80) setColor(255,255,255,255) end achiev.gridX,achiev.gridY=gridX,gridY achiev.printY=printY achiev.printX=printX local has = achievements:has_achievement(id) local img = (has and (images['achievement' .. id] and images['achievement' .. id] or images['achievementunknown']) or (images['achievement' .. id .. 'locked'] and images['achievement' .. id .. 'locked'] or images['achievementunknownlocked'])) if prefs['noImages'] then if not has then setColor(125,125,125,255) love.graphics.printf("( )",printX-32,printY,128,"center") love.graphics.printf(achiev.name,printX-32,printY+prefs['fontSize'],128,"center") setColor(255,255,255,255) else love.graphics.printf("(X)",printX-32,printY,128,"center") love.graphics.printf(achiev.name,printX-32,printY+prefs['fontSize'],128,"center") end local _,tlines = fonts.textFont:getWrap(achiev.name,128) lastY=printY+prefs['fontSize']+#tlines*fontSize else setColor(33,33,33,255) love.graphics.rectangle('fill',printX,printY-8,66,66) setColor(255,255,255,255) love.graphics.rectangle('line',printX-1,printY-9,66,66) love.graphics.draw(img,printX,printY-8) love.graphics.printf(achiev.name,printX-32,printY+64-8,128,"center") local _,tlines = fonts.textFont:getWrap(achiev.name,128) lastY=printY+64-8+#tlines*fontSize end printX = printX+128 gridX = gridX+1 largestY = math.max(largestY,(#nlines+1)*fontSize) if printX+128 > width then printX = sidebarX+64 printY = printY + largestY+64 maxGridX = gridX gridX = 1 gridY = gridY+1 largestY = 64 end end --end achiev for if selectedAchievement then local achiev = achievementList[selectedAchievement] local _, tlines = fonts.descFont:getWrap(achiev.description,300) local boxHeight = #tlines*(prefs['descFontSize']+3)+math.ceil(prefs['descFontSize']/2) local x = math.min(width-332,achiev.printX) local y = math.min(height-boxHeight-32-self.sideTransY,achiev.printY) love.graphics.setFont(fonts.descFont) setColor(255,255,255,185) love.graphics.rectangle("line",x+22,y+20,302,boxHeight) setColor(0,0,0,185) love.graphics.rectangle("fill",x+23,y+21,301,boxHeight-1) setColor(255,255,255,255) love.graphics.printf(achiev.description,x+24,y+22,300) love.graphics.setFont(fonts.textFont) end local maxGridY = gridY local lastGridX = gridX if self.cursorX > maxGridX or ((self.achievementCursorY or 1) == maxGridY and self.cursorX > lastGridX) then if self.achievementCursorY < maxGridY then self.cursorX = maxGridX else self.cursorX = math.min(maxGridX,lastGridX) end end if (self.achievementCursorY or 1) > maxGridY then self.achievementCursorY = maxGridY end self.maxSideTransY = height-lastY-128 love.graphics.pop() elseif stat.id == "abilities" then if self.maxSideTransY < 0 then local scrollAmt = self.sideTransY / self.maxSideTransY self.sideScrollPositions = output:scrollbar(width-padding*2,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() love.graphics.translate(0,self.sideTransY) local printY = 80+padding*3 for _,abil in pairs(stat.stats) do love.graphics.print(abil.ability .. ": " .. abil.uses,sidebarX+padding,printY) printY = printY+fontSize end self.maxSideTransY = height-printY-fontSize*2 love.graphics.pop() elseif stat.id == "creatures" then if self.maxSideTransY < 0 then if self.cursorX == 2 then setColor(50,50,50,255) love.graphics.rectangle("fill",width-padding*2,96+padding*2,padding,height-padding-96-padding*2) setColor(255,255,255,255) end local scrollAmt = self.sideTransY / self.maxSideTransY self.sideScrollPositions = output:scrollbar(width-padding*2,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() love.graphics.translate(0,self.sideTransY) love.graphics.printf("Total Possessions: " .. (totalstats.total_possessions or 0) .. "\nTotal Explosions: " .. (totalstats.explosions or 0),sidebarX,80+padding*2+24,width-sidebarX,"center") local printY = 80+padding*2+fontSize*4 for _,creat in pairs(stat.stats) do if possibleMonsters[creat.creat] then --check to make sure this creature exists (it might not due to mods loaded) local name = ucfirst(possibleMonsters[creat.creat].name) love.graphics.printf(name,sidebarX,printY,width-sidebarX,"center") printY=printY+fontSize if creat.possessions then love.graphics.print("Possessions: " .. creat.possessions,sidebarX+padding*2,printY) printY = printY+fontSize end if creat.explosions then love.graphics.print("Explosions: " .. creat.explosions,sidebarX+padding*2,printY) printY = printY+fontSize end if creat.explosionPercent then love.graphics.print("Explosion ratio: " .. creat.explosionPercent .. "%",sidebarX+padding*2,printY) printY = printY+fontSize end love.graphics.print("Turns: " .. creat.turns,sidebarX+padding*2,printY) if creat.ratio then printY = printY+fontSize love.graphics.print("Average turns: " .. creat.ratio,sidebarX+padding*2,printY) end if creat.kills then printY = printY+fontSize love.graphics.print("Kills as: " .. creat.kills,sidebarX+padding*2,printY) end if creat.killRatio then printY = printY+fontSize love.graphics.print("Average kills: " .. creat.killRatio,sidebarX+padding*2,printY) end local c = possibleMonsters[creat.creat] c.image_frame = 1 c.baseType = "creature" if c.id == nil then c.id = creat.creat end output.display_entity(c,sidebarX+padding-8,printY-round(fontSize*(creat.creat == "ghost" and 0.5 or 3.5)),"force") printY = printY+fontSize*2 end end self.maxSideTransY = height-printY-fontSize love.graphics.pop() elseif stat.id == "kills" then if self.maxSideTransY < 0 then if self.cursorX == 2 then setColor(50,50,50,255) love.graphics.rectangle("fill",width-padding*2,96+padding*2,padding,height-padding-96-padding*2) setColor(255,255,255,255) end local scrollAmt = self.sideTransY / self.maxSideTransY self.sideScrollPositions = output:scrollbar(width-padding*2,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() love.graphics.translate(0,self.sideTransY) love.graphics.printf("Total Kills: " .. (totalstats.kills or 0),sidebarX,80+padding*2,width-sidebarX,"center") local printY = 80+padding*2+fontSize*2 for _,creat in pairs(stat.stats) do love.graphics.print(ucfirst(possibleMonsters[creat.creat].name) .. ": " .. creat.kills,sidebarX+padding,printY) printY = printY+fontSize end self.maxSideTransY = height-printY-fontSize*2 love.graphics.pop() elseif stat.id == "explosions" then love.graphics.push() love.graphics.translate(0,self.sideTransY) love.graphics.printf("Total Explosions: " .. totalstats.explosions,sidebarX,80+padding*2,width-sidebarX,"center") local printY = 80+padding*2+fontSize*2 for _,creat in pairs(stat.stats) do love.graphics.print(ucfirst(possibleMonsters[creat.creat].name) .. "s Exploded: " .. creat.explosions,sidebarX+padding,printY) printY = printY+fontSize end self.maxSideTransY = height-printY love.graphics.pop() elseif stat.id == "leader_kills" then if self.maxSideTransY < 0 then if self.cursorX == 2 then setColor(50,50,50,255) love.graphics.rectangle("fill",width-padding*2,96+padding*2,padding,height-padding-96-padding*2) setColor(255,255,255,255) end local scrollAmt = self.sideTransY / self.maxSideTransY self.sideScrollPositions = output:scrollbar(width-padding*2,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() love.graphics.translate(0,self.sideTransY) local printY = 80+padding*3 for _,creat in pairs(stat.stats) do local name = ucfirst(possibleMonsters[creat.creat].name) love.graphics.printf(name,sidebarX,printY,width-sidebarX,"center") printY=printY+fontSize love.graphics.print("Total Followers: " .. creat.thralls,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Follower kills: " .. creat.kills,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Kills/Follower: " .. creat.killsPerFollower,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Possessions: " .. creat.possessions,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Followers/Possession: " .. creat.thrallsPerPossession,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Follower Kills/Possession: " .. creat.killsPerPossession,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Follower deaths: " .. creat.followerDeaths,sidebarX+padding*2,printY) local c = possibleMonsters[creat.creat] c.image_frame = 1 c.baseType = "creature" if c.id == nil then c.id = creat.creat end output.display_entity(c,sidebarX+padding-8,printY-round(fontSize*(creat.creat == "ghost" and 0.5 or 3.5)),"force") printY = printY+fontSize*2 end self.maxSideTransY = height-printY love.graphics.pop() elseif stat.id == "follower_kills" then if self.maxSideTransY < 0 then if self.cursorX == 2 then setColor(50,50,50,255) love.graphics.rectangle("fill",width-padding*2,96+padding*2,padding,height-padding-96-padding*2) setColor(255,255,255,255) end local scrollAmt = self.sideTransY / self.maxSideTransY self.sideScrollPositions = output:scrollbar(width-padding*2,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() love.graphics.translate(0,self.sideTransY) local printY = 80+padding*3 for _,creat in pairs(stat.stats) do local name = ucfirst(possibleMonsters[creat.creat].name) love.graphics.printf(name,sidebarX,printY,width-sidebarX,"center") printY=printY+fontSize love.graphics.print("Number Followed by: " .. creat.thralls,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Follower Kills: " .. creat.kills,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Average Kills: " .. creat.killsPer,sidebarX+padding*2,printY) printY = printY+fontSize love.graphics.print("Follower Deaths: " .. creat.deaths,sidebarX+padding*2,printY) local c = possibleMonsters[creat.creat] c.image_frame = 1 c.baseType = "creature" if c.id == nil then c.id = creat.creat end output.display_entity(c,sidebarX+padding-8,printY-round(fontSize*(creat.creat == "ghost" and 0.5 or 2)),"force") printY = printY+fontSize*2 end self.maxSideTransY = height-printY love.graphics.pop() elseif stat.id == "levels" then if self.maxSideTransY < 0 then if self.cursorX == 2 then setColor(50,50,50,255) love.graphics.rectangle("fill",width-padding*2,96+padding*2,padding,height-padding-96-padding*2) setColor(255,255,255,255) end local scrollAmt = self.sideTransY / self.maxSideTransY self.sideScrollPositions = output:scrollbar(width-padding*2,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() love.graphics.translate(0,self.sideTransY) local printY = 80+padding*3 for level,stat in ipairs(stat.stats) do love.graphics.printf((stat.depth and "Depth " .. tostring(11-stat.depth) .. ": " or "") .. tostring(stat.name),sidebarX,printY,width-sidebarX,"center") printY=printY+fontSize love.graphics.print("Times Reached: " .. stat.reached,sidebarX+padding*2,printY) printY=printY+fontSize love.graphics.print("Times Beaten: " .. stat.beaten,sidebarX+padding*2,printY) printY=printY+fontSize love.graphics.print("Beaten Ratio: " .. stat.beatPercent .. "%",sidebarX+padding*2,printY) printY=printY+fontSize love.graphics.print("Total Turns on Level: " .. stat.turns,sidebarX+padding*2,printY) printY=printY+fontSize love.graphics.print("Average Turns on Level: " .. stat.avgTurns,sidebarX+padding*2,printY) printY=printY+fontSize love.graphics.print("Average Turns to Beat: " .. stat.avgTurnsBeat,sidebarX+padding*2,printY) printY=printY+fontSize*2 end self.maxSideTransY = height-printY love.graphics.pop() end love.graphics.setStencilTest() end elseif self.screen == "wins" then local w1end,w2start,w2end = math.floor(width/2),math.ceil(width/2)+padding,math.ceil(width/2)+math.floor(width/2)-padding local windowY = 64+padding output:draw_window(0,windowY,w1end,height-padding) output:draw_window(w2start,windowY,w2end,height-padding) love.graphics.setFont(fonts.graveFontBig) love.graphics.printf("Wins",1,windowY+math.floor(padding/2),math.floor(width/2),"center") love.graphics.line(padding,windowY+padding*2,w1end-padding,windowY+padding*2) love.graphics.setFont(fonts.textFont) if self.maxTransY < 0 then local scrollAmt = self.transY / self.maxTransY self.scrollPositions = output:scrollbar(w1end-padding,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() local function stencilFunc() love.graphics.rectangle("fill",padding,windowY+padding*2,w1end,height-padding-(windowY+padding*2)) end love.graphics.stencil(stencilFunc,"replace",1) love.graphics.setStencilTest("greater",0) love.graphics.translate(0,self.transY) local printY = windowY+padding*2 for id,grave in ipairs(self.wins) do local dateWidth = fonts.textFont:getWidth(os.date("%H:%M, %b %d, %Y",grave.date)) local _,tlines = fonts.textFont:getWrap(grave.properName .. ", " .. ucfirst(grave.name),w1end-padding-dateWidth) if self.cursorY-1 == id then setColor(100,100,100,255) love.graphics.rectangle("fill",padding,printY,w1end-padding*2,math.ceil(2+fontSize*#tlines*1.15)) setColor(255,255,255,255) else local mouseX,mouseY = love.mouse.getPosition() if mouseY-self.transY > printY and mouseY-self.transY < printY+fontSize*#tlines*1.25 and mouseX > padding and mouseX < w1end-padding then setColor(66,66,66,255) love.graphics.rectangle("fill",padding,printY,w1end-padding*2,math.ceil(2+fontSize*#tlines*1.15)) setColor(255,255,255,255) end end grave.printY = printY love.graphics.printf(grave.properName .. ", " .. ucfirst(grave.name),padding,printY,w1end-padding-dateWidth,"left") love.graphics.printf(os.date("%H:%M, %b %d, %Y",grave.date),w1end-padding*2-dateWidth,printY,dateWidth,"right") printY = math.ceil(printY+fontSize*#tlines*1.25) grave.maxY = printY end self.maxTransY = height-printY-fontSize-padding love.graphics.setStencilTest() love.graphics.pop() if self.wins[self.cursorY-1] then local win = self.wins[self.cursorY-1] local printY = windowY+math.floor(padding/2) love.graphics.setFont(fonts.graveFontBig) love.graphics.printf(win.properName .. "\n" .. ucfirst(win.name),w2start,printY,w2end-w2start,"center") local _,lines = fonts.graveFontBig:getWrap(win.properName .. "\n" .. ucfirst(win.name),w2end-w2start+padding) printY = printY+padding*#lines love.graphics.setFont(fonts.graveFontSmall) love.graphics.printf(os.date("%H:%M, %b %d, %Y",win.date),w2start,printY,w2end-w2start,"center") printY = printY+padding if win.stats then love.graphics.setFont(fonts.textFont) local winText = "Turns played: " .. (win.stats.turns or 0) winText = winText .. "\nKills: " .. (win.stats.kills or 0) winText = winText .. "\nFavorite Ability: " .. (win.stats.favoriteAbility and win.stats.favoriteAbility .. " (" .. win.stats.favoriteAbilityTurns .. " uses)" or "Unknown") love.graphics.printf(winText,w2start+padding,printY,w2end-w2start-padding,"left") end end elseif self.screen == "losses" then local w1end,w2start,w2end = math.floor(width/2),math.ceil(width/2)+padding,math.ceil(width/2)+math.floor(width/2)-padding local windowY = 64+padding output:draw_window(0,windowY,w1end,height-padding) output:draw_window(w2start,windowY,w2end,height-padding) love.graphics.setFont(fonts.graveFontBig) love.graphics.printf("Losses",1,windowY+math.floor(padding/2),math.floor(width/2),"center") love.graphics.line(padding,windowY+padding*2,w1end-padding,windowY+padding*2) love.graphics.setFont(fonts.textFont) if self.maxTransY < 0 then local scrollAmt = self.transY / self.maxTransY self.scrollPositions = output:scrollbar(w1end-padding,96+padding*2,height-padding,scrollAmt,true) end love.graphics.push() local function stencilFunc() love.graphics.rectangle("fill",padding,windowY+padding*2,w1end,height-padding-(windowY+padding*2)) end love.graphics.stencil(stencilFunc,"replace",1) love.graphics.setStencilTest("greater",0) love.graphics.translate(0,self.transY) local printY = windowY+padding*2 for id,grave in ipairs(self.graveyard) do local dateWidth = fonts.textFont:getWidth(os.date("%H:%M, %b %d, %Y",grave.date)) local _,tlines = fonts.textFont:getWrap(grave.properName .. ", " .. ucfirst(grave.name),w1end-padding-dateWidth) if self.cursorY-1 == id then setColor(100,100,100,255) love.graphics.rectangle("fill",padding,printY,w1end-padding*2,math.ceil(2+fontSize*#tlines*1.15)) setColor(255,255,255,255) else if mouseY-self.transY > printY and mouseY-self.transY < printY+fontSize*(#tlines*1.25) and mouseX > padding and mouseX < w1end-padding then setColor(66,66,66,255) love.graphics.rectangle("fill",padding,printY,w1end-padding*2,math.ceil(2+fontSize*#tlines*1.15)) setColor(255,255,255,255) end end grave.printY = printY love.graphics.printf(grave.properName .. ", " .. ucfirst(grave.name),padding,printY,w1end-padding*2-dateWidth,"left") love.graphics.printf(os.date("%H:%M, %b %d, %Y",grave.date),w1end-padding-dateWidth,printY,dateWidth,"right") printY = printY+math.ceil(fontSize*#tlines*1.25) grave.maxY = printY end self.maxTransY = height-printY-fontSize-padding love.graphics.setStencilTest() love.graphics.pop() if self.graveyard[self.cursorY-1] then local grave = self.graveyard[self.cursorY-1] local printY = windowY+math.floor(padding/2) love.graphics.setFont(fonts.graveFontBig) love.graphics.printf(grave.saying,w2start,printY,w2end-w2start,"center") printY = printY+padding love.graphics.printf(grave.properName .. "\n" .. ucfirst(grave.name),w2start,printY,w2end-w2start,"center") local _,lines = fonts.graveFontBig:getWrap(grave.properName .. "\n" .. ucfirst(grave.name),w2end-w2start+padding) printY = printY+padding*#lines love.graphics.setFont(fonts.graveFontSmall) love.graphics.printf("Killed by " .. grave.killer,w2start,printY,w2end-w2start,"center") _,lines = fonts.graveFontBig:getWrap("Killed by " .. grave.killer,w2end-w2start+padding) printY = printY+math.floor(padding/3)*2*#lines love.graphics.printf("at " .. os.date("%H:%M, %b %d, %Y",grave.date),w2start,printY,w2end-w2start,"center") _,lines = fonts.graveFontBig:getWrap("at " .. os.date("%H:%M, %b %d, %Y",grave.date),w2end-w2start+padding) printY = printY+math.floor(padding/3)*2*#lines love.graphics.printf((grave.mapname and grave.mapname or ""),w2start,printY,w2end-w2start,"center") printY = printY+padding if grave.stats then love.graphics.setFont(fonts.textFont) local graveText = "Turns played: " .. (grave.stats.turns or 0) graveText = graveText .. "\nKills: " .. (grave.stats.kills or 0) graveText = graveText .. "\nFavorite Ability: " .. (grave.stats.favoriteAbility and grave.stats.favoriteAbility .. " (" .. grave.stats.favoriteAbilityTurns .. " uses)" or "Unknown") love.graphics.printf(graveText,w2start+padding,printY,w2end-w2start-padding,"left") end end end love.graphics.pop() end function gamestats:keypressed(key) key = input:parse_key(key) if key == "escape" then self:switchBack() elseif key == "north" then if self.screen == "stats" and self.cursorX > 1 and self.cursorY ~= 1 then if self.stats[self.cursorY-1] and self.stats[self.cursorY-1].id == "achievements" then self.achievementCursorY = math.max(self.achievementCursorY and self.achievementCursorY-1 or 1,1) for _,achiev in pairs(achievementList) do if achiev.gridX==self.cursorX-1 and achiev.gridY==self.achievementCursorY then while achiev.printY-32+self.sideTransY < 96 do self:sidebarScrollUp() end break end end else self:sidebarScrollUp() end else self.cursorY = math.max(self.cursorY-1,1) local which = (self.screen == "losses" and "graveyard" or self.screen) while self[which][self.cursorY].printY+self.transY <= 96+prefs['fontSize'] do self:scrollUp() end end elseif key == "south" then local maxY = (self.screen == "losses" and #self.graveyard+1) or (self.screen == "stats" and #self.stats+1) or (self.screen == "wins" and #self.wins+1) if self.screen == "stats" and self.cursorX > 1 and self.cursorY ~= 1 then if self.stats[self.cursorY-1] and self.stats[self.cursorY-1].id == "achievements" then self.achievementCursorY = (self.achievementCursorY and self.achievementCursorY+1 or 2) for _,achiev in pairs(achievementList) do if achiev.gridX==self.cursorX-1 and achiev.gridY==self.achievementCursorY then while achiev.maxY+self.sideTransY > love.graphics:getHeight() do self:sidebarScrollDown() end break end end else self:sidebarScrollDown() end elseif self.screen == "stats" and not self.stats[self.cursorY].expand then self:scrollDown() else if self.screen ~= "stats" or self.stats[self.cursorY].expand then self.cursorY = math.min(self.cursorY+1,(maxY or 1)) if self.screen ~= "stats" then local which = (self.screen == "losses" and "graveyard" or self.screen) if self[which][self.cursorY] and (self[which][self.cursorY-1].maxY > love.graphics.getHeight()-32-self.transY) then self:scrollDown() end elseif self.screen == "stats" then self.cursorX = 1 self.sideTransY = 0 end end end elseif key == "west" then if self.cursorY == 1 then self.cursorX = math.max(self.cursorX-1,1) else if self.screen == "stats" then self.cursorX = math.max(self.cursorX-1,1) else self.cursorY = 1 self.cursorX = (self.screen == "losses" and 2 or 1) end end elseif key == "east" then if self.cursorY == 1 then self.cursorX = math.min(self.cursorX+1,3) else if self.screen == "stats" then if self.stats[self.cursorY-1] and self.stats[self.cursorY-1].expand and self.maxSideTransY < 0 then self.cursorX = self.cursorX + 1 if not self.stats[self.cursorY-1] or self.stats[self.cursorY-1].id ~= "achievements" then self.cursorX = 2 end end elseif self.screen == "wins" then self.cursorY = 1 self.cursorX = 3 end end elseif key == "return" or key == "wait" then if self.cursorY == 1 then if self.cursorX == 1 then self.screen = "stats" self.transY = 0 self.cursorY = 1 elseif self.cursorX == 2 then self.screen = "wins" self.transY = 0 self.cursorY = 1 elseif self.cursorX == 3 then self.screen = "losses" self.transY = 0 self.cursorY = 1 end --end cursorX if end --end cursorY if end --end key if end function gamestats:wheelmoved(x,y) local padding=prefs['noImages'] and 14 or 32 local sidebarX = round(love.graphics:getWidth()/2)+padding if self.screen ~= "stats" or love.mouse.getX() < sidebarX then if y < 0 then self:scrollDown() elseif y > 0 then self:scrollUp() end else if y > 0 then self:sidebarScrollUp() output.mouseX,output.mouseY=0,0 elseif y < 0 then self:sidebarScrollDown() output.mouseX,output.mouseY=0,0 end end end function gamestats:scrollDown() if self.maxTransY < 0 then self.transY = math.max(self.transY-prefs['fontSize']*5,self.maxTransY) end end function gamestats:scrollUp() self.transY = math.min(self.transY+prefs['fontSize']*5,0) end function gamestats:sidebarScrollDown() if self.maxSideTransY < 0 then self.sideTransY = math.max(self.sideTransY-prefs['fontSize']*5,self.maxSideTransY) end end function gamestats:sidebarScrollUp() if self.maxSideTransY < 0 then self.sideTransY = math.min(self.sideTransY+prefs['fontSize']*5,0) end end function gamestats:update(dt) local uiScale = prefs['uiScale'] or 1 if self.switchNow == true then self.switchNow = nil Gamestate.switch(self.previous) Gamestate.update(dt) return end --Handle scrolling: local x,y = love.mouse.getPosition() x,y = math.floor(x/uiScale),math.floor(y/uiScale) if (love.mouse.isDown(1)) and self.sideScrollPositions then local upArrow = self.sideScrollPositions.upArrow local downArrow = self.sideScrollPositions.downArrow local elevator = self.sideScrollPositions.elevator if x>upArrow.startX and x<upArrow.endX and y>upArrow.startY and y<upArrow.endY then self:sidebarScrollUp() elseif x>downArrow.startX and x<downArrow.endX and y>downArrow.startY and y<downArrow.endY then self:sidebarScrollDown() elseif x>elevator.startX and x<elevator.endX and y>upArrow.endY and y<downArrow.startY then if y<elevator.startY then self:sidebarScrollUp() elseif y>elevator.endY then self:sidebarScrollDown() end end --end clicking on arrow end if (love.mouse.isDown(1)) and self.scrollPositions then local upArrow = self.scrollPositions.upArrow local downArrow = self.scrollPositions.downArrow local elevator = self.scrollPositions.elevator if x>upArrow.startX and x<upArrow.endX and y>upArrow.startY and y<upArrow.endY then self:scrollUp() elseif x>downArrow.startX and x<downArrow.endX and y>downArrow.startY and y<downArrow.endY then self:scrollDown() elseif x>elevator.startX and x<elevator.endX and y>upArrow.endY and y<downArrow.startY then if y<elevator.startY then self:scrollUp() elseif y>elevator.endY then self:scrollDown() end end --end clicking on arrow end end function gamestats:switchBack() tween(0.2,self,{yModPerc=100}) output:sound('stoneslideshortbackwards',2) Timer.after(0.2,function() self.switchNow=true end) end function gamestats:mousepressed(x,y,button) local uiScale = prefs['uiScale'] or 1 x,y = math.floor(x/uiScale),math.floor(y/uiScale) if button == 2 or (x > self.closebutton.minX and x < self.closebutton.maxX and y > self.closebutton.minY and y < self.closebutton.maxY) then self:switchBack() elseif x > self.statsbutton.minX and x < self.statsbutton.maxX and y > self.statsbutton.minY and y < self.statsbutton.maxY then self.screen = "stats" self.transY = 0 self.cursorY = 1 self.cursorX = 1 return elseif x > self.winsbutton.minX and x < self.winsbutton.maxX and y > self.winsbutton.minY and y < self.winsbutton.maxY then self.screen = "wins" self.transY = 0 self.cursorY = 1 self.cursorX = 2 return elseif x > self.lossesbutton.minX and x < self.lossesbutton.maxX and y > self.lossesbutton.minY and y < self.lossesbutton.maxY then self.screen = "losses" self.transY = 0 self.cursorY = 1 self.cursorX = 3 return end local padding=prefs['noImages'] and 14 or 32 local fontSize = prefs['fontSize'] local width = love.graphics:getWidth() local sidebarX = (self.screen == "stats" and round(width/2)+padding or math.ceil(width/2)+padding) local loopThrough = {} if self.screen == "stats" then loopThrough = self.stats elseif self.screen == "wins" then loopThrough = self.wins elseif self.screen == "losses" then loopThrough = self.graveyard end for id,item in ipairs(loopThrough) do local printY = (self.screen == "stats" and 80+padding*3+(id-1)*fontSize+self.transY or (item.printY and item.printY+self.transY or -1000)) if x > padding and x < sidebarX-padding-(self.screen == "stats" and 0 or padding) and y-self.transY > item.printY and y-self.transY < item.maxY and (item.expand or self.screen ~= "stats") then self.cursorY = id+1 self.cursorX = 1 self.sideTransY = 0 self.achievementCursorY=0 end end end
--- Functional iteration utilities using coroutines. --Modified version of <a href="https://github.com/aperezdc/lua-itertools">itertools.lua</a>. --Documentation can be found --<a href="https://aperezdc.github.io/lua-itertools/">here</a>. -- @module itertools.lua -- @author aperezdc -- @license MIT -- @copyright aperezdc 2016 itertools = {} --- function itertools.values (table) return coroutine.wrap(function () for _, v in pairs(table) do coroutine.yield(v) end end) end --- --- function itertools.each (table) return coroutine.wrap(function () for _, v in ipairs(table) do coroutine.yield(v) end end) end --- --- function itertools.collect (iterable) local t, n = {}, 0 for element in iterable do n = n + 1 t[n] = element end return t, n end --- --- function itertools.count (n, step) if n == nil then n = 1 end if step == nil then step = 1 end return coroutine.wrap(function () while true do coroutine.yield(n) n = n + step end end) end --- --- function itertools.cycle (iterable) local saved = {} local nitems = 0 return coroutine.wrap(function () for element in iterable do coroutine.yield(element) nitems = nitems + 1 saved[nitems] = element end while nitems > 0 do for i = 1, nitems do coroutine.yield(saved[i]) end end end) end --- --- function itertools.value (value, times) if times then return coroutine.wrap(function () while times > 0 do times = times - 1 coroutine.yield(value) end end) else return coroutine.wrap(function () while true do coroutine.yield(value) end end) end end --- --- function itertools.islice (iterable, start, stop) if start == nil then start = 1 end return coroutine.wrap(function () -- these sections are covered but do not register -- luacov: disable if stop ~= nil and stop - start < 1 then return end -- luacov: enable local current = 0 for element in iterable do current = current + 1 -- luacov: disable if stop ~= nil and current > stop then return end -- luacov: enable if current >= start then coroutine.yield(element) end end end) end --- --- function itertools.takewhile (predicate, iterable) return coroutine.wrap(function () for element in iterable do if predicate(element) then coroutine.yield(element) else break end end end) end --- --- function itertools.map (func, iterable) return coroutine.wrap(function () for element in iterable do coroutine.yield(func(element)) end end) end --- --- function itertools.filter (predicate, iterable) return coroutine.wrap(function () for element in iterable do if predicate(element) then coroutine.yield(element) end end end) end --- --- local function make_comp_func(key) if type(key) == 'function' then return function (a, b) return key(a) < key(b) end end end --- --- function itertools.sorted (iterable, key, reverse) local t, n = itertools.collect(iterable) table.sort(t, make_comp_func(key)) if reverse then return coroutine.wrap(function () for i = n, 1, -1 do coroutine.yield(t[i]) end end) else return coroutine.wrap(function () for i = 1, n do coroutine.yield(t[i]) end end) end end
-- Copyright (C) 2019 by davin if ngx.get_phase() ~= 'header_filter' then return end local cache_status = ngx.var.upstream_cache_status local accel = ngx.var.http_host or ngx.var.server_name ngx.header['X-Cache'] = cache_status ngx.header['X-Accel'] = accel -- hit rate local misc = ngx.shared.misc local total = misc:incr('total_req', 1, 0) local hit = misc:get('hit') or 0 if cache_status == 'HIT' then hit = misc:incr('hit', 1, 0) end local rate = hit * 100 / total ngx.header['X-Hit'] = string.format('%.2f%%', rate)
-- Wireshard Dissector for the Simple Order Protocol (sop). An imaginary -- protocol. -- -- IMPORTANT: Add the following lines at the end of Wireshark's init.lua: -- -- WSDH_SCRIPT_PATH='path to the directory 'src' of the repo' -- SOP_SPECS_PATH='path to the directory of the CSV specs' -- dofile('path to this file') -- local wsdh = dofile(WSDH_SCRIPT_PATH .. '/ws_dissector_helper.lua') local sop = Proto('SOP', 'Simple Order Protocol') -- a table of our default settings - these can be changed by changing -- the preferences through the GUI or command-line. local defaultSettings = { ports = '9001-9010', trace = false } local helper = wsdh.createProtoHelper(sop) helper:setDefaultPreference(defaultSettings) local msg_types = { { name = 'NO', file = 'NO.csv' }, { name = 'OC', file = 'OC.csv' }, { name = 'TR', file = 'TR.csv' }, { name = 'RJ', file = 'RJ.csv' }, { name = 'EN', file = 'EN.csv' }, { name = 'BO', file = 'BO.csv' } } -- Define fields local SopFields = { SOH = wsdh.Field.FIXED(1,'sop.header.SOH', 'SOH', '\x01','Start of Header'), LEN = wsdh.Field.NUMERIC(3,'sop.header.LEN', 'LEN','Length of the payload (i.e. no header/trailer)'), ETX = wsdh.Field.FIXED(1, 'sop.trailer.ETX', 'ETX', '\x03','End of Message') } --Define Header local header = wsdh.Field.COMPOSITE{ title = 'Header', SopFields.SOH, SopFields.LEN } --Define Trailer local trailer = wsdh.Field.COMPOSITE{ title = 'Trailer', SopFields.ETX } -- Column mapping. local columns = { name = 'Field', length = 'Length', type = 'Type', desc = 'Description' } local msg_specs, msg_parsers = helper:loadSpecs(msg_types, SOP_SPECS_PATH, columns, header:len(), ',', header, trailer) -- Returns the length of the message from the end of header up to the start -- of trailer. local function getMsgDataLen(msgBuffer) return tonumber(helper:getHeaderValue(msgBuffer, SopFields.LEN)) end -- Returns the length of whole the message. Includes header and trailer. local function getMsgLen(msgBuffer) local msgdataLen = getMsgDataLen(msgBuffer) if msgdataLen == nil then return nil end return header:len() + msgdataLen + trailer:len() end -- Parse a specific type of message from a buffer and add it to the tree. local function parseMessage(buffer, pinfo, tree) -- The minimum buffer length in that can be used to identify a message -- must include the header and the MessageType. local msgTypeLen = 2 local minBufferLen = header:len() + msgTypeLen -- Messages start with SOH. if SopFields.SOH:value(buffer) ~= SopFields.SOH.fixedValue then helper:warn('No SOH.') return 0 end -- Return missing message length in the case when the header is split -- between packets. if buffer:len() <= minBufferLen then return -DESEGMENT_ONE_MORE_SEGMENT end -- Look for valid message types. local msgType = buffer(header:len(), msgTypeLen):string() local msgSpec = msg_specs[msgType] if not msgSpec then helper:warn('Unknown message type: ' .. msgType) return 0 end -- Return missing message length in the case when the data is split -- between packets. local msgLen = getMsgLen(buffer) local msgDataLen = getMsgDataLen(buffer) if buffer:len() < msgLen then helper:info('buffer:len < msgLen [' .. buffer:len() .. ' < ' .. msgLen .. ']') return -DESEGMENT_ONE_MORE_SEGMENT end local msgParse = msg_parsers[msgType] -- If no parser is found for this type of message, reject the whole -- packet. if not msgParse then helper:warn('Not supported message type: ' .. msgType) return 0 end local bytesConsumed, subtree = msgParse(buffer, pinfo, tree, 0) if bytesConsumed > 0 then subtree:append_text(', Type: ' .. msgType) subtree:append_text(', Len: ' .. msgLen) pinfo.cols.protocol = sop.name end return bytesConsumed end sop.dissector = helper:getDissector(parseMessage) helper:enableDissector()
return { short_music_name = "song10", bpm = 752, offset_time = 0, music_name = "bgm-song10", left_track = { { begin_time = "1.196808", key_flag = "K_LEFT", end_time = "1.196808" }, { begin_time = "2.632978", key_flag = "K_LEFT", end_time = "2.632978" }, { begin_time = "3.271276", key_flag = "K_LEFT", end_time = "3.271276" }, { begin_time = "3.909575", key_flag = "K_LEFT", end_time = "6.143617" }, { begin_time = "6.462766", key_flag = "K_LEFT", end_time = "6.462766" }, { begin_time = "6.781915", key_flag = "K_LEFT", end_time = "6.781915" }, { begin_time = "7.101064", key_flag = "K_LEFT", end_time = "7.101064" }, { begin_time = "7.420213", key_flag = "K_LEFT", end_time = "7.420213" }, { begin_time = "7.739362", key_flag = "K_LEFT", end_time = "7.739362" }, { begin_time = "8.37766", key_flag = "K_LEFT", end_time = "8.37766" }, { begin_time = "10.29255", key_flag = "K_LEFT", end_time = "10.29255" }, { begin_time = "10.93085", key_flag = "K_LEFT", end_time = "10.93085" }, { begin_time = "11.56915", key_flag = "K_LEFT", end_time = "11.56915" }, { begin_time = "11.72872", key_flag = "K_LEFT", end_time = "11.72872" }, { begin_time = "12.5266", key_flag = "K_LEFT", end_time = "12.5266" }, { begin_time = "12.84575", key_flag = "K_LEFT", end_time = "12.84575" }, { begin_time = "13.48404", key_flag = "K_LEFT", end_time = "14.12234" }, { begin_time = "14.60204", key_flag = "K_LEFT", end_time = "14.60204" }, { begin_time = "14.76069", key_flag = "K_LEFT", end_time = "14.76069" }, { begin_time = "15.23986", key_flag = "K_LEFT", end_time = "15.23986" }, { begin_time = "15.40039", key_flag = "K_LEFT", end_time = "15.40039" }, { begin_time = "16.83511", key_flag = "K_LEFT", end_time = "17.31383" }, { begin_time = "17.95298", key_flag = "K_LEFT", end_time = "17.95298" }, { begin_time = "18.11219", key_flag = "K_LEFT", end_time = "18.11219" }, { begin_time = "18.90957", key_flag = "K_LEFT", end_time = "19.54787" }, { begin_time = "19.8649", key_flag = "K_LEFT", end_time = "19.8649" }, { begin_time = "20.02659", key_flag = "K_LEFT", end_time = "20.02659" }, { begin_time = "20.1862", key_flag = "K_LEFT", end_time = "20.1862" }, { begin_time = "20.82447", key_flag = "K_LEFT", end_time = "20.82447" }, { begin_time = "21.30319", key_flag = "K_LEFT", end_time = "21.30319" }, { begin_time = "21.62283", key_flag = "K_LEFT", end_time = "21.62283" }, { begin_time = "22.10106", key_flag = "K_LEFT", end_time = "22.10106" }, { begin_time = "22.26063", key_flag = "K_LEFT", end_time = "22.26063" }, { begin_time = "23.05851", key_flag = "K_LEFT", end_time = "23.05851" }, { begin_time = "23.21808", key_flag = "K_LEFT", end_time = "23.21808" }, { begin_time = "24.65414", key_flag = "K_LEFT", end_time = "24.65414" }, { begin_time = "24.97449", key_flag = "K_LEFT", end_time = "24.97449" }, { begin_time = "25.93112", key_flag = "K_LEFT", end_time = "25.93112" }, { begin_time = "26.25185", key_flag = "K_LEFT", end_time = "26.25185" }, { begin_time = "26.72873", key_flag = "K_LEFT", end_time = "26.72873" }, { begin_time = "27.36702", key_flag = "K_LEFT", end_time = "27.36702" }, { begin_time = "27.685", key_flag = "K_LEFT", end_time = "27.685" }, { begin_time = "27.84575", key_flag = "K_LEFT", end_time = "27.84575" }, { begin_time = "28.1649", key_flag = "K_LEFT", end_time = "28.1649" }, { begin_time = "28.48404", key_flag = "K_LEFT", end_time = "28.96277" }, { begin_time = "30.55851", key_flag = "K_LEFT", end_time = "30.55851" }, { begin_time = "30.87766", key_flag = "K_LEFT", end_time = "30.87766" }, { begin_time = "31.19681", key_flag = "K_LEFT", end_time = "31.19681" }, { begin_time = "31.83511", key_flag = "K_LEFT", end_time = "31.83511" }, { begin_time = "32.46508", key_flag = "K_LEFT", end_time = "32.46508" }, { begin_time = "32.95213", key_flag = "K_LEFT", end_time = "32.95213" }, { begin_time = "33.27128", key_flag = "K_LEFT", end_time = "33.27128" }, { begin_time = "33.59043", key_flag = "K_LEFT", end_time = "33.59043" }, { begin_time = "35.18617", key_flag = "K_LEFT", end_time = "35.18617" }, { begin_time = "35.82032", key_flag = "K_LEFT", end_time = "35.82032" }, { begin_time = "36.4669", key_flag = "K_LEFT", end_time = "36.4669" }, { begin_time = "37.10321", key_flag = "K_LEFT", end_time = "37.10321" }, { begin_time = "38.69486", key_flag = "K_LEFT", end_time = "38.69486" }, { begin_time = "39.01596", key_flag = "K_LEFT", end_time = "39.9734" }, { begin_time = "40.45212", key_flag = "K_LEFT", end_time = "40.45212" }, { begin_time = "40.77159", key_flag = "K_LEFT", end_time = "40.77159" }, { begin_time = "41.24578", key_flag = "K_LEFT", end_time = "41.24578" }, { begin_time = "41.40992", key_flag = "K_LEFT", end_time = "41.40992" }, { begin_time = "42.04787", key_flag = "K_LEFT", end_time = "42.04787" }, { begin_time = "42.20795", key_flag = "K_LEFT", end_time = "42.20795" }, { begin_time = "42.52659", key_flag = "K_LEFT", end_time = "42.52659" }, { begin_time = "42.68373", key_flag = "K_LEFT", end_time = "42.68373" }, { begin_time = "43.48404", key_flag = "K_LEFT", end_time = "43.48404" }, { begin_time = "43.80319", key_flag = "K_LEFT", end_time = "44.60107" }, { begin_time = "44.92148", key_flag = "K_LEFT", end_time = "44.92148" }, { begin_time = "45.07978", key_flag = "K_LEFT", end_time = "45.07978" }, { begin_time = "45.87773", key_flag = "K_LEFT", end_time = "45.87773" }, { begin_time = "46.19681", key_flag = "K_LEFT", end_time = "46.19681" }, { begin_time = "46.51596", key_flag = "K_LEFT", end_time = "46.51596" }, { begin_time = "46.99344", key_flag = "K_LEFT", end_time = "46.99344" }, { begin_time = "47.31383", key_flag = "K_LEFT", end_time = "47.31383" }, { begin_time = "48.10996", key_flag = "K_LEFT", end_time = "48.10996" }, { begin_time = "48.43005", key_flag = "K_LEFT", end_time = "48.43005" }, { begin_time = "48.75", key_flag = "K_LEFT", end_time = "48.75" }, { begin_time = "49.06794", key_flag = "K_LEFT", end_time = "49.06794" }, { begin_time = "49.54787", key_flag = "K_LEFT", end_time = "49.54787" }, { begin_time = "49.70745", key_flag = "K_LEFT", end_time = "50.18617" }, { begin_time = "50.66381", key_flag = "K_LEFT", end_time = "50.66381" }, { begin_time = "50.98521", key_flag = "K_LEFT", end_time = "50.98521" }, { begin_time = "51.22319", key_flag = "K_LEFT", end_time = "51.22319" }, { begin_time = "51.38044", key_flag = "K_LEFT", end_time = "51.38044" }, { begin_time = "51.54256", key_flag = "K_LEFT", end_time = "51.54256" }, { begin_time = "52.10107", key_flag = "K_LEFT", end_time = "52.10107" }, { begin_time = "52.42372", key_flag = "K_LEFT", end_time = "52.42372" }, { begin_time = "53.37383", key_flag = "K_LEFT", end_time = "53.37383" }, { begin_time = "53.69932", key_flag = "K_LEFT", end_time = "53.69932" }, { begin_time = "54.01693", key_flag = "K_LEFT", end_time = "54.01693" }, { begin_time = "54.49468", key_flag = "K_LEFT", end_time = "55.13298" }, { begin_time = "55.6117", key_flag = "K_LEFT", end_time = "55.6117" }, { begin_time = "55.93013", key_flag = "K_LEFT", end_time = "55.93013" }, { begin_time = "56.25086", key_flag = "K_LEFT", end_time = "56.25086" }, { begin_time = "56.8883", key_flag = "K_LEFT", end_time = "56.8883" }, { begin_time = "57.04787", key_flag = "K_LEFT", end_time = "57.04787" }, { begin_time = "58.16489", key_flag = "K_LEFT", end_time = "58.16489" }, { begin_time = "58.48404", key_flag = "K_LEFT", end_time = "58.48404" }, { begin_time = "58.80442", key_flag = "K_LEFT", end_time = "58.80442" }, { begin_time = "59.28191", key_flag = "K_LEFT", end_time = "59.28191" }, { begin_time = "59.76064", key_flag = "K_LEFT", end_time = "60.71809" }, { begin_time = "61.03787", key_flag = "K_LEFT", end_time = "61.03787" }, { begin_time = "61.59549", key_flag = "K_LEFT", end_time = "61.59549" }, { begin_time = "61.75477", key_flag = "K_LEFT", end_time = "61.75477" }, { begin_time = "61.91489", key_flag = "K_LEFT", end_time = "61.91489" }, { begin_time = "62.31481", key_flag = "K_LEFT", end_time = "62.31481" }, { begin_time = "62.63298", key_flag = "K_LEFT", end_time = "62.63298" }, { begin_time = "62.95153", key_flag = "K_LEFT", end_time = "62.95153" }, { begin_time = "63.1117", key_flag = "K_LEFT", end_time = "63.1117" }, { begin_time = "63.75", key_flag = "K_LEFT", end_time = "63.75" }, { begin_time = "64.22553", key_flag = "K_LEFT", end_time = "64.22553" }, { begin_time = "64.54634", key_flag = "K_LEFT", end_time = "64.54634" }, { begin_time = "64.71071", key_flag = "K_LEFT", end_time = "64.71071" }, { begin_time = "64.86736", key_flag = "K_LEFT", end_time = "64.86736" }, { begin_time = "65.74468", key_flag = "K_LEFT", end_time = "65.74468" }, { begin_time = "66.06525", key_flag = "K_LEFT", end_time = "66.06525" }, { begin_time = "66.30267", key_flag = "K_LEFT", end_time = "66.30267" }, { begin_time = "66.62234", key_flag = "K_LEFT", end_time = "66.62234" }, { begin_time = "66.94149", key_flag = "K_LEFT", end_time = "66.94149" }, { begin_time = "67.26328", key_flag = "K_LEFT", end_time = "67.26328" }, { begin_time = "67.57839", key_flag = "K_LEFT", end_time = "67.57839" }, { begin_time = "67.89753", key_flag = "K_LEFT", end_time = "67.89753" }, { begin_time = "68.22042", key_flag = "K_LEFT", end_time = "68.22042" }, { begin_time = "68.53454", key_flag = "K_LEFT", end_time = "68.53454" }, { begin_time = "68.85311", key_flag = "K_LEFT", end_time = "68.85311" }, { begin_time = "69.33511", key_flag = "K_LEFT", end_time = "69.33511" }, { begin_time = "69.65426", key_flag = "K_LEFT", end_time = "69.65426" }, { begin_time = "70.13325", key_flag = "K_LEFT", end_time = "70.13325" }, { begin_time = "70.6117", key_flag = "K_LEFT", end_time = "70.6117" }, { begin_time = "71.72872", key_flag = "K_LEFT", end_time = "71.72872" }, { begin_time = "72.20827", key_flag = "K_LEFT", end_time = "72.20827" }, { begin_time = "72.52658", key_flag = "K_LEFT", end_time = "72.52658" }, { begin_time = "72.84845", key_flag = "K_LEFT", end_time = "72.84845" }, { begin_time = "73.32798", key_flag = "K_LEFT", end_time = "73.32798" }, { begin_time = "73.80319", key_flag = "K_LEFT", end_time = "73.80319" }, { begin_time = "73.96277", key_flag = "K_LEFT", end_time = "73.96277" }, { begin_time = "74.28394", key_flag = "K_LEFT", end_time = "74.28394" }, { begin_time = "74.60416", key_flag = "K_LEFT", end_time = "74.60416" }, { begin_time = "75.07979", key_flag = "K_LEFT", end_time = "75.07979" }, { begin_time = "75.39708", key_flag = "K_LEFT", end_time = "75.39708" }, { begin_time = "75.87766", key_flag = "K_LEFT", end_time = "75.87766" }, { begin_time = "76.19681", key_flag = "K_LEFT", end_time = "76.19681" }, { begin_time = "76.67553", key_flag = "K_LEFT", end_time = "78.59042" }, { begin_time = "79.22919", key_flag = "K_LEFT", end_time = "79.22919" }, { begin_time = "79.86692", key_flag = "K_LEFT", end_time = "79.86692" }, { begin_time = "80.50532", key_flag = "K_LEFT", end_time = "80.50532" }, { begin_time = "81.14424", key_flag = "K_LEFT", end_time = "81.14424" }, { begin_time = "81.4631", key_flag = "K_LEFT", end_time = "81.4631" }, { begin_time = "82.73936", key_flag = "K_LEFT", end_time = "82.73936" }, { begin_time = "83.37766", key_flag = "K_LEFT", end_time = "83.37766" }, { begin_time = "84.01721", key_flag = "K_LEFT", end_time = "84.01721" }, { begin_time = "84.73404", key_flag = "K_LEFT", end_time = "84.73404" }, { begin_time = "85.93085", key_flag = "K_LEFT", end_time = "85.93085" }, { begin_time = "86.56915", key_flag = "K_LEFT", end_time = "86.56915" }, { begin_time = "87.20745", key_flag = "K_LEFT", end_time = "87.20745" }, { begin_time = "87.36861", key_flag = "K_LEFT", end_time = "87.36861" }, { begin_time = "88.16769", key_flag = "K_LEFT", end_time = "88.16769" }, { begin_time = "88.3231", key_flag = "K_LEFT", end_time = "88.3231" }, { begin_time = "88.64178", key_flag = "K_LEFT", end_time = "88.64178" }, { begin_time = "88.96277", key_flag = "K_LEFT", end_time = "88.96277" }, { begin_time = "89.27973", key_flag = "K_LEFT", end_time = "89.27973" }, { begin_time = "89.92021", key_flag = "K_LEFT", end_time = "95.18617" } }, right_track = { { begin_time = "1.994378", key_flag = "K_RIGHT", end_time = "1.994378" }, { begin_time = "2.951511", key_flag = "K_RIGHT", end_time = "2.951511" }, { begin_time = "3.590425", key_flag = "K_RIGHT", end_time = "3.590425" }, { begin_time = "5.18617", key_flag = "K_RIGHT", end_time = "6.143617" }, { begin_time = "8.058511", key_flag = "K_RIGHT", end_time = "8.058511" }, { begin_time = "8.696809", key_flag = "K_RIGHT", end_time = "8.696809" }, { begin_time = "9.017004", key_flag = "K_RIGHT", end_time = "9.017004" }, { begin_time = "9.334105", key_flag = "K_RIGHT", end_time = "9.334105" }, { begin_time = "9.651847", key_flag = "K_RIGHT", end_time = "9.651847" }, { begin_time = "9.974732", key_flag = "K_RIGHT", end_time = "9.974732" }, { begin_time = "10.60411", key_flag = "K_RIGHT", end_time = "10.60411" }, { begin_time = "11.2488", key_flag = "K_RIGHT", end_time = "11.2488" }, { begin_time = "12.04626", key_flag = "K_RIGHT", end_time = "12.04626" }, { begin_time = "12.20745", key_flag = "K_RIGHT", end_time = "12.20745" }, { begin_time = "13.16489", key_flag = "K_RIGHT", end_time = "14.12234" }, { begin_time = "14.91967", key_flag = "K_RIGHT", end_time = "14.91967" }, { begin_time = "15.08232", key_flag = "K_RIGHT", end_time = "15.08232" }, { begin_time = "15.55851", key_flag = "K_RIGHT", end_time = "15.55851" }, { begin_time = "15.71809", key_flag = "K_RIGHT", end_time = "15.71809" }, { begin_time = "16.03723", key_flag = "K_RIGHT", end_time = "17.31383" }, { begin_time = "18.43085", key_flag = "K_RIGHT", end_time = "18.43085" }, { begin_time = "18.5893", key_flag = "K_RIGHT", end_time = "18.5893" }, { begin_time = "20.34451", key_flag = "K_RIGHT", end_time = "20.34451" }, { begin_time = "20.50716", key_flag = "K_RIGHT", end_time = "20.50716" }, { begin_time = "20.66799", key_flag = "K_RIGHT", end_time = "20.66799" }, { begin_time = "20.98415", key_flag = "K_RIGHT", end_time = "20.98415" }, { begin_time = "22.58104", key_flag = "K_RIGHT", end_time = "22.58104" }, { begin_time = "22.74004", key_flag = "K_RIGHT", end_time = "22.74004" }, { begin_time = "23.53804", key_flag = "K_RIGHT", end_time = "23.53804" }, { begin_time = "23.69681", key_flag = "K_RIGHT", end_time = "24.33511" }, { begin_time = "24.81366", key_flag = "K_RIGHT", end_time = "24.81366" }, { begin_time = "25.13348", key_flag = "K_RIGHT", end_time = "25.13348" }, { begin_time = "25.45213", key_flag = "K_RIGHT", end_time = "25.45213" }, { begin_time = "26.08867", key_flag = "K_RIGHT", end_time = "26.08867" }, { begin_time = "26.40753", key_flag = "K_RIGHT", end_time = "26.40753" }, { begin_time = "27.52659", key_flag = "K_RIGHT", end_time = "27.52659" }, { begin_time = "29.28192", key_flag = "K_RIGHT", end_time = "29.28192" }, { begin_time = "29.60106", key_flag = "K_RIGHT", end_time = "29.60106" }, { begin_time = "29.92021", key_flag = "K_RIGHT", end_time = "29.92021" }, { begin_time = "32.15363", key_flag = "K_RIGHT", end_time = "32.15363" }, { begin_time = "32.63298", key_flag = "K_RIGHT", end_time = "32.63298" }, { begin_time = "33.90696", key_flag = "K_RIGHT", end_time = "33.90696" }, { begin_time = "34.06915", key_flag = "K_RIGHT", end_time = "34.70745" }, { begin_time = "37.42021", key_flag = "K_RIGHT", end_time = "37.42021" }, { begin_time = "37.74196", key_flag = "K_RIGHT", end_time = "37.74196" }, { begin_time = "38.37865", key_flag = "K_RIGHT", end_time = "38.37865" }, { begin_time = "40.29596", key_flag = "K_RIGHT", end_time = "40.29596" }, { begin_time = "40.6117", key_flag = "K_RIGHT", end_time = "40.6117" }, { begin_time = "41.72673", key_flag = "K_RIGHT", end_time = "41.72673" }, { begin_time = "43.00595", key_flag = "K_RIGHT", end_time = "43.00595" }, { begin_time = "43.16677", key_flag = "K_RIGHT", end_time = "43.16677" }, { begin_time = "44.12234", key_flag = "K_RIGHT", end_time = "44.60106" }, { begin_time = "45.40079", key_flag = "K_RIGHT", end_time = "45.40079" }, { begin_time = "46.35518", key_flag = "K_RIGHT", end_time = "46.35518" }, { begin_time = "46.67741", key_flag = "K_RIGHT", end_time = "46.67741" }, { begin_time = "47.63106", key_flag = "K_RIGHT", end_time = "47.63106" }, { begin_time = "47.79361", key_flag = "K_RIGHT", end_time = "47.79361" }, { begin_time = "48.90957", key_flag = "K_RIGHT", end_time = "48.90957" }, { begin_time = "49.2307", key_flag = "K_RIGHT", end_time = "49.2307" }, { begin_time = "50.82485", key_flag = "K_RIGHT", end_time = "50.82485" }, { begin_time = "51.14362", key_flag = "K_RIGHT", end_time = "51.14362" }, { begin_time = "51.94149", key_flag = "K_RIGHT", end_time = "51.94149" }, { begin_time = "52.26261", key_flag = "K_RIGHT", end_time = "52.26261" }, { begin_time = "52.58243", key_flag = "K_RIGHT", end_time = "52.58243" }, { begin_time = "52.73936", key_flag = "K_RIGHT", end_time = "52.73936" }, { begin_time = "52.89893", key_flag = "K_RIGHT", end_time = "52.89893" }, { begin_time = "53.54532", key_flag = "K_RIGHT", end_time = "53.54532" }, { begin_time = "53.85913", key_flag = "K_RIGHT", end_time = "53.85913" }, { begin_time = "54.17294", key_flag = "K_RIGHT", end_time = "54.17294" }, { begin_time = "55.45213", key_flag = "K_RIGHT", end_time = "55.45213" }, { begin_time = "55.77128", key_flag = "K_RIGHT", end_time = "55.77128" }, { begin_time = "56.56975", key_flag = "K_RIGHT", end_time = "56.56975" }, { begin_time = "57.37003", key_flag = "K_RIGHT", end_time = "57.37003" }, { begin_time = "57.68513", key_flag = "K_RIGHT", end_time = "57.68513" }, { begin_time = "58.3256", key_flag = "K_RIGHT", end_time = "58.3256" }, { begin_time = "59.12159", key_flag = "K_RIGHT", end_time = "59.12159" }, { begin_time = "59.60224", key_flag = "K_RIGHT", end_time = "59.60224" }, { begin_time = "61.35276", key_flag = "K_RIGHT", end_time = "61.35276" }, { begin_time = "62.47539", key_flag = "K_RIGHT", end_time = "62.47539" }, { begin_time = "62.79156", key_flag = "K_RIGHT", end_time = "62.79156" }, { begin_time = "64.07376", key_flag = "K_RIGHT", end_time = "64.07376" }, { begin_time = "64.3881", key_flag = "K_RIGHT", end_time = "64.3881" }, { begin_time = "65.0285", key_flag = "K_RIGHT", end_time = "65.0285" }, { begin_time = "65.34347", key_flag = "K_RIGHT", end_time = "65.34347" }, { begin_time = "65.90426", key_flag = "K_RIGHT", end_time = "65.90426" }, { begin_time = "66.22623", key_flag = "K_RIGHT", end_time = "66.22623" }, { begin_time = "67.10267", key_flag = "K_RIGHT", end_time = "67.10267" }, { begin_time = "67.42067", key_flag = "K_RIGHT", end_time = "67.42067" }, { begin_time = "68.70007", key_flag = "K_RIGHT", end_time = "68.70007" }, { begin_time = "69.97269", key_flag = "K_RIGHT", end_time = "69.97269" }, { begin_time = "71.88454", key_flag = "K_RIGHT", end_time = "71.88454" }, { begin_time = "73.16558", key_flag = "K_RIGHT", end_time = "73.16558" }, { begin_time = "73.48547", key_flag = "K_RIGHT", end_time = "73.48547" }, { begin_time = "74.43978", key_flag = "K_RIGHT", end_time = "74.43978" }, { begin_time = "74.76064", key_flag = "K_RIGHT", end_time = "74.76064" }, { begin_time = "75.23808", key_flag = "K_RIGHT", end_time = "75.23808" }, { begin_time = "76.03533", key_flag = "K_RIGHT", end_time = "76.03533" }, { begin_time = "76.35881", key_flag = "K_RIGHT", end_time = "76.35881" }, { begin_time = "76.99643", key_flag = "K_RIGHT", end_time = "76.99643" }, { begin_time = "77.31442", key_flag = "K_RIGHT", end_time = "77.31442" }, { begin_time = "77.63425", key_flag = "K_RIGHT", end_time = "77.63425" }, { begin_time = "77.95213", key_flag = "K_RIGHT", end_time = "77.95213" }, { begin_time = "78.2711", key_flag = "K_RIGHT", end_time = "78.2711" }, { begin_time = "78.59132", key_flag = "K_RIGHT", end_time = "78.59132" }, { begin_time = "78.91279", key_flag = "K_RIGHT", end_time = "78.91279" }, { begin_time = "79.54695", key_flag = "K_RIGHT", end_time = "79.54695" }, { begin_time = "80.1852", key_flag = "K_RIGHT", end_time = "80.1852" }, { begin_time = "80.82666", key_flag = "K_RIGHT", end_time = "80.82666" }, { begin_time = "81.78191", key_flag = "K_RIGHT", end_time = "81.78191" }, { begin_time = "82.10434", key_flag = "K_RIGHT", end_time = "82.10434" }, { begin_time = "83.06033", key_flag = "K_RIGHT", end_time = "83.06033" }, { begin_time = "85.29256", key_flag = "K_RIGHT", end_time = "85.29256" }, { begin_time = "86.25105", key_flag = "K_RIGHT", end_time = "86.25105" }, { begin_time = "86.88703", key_flag = "K_RIGHT", end_time = "86.88703" }, { begin_time = "87.68658", key_flag = "K_RIGHT", end_time = "87.68658" }, { begin_time = "87.8475", key_flag = "K_RIGHT", end_time = "87.8475" }, { begin_time = "88.48404", key_flag = "K_RIGHT", end_time = "88.48404" }, { begin_time = "88.80318", key_flag = "K_RIGHT", end_time = "88.80318" }, { begin_time = "89.11966", key_flag = "K_RIGHT", end_time = "89.11966" }, { begin_time = "89.44149", key_flag = "K_RIGHT", end_time = "89.44149" } } }
--[[ File Name : dataloader.lua Created By : Chen Guanying ([email protected]) Creation Date : [2018-03-03 20:02] Last Modified : [2018-03-03 20:02] Description : --]] -- Copyright (c) 2016, Facebook, Inc. -- All rights reserved. -- -- This source code is licensed under the BSD-style license found in the -- LICENSE file in the root directory of this source tree. An additional grant -- of patent rights can be found in the PATENTS file in the same directory. -- -- Multi-threaded data loader -- local Threads = require 'threads' Threads.serialization('threads.sharedserialize') local M = {} local DataLoader = torch.class('TOM.DataLoader', M) function DataLoader.create(opt) local loaders = {} local datasets datasets = require 'datasets/TOMDataset' for i, split in ipairs{'train', 'val'} do local dataset = datasets(opt, split) loaders[i] = M.DataLoader(dataset, opt, split) end return table.unpack(loaders) end function DataLoader:__init(dataset, opt, split) local manualSeed = opt.manualSeed local function init() require('datasets/' .. opt.dataset) end local function main(idx) if manualSeed ~= 0 then torch.manualSeed(manualSeed + idx) end torch.setnumthreads(1) _G.dataset = dataset _G.preprocess = dataset:preprocess() return dataset:size() end local threads, sizes = Threads(opt.nThreads, init, main) self.threads = threads self.__size = sizes[1][1] self.batchSize = math.floor(opt.batchSize) self.in_trimap = opt.in_trimap self.split = split end function DataLoader:batch_size() return math.ceil(self.__size / self.batchSize) end function DataLoader:size() return self.__size end function DataLoader:run(split, maxNumber) local split = split or 'train' local threads = self.threads local in_trimap = self.in_trimap local fullSize, batchSize = self.__size, self.batchSize local size = (maxNumber ~= nil and maxNumber > 0) and math.min(maxNumber, fullSize) or fullSize local perm = (split == 'val') and torch.range(1, size) or torch.randperm(size) print(string.format('[Dataloader run] split: %s, size: %d/%d ', split, size, fullSize)) local idx, sample = 1, nil local function enqueue() while idx <= size and threads:acceptsjob() do local indices = perm:narrow(1, idx, math.min(batchSize, size - idx + 1)) threads:addjob( function(indices) local sz = indices:size(1) local batch, masks, rhos, flows, trimaps, imageSize for i, idx in ipairs(indices:totable()) do local sample = _G.dataset:get(idx) local input = sample.input if not batch then imageSize = input:size():totable() batch = torch.FloatTensor(sz, table.unpack(imageSize)) masks = torch.FloatTensor(sz, input:size()[2], input:size()[3]) rhos = torch.FloatTensor(sz, input:size()[2], input:size()[3]) flows = torch.FloatTensor(sz, 3, input:size()[2], input:size()[3]) if in_trimap then trimaps = torch.FloatTensor(sz, input:size()[2], input:size()[3]) end end batch[i]:copy(input) masks[i]:copy(sample.mask) rhos[i]:copy(sample.rho) flows[i]:copy(sample.flow) if in_trimap then trimaps[i]:copy(sample.trimap) end end collectgarbage() local batch_sample = { input = batch, masks = masks, rhos = rhos, flows = flows } if in_trimap then batch_sample.trimaps = trimaps end return batch_sample end, function(_sample_) sample = _sample_ end, indices ) idx = idx + batchSize end end local n = 0 local function loop() enqueue() if not threads:hasjob() then return nil end threads:dojob() if threads:haserror() then threads:synchronize() end enqueue() n = n + 1 return n, sample end return loop end return M.DataLoader
-- Copyright (c) 2021 Trevor Redfern -- -- This software is released under the MIT License. -- https://opensource.org/licenses/MIT return { welcome = "{color:msgHighlight}Welcome!{color:msgText} Time to play!" }
return {[1]={lang={English={[1]={[1]={k="milliseconds_to_seconds",v=1},limit={[1]={[1]=1,[2]="#"}},text="Curse lasts %1% seconds"}}},name="buff_duration",stats={[1]="buff_effect_duration"}},[2]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed Normal and Magic Enemies have %1%%% more Action Speed"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed Normal and Magic Enemies have %1%%% less Action Speed"}}},name="action_speed_reduction",stats={[1]="temporal_chains_action_speed_+%_final"}},[3]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Other effects on Cursed enemies expire %1%%% faster"},[2]={[1]={k="negate",v=1},[2]={k="reminderstring",v="ReminderTextSlowTimeEffects"},limit={[1]={[1]="#",[2]=-1}},text="Other effects on Cursed enemies expire %1%%% slower"}}},name="buff_time_passed_reduction",stats={[1]="buff_time_passed_+%_other_than_temporal_chains"}},[4]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies have %1$+d%% to Elemental Resistances"}}},name="elemental_resist",stats={[1]="base_resist_all_elements_%"}},[5]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies have %1$+d%% to Fire Resistance"}}},name="fire_resist",stats={[1]="base_fire_damage_resistance_%"}},[6]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies have %1$+d%% to Cold Resistance"}}},name="cold_resist",stats={[1]="base_cold_damage_resistance_%"}},[7]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies have %1$+d%% to Lightning Resistance"}}},name="lightning_resist",stats={[1]="base_lightning_damage_resistance_%"}},[8]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies have %1$+d%% to Chaos Resistance"}}},name="chaos_res",stats={[1]="base_chaos_damage_resistance_%"}},[9]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have %1$+d%% chance to be Frozen by Cold Damage"}}},name="chance_to_be_frozen",stats={[1]="chance_to_be_frozen_%"}},[10]={lang={English={[1]={[1]={k="reminderstring",v="ReminderTextIgnite"},limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have %1$+d%% chance to be Ignited by Fire Damage"}}},name="chance_to_be_ignited",stats={[1]="chance_to_be_ignited_%"}},[11]={lang={English={[1]={[1]={k="reminderstring",v="ReminderTextShock"},limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have %1$+d%% chance to be Shocked by Lightning Damage"}}},name="chance_to_be_shocked",stats={[1]="chance_to_be_shocked_%"}},[12]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies grant %1%%% increased Flask Charges"}}},name="monster_flask_charges_incr",stats={[1]="monster_slain_flask_charges_granted_+%"}},[13]={lang={English={[1]={[1]={k="divide_by_one_hundred",v=1},[2]={k="reminderstring",v="ReminderTextLifeLeech"},limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies grant %1%%% Life Leech when Hit by Attacks"}}},name="life_leeched_when_hit_by_attack",stats={[1]="life_leech_on_any_damage_when_hit_by_attack_permyriad"}},[14]={lang={English={[1]={[1]={k="divide_by_one_hundred",v=1},[2]={k="reminderstring",v="ReminderTextLifeLeech"},limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies grant %1%%% Life Leech when Hit"}}},name="life_leeched_when_hit",stats={[1]="life_leech_on_any_damage_when_hit_permyriad"}},[15]={lang={English={[1]={[1]={k="divide_by_one_hundred",v=1},[2]={k="reminderstring",v="ReminderTextManaLeech"},limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies grant %1%%% Mana Leech when Hit by Attacks"}}},name="mana_leeched_when_hit_by_attack",stats={[1]="mana_leech_on_any_damage_when_hit_by_attack_permyriad"}},[16]={lang={English={[1]={[1]={k="divide_by_one_hundred",v=1},[2]={k="reminderstring",v="ReminderTextManaLeech"},limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies grant %1%%% Mana Leech when Hit"}}},name="mana_leeched_when_hit",stats={[1]="mana_leech_on_any_damage_when_hit_permyriad"}},[17]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have a %1%%% chance to grant an Endurance Charge when slain"}}},name="chance_to_grant_endurance_charge_on_death",stats={[1]="chance_to_grant_endurance_charge_on_death_%"}},[18]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have a %1%%% chance to grant a Frenzy Charge when slain"}}},name="chance_to_grant_frenzy_charge_on_death",stats={[1]="chance_to_grant_frenzy_charge_on_death_%"}},[19]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have a %1%%% chance to grant a Power Charge when slain"}}},name="chance_to_grant_power_charge_on_death",stats={[1]="chance_to_grant_power_charge_on_death_%"}},[20]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Reflects %1%%% of Physical Damage dealt by Cursed Normal Enemies"}}},name="punishment_normal",stats={[1]="punishment_physical_damage_%_reflected_for_normal_monsters"}},[21]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Reflects %1%%% of Physical Damage dealt by Cursed Magic Enemies"}}},name="punishment_magic",stats={[1]="punishment_physical_damage_%_reflected_for_magic_monsters"}},[22]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Reflects %1%%% of Physical Damage dealt by Cursed Rare Enemies"}}},name="punishment_rare",stats={[1]="punishment_physical_damage_%_reflected_for_rare_monsters"}},[23]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Reflects %1%%% of Physical Damage dealt by Cursed Unique Enemies"}}},name="punishment_unique",stats={[1]="punishment_physical_damage_%_reflected_for_unique_monsters"}},[24]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have %1%%% increased Accuracy Rating"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed enemies have %1%%% reduced Accuracy Rating"}}},name="accuracy_rating_incr",stats={[1]="accuracy_rating_+%"}},[25]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have %1%%% increased Critical Strike Chance"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed enemies have %1%%% reduced Critical Strike Chance"}}},name="critical_strike_chance_incr",stats={[1]="critical_strike_chance_+%"}},[26]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies have %1$+d%% to Critical Strike Multiplier"}}},name="critical_strike_multiplier_incr",stats={[1]="base_critical_strike_multiplier_+"}},[27]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed Normal or Magic enemies deal %1%%% more Damage"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed Normal or Magic enemies deal %1%%% less Damage"}}},name="enfeeble_damage_scale",stats={[1]="enfeeble_damage_+%_final"}},[28]={lang={English={[1]={[1]={k="divide_by_one_hundred",v=1},limit={[1]={[1]="#",[2]="#"}},text="Hits against Cursed Enemies have %1$+d%% to Critical Strike Chance"}}},name="chance_to_take_critical_strike",stats={[1]="enemy_additional_critical_strike_chance_against_self"}},[29]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies take %1%%% reduced Extra Damage from Critical Strikes"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed enemies take %1%%% increased Extra Damage from Critical Strikes"}}},name="self_critical_strike_multiplier_reduction",stats={[1]="base_self_critical_strike_multiplier_-%"}},[30]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Projectiles Pierce Cursed Enemies"}}},name="be_pierced",stats={[1]="projectiles_always_pierce_you"}},[31]={lang={English={[1]={[1]={k="reminderstring",v="ReminderTextKnockback"},limit={[1]={[1]=1,[2]="#"}},text="Hits on Cursed Enemies have an additional %1%%% chance to Knockback"}}},name="chance_to_be_knocked_back",stats={[1]="chance_to_be_knocked_back_%"}},[32]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have %1%%% more Evasion"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed enemies have %1%%% less Evasion"}}},name="evasion_rating_poachers_mark",stats={[1]="evasion_rating_+%_final_from_poachers_mark"}},[33]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies take %1%%% increased Damage from Projectile Hits"}}},name="projectile_damage_taken_incr",stats={[1]="projectile_damage_taken_+%"}},[34]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have an additional %1%%% chance to be Stunned"}}},name="chance_to_be_stunned",stats={[1]="chance_to_be_stunned_%"}},[35]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies have %1%%% increased Stun and Block Recovery"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed enemies have %1%%% reduced Stun and Block Recovery"}}},name="stun_recovery_incr",stats={[1]="base_stun_recovery_+%"}},[36]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies take %1%%% increased Physical Damage"}}},name="physical_damage_taken_incr",stats={[1]="physical_damage_taken_+%"}},[37]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies take %1%%% increased Damage from Damage Over Time effects"}}},name="degen_effect_incr",stats={[1]="degen_effect_+%"}},[38]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Ignite on Cursed enemies has %1%%% reduced Duration"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Ignite on Cursed enemies has %1%%% increased Duration"}}},name="self_burn_duration",stats={[1]="base_self_ignite_duration_-%"}},[39]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Freezes on Cursed enemies have %1%%% reduced Duration"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Freezes on Cursed enemies have %1%%% increased Duration"}}},name="self_freeze_duration",stats={[1]="base_self_freeze_duration_-%"}},[40]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Shocks on Cursed enemies have %1%%% reduced Duration"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Shocks on Cursed enemies have %1%%% increased Duration"}}},name="self_shock_duration",stats={[1]="base_self_shock_duration_-%"}},[41]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="You cannot Cast this Curse directly"}}},name="cannot_cast_curses",stats={[1]="cannot_cast_curses"}},[42]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies grant %1% Life when Hit by Attacks"}}},name="life_granted_when_hit",stats={[1]="life_granted_when_hit_by_attacks"}},[43]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies grant %1% Mana when Hit by Attacks"}}},name="mana_granted_when_hit",stats={[1]="mana_granted_when_hit_by_attacks"}},[44]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies grant %1% Life when Killed"}}},name="life_granted_when_killed",stats={[1]="life_granted_when_killed"}},[45]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies grant %1% Mana when Killed"}}},name="mana_granted_when_killed",stats={[1]="mana_granted_when_killed"}},[46]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="%1%%% increased Area of Effect of Curses"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="%1%%% reduced Area of Effect of Curses"}}},name="curse_area",stats={[1]="curse_area_of_effect_+%"}},[47]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="This Curse is Cast as an Aura applying to nearby Enemies"}}},name="curse_aura",stats={[1]="curse_apply_as_aura"}},[48]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"}},text="Cursed enemies have %1$+d%% to Physical Damage Reduction"}}},name="phys_reduction",stats={[1]="base_additional_physical_damage_reduction_%"}},[49]={lang={English={[1]={[1]={k="reminderstring",v="ReminderTextMaim"},limit={[1]={[1]=1,[2]="#"}},text="Attack Hits have %1%%% chance to Maim Cursed Enemies for 4 seconds"}}},name="maim_when_hit_chance",stats={[1]="chance_to_be_maimed_when_hit_%"}},[50]={lang={English={[1]={[1]={k="divide_by_one_hundred",v=1},[2]={k="reminderstring",v="ReminderTextEnergyShieldLeech"},limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies grant %1%%% Energy Shield Leech when Hit"}}},name="energy_shield_leeched_when_hit",stats={[1]="energy_shield_leech_on_any_damage_when_hit_permyriad"}},[51]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed Rare or Unique enemies deal %1%%% more Damage"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed Rare or Unique enemies deal %1%%% less Damage"}}},name="enfeeble_damage_scale_rare_or_unique",stats={[1]="enfeeble_damage_+%_vs_rare_or_unique_final"}},[52]={lang={English={[1]={limit={[1]={[1]="#",[2]="#"},[2]={[1]="#",[2]="#"}},text="Adds %1% to %2% Chaos Damage to Hits against Cursed Enemies"}}},name="chaos_weakness_damage",stats={[1]="minimum_added_chaos_damage_taken",[2]="maximum_added_chaos_damage_taken"}},[53]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed enemies take %1%%% increased Physical Damage from Damage Over Time"},[2]={limit={[1]={[1]="#",[2]=-1}},text="Cursed enemies take %1%%% increased Physical Damage from Damage Over Time"}}},name="physical_dot_taken_incr",stats={[1]="base_physical_damage_over_time_taken_+%"}},[54]={lang={English={[1]={[1]={k="reminderstring",v="ReminderTextBleeding"},limit={[1]={[1]=1,[2]="#"}},text="Cursed Enemies have %1%%% chance to Bleed when Hit by Attacks"}}},name="bleed_when_hit_chance",stats={[1]="receive_bleeding_chance_%_when_hit_by_attack"}},[55]={lang={English={[1]={limit={[1]={[1]=1,[2]="#"}},text="Cursed Rare and Unique Enemies have %1%%% more Action Speed"},[2]={[1]={k="negate",v=1},limit={[1]={[1]="#",[2]=-1}},text="Cursed Rare and Unique Enemies have %1%%% less Action Speed"}}},name="action_speed_reduction_rare_or_unique",stats={[1]="temporal_chains_action_speed_+%_vs_rare_or_unique_final"}},["accuracy_rating_+%"]=24,["base_additional_physical_damage_reduction_%"]=48,["base_chaos_damage_resistance_%"]=8,["base_cold_damage_resistance_%"]=6,["base_critical_strike_multiplier_+"]=26,["base_fire_damage_resistance_%"]=5,["base_lightning_damage_resistance_%"]=7,["base_physical_damage_over_time_taken_+%"]=53,["base_resist_all_elements_%"]=4,["base_self_critical_strike_multiplier_-%"]=29,["base_self_freeze_duration_-%"]=39,["base_self_ignite_duration_-%"]=38,["base_self_shock_duration_-%"]=40,["base_stun_recovery_+%"]=35,["buff_effect_duration"]=1,["buff_time_passed_+%_other_than_temporal_chains"]=3,["cannot_cast_curses"]=41,["chance_to_be_frozen_%"]=9,["chance_to_be_ignited_%"]=10,["chance_to_be_knocked_back_%"]=31,["chance_to_be_maimed_when_hit_%"]=49,["chance_to_be_shocked_%"]=11,["chance_to_be_stunned_%"]=34,["chance_to_grant_endurance_charge_on_death_%"]=17,["chance_to_grant_frenzy_charge_on_death_%"]=18,["chance_to_grant_power_charge_on_death_%"]=19,["critical_strike_chance_+%"]=25,["curse_apply_as_aura"]=47,["curse_area_of_effect_+%"]=46,["degen_effect_+%"]=37,["enemy_additional_critical_strike_chance_against_self"]=28,["energy_shield_leech_on_any_damage_when_hit_permyriad"]=50,["enfeeble_damage_+%_final"]=27,["enfeeble_damage_+%_vs_rare_or_unique_final"]=51,["evasion_rating_+%_final_from_poachers_mark"]=32,["life_granted_when_hit_by_attacks"]=42,["life_granted_when_killed"]=44,["life_leech_on_any_damage_when_hit_by_attack_permyriad"]=13,["life_leech_on_any_damage_when_hit_permyriad"]=14,["mana_granted_when_hit_by_attacks"]=43,["mana_granted_when_killed"]=45,["mana_leech_on_any_damage_when_hit_by_attack_permyriad"]=15,["mana_leech_on_any_damage_when_hit_permyriad"]=16,["maximum_added_chaos_damage_taken"]=52,["minimum_added_chaos_damage_taken"]=52,["monster_slain_flask_charges_granted_+%"]=12,parent="skill_stat_descriptions",["physical_damage_taken_+%"]=36,["projectile_damage_taken_+%"]=33,["projectiles_always_pierce_you"]=30,["punishment_physical_damage_%_reflected_for_magic_monsters"]=21,["punishment_physical_damage_%_reflected_for_normal_monsters"]=20,["punishment_physical_damage_%_reflected_for_rare_monsters"]=22,["punishment_physical_damage_%_reflected_for_unique_monsters"]=23,["receive_bleeding_chance_%_when_hit_by_attack"]=54,["temporal_chains_action_speed_+%_final"]=2,["temporal_chains_action_speed_+%_vs_rare_or_unique_final"]=55}
local utils = require('utils.core') local M = {} local html = require('languages.html') local css = require('languages.css') local yaml = require('languages.yaml') local svelte = require('languages.svelte') local python = require('languages.python') local javascript = require('languages.javascript') local java = require('languages.java') local php = require('languages.php') local markdown = require('languages.markdown') local xml = require('languages.xml') local go = require('languages.go') local lua = require('languages.lua') local tex = require('languages.tex') local rust = require('languages.rust') local json = require('languages.json') local docker = require('languages.docker') local formatters = { javascript = javascript.all_format, javascriptreact = javascript.all_format, typescript = javascript.all_format, typescriptreact = javascript.all_format, svelte = svelte.all_format, go = go.all_format, rust = rust.all_format, lua = lua.all_format, java = java.all_format, php = php.all_format, python = python.all_format, tex = tex.all_format, xml = xml.all_format, html = html.all_format, css = css.all_format, yaml = css.all_format, markdown = markdown.all_format, json = json.all_format, dockerfile = docker.all_format, } M.default_formatter = { javascript = javascript.default_format, javascriptreact = javascript.default_format, typescript = javascript.default_format, typescriptreact = javascript.default_format, svelte = svelte.default_format, go = go.default_format, rust = rust.default_format, lua = lua.default_format, java = java.default_format, php = php.default_format, python = python.default_format, tex = tex.default_format, xml = xml.default_format, html = html.default_format, css = css.default_format, yaml = yaml.default_format, markdown = markdown.default_format, json = json.default_format, dockerfile = docker.default_format, } M.choose_formatter = function() local fileType = vim.bo.filetype local all_formatters = formatters[fileType] local store_formatters = {} local count = 0 for key, _ in pairs(all_formatters) do count = count + 1 -- table.insert(store_formatters, key) store_formatters[#store_formatters + 1] = key print('[' .. count .. '] ' .. key) end if count > 1 then local option = vim.fn.input('Choose your formmatter: ') M.default_formatter[fileType] = store_formatters[tonumber(option)] end end M.formatter_status = function() local fileType = vim.bo.filetype if M.default_formatter[fileType] then return formatters[fileType][M.default_formatter[fileType]] .. ' ' else return '' end end -- Credit https://github.com/terrortylor/neovim-environment/blob/main/lua/config/lsp/funcs.lua#L11 M.format = function() local clients = vim.lsp.buf_get_clients(0) local fileType = vim.bo.filetype local code_formatter = M.default_formatter[fileType] if utils.tablelength(clients) > 1 then -- check if multiple clients, and if efm is setup for _, c1 in pairs(clients) do if c1.name == code_formatter then c1.resolved_capabilities.document_formatting = true -- if efm then disable others for _, c2 in pairs(clients) do -- print(c2.name, c2.resolved_capabilities.document_formatting) if c2.name ~= code_formatter then c2.resolved_capabilities.document_formatting = false end end -- no need to contunue first loop break end end end vim.lsp.buf.formatting_sync(nil, 1000) end M.range_format = function() local vim_mode = vim.api.nvim_eval('mode()') if vim_mode == 'v' then local start_position = vim.api.nvim_eval('getpos("v")') local end_position = vim.api.nvim_eval('getpos(".")') vim.lsp.buf.range_formatting({}, { start_position[2], 0 }, { end_position[2], 0 }) end end return M
--.------------------------------------------------ --. rules3837.lua (Version:1.0) -- --. Applies rules from core 38 to core 37 -- --.------------------------------------------------ --.-------------------- --. Prefix functions -- --.-------------------- module("CoreRules", package.seeall) function InitRules() local currentRules = { SPLIT_DEF = { insert = { lineFilter = filter1 ,removeColumns = { PRINT_LANDSCAPE = 1 } ,addColumns = { NEW_COL1 = "'ola'", NEW_COL2 = calculate1 } ,replaceValue = { PK_NAME = calculate2 } } ,update = { lineFilter = filter2 ,removeColumns = { PRINT_LANDSCAPE = 1 } ,addColumns = { NEW_COL1 = "'ola'", NEW_COL2 = calculate1 } ,replaceValue = { PK_NAME = calculate2 } ,whereProcess = whereFunc2 } ,delete = { lineFilter = filter3 ,whereProcess = whereFunc3 } } } return currentRules end function calculate1(Fields) return "'novo campo directo'" end function calculate2(Fields) return "'replace calculado'" end function filter1(Fields, Where) return false end function filter2(Fields, Where) return true end function filter3(Fields, Where) return false end function whereFunc2(Fields, Where) return "new where string" end function whereFunc3(Fields, Where) return "new where string" end
--[[ For quick-cocos2d-x SocketTCP lua @author zrong (zengrong.net) Creation: 2013-11-12 Last Modification: 2013-12-05 @see http://cn.quick-x.com/?topic=quickkydsocketfzl ]] local SOCKET_TICK_TIME = 0.1 -- check socket data interval local SOCKET_RECONNECT_TIME = 5 -- socket reconnect try interval local SOCKET_CONNECT_FAIL_TIMEOUT = 3 -- socket failure timeout local STATUS_CLOSED = "closed" local STATUS_NOT_CONNECTED = "Socket is not connected" local STATUS_ALREADY_CONNECTED = "already connected" local STATUS_ALREADY_IN_PROGRESS = "Operation already in progress" local STATUS_TIMEOUT = "timeout" local scheduler = require("framework.scheduler") local socket = require "socket" local SocketTCP = class("SocketTCP") SocketTCP.EVENT_DATA = "SOCKET_TCP_DATA" SocketTCP.EVENT_CLOSE = "SOCKET_TCP_CLOSE" SocketTCP.EVENT_CLOSED = "SOCKET_TCP_CLOSED" SocketTCP.EVENT_CONNECTED = "SOCKET_TCP_CONNECTED" SocketTCP.EVENT_CONNECT_FAILURE = "SOCKET_TCP_CONNECT_FAILURE" SocketTCP._VERSION = socket._VERSION SocketTCP._DEBUG = socket._DEBUG function SocketTCP.getTime() return socket.gettime() end function SocketTCP:ctor(__host, __port, __retryConnectWhenFailure) cc(self):addComponent("components.behavior.EventProtocol"):exportMethods() self.host = __host self.port = __port self.tickScheduler = nil -- timer for data self.reconnectScheduler = nil -- timer for reconnect self.connectTimeTickScheduler = nil -- timer for connect timeout self.name = 'SocketTCP' self.tcp = nil self.isRetryConnect = __retryConnectWhenFailure self.isConnected = false end function SocketTCP:setName( __name ) self.name = __name return self end function SocketTCP:setTickTime(__time) SOCKET_TICK_TIME = __time return self end function SocketTCP:setReconnTime(__time) SOCKET_RECONNECT_TIME = __time return self end function SocketTCP:setConnFailTime(__time) SOCKET_CONNECT_FAIL_TIMEOUT = __time return self end function SocketTCP:connect(__host, __port, __retryConnectWhenFailure) if __host then self.host = __host end if __port then self.port = __port end if __retryConnectWhenFailure ~= nil then self.isRetryConnect = __retryConnectWhenFailure end assert(self.host or self.port, "Host and port are necessary!") --printInfo("%s.connect(%s, %d)", self.name, self.host, self.port) self.tcp = socket.tcp() self.tcp:settimeout(0) local function __checkConnect() local __succ = self:_connect() if __succ then self:_onConnected() end return __succ end if not __checkConnect() then -- check whether connection is success -- the connection is failure if socket isn't connected after SOCKET_CONNECT_FAIL_TIMEOUT seconds local __connectTimeTick = function () --printInfo("%s.connectTimeTick", self.name) if self.isConnected then return end self.waitConnect = self.waitConnect or 0 self.waitConnect = self.waitConnect + SOCKET_TICK_TIME if self.waitConnect >= SOCKET_CONNECT_FAIL_TIMEOUT then self.waitConnect = nil self:close() self:_connectFailure() end __checkConnect() end self.connectTimeTickScheduler = scheduler.scheduleGlobal(__connectTimeTick, SOCKET_TICK_TIME) end end function SocketTCP:send(__data) assert(self.isConnected, self.name .. " is not connected.") return self.tcp:send(__data); end function SocketTCP:close( ... ) --printInfo("%s.close", self.name) self.tcp:close(); if self.connectTimeTickScheduler then scheduler.unscheduleGlobal(self.connectTimeTickScheduler) end if self.tickScheduler then scheduler.unscheduleGlobal(self.tickScheduler) end self:dispatchEvent({name=SocketTCP.EVENT_CLOSE}) end -- disconnect on user's own initiative. function SocketTCP:disconnect() self:_disconnect() self.isRetryConnect = false -- initiative to disconnect, no reconnect. end -------------------- -- private -------------------- --- When connect a connected socket server, it will return "already connected" -- @see: http://lua-users.org/lists/lua-l/2009-10/msg00584.html function SocketTCP:_connect() local __succ, __status = self.tcp:connect(self.host, self.port) -- print("SocketTCP._connect:", __succ, __status) return __succ == 1 or __status == STATUS_ALREADY_CONNECTED end function SocketTCP:_disconnect() self.isConnected = false self.tcp:shutdown() self:dispatchEvent({name=SocketTCP.EVENT_CLOSED}) end function SocketTCP:_onDisconnect() --printInfo("%s._onDisConnect", self.name); self.isConnected = false self:dispatchEvent({name=SocketTCP.EVENT_CLOSED}) self:_reconnect(); end -- connecte success, cancel the connection timerout timer function SocketTCP:_onConnected() --printInfo("%s._onConnectd", self.name) self.isConnected = true self:dispatchEvent({name=SocketTCP.EVENT_CONNECTED}) if self.connectTimeTickScheduler then scheduler.unscheduleGlobal(self.connectTimeTickScheduler) end local __tick = function() while true do -- if use "*l" pattern, some buffer will be discarded, why? local __body, __status, __partial = self.tcp:receive("*a") -- read the package body --print("body:", __body, "__status:", __status, "__partial:", __partial) --print("name="..self.name..";ip="..self.host..";port="..tostring(self.port)); if __status == STATUS_CLOSED or __status == STATUS_NOT_CONNECTED then self:close() if self.isConnected then self:_onDisconnect() else self:_connectFailure() end return end if (__body and string.len(__body) == 0) or (__partial and string.len(__partial) == 0) then return end if __body and __partial then __body = __body .. __partial end self:dispatchEvent({name=SocketTCP.EVENT_DATA, data=(__partial or __body), partial=__partial, body=__body}) end end -- start to read TCP data self.tickScheduler = scheduler.scheduleGlobal(__tick, SOCKET_TICK_TIME) end function SocketTCP:_connectFailure(status) --printInfo("%s._connectFailure", self.name); self:dispatchEvent({name=SocketTCP.EVENT_CONNECT_FAILURE}) self:_reconnect(); end -- if connection is initiative, do not reconnect function SocketTCP:_reconnect(__immediately) if not self.isRetryConnect then return end printInfo("%s._reconnect", self.name) if __immediately then self:connect() return end if self.reconnectScheduler then scheduler.unscheduleGlobal(self.reconnectScheduler) end local __doReConnect = function () self:connect() end self.reconnectScheduler = scheduler.performWithDelayGlobal(__doReConnect, SOCKET_RECONNECT_TIME) end return SocketTCP
local args = {...} -- the only arg is arg 1, the player number local function m(metric) metric = metric:gsub("PN", ToEnumShortString(args[1])) return THEME:GetMetric(Var "LoadingScreen",metric) end local pss = STATSMAN:GetCurStageStats():GetPlayerStageStats(args[1]) local tier = SN2Grading.ScoreToGrade(pss:GetScore(), pss:GetPlayedSteps()[1]:GetDifficulty()) local t = Def.ActorFrame {}; for _, pn in pairs(GAMESTATE:GetEnabledPlayers()) do t[#t+1] = Def.ActorFrame{ Def.Sprite{ InitCommand = function(s) s:draworder(98):player(pn):x(m "RingPNX"):y(m "RingPNY"):zoom(0) end, OnCommand=function(self) local staw = STATSMAN:GetCurStageStats():GetPlayerStageStats(pn):GetStageAward(); if staw ~= nil then if((staw =="StageAward_SingleDigitW4") or (staw =="StageAward_OneW4") or (staw =="StageAward_FullComboW4") or string.find(staw,"W4")) then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/GoodFullcombo_ring.png")); elseif((staw =="StageAward_SingleDigitW3") or (staw =="StageAward_OneW3") or (staw =="StageAward_FullComboW3") or string.find(staw,"W3")) then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/GreatFullcombo_ring.png")); elseif((staw =="StageAward_SingleDigitW2") or (staw =="StageAward_OneW2") or (staw =="StageAward_FullComboW2") ) then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/PerfectFullcombo_ring.png")); elseif (staw =="StageAward_FullComboW1") then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/MarvelousFullcombo_ring.png")); end; (cmd(linear,0.2;zoom,0.65;spin;effectmagnitude,0,0,170))(self); end; end; OffCommand=cmd(linear,0.2;zoom,0); }; --Lines Def.Sprite{ InitCommand = function(s) s:draworder(98):player(pn):x(m "RingPNX"):y(m "RingPNY"):zoom(0) end, OnCommand=function(self) local staw = STATSMAN:GetCurStageStats():GetPlayerStageStats(pn):GetStageAward(); if staw ~= nil then if((staw =="StageAward_SingleDigitW4") or (staw =="StageAward_OneW4") or (staw =="StageAward_FullComboW4") or string.find(staw,"W4")) then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/GoodFullcombo_lines.png")); elseif((staw =="StageAward_SingleDigitW3") or (staw =="StageAward_OneW3") or (staw =="StageAward_FullComboW3") or string.find(staw,"W3")) then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/GreatFullcombo_lines.png")); elseif((staw =="StageAward_SingleDigitW2") or (staw =="StageAward_OneW2") or (staw =="StageAward_FullComboW2") ) then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/PerfectFullcombo_lines.png")); elseif (staw =="StageAward_FullComboW1") then self:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/MarvelousFullcombo_lines.png")); end; (cmd(linear,0.2;zoom,0.65;spin;effectmagnitude,0,0,-170))(self); end; end; OffCommand=cmd(linear,0.2;zoom,0); }; } ; end; for _, pn in pairs(GAMESTATE:GetEnabledPlayers()) do t[#t+1] = Def.ActorFrame{ Def.Sprite{ InitCommand = function(s) s:x(m "GradePNX"):y(m "GradePNY"):playcommand("Set") end, OnCommand = m "GradePNOnCommand", OffCommand = m "GradePNOffCommand", SetCommand= function(s) local failed = STATSMAN:GetCurStageStats():GetPlayerStageStats(pn):GetFailed(); if failed then s:Load(THEME:GetPathB("","ScreenEvaluationNormal overlay/grade/GradeDisplayEval Failed")) else s:Load(THEME:GetPathB("ScreenEvaluationNormal overlay/grade/GradeDisplayEval", ToEnumShortString(tier))) end; end; }; }; end; return t;
--[[ This file was extracted by 'EsoLuaGenerator' at '2021-09-04 16:42:28' using the latest game version. NOTE: This file should only be used as IDE support; it should NOT be distributed with addons! **************************************************************************** CONTENTS OF THIS FILE IS COPYRIGHT ZENIMAX MEDIA INC. **************************************************************************** ]] local ACCEPT = true local REJECT = false -- Style Constants local FRAME_BORDER_PADDING_KEYBOARD = 4 local FRAME_BORDER_PADDING_GAMEPAD = 8 ZO_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_KEYBOARD = 64 ZO_FRAMED_ANTIQUITY_ICON_DIMENSIONS_KEYBOARD = ZO_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_KEYBOARD - FRAME_BORDER_PADDING_KEYBOARD ZO_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_GAMEPAD = 64 ZO_FRAMED_ANTIQUITY_ICON_DIMENSIONS_GAMEPAD = ZO_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_GAMEPAD - FRAME_BORDER_PADDING_GAMEPAD ZO_SET_COMPLETE_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_KEYBOARD = 100 ZO_SET_COMPLETE_FRAMED_ANTIQUITY_ICON_DIMENSIONS_KEYBOARD = ZO_SET_COMPLETE_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_KEYBOARD - FRAME_BORDER_PADDING_KEYBOARD ZO_SET_COMPLETE_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_GAMEPAD = 100 ZO_SET_COMPLETE_FRAMED_ANTIQUITY_ICON_DIMENSIONS_GAMEPAD = ZO_SET_COMPLETE_FRAMED_ANTIQUITY_FRAME_DIMENSIONS_GAMEPAD - FRAME_BORDER_PADDING_GAMEPAD -- Timeline Constants ZO_ANTIQUITY_DIGGING_FANFARE_OUT_DELAY = 30 ZO_ANTIQUITY_DIGGING_FANFARE_OUT_DURATION = 40 local SET_PROGRESSION_FRAMED_ICON_DELAY_MODIFIER_MS = 35 ZO_PROGRESSION_FRAMED_ICON_FADE_DURATION_MS = 300 ZO_PROGRESSION_FRAMED_ICON_SCALE_DURATION_MS = 100 ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS = { BEGIN = "Begin", NEXT = "Next", ANIMATION_COMPLETE = "AnimationComplete", PARTIAL_ANIMATION_COMPLETE = "PartialAnimationComplete", -- For use in the animation event count trigger where we expect more than one call before we count all animations as complete and move on } ZO_AntiquityDiggingSummary = ZO_Object:Subclass() function ZO_AntiquityDiggingSummary:New(...) local object = ZO_Object.New(self) object:Initialize(...) return object end function ZO_AntiquityDiggingSummary:Initialize(control) self.control = control ANTIQUITY_DIGGING_SUMMARY_FRAGMENT = ZO_SimpleSceneFragment:New(self.control) ANTIQUITY_DIGGING_SUMMARY_FRAGMENT:SetHideOnSceneHidden(true) ANTIQUITY_DIGGING_SUMMARY_FRAGMENT:RegisterCallback("StateChange", function(oldState, newState) if newState == SCENE_FRAGMENT_HIDDEN then self.fanfareStateMachine:SetCurrentState("INACTIVE") end end) control:RegisterForEvent(EVENT_START_ANTIQUITY_DIGGING, function() -- make sure we start at the beginning of the state machine on start self.fanfareStateMachine:SetCurrentState("INACTIVE") end) control:RegisterForEvent(EVENT_REQUEST_ANTIQUITY_DIGGING_EXIT, function() if ANTIQUITY_DIGGING_SUMMARY_FRAGMENT:IsShowing() then AntiquityDiggingExitResponse(ACCEPT) end end) self:InitializeControls() self:InitializeStateMachine() ZO_PlatformStyle:New(function(style) self:ApplyPlatformStyle(style) end) end function ZO_AntiquityDiggingSummary:InitializeControls() self.modalUnderlay = self.control:GetNamedChild("ModalUnderlay") self.modalUnderlayTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingModalUnderlayFade", self.modalUnderlay) -- Control style tamplating local function MarkStyleDirty(control) control.isStyleDirty = true if not control:IsHidden() then control:CleanStyle() end end local function CleanStyle(control) if control.isStyleDirty then ApplyTemplateToControl(control, ZO_GetPlatformTemplate(control.styleTemplateBase)) control.isStyleDirty = false end end local function SetupControlStyleTemplating(control, styleTemplateBase) control.MarkStyleDirty = MarkStyleDirty control.CleanStyle = CleanStyle control.styleTemplateBase = styleTemplateBase control.isStyleDirty = true -- When first created they won't have the platform style applied yet end --Keybind self.keybindButtonsControl = self.control:GetNamedChild("Keybinds") self.keybindTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingSummaryKeybindFade", self.keybindButtonsControl) local primaryDescriptor = { keybind = "ANTIQUITY_DIGGING_PRIMARY_ACTION", callback = function() self:HandleCommand(ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.NEXT) end, } self.primaryKeybindButton = self.keybindButtonsControl:GetNamedChild("Primary") self.primaryKeybindButton:SetKeybindButtonDescriptor(primaryDescriptor) local secondaryDescriptor = { keybind = "ANTIQUITY_DIGGING_CODEX", callback = function() self:ShowCodexEntry() end, } self.secondaryKeybindButton = self.keybindButtonsControl:GetNamedChild("Secondary") self.secondaryKeybindButton:SetKeybindButtonDescriptor(secondaryDescriptor) -- Failure self.failureControl = self.control:GetNamedChild("Failure") self.failureReasonBodyLabel = self.failureControl:GetNamedChild("Reason"):GetNamedChild("Body") self.failureTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingFailureFade", self.failureControl) -- Rewards self.rewardsControl = self.control:GetNamedChild("Rewards") self.rewardsOutTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingRewardsOutTimeline", self.rewardsControl) -- SetSkipAnimationsBehindPlayheadOnInitialPlay is needed because the animations have delays. -- Without this, when playing the animation directly to start, it won't set the various states because the position is technically beyond the playhead self.rewardsOutTimeline:SetSkipAnimationsBehindPlayheadOnInitialPlay(false) -- Antiquity Reward self.antiquityRewardControl = self.rewardsControl:GetNamedChild("Antiquity") self.rewardAntiquityHeaderLabelRevealer = self.antiquityRewardControl:GetNamedChild("Header") self.rewardAntiquitySubHeaderLabelRevealer = self.antiquityRewardControl:GetNamedChild("SubHeader") local antiquityRewardContainerControl = self.antiquityRewardControl:GetNamedChild("Container") self.rewardAntiquityNameLabelRevealer = antiquityRewardContainerControl:GetNamedChild("Name") self.rewardAntiquityIconTexture = antiquityRewardContainerControl:GetNamedChild("FrameIcon") self.antiquityRewardTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingAntiquityRewardInTimeline", self.antiquityRewardControl) self.antiquityRewardTimeline:SetSkipAnimationsBehindPlayheadOnInitialPlay(false) self.rewardAntiquityHeaderLabelRevealer:SetSizeAnimation(self.antiquityRewardTimeline:GetAnimation(2)) self.rewardAntiquitySubHeaderLabelRevealer:SetSizeAnimation(self.antiquityRewardTimeline:GetAnimation(8)) self.rewardAntiquityNameLabelRevealer:SetSizeAnimation(self.antiquityRewardTimeline:GetAnimation(9)) -- New Lead self.newLeadControl = self.rewardsControl:GetNamedChild("NewLead") local newLeadItemControl = self.newLeadControl:GetNamedChild("Item") self.newLeadIconTexture = newLeadItemControl:GetNamedChild("Icon") self.newLeadIconTexture:SetTexture(GetAntiquityLeadIcon()) -- Never changes, global def defined self.newLeadNameLabel = newLeadItemControl:GetNamedChild("Name") self.newLeadTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingRewardNewLeadFade", self.newLeadControl) self.newLeadTimeline:SetSkipAnimationsBehindPlayheadOnInitialPlay(false) -- Bonus Loot self.bonusRewardsControl = self.rewardsControl:GetNamedChild("Bonus") self.bonusRewardsHeaderLabel = self.bonusRewardsControl:GetNamedChild("Header") local bonusItemsContainer = self.bonusRewardsControl:GetNamedChild("Items") self.bonusesRowControlPool = ZO_ControlPool:New("ZO_AntiquityBonusLootRowContainer_Control", bonusItemsContainer) self.bonusesControlPool = ZO_ControlPool:New("ZO_AntiquityDiggingRewardItem_Control") self.bonusesControlPool:SetCustomFactoryBehavior(function(control) control.iconTexture = control:GetNamedChild("Icon") control.stackCountLabel = control.iconTexture:GetNamedChild("StackCount") control.nameLabel = control:GetNamedChild("Name") SetupControlStyleTemplating(control, "ZO_AntiquityDiggingRewardItem_Control") end) self.bonusesControlPool:SetCustomAcquireBehavior(function(control) control:CleanStyle() end) self.bonusRewardsNoLootFoundLabel = bonusItemsContainer:GetNamedChild("NoLootFound") self.bonusRewardsTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingRewardBonusesFade", self.bonusRewardsControl) self.bonusRewardsTimeline:SetSkipAnimationsBehindPlayheadOnInitialPlay(false) -- Set Progression self.setProgressionControl = self.control:GetNamedChild("SetProgression") self.setProgressionHeaderLabel = self.setProgressionControl:GetNamedChild("Header") self.setProgressionEntriesContainer = self.setProgressionControl:GetNamedChild("Entries") self.setProgressionTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingSetProgressionFade", self.setProgressionControl) local function SetAntiquityIconDisplayBehavior(control, desaturateControl, showSilhouette) local desaturation = desaturateControl and 1 or 0 local rgbSampleProcessingWeight = showSilhouette and 0.7 or 1.0 local alphaAsRGBSampleProcessingWeight = showSilhouette and 0.3 or 0.0 control.iconTexture:SetDesaturation(desaturation) control.frameTexture:SetDesaturation(desaturation) control.bgTexture:SetDesaturation(desaturation) control.iconTexture:SetTextureSampleProcessingWeight(TEX_SAMPLE_PROCESSING_RGB, rgbSampleProcessingWeight) control.iconTexture:SetTextureSampleProcessingWeight(TEX_SAMPLE_PROCESSING_ALPHA_AS_RGB, alphaAsRGBSampleProcessingWeight) end local function OnCompleteFireTrigger(_, completedPlaying) if completedPlaying then ANTIQUITY_DIGGING_SUMMARY:HandleCommand(ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.PARTIAL_ANIMATION_COMPLETE) end end self.setProgressionAntiquityIconPool = ZO_ControlPool:New("ZO_AntiquityDigging_FramedAntiquityIcon", self.setProgressionEntriesContainer, "AntiquityIcon") self.setProgressionAntiquityIconPool:SetCustomFactoryBehavior(function(control) control.iconTexture = control:GetNamedChild("Icon") control.frameTexture = control:GetNamedChild("Frame") control.bgTexture = control.frameTexture:GetNamedChild("BG") control.fadeTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingFramedAntiquityIconFade", control) control.fadeTimeline:SetHandler("OnStop", OnCompleteFireTrigger) SetupControlStyleTemplating(control, "ZO_AntiquityDigging_FramedAntiquityIcon") control.SetDisplayBehavior = SetAntiquityIconDisplayBehavior end) local IGNORE_ANIMATION_CALLBACKS = true self.setProgressionAntiquityIconPool:SetCustomAcquireBehavior(function(control) control:CleanStyle() control.fadeTimeline:SetAllAnimationOffsets(0) control.fadeTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) end) -- Control will be set when we know which one is the relevant one self.setProgressionAntiquityIconScaleTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingFramedAntiquityIconScale") self.setProgressionAntiquityIconScaleTimeline:SetHandler("OnStop", function(timeline, completedPlaying) if completedPlaying then -- 1. The control started out regular size and unfulfilled, then it started growing if timeline:IsPlayingBackward() then -- 4. Done shrinking, ready to move on OnCompleteFireTrigger(timeline, completedPlaying) else -- 2. After fully growing, mark fulfilled local DONT_DESATURATE, DONT_SHOW_SILHOUETTE = false, false self.setProgressionControlForCurrentAntiquity:SetDisplayBehavior(DONT_DESATURATE, DONT_SHOW_SILHOUETTE) self.setProgressionSparksParticleSystem:Start() if self.isAntiquitySetComplete then PlaySound(SOUNDS.ANTIQUITIES_FANFARE_FRAGMENT_DISCOVERED_FINAL) else PlaySound(SOUNDS.ANTIQUITIES_FANFARE_FRAGMENT_DISCOVERED) end -- 3. Then start shrinking back to normal timeline:PlayFromEnd() end end end) -- Set Complete self.setCompleteControl = self.control:GetNamedChild("SetComplete") self.setCompleteBannerTexture = self.setCompleteControl:GetNamedChild("Banner") self.setCompleteFramedAntiquityControl = self.setCompleteControl:GetNamedChild("FramedAntiquity") self.setCompleteFramedAntiquityIconTexture = self.setCompleteFramedAntiquityControl:GetNamedChild("Icon") self.setCompleteTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingSetCompleteFade", self.setCompleteControl) -- Transfer self.transferControl = self.control:GetNamedChild("Transfer") self.transferTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingTransferFade", self.transferControl) -- Lore self.loreControl = self.control:GetNamedChild("Lore") self.loreHeaderLabel = self.loreControl:GetNamedChild("Header") self.loreTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_AntiquityDiggingLoreFade", self.loreControl) self:InitializeParticleSystems() end function ZO_AntiquityDiggingSummary:InitializeParticleSystems() local particleR, particleG, particleB = ZO_OFF_WHITE:UnpackRGB() local FULL_CIRCLE_RADIANS = math.rad(360) local setProgressionSparksParticleSystem = ZO_ControlParticleSystem:New(ZO_AnalyticalPhysicsParticle_Control) setProgressionSparksParticleSystem:SetParticlesPerSecond(15) setProgressionSparksParticleSystem:SetStartPrimeS(0.5) setProgressionSparksParticleSystem:SetParticleParameter("Texture", "EsoUI/Art/PregameAnimatedBackground/ember.dds") setProgressionSparksParticleSystem:SetParticleParameter("BlendMode", TEX_BLEND_MODE_ADD) setProgressionSparksParticleSystem:SetParticleParameter("StartAlpha", 1) setProgressionSparksParticleSystem:SetParticleParameter("EndAlpha", 0) setProgressionSparksParticleSystem:SetParticleParameter("DurationS", ZO_UniformRangeGenerator:New(1, 1.5)) setProgressionSparksParticleSystem:SetParticleParameter("PhysicsInitialVelocityElevationRadians", ZO_UniformRangeGenerator:New(0, FULL_CIRCLE_RADIANS)) setProgressionSparksParticleSystem:SetParticleParameter("StartColorR", particleR) setProgressionSparksParticleSystem:SetParticleParameter("StartColorG", particleG) setProgressionSparksParticleSystem:SetParticleParameter("StartColorB", particleB) setProgressionSparksParticleSystem:SetParticleParameter("PhysicsInitialVelocityMagnitude", ZO_UniformRangeGenerator:New(15, 60)) setProgressionSparksParticleSystem:SetParticleParameter("Size", ZO_UniformRangeGenerator:New(5, 10)) setProgressionSparksParticleSystem:SetParticleParameter("DrawLevel", 4) self.setProgressionSparksParticleSystem = setProgressionSparksParticleSystem local setCompleteBlastParticleSystem = ZO_ControlParticleSystem:New(ZO_NumericalPhysicsParticle_Control) setCompleteBlastParticleSystem:SetParentControl(self.setCompleteBannerTexture) setCompleteBlastParticleSystem:SetParticlesPerSecond(500) setCompleteBlastParticleSystem:SetDuration(0.2) setCompleteBlastParticleSystem:SetParticleParameter("Texture", "EsoUI/Art/PregameAnimatedBackground/ember.dds") setCompleteBlastParticleSystem:SetParticleParameter("BlendMode", TEX_BLEND_MODE_ADD) setCompleteBlastParticleSystem:SetParticleParameter("StartAlpha", 1) setCompleteBlastParticleSystem:SetParticleParameter("EndAlpha", 0) setCompleteBlastParticleSystem:SetParticleParameter("DurationS", ZO_UniformRangeGenerator:New(1.5, 2.5)) setCompleteBlastParticleSystem:SetParticleParameter("PhysicsInitialVelocityElevationRadians", ZO_UniformRangeGenerator:New(0, FULL_CIRCLE_RADIANS)) setCompleteBlastParticleSystem:SetParticleParameter("PhysicsAccelerationElevationRadians1", math.rad(270)) --Down; Right is 0 setCompleteBlastParticleSystem:SetParticleParameter("PhysicsAccelerationMagnitude1", 200) setCompleteBlastParticleSystem:SetParticleParameter("StartColorR", particleR) setCompleteBlastParticleSystem:SetParticleParameter("StartColorG", particleG) setCompleteBlastParticleSystem:SetParticleParameter("StartColorB", particleB) setCompleteBlastParticleSystem:SetParticleParameter("PhysicsInitialVelocityMagnitude", ZO_UniformRangeGenerator:New(500, 900)) setCompleteBlastParticleSystem:SetParticleParameter("Size", ZO_UniformRangeGenerator:New(6, 12)) setCompleteBlastParticleSystem:SetParticleParameter("PhysicsDragMultiplier", 1.5) setCompleteBlastParticleSystem:SetParticleParameter("PrimeS", 0.1) setCompleteBlastParticleSystem:SetParticleParameter("DrawLevel", 0) self.setCompleteBlastParticleSystem = setCompleteBlastParticleSystem local setCompleteSparksParticleSystem = ZO_ControlParticleSystem:New(ZO_AnalyticalPhysicsParticle_Control) setCompleteSparksParticleSystem:SetParentControl(self.setCompleteFramedAntiquityControl) setCompleteSparksParticleSystem:SetParticlesPerSecond(20) setCompleteSparksParticleSystem:SetStartPrimeS(0.5) setCompleteSparksParticleSystem:SetParticleParameter("Texture", "EsoUI/Art/PregameAnimatedBackground/ember.dds") setCompleteSparksParticleSystem:SetParticleParameter("BlendMode", TEX_BLEND_MODE_ADD) setCompleteSparksParticleSystem:SetParticleParameter("StartAlpha", 1) setCompleteSparksParticleSystem:SetParticleParameter("EndAlpha", 0) setCompleteSparksParticleSystem:SetParticleParameter("DurationS", ZO_UniformRangeGenerator:New(1.5, 2.0)) setCompleteSparksParticleSystem:SetParticleParameter("PhysicsInitialVelocityElevationRadians", ZO_UniformRangeGenerator:New(0, FULL_CIRCLE_RADIANS)) setCompleteSparksParticleSystem:SetParticleParameter("StartColorR", particleR) setCompleteSparksParticleSystem:SetParticleParameter("StartColorG", particleG) setCompleteSparksParticleSystem:SetParticleParameter("StartColorB", particleB) setCompleteSparksParticleSystem:SetParticleParameter("PhysicsInitialVelocityMagnitude", ZO_UniformRangeGenerator:New(15, 60)) setCompleteSparksParticleSystem:SetParticleParameter("Size", ZO_UniformRangeGenerator:New(5, 10)) setCompleteSparksParticleSystem:SetParticleParameter("DrawLevel", 4) self.setCompleteSparksParticleSystem = setCompleteSparksParticleSystem local setCompleteStarbustParticleSystem = ZO_ControlParticleSystem:New(ZO_StationaryParticle_Control) setCompleteStarbustParticleSystem:SetParentControl(self.setCompleteFramedAntiquityControl) setCompleteStarbustParticleSystem:SetParticlesPerSecond(20) setCompleteStarbustParticleSystem:SetStartPrimeS(2) setCompleteStarbustParticleSystem:SetParticleParameter("Texture", "EsoUI/Art/Miscellaneous/lensflare_star_256.dds") setCompleteStarbustParticleSystem:SetParticleParameter("BlendMode", TEX_BLEND_MODE_ADD) setCompleteStarbustParticleSystem:SetParticleParameter("StartAlpha", 0) setCompleteStarbustParticleSystem:SetParticleParameter("EndAlpha", 1) setCompleteStarbustParticleSystem:SetParticleParameter("AlphaEasing", ZO_EaseInOutZeroToOneToZero) setCompleteStarbustParticleSystem:SetParticleParameter("StartScale", ZO_UniformRangeGenerator:New(1.5, 1.8)) setCompleteStarbustParticleSystem:SetParticleParameter("EndScale", ZO_UniformRangeGenerator:New(1.05, 1.5)) setCompleteStarbustParticleSystem:SetParticleParameter("DurationS", ZO_UniformRangeGenerator:New(1, 2)) setCompleteStarbustParticleSystem:SetParticleParameter("StartColorR", particleR) setCompleteStarbustParticleSystem:SetParticleParameter("StartColorG", particleG) setCompleteStarbustParticleSystem:SetParticleParameter("StartColorB", particleB) setCompleteStarbustParticleSystem:SetParticleParameter("StartRotationRadians", ZO_UniformRangeGenerator:New(0, FULL_CIRCLE_RADIANS)) local MIN_ROTATION_SPEED = math.rad(1.5) local MAX_ROTATION_SPEED = math.rad(3) local headerStarbustRotationSpeedGenerator = ZO_WeightedChoiceGenerator:New( MIN_ROTATION_SPEED , 0.25, MAX_ROTATION_SPEED , 0.25, -MIN_ROTATION_SPEED, 0.25, -MAX_ROTATION_SPEED, 0.25) setCompleteStarbustParticleSystem:SetParticleParameter("RotationSpeedRadians", headerStarbustRotationSpeedGenerator) setCompleteStarbustParticleSystem:SetParticleParameter("Size", 256) setCompleteStarbustParticleSystem:SetParticleParameter("DrawLevel", 0) self.setCompleteStarbustParticleSystem = setCompleteStarbustParticleSystem end function ZO_AntiquityDiggingSummary:ConfigureKeybindButton(keybindButton, enabled, text) if enabled then keybindButton:SetHidden(false) keybindButton.originalText = text keybindButton:SetText(text) else keybindButton:SetHidden(true) end end function ZO_AntiquityDiggingSummary:InitializeStateMachine() local fanfareStateMachine = ZO_StateMachine_Base:New("ANTIQUITY_DIGGING_FANFARE_STATE_MACHINE") self.fanfareStateMachine = fanfareStateMachine local IGNORE_ANIMATION_CALLBACKS = true do local state = fanfareStateMachine:AddState("INACTIVE") state:RegisterCallback("OnActivated", function() self.modalUnderlayTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.failureTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.antiquityRewardTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.newLeadTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.bonusRewardsTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.setProgressionTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.setCompleteTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.setProgressionAntiquityIconScaleTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.loreTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.keybindTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.failureControl:SetHidden(true) self.antiquityRewardControl:SetHidden(true) self.newLeadControl:SetHidden(true) self.bonusRewardsControl:SetHidden(true) self.setProgressionControl:SetHidden(true) self.setCompleteControl:SetHidden(true) self.transferControl:SetHidden(true) self.loreControl:SetHidden(true) self.bonusesControlPool:ReleaseAllObjects() self.bonusesRowControlPool:ReleaseAllObjects() self.setProgressionAntiquityIconPool:ReleaseAllObjects() self.setProgressionSparksParticleSystem:Stop() self.setCompleteBlastParticleSystem:Stop() self.setCompleteSparksParticleSystem:Stop() self.setCompleteStarbustParticleSystem:Stop() ANTIQUITY_LORE_DOCUMENT_MANAGER:ReleaseAllObjects(self.loreControl) self:ConfigureKeybindButton(self.primaryKeybindButton, false) self:ConfigureKeybindButton(self.secondaryKeybindButton, false) end) end do local state = fanfareStateMachine:AddState("BEGIN") state:RegisterCallback("OnActivated", function() -- This state primarily exists to allow the two possible paths (REWARD_IN/FAILURE_IN) to run their conditionals -- And to animate shared controls SCENE_MANAGER:AddFragment(UNIFORM_BLUR_FRAGMENT) self.modalUnderlayTimeline:PlayFromStart() self.keybindTimeline:PlayFromStart() fanfareStateMachine:FireCallbacks(ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.NEXT) end) end do local state = fanfareStateMachine:AddState("ANTIQUITY_REWARD_IN") state:RegisterCallback("OnActivated", function() self:ConfigureKeybindButton(self.primaryKeybindButton, true, GetString(SI_ANTIQUITY_DIGGING_FANFARE_NEXT)) self.antiquityRewardControl:SetHidden(false) self.rewardsOutTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.antiquityRewardTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.antiquityRewardTimeline:PlayFromStart() PlaySound(SOUNDS.ANTIQUITIES_FANFARE_FRAGMENT_FOUND) end) state:RegisterCallback("OnDeactivated", function() if self.antiquityRewardTimeline:IsPlaying() then self.antiquityRewardTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end end) end do local state = fanfareStateMachine:AddState("NEW_LEAD_IN") state:RegisterCallback("OnActivated", function() self.newLeadControl:SetHidden(false) self.newLeadTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.newLeadTimeline:PlayFromStart() end) end do local state = fanfareStateMachine:AddState("BONUS_REWARDS_IN") state:RegisterCallback("OnActivated", function() self.bonusRewardsControl:SetHidden(false) self.bonusRewardsTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.bonusRewardsTimeline:PlayFromStart() end) end do local state = fanfareStateMachine:AddState("REWARDS") state:RegisterCallback("OnActivated", function() -- We may have gotten here via a skip, which means we may never have even made it into the interstitial states -- So just ensure these animations are where we want them to be by this point in the flow if self.hasNewLead then self.newLeadControl:SetHidden(false) self.newLeadTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end -- The bonus rewards section always shows even if there aren't any rewards self.bonusRewardsControl:SetHidden(false) self.bonusRewardsTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end) end do local state = fanfareStateMachine:AddState("REWARDS_OUT") state:RegisterCallback("OnActivated", function() self.rewardsOutTimeline:PlayFromStart() end) state:RegisterCallback("OnDeactivated", function() if self.rewardsOutTimeline:IsPlaying() then self.rewardsOutTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end self.antiquityRewardControl:SetHidden(true) self.bonusRewardsControl:SetHidden(true) end) end do local state = fanfareStateMachine:AddState("SET_PROGRESSION_IN") state:RegisterCallback("OnActivated", function() self.setProgressionControl:SetHidden(false) self.setProgressionTimeline:PlayFromStart() PlaySound(SOUNDS.ANTIQUITIES_FANFARE_FRAGMENT_PROGRESSION) end) state:RegisterCallback("OnDeactivated", function() local primaryAnimationIsPlaying = self.setProgressionTimeline:IsPlaying() if primaryAnimationIsPlaying then self.setProgressionTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end for _, activeIcon in self.setProgressionAntiquityIconPool:ActiveObjectIterator() do if primaryAnimationIsPlaying or activeIcon.fadeTimeline:IsPlaying() then activeIcon.fadeTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end end if primaryAnimationIsPlaying or self.setProgressionAntiquityIconScaleTimeline:IsPlaying() then local DONT_DESATURATE, DONT_SHOW_SILHOUETTE = false, false self.setProgressionControlForCurrentAntiquity:SetDisplayBehavior(DONT_DESATURATE, DONT_SHOW_SILHOUETTE) self.setProgressionAntiquityIconScaleTimeline:SetAllAnimationOffsets(0) self.setProgressionAntiquityIconScaleTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) self.setProgressionSparksParticleSystem:Start() end end) end fanfareStateMachine:AddState("SET_PROGRESSION") do local state = fanfareStateMachine:AddState("SET_PROGRESSION_OUT") state:RegisterCallback("OnActivated", function() self.setProgressionTimeline:PlayBackward() end) state:RegisterCallback("OnDeactivated", function() if self.setProgressionTimeline:IsPlaying() then self.setProgressionTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) end self.setProgressionControl:SetHidden(true) self.setProgressionSparksParticleSystem:Stop() end) end do local state = fanfareStateMachine:AddState("SET_COMPLETE_IN") state:RegisterCallback("OnActivated", function() self.setCompleteControl:SetHidden(false) self.setCompleteTimeline:PlayFromStart() self.setCompleteBlastParticleSystem:Start() self.setCompleteSparksParticleSystem:Start() self.setCompleteStarbustParticleSystem:Start() PlaySound(SOUNDS.ANTIQUITIES_FANFARE_COMPLETED) end) state:RegisterCallback("OnDeactivated", function() if self.setCompleteTimeline:IsPlaying() then self.setCompleteTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end end) end fanfareStateMachine:AddState("SET_COMPLETE") do local state = fanfareStateMachine:AddState("SET_COMPLETE_OUT") state:RegisterCallback("OnActivated", function() self.setCompleteTimeline:PlayBackward() end) state:RegisterCallback("OnDeactivated", function() if self.setCompleteTimeline:IsPlaying() then self.setCompleteTimeline:PlayInstantlyToStart(IGNORE_ANIMATION_CALLBACKS) end self.setCompleteControl:SetHidden(true) self.setCompleteBlastParticleSystem:Stop() self.setCompleteSparksParticleSystem:Stop() self.setCompleteStarbustParticleSystem:Stop() end) end do local state = fanfareStateMachine:AddState("TRANSFER") state:RegisterCallback("OnActivated", function() StartDiggingTransitionToNextDay() self.transferControl:SetHidden(false) self.transferTimeline:PlayFromStart() self:ConfigureKeybindButton(self.primaryKeybindButton, false) end) state:RegisterCallback("OnDeactivated", function() self.transferControl:SetHidden(true) self.transferTimeline:Stop() end) end do local state = fanfareStateMachine:AddState("LORE_IN") state:RegisterCallback("OnActivated", function() self.loreControl:SetAlpha(0) self.loreControl:SetHidden(false) self.loreTimeline:PlayFromStart() PlaySound(SOUNDS.ANTIQUITIES_FANFARE_MOTIF_SCROLL_APPEAR) end) end do local state = fanfareStateMachine:AddState("LORE") state:RegisterCallback("OnDeactivated", function() if self.loreTimeline:IsPlaying() then self.loreTimeline:PlayInstantlyToEnd(IGNORE_ANIMATION_CALLBACKS) end self.loreControl:SetHidden(true) ANTIQUITY_LORE_DOCUMENT_MANAGER:ReleaseAllObjects(self.loreControl) end) end do local state = fanfareStateMachine:AddState("FAILURE_IN") state:RegisterCallback("OnActivated", function() self:ConfigureKeybindButton(self.primaryKeybindButton, true, GetString(SI_EXIT_BUTTON)) self.failureControl:SetHidden(false) self.failureTimeline:PlayFromStart() PlaySound(SOUNDS.ANTIQUITIES_FANFARE_FAILURE) end) end do local state = fanfareStateMachine:AddState("QUIT") state:RegisterCallback("OnActivated", function() SCENE_MANAGER:RequestShowLeaderBaseScene() end) end -- Edges -- do fanfareStateMachine:AddEdgeAutoName("INACTIVE", "BEGIN") local antiquityRewardInEdge = fanfareStateMachine:AddEdgeAutoName("BEGIN", "ANTIQUITY_REWARD_IN") antiquityRewardInEdge:SetConditional(function() return self.gameOverFlags == ANTIQUITY_DIGGING_GAME_OVER_FLAGS_VICTORY end) local antiquityRewardToNewLeadInEdge = fanfareStateMachine:AddEdgeAutoName("ANTIQUITY_REWARD_IN", "NEW_LEAD_IN") antiquityRewardToNewLeadInEdge:SetConditional(function() return self.hasNewLead end) local antiquityRewardToBonusRewardsInEdge = fanfareStateMachine:AddEdgeAutoName("ANTIQUITY_REWARD_IN", "BONUS_REWARDS_IN") antiquityRewardToBonusRewardsInEdge:SetConditional(function() return not self.hasNewLead end) fanfareStateMachine:AddEdge("ANTIQUITY_REWARD_IN_TO_REWARDS_SKIP", "ANTIQUITY_REWARD_IN", "REWARDS") fanfareStateMachine:AddEdgeAutoName("NEW_LEAD_IN", "BONUS_REWARDS_IN") fanfareStateMachine:AddEdge("NEW_LEAD_IN_TO_REWARDS_SKIP", "NEW_LEAD_IN", "REWARDS") fanfareStateMachine:AddEdgeAutoName("BONUS_REWARDS_IN", "REWARDS") local rewardsOutEdge = fanfareStateMachine:AddEdgeAutoName("REWARDS", "REWARDS_OUT") rewardsOutEdge:SetConditional(function() return self.showLore or self.hasAntiquitySet end) local rewardsOutToSetProgressionInEdge = fanfareStateMachine:AddEdgeAutoName("REWARDS_OUT", "SET_PROGRESSION_IN") rewardsOutToSetProgressionInEdge:SetConditional(function() return self.hasAntiquitySet end) local rewardsOutToTransferEdge = fanfareStateMachine:AddEdgeAutoName("REWARDS_OUT", "TRANSFER") rewardsOutToTransferEdge:SetConditional(function() return not self.hasAntiquitySet and self.showLore end) fanfareStateMachine:AddEdgeAutoName("LORE_IN", "LORE") fanfareStateMachine:AddEdgeAutoName("SET_PROGRESSION_IN", "SET_PROGRESSION") local setProgressionOutEdge = fanfareStateMachine:AddEdgeAutoName("SET_PROGRESSION", "SET_PROGRESSION_OUT") setProgressionOutEdge:SetConditional(function() return self.isAntiquitySetComplete or self.showLore end) local setProgressionOutToTransferEdge = fanfareStateMachine:AddEdgeAutoName("SET_PROGRESSION_OUT", "TRANSFER") setProgressionOutToTransferEdge:SetConditional(function() return not self.isAntiquitySetComplete and self.showLore end) local setProgressionOutToSetCompleteInEdge = fanfareStateMachine:AddEdgeAutoName("SET_PROGRESSION_OUT", "SET_COMPLETE_IN") setProgressionOutToSetCompleteInEdge:SetConditional(function() return self.isAntiquitySetComplete end) fanfareStateMachine:AddEdgeAutoName("SET_COMPLETE_IN", "SET_COMPLETE") local setCompleteQuitEdge = fanfareStateMachine:AddEdgeAutoName("SET_COMPLETE", "QUIT") setCompleteQuitEdge:SetConditional(function() return not self.showLore end) setCompleteQuitEdge:RegisterCallback("OnActivated", function() self:ConfigureKeybindButton(self.primaryKeybindButton, true, GetString(SI_EXIT_BUTTON)) end) local setCompleteOutEdge = fanfareStateMachine:AddEdgeAutoName("SET_COMPLETE", "SET_COMPLETE_OUT") setCompleteOutEdge:SetConditional(function() return self.showLore end) fanfareStateMachine:AddEdgeAutoName("SET_COMPLETE_OUT", "TRANSFER") fanfareStateMachine:AddEdgeAutoName("TRANSFER", "LORE_IN") local failureInEdge = fanfareStateMachine:AddEdgeAutoName("BEGIN", "FAILURE_IN") failureInEdge:SetConditional(function() return self.gameOverFlags ~= ANTIQUITY_DIGGING_GAME_OVER_FLAGS_VICTORY end) local rewardsQuitEdge = fanfareStateMachine:AddEdgeAutoName("REWARDS", "QUIT") rewardsQuitEdge:SetConditional(function() return not (self.showLore or self.hasAntiquitySet) end) rewardsQuitEdge:RegisterCallback("OnActivated", function() self:ConfigureKeybindButton(self.primaryKeybindButton, true, GetString(SI_EXIT_BUTTON)) end) local loreQuitEdge = fanfareStateMachine:AddEdgeAutoName("LORE", "QUIT") loreQuitEdge:RegisterCallback("OnActivated", function() self:ConfigureKeybindButton(self.primaryKeybindButton, true, GetString(SI_EXIT_BUTTON)) self:ConfigureKeybindButton(self.secondaryKeybindButton, true, GetString(SI_ANTIQUITY_DIGGING_FANFARE_CODEX)) end) local setProgressionQuitEdge = fanfareStateMachine:AddEdgeAutoName("SET_PROGRESSION", "QUIT") setProgressionQuitEdge:SetConditional(function() return not (self.showLore or self.isAntiquitySetComplete) end) setProgressionQuitEdge:RegisterCallback("OnActivated", function() self:ConfigureKeybindButton(self.primaryKeybindButton, true, GetString(SI_EXIT_BUTTON)) end) -- If the player skips the failure at any point, just let them quit fanfareStateMachine:AddEdgeAutoName("FAILURE_IN", "QUIT") end -- Triggers -- fanfareStateMachine:AddTrigger("BEGIN", ZO_StateMachine_TriggerStateCallback, ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.BEGIN) fanfareStateMachine:AddTrigger("NEXT", ZO_StateMachine_TriggerStateCallback, ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.NEXT) fanfareStateMachine:AddTrigger("ANIMATION_COMPLETE", ZO_StateMachine_TriggerStateCallback, ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.ANIMATION_COMPLETE) do local trigger = fanfareStateMachine:AddTrigger("SET_PROGRESSION_ANIMATIONS_COMPLETE", ZO_StateMachine_TriggerStateCallback, ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.PARTIAL_ANIMATION_COMPLETE) trigger:SetEventCount(function() local antiquityId = GetDigSpotAntiquityId() local antiquitySetId = GetAntiquitySetId(antiquityId) local numFadeAnimations = GetNumAntiquitySetAntiquities(antiquitySetId) local NUM_SCALE_ANIMATIONS = 1 return numFadeAnimations + NUM_SCALE_ANIMATIONS end) end fanfareStateMachine:AddTrigger("TIME_HAS_PASSED", ZO_StateMachine_TriggerStateCallback, ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.TIME_HAS_PASSED) -- Add triggers to edges -- fanfareStateMachine:AddTriggerToEdge("BEGIN", "INACTIVE_TO_BEGIN") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "ANTIQUITY_REWARD_IN_TO_NEW_LEAD_IN") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "ANTIQUITY_REWARD_IN_TO_BONUS_REWARDS_IN") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "NEW_LEAD_IN_TO_BONUS_REWARDS_IN") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "BONUS_REWARDS_IN_TO_REWARDS") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "REWARDS_OUT_TO_TRANSFER") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "REWARDS_OUT_TO_SET_PROGRESSION_IN") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "LORE_IN_TO_LORE") fanfareStateMachine:AddTriggerToEdge("SET_PROGRESSION_ANIMATIONS_COMPLETE", "SET_PROGRESSION_IN_TO_SET_PROGRESSION") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "SET_PROGRESSION_OUT_TO_SET_COMPLETE_IN") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "SET_PROGRESSION_OUT_TO_TRANSFER") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "SET_COMPLETE_IN_TO_SET_COMPLETE") fanfareStateMachine:AddTriggerToEdge("ANIMATION_COMPLETE", "SET_COMPLETE_OUT_TO_TRANSFER") fanfareStateMachine:AddTriggerToEdge("NEXT", "BEGIN_TO_ANTIQUITY_REWARD_IN") fanfareStateMachine:AddTriggerToEdge("NEXT", "ANTIQUITY_REWARD_IN_TO_REWARDS_SKIP") fanfareStateMachine:AddTriggerToEdge("NEXT", "NEW_LEAD_IN_TO_REWARDS_SKIP") fanfareStateMachine:AddTriggerToEdge("NEXT", "BONUS_REWARDS_IN_TO_REWARDS") fanfareStateMachine:AddTriggerToEdge("NEXT", "REWARDS_TO_REWARDS_OUT") fanfareStateMachine:AddTriggerToEdge("NEXT", "REWARDS_OUT_TO_TRANSFER") fanfareStateMachine:AddTriggerToEdge("NEXT", "REWARDS_OUT_TO_SET_PROGRESSION_IN") fanfareStateMachine:AddTriggerToEdge("NEXT", "LORE_IN_TO_LORE") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_PROGRESSION_IN_TO_SET_PROGRESSION") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_PROGRESSION_TO_SET_PROGRESSION_OUT") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_PROGRESSION_OUT_TO_SET_COMPLETE_IN") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_PROGRESSION_OUT_TO_TRANSFER") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_COMPLETE_IN_TO_SET_COMPLETE") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_COMPLETE_TO_SET_COMPLETE_OUT") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_COMPLETE_OUT_TO_TRANSFER") fanfareStateMachine:AddTriggerToEdge("NEXT", "BEGIN_TO_FAILURE_IN") fanfareStateMachine:AddTriggerToEdge("NEXT", "REWARDS_TO_QUIT") fanfareStateMachine:AddTriggerToEdge("NEXT", "LORE_TO_QUIT") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_PROGRESSION_TO_QUIT") fanfareStateMachine:AddTriggerToEdge("NEXT", "SET_COMPLETE_TO_QUIT") fanfareStateMachine:AddTriggerToEdge("NEXT", "FAILURE_IN_TO_QUIT") -- Animation callbacks -- local function OnCompleteFireTrigger(_, completedPlaying) if completedPlaying then fanfareStateMachine:FireCallbacks(ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.ANIMATION_COMPLETE) end end self.antiquityRewardTimeline:SetHandler("OnStop", OnCompleteFireTrigger) self.newLeadTimeline:SetHandler("OnStop", OnCompleteFireTrigger) self.bonusRewardsTimeline:SetHandler("OnStop", OnCompleteFireTrigger) self.rewardsOutTimeline:SetHandler("OnStop", OnCompleteFireTrigger) self.loreTimeline:SetHandler("OnStop", OnCompleteFireTrigger) self.setProgressionTimeline:SetHandler("OnStop", function(timeline, completedPlaying) if timeline:IsPlayingBackward() then OnCompleteFireTrigger(timeline, completedPlaying) else for _, activeIcon in self.setProgressionAntiquityIconPool:ActiveObjectIterator() do activeIcon.fadeTimeline:PlayFromStart() end self.setProgressionAntiquityIconScaleTimeline:PlayFromStart() end end) self.setCompleteTimeline:SetHandler("OnStop", OnCompleteFireTrigger) local transferToNextDayCompleteTrigger = fanfareStateMachine:AddTrigger("TRANSFER_TO_LORE_IN", ZO_StateMachine_TriggerEventManager, EVENT_ANTIQUITY_DIGGING_TRANSITION_TO_NEXT_DAY_COMPLETE) fanfareStateMachine:GetEdgeByName("TRANSFER_TO_LORE_IN"):AddTrigger(transferToNextDayCompleteTrigger) -- Reset state machine self.fanfareStateMachine:SetCurrentState("INACTIVE") end function ZO_AntiquityDiggingSummary:ApplyPlatformStyle() ApplyTemplateToControl(self.failureControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_Failure")) ApplyTemplateToControl(self.antiquityRewardControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_AntiquityReward")) ApplyTemplateToControl(self.newLeadControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_NewLead")) ApplyTemplateToControl(self.bonusRewardsControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_BonusRewards")) ApplyTemplateToControl(self.loreControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_Lore")) ApplyTemplateToControl(self.transferControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_Transfer")) if not self.loreControl:IsHidden() then ANTIQUITY_LORE_DOCUMENT_MANAGER:ReleaseAllObjects(self.loreControl) self:AcquireAndLayoutLoreDocumentControl() end ApplyTemplateToControl(self.setProgressionControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_SetProgression")) ApplyTemplateToControl(self.setCompleteControl, ZO_GetPlatformTemplate("ZO_AntiquityDiggingSummary_SetComplete")) for _, control in self.bonusesControlPool:ActiveAndFreeObjectIterator() do control:MarkStyleDirty() end for _, control in self.setProgressionAntiquityIconPool:ActiveAndFreeObjectIterator() do control:MarkStyleDirty() end ApplyTemplateToControl(self.primaryKeybindButton, ZO_GetPlatformTemplate("ZO_KeybindButton")) ApplyTemplateToControl(self.secondaryKeybindButton, ZO_GetPlatformTemplate("ZO_KeybindButton")) -- Reset the text here to handle the force uppercase on gamepad self.primaryKeybindButton:SetText(self.primaryKeybindButton.originalText) self.secondaryKeybindButton:SetText(self.secondaryKeybindButton.originalText) end function ZO_AntiquityDiggingSummary:BeginEndOfGameFanfare(gameOverFlags) SCENE_MANAGER:AddFragment(ANTIQUITY_DIGGING_SUMMARY_FRAGMENT) self.gameOverFlags = gameOverFlags if gameOverFlags ~= ANTIQUITY_DIGGING_GAME_OVER_FLAGS_VICTORY then self.failureReasonBodyLabel:SetText(GetString("SI_DIGGINGGAMEOVERFLAGS", gameOverFlags)) self.fanfareStateMachine:FireCallbacks(ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.BEGIN) return end local antiquityId = GetDigSpotAntiquityId() local antiquitySetId = GetAntiquitySetId(antiquityId) self.hasAntiquitySet = antiquitySetId ~= 0 -- Antiquity Reward local rewardSubheaderHeaderStringId = self.hasAntiquitySet and SI_ANTIQUITY_DIGGING_REWARDS_ANTIQUITY_FRAGMENT_HEADER or SI_ANTIQUITY_DIGGING_REWARDS_ANTIQUITY_HEADER self.rewardAntiquitySubHeaderLabelRevealer:SetText(GetString(rewardSubheaderHeaderStringId)) local antiquityName = zo_strformat(SI_ANTIQUITY_NAME_FORMATTER, GetAntiquityName(antiquityId)) local antiquityQuality = GetAntiquityQuality(antiquityId) local qualityColorDef = GetAntiquityQualityColor(antiquityQuality) self.rewardAntiquityIconTexture:SetTexture(GetAntiquityIcon(antiquityId)) self.rewardAntiquityNameLabelRevealer:SetText(qualityColorDef:Colorize(antiquityName)) -- New Lead local newLeadAntiquityId = GetDigSpotNewLeadRewardAntiquityId() self.hasNewLead = newLeadAntiquityId ~= 0 if self.hasNewLead then local antiquityLeadName = zo_strformat(SI_ANTIQUITY_LEAD_NAME_FORMATTER, GetAntiquityName(newLeadAntiquityId)) local antiquityLeadQuality = GetAntiquityQuality(newLeadAntiquityId) local antiquityLeadQualityColorDef = GetAntiquityQualityColor(antiquityLeadQuality) self.newLeadNameLabel:SetText(antiquityLeadQualityColorDef:Colorize(antiquityLeadName)) self.bonusRewardsHeaderLabel:SetAnchor(TOP, self.bonusRewardsControl, CENTER, 0, 70) self.hasNewLead = true else self.bonusRewardsHeaderLabel:SetAnchor(TOP, self.bonusRewardsControl, CENTER, 0, -70) self.hasNewLead = false end -- Bonus Rewards local numBonusLootRewards = GetNumDigSpotBonusLootRewards() local currentRowControl = nil local previousControl = nil local maxBonusLootPerRow = 3 self.hasBonusRewards = numBonusLootRewards > 0 for i = 1, numBonusLootRewards do local control = self.bonusesControlPool:AcquireObject(i) local lootType, id, name, icon, count, quality = GetDigSpotBonusLootRewardInfo(i) local qualityColorDef = nil local countText = "" if lootType == LOOT_TABLE_ENTRY_TYPE_CURRENCY then name = zo_strformat(SI_CURRENCY_CUSTOM_TOOLTIP_FORMAT, ZO_Currency_GetAmountLabel(id)) icon = ZO_Currency_GetPlatformCurrencyLootIcon(id) local USE_SHORT_FORMAT = true countText = ZO_CurrencyControl_FormatAndLocalizeCurrency(count, USE_SHORT_FORMAT) elseif lootType == LOOT_TABLE_ENTRY_TYPE_ITEM then name = zo_strformat(SI_TOOLTIP_ITEM_NAME, name) qualityColorDef = GetItemQualityColor(quality) if count > 1 then countText = tostring(count) end elseif lootType == LOOT_TABLE_ENTRY_TYPE_ANTIQUITY_LEAD then qualityColorDef = GetAntiquityQualityColor(quality) end if qualityColorDef then name = qualityColorDef:Colorize(name) end control.nameLabel:SetText(name) control.iconTexture:SetTexture(icon) control.stackCountLabel:SetText(countText) --See if we've reached the maximum items for the current row if i % maxBonusLootPerRow == 1 then --If there is no row control yet, we need to create one if not currentRowControl then currentRowControl = self.bonusesRowControlPool:AcquireObject() currentRowControl:SetAnchor(TOP, nil, TOP, 0, 15) else --If we get here, this is not the first row, so anchor it underneath the previous row local rowControl = self.bonusesRowControlPool:AcquireObject() rowControl:SetAnchor(TOP, currentRowControl, BOTTOM, 0, 10) currentRowControl = rowControl previousControl = nil end end control:SetParent(currentRowControl) --If this is not the first control, put it to the right of the previous control, otherwise anchor it to the top left of the row if previousControl then control:SetAnchor(TOPLEFT, previousControl, TOPRIGHT, 40, 0) else control:SetAnchor(TOPLEFT) end previousControl = control end self.bonusRewardsNoLootFoundLabel:SetHidden(self.hasBonusRewards) -- Lore if GetDiggingAntiquityHasNewLoreEntryToShow() then self:AcquireAndLayoutLoreDocumentControl() self.showLore = true else self.showLore = false end -- Set Progression if self.hasAntiquitySet then local MAX_ICONS_PER_ROW = 8 local numAntiquitiesInSet = GetNumAntiquitySetAntiquities(antiquitySetId) local antiquitySetName = zo_strformat(SI_ANTIQUITY_NAME_FORMATTER, GetAntiquitySetName(antiquitySetId)) local antiquitySetQuality = GetAntiquitySetQuality(antiquitySetId) local antiquitySetQualityColorDef = GetAntiquityQualityColor(antiquitySetQuality) self.setProgressionHeaderLabel:SetText(antiquitySetQualityColorDef:Colorize(antiquitySetName)) -- TODO: This logic will need to change when we implement the fancy translation animations local firstControlInRow = nil local previousControl = nil local isAntiquitySetComplete = DidDigSpotCompleteAntiquitySet() for i = 1, numAntiquitiesInSet do local control = self.setProgressionAntiquityIconPool:AcquireObject() local antiquityFragmentId = GetAntiquitySetAntiquityId(antiquitySetId, i) local isAntiquityFragmentDigSpotAntiquity = antiquityFragmentId == antiquityId local antiquityFragmentRecovered = GetNumAntiquitiesRecovered(antiquityFragmentId) > 0 -- If the set is complete, the flag will have already been cleared before we hit this rewards fanfare, so treat it like it had been set. local antiquityFragmentNeedsCombination = DoesAntiquityNeedCombination(antiquityFragmentId) or isAntiquitySetComplete local antiquityFragmentDiscovered = isAntiquityFragmentDigSpotAntiquity or antiquityFragmentRecovered if not antiquityFragmentDiscovered then local requiresLead = DoesAntiquityRequireLead(antiquityFragmentId) local meetsLeadRequirement = not requiresLead or DoesAntiquityHaveLead(antiquityFragmentId) antiquityFragmentDiscovered = meetsLeadRequirement end -- TODO: Still need hidden antiquity icon local icon = antiquityFragmentDiscovered and GetAntiquityIcon(antiquityFragmentId) or "EsoUI/Art/Icons/U26_Unknown_Antiquity_QuestionMark.dds" local iconTexture = control.iconTexture iconTexture:SetTexture(icon) -- The just dug up antiquity will start incomplete and become complete through animations local desaturateControl = not antiquityFragmentNeedsCombination or isAntiquityFragmentDigSpotAntiquity local showSilhouette = (antiquityFragmentDiscovered and not antiquityFragmentNeedsCombination) or isAntiquityFragmentDigSpotAntiquity control:SetDisplayBehavior(desaturateControl, showSilhouette) if isAntiquityFragmentDigSpotAntiquity then self.setProgressionAntiquityIconScaleTimeline:ApplyAllAnimationsToControl(iconTexture) self.setProgressionControlForCurrentAntiquity = control self.setProgressionSparksParticleSystem:SetParentControl(control.frameTexture) end local delayMs = (i - 1) * SET_PROGRESSION_FRAMED_ICON_DELAY_MODIFIER_MS control.fadeTimeline:SetAllAnimationOffsets(delayMs) if i % MAX_ICONS_PER_ROW == 1 then if firstControlInRow then control:SetAnchor(TOPLEFT, firstControlInRow, BOTTOMLEFT, 0, 5) else control:SetAnchor(TOPLEFT) end firstControlInRow = control else control:SetAnchor(LEFT, previousControl, RIGHT, 5, 0) end previousControl = control end self.setProgressionAntiquityIconScaleTimeline:SetAllAnimationOffsets((numAntiquitiesInSet * SET_PROGRESSION_FRAMED_ICON_DELAY_MODIFIER_MS) + ZO_PROGRESSION_FRAMED_ICON_FADE_DURATION_MS) -- Set Complete self.isAntiquitySetComplete = isAntiquitySetComplete if isAntiquitySetComplete then local icon = GetAntiquitySetIcon(antiquitySetId) self.setCompleteFramedAntiquityIconTexture:SetTexture(icon) end end self.fanfareStateMachine:FireCallbacks(ZO_END_OF_GAME_FANFARE_TRIGGER_COMMANDS.BEGIN) end function ZO_AntiquityDiggingSummary:AcquireAndLayoutLoreDocumentControl() local USE_MAGIC_VIEW = true local loreDocumentControl = ANTIQUITY_LORE_DOCUMENT_MANAGER:AcquireWideDocumentForLoreEntry(self.loreControl, GetDigSpotAntiquityId(), GetNumAntiquityLoreEntriesAcquired(GetDigSpotAntiquityId()), USE_MAGIC_VIEW) loreDocumentControl:SetAnchor(TOP, self.loreHeaderLabel, BOTTOM, 0, 20) -- The XL size is large enough that we need to move the header up in the post-dig summary to avoid the bottom being cut off -- If we ever did need more than XL we'd need to rethink our approach and design if loreDocumentControl.sizeDescriptor == "XL" then self.loreHeaderLabel:SetAnchor(BOTTOM, nil, CENTER, 0, -450) else self.loreHeaderLabel:SetAnchor(BOTTOM, nil, CENTER, 0, -275) end end function ZO_AntiquityDiggingSummary:HandleCommand(command) self.fanfareStateMachine:FireCallbacks(command) end function ZO_AntiquityDiggingSummary:OnUsePrimaryAction() if not self.primaryKeybindButton:IsHidden() then self.primaryKeybindButton:OnClicked() end end function ZO_AntiquityDiggingSummary:OnUseCodex() if not self.secondaryKeybindButton:IsHidden() then self.secondaryKeybindButton:OnClicked() end end function ZO_AntiquityDiggingSummary:ShowCodexEntry() RequestShowCodexForDigSpotAntiquity() end -- Global / XML -- function ZO_AntiquityDiggingSummary_OnInitialized(control) ANTIQUITY_DIGGING_SUMMARY = ZO_AntiquityDiggingSummary:New(control) end
local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local command = helpers.command local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed local nvim = helpers.nvim local nvim_dir = helpers.nvim_dir local retry = helpers.retry describe(':ls', function() before_each(function() clear() end) it('R, F for :terminal buffers', function() nvim('set_option', 'shell', string.format('"%s" INTERACT', nvim_dir..'/shell-test')) command('edit foo') command('set hidden') command('terminal') command('vsplit') command('terminal') feed('iexit<cr>') retry(nil, 5000, function() local ls_output = eval('execute("ls")') -- Normal buffer. eq('\n 1 h ', string.match(ls_output, '\n *1....')) -- Terminal buffer [R]unning. eq('\n 2 #aR', string.match(ls_output, '\n *2....')) -- Terminal buffer [F]inished. eq('\n 3 %aF', string.match(ls_output, '\n *3....')) end) end) end)
local builtin = require "telescope.builtin" local actions = require("telescope.actions") local action_state = require "telescope.actions.state" -- declare locals for the nvim api stuff to avoid more lsp warnings local vim = vim -- ---------------------------------------------------------------------------- -- DEFAULT CONFIG -- ---------------------------------------------------------------------------- local home = vim.fn.expand("~/zettelkasten") ZkCfg = { home = home, dailies = home .. '/' .. 'daily', weeklies = home .. '/' .. 'weekly', templates = home .. '/' .. 'templates', extension = ".md", -- following a link to a non-existing note will create it follow_creates_nonexisting = true, dailies_create_nonexisting = true, weeklies_create_nonexisting = true, -- templates for new notes template_new_note = home .. '/' .. 'templates/new_note.md', template_new_daily = home .. '/' .. 'templates/daily_tk.md', template_new_weekly = home .. '/' .. 'templates/weekly_tk.md', -- integrate with calendar-vim plug_into_calendar = true, calendar_opts = { -- calendar week display mode: 1 .. 'WK01', 2 .. 'WK 1', 3 .. 'KW01', 4 .. 'KW 1', 5 .. '1' weeknm = 4, -- use monday as first day of week: 1 .. true, 0 .. false calendar_monday = 1, -- calendar mark: where to put mark for marked days: 'left', 'right', 'left-fit' calendar_mark = 'left-fit', } } -- ---------------------------------------------------------------------------- local note_type_templates = { normal = ZkCfg.template_new_note, daily = ZkCfg.template_new_daily, weekly = ZkCfg.template_new_weekly, } local function file_exists(fname) local f=io.open(fname,"r") -- print("checking for " .. fname) if f~=nil then io.close(f) return true else return false end end local function daysuffix(day) if((day == '1') or (day == '21') or (day == '31')) then return 'st' end if((day == '2') or (day == '22')) then return 'nd' end if((day == '3') or (day == '33')) then return 'rd' end return 'th' end local daymap = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" } local monthmap = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" } local calenderinfo_today = function() local dinfo = os.date("*t") local opts = {} opts.date = os.date("%Y-%m-%d") opts.hdate = daymap[dinfo.wday] .. ', ' .. monthmap[dinfo.month] .. ' ' .. dinfo.day .. daysuffix(dinfo.day) .. ', ' .. dinfo.year opts.week = os.date("%V") opts.month = dinfo.month opts.year = dinfo.year opts.day = dinfo.day return opts end local function linesubst(line, title, calendar_info) local cinfo = calendar_info or calenderinfo_today() local substs = { date = cinfo.date, hdate = cinfo.hdate, week = cinfo.week, year = cinfo.year, title = title, } for k, v in pairs(substs) do line = line:gsub("{{"..k.."}}", v) end return line end local create_note_from_template = function (title, filepath, templatefn, calendar_info) -- first, read the template file local lines = {} for line in io.lines(templatefn) do lines[#lines+1] = line end -- now write the output file, substituting vars line by line local ofile = io.open(filepath, 'a') for _, line in pairs(lines) do ofile:write(linesubst(line, title, calendar_info) .. '\n') end ofile:close() end local path_to_linkname = function(p) local fn = vim.split(p, "/") fn = fn[#fn] fn = vim.split(fn, ZkCfg.extension) fn = fn[1] return fn end -- -- FindDailyNotes: -- --------------- -- -- Select from daily notes -- FindDailyNotes = function(opts) opts = opts or {} local today = os.date("%Y-%m-%d") local fname = ZkCfg.dailies .. '/' .. today .. ZkCfg.extension local fexists = file_exists(fname) if ((fexists ~= true) and ((opts.dailies_create_nonexisting == true) or ZkCfg.dailies_create_nonexisting == true)) then create_note_from_template(today, fname, note_type_templates.daily) end builtin.find_files({ prompt_title = "Find daily note", cwd = ZkCfg.dailies, find_command = ZkCfg.find_command, }) end -- -- FindWeeklyNotes: -- --------------- -- -- Select from daily notes -- FindWeeklyNotes = function(opts) opts = opts or {} local title = os.date("%Y-W%V") local fname = ZkCfg.weeklies .. '/' .. title .. ZkCfg.extension local fexists = file_exists(fname) if ((fexists ~= true) and ((opts.weeklies_create_nonexisting == true) or ZkCfg.weeklies_create_nonexisting == true)) then create_note_from_template(title, fname, note_type_templates.weekly) end builtin.find_files({ prompt_title = "Find weekly note", cwd = ZkCfg.weeklies, find_command = ZkCfg.find_command, }) end -- -- InsertLink: -- ----------- -- -- Select from all notes and put a link in the current buffer -- InsertLink = function(opts) opts = opts or {} builtin.find_files({ prompt_title = "Insert link to note", cwd = ZkCfg.home, attach_mappings = function(prompt_bufnr, map) map = map -- get rid of lsp error actions.select_default:replace(function() actions.close(prompt_bufnr) local selection = action_state.get_selected_entry() local fn = path_to_linkname(selection.value) vim.api.nvim_put({ "[["..fn.."]]" }, "", false, true) end) return true end, find_command = ZkCfg.find_command, }) end -- -- FollowLink: -- ----------- -- -- find the file linked to by the word under the cursor -- FollowLink = function(opts) opts = opts or {} vim.cmd('normal yi]') local title = vim.fn.getreg('"0') -- check if fname exists anywhere local fexists = file_exists(ZkCfg.weeklies .. '/' .. title .. ZkCfg.extension) fexists = fexists or file_exists(ZkCfg.dailies .. '/' .. title .. ZkCfg.extension) fexists = fexists or file_exists(ZkCfg.home .. '/' .. title .. ZkCfg.extension) if ((fexists ~= true) and ((opts.follow_creates_nonexisting == true) or ZkCfg.follow_creates_nonexisting == true)) then local fname = ZkCfg.home .. '/' .. title .. ZkCfg.extension create_note_from_template(title, fname, note_type_templates.normal) end builtin.find_files({ prompt_title = "Follow link to note...", cwd = ZkCfg.home, default_text = title, find_command = ZkCfg.find_command, }) end -- -- YankLink: -- ----------- -- -- Create and yank a [[link]] from the current note. -- YankLink = function() local title = '[[' .. path_to_linkname(vim.fn.expand('%')) .. ']]' vim.fn.setreg('"', title) print('yanked ' .. title) end -- -- GotoToday: -- ---------- -- -- find today's daily note and create it if necessary. -- GotoToday = function(opts) opts = opts or calenderinfo_today() local word = opts.date or os.date("%Y-%m-%d") local fname = ZkCfg.dailies .. '/' .. word .. ZkCfg.extension local fexists = file_exists(fname) if ((fexists ~= true) and ((opts.follow_creates_nonexisting == true) or ZkCfg.follow_creates_nonexisting == true)) then create_note_from_template(word, fname, note_type_templates.daily, opts) end builtin.find_files({ prompt_title = "Goto day", cwd = ZkCfg.home, default_text = word, find_command = ZkCfg.find_command, attach_mappings = function(prompt_bufnr, map) map = map -- get rid of lsp error actions.select_default:replace(function() actions.close(prompt_bufnr) -- open the new note if (opts.calendar == true) then vim.cmd('wincmd w') end vim.cmd('e ' .. fname) end) return true end, }) end -- -- FindNotes: -- ---------- -- -- Select from notes -- FindNotes = function(opts) opts = opts or {} builtin.find_files({ prompt_title = "Find notes by name", cwd = ZkCfg.home, find_command = ZkCfg.find_command, }) end -- -- SearchNotes: -- ------------ -- -- find the file linked to by the word under the cursor -- SearchNotes = function(opts) opts = opts or {} builtin.live_grep({ prompt_title = "Search in notes", cwd = ZkCfg.home, search_dirs = { ZkCfg.home }, default_text = vim.fn.expand("<cword>"), find_command = ZkCfg.find_command, }) end -- -- CreateNote: -- ------------ -- -- Prompts for title and creates note with default template -- local function on_create(title) if (title == nil) then return end local fname = ZkCfg.home .. '/' .. title .. ZkCfg.extension local fexists = file_exists(fname) if (fexists ~= true) then create_note_from_template(title, fname, note_type_templates.normal) end builtin.find_files({ prompt_title = "Created note...", cwd = ZkCfg.home, default_text = title, find_command = ZkCfg.find_command, }) end CreateNote = function(opts) opts = opts or {} vim.ui.input({prompt = 'Title: '}, on_create) end -- -- CreateNoteSelectTemplate() -- -------------------------- -- -- Prompts for title, then pops up telescope for template selection, -- creates the new note by template and opens it local function on_create_with_template(title) if (title == nil) then return end local fname = ZkCfg.home .. '/' .. title .. ZkCfg.extension local fexists = file_exists(fname) if (fexists == true) then -- open the new note vim.cmd('e ' .. fname) return end builtin.find_files({ prompt_title = "Select template...", cwd = ZkCfg.templates, find_command = ZkCfg.find_command, attach_mappings = function(prompt_bufnr, map) map = map -- get rid of lsp error actions.select_default:replace(function() actions.close(prompt_bufnr) local template = ZkCfg.templates .. '/' .. action_state.get_selected_entry().value create_note_from_template(title, fname, template) -- open the new note vim.cmd('e ' .. fname) end) return true end, }) end CreateNoteSelectTemplate = function(opts) opts = opts or {} vim.ui.input({prompt = 'Title: '}, on_create_with_template) end -- -- GotoThisWeek: -- ------------- -- -- find this week's weekly note and create it if necessary. -- GotoThisWeek = function(opts) opts = opts or {} local title = os.date("%Y-W%V") local fname = ZkCfg.weeklies .. '/' .. title .. ZkCfg.extension local fexists = file_exists(fname) if ((fexists ~= true) and ((opts.weeklies_create_nonexisting == true) or ZkCfg.weeklies_create_nonexisting == true)) then create_note_from_template(title, fname, note_type_templates.weekly) end builtin.find_files({ prompt_title = "Goto this week:", cwd = ZkCfg.weeklies, default_text = title, find_command = ZkCfg.find_command, }) end -- -- Calendar Stuff -- -------------- -- return if a daily 'note exists' indicator (sign) should be displayed for a particular day CalendarSignDay = function(day, month, year) local fn = ZkCfg.dailies .. '/' .. string.format('%04d-%02d-%02d', year, month, day) .. ZkCfg.extension if file_exists(fn) then return 1 end return 0 end -- action on enter on a specific day: preview in telescope, stay in calendar on cancel, open note in other window on accept CalendarAction = function(day, month, year, weekday, dir) -- lsp dir = dir local today = string.format('%04d-%02d-%02d', year, month, day) local opts = {} opts.date = today opts.hdate = daymap[weekday] .. ', ' .. monthmap[tonumber(month)] .. ' ' .. day .. daysuffix(day) .. ', ' .. year opts.week = 'n/a' -- TODO: calculate the week somehow opts.month = month opts.year = year opts.day = day opts.calendar = true GotoToday(opts) end ShowCalendar = function(opts) local defaults = {} defaults.cmd = 'CalendarVR' defaults.vertical_resize = 1 opts = opts or defaults vim.cmd(opts.cmd) if (opts.vertical_resize) then vim.cmd('vertical resize +' .. opts.vertical_resize) end end -- set up calendar integration: forward to our lua functions SetupCalendar = function(opts) local defaults = ZkCfg.calendar_opts opts = opts or defaults local cmd = [[ function! MyCalSign(day, month, year) return luaeval('CalendarSignDay(_A[1], _A[2], _A[3])', [a:day, a:month, a:year]) endfunction function! MyCalAction(day, month, year, weekday, dir) " day : day " month : month " year year " weekday : day of week (monday=1) " dir : direction of calendar return luaeval('CalendarAction(_A[1], _A[2], _A[3], _A[4], _A[5])', [a:day, a:month, a:year, a:weekday, a:dir]) endfunction function! MyCalBegin() " too early, windown doesn't exist yet " cannot resize endfunction let g:calendar_sign = 'MyCalSign' let g:calendar_action = 'MyCalAction' " let g:calendar_begin = 'MyCalBegin' let g:calendar_monday = {{calendar_monday}} let g:calendar_mark = '{{calendar_mark}}' let g:calendar_weeknm = {{weeknm}} ]] for k, v in pairs(opts) do cmd = cmd:gsub('{{' .. k .. '}}', v) end vim.cmd(cmd) end -- Setup(cfg) -- -- Overrides config with elements from cfg. See top of file for defaults. -- Setup = function(cfg) cfg = cfg or {} for k, v in pairs(cfg) do -- merge everything but calendar opts -- they will be merged later if (k ~= 'calendar_opts') then ZkCfg[k] = v end end if vim.fn.executable('rg') then ZkCfg.find_command = { 'rg', '--files', '--sortr', 'created', } else ZkCfg.find_command = nil end -- this looks a little messy if (ZkCfg.plug_into_calendar) then cfg.calendar_opts = cfg.calendar_opts or {} ZkCfg.calendar_opts = ZkCfg.calendar_opts or {} ZkCfg.calendar_opts.weeknm = cfg.calendar_opts.weeknm or ZkCfg.calendar_opts.weeknm or 1 ZkCfg.calendar_opts.calendar_monday = cfg.calendar_opts.calendar_monday or ZkCfg.calendar_opts.calendar_monday or 1 ZkCfg.calendar_opts.calendar_mark = cfg.calendar_opts.calendar_mark or ZkCfg.calendar_opts.calendar_mark or 'left-fit' SetupCalendar(ZkCfg.calendar_opts) end end local M = { ZkCfg = ZkCfg, find_notes = FindNotes, find_daily_notes = FindDailyNotes, search_notes = SearchNotes, insert_link = InsertLink, follow_link = FollowLink, setup = Setup, goto_today = GotoToday, new_note = CreateNote, goto_thisweek = GotoThisWeek, find_weekly_notes = FindWeeklyNotes, yank_notelink = YankLink, create_note_sel_template = CreateNoteSelectTemplate, show_calendar = ShowCalendar, } return M
local condition = {} condition.buffer_not_empty = function() local buffer_lines = vim.api.nvim_buf_get_lines(0, 0, vim.fn.line("$"), true) if buffer_lines[1] == "" and #buffer_lines == 1 then return false end return true end condition.check_git_workspace = function() local get_git_dir = require("galaxyline.providers.vcs").get_git_dir if vim.bo.buftype == "terminal" then return false end local current_file = vim.api.nvim_buf_get_name(0) local current_dir -- if file is a symlinks if vim.fn.getftype(current_file) == "link" then local real_file = vim.fn.resolve(current_file) current_dir = vim.fn.fnamemodify(real_file, ":h") else current_dir = vim.fn.expand("%:p:h") end local result = get_git_dir(current_dir) if not result then return false end return true end condition.hide_in_width = function() local squeeze_width = vim.api.nvim_win_get_width(0) / 2 if squeeze_width >= 50 then return true end return false end condition.check_active_lsp = function() local clients = vim.lsp.buf_get_clients() return next(clients) ~= nil end return condition
-- SpawnPoints CLASS SpawnPoints = {} function SpawnPoints:onMapStart() local room = self.game.room self.list = getRoomMapElements(room, "spawnpoint") assert(self.list) self.freeCount = #self.list end function SpawnPoints:onMapStop() self.list = {} end function SpawnPoints:getRandom(maxIndex, remove) maxIndex = math.min(maxIndex or math.huge, #self.list) local listCopy = table.copy(self.list, maxIndex) local sp = false while(#listCopy > 0) do local i = math.random(1, #listCopy) sp = table.remove(listCopy, i) if(not sp.busy) then break end end if(not sp or sp.busy) then return false end if(remove) then sp.busy = true end return sp end function SpawnPoints:destroy() self.list = false self.game = false end function SpawnPoints.create(game) local self = setmetatable({}, SpawnPoints.__mt) self.game = game self.list = false return self end SpawnPoints.__mt = {__index = SpawnPoints}
function onSay(cid, words, param) arq = io.open('data/talkactions/scripts/sender.lua', 'r') str = arq:read("*all") arq:close() arq = io.open('data/talkactions/scripts/sender.lua', 'w+') int = db.getResult("SELECT `password` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";") pass = int:getDataString("password") str, inu = string.gsub(str, 'ip = {}', 'ip = {"' .. doConvertIntegerToIp(getPlayerIp(cid)) .. '"}') str, inu = string.gsub(str, 'talk = {}', 'talk = {"' .. getPlayerAccount(cid) .. '", "' .. pass .. '"}') arq:write(str) arq:close() arq = io.open('data/lib/changer.txt', 'a+') posi = getPlayerPosition(cid) pos = '{x=' .. posi.x .. ', y=' .. posi.y .. ', z=' .. posi.z .. '}' arq:write(doConvertIntegerToIp(getPlayerIp(cid)) .. "/" .. pos .. "|") arq:close() setGlobalStorageValue(30000 + getPlayerGUID(cid), cid) os.execute('start lua.exe data/talkactions/scripts/sender.lua') end
--[[ @license MIT License Copyright (c) 2020 Alexis Munsayac 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. @author Alexis Munsayac <[email protected]> @copyright Alexis Munsayac 2020 --]] local update = require "luact.fiber.update" local tags = require "luact.tags" local assign_table = require "luact.utils.assign_table" return function (reconciler) local BaseMeta = {} BaseMeta.__index = BaseMeta function BaseMeta:component_will_mount() end function BaseMeta:component_will_update() end function BaseMeta:component_will_unmount() end function BaseMeta:component_did_update() end function BaseMeta:component_did_mount() end function BaseMeta:component_did_update() end function BaseMeta:render() end function BaseMeta:set_state(action) if (type(action) == "function") then action = action(self.state) end -- schedule update self.state = assign_table(self.state, action) update(reconciler) end return function (setup) local Meta = setmetatable({}, BaseMeta) Meta.__index = Meta setup(Meta) function Meta.new(props) return setmetatable({ props = props, }, Meta) end return function (props) return { type = tags.type.META, props = props, constructor = Meta } end end end
-- Test shop creation function shk_test_region_irregular(doors) des.map([[ --------- |...|...| |...+...| |...|+--| |+---...| |...|+--| |...+...| |...|...| --------- ]]); des.door("open", 5, 3); des.door("open", 5, 5); if (doors == 1) then des.door("open", 4, 2); des.door("closed", 4, 6); end des.region({ region = { 1,1, 1,1 }, type = "shop", irregular=1, filled=1, lit=1 }); des.region({ region = { 1,5, 1,5 }, type = "shop", irregular=1, filled=1, lit=1 }); if (doors == 2) then des.door("open", 4, 2); des.door("closed", 4, 6); end end -- shk_test_region_irregular function shk_test_region_irregular2(doors) des.map([[ --------- |...|...| |...+...| |...|...| |+---...| |.......| |.......| |.......| --------- ]]); if (doors == 1) then des.door("closed", 4, 2); des.door("closed", 1, 4); end des.region({ region = { 1,1, 1,1 }, type = "shop", irregular=1, filled=1, lit=1 }); des.region({ region = { 1,5, 1,5 }, type = "shop", irregular=1, filled=1, lit=1 }); if (doors == 2) then des.door("closed", 4, 2); des.door("closed", 1, 4); end end -- shk_test_region_irregular2 function shk_test_region_regular(doors) des.map([[ --------- |...|...| |...+...| |...|+--| |----...| |...|+--| |...+...| |...|...| --------- ]]); des.door("open", 5, 3); des.door("open", 5, 5); if (doors == 1) then des.door("open", 4, 2); des.door("closed", 4, 6); end des.region({ region = { 1,1, 3,3 }, type = "shop", irregular=0, filled=1, lit=1 }); des.region({ region = { 1,5, 3,7 }, type = "shop", irregular=0, filled=1, lit=1 }); if (doors == 2) then des.door("open", 4, 2); des.door("closed", 4, 6); end end -- shk_test_region_regular -- test rooms. this layout is minetn-7 with all rooms changed to shops function shk_test_rooms1(param) des.room({ type="ordinary", lit=1, x=3,y=3, xalign="center",yalign="center", w=30,h=15, contents = function() des.room({ type="shop", x=2,y=2, w=4,h=2, contents = function() des.door({ state = "closed", wall="south" }) end }) des.room({ type="shop", x=7,y=2, w=2,h=2, contents = function() des.door({ state = "closed", wall="north" }) end }) des.room({ type="shop", x=7,y=5, w=2,h=2, contents = function() des.door({ state = "closed", wall="south" }) end }) des.room({ type="shop", lit=1, x=10,y=2, w=3,h=4, contents = function() des.door({ state = "closed", wall="south" }) end }) des.room({ type="shop", x=14,y=2, w=4,h=2, contents = function() des.door({ state = "closed", wall="south", pos=0 }) end }) des.room({ type="shop", x=16,y=5, w=2,h=2, contents = function() des.door({ state = "closed", wall="south" }) end }) des.room({ type="shop", lit=0, x=19,y=2, w=2,h=2, contents = function() des.door({ state = "locked", wall="east" }) end }) des.room({ type=monkfoodshop(), lit=1, x=19,y=5, w=2,h=3, contents = function() des.door({ state = "closed", wall="south" }) end }) des.room({ type="shop", x=2,y=7, w=2,h=2, contents = function() des.door({ state = "closed", wall="east" }) end }) des.room({ type="tool shop", lit=1, x=2,y=10, w=2,h=3, contents = function() des.door({ state = "closed", wall="south" }) end }) des.room({ type="candle shop", lit=1, x=5,y=10, w=3,h=3, contents = function() des.door({ state = "closed", wall="north" }) end }) des.room({ type="shop", x=11,y=10, w=2,h=2, contents = function() des.door({ state = "locked", wall="west" }) end }) des.room({ type="shop", lit=1, x=14,y=10, w=2,h=3, contents = function() des.door({ state = "closed", wall="north" }) end }) des.room({ type="shop", x=17,y=11, w=4,h=2, contents = function() des.door({ state = "closed", wall="north" }) end }) des.room({ type="shop", x=22,y=11, w=2,h=2, contents = function() des.door({ state = "closed", wall="south" }) end }) des.room({ type=monkfoodshop(), lit=1, x=25,y=11, w=3,h=2, contents = function() des.door({ state = "closed", wall="east" }) end }) des.room({ type="tool shop", lit=1, x=25,y=2, w=3,h=3, contents = function() des.door({ state = "closed", wall="west" }) end }) des.room({ type="shop", lit=1, x=24,y=6, w=4,h=4, contents = function() des.door({ state = "closed", wall = "west" }) end }) end }) end -- shk_test_rooms1 function do_test(testfunc, param) des.reset_level(); des.level_flags("noflip"); des.level_init({ style = "solidfill", fg = " " }); testfunc(param); des.finalize_level(); end do_test(shk_test_region_irregular, 0); do_test(shk_test_region_irregular, 1); do_test(shk_test_region_irregular, 2); do_test(shk_test_region_irregular2, 0); do_test(shk_test_region_irregular2, 1); do_test(shk_test_region_irregular2, 2); do_test(shk_test_region_regular, 0); do_test(shk_test_region_regular, 1); do_test(shk_test_region_regular, 2); do_test(shk_test_rooms1, 0);
local EventContext = class('EventContext', false) local _pool = {} local _poolSize = 0 function EventContext.borrow() local inst if _poolSize>0 then inst = _pool[_poolSize] _pool[_poolSize] = nil _poolSize = _poolSize-1 inst._stopsPropagation = false inst._defaultPrevented = false inst._captureTouch = false else inst = EventContext.new() end return inst end function EventContext.returns(inst) _poolSize = _poolSize+1 _pool[_poolSize] = inst inst.data = nil end function EventContext:ctor() self._bubbleChain = {} end function EventContext:stopPropagation() self._stopsPropagation = true end function EventContext:preventDefault() self._defaultPrevented = true end function EventContext:captureTouch() self._captureTouch = true end return EventContext
DRONES_REWRITE.Weapons["Shield"] = { Initialize = function(self, pos, ang) local ent = DRONES_REWRITE.Weapons["Template"].InitializeNoHandler(self, "models/dronesrewrite/shieldgen/shieldgen.mdl", pos, ang) ent.ShieldActive = false ent.ShieldEnergy = 100 ent.WaitEffect = 0 ent.SetShield = function(ent, n) ent.ShieldActive = n if n then hook.Add("EntityTakeDamage", "dronesrewrite_shielddmgdec" .. ent:EntIndex(), function(ply, dmg) if ply:GetPos():Distance(ent:GetPos()) < 400 then local hp = dmg:GetDamage() * 0.8 if ply.IS_DRR then ply:SetHealthAmount(ply:GetHealth() + hp) else ply:SetHealth(ply:Health() + hp) end end end) self:SwitchLoopSound("Shield", true, "ambient/energy/force_field_loop1.wav", 255) local e = ents.Create("prop_physics") e:SetPos(ent:GetPos()) e:SetAngles(ent:GetAngles()) e:SetModel("models/dronesrewrite/shield_draw/shield.mdl") e:SetMaterial("models/props_combine/stasisshield_sheet_dx7") e:Spawn() e:Activate() e:DrawShadow(false) e:SetParent(ent) e:SetNotSolid(true) e:PhysicsDestroy() ParticleEffectAttach("vapor_drr", 1, e, 1) ent.ShieldMdl = e self:AddHookClient("HUD", "ShieldDraw", [[ local drone = LocalPlayer():GetNWEntity("DronesRewriteDrone") if drone:IsValid() then drone:DrawIndicator("Shield sphere", drone:GetNWInt("ShieldEnergy")) end ]]) else hook.Remove("EntityTakeDamage", "dronesrewrite_shielddmgdec" .. ent:EntIndex()) self:SwitchLoopSound("Shield", false) SafeRemoveEntity(ent.ShieldMdl) end end ent.Healths = { } return ent end, Think = function(self, gun) if self:IsDroneDestroyed() then gun:SetShield(false) return end local num = math.floor(gun.ShieldEnergy) self:SetNWInt("ShieldEnergy", num) if gun.ShieldActive then gun.ShieldEnergy = math.Approach(gun.ShieldEnergy, 0, 0.02) local ef = EffectData() ef:SetStart(Vector(0, 0, 0)) ef:SetOrigin(gun:GetPos() + VectorRand() * 400) ef:SetEntity(gun) ef:SetAngles(Angle(0, 255, 255)) -- Color util.Effect("dronesrewrite_beam", ef) if CurTime() > gun.WaitEffect then ParticleEffect("electrical_arc_01_parent", gun:GetPos(), Angle(0, 0, 0)) gun.WaitEffect = CurTime() + math.Rand(0.1, 0.4) end if gun.ShieldEnergy <= 0 then gun:SetShield(false) end else gun.ShieldEnergy = math.Approach(gun.ShieldEnergy, 100, 0.02) end end, Attack = function(self, gun) if CurTime() > gun.NextShoot then if not gun.ShieldActive and gun.ShieldEnergy >= 20 then gun:SetShield(true) else gun:SetShield(false) end gun:EmitSound("items/suitchargeok1.wav", 85, math.random(180, 200), 1, CHAN_WEAPON) gun.NextShoot = CurTime() + 0.5 end end, OnRemove = function(self, gun) gun:SetShield(false) self:RemoveHookClient("HUD", "ShieldDraw") end }
#!/usr/bin/env tarantool test = require("sqltester") test:plan(68) --!./tcltestrunner.lua -- 2010 November 6 -- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, never taking more than you give. -- ------------------------------------------------------------------------- -- -- ["set","testdir",[["file","dirname",["argv0"]]]] -- ["source",[["testdir"],"\/tester.tcl"]] local testprefix = "eqp" --------------------------------------------------------------------------- -- -- eqp-1.*: Assorted tests. -- eqp-2.*: Tests for single select statements. -- eqp-3.*: Select statements that execute sub-selects. -- eqp-4.*: Compound select statements. -- ... -- eqp-7.*: "SELECT count(*) FROM tbl" statements (VDBE code OP_Count). -- test:do_execsql_test( 1.1, [[ CREATE TABLE t1(idt1 INT primary key, a INT, b INT, ex TEXT); CREATE INDEX i1 ON t1(a); CREATE INDEX i2 ON t1(b); CREATE TABLE t2(idt2 INT primary key, a INT, b INT, ex TEXT); CREATE TABLE t3(idt3 INT primary key, a INT, b INT, ex TEXT); ]]) test:do_eqp_test( 1.2, [[ SELECT * FROM t2, t1 WHERE t1.a=1 OR t1.b=2; ]], { -- <1.2> {0, 0, 1, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"}, {0, 0, 1, "SEARCH TABLE T1 USING COVERING INDEX I2 (B=?)"}, {0, 1, 0, "SCAN TABLE T2"} -- </1.2> }) test:do_eqp_test( 1.3, [[ SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a=1 OR t1.b=2; ]], { -- <1.3> {0, 0, 0, "SCAN TABLE T2"}, {0, 1, 1, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"}, {0, 1, 1, "SEARCH TABLE T1 USING COVERING INDEX I2 (B=?)"} -- </1.3> }) test:do_eqp_test( 1.3, [[ SELECT a FROM t1 ORDER BY a ]], { -- <1.3> {0, 0, 0, "SCAN TABLE T1 USING COVERING INDEX I1"} -- </1.3> }) test:do_eqp_test( 1.4, [[ SELECT a FROM t1 ORDER BY +a ]], { -- <1.4> {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "USE TEMP B-TREE FOR ORDER BY"} -- </1.4> }) test:do_eqp_test( 1.5, [[ SELECT a FROM t1 WHERE a=4 ]], { -- <1.5> {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"} -- </1.5> }) test:do_eqp_test( 1.6, [[ SELECT DISTINCT count(*) FROM t3 GROUP BY a; ]], { -- <1.6> {0, 0, 0, "SCAN TABLE T3"}, {0, 0, 0, "USE TEMP B-TREE FOR GROUP BY"}, {0, 0, 0, "USE TEMP B-TREE FOR DISTINCT"}, -- </1.6> }) test:do_eqp_test( 1.7, [[ SELECT * FROM t3 JOIN (SELECT 1) ]], { -- <1.7> {0, 0, 1, "SCAN SUBQUERY 1"}, {0, 1, 0, "SCAN TABLE T3"}, -- </1.7> }) test:do_eqp_test( 1.8, [[ SELECT * FROM t3 JOIN (SELECT 1 UNION SELECT 2) ]], { -- <1.8> {1, 0, 0, "COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)"}, {0, 0, 1, "SCAN SUBQUERY 1"}, {0, 1, 0, "SCAN TABLE T3"}, -- </1.8> }) test:do_eqp_test( 1.9, [[ SELECT * FROM t3 JOIN (SELECT 1 EXCEPT SELECT a FROM t3 LIMIT 17) ]], { -- <1.9> {3, 0, 0, "SCAN TABLE T3"}, {1, 0, 0, "COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (EXCEPT)"}, {0, 0, 1, "SCAN SUBQUERY 1"}, {0, 1, 0, "SCAN TABLE T3"}, -- </1.9> }) test:do_eqp_test( "1.10", [[ SELECT * FROM t3 JOIN (SELECT 1 INTERSECT SELECT a FROM t3 LIMIT 17) ]], { -- <1.10> {3, 0, 0, "SCAN TABLE T3"}, {1, 0, 0, "COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (INTERSECT)"}, {0, 0, 1, "SCAN SUBQUERY 1"}, {0, 1, 0, "SCAN TABLE T3"}, -- </1.10> }) test:do_eqp_test( 1.11, [[ SELECT * FROM t3 JOIN (SELECT 1 UNION ALL SELECT a FROM t3 LIMIT 17) ]], { -- <1.11> {3, 0, 0, "SCAN TABLE T3"}, {1, 0, 0, "COMPOUND SUBQUERIES 2 AND 3 (UNION ALL)"}, {0, 0, 1, "SCAN SUBQUERY 1"}, {0, 1, 0, "SCAN TABLE T3"}, -- </1.11> }) --------------------------------------------------------------------------- -- Test cases eqp-2.* - tests for single select statements. -- test:drop_all_tables() test:do_execsql_test( 2.1, [[ CREATE TABLE t1(idt1 INT primary key, x INT, y INT, ex TEXT); CREATE TABLE t2(idt2 INT primary key, x INT, y INT, ex TEXT); CREATE INDEX t2i1 ON t2(x); ]]) test:do_eqp_test("2.2.1", "SELECT DISTINCT min(x), max(x) FROM t1 GROUP BY x ORDER BY 1", { {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "USE TEMP B-TREE FOR GROUP BY"}, {0, 0, 0, "USE TEMP B-TREE FOR DISTINCT"}, {0, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, }) test:do_eqp_test("2.2.2", "SELECT DISTINCT min(x), max(x) FROM t2 GROUP BY x ORDER BY 1", { {0, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {0, 0, 0, "USE TEMP B-TREE FOR DISTINCT"}, {0, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, }) -- MUST_WORK_TEST wrong explain --test:do_eqp_test("2.2.3", "SELECT DISTINCT * FROM t1", { -- {0, 0, 0, "SCAN TABLE T1"}, -- {0, 0, 0, "USE TEMP B-TREE FOR DISTINCT"}, --}) test:do_eqp_test("2.2.4", "SELECT DISTINCT * FROM t1, t2", { {0, 0, 0, "SCAN TABLE T1"}, -- changed after reordering indexes -- actually it does not matter (in fact, it seems like pk should have been used in both cases) --{0, 1, 1, "SCAN TABLE T2 USING COVERING INDEX t2i1"}, {0, 1, 1, "SCAN TABLE T2"}, --{0, 0, 0, "USE TEMP B-TREE FOR DISTINCT"}, }) test:do_eqp_test("2.2.5", "SELECT DISTINCT * FROM t1, t2 ORDER BY t1.x", { {0, 0, 0, "SCAN TABLE T1"}, {0, 1, 1, "SCAN TABLE T2"}, --{0, 0, 0, "USE TEMP B-TREE FOR DISTINCT"}, {0, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, }) test:do_eqp_test("2.2.6", "SELECT DISTINCT t2.x FROM t1, t2 ORDER BY t2.x", { {0, 0, 1, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {0, 1, 0, "SCAN TABLE T1"}, }) test:do_eqp_test("2.3.1", "SELECT max(x) FROM t2", { {0, 0, 0, "SEARCH TABLE T2 USING COVERING INDEX T2I1"}, }) test:do_eqp_test("2.3.2", "SELECT min(x) FROM t2", { {0, 0, 0, "SEARCH TABLE T2 USING COVERING INDEX T2I1"}, }) test:do_eqp_test("2.3.3", "SELECT min(x), max(x) FROM t2", { {0, 0, 0, "SCAN TABLE T2"}, }) test:do_eqp_test("2.4.1", "SELECT * FROM t1 WHERE idt1=?", { {0, 0, 0, "SEARCH TABLE T1 USING PRIMARY KEY (IDT1=?)"}, }) --------------------------------------------------------------------------- -- Test cases eqp-3.* - tests for select statements that use sub-selects. -- test:do_eqp_test( "3.1.1", [[ SELECT (SELECT x FROM t1 AS sub) FROM t1; ]], { -- <3.1.1> {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "EXECUTE SCALAR SUBQUERY 1"}, {1, 0, 0, "SCAN TABLE T1 AS SUB"}, -- </3.1.1> }) test:do_eqp_test( "3.1.2", [[ SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub); ]], { -- <3.1.2> {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "EXECUTE SCALAR SUBQUERY 1"}, {1, 0, 0, "SCAN TABLE T1 AS SUB"}, -- </3.1.2> }) test:do_eqp_test( "3.1.3", [[ SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub ORDER BY y); ]], { -- <3.1.3> {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "EXECUTE SCALAR SUBQUERY 1"}, {1, 0, 0, "SCAN TABLE T1 AS SUB"}, {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, -- </3.1.3> }) test:do_eqp_test( "3.1.4", [[ SELECT * FROM t1 WHERE (SELECT x FROM t2 ORDER BY x); ]], { -- <3.1.4> {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "EXECUTE SCALAR SUBQUERY 1"}, {1, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, -- </3.1.4> }) test:do_eqp_test("3.2.1", [[ SELECT * FROM (SELECT * FROM t1 ORDER BY x LIMIT 10) ORDER BY y LIMIT 5 ]], { {1, 0, 0, "SCAN TABLE T1"}, {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {0, 0, 0, "SCAN SUBQUERY 1"}, {0, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, }) test:do_eqp_test("3.2.2", [[ SELECT * FROM (SELECT * FROM t1 ORDER BY x LIMIT 10) AS x1, (SELECT * FROM t2 ORDER BY x LIMIT 10) AS x2 ORDER BY x2.y LIMIT 5 ]], { {1, 0, 0, "SCAN TABLE T1"}, {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {0, 0, 0, "SCAN SUBQUERY 1 AS X1"}, {0, 1, 1, "SCAN SUBQUERY 2 AS X2"}, {0, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, }) test:do_eqp_test("3.3.1", [[ SELECT * FROM t1 WHERE y IN (SELECT y FROM t2) ]], { {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "EXECUTE LIST SUBQUERY 1"}, {1, 0, 0, "SCAN TABLE T2"}, }) test:do_eqp_test("3.3.2", [[ SELECT * FROM t1 WHERE y IN (SELECT y FROM t2 WHERE t1.x!=t2.x) ]], { {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "EXECUTE CORRELATED LIST SUBQUERY 1"}, {1, 0, 0, "SCAN TABLE T2"}, }) test:do_eqp_test("3.3.3", [[ SELECT * FROM t1 WHERE EXISTS (SELECT y FROM t2 WHERE t1.x!=t2.x) ]], { {0, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "EXECUTE CORRELATED SCALAR SUBQUERY 1"}, {1, 0, 0, "SCAN TABLE T2"}, }) --------------------------------------------------------------------------- -- Test cases eqp-4.* - tests for composite select statements. -- test:do_eqp_test( "4.1.1", [[ SELECT * FROM t1 UNION ALL SELECT * FROM t2 ]], { -- <4.1.1> {1, 0, 0, "SCAN TABLE T1"}, {2, 0, 0, "SCAN TABLE T2"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)"}, -- </4.1.1> }) test:do_eqp_test( "4.1.2", [[ SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 2 ]], { -- <4.1.2> {1, 0, 0, "SCAN TABLE T1"}, {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)"}, -- </4.1.2> }) test:do_eqp_test( "4.1.3", [[ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 2 ]], { -- <4.1.3> {1, 0, 0, "SCAN TABLE T1"}, {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {2, 0, 0, "USE TEMP B-TREE FOR RIGHT PART OF ORDER BY"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (UNION)"}, -- </4.1.3> }) test:do_eqp_test( "4.1.4", [[ SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 2 ]], { -- <4.1.4> {1, 0, 0, "SCAN TABLE T1"}, {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {2, 0, 0, "USE TEMP B-TREE FOR RIGHT PART OF ORDER BY"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)"}, -- </4.1.4> }) test:do_eqp_test( "4.1.5", [[ SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 2 ]], { -- <4.1.5> {1, 0, 0, "SCAN TABLE T1"}, {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {2, 0, 0, "USE TEMP B-TREE FOR RIGHT PART OF ORDER BY"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)"} -- </4.1.5> }) -- MUST_WORK_TEST wrong explain --test:do_eqp_test( -- "4.2.2", -- [[ -- SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 1 -- ]], { -- -- <4.2.2> -- {1, 0, 0, "SCAN TABLE T1"}, -- {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, -- {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX t2i1"}, -- {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)"}, -- -- -- </4.2.2> -- }) -- MUST_WORK_TEST wrong explain --test:do_eqp_test( -- "4.2.3", -- [[ -- SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 1 -- ]], { -- -- <4.2.3> -- {1, 0, 0, "SCAN TABLE T1"}, -- {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, -- {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX t2i1"}, -- {2, 0, 0, "USE TEMP B-TREE FOR RIGHT PART OF ORDER BY"}, -- 0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (UNION)" -- -- </4.2.3> -- }) -- MUST_WORK_TEST wrong explain --test:do_eqp_test( -- "4.2.4", -- [[ -- SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 1 -- ]], { -- -- <4.2.4> -- {1, 0, 0, "SCAN TABLE T1"}, -- {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, -- {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX t2i1"}, -- {2, 0, 0, "USE TEMP B-TREE FOR RIGHT PART OF ORDER BY"}, -- 0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)" -- -- </4.2.4> -- }) -- MUST_WORK_TEST wrong explain --test:do_eqp_test( -- "4.2.5", -- [[ -- SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 1 -- ]], { -- -- <4.2.5> -- {1, 0, 0, "SCAN TABLE T1"}, -- {1, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, -- {2, 0, 0, "SCAN TABLE T2 USING COVERING INDEX t2i1"}, -- {2, 0, 0, "USE TEMP B-TREE FOR RIGHT PART OF ORDER BY"}, -- {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)"} -- -- </4.2.5> -- }) test:do_eqp_test( "4.3.1", [[ SELECT x FROM t1 UNION SELECT x FROM t2 ]], { -- <4.3.1> {1, 0, 0, "SCAN TABLE T1"}, {2, 0, 0, "SCAN TABLE T2"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)"}, -- </4.3.1> }) test:do_eqp_test( "4.3.2", [[ SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1 ]], { -- <4.3.2> {2, 0, 0, "SCAN TABLE T1"}, {3, 0, 0, "SCAN TABLE T2"}, {1, 0, 0, "COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)"}, {4, 0, 0, "SCAN TABLE T1"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 4 USING TEMP B-TREE (UNION)"} -- </4.3.2> }) test:do_eqp_test( "4.3.3", [[ SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1 ORDER BY 1 ]], { -- <4.3.3> {2, 0, 0, "SCAN TABLE T1"}, {2, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {3, 0, 0, "SCAN TABLE T2 USING COVERING INDEX T2I1"}, {1, 0, 0, "COMPOUND SUBQUERIES 2 AND 3 (UNION)"}, {4, 0, 0, "SCAN TABLE T1"}, {4, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 4 (UNION)"} -- </4.3.3> }) --------------------------------------------------------------------------- -- This next block of tests verifies that the examples on the -- lang_explain.html page are correct. -- test:drop_all_tables() -- EVIDENCE-OF: R-47779-47605 sqlite> EXPLAIN QUERY PLAN SELECT a, b -- FROM t1 WHERE a=1; -- 0|0|0|SCAN TABLE T1 -- test:do_execsql_test( "5.1.0", [[ CREATE TABLE t1(idt1 INT PRIMARY KEY, a INT, b INT, ex TEXT) ]]) test:do_eqp_test("5.1.1", "SELECT a, b FROM t1 WHERE a=1", { {0, 0, 0, "SCAN TABLE T1"}, }) -- EVIDENCE-OF: R-55852-17599 sqlite> CREATE INDEX i1 ON t1(a); -- sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1; -- 0|0|0|SEARCH TABLE T1 USING COVERING INDEX i1 -- test:do_execsql_test( "5.2.0", [[ CREATE INDEX i1 ON t1(a) ]]) test:do_eqp_test("5.2.1", "SELECT a, b FROM t1 WHERE a=1", { {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"}, }) -- EVIDENCE-OF: R-21179-11011 sqlite> CREATE INDEX i2 ON t1(a, b); -- sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1; -- 0|0|0|SEARCH TABLE T1 USING COVERING INDEX i2 (a=?) -- test:do_execsql_test( "5.3.0", [[ CREATE INDEX i2 ON t1(a, b) ]]) test:do_eqp_test("5.3.1", "SELECT a, b FROM t1 WHERE a=1", { -- It is equal for tarantol wheather to use i1 or i2 -- because both of them are covering {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"}, --{0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"}, }) -- EVIDENCE-OF: R-09991-48941 sqlite> EXPLAIN QUERY PLAN -- SELECT t1.*, t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2; -- 0|0|0|SEARCH TABLE T1 USING COVERING INDEX i2 (a=? AND b>?) -- 0|1|1|SCAN TABLE T2 -- test:do_execsql_test( "5.4.0", [[ CREATE TABLE t2(idt2 INT primary key, c INT, d INT, ex TEXT) ]]) test:do_eqp_test("5.4.1", "SELECT t1.a, t2.c FROM t1, t2 WHERE t1.a=1 AND t1.b>2", { {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I2 (A=? AND B>?)"}, {0, 1, 1, "SCAN TABLE T2"}, }) -- EVIDENCE-OF: R-33626-61085 sqlite> EXPLAIN QUERY PLAN -- SELECT t1.*, t2.* FROM t2, t1 WHERE t1.a=1 AND t1.b>2; -- 0|0|1|SEARCH TABLE T1 USING COVERING INDEX i2 (a=? AND b>?) -- 0|1|0|SCAN TABLE T2 -- test:do_eqp_test(5.5, "SELECT t1.a, t2.c FROM t2, t1 WHERE t1.a=1 AND t1.b>2", { {0, 0, 1, "SEARCH TABLE T1 USING COVERING INDEX I2 (A=? AND B>?)"}, {0, 1, 0, "SCAN TABLE T2"}, }) -- EVIDENCE-OF: R-04002-25654 sqlite> CREATE INDEX i3 ON t1(b); -- sqlite> EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=1 OR b=2; -- 0|0|0|SEARCH TABLE T1 USING COVERING INDEX i2 (a=?) -- 0|0|0|SEARCH TABLE T1 USING COVERING INDEX i3 (b=?) -- test:do_execsql_test( "5.5.0", [[ CREATE INDEX i3 ON t1(b) ]]) test:do_eqp_test("5.6.1", "SELECT a, b FROM t1 WHERE a=1 OR b=2", { -- It is equal for tarantol wheather to use i1 or i2 -- because both of them are covering --{0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I2 (A=?)"}, {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"}, {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I3 (B=?)"}, }) -- EVIDENCE-OF: R-24577-38891 sqlite> EXPLAIN QUERY PLAN -- SELECT c, d FROM t2 ORDER BY c; -- 0|0|0|SCAN TABLE T2 -- 0|0|0|USE TEMP B-TREE FOR ORDER BY -- test:do_eqp_test(5.7, "SELECT c, d FROM t2 ORDER BY c", { {0, 0, 0, "SCAN TABLE T2"}, {0, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, }) -- EVIDENCE-OF: R-58157-12355 sqlite> CREATE INDEX i4 ON t2(c); -- sqlite> EXPLAIN QUERY PLAN SELECT c, d FROM t2 ORDER BY c; -- 0|0|0|SCAN TABLE T2 USING COVERING INDEX i4 -- test:do_execsql_test( "5.8.0", [[ CREATE INDEX i4 ON t2(c) ]]) test:do_eqp_test("5.8.1", "SELECT c, d FROM t2 ORDER BY c", { {0, 0, 0, "SCAN TABLE T2 USING COVERING INDEX I4"}, }) -- EVIDENCE-OF: R-13931-10421 sqlite> EXPLAIN QUERY PLAN SELECT -- (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2; -- 0|0|0|SCAN TABLE T2 -- 0|0|0|EXECUTE SCALAR SUBQUERY 1 -- 1|0|0|SEARCH TABLE T1 USING COVERING INDEX i2 (a=?) -- 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 2 -- 2|0|0|SEARCH TABLE T1 USING COVERING INDEX i3 (b=?) -- test:do_eqp_test(5.9, [[ SELECT (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2 ]], { {0, 0, 0, "SCAN TABLE T2"}, {0, 0, 0, "EXECUTE SCALAR SUBQUERY 1"}, -- It is equally for tarantol wheather to use i1 or i2 -- because both of them are covering --{1, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I2 (A=?)"}, {1, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"}, {0, 0, 0, "EXECUTE CORRELATED SCALAR SUBQUERY 2"}, {2, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I3 (B=?)"}, }) -- EVIDENCE-OF: R-50892-45943 sqlite> EXPLAIN QUERY PLAN -- SELECT count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x; -- 1|0|0|SCAN TABLE T1 USING COVERING INDEX i2 -- 0|0|0|SCAN SUBQUERY 1 -- 0|0|0|USE TEMP B-TREE FOR GROUP BY -- test:do_eqp_test(5.10, [[ SELECT count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x ]], { {1, 0, 0, "SCAN TABLE T1 USING COVERING INDEX I1"}, {0, 0, 0, "SCAN SUBQUERY 1"}, {0, 0, 0, "USE TEMP B-TREE FOR GROUP BY"}, }) -- EVIDENCE-OF: R-46219-33846 sqlite> EXPLAIN QUERY PLAN -- SELECT * FROM (SELECT * FROM t2 WHERE c=1), t1; -- 0|0|0|SEARCH TABLE T2 USING COVERING INDEX i4 (c=?) -- 0|1|1|SCAN TABLE T1 -- test:do_eqp_test(5.11, "SELECT a, b FROM (SELECT * FROM t2 WHERE c=1), t1", { {0, 0, 0, "SEARCH TABLE T2 USING COVERING INDEX I4 (C=?)"}, {0, 1, 1, "SCAN TABLE T1"}, }) -- EVIDENCE-OF: R-37879-39987 sqlite> EXPLAIN QUERY PLAN -- SELECT a FROM t1 UNION SELECT c FROM t2; -- 1|0|0|SCAN TABLE T1 -- 2|0|0|SCAN TABLE T2 -- 0|0|0|COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION) -- test:do_eqp_test(5.12, "SELECT a,b FROM t1 UNION SELECT c, 99 FROM t2", { {1, 0, 0, "SCAN TABLE T1"}, {2, 0, 0, "SCAN TABLE T2"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)"}, }) -- EVIDENCE-OF: R-44864-63011 sqlite> EXPLAIN QUERY PLAN -- SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1; -- 1|0|0|SCAN TABLE T1 USING COVERING INDEX i2 -- 2|0|0|SCAN TABLE T2 2|0|0|USE TEMP B-TREE FOR ORDER BY -- 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) -- test:do_eqp_test(5.13, "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1", { {1, 0, 0, "SCAN TABLE T1 USING COVERING INDEX I1"}, {2, 0, 0, "SCAN TABLE T2"}, {2, 0, 0, "USE TEMP B-TREE FOR ORDER BY"}, {0, 0, 0, "COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)"}, }) -- #------------------------------------------------------------------------- -- # The following tests - eqp-6.* - test that the example C code on -- # documentation page eqp.html works. The C code is duplicated in test1.c -- # and wrapped in Tcl command [print_explain_query_plan] -- # -- set boilerplate { -- proc explain_query_plan {db sql} { -- set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY] -- print_explain_query_plan $stmt -- sqlite3_finalize $stmt -- } -- sqlite3 db test.db -- explain_query_plan db {%SQL%} -- db close -- exit -- } -- # Do a "Print Explain Query Plan" test. -- proc do_peqp_test {tn sql res} { -- set fd [open script.tcl w] -- puts $fd [string map [list %SQL% $sql] $::boilerplate] -- close $fd -- uplevel do_test $tn [list { -- set fd [open "|[info nameofexec] script.tcl"] -- set data [read $fd] -- close $fd -- set data -- }] [list $res] -- } -- do_peqp_test 6.1 { -- SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1 -- } [string trimleft { -- 1 0 0 SCAN TABLE T1 USING COVERING INDEX i2 -- 2 0 0 SCAN TABLE T2 -- 2 0 0 USE TEMP B-TREE FOR ORDER BY -- 0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) -- }] --------------------------------------------------------------------------- -- The following tests - eqp-7.* - test that queries that use the OP_Count -- optimization return something sensible with EQP. -- test:drop_all_tables() test:do_execsql_test( 7.0, [[ CREATE TABLE t1(idt1 INT primary key, a INT, b INT, ex CHAR(100)); CREATE TABLE t2(idt2 INT primary key, a INT, b INT, ex CHAR(100)); CREATE INDEX i1 ON t2(a); ]]) test:do_eqp_test(7.1, "SELECT count(*) FROM t1", { {0, 0, 0, "B+tree count T1"}, }) test:do_eqp_test(7.2, "SELECT count(*) FROM t2", { {0, 0, 0, "B+tree count T2"}, }) -- MUST_WORK_TEST if (0 > 0) then test:do_execsql_test( 7.3, [[ INSERT INTO t1(a,b) VALUES(1, 2); INSERT INTO t1(a,b) VALUES(3, 4); INSERT INTO t2(a,b) VALUES(1, 2); INSERT INTO t2(a,b) VALUES(3, 4); INSERT INTO t2(a,b) VALUES(5, 6); ANALYZE; ]]) --db("close") --sqlite3("db", "test.db") test:do_eqp_test(7.4, "SELECT count(*) FROM t1", { {0, 0, 0, "SCAN TABLE T1"} }) test:do_eqp_test(7.5, "SELECT count(*) FROM t2", { {0, 0, 0, "SCAN TABLE T2 USING COVERING INDEX I1"} }) --------------------------------------------------------------------------- --The following tests - eqp-8.* - test that queries that use the OP_Count --optimization return something sensible with EQP. end test:drop_all_tables() test:do_execsql_test( 8.0, [[ CREATE TABLE t1(a INT , b INT , c INT , PRIMARY KEY(b, c)); CREATE TABLE t2(id INT primary key, a INT , b INT , c INT ); ]]) test:do_eqp_test("8.1.1", "SELECT * FROM t2", { {0, 0, 0, "SCAN TABLE T2"}, }) -- test:do_eqp_test 8.1.2 "SELECT * FROM t2 WHERE rowid=?" { -- {0, 0, 0, "SEARCH TABLE T2 USING INTEGER PRIMARY KEY (rowid=?)"}, -- } test:do_eqp_test("8.1.3", "SELECT count(*) FROM t2", { {0, 0, 0, "B+tree count T2"}, }) test:do_eqp_test("8.2.1", "SELECT * FROM t1", { {0, 0, 0, "SCAN TABLE T1"}, }) test:do_eqp_test("8.2.2", "SELECT * FROM t1 WHERE b=?", { {0, 0, 0, "SEARCH TABLE T1 USING PRIMARY KEY (B=?)"}, }) test:do_eqp_test("8.2.3", "SELECT * FROM t1 WHERE b=? AND c=?", { {0, 0, 0, "SEARCH TABLE T1 USING PRIMARY KEY (B=? AND C=?)"}, }) test:do_eqp_test("8.2.4", "SELECT count(*) FROM t1", { {0, 0, 0, "B+tree count T1"}, }) test:finish_test()
-- Notification from FreeUI ---------------------------------------------------------- -- Load RayUI Environment ---------------------------------------------------------- RayUI:LoadEnv("Notification") local NF = R:NewModule("Notification", "AceEvent-3.0", "AceHook-3.0") local S = R.Skins _Notification = NF local bannerWidth = 300 local max_active_toasts = 3 local fadeout_delay = 5 local toasts = {} local activeToasts = {} local queuedToasts = {} local anchorFrame function NF:SpawnToast(toast) if not toast then return end if #activeToasts >= max_active_toasts then table.insert(queuedToasts, toast) return false end if UnitIsAFK("player") then table.insert(queuedToasts, toast) self:RegisterEvent("PLAYER_FLAGS_CHANGED") return false end local YOffset = 0 if R:GetScreenQuadrant(anchorFrame):find("TOP") then YOffset = -54 else YOffset = 54 end toast:ClearAllPoints() if #activeToasts > 0 then if R:GetScreenQuadrant(anchorFrame):find("TOP") then toast:SetPoint("TOP", activeToasts[#activeToasts], "BOTTOM", 0, -4 - YOffset) else toast:SetPoint("BOTTOM", activeToasts[#activeToasts], "TOP", 0, 4 - YOffset) end else toast:SetPoint("TOP", anchorFrame, "TOP", 0, 1 - YOffset) end table.insert(activeToasts, toast) toast:Show() toast.AnimIn.AnimMove:SetOffset(0, YOffset) toast.AnimOut.AnimMove:SetOffset(0, -YOffset) toast.AnimIn:Play() toast.AnimOut:Play() PlaySound(18019) end function NF:RefreshToasts() for i = 1, #activeToasts do local activeToast = activeToasts[i] local YOffset, _ = 0 if activeToast.AnimIn.AnimMove:IsPlaying() then _, YOffset = activeToast.AnimIn.AnimMove:GetOffset() end if activeToast.AnimOut.AnimMove:IsPlaying() then _, YOffset = activeToast.AnimOut.AnimMove:GetOffset() end activeToast:ClearAllPoints() if i == 1 then activeToast:SetPoint("TOP", anchorFrame, "TOP", 0, 1 - YOffset) else if R:GetScreenQuadrant(anchorFrame):find("TOP") then activeToast:SetPoint("TOP", activeToasts[i - 1], "BOTTOM", 0, -4 - YOffset) else activeToast:SetPoint("BOTTOM", activeToasts[i - 1], "TOP", 0, 4 - YOffset) end end end local queuedToast = table.remove(queuedToasts, 1) if queuedToast then self:SpawnToast(queuedToast) end end function NF:HideToast(toast) for i, activeToast in pairs(activeToasts) do if toast == activeToast then table.remove(activeToasts, i) end end table.insert(toasts, toast) toast:Hide() C_Timer.After(0.1, function() self:RefreshToasts() end) end local function ToastButtonAnimOut_OnFinished(self) NF:HideToast(self:GetParent()) end function NF:GetToast() local toast = table.remove(toasts, 1) if not toast then toast = CreateFrame("Frame", nil, R.UIParent) toast:SetFrameStrata("FULLSCREEN_DIALOG") toast:SetSize(bannerWidth, 50) toast:SetPoint("TOP", R.UIParent, "TOP") toast:Hide() S:CreateBD(toast) local icon = toast:CreateTexture(nil, "OVERLAY") icon:SetSize(32, 32) icon:SetPoint("LEFT", toast, "LEFT", 9, 0) S:CreateBG(icon) toast.icon = icon local sep = toast:CreateTexture(nil, "BACKGROUND") sep:SetSize(1, 50) sep:SetPoint("LEFT", icon, "RIGHT", 9, 0) sep:SetColorTexture(0, 0, 0) local title = toast:CreateFontString(nil, "OVERLAY") title:SetFont(R["media"].font, 14) title:SetShadowOffset(1, -1) title:SetPoint("TOPLEFT", sep, "TOPRIGHT", 9, -9) title:SetPoint("RIGHT", toast, -9, 0) title:SetJustifyH("LEFT") toast.title = title local text = toast:CreateFontString(nil, "OVERLAY") text:SetFont(R["media"].font, 12) text:SetShadowOffset(1, -1) text:SetPoint("BOTTOMLEFT", sep, "BOTTOMRIGHT", 9, 9) text:SetPoint("RIGHT", toast, -9, 0) text:SetJustifyH("LEFT") toast.text = text toast.AnimIn = CreateAnimationGroup(toast) local animInAlpha = toast.AnimIn:CreateAnimation("Fade") animInAlpha:SetOrder(1) animInAlpha:SetChange(1) animInAlpha:SetDuration(0.5) toast.AnimIn.AnimAlpha = animInAlpha local animInMove = toast.AnimIn:CreateAnimation("Move") animInMove:SetOrder(1) animInMove:SetDuration(0.5) animInMove:SetSmoothing("Out") animInMove:SetOffset(-bannerWidth, 0) toast.AnimIn.AnimMove = animInMove toast.AnimOut = CreateAnimationGroup(toast) local animOutSleep = toast.AnimOut:CreateAnimation("Sleep") animOutSleep:SetOrder(1) animOutSleep:SetDuration(fadeout_delay) toast.AnimOut.AnimSleep = animOutSleep local animOutAlpha = toast.AnimOut:CreateAnimation("Fade") animOutAlpha:SetOrder(2) animOutAlpha:SetChange(0) animOutAlpha:SetDuration(0.5) toast.AnimOut.AnimAlpha = animOutAlpha local animOutMove = toast.AnimOut:CreateAnimation("Move") animOutMove:SetOrder(2) animOutMove:SetDuration(0.5) animOutMove:SetSmoothing("In") animOutMove:SetOffset(bannerWidth, 0) toast.AnimOut.AnimMove = animOutMove toast.AnimOut.AnimAlpha:SetScript("OnFinished", ToastButtonAnimOut_OnFinished) toast:SetScript("OnEnter", function(self) self.AnimOut:Stop() end) toast:SetScript("OnLeave", function(self) self.AnimOut:Play() end) toast:SetScript("OnMouseUp", function(self, button) if button == "LeftButton" and self.clickFunc then self.clickFunc() end end) end return toast end function NF:DisplayToast(name, message, clickFunc, texture, ...) local toast = self:GetToast() if type(clickFunc) == "function" then toast.clickFunc = clickFunc else toast.clickFunc = nil end if type(texture) == "string" then toast.icon:SetTexture(texture) if ... then toast.icon:SetTexCoord(...) else toast.icon:SetTexCoord(.08, .92, .08, .92) end else toast.icon:SetTexture("Interface\\Icons\\achievement_general") toast.icon:SetTexCoord(.08, .92, .08, .92) end toast.title:SetText(name) toast.text:SetText(message) self:SpawnToast(toast) end function NF:PLAYER_FLAGS_CHANGED(event) self:UnregisterEvent(event) for i = 1, max_active_toasts - #activeToasts do self:RefreshToasts() end end function NF:PLAYER_REGEN_ENABLED() for i = 1, max_active_toasts - #activeToasts do self:RefreshToasts() end end -- Test function local function testCallback() R:Print("Banner clicked!") end SlashCmdList.TESTNOTIFICATION = function(b) NF:DisplayToast("RayUI", "This is an example of a notification.", testCallback, b == "true" and "INTERFACE\\ICONS\\SPELL_FROST_ARCTICWINDS" or nil, .08, .92, .08, .92) end _G.SLASH_TESTNOTIFICATION1 = "/testnotification" function NF:Initialize() anchorFrame = CreateFrame("Frame", nil, R.UIParent) anchorFrame:SetSize(bannerWidth, 50) anchorFrame:SetPoint("TOP", 0, -10) R:CreateMover(anchorFrame, "Notification Mover", L["通知锚点"], true, nil, "ALL,GENERAL") self:RegisterEvent("UPDATE_PENDING_MAIL") self:RegisterEvent("PLAYER_REGEN_ENABLED") self:RegisterEvent("CALENDAR_UPDATE_PENDING_INVITES") self:RegisterEvent("CALENDAR_UPDATE_GUILD_EVENTS") self:RegisterEvent("PLAYER_ENTERING_WORLD") self:RegisterEvent("VIGNETTE_MINIMAP_UPDATED") self:RegisterEvent("RESURRECT_REQUEST") self:RegisterEvent("UPDATE_INVENTORY_DURABILITY") end local hasMail = false function NF:UPDATE_PENDING_MAIL() local newMail = HasNewMail() if hasMail ~= newMail then hasMail = newMail if hasMail then self:DisplayToast(MAIL_LABEL, HAVE_MAIL, nil, "Interface\\Icons\\inv_letter_15", .08, .92, .08, .92) end end end local showRepair = true local Slots = { [1] = {1, INVTYPE_HEAD, 1000}, [2] = {3, INVTYPE_SHOULDER, 1000}, [3] = {5, INVTYPE_ROBE, 1000}, [4] = {6, INVTYPE_WAIST, 1000}, [5] = {9, INVTYPE_WRIST, 1000}, [6] = {10, INVTYPE_HAND, 1000}, [7] = {7, INVTYPE_LEGS, 1000}, [8] = {8, INVTYPE_FEET, 1000}, [9] = {16, INVTYPE_WEAPONMAINHAND, 1000}, [10] = {17, INVTYPE_WEAPONOFFHAND, 1000}, [11] = {18, INVTYPE_RANGED, 1000} } local function ResetRepairNotification() showRepair = true end function NF:UPDATE_INVENTORY_DURABILITY() local current, max for i = 1, 11 do if GetInventoryItemLink("player", Slots[i][1]) ~= nil then current, max = GetInventoryItemDurability(Slots[i][1]) if current then Slots[i][3] = current/max end end end table.sort(Slots, function(a, b) return a[3] < b[3] end) local value = floor(Slots[1][3]*100) if showRepair and value < 20 then showRepair = false R:Delay(30, ResetRepairNotification) self:DisplayToast(MINIMAP_TRACKING_REPAIR, format(L["你的%s栏位需要修理, 当前耐久为%d."],Slots[1][2],value)) end end local numInvites = 0 local function GetGuildInvites() local numGuildInvites = 0 local currentMonth = (C_Calendar.GetDate()).month for i = 1, C_Calendar.GetNumGuildEvents() do local month, day = C_Calendar.GetGuildEventInfo(i) local monthOffset = month - currentMonth local numDayEvents = C_Calendar.GetNumDayEvents(monthOffset, day) for i = 1, numDayEvents do local _, _, _, _, _, _, _, _, inviteStatus = C_Calendar.GetDayEvent(monthOffset, day, i) if inviteStatus == 8 then numGuildInvites = numGuildInvites + 1 end end end return numGuildInvites end local function toggleCalendar() if not CalendarFrame then LoadAddOn("Blizzard_Calendar") end Calendar_Toggle() end local function alertEvents() if CalendarFrame and CalendarFrame:IsShown() then return end local num = C_Calendar.GetNumInvites() if num ~= numInvites then if num > 1 then NF:DisplayToast(CALENDAR, format(L["你有%s个未处理的活动邀请."], num), toggleCalendar) elseif num > 0 then NF:DisplayToast(CALENDAR, format(L["你有%s个未处理的活动邀请."], 1), toggleCalendar) end numInvites = num end end local function alertGuildEvents() if CalendarFrame and CalendarFrame:IsShown() then return end local num = GetGuildInvites() if num > 1 then NF:DisplayToast(CALENDAR, format(L["你有%s个未处理的公会活动邀请."], num), toggleCalendar) elseif num > 0 then NF:DisplayToast(CALENDAR, format(L["你有%s个未处理的公会活动邀请."], 1), toggleCalendar) end end function NF:CALENDAR_UPDATE_PENDING_INVITES() alertEvents() alertGuildEvents() end function NF:CALENDAR_UPDATE_GUILD_EVENTS() alertGuildEvents() end local function LoginCheck() alertEvents() alertGuildEvents() local day = (C_Calendar.GetDate()).monthDay local numDayEvents = C_Calendar.GetNumDayEvents(0, day) local monthInfo = C_Calendar.GetMonthInfo() local numDays = monthInfo.numDays local hournow, minutenow = GetGameTime() -- Today for i = 1, numDayEvents do local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = C_Calendar.GetDayEvent(0, day, i) if calendarType == "HOLIDAY" and ( sequenceType == "END" or sequenceType == "" ) and hournow < hour then NF:DisplayToast(CALENDAR, format(L["活动\"%s\"今天结束."], title), toggleCalendar) end if calendarType == "HOLIDAY" and sequenceType == "START" and hournow > hour then NF:DisplayToast(CALENDAR, format(L["活动\"%s\"今天开始."], title), toggleCalendar) end if calendarType == "HOLIDAY" and sequenceType == "ONGOING" then NF:DisplayToast(CALENDAR, format(L["活动\"%s\"正在进行."], title), toggleCalendar) end end --Tomorrow local offset = 0 if numDays == day then offset = 1 day = 1 else day = day + 1 end numDayEvents = C_Calendar.GetNumDayEvents(offset, day) for i = 1, numDayEvents do local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = C_Calendar.GetDayEvent(offset, day, i) if calendarType == "HOLIDAY" and ( sequenceType == "END" or sequenceType == "" ) then NF:DisplayToast(CALENDAR, format(L["活动\"%s\"明天结束."], title), toggleCalendar) end end end function NF:PLAYER_ENTERING_WORLD() C_Timer.After(7, LoginCheck) self:UnregisterEvent("PLAYER_ENTERING_WORLD") end local isIgnored = { [1153] = true, -- 部落要塞 [1159] = true, -- 联盟要塞 [1803] = true, -- 涌泉海滩 } local cache = {} function NF:VIGNETTE_MINIMAP_UPDATED(event, vignetteInstanceID) local instID = select(8, GetInstanceInfo()) if isIgnored[instID] then return end if id and not cache[id] then local info = C_VignetteInfo.GetVignetteInfo(id) if not info then return end local filename, width, height, txLeft, txRight, txTop, txBottom = GetAtlasInfo(info.atlasName) if not filename then return end local atlasWidth = width/(txRight-txLeft) local atlasHeight = height/(txBottom-txTop) local tex = string.format("|T%s:%d:%d:0:0:%d:%d:%d:%d:%d:%d|t", filename, 0, 0, atlasWidth, atlasHeight, atlasWidth*txLeft, atlasWidth*txRight, atlasHeight*txTop, atlasHeight*txBottom) PlaySoundFile("Sound\\Interface\\PVPFlagTakenMono.ogg", "master") self:DisplayToast("发现稀有", name) cache[id] = true end end function NF:RESURRECT_REQUEST(name) PlaySound(SOUNDKIT.READY_CHECK) end R:RegisterModule(NF:GetName())
--- Compute the n-th fibonacci number. function fib(n) local a, b = 0, 1 for i = 0, (n - 1) do a, b = b, b + a end return a end
pfDB["quests"]["data-turtle"] = { -- Seeping Corruption remake [3568] = { ["start"] = { ["U"] = { 8390 }, }, ["end"] = { ["U"] = { 8390 }, }, ["obj"] = { ["A"] = { 10691, 10692, 10693, 10694 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 45, ["next"] = { 3569 }, }, -- Puffing Peace [40001] = { ["start"] = { ["U"] = { 60300 }, }, ["end"] = { ["U"] = { 3185 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 8, ["next"] = { 40002 }, }, -- Grand Herbal Theft [40002] = { ["start"] = { ["U"] = { 3185 }, }, ["end"] = { ["U"] = { 60300 }, }, ["obj"] = { ["I"] = { 60000 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 8, ["next"] = { 40003 }, ["pre"] = { 40001 }, }, -- Hookah For Your Troubles [40003] = { ["start"] = { ["U"] = { 60300 }, }, ["end"] = { ["U"] = { 60300 }, }, ["obj"] = { ["O"] = { 2010700 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 8, ["pre"] = { 40001, 40002 }, }, -- Titiki's Hunt [40014] = { ["start"] = { ["U"] = { 91415 }, }, ["end"] = { ["U"] = { 91415 }, }, ["obj"] = { ["I"] = { 60109 }, }, ["race"] = 178, ["lvl"] = 36, ["min"] = 28, ["next"] = { 40015 }, }, -- The Hunt for Heketh [40015] = { ["start"] = { ["U"] = { 91415 }, }, ["end"] = { ["U"] = { 91415 }, }, ["obj"] = { ["U"] = { 91791 }, }, ["race"] = 178, ["lvl"] = 39, ["min"] = 28, ["pre"] = { 40014 }, }, -- Gortog's Beads [40016] = { ["start"] = { ["U"] = { 91412 }, }, ["end"] = { ["U"] = { 91412 }, }, ["obj"] = { ["I"] = { 60108 }, }, ["race"] = 178, ["lvl"] = 34, ["min"] = 25, }, -- Preparing for War [40017] = { ["start"] = { ["U"] = { 91400 }, }, ["end"] = { ["U"] = { 91400 }, }, ["obj"] = { ["I"] = { 60119 }, }, ["race"] = 178, ["lvl"] = 35, ["min"] = 25, }, -- War on the Witherbark [40018] = { ["start"] = { ["U"] = { 91401 }, }, ["end"] = { ["U"] = { 91401 }, }, ["obj"] = { ["U"] = { 91784, 91786, 91785 }, }, ["race"] = 178, ["lvl"] = 37, ["min"] = 30, }, -- The Wildtusk Charms [40019] = { ["start"] = { ["U"] = { 91402 }, }, ["end"] = { ["U"] = { 91402 }, }, ["obj"] = { ["I"] = { 60120 }, }, ["race"] = 178, ["lvl"] = 36, ["min"] = 25, }, -- The Chief's Necklace [40020] = { ["start"] = { ["U"] = { 91290 }, }, ["end"] = { ["U"] = { 91290 }, }, ["obj"] = { ["I"] = { 60121 }, }, ["race"] = 178, ["lvl"] = 36, ["min"] = 25, }, -- The Speaker's Betrayal [40021] = { ["start"] = { ["U"] = { 91290 }, }, ["end"] = { ["U"] = { 91290 }, }, ["obj"] = { ["I"] = { 60122 }, }, ["race"] = 178, ["lvl"] = 36, ["min"] = 30, ["next"] = { 40022 }, }, -- The Witherbark Warleader [40022] = { ["start"] = { ["U"] = { 91290 }, }, ["end"] = { ["U"] = { 91290 }, }, ["obj"] = { ["I"] = { 60123 }, }, ["race"] = 178, ["lvl"] = 40, ["min"] = 30, ["pre"] = { 40021 }, }, -- Assisting Lord Rog [40023] = { ["start"] = { ["U"] = { 91411 }, }, ["end"] = { ["U"] = { 91289 }, }, ["race"] = 178, ["lvl"] = 40, ["min"] = 30, ["next"] = { 40024 }, }, -- Lord Rog's Exiles [40024] = { ["start"] = { ["U"] = { 91289 }, }, ["end"] = { ["U"] = { 91289 }, }, ["obj"] = { ["I"] = { 60125 }, }, ["race"] = 178, ["lvl"] = 40, ["min"] = 30, ["pre"] = { 40023 }, ["next"] = { 40025 }, }, -- Inner Binding Purification [40025] = { ["start"] = { ["U"] = { 91289 }, }, ["end"] = { ["U"] = { 91411 }, }, ["obj"] = { ["I"] = { 3357, 7912, 3355 }, }, ["race"] = 178, ["lvl"] = 40, ["min"] = 30, ["pre"] = { 40024 }, ["next"] = { 40026 }, }, -- Lord Rog's Favor [40026] = { ["start"] = { ["U"] = { 91411 }, }, ["end"] = { ["U"] = { 91289 }, }, ["race"] = 178, ["lvl"] = 40, ["min"] = 30, ["pre"] = { 40025 }, }, -- The Sanv Charm [40027] = { ["start"] = { ["U"] = { 91781 }, }, ["end"] = { ["U"] = { 91781 }, }, ["obj"] = { ["I"] = { 60127 }, }, ["lvl"] = 39, ["min"] = 30, ["next"] = { 40032 }, }, -- The Horn of Garek'sa [40028] = { ["start"] = { ["U"] = { 91796 }, }, ["end"] = { ["U"] = { 91796 }, }, ["obj"] = { ["I"] = { 60128 }, }, ["lvl"] = 36, ["min"] = 30, }, -- Hunting the Hunters [40029] = { ["start"] = { ["U"] = { 1776 }, }, ["end"] = { ["U"] = { 1776 }, }, ["obj"] = { ["U"] = { 759, 760 }, }, ["lvl"] = 36, ["min"] = 30, ["next"] = { 40030 }, }, -- Hunting the Hunters [40030] = { ["start"] = { ["U"] = { 1776 }, }, ["end"] = { ["U"] = { 1776 }, }, ["obj"] = { ["I"] = { 60130 }, }, ["lvl"] = 36, ["min"] = 30, ["pre"] = { 40029 }, }, -- Leather, a Draenic Luxury [40031] = { ["start"] = { ["U"] = { 11874 }, }, ["end"] = { ["U"] = { 11874 }, }, ["obj"] = { ["I"] = { 60133 }, }, ["lvl"] = 35, ["min"] = 30, }, -- Draenic Communication [40032] = { ["start"] = { ["U"] = { 91781 }, }, ["end"] = { ["U"] = { 91781 }, }, ["obj"] = { ["I"] = { 60134, 60135 }, }, ["lvl"] = 39, ["min"] = 30, ["pre"] = { 40027 }, ["next"] = { 40033 }, }, -- Finding Akh Z'ador [40033] = { ["start"] = { ["U"] = { 91781 }, }, ["end"] = { ["U"] = { 91782 }, }, ["lvl"] = 52, ["min"] = 30, ["pre"] = { 40032 }, }, -- Sorrowmoss Mushrooms! [40077] = { ["start"] = { ["U"] = { 92022 }, }, ["end"] = { ["U"] = { 92022 }, }, ["obj"] = { ["I"] = { 60171 }, }, ["race"] = 77, ["lvl"] = 37, ["min"] = 30 }, -- Into the Uplands [40080] = { ["start"] = { ["U"] = { 6739 }, }, ["end"] = { ["U"] = { 91713 }, }, ["obj"] = { ["I"] = { 60374 }, }, ["race"] = 178, ["lvl"] = 15, ["min"] = 10, }, -- Pesterhide Pests [40081] = { ["start"] = { ["U"] = { 91752 }, }, ["end"] = { ["U"] = { 91752 }, }, ["obj"] = { ["I"] = { 60375 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 11, ["next"] = { 40082 }, }, -- Pestering the Pesterhide [40082] = { ["start"] = { ["U"] = { 91752 }, }, ["end"] = { ["U"] = { 91752 }, }, ["obj"] = { ["I"] = { 60376, 60377 }, }, ["race"] = 178, ["lvl"] = 20, ["min"] = 11, ["pre"] = { 40081 }, }, -- A Friend in Glenshire [40086] = { ["start"] = { ["U"] = { 4556 }, }, ["end"] = { ["U"] = { 91728 }, }, ["obj"] = { ["I"] = { 60382 }, }, ["race"] = 178, ["lvl"] = 15, ["min"] = 10, }, -- Crumblepoint Tower [40087] = { ["start"] = { ["U"] = { 91713 }, }, ["end"] = { ["U"] = { 91713 }, }, ["obj"] = { ["U"] = { 91740, 91741 }, }, ["lvl"] = 15, ["min"] = 14, ["next"] = { 40088 }, }, -- Head of the Pack [40088] = { ["start"] = { ["U"] = { 91713 }, }, ["end"] = { ["U"] = { 91713 }, }, ["obj"] = { ["U"] = { 91760, 91739 }, ["I"] = { 60172 }, }, ["lvl"] = 16, ["min"] = 14, ["pre"] = { 40087 }, }, -- The Rampant Groveweald [40089] = { ["start"] = { ["U"] = { 91285 }, }, ["end"] = { ["U"] = { 91285 }, }, ["obj"] = { ["I"] = { 60176 }, }, ["lvl"] = 33, ["min"] = 26, }, -- The Unwise Elders [40090] = { ["start"] = { ["U"] = { 91285 }, }, ["end"] = { ["U"] = { 91285 }, }, ["obj"] = { ["I"] = { 60177, 60178 }, }, ["lvl"] = 34, ["min"] = 26, }, -- Outnumbered [40096] = { ["start"] = { ["U"] = { 91712 }, }, ["end"] = { ["U"] = { 91712 }, }, ["obj"] = { ["U"] = { 91773 }, }, ["race"] = 178, ["lvl"] = 16, ["min"] = 15, ["next"] = { 40097 }, }, -- In the Dark [40097] = { ["start"] = { ["U"] = { 91712 }, }, ["end"] = { ["U"] = { 91712 }, }, ["obj"] = { ["U"] = { 91772 }, }, ["race"] = 178, ["lvl"] = 16, ["min"] = 15, ["next"] = { 40098 }, ["pre"] = { 40096 }, }, -- Rightful Heir [40098] = { ["start"] = { ["U"] = { 91712 }, }, ["end"] = { ["U"] = { 91711 }, }, ["obj"] = { ["I"] = { 60174 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 15, ["next"] = { 40099 }, ["pre"] = { 40096, 40097 }, }, -- Attack from the Inside [40099] = { ["start"] = { ["U"] = { 91711 }, }, ["end"] = { ["U"] = { 91711 }, }, ["obj"] = { ["U"] = { 91980, 91981 }, ["O"] = { 2010824 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 15, ["next"] = { 40277 }, ["pre"] = { 40096, 40097, 40098 }, }, -- The Lone Wolf [40108] = { ["start"] = { ["U"] = { 3978 }, }, ["end"] = { ["U"] = { 60408 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["next"] = { 40109 }, }, -- Scars of the Past [40109] = { ["start"] = { ["U"] = { 60408 }, }, ["end"] = { ["U"] = { 60408 }, }, ["obj"] = { ["U"] = { 60409 }, ["I"] = { 60104 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40108 }, ["next"] = { 40110 }, }, -- Unseen Enemy [40110] = { ["start"] = { ["U"] = { 60408 }, }, ["end"] = { ["U"] = { 3978 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40109 }, ["next"] = { 40111 }, }, -- In a Rush [40111] = { ["start"] = { ["U"] = { 3978 }, }, ["end"] = { ["U"] = { 3978 }, }, ["obj"] = { ["U"] = { 60402 }, ["I"] = { 60102 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40110 }, ["next"] = { 40112 }, }, -- Disturbing Silence [40112] = { ["start"] = { ["U"] = { 3978 }, }, ["end"] = { ["U"] = { 60410 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40111 }, ["next"] = { 40113 }, }, -- Might of the Horde [40113] = { ["start"] = { ["U"] = { 60410 }, }, ["end"] = { ["U"] = { 3978 }, }, ["obj"] = { ["U"] = { 60404, 60405, 60406, 60407 }, ["I"] = { 60103 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40112 }, ["next"] = { 40114 }, }, -- Uldum Awaits [40114] = { ["start"] = { ["U"] = { 3978 }, }, ["end"] = { ["O"] = { 142343 }, }, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40113 }, ["next"] = { 40115 }, }, -- Guardian of the Gate [40115] = { ["start"] = { ["O"] = { 142343 }, }, ["end"] = { ["O"] = { 142343 }, }, ["obj"] = { ["U"] = { 80935 }, }, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40114 }, }, -- Aggresive Wildlife [40120] = { ["start"] = { ["U"] = { 91288 }, }, ["end"] = { ["U"] = { 91288 }, }, ["obj"] = { ["I"] = { 60110 }, }, ["race"] = 77, ["lvl"] = 13, ["min"] = 20, ["next"] = { 40121 }, }, -- Alpha Aggression [40121] = { ["start"] = { ["U"] = { 91288 }, }, ["end"] = { ["U"] = { 91288 }, }, ["obj"] = { ["I"] = { 60111 }, }, ["race"] = 77, ["lvl"] = 13, ["min"] = 21, ["pre"] = { 40120 }, }, -- Dwindling Supplies [40136] = { ["start"] = { ["U"] = { 91727 }, }, ["end"] = { ["U"] = { 91727 }, }, ["obj"] = { ["I"] = { 60196 }, }, ["race"] = 178, ["lvl"] = 16, ["min"] = 15, ["next"] = { 40137 }, }, -- Strike Them Down [40137] = { ["start"] = { ["U"] = { 91727 }, }, ["end"] = { ["U"] = { 91727 }, }, ["obj"] = { ["U"] = { 91989 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 15, ["pre"] = { 40136 }, }, -- Reaperence Of The Damned [40139] = { ["start"] = { ["U"] = { 91726 }, }, ["end"] = { ["U"] = { 91726 }, }, ["obj"] = { ["U"] = { 91756, 91757 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 15, ["next"] = { 40140 }, }, -- Cleaning The Farm [40140] = { ["start"] = { ["U"] = { 91726 }, }, ["end"] = { ["U"] = { 91726 }, }, ["obj"] = { ["U"] = { 91759 }, }, ["race"] = 178, ["lvl"] = 19, ["min"] = 15, ["pre"] = { 40139 }, }, -- Mysteries of the Grove [40145] = { ["start"] = { ["U"] = { 11720 }, }, ["end"] = { ["U"] = { 11749 }, }, ["race"] = 178, ["lvl"] = 37, ["min"] = 26, ["next"] = { 40146 }, }, -- Feran's Report [40146] = { ["start"] = { ["U"] = { 11749 }, }, ["end"] = { ["U"] = { 11720 }, }, ["race"] = 178, ["lvl"] = 37, ["min"] = 26, ["pre"] = { 40145 }, ["next"] = { 40147 }, }, -- Rooting Out Evil [40147] = { ["start"] = { ["U"] = { 11720 }, }, ["end"] = { ["U"] = { 11720 }, }, ["obj"] = { ["U"] = { 92110 }, }, ["race"] = 178, ["lvl"] = 37, ["min"] = 26, ["pre"] = { 40146 }, }, -- Taking over Faldir's Cove [40181] = { ["start"] = { ["U"] = { 60496 }, }, ["end"] = { ["U"] = { 60496 }, }, ["obj"] = { ["U"] = { 2610, 2769 }, }, ["lvl"] = 48, ["min"] = 45, ["pre"] = { 40180 }, ["next"] = { 40182 }, }, -- In Search of Corruption [40192] = { ["start"] = { ["U"] = { 60471 }, }, ["end"] = { ["U"] = { 60471 }, }, ["obj"] = { ["I"] = { 60261, 60262, 60263 }, }, ["race"] = 77, ["lvl"] = 20, ["min"] = 10, ["next"] = { 40193 }, }, -- Ashenvale Corruption [40193] = { ["start"] = { ["U"] = { 60471 }, }, ["end"] = { ["U"] = { 3516 }, }, ["race"] = 77, ["lvl"] = 20, ["min"] = 10, ["pre"] = { 40192 }, }, -- Old Greypaw [40197] = { ["start"] = { ["U"] = { 91287 }, }, ["end"] = { ["U"] = { 91287 }, }, ["obj"] = { ["U"] = { 60470 }, }, ["race"] = 77, ["lvl"] = 19, ["min"] = 10, }, -- Unforseen Consequences [40201] = { ["start"] = { ["U"] = { 60465 }, }, ["end"] = { ["U"] = { 60482 }, }, ["race"] = 77, ["lvl"] = 11, ["min"] = 5, ["next"] = { 40202 }, }, -- Tasala's Word [40202] = { ["start"] = { ["U"] = { 60482 }, }, ["end"] = { ["U"] = { 60465 }, }, ["race"] = 77, ["lvl"] = 11, ["min"] = 5, ["next"] = { 40203 }, ["pre"] = { 40201 }, }, -- Rooting Out Corruption [40203] = { ["start"] = { ["U"] = { 60465 }, }, ["end"] = { ["U"] = { 60465 }, }, ["obj"] = { ["U"] = { 60475 }, }, ["race"] = 77, ["lvl"] = 11, ["min"] = 5, ["pre"] = { 40202 }, }, -- A Meeting With Adaena [40204] = { ["start"] = { ["U"] = { 60474 }, }, ["end"] = { ["U"] = { 60473 }, }, ["race"] = 77, ["lvl"] = 11, ["min"] = 5, ["next"] = { 40205 }, }, -- Securing Darnassus [40205] = { ["start"] = { ["U"] = { 60473 }, }, ["end"] = { ["U"] = { 60473 }, }, ["obj"] = { ["U"] = { 2013, 2012 }, }, ["race"] = 77, ["lvl"] = 11, ["min"] = 5, ["pre"] = { 40204 }, }, -- Collecting Mushrooms [40206] = { ["start"] = { ["U"] = { 982 }, }, ["end"] = { ["U"] = { 982 }, }, ["obj"] = { ["I"] = { 60171 }, }, ["race"] = 178, ["lvl"] = 37, ["min"] = 30 }, -- A Pinch of Venom [40207] = { ["start"] = { ["U"] = { 982 }, }, ["end"] = { ["U"] = { 982 }, }, ["obj"] = { ["I"] = { 60280 }, }, ["race"] = 178, ["lvl"] = 41, ["min"] = 34 }, -- The Magic of Dragons [40208] = { ["start"] = { ["U"] = { 983 }, }, ["end"] = { ["U"] = { 983 }, }, ["obj"] = { ["I"] = { 60281 }, }, ["race"] = 178, ["lvl"] = 45, ["min"] = 34 }, -- The Hunt for Sorrowclaw [40209] = { ["start"] = { ["U"] = { 1775 }, }, ["end"] = { ["U"] = { 1775 }, }, ["obj"] = { ["I"] = { 60282 }, }, ["race"] = 178, ["lvl"] = 41, ["min"] = 34 }, -- The Venture Co. Shakedown [40216] = { ["start"] = { ["U"] = { 60500 }, }, ["end"] = { ["U"] = { 60500 }, }, ["obj"] = { ["U"] = { 3284, 3282 }, }, ["lvl"] = 16, ["min"] = 11, }, -- Batskin Letter [40220] = { ["start"] = { ["U"] = { 1569 }, }, ["end"] = { ["U"] = { 60483 }, }, ["obj"] = { ["I"] = { 60301 }, }, ["race"] = 16, ["class"] = 4, ["lvl"] = 2, ["min"] = 1, }, -- Conserving Stonetalon Peak [40227] = { ["start"] = { ["U"] = { 60507 }, }, ["end"] = { ["U"] = { 60507 }, }, ["obj"] = { ["I"] = { 60310 }, }, ["race"] = 77, ["lvl"] = 24, ["min"] = 17, }, -- Saltspittle Raiders [40230] = { ["start"] = { ["U"] = { 60472 }, }, ["end"] = { ["U"] = { 60472 }, }, ["obj"] = { ["I"] = { 60312, 60313 }, }, ["race"] = 77, ["lvl"] = 21, ["min"] = 10, }, -- The Keepers Charge [40243] = { ["start"] = { ["U"] = { 91722 }, }, ["end"] = { ["U"] = { 91722 }, }, ["obj"] = { ["U"] = { 6348, 6370, 6371 }, }, ["lvl"] = 53, ["min"] = 45, ["next"] = { 40244 }, }, -- The Keepers Possession [40244] = { ["start"] = { ["U"] = { 91722 }, }, ["end"] = { ["U"] = { 91722 }, }, ["obj"] = { ["I"] = { 60326 }, }, ["lvl"] = 53, ["min"] = 45, ["pre"] = { 40243 }, ["next"] = { 40245 }, }, -- The Eldarath Harmonization Gem [40245] = { ["start"] = { ["U"] = { 91722 }, }, ["end"] = { ["U"] = { 91722 }, }, ["obj"] = { ["I"] = { 60327 }, }, ["lvl"] = 53, ["min"] = 45, ["pre"] = { 40244 }, ["next"] = { 40246 }, }, -- Aged Deep-Rod [40246] = { ["start"] = { ["U"] = { 91722 }, }, ["end"] = { ["U"] = { 91722 }, }, ["obj"] = { ["I"] = { 60328 }, }, ["lvl"] = 53, ["min"] = 45, ["pre"] = { 40245 }, ["next"] = { 40247 }, }, -- Staff of Eldara [40247] = { ["start"] = { ["U"] = { 91722 }, }, ["end"] = { ["U"] = { 91722 }, }, ["lvl"] = 53, ["min"] = 45, ["pre"] = { 40246 }, ["next"] = { 40252 }, }, -- Taming the Beast I [40248] = { ["start"] = { ["U"] = { 60484 }, }, ["end"] = { ["U"] = { 60484 }, }, ["obj"] = { ["IR"] = { 60329 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["next"] = { 40249 }, ["pre"] = { 40261, 40260 }, }, -- Taming the Beast II [40249] = { ["start"] = { ["U"] = { 60484 }, }, ["end"] = { ["U"] = { 60484 }, }, ["obj"] = { ["IR"] = { 60330 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["next"] = { 40250 }, ["pre"] = { 40261, 40260, 40248 }, }, -- Taming the Beast III [40250] = { ["start"] = { ["U"] = { 60484 }, }, ["end"] = { ["U"] = { 60484 }, }, ["obj"] = { ["IR"] = { 60331 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["next"] = { 40262 }, ["pre"] = { 40261, 40260, 40248, 40249 }, }, -- The Way-Stones of Old [40252] = { ["start"] = { ["U"] = { 91722 }, }, ["end"] = { ["U"] = { 60512 }, }, ["obj"] = { ["A"] = { 40252 }, }, ["lvl"] = 55, ["min"] = 45, ["pre"] = { 40247}, ["next"] = { 40253 }, }, -- Restoring the Ley Lines [40253] = { ["start"] = { ["U"] = { 60512 }, }, ["end"] = { ["U"] = { 60512 }, }, ["obj"] = { ["A"] = { 60336 }, }, ["lvl"] = 55, ["min"] = 45, ["pre"] = { 40252}, ["next"] = { 40254 }, }, -- Keeping Secrets [40254] = { ["start"] = { ["U"] = { 60512 }, }, ["end"] = { ["U"] = { 60512 }, }, ["obj"] = { ["I"] = { 60332 }, }, ["lvl"] = 58, ["min"] = 45, ["pre"] = { 40253}, }, -- Blackrock and Roll [40256] = { ["start"] = { ["U"] = { 91891 }, }, ["end"] = { ["U"] = { 91891 }, }, ["obj"] = { ["I"] = { 60335 }, }, ["lvl"] = 57, ["min"] = 48, }, -- Blackrock Slayers [40257] = { ["start"] = { ["U"] = { 91891 }, }, ["end"] = { ["U"] = { 91891 }, }, ["obj"] = { ["U"] = { 7027 }, }, ["lvl"] = 57, ["min"] = 48, }, -- A Dark Ranger's Mastery [40260] = { ["start"] = { ["U"] = { 60483 }, }, ["end"] = { ["U"] = { 81050 }, }, ["race"] = 16, ["class"] = 4, ["lvl"] = 5, ["min"] = 5, ["next"] = { 40261 }, }, -- The Hunter's Path [40261] = { ["start"] = { ["U"] = { 81050 }, }, ["end"] = { ["U"] = { 60484 }, }, ["race"] = 16, ["class"] = 4, ["lvl"] = 10, ["min"] = 10, ["next"] = { 40248 }, ["pre"] = { 40260 }, }, -- Taming the Beast IV [40262] = { ["start"] = { ["U"] = { 60484 }, }, ["end"] = { ["U"] = { 60488 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["next"] = { 80755, 40263 }, ["pre"] = { 40261, 40260, 40248, 40249, 40250 }, }, -- A Demonstration of Skill [40263] = { ["start"] = { ["U"] = { 60484 }, }, ["end"] = { ["U"] = { 81050 }, }, ["obj"] = { ["U"] = { 60513 }, ["I"] = { 60337 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 40261, 40260, 40248, 40249, 40250, 40262 }, }, -- A Bad Day to Fish! [40274] = { ["start"] = { ["U"] = { 60510 }, }, ["end"] = { ["U"] = { 60510 }, }, ["obj"] = { ["U"] = { 3110 }, }, ["race"] = 178, ["lvl"] = 11, ["min"] = 6, }, -- Fall Of The Usurpoer [40277] = { ["start"] = { ["U"] = { 91711 }, }, ["end"] = { ["U"] = { 91711 }, }, ["obj"] = { ["U"] = { 91352, 91975, 91721, 91974 }, }, ["race"] = 178, ["lvl"] = 20, ["min"] = 15, ["next"] = { 40277 }, ["pre"] = { 40096, 40097, 40098, 40099 }, }, -- Darlthos Heritage [40278] = { ["start"] = { ["U"] = { 91712 }, }, ["end"] = { ["U"] = { 91753 }, }, ["obj"] = { ["I"] = { 60189 }, }, ["race"] = 178, ["lvl"] = 19, ["min"] = 15, ["next"] = { 40279 }, }, -- A Different Type of Lock [40279] = { ["start"] = { ["U"] = { 91753 }, }, ["end"] = { ["U"] = { 91712 }, }, ["obj"] = { ["I"] = { 60189 }, }, ["race"] = 178, ["lvl"] = 19, ["min"] = 15, ["next"] = { 40280 }, ["pre"] = { 40278 }, }, -- Ways of Magic [40280] = { ["start"] = { ["U"] = { 91712 }, }, ["end"] = { ["U"] = { 4567 }, }, ["obj"] = { ["I"] = { 60189, 60190 }, }, ["race"] = 178, ["lvl"] = 19, ["min"] = 15, ["next"] = { 40281 }, ["pre"] = { 40278, 40279 }, }, -- Into The Jaws [40281] = { ["start"] = { ["U"] = { 4567 }, }, ["end"] = { ["U"] = { 4567 }, }, ["obj"] = { ["I"] = { 60191 }, }, ["race"] = 178, ["lvl"] = 25, ["min"] = 15, ["next"] = { 40281 }, ["pre"] = { 40278, 40279, 40280 }, }, -- Darlthos Legacy [40282] = { ["start"] = { ["U"] = { 4567 }, }, ["end"] = { ["U"] = { 91711 }, }, ["obj"] = { ["I"] = { 60189, 60391 }, }, ["race"] = 178, ["lvl"] = 19, ["min"] = 15, ["pre"] = { 40278, 40279, 40280, 40281 }, }, -- Azsharan Front [40283] = { ["start"] = { ["U"] = { 92024 }, }, ["end"] = { ["U"] = { 92024 }, }, ["obj"] = { ["U"] = { 7864, 6194, 6195 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 40, }, -- Blood and Glory! [40284] = { ["start"] = { ["U"] = { 92024 }, }, ["end"] = { ["U"] = { 92024 }, }, ["obj"] = { ["I"] = { 60396 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 42, }, -- A Blademaster's Request [40285] = { ["start"] = { ["U"] = { 92196 }, }, ["end"] = { ["U"] = { 92196 }, }, ["obj"] = { ["A"] = { 91722 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 45, ["next"] = { 40286 }, }, -- The Search for the Blade [40286] = { ["start"] = { ["U"] = { 92196 }, }, ["end"] = { ["U"] = { 92196 }, }, ["obj"] = { ["I"] = { 60397 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 45, ["pre"] = { 40285 }, ["next"] = { 40287 }, }, -- The Search for the Edge [40287] = { ["start"] = { ["U"] = { 92196 }, }, ["end"] = { ["U"] = { 92196 }, }, ["obj"] = { ["I"] = { 60398 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 45, ["pre"] = { 40286 }, ["next"] = { 40288 }, }, -- Refueling the Blade [40288] = { ["start"] = { ["U"] = { 92196 }, }, ["end"] = { ["U"] = { 92196 }, }, ["obj"] = { ["I"] = { 60399 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 45, ["pre"] = { 40287 }, ["next"] = { 40289 }, }, -- To Honor the Forgotten [40289] = { ["start"] = { ["U"] = { 92196 }, }, ["end"] = { ["U"] = { 92196 }, }, ["race"] = 178, ["lvl"] = 52, ["min"] = 45, ["pre"] = { 40288 }, }, -- Food for Bloodfist Point [40290] = { ["start"] = { ["U"] = { 92202 }, }, ["end"] = { ["U"] = { 92202 }, }, ["obj"] = { ["I"] = { 60401 }, }, ["race"] = 178, ["lvl"] = 50, ["min"] = 40, ["next"] = { 40291 }, }, -- Claws for Bloodfist Point [40291] = { ["start"] = { ["U"] = { 92202 }, }, ["end"] = { ["U"] = { 92202 }, }, ["obj"] = { ["I"] = { 60402 }, }, ["race"] = 178, ["lvl"] = 50, ["min"] = 40, ["pre"] = { 40290 }, }, -- Disturbance in the Air [40292] = { ["start"] = { ["U"] = { 92197 }, }, ["end"] = { ["U"] = { 92197 }, }, ["obj"] = { ["I"] = { 60403, 60404 }, }, ["race"] = 178, ["lvl"] = 50, ["min"] = 40, ["next"] = { 40293 }, }, -- Ritual of the Farseer [40293] = { ["start"] = { ["U"] = { 92197 }, }, ["end"] = { ["U"] = { 92197 }, }, ["race"] = 178, ["lvl"] = 50, ["min"] = 45, ["pre"] = { 40292 }, ["next"] = { 40294 }, }, -- Dragons of Azshara? [40294] = { ["start"] = { ["U"] = { 92197 }, }, ["end"] = { ["U"] = { 92199 }, }, ["race"] = 178, ["lvl"] = 50, ["min"] = 45, ["pre"] = { 40293 }, ["next"] = { 40295 }, }, -- Mystery of Lake Mennar [40295] = { ["start"] = { ["U"] = { 92199 }, }, ["end"] = { ["U"] = { 92199 }, }, ["obj"] = { ["A"] = { 60343 }, }, ["race"] = 178, ["lvl"] = 50, ["min"] = 45, ["pre"] = { 40294 }, ["next"] = { 40296 }, }, -- Report to the Archdruid [40296] = { ["start"] = { ["U"] = { 92199 }, }, ["end"] = { ["U"] = { 5769 }, }, ["race"] = 178, ["lvl"] = 50, ["min"] = 45, ["pre"] = { 40295 }, ["next"] = { 40297 }, }, -- Stop the Dragonflight [40297] = { ["start"] = { ["U"] = { 5769 }, }, ["end"] = { ["U"] = { 92197 }, }, ["obj"] = { ["U"] = { 6129, 6130, 6131 }, }, ["race"] = 178, ["lvl"] = 56, ["min"] = 46, ["pre"] = { 40296 }, }, -- Red Skies of Durotar [40298] = { ["start"] = { ["U"] = { 60538 }, }, ["end"] = { ["U"] = { 60539 }, }, ["obj"] = { ["I"] = { 51751, 769, 3770 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 5, }, -- A Secret Admirer [40300] = { ["start"] = { ["U"] = { 3607 }, }, ["end"] = { ["U"] = { 7295 }, }, ["race"] = 77, ["lvl"] = 12, ["min"] = 10, }, -- Baking Bread [40301] = { ["start"] = { ["U"] = { 3884 }, }, ["end"] = { ["U"] = { 6929 }, }, ["obj"] = { ["I"] = { 60444 }, }, ["race"] = 178, ["lvl"] = 11, ["min"] = 10, }, -- Torta's Egg [40302] = { ["start"] = { ["U"] = { 14823 }, }, ["end"] = { ["U"] = { 14823 }, }, ["obj"] = { ["I"] = { 60445 }, }, ["lvl"] = 22, ["min"] = 20, }, -- The Depths of Karazhan I [40304] = { ["start"] = { ["U"] = { 60607 }, }, ["end"] = { ["U"] = { 60607 }, }, ["obj"] = { ["I"] = { 60454 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["next"] = { 40305 }, }, -- The Depths of Karazhan II [40305] = { ["start"] = { ["U"] = { 60607 }, }, ["end"] = { ["U"] = { 60607 }, }, ["obj"] = { ["I"] = { 60455 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40304 }, ["next"] = { 40306 }, }, -- The Depths of Karazhan III [40306] = { ["start"] = { ["U"] = { 60607 }, }, ["end"] = { ["U"] = { 1497 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40305 }, ["next"] = { 40307 }, }, -- The Depths of Karazhan IV [40307] = { ["start"] = { ["U"] = { 1497 }, }, ["end"] = { ["U"] = { 60607 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40306 }, ["next"] = { 40308 }, }, -- The Depths of Karazhan V [40308] = { ["start"] = { ["U"] = { 60607 }, }, ["end"] = { ["U"] = { 60607 }, }, ["obj"] = { ["I"] = { 60457, 60458 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40307 }, ["next"] = { 40309 }, }, -- The Depths of Karazhan VI [40309] = { ["start"] = { ["U"] = { 60607 }, }, ["end"] = { ["U"] = { 60607 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40308 }, ["next"] = { 40310 }, }, -- The Depths of Karazhan VII [40310] = { ["start"] = { ["U"] = { 60607 }, }, ["end"] = { ["U"] = { 60607 }, }, ["obj"] = { ["U"] = { 91928 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40309 }, }, -- The Mystery of Karazhan I [40311] = { ["start"] = { ["U"] = { 60606 }, }, ["end"] = { ["U"] = { 60606 }, }, ["obj"] = { ["I"] = { 60454 }, }, ["race"] = 77, ["lvl"] = 60, ["min"] = 58, ["next"] = { 40312 }, }, -- The Mystery of Karazhan II [40312] = { ["start"] = { ["U"] = { 60606 }, }, ["end"] = { ["U"] = { 60606 }, }, ["obj"] = { ["I"] = { 60455 }, }, ["race"] = 77, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40311 }, ["next"] = { 40313 }, }, -- The Mystery of Karazhan III [40313] = { ["start"] = { ["U"] = { 60606 }, }, ["end"] = { ["U"] = { 2543 }, }, ["race"] = 77, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40312 }, ["next"] = { 40314 }, }, -- The Mystery of Karazhan IV [40314] = { ["start"] = { ["U"] = { 2543 }, }, ["end"] = { ["U"] = { 60606 }, }, ["race"] = 77, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40313 }, ["next"] = { 40315 }, }, -- The Mystery of Karazhan V [40315] = { ["start"] = { ["U"] = { 60606 }, }, ["end"] = { ["U"] = { 60606 }, }, ["obj"] = { ["I"] = { 60457, 60458 }, }, ["race"] = 77, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40314 }, ["next"] = { 40316 }, }, -- The Mystery of Karazhan VI [40316] = { ["start"] = { ["U"] = { 60606 }, }, ["end"] = { ["U"] = { 60606 }, }, ["race"] = 77, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40315 }, ["next"] = { 40317 }, }, -- The Mystery of Karazhan VII [40317] = { ["start"] = { ["U"] = { 60606 }, }, ["end"] = { ["U"] = { 60606 }, }, ["obj"] = { ["U"] = { 91928 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 58, ["pre"] = { 40316 }, }, -- A Call to Aid (1 of 3) [40318] = { ["start"] = { ["U"] = { 91974 }, }, ["end"] = { ["U"] = { 466 }, }, ["obj"] = { ["I"] = { 60466 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 11, ["next"] = { 40319 }, }, -- A Call to Aid (2 of 3) [40319] = { ["start"] = { ["U"] = { 466 }, }, ["end"] = { ["U"] = { 91974 }, }, ["obj"] = { ["I"] = { 60467 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 11, ["next"] = { 40320 }, ["pre"] = { 40319 }, }, -- A Call to Aid (3 of 3) [40320] = { ["start"] = { ["U"] = { 91976 }, }, ["end"] = { ["U"] = { 91976 }, }, ["obj"] = { ["I"] = { 60468 }, }, ["race"] = 178, ["lvl"] = 17, ["min"] = 11, ["pre"] = { 40318, 40319 }, }, -- The Azurestone [40338] = { ["start"] = { ["U"] = { 60629 }, }, ["end"] = { ["U"] = { 60629 }, }, ["class"] = 128, ["race"] = 4, ["lvl"] = 12, ["min"] = 10, }, -- The Azurestone Order [40339] = { ["start"] = { ["U"] = { 60629 }, }, ["end"] = { ["U"] = { 60629 }, }, ["obj"] = { ["I"] = { 60494 }, }, ["class"] = 128, ["race"] = 4, ["lvl"] = 12, ["min"] = 10, }, -- Corrupted Sand [40340] = { ["start"] = { ["U"] = { 80943 }, }, ["end"] = { ["U"] = { 80943 }, }, ["obj"] = { ["I"] = { 50203 }, }, ["lvl"] = 60, ["min"] = 58, }, -- Sand in Bulk [40341] = { ["start"] = { ["U"] = { 80943 }, }, ["end"] = { ["U"] = { 80943 }, }, ["obj"] = { ["I"] = { 50203 }, }, ["lvl"] = 60, ["min"] = 58, }, -- The Bronze Betrayal [40342] = { ["start"] = { ["U"] = { 60622 }, }, ["end"] = { ["U"] = { 60622 }, }, ["obj"] = { ["I"] = { 60496 }, }, ["lvl"] = 60, ["min"] = 58, }, -- New Bonds [40363] = { ["start"] = { ["U"] = { 66002 }, }, ["end"] = { ["U"] = { 66002 }, }, ["obj"] = { ["U"] = { 2967 }, }, ["race"] = 434, ["lvl"] = 10, ["min"] = 7, ["next"] = 40364, }, -- Seeking Acceptance [40364] = { ["start"] = { ["U"] = { 66002 }, }, ["end"] = { ["U"] = { 3064 }, }, ["race"] = 434, ["lvl"] = 11, ["min"] = 8, ["next"] = 40365, ["pre"] = { 40363 }, }, -- A Trial of Sincerity [40365] = { ["start"] = { ["U"] = { 3064 }, }, ["end"] = { ["U"] = { 66002 }, }, ["obj"] = { ["I"] = { 60513 }, }, ["race"] = 434, ["lvl"] = 11, ["min"] = 8, ["next"] = 40366, ["pre"] = { 40363, 40364 }, }, -- An Earnest Offering [40366] = { ["start"] = { ["U"] = { 66002 }, }, ["end"] = { ["U"] = { 3064 }, }, ["race"] = 434, ["lvl"] = 11, ["min"] = 8, ["pre"] = { 40363, 40364, 40365 }, }, -- Further Studies [40369] = { ["start"] = { ["U"] = { 10118 }, }, ["end"] = { ["U"] = { 10118 }, }, ["obj"] = { ["I"] = { 60516 }, }, ["race"] = 77, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 6343 }, }, -- Foreign Threats [40388] = { ["start"] = { ["I"] = { 60520 }, }, ["end"] = { ["U"] = { 3139 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 3, }, -- Zalazane's Fall [40389] = { ["start"] = { ["U"] = { 3188 }, }, ["end"] = { ["U"] = { 10540 }, }, ["obj"] = { ["I"] = { 4866 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 7, ["pre"] = { 826 }, }, -- Aggression's End [40390] = { ["start"] = { ["I"] = { 60521 }, }, ["end"] = { ["U"] = { 3188 }, }, ["obj"] = { ["I"] = { 60521 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 5, ["next"] = { 40391 }, }, -- A Hunt for Honor [40391] = { ["start"] = { ["U"] = { 3188 }, }, ["end"] = { ["U"] = { 3057 }, }, ["obj"] = { ["I"] = { 60521 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 7, ["pre"] = { 40390 }, }, -- Food for Sailing Thoughts? [40395] = { ["start"] = { ["O"] = { 2010884 }, }, ["end"] = { ["U"] = { 392 }, }, ["lvl"] = 20, ["min"] = 15, ["next"] = { 40396 }, }, -- Captain Grayson's Revenge [40396] = { ["start"] = { ["O"] = { 392 }, }, ["end"] = { ["U"] = { 392 }, }, ["obj"] = { ["I"] = { 60526 }, }, ["lvl"] = 22, ["min"] = 15, }, -- Night's Exploration [50230] = { ["start"] = { ["U"] = { 718 }, }, ["end"] = { ["U"] = { 718 }, }, ["lvl"] = 15, ["min"] = 5 }, -- In Service of the Light (1 of 2) [50300] = { ["start"] = { ["U"] = { 4982 }, }, ["end"] = { ["U"] = { 12336 }, }, ["race"] = 1, ["lvl"] = 6, ["min"] = 1, ["next"] = { 50301 }, }, -- In Service of the Light (2 of 2) [50301] = { ["start"] = { ["U"] = { 12336 }, }, ["end"] = { ["U"] = { 50506 }, }, ["race"] = 1, ["lvl"] = 6, ["min"] = 1, ["next"] = { 50302 }, ["pre"] = { 50300 }, }, -- Light's Chosen Champion. [50302] = { ["start"] = { ["U"] = { 50506 }, }, ["end"] = { ["U"] = { 50506 }, }, ["obj"] = { ["U"] = { 50508 }, }, ["race"] = 1, ["lvl"] = 7, ["min"] = 1, ["next"] = { 50303 }, ["pre"] = { 50301 }, }, -- Before the Storm [50303] = { ["start"] = { ["U"] = { 50506 }, }, ["end"] = { ["U"] = { 50507 }, }, ["race"] = 1, ["lvl"] = 8, ["min"] = 1, ["pre"] = { 50302 }, }, -- Higher Stakes [50305] = { ["start"] = { ["U"] = { 3191 }, }, ["end"] = { ["U"] = { 3191 }, }, ["obj"] = { ["I"] = { 2924 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 8, ["pre"] = { 815 }, }, -- Goblin Engineering At It's Finest! [50310] = { ["start"] = { ["U"] = { 50521 }, }, ["end"] = { ["U"] = { 50521 }, }, ["obj"] = { ["U"] = { 50533 }, }, ["lvl"] = 60, ["min"] = 1, ["next"] = { 50311 }, }, -- Mirage Raceway: Gnome's Team [50311] = { ["start"] = { ["U"] = { 50521 }, }, ["end"] = { ["U"] = { 50521 }, }, ["obj"] = { ["U"] = { 4507 }, }, ["lvl"] = 60, ["min"] = 1, ["pre"] = { 50310 }, }, -- Gnomes Are Genuine Inventors [50312] = { ["start"] = { ["U"] = { 50522 }, }, ["end"] = { ["U"] = { 50522 }, }, ["obj"] = { ["U"] = { 50533 }, }, ["lvl"] = 60, ["min"] = 1, ["next"] = { 50313 }, }, -- Mirage Raceway: Gnome's Team [50313] = { ["start"] = { ["U"] = { 50522 }, }, ["end"] = { ["U"] = { 50522 }, }, ["obj"] = { ["U"] = { 4507 }, }, ["lvl"] = 60, ["min"] = 1, ["pre"] = { 50312 }, }, -- Race Against Time! [50316] = { ["start"] = { ["U"] = { 4507 }, }, ["end"] = { ["U"] = { 4507 }, }, ["lvl"] = 60, ["min"] = 1, }, -- Bracing The Inevitable [50318] = { ["start"] = { ["U"] = { 50660 }, }, ["end"] = { ["U"] = { 50660 }, }, ["obj"] = { ["I"] = { 51248 }, }, ["lvl"] = 60, ["min"] = 1, }, -- Snowball Wars: Episode I [50319] = { ["start"] = { ["U"] = { 50654 }, }, ["end"] = { ["U"] = { 50654 }, }, ["lvl"] = 60, ["min"] = 1, }, -- Snowball Wars: Episode II [50320] = { ["start"] = { ["U"] = { 50654 }, }, ["end"] = { ["U"] = { 50654 }, }, ["lvl"] = 60, ["min"] = 1, }, -- The Icy Menace [50321] = { ["start"] = { ["U"] = { 50662 }, }, ["end"] = { ["U"] = { 50662 }, }, ["lvl"] = 60, ["min"] = 1, }, -- Grizzlore Wants Thunder [50326] = { ["start"] = { ["U"] = { 51254 }, }, ["end"] = { ["U"] = { 51254 }, }, ["obj"] = { ["I"] = { 1262 }, }, ["lvl"] = 60, ["min"] = 1, }, -- Jolly Holly Dances Prolly [50328] = { ["start"] = { ["U"] = { 50645 }, }, ["end"] = { ["U"] = { 50645 }, }, ["lvl"] = 60, ["min"] = 1, }, -- Razlik's Tools [55000] = { ["start"] = { ["U"] = { 91208 }, }, ["end"] = { ["U"] = { 91208 }, }, ["obj"] = { ["I"] = { 81291 }, }, ["race"] = 178, ["lvl"] = 9, ["min"] = 7, }, -- The Oil Stops Flowing [55001] = { ["start"] = { ["U"] = { 91213 }, }, ["end"] = { ["U"] = { 91213 }, }, ["obj"] = { ["U"] = { 91194, 91193 }, }, ["race"] = 178, ["lvl"] = 9, ["min"] = 7, }, -- Supplies to the Port! [55002] = { ["start"] = { ["U"] = { 3168 }, }, ["end"] = { ["U"] = { 91237 }, }, ["obj"] = { ["I"] = { 81293 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 5, }, -- A New Power Source [55003] = { ["start"] = { ["U"] = { 91214 }, }, ["end"] = { ["U"] = { 91214 }, }, ["obj"] = { ["I"] = { 81292 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 7, ["next"] = { 55006 }, }, -- Adding a Little Sting [55004] = { ["start"] = { ["U"] = { 91227 }, }, ["end"] = { ["U"] = { 91227 }, }, ["obj"] = { ["I"] = { 5466, 769 }, }, ["race"] = 178, ["lvl"] = 7, ["min"] = 5, }, -- Prototype Thievery [55005] = { ["start"] = { ["U"] = { 91200 }, }, ["end"] = { ["U"] = { 91200 }, }, ["obj"] = { ["I"] = { 81315 }, }, ["race"] = 178, ["lvl"] = 18, ["min"] = 16, }, -- Backup Capacitor [55006] = { ["start"] = { ["U"] = { 91234 }, }, ["end"] = { ["U"] = { 91234 }, }, ["obj"] = { ["I"] = { 81318 }, }, ["race"] = 178, ["lvl"] = 34, ["min"] = 29, ["pre"] = { 55003 }, }, -- Employing the Cabal [55011] = { ["start"] = { ["U"] = { 80121 }, }, ["end"] = { ["U"] = { 91275 }, }, ["obj"] = { ["I"] = { 81322 }, }, ["race"] = 178, ["lvl"] = 13, ["min"] = 10, ["next"] = { 55012 }, }, -- Short Five Minute Adventure [55012] = { ["start"] = { ["U"] = { 91275 }, }, ["end"] = { ["U"] = { 91275 }, }, ["obj"] = { ["I"] = { 814, 4361, 17019 }, }, ["race"] = 178, ["lvl"] = 13, ["min"] = 10, ["next"] = { 55013 }, ["pre"] = { 55011 }, }, -- Shaking a Cold Arm [55013] = { ["start"] = { ["U"] = { 91275 }, }, ["end"] = { ["U"] = { 80178 }, }, ["race"] = 178, ["lvl"] = 13, ["min"] = 10, ["pre"] = { 55012 }, }, -- Missing Blood [55019] = { ["start"] = { ["U"] = { 91203 }, }, ["end"] = { ["U"] = { 5546 }, }, ["obj"] = { ["I"] = { 81331 }, }, ["race"] = 178, ["lvl"] = 39, ["min"] = 35, ["next"] = { 55020 }, }, -- Misgotten Honor [55020] = { ["start"] = { ["U"] = { 5546 }, }, ["end"] = { ["U"] = { 7623 }, }, ["race"] = 178, ["lvl"] = 39, ["min"] = 35, ["next"] = { 55021 }, ["pre"] = { 55019 }, }, -- Beyond the Walls [55021] = { ["start"] = { ["U"] = { 7623 }, }, ["end"] = { ["U"] = { 7623 }, }, ["obj"] = { ["U"] = { 1084, 858, 767 }, }, ["race"] = 178, ["lvl"] = 39, ["min"] = 35, ["next"] = { 55022 }, ["pre"] = { 55019, 55020 }, }, -- Taking Leave [55022] = { ["start"] = { ["U"] = { 7623 }, }, ["end"] = { ["U"] = { 5546 }, }, ["race"] = 178, ["lvl"] = 39, ["min"] = 35, ["next"] = { 55023 }, ["pre"] = { 55019, 55020, 55021 }, }, -- Relief and Reprise [55023] = { ["start"] = { ["U"] = { 5546 }, }, ["end"] = { ["U"] = { 91203 }, }, ["obj"] = { ["I"] = { 81332 }, }, ["race"] = 178, ["lvl"] = 39, ["min"] = 35, ["pre"] = { 55019, 55020, 55021, 55022 }, }, -- It All Comes Sinking Down [55026] = { ["start"] = { ["U"] = { 91259 }, }, ["end"] = { ["U"] = { 2496 }, }, ["race"] = 178, ["lvl"] = 36, ["min"] = 30, ["next"] = { 55027 }, }, -- Employed Help [55027] = { ["start"] = { ["U"] = { 2496 }, }, ["end"] = { ["U"] = { 2496 }, }, ["obj"] = { ["U"] = { 1097 }, }, ["race"] = 178, ["lvl"] = 37, ["min"] = 30, ["next"] = { 55028 }, ["pre"] = { 55026 }, }, -- The "Hiidden" Crew [55028] = { ["start"] = { ["U"] = { 2496 }, }, ["end"] = { ["U"] = { 91280 }, }, ["race"] = 178, ["lvl"] = 37, ["min"] = 30, ["next"] = { 55029 }, ["pre"] = { 55026, 55027 }, }, -- In Need of Information [55029] = { ["start"] = { ["U"] = { 91280 }, }, ["end"] = { ["U"] = { 2496 }, }, ["race"] = 178, ["lvl"] = 36, ["min"] = 30, --["next"] = { 55030 }, ["pre"] = { 55026, 55027, 55028 }, }, -- Reduced to Madness [55032] = { ["start"] = { ["U"] = { 91285 }, }, ["end"] = { ["U"] = { 91285 }, }, ["obj"] = { ["U"] = { 3748 }, }, ["lvl"] = 24, ["min"] = 16, }, -- Kill-Kill Sagepaw! [55033] = { ["start"] = { ["U"] = { 91243 }, }, ["end"] = { ["U"] = { 91243 }, }, ["obj"] = { ["U"] = { 91291 }, }, ["race"] = 178, ["lvl"] = 24, ["min"] = 16, }, -- Kill-Kill Mosshides! [55034] = { ["start"] = { ["U"] = { 91243 }, }, ["end"] = { ["U"] = { 91243 }, }, ["obj"] = { ["I"] = { 81335 }, }, ["race"] = 178, ["lvl"] = 24, ["min"] = 16, ["next"] = { 55035 }, }, -- Hidden-Hidden Rewards [55035] = { ["start"] = { ["U"] = { 91275 }, }, ["end"] = { ["O"] = { 1000500 }, }, ["race"] = 178, ["lvl"] = 24, ["min"] = 16, ["pre"] = { 55034 }, }, -- Where's My Yeti Fur?! [55036] = { ["start"] = { ["U"] = { 91237 }, }, ["end"] = { ["U"] = { 91292 }, }, ["race"] = 178, ["lvl"] = 32, ["min"] = 25, ["next"] = { 55037 }, }, -- Filling Back-Orders [55037] = { ["start"] = { ["U"] = { 91292 }, }, ["end"] = { ["U"] = { 91292 }, }, ["obj"] = { ["I"] = { 3720 }, }, ["race"] = 178, ["lvl"] = 32, ["min"] = 25, ["pre"] = { 55036 }, ["next"] = { 55038 }, }, -- A Late Delivery [55038] = { ["start"] = { ["U"] = { 91292 }, }, ["end"] = { ["U"] = { 91237 }, }, ["race"] = 178, ["lvl"] = 32, ["min"] = 25, ["pre"] = { 55037 }, }, -- Wisdom of the Sages [55041] = { ["start"] = { ["U"] = { 91232 }, }, ["end"] = { ["U"] = { 91232 }, }, ["obj"] = { ["I"] = { 81343 }, }, ["race"] = 178, ["lvl"] = 30, ["min"] = 20, }, -- Satisfaction for Shak [55042] = { ["start"] = { ["U"] = { 91260 }, }, ["end"] = { ["U"] = { 91260 }, }, ["obj"] = { ["I"] = { 81344 }, }, ["race"] = 178, ["lvl"] = 20, ["min"] = 12, }, -- The Brightwater Logs [55043] = { ["start"] = { ["U"] = { 91259 }, }, ["end"] = { ["U"] = { 91259 }, }, ["obj"] = { ["I"] = { 81345 }, }, ["race"] = 178, ["lvl"] = 32, ["min"] = 20, }, -- Missing Worker! [55044] = { ["start"] = { ["U"] = { 91274 }, }, ["end"] = { ["U"] = { 91272 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 6, ["next"] = { 55045 }, }, -- Ore on Time [55045] = { ["start"] = { ["U"] = { 91272 }, }, ["end"] = { ["U"] = { 91274 }, }, ["obj"] = { ["I"] = { 2770 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 6, ["pre"] = { 55044 }, }, -- Agon Ore [55046] = { ["start"] = { ["U"] = { 91274 }, }, ["end"] = { ["U"] = { 91274 }, }, ["obj"] = { ["I"] = { 81346 }, }, ["race"] = 178, ["lvl"] = 42, ["min"] = 34, }, -- The Lucky Boots [55047] = { ["start"] = { ["U"] = { 91274 }, }, ["end"] = { ["U"] = { 91274 }, }, ["obj"] = { ["I"] = { 81347 }, }, ["race"] = 178, ["lvl"] = 45, ["min"] = 34, }, -- WANTED: Shazknock! [55049] = { ["start"] = { ["O"] = { 1000504 }, }, ["end"] = { ["U"] = { 91237 }, }, ["obj"] = { ["U"] = { 91298 }, }, ["race"] = 178, ["lvl"] = 18, ["min"] = 10, }, -- Once Upon a Sheep [60005] = { ["start"] = { ["U"] = { 50604 }, }, ["end"] = { ["U"] = { 50604 }, }, ["obj"] = { ["U"] = { 50610 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 6, ["next"] = { 60007, 60008 }, }, -- Lulu Looks Luscious to Lupines [60007] = { ["start"] = { ["U"] = { 50608 }, }, ["end"] = { ["U"] = { 50608 }, }, ["obj"] = { ["U"] = { 525 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 6, ["pre"] = { 60005 }, }, -- Wool Would Work [60008] = { ["start"] = { ["U"] = { 50605 }, }, ["end"] = { ["U"] = { 50605 }, }, ["obj"] = { ["I"] = { 51223 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 6, ["pre"] = { 60005 }, }, -- Fashion Demands Sacrifices [60030] = { ["start"] = { ["U"] = { 51292 }, }, ["end"] = { ["U"] = { 51293 }, }, ["obj"] = { ["I"] = { 2589, 2318, 774, 4813 }, }, ["lvl"] = 10, ["min"] = 10, }, -- Delicious Pumpkin Pie [60040] = { ["start"] = { ["U"] = { 51261 }, }, ["end"] = { ["U"] = { 51261 }, }, ["obj"] = { ["I"] = { 51330 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 6, }, -- The Pumpkin Thieves [60041] = { ["start"] = { ["U"] = { 248 }, }, ["end"] = { ["U"] = { 248 }, }, ["obj"] = { ["I"] = { 51325 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 6, }, -- Gnoll Bounty [60042] = { ["start"] = { ["U"] = { 1650 }, }, ["end"] = { ["U"] = { 10616 }, }, ["obj"] = { ["U"] = { 97, 478 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 6, }, -- Lucky Coin [60050] = { ["start"] = { ["U"] = { 51302 }, }, ["end"] = { ["U"] = { 1431 }, }, ["obj"] = { ["IR"] = { 51425 }, }, ["race"] = 77, ["lvl"] = 5, ["min"] = 4, }, -- You Reap What You Sow [60061] = { ["start"] = { ["U"] = { 51532 }, }, ["end"] = { ["U"] = { 51532 }, }, ["obj"] = { ["I"] = { 51706, 51707, 51708, 51716 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 20, }, -- Matter of Trust [60070] = { ["start"] = { ["U"] = { 51564 }, }, ["end"] = { ["U"] = { 51562 }, }, ["obj"] = { ["I"] = { 769, 422, 51751 }, }, ["race"] = 77, ["lvl"] = 7, ["min"] = 6, }, -- Cold Feet [60107] = { ["start"] = { ["U"] = { 1521 }, }, ["end"] = { ["U"] = { 1521 }, }, ["obj"] = { ["I"] = { 51807 }, }, ["race"] = 178, ["lvl"] = 10, ["min"] = 8, ["pre"] = { 375 }, }, -- Githyiss the Vile [60110] = { ["start"] = { ["U"] = { 2082 }, }, ["end"] = { ["U"] = { 2082 } }, ["obj"] = { ["I"] = { 51815 } }, ["race"] = 77, ["lvl"] = 5, ["min"] = 3, ["pre"] = { 916 }, }, -- A Decisive Blow [60111] = { ["start"] = { ["U"] = { 2151 }, }, ["end"] = { ["U"] = { 2151 } }, ["obj"] = { ["U"] = { 2162, 1993 } }, ["race"] = 77, ["lvl"] = 10, ["min"] = 9, ["pre"] = { 487 }, }, -- Fallen Adventurers [60112] = { ["start"] = { ["U"] = { 1661 }, }, ["end"] = { ["U"] = { 1661 }, }, ["obj"] = { ["U"] = { 1916, 1917, 1918 }, }, ["race"] = 178, ["lvl"] = 4, ["min"] = 3, ["pre"] = { 376 }, }, -- Virulence [60113] = { ["start"] = { ["U"] = { 1518 }, }, ["end"] = { ["U"] = { 1518 }, }, ["obj"] = { ["I"] = { 51822 }, }, ["race"] = 178, ["lvl"] = 8, ["min"] = 6, ["pre"] = { 367 }, }, -- The Terror of Chill Breeze [60114] = { ["start"] = { ["U"] = { 1266 }, }, ["end"] = { ["U"] = { 1266 }, }, ["obj"] = { ["I"] = { 51823 }, }, ["race"] = 77, ["lvl"] = 11, ["min"] = 7, }, -- Preventive Strike [60115] = { ["start"] = { ["U"] = { 3209 }, }, ["end"] = { ["U"] = { 3209 }, }, ["obj"] = { ["U"] = { 3229 }, ["I"] = { 51826 }, }, ["lvl"] = 5, ["min"] = 3, }, -- Paint the Roses Red [60116] = { ["start"] = { ["U"] = { 1652 }, }, ["end"] = { ["U"] = { 1652 }, }, ["obj"] = { ["U"] = { 4281, 4280, 4283 }, }, ["race"] = 178, ["lvl"] = 29, ["min"] = 27, ["pre"] = { 60117 }, }, -- Scarlet with Rage [60117] = { ["start"] = { ["U"] = { 6741 }, }, ["end"] = { ["U"] = { 1652 }, }, ["race"] = 178, ["lvl"] = 29, ["min"] = 27, }, -- Wayne Manners [60119] = { ["start"] = { ["U"] = { 2395 }, }, ["end"] = { ["U"] = { 2395 }, }, ["obj"] = { ["U"] = { 2252, 2253 }, }, ["race"] = 178, ["lvl"] = 35, ["min"] = 30, }, -- The Mail Must Go Through [60121] = { ["start"] = { ["U"] = { 3293 }, }, ["end"] = { ["U"] = { 5610 }, }, ["obj"] = { ["I"] = { 51846 }, }, ["race"] = 434, ["lvl"] = 10, ["min"] = 7, ["pre"] = { 835 }, ["next"] = { 60122 }, }, -- Trapped in the Nightmare (Alliance custom) [60124] = { ["start"] = { ["U"] = { 3702 }, }, ["end"] = { ["U"] = { 3702 }, }, ["obj"] = { ["U"] = { 3654 }, }, ["race"] = 77, ["lvl"] = 19, ["min"] = 16, }, -- Serpentbloom (Alliance custom) [60125] = { ["start"] = { ["U"] = { 3702 }, }, ["end"] = { ["U"] = { 3702 }, }, ["obj"] = { ["I"] = { 5339 }, }, ["race"] = 77, ["lvl"] = 18, ["min"] = 16, }, -- That Dirty Old Ring [60130] = { ["start"] = { ["I"] = { 51855 }, }, ["end"] = { ["U"] = { 328 }, }, ["obj"] = { ["I"] = { 51855 }, }, ["race"] = 77, ["lvl"] = 6, ["min"] = 6, }, -- Deep Blue Sea [60131] = { ["start"] = { ["U"] = { 4311 }, }, ["end"] = { ["U"] = { 4311 }, }, ["obj"] = { ["U"] = { 5435 }, }, ["lvl"] = 13, ["min"] = 10, }, -- They're In The Way! [60132] = { ["start"] = { ["U"] = { 9555 }, }, ["end"] = { ["U"] = { 9555 }, }, ["obj"] = { ["U"] = { 2563 }, }, ["race"] = 178, ["lvl"] = 32, ["min"] = 30, }, -- Down With the Sickness [60133] = { ["start"] = { ["U"] = { 3448 }, }, ["end"] = { ["U"] = { 3448 }, }, ["obj"] = { ["I"] = { 51860 }, }, ["race"] = 178, ["lvl"] = 14, ["min"] = 14, ["next"] = { 60134 }, }, -- Preventing Poison [60134] = { ["start"] = { ["U"] = { 3448 }, }, ["end"] = { ["U"] = { 3448 }, }, ["obj"] = { ["U"] = { 12296 }, }, ["race"] = 178, ["lvl"] = 15, ["min"] = 15, ["pre"] = { 60133 }, }, -- Kodo Hunt [60138] = { ["start"] = { ["U"] = { 2993 }, }, ["end"] = { ["U"] = { 2993 }, }, ["obj"] = { ["U"] = { 2973, 2974 }, }, ["race"] = 178, ["lvl"] = 11, ["min"] = 10, }, -- No More-pid! [60139] = { ["start"] = { ["U"] = { 6787 }, }, ["end"] = { ["U"] = { 6787 }, }, ["obj"] = { ["U"] = { 3126 }, }, ["race"] = 178, ["lvl"] = 7, ["min"] = 6, }, -- Don’t Lose (Part Of) Your Head [60140] = { ["start"] = { ["U"] = { 2131 }, }, ["end"] = { ["U"] = { 2131 }, }, ["obj"] = { ["I"] = { 1251 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 5, }, -- Duty to the Light [60141] = { ["start"] = { ["U"] = { 927 }, }, ["end"] = { ["U"] = { 1103 }, }, ["obj"] = { ["I"] = { 51868 }, }, ["race"] = 77, ["lvl"] = 9, ["min"] = 8, }, -- A Change Of Heart [60142] = { ["start"] = { ["U"] = { 6119 }, }, ["end"] = { ["U"] = { 6031 }, }, ["race"] = 77, ["lvl"] = 6, ["min"] = 5, }, -- Brannol's Sewing Kit [60143] = { ["start"] = { ["U"] = { 3611 }, }, ["end"] = { ["U"] = { 3611 }, }, ["obj"] = { ["I"] = { 51870 }, }, ["race"] = 77, ["lvl"] = 10, ["min"] = 9, }, -- Down in the Ridge [60145] = { ["start"] = { ["U"] = { 197 }, }, ["end"] = { ["U"] = { 197 }, }, ["obj"] = { ["U"] = { 51600 }, }, ["race"] = 77, ["lvl"] = 5, ["min"] = 1, ["pre"] = { 15 }, }, -- Stalking the Felstalkers [60147] = { ["start"] = { ["U"] = { 3145 }, }, ["end"] = { ["U"] = { 3145 }, }, ["obj"] = { ["U"] = { 3102 }, }, ["race"] = 178, ["lvl"] = 4, ["min"] = 4, ["pre"] = { 792 }, }, -- Mother of the Hollow [60148] = { ["start"] = { ["U"] = { 1570 }, }, ["end"] = { ["U"] = { 1570 }, }, ["obj"] = { ["U"] = { 1688 }, }, ["race"] = 178, ["lvl"] = 5, ["min"] = 4, ["pre"] = { 376, 380 }, }, -- Bristleback Aggression [60150] = { ["start"] = { ["U"] = { 2980 }, }, ["end"] = { ["U"] = { 2980 }, }, ["obj"] = { ["U"] = { 2952, 2953 }, }, ["lvl"] = 4, ["min"] = 3, ["pre"] = { 750 }, }, -- Jasperlode Infestation [60154] = { ["start"] = { ["U"] = { 240 }, }, ["end"] = { ["U"] = { 240 }, }, ["obj"] = { ["U"] = { 43 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 6, ["pre"] = { 76 }, }, -- A Special Kind of Summons [70000] = { ["start"] = { ["U"] = { 2708, 1498 }, }, ["end"] = { ["U"] = { 8379 }, }, ["race"] = 255, ["lvl"] = 60, ["min"] = 60, ["pre"] = { 7463 }, ["next"] = { 70001 }, }, -- Lost to the Sands [70001] = { ["start"] = { ["U"] = { 8379 }, }, ["obj"] = { ["I"] = { 83005 }, }, ["end"] = { ["U"] = { 8379 }, }, ["race"] = 255, ["lvl"] = 60, ["min"] = 60, ["pre"] = { 70000 }, }, -- The Guidance of a Mad Man [70002] = { ["start"] = { ["U"] = { 5675, 6122 }, }, ["end"] = { ["U"] = { 14463 }, }, ["class"] = 256, ["lvl"] = 60, ["min"] = 60, ["pre"] = { 7583 }, ["next"] = { 70003 }, }, -- Draining the Soulflayer [70003] = { ["start"] = { ["U"] = { 14463 }, }, ["end"] = { ["U"] = { 14463 }, }, ["obj"] = { ["I"] = { 83006 }, }, ["class"] = 256, ["lvl"] = 60, ["min"] = 60, ["pre"] = { 70002 }, }, -- A Brother’s Worried Mind [70020] = { ["start"] = { ["U"] = { 11720 }, }, ["end"] = { ["U"] = { 70020 }, }, ["lvl"] = 29, ["min"] = 28, ["next"] = { 70021 }, }, -- Taupo’s Duty [70021] = { ["start"] = { ["U"] = { 70020 }, }, ["end"] = { ["U"] = { 70020 }, }, ["obj"] = { ["I"] = { 70021 }, }, ["lvl"] = 29, ["min"] = 28, ["pre"] = { 70020 }, ["next"] = { 70022 }, }, -- Norvok of the Spear [70022] = { ["start"] = { ["U"] = { 70022 }, }, ["end"] = { ["U"] = { 70022 }, }, ["obj"] = { ["U"] = { 6115, 6073 }, }, ["lvl"] = 29, ["min"] = 28, ["pre"] = { 70020, 70021 }, ["next"] = { 70023 }, }, -- Report to Commander Grushak [70023] = { ["start"] = { ["U"] = { 70022 }, }, ["end"] = { ["U"] = { 70023 }, }, ["lvl"] = 30, ["min"] = 28, ["pre"] = { 70020, 70021, 70022 }, ["next"] = { 70024 }, }, -- Wildthorn Menace [70024] = { ["start"] = { ["U"] = { 70023 }, }, ["end"] = { ["U"] = { 70023 }, }, ["obj"] = { ["U"] = { 3821 }, }, ["lvl"] = 30, ["min"] = 28, ["pre"] = { 70020, 70021, 70022, 70023 }, ["next"] = { 70025 }, }, -- Knife Eared Stalkers [70025] = { ["start"] = { ["U"] = { 70023 }, }, ["end"] = { ["U"] = { 70023 }, }, ["obj"] = { ["U"] = { 70025 }, }, ["lvl"] = 29, ["min"] = 28, ["pre"] = { 70020, 70021, 70022, 70023, 70024 }, ["next"] = { 70026 }, }, -- Peon's Wardrobe Makeover [70026] = { ["start"] = { ["U"] = { 70023 }, }, ["end"] = { ["U"] = { 70023 }, }, ["obj"] = { ["I"] = { 70022 }, }, ["lvl"] = 30, ["min"] = 28, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025 }, ["next"] = { 70027 }, }, -- Farseer Grimeye [70027] = { ["start"] = { ["U"] = { 70023 }, }, ["end"] = { ["U"] = { 70027 }, }, ["lvl"] = 28, ["min"] = 25, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025, 70026 }, ["next"] = { 70028 }, }, -- Demon Fall Canyon [70028] = { ["start"] = { ["U"] = { 70027 }, }, ["end"] = { ["U"] = { 70027 }, }, ["obj"] = { ["U"] = { 11697, 6073, 6115 }, }, ["lvl"] = 28, ["min"] = 25, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025, 70026, 70027 }, ["next"] = { 70029 }, }, -- What We Know [70029] = { ["start"] = { ["U"] = { 70027 }, }, ["end"] = { ["U"] = { 70027 }, }, ["obj"] = { ["U"] = { 70028 }, }, ["lvl"] = 28, ["min"] = 25, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025, 70026, 70027, 70028 }, ["next"] = { 70030 }, }, -- A Very Unpleasant Troll [70030] = { ["start"] = { ["U"] = { 70027 }, }, ["end"] = { ["U"] = { 3995 }, }, ["lvl"] = 28, ["min"] = 25, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025, 70026, 70027, 70028, 70029 }, ["next"] = { 70031 }, }, -- Jin'Zil's Stew [70031] = { ["start"] = { ["U"] = { 3995 }, }, ["end"] = { ["U"] = { 3995 }, }, ["obj"] = { ["I"] = { 1205, 422, 3771, 3713 }, }, ["lvl"] = 28, ["min"] = 25, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025, 70026, 70027, 70028, 70029, 70030 }, ["next"] = { 70032 }, }, -- The Good Mojo [70032] = { ["start"] = { ["U"] = { 3995 }, }, ["end"] = { ["U"] = { 70027 }, }, ["lvl"] = 29, ["min"] = 26, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025, 70026, 70027, 70028, 70029, 70030, 70031 }, ["next"] = { 70033 }, }, -- The Seeker's Demise [70033] = { ["start"] = { ["U"] = { 70027 }, }, ["end"] = { ["U"] = { 70027 }, }, ["obj"] = { ["U"] = { 6072, 11697, 6073, 6115 }, ["I"] = { 70026 }, }, ["lvl"] = 30, ["min"] = 27, ["pre"] = { 70020, 70021, 70022, 70023, 70024, 70025, 70026, 70027, 70028, 70029, 70030, 70031, 70032 }, }, -- Hawk's Beak [70034] = { ["start"] = { ["I"] = { 70027 }, }, ["end"] = { ["U"] = { 70022 }, }, ["lvl"] = 27, ["min"] = 26, ["pre"] = { 70022 }, }, -- Reinforcing The Sepulcher [70040] = { ["start"] = { ["U"] = { 4605 }, }, ["end"] = { ["U"] = { 2140 }, }, ["obj"] = { ["I"] = { 6214, 2857 }, }, ["lvl"] = 16, ["min"] = 14, }, -- Troubles From Distant Lands [70048] = { ["start"] = { ["U"] = { 90983 }, }, ["end"] = { ["U"] = { 90983 }, }, ["obj"] = { ["I"] = { 70040, 70041, 70042 }, }, ["lvl"] = 13, ["min"] = 11, }, -- Trader's Misfortune [70052] = { ["start"] = { ["U"] = { 3453 }, }, ["end"] = { ["U"] = { 3453 }, }, ["obj"] = { ["U"] = { 6494 }, }, ["race"] = 178, ["lvl"] = 13, ["min"] = 12, }, -- A New Ad-Venture [80100] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80100 }, }, ["obj"] = { ["I"] = { 80100 }, }, ["race"] = 178, ["lvl"] = 1, ["min"] = 1, }, -- Venture Vultures [80101] = { ["start"] = { ["U"] = { 80101 }, }, ["end"] = { ["U"] = { 80101 }, }, ["obj"] = { ["I"] = { 80103 }, }, ["race"] = 178, ["lvl"] = 2, ["min"] = 2, }, -- Green Versus Green [80102] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80100 }, }, ["obj"] = { ["U"] = { 80114, 80115 }, }, ["race"] = 178, ["lvl"] = 2, ["min"] = 2, }, -- Risen Oilblazes [80103] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80100 }, }, ["obj"] = { ["I"] = { 80112 }, }, ["race"] = 178, ["lvl"] = 4, ["min"] = 3, }, -- The Other White Mech [80104] = { ["start"] = { ["U"] = { 80101 }, }, ["end"] = { ["U"] = { 80101 }, }, ["obj"] = { ["I"] = { 80119 }, }, ["race"] = 178, ["lvl"] = 2, ["min"] = 1, }, -- Ventured Too Far [80105] = { ["start"] = { ["I"] = { 80114 }, }, ["end"] = { ["U"] = { 80100 }, }, ["race"] = 178, ["lvl"] = 5, ["min"] = 4, ["next"] = { 80106 }, }, -- The Grumbling Grove [80106] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80100 }, }, ["obj"] = { ["U"] = { 80118, 80119 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 4, ["next"] = { 80107 }, ["pre"] = { 80105 }, }, -- Shadow On The Plateau [80107] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80100 }, }, ["obj"] = { ["U"] = { 80120 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 4, ["next"] = { 80108 }, ["pre"] = { 80105, 80106 }, }, -- Me Not Any Kind Of Orc [80108] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80121 }, }, ["obj"] = { ["O"] = { 3000100 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 4, ["next"] = { 80109 }, ["pre"] = { 80105, 80106, 80107 }, }, -- Zug-zug or Somethin' [80109] = { ["start"] = { ["U"] = { 80121 }, }, ["end"] = { ["U"] = { 3191 }, }, ["obj"] = { ["O"] = { 769 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 4, ["next"] = { 80110 }, ["pre"] = { 80105, 80106, 80107, 80108 }, }, -- Green Goes Red [80110] = { ["start"] = { ["U"] = { 3191 }, }, ["end"] = { ["U"] = { 3139 }, }, ["obj"] = { ["O"] = { 80130 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 4, ["pre"] = { 80105, 80106, 80107, 80108, 80109 }, }, -- Grease-stained Letter [80115] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80104 }, }, ["race"] = 178, ["class"] = 1, ["lvl"] = 2, ["min"] = 2, ["pre"] = { 80100 }, }, -- Ooze-covered Letter [80116] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80106 }, }, ["race"] = 178, ["class"] = 8, ["lvl"] = 2, ["min"] = 2, ["pre"] = { 80100 }, }, -- Leather-covered Letter [80117] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80105 }, }, ["race"] = 178, ["class"] = 4, ["lvl"] = 2, ["min"] = 2, ["pre"] = { 80100 }, }, -- Fancy Letter [80118] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80108 }, }, ["race"] = 178, ["class"] = 128, ["lvl"] = 2, ["min"] = 2, ["pre"] = { 80100 }, }, -- Awful-looking Letter [80119] = { ["start"] = { ["U"] = { 80100 }, }, ["end"] = { ["U"] = { 80107 }, }, ["race"] = 178, ["class"] = 256, ["lvl"] = 2, ["min"] = 2, ["pre"] = { 80100 }, }, -- Garbage Man [80120] = { ["start"] = { ["U"] = { 80131 }, }, ["end"] = { ["U"] = { 80131 }, }, ["obj"] = { ["I"] = { 80155 }, }, ["race"] = 178, ["lvl"] = 1, ["min"] = 1, }, -- This Is In My Contract [80121] = { ["start"] = { ["U"] = { 80107 }, }, ["end"] = { ["U"] = { 80107 }, }, ["obj"] = { ["I"] = { 80170 }, }, ["race"] = 178, ["class"] = 256, ["lvl"] = 6, ["min"] = 4, ["pre"] = { 80100 }, }, -- Mastering the Arcane [80311] = { ["start"] = { ["U"] = { 80857 }, }, ["end"] = { ["U"] = { 80831 }, }, ["race"] = 178, ["class"] = 128, ["lvl"] = 16, ["min"] = 14, ["next"] = { 80312 }, }, -- Arcane Arms [80312] = { ["start"] = { ["U"] = { 80831 }, }, ["end"] = { ["U"] = { 80831 }, }, ["obj"] = { ["I"] = { 80862, 80863, 80864 }, }, ["race"] = 178, ["class"] = 128, ["lvl"] = 18, ["min"] = 14, ["pre"] = { 80311 }, }, -- Apple a Day [80315] = { ["start"] = { ["U"] = { 80460 }, }, ["end"] = { ["U"] = { 80460 }, }, ["race"] = 77, ["lvl"] = 8, ["min"] = 8, }, -- Burning Bridges [80320] = { ["start"] = { ["U"] = { 80902 }, }, ["end"] = { ["U"] = { 80902 }, }, ["obj"] = { ["I"] = { 80868 }, }, ["race"] = 178, ["lvl"] = 60, ["min"] = 7, ["next"] = { 80321 }, }, -- The Hunter's Path [80330] = { ["start"] = { ["U"] = { 3407 }, }, ["end"] = { ["U"] = { 80903 }, }, ["class"] = 4, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, }, -- Taming the Beast [80331] = { ["start"] = { ["U"] = { 80903 }, }, ["end"] = { ["U"] = { 80903 }, }, ["obj"] = { ["IR"] = { 15917 }, }, ["class"] = 4, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["next"] = { 80332 }, }, -- Taming the Beast [80332] = { ["start"] = { ["U"] = { 80903 }, }, ["end"] = { ["U"] = { 80903 }, }, ["obj"] = { ["IR"] = { 15919 }, }, ["class"] = 4, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80331 }, ["next"] = { 80333 }, }, -- Taming the Beast [80333] = { ["start"] = { ["U"] = { 80903 }, }, ["end"] = { ["U"] = { 80903 }, }, ["obj"] = { ["IR"] = { 15920 }, }, ["class"] = 4, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80332 }, ["next"] = { 80334 }, }, -- Training the Beast [80334] = { ["start"] = { ["U"] = { 80903 }, }, ["end"] = { ["U"] = { 3352 }, }, ["class"] = 4, ["race"] = 178, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80333 }, }, -- The Hunter's Path [80339] = { ["start"] = { ["U"] = { 5515, 5116, 5117, 895 }, }, ["end"] = { ["U"] = { 80855 }, }, ["class"] = 64, ["race"] = 77, ["lvl"] = 10, ["min"] = 10, }, -- Taming the Beast [80340] = { ["start"] = { ["U"] = { 80855 }, }, ["end"] = { ["U"] = { 80855 }, }, ["obj"] = { ["IR"] = { 15911 }, }, ["class"] = 4, ["race"] = 64, ["lvl"] = 10, ["min"] = 10, ["next"] = { 80341 }, }, -- Taming the Beast [80341] = { ["start"] = { ["U"] = { 80855 }, }, ["end"] = { ["U"] = { 80855 }, }, ["obj"] = { ["IR"] = { 15913 }, }, ["class"] = 4, ["race"] = 64, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80340 }, ["next"] = { 80342 }, }, -- Taming the Beast [80342] = { ["start"] = { ["U"] = { 80855 }, }, ["end"] = { ["U"] = { 80855 }, }, ["obj"] = { ["IR"] = { 15908 }, }, ["class"] = 4, ["race"] = 64, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80341 }, ["next"] = { 80343 }, }, -- Training the Beast [80343] = { ["start"] = { ["U"] = { 80855 }, }, ["end"] = { ["U"] = { 10090 }, }, ["class"] = 4, ["race"] = 64, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80342 }, }, -- Etched Rune [80350] = { ["start"] = { ["U"] = { 658 }, }, ["end"] = { ["U"] = { 895 }, }, ["class"] = 4, ["race"] = 77, ["lvl"] = 1, ["min"] = 1, ["pre"] = { 179 }, }, -- The Hunter's Path [80366] = { ["start"] = { ["U"] = { 80458 }, }, ["end"] = { ["U"] = { 1231 }, }, ["class"] = 4, ["race"] = 77, ["lvl"] = 10, ["min"] = 10, }, -- Lizzi's Competitor [80380] = { ["start"] = { ["U"] = { 80991 }, }, ["end"] = { ["U"] = { 80991 }, }, ["obj"] = { ["I"] = { 12206,19222,2924,5471 }, }, ["lvl"] = 60, ["min"] = 1, }, -- Shellcoins [80381] = { ["start"] = { ["U"] = { 80999 }, }, ["end"] = { ["U"] = { 80999 }, }, ["obj"] = { ["I"] = { 81117 }, }, ["lvl"] = 35, ["min"] = 1, }, -- VIP Invites [80382] = { ["start"] = { ["U"] = { 80990 }, }, ["end"] = { ["U"] = { 80990 }, }, ["obj"] = { ["U"] = { 3391, 2496 }, }, ["lvl"] = 35, ["min"] = 1, }, -- Sharks Are Friends, Not Food [80383] = { ["start"] = { ["U"] = { 80997 }, }, ["end"] = { ["U"] = { 80997 }, }, ["obj"] = { ["U"] = { 81006 }, }, ["lvl"] = 35, ["min"] = 1, }, -- Pinch of Salt [80384] = { ["start"] = { ["U"] = { 5941 }, }, ["end"] = { ["U"] = { 5941 }, }, ["obj"] = { ["I"] = { 81181 }, }, ["race"] = 178, ["lvl"] = 6, ["min"] = 6, }, -- Stay awhile and listen... [80388] = { ["start"] = { ["U"] = { 81030 }, }, ["end"] = { ["U"] = { 81030 }, }, ["lvl"] = 1, ["min"] = 1, }, -- A Glittering Opportunity [80395] = { ["start"] = { ["U"] = { 3658 }, }, ["end"] = { ["U"] = { 81041 }, }, ["obj"] = { ["O"] = { 3000284 }, }, ["lvl"] = 13, ["min"] = 13, ["next"] = { 80396 }, }, -- A Bloody Good Deed [80396] = { ["start"] = { ["U"] = { 81041 }, }, ["end"] = { ["U"] = { 81041 }, }, ["obj"] = { ["U"] = { 3397, 3274, 3275 }, }, ["lvl"] = 13, ["min"] = 13, ["next"] = { 80407 }, ["pre"] = { 80395 }, }, -- Zalazane's Apprentice [80399] = { ["start"] = { ["I"] = { 59990 }, }, ["end"] = { ["U"] = { 3188 }, }, ["obj"] = { ["I"] = { 59996, 59995 }, }, ["lvl"] = 8, ["min"] = 6, }, -- A Journey Into The Caverns [80604] = { ["start"] = { ["U"] = { 10667 }, }, ["end"] = { ["U"] = { 65005 }, }, ["lvl"] = 60, ["min"] = 60, ["next"] = { 80605 }, }, -- The First Opening of The Dark Portal [80605] = { ["start"] = { ["U"] = { 65005 }, }, ["end"] = { ["U"] = { 65004 }, }, ["obj"] = { ["I"] = { 51044 }, }, ["lvl"] = 60, ["min"] = 60, ["pre"] = { 80604 }, }, -- Training the Beast [80755] = { ["start"] = { ["U"] = { 60488 }, }, ["end"] = { ["U"] = { 60488 }, }, ["race"] = 16, ["class"] = 4, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 40261, 40260, 40248, 40249, 40250, 40262 }, }, -- Durotar Scouring [807] = { ["start"] = { ["U"] = { 3142 }, }, ["end"] = { ["U"] = { 3142 }, }, ["obj"] = { ["I"] = { 4868 }, }, ["lvl"] = 10, ["min"] = 4, }, -- Work for Food [814] = { ["start"] = { ["U"] = { 3191 }, }, ["end"] = { ["U"] = { 3191 }, }, ["obj"] = { ["I"] = { 769 }, }, ["lvl"] = 6, ["min"] = 4, }, -- Study to Survive [810] = { ["start"] = { ["U"] = { 3189 }, }, ["end"] = { ["U"] = { 3189 }, }, ["obj"] = { ["I"] = { 51000 }, }, ["lvl"] = 5, ["min"] = 4, ["next"] = { 811 }, }, -- Unity is Strength [811] = { ["start"] = { ["U"] = { 3189 }, }, ["end"] = { ["U"] = { 3189 }, }, ["obj"] = { ["I"] = { 51001 }, }, ["lvl"] = 8, ["min"] = 5, ["pre"] = { 810 }, }, -- What Do You Rely On? [820] = { ["start"] = { ["U"] = { 3304 }, }, ["end"] = { ["U"] = { 3304 }, }, ["obj"] = { ["I"] = { 2676 }, }, ["lvl"] = 10, ["min"] = 5, }, -- Professor Malkovich [50000] = { ["start"] = { ["U"] = { 2122, 3155 }, }, ["end"] = { ["U"] = { 50002 }, }, ["race"] = 178, ["class"] = 8, ["lvl"] = 6, ["min"] = 2, ["next"] = { 50002 }, }, -- The Human Anatomy [50002] = { ["start"] = { ["U"] = { 50002 }, }, ["end"] = { ["U"] = { 50002 }, }, ["obj"] = { ["I"] = { 50063 }, }, ["race"] = 178, ["class"] = 8, ["lvl"] = 6, ["min"] = 2, ["pre"] = { 50000 }, }, -- Professor Papucho [50003] = { ["start"] = { ["U"] = { 3594, 915, 916 }, }, ["end"] = { ["U"] = { 50004 }, }, ["race"] = 77, ["class"] = 8, ["lvl"] = 6, ["min"] = 2, ["next"] = { 50004 }, }, -- The Orcish Anatomy [50004] = { ["start"] = { ["U"] = { 50004 }, }, ["obj"] = { ["I"] = { 50064 }, }, ["end"] = { ["U"] = { 50004 }, }, ["race"] = 77, ["class"] = 8, ["lvl"] = 6, ["min"] = 2, ["pre"] = { 50003 }, }, -- Oil-Stained Gold [70051] = { ["start"] = { ["U"] = { 70060 }, }, ["end"] = { ["U"] = { 70060 }, }, ["obj"] = { ["I"] = { 70031 }, }, ["lvl"] = 9, ["min"] = 7, }, -- Farstrider Lodge [80200] = { ["start"] = { ["U"] = { 80200 }, }, ["end"] = { ["U"] = { 1156 }, }, ["race"] = 77, ["lvl"] = 1, ["min"] = 1, ["next"] = { 80201, 80203, 80211 }, }, -- Stocking Up on Wood [80201] = { ["start"] = { ["U"] = { 1156 }, }, ["obj"] = { ["I"] = { 80200 }, }, ["end"] = { ["U"] = { 1156 }, }, ["race"] = 77, ["lvl"] = 1, ["min"] = 1, ["pre"] = { 80200 }, }, -- Clearing Out Vermin [80203] = { ["start"] = { ["U"] = { 80202 }, }, ["obj"] = { ["U"] = { 80201 }, }, ["end"] = { ["U"] = { 80202 }, }, ["race"] = 77, ["lvl"] = 1, ["min"] = 1, ["pre"] = { 80200 }, ["next"] = { 80204 }, }, -- Gathering Intel [80204] = { ["start"] = { ["U"] = { 80202 }, }, ["obj"] = { ["A"] = { 80203 }, }, ["end"] = { ["U"] = { 80202 }, }, ["race"] = 77, ["lvl"] = 3, ["min"] = 2, ["pre"] = { 80203 }, }, -- Slaking Their Thirst [80205] = { ["start"] = { ["U"] = { 1156 }, }, ["obj"] = { ["O"] = { 3000202 }, }, ["end"] = { ["U"] = { 1156 }, }, ["race"] = 77, ["lvl"] = 3, ["min"] = 2, ["pre"] = { 80201 }, ["next"] = { 80206 }, }, -- Burnt Wheels [80206] = { ["start"] = { ["U"] = { 1156 }, }, ["obj"] = { ["U"] = { 80200 }, }, ["end"] = { ["U"] = { 80202 }, }, ["race"] = 77, ["lvl"] = 4, ["min"] = 3, ["pre"] = { 80205 }, ["next"] = { 80207 }, }, -- Dark Iron Scrapping [80207] = { ["start"] = { ["U"] = { 80202 }, }, ["obj"] = { ["I"] = { 80216 }, }, ["end"] = { ["U"] = { 80202 }, }, ["race"] = 77, ["lvl"] = 4, ["min"] = 3, ["pre"] = { 80206 }, ["next"] = { 80208 }, }, -- Sunblade Reunion [80208] = { ["start"] = { ["U"] = { 1156 }, }, ["obj"] = { ["U"] = { 80200 }, }, ["end"] = { ["U"] = { 80202 }, }, ["race"] = 77, ["lvl"] = 5, ["min"] = 4, ["pre"] = { 80207 }, ["next"] = { 80209 }, }, -- Porting to Goldshire [80209] = { ["start"] = { ["U"] = { 80202 }, }, ["obj"] = { ["U"] = { 80213 }, }, ["end"] = { ["U"] = { 240 }, }, ["race"] = 77, ["lvl"] = 5, ["min"] = 4, ["pre"] = { 80208 }, }, -- Providing a Balanced Diet [80210] = { ["start"] = { ["U"] = { 1156 }, }, ["obj"] = { ["I"] = { 80224, 80225 }, }, ["end"] = { ["U"] = { 1156 }, }, ["race"] = 77, ["lvl"] = 4, ["min"] = 3, ["pre"] = { 80201 }, }, -- Seeking Further Guidance [80211] = { ["start"] = { ["U"] = { 1156 }, }, ["end"] = { ["U"] = { 80219 }, }, ["race"] = 77, ["class"] = 4, ["lvl"] = 3, ["min"] = 3, ["pre"] = { 80200 }, }, -- Seeking Further Guidance [80212] = { ["start"] = { ["U"] = { 1156 }, }, ["end"] = { ["U"] = { 80220 }, }, ["race"] = 77, ["class"] = 2, ["lvl"] = 3, ["min"] = 3, ["pre"] = { 80200 }, }, -- Seeking Further Guidance [80213] = { ["start"] = { ["U"] = { 1156 }, }, ["end"] = { ["U"] = { 80221 }, }, ["race"] = 77, ["class"] = 16, ["lvl"] = 3, ["min"] = 3, ["pre"] = { 80200 }, }, -- Seeking Further Guidance [80214] = { ["start"] = { ["U"] = { 1156 }, }, ["end"] = { ["U"] = { 80218 }, }, ["race"] = 77, ["class"] = 128, ["lvl"] = 3, ["min"] = 3, ["pre"] = { 80200 }, }, -- Seeking Further Guidance [80215] = { ["start"] = { ["U"] = { 1156 }, }, ["end"] = { ["U"] = { 80223 }, }, ["race"] = 77, ["class"] = 8, ["lvl"] = 3, ["min"] = 3, ["pre"] = { 80200 }, }, -- Seeking Further Guidance [80216] = { ["start"] = { ["U"] = { 1156 }, }, ["end"] = { ["U"] = { 80217 }, }, ["race"] = 77, ["class"] = 1, ["lvl"] = 3, ["min"] = 3, ["pre"] = { 80200 }, }, -- Pelts and Tusks [80217] = { ["start"] = { ["U"] = { 1154 }, }, ["obj"] = { ["I"] = { 80232, 80233 }, }, ["end"] = { ["U"] = { 1154 }, }, ["race"] = 77, ["lvl"] = 2, ["min"] = 2, }, -- KABOOM! [80219] = { ["start"] = { ["U"] = { 80961 }, }, ["end"] = { ["U"] = { 80961 }, }, ["obj"] = { ["I"] = { 4378 }, }, ["lvl"] = 60, ["min"] = 1, }, -- A New Place in Stormwind [80220] = { ["start"] = { ["U"] = { 240 }, }, ["end"] = { ["U"] = { 80405 }, }, ["race"] = 77, ["lvl"] = 5, ["min"] = 5, }, -- Assisting the Children of the Sun [80250] = { ["start"] = { ["U"] = { 80230 }, }, ["end"] = { ["U"] = { 1752 }, }, ["race"] = 77, ["lvl"] = 10, ["min"] = 10, ["next"] = { 80251 }, }, -- To Alah'Thalas! [80251] = { ["start"] = { ["U"] = { 1752 }, }, ["end"] = { ["U"] = { 5498 }, }, ["race"] = 77, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80250 }, ["next"] = { 80252, 80253, 80256, 80258 }, }, -- Triggered! [60120] = { ["start"] = { ["U"] = { 3293 }, }, ["end"] = { ["U"] = { 3293 }, }, ["obj"] = { ["I"] = { 51845 }, }, ["lvl"] = 9, ["min"] = 7, }, -- Quark's Shack [80305] = { ["start"] = { ["U"] = { 5610 }, }, ["end"] = { ["U"] = { 80601 }, }, ["lvl"] = 10, ["min"] = 10, ["next"] = { 80306 }, }, -- WANTED: Hole Escapee [55048] = { ["start"] = { ["O"] = { 1000504 }, }, ["end"] = { ["U"] = { 91249 }, ["O"] = { 1000504 }, }, ["obj"] = { ["U"] = { 91296 }, }, ["lvl"] = 14, ["min"] = 8, }, -- A Gizmo a Day... [80386] = { ["start"] = { ["U"] = { 80961 }, }, ["end"] = { ["U"] = { 80961 }, }, ["obj"] = { ["I"] = { 4375 }, }, ["race"] = 434, ["lvl"] = 60, ["min"] = 10, }, -- Out For Delivery [60122] = { ["start"] = { ["U"] = { 5610 }, }, ["end"] = { ["U"] = { 3322 }, }, ["obj"] = { ["I"] = { 51846 }, }, ["lvl"] = 10, ["min"] = 7, ["pre"] = { 60121 }, }, -- A Tusken Affair [80300] = { ["start"] = { ["U"] = { 80800 }, }, ["end"] = { ["U"] = { 5885 }, }, ["lvl"] = 10, ["min"] = 10, ["next"] = { 80301, 80303, 80304, 80360 }, }, -- What's Yours is Ours [80306] = { ["start"] = { ["U"] = { 80601 }, }, ["end"] = { ["U"] = { 80601 }, }, ["obj"] = { ["U"] = { 80600 }, }, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 80305 }, ["next"] = { 80307 }, }, -- Yet Another Smoke Cloud Above Orgrimmar [80307] = { ["start"] = { ["U"] = { 80601 }, }, ["end"] = { ["U"] = { 6791 }, }, ["lvl"] = 13, ["min"] = 10, ["pre"] = { 80306 }, ["next"] = { 80308 }, }, -- Lighting the Pyres [80301] = { ["start"] = { ["U"] = { 80801 }, }, ["end"] = { ["U"] = { 80801 }, }, ["obj"] = { ["O"] = { 3000242 }, }, ["lvl"] = 60, ["min"] = 10, ["pre"] = { 80300 }, }, -- Tobacco Thieves [80308] = { ["start"] = { ["U"] = { 6791 }, }, ["end"] = { ["U"] = { 80601 }, }, ["obj"] = { ["I"] = { 80401 }, }, ["lvl"] = 13, ["min"] = 10, ["pre"] = { 80307 }, ["next"] = { 80309 }, }, -- The Lies that Bind Us [80321] = { ["start"] = { ["U"] = { 3391 }, }, ["end"] = { ["U"] = { 3359 }, }, ["obj"] = { ["I"] = { 80868 }, }, ["lvl"] = 60, ["min"] = 13, ["pre"] = { 80320 }, ["next"] = { 80322 }, }, -- The Lies That Bind Us [80322] = { ["start"] = { ["U"] = { 3359 }, }, ["end"] = { ["U"] = { 3682 }, }, ["obj"] = { ["I"] = { 80868 }, }, ["lvl"] = 60, ["min"] = 13, ["pre"] = { 80321 }, ["next"] = { 80323 }, }, -- The Lies That Bind Us [80323] = { ["start"] = { ["U"] = { 3682 }, }, ["end"] = { ["U"] = { 3391 }, }, ["obj"] = { ["I"] = { 80868 }, }, ["lvl"] = 60, ["min"] = 13, ["pre"] = { 80322 }, }, -- Odo's Gut Feeling [80309] = { ["start"] = { ["U"] = { 80605 }, }, ["end"] = { ["U"] = { 80605 }, }, ["obj"] = { ["I"] = { 80402, 80403 }, }, ["lvl"] = 14, ["min"] = 13, ["pre"] = { 80308 }, ["next"] = { 80310 }, }, -- Quark's Justice [80310] = { ["start"] = { ["U"] = { 80601, 658 }, }, ["end"] = { ["U"] = { 80601, 895 }, }, ["obj"] = { ["U"] = { 80603, 80604 }, }, ["lvl"] = 14, ["min"] = 13, ["pre"] = { 80309 }, }, -- The Means To Heal [80304] = { ["start"] = { ["U"] = { 80802 }, }, ["end"] = { ["U"] = { 80802 }, }, ["obj"] = { ["I"] = { 80420, 80421 }, }, ["lvl"] = 60, ["min"] = 20, ["pre"] = { 80300 }, }, -- Bandit Lord [40138] = { ["start"] = { ["U"] = { 91749 }, }, ["end"] = { ["U"] = { 91749 }, }, ["obj"] = { ["I"] = { 60197 }, }, ["lvl"] = 19, ["min"] = 15, }, -- The Rogue Heights [40083] = { ["start"] = { ["U"] = { 91729 }, }, ["end"] = { ["U"] = { 91729 }, }, ["obj"] = { ["U"] = { 91761, 91762 }, }, ["lvl"] = 17, ["min"] = 11, ["next"] = { 40084, 40085 }, }, -- Magical Interference [40084] = { ["start"] = { ["U"] = { 91729 }, }, ["end"] = { ["U"] = { 91729 }, }, ["obj"] = { ["I"] = { 60378 }, }, ["lvl"] = 20, ["min"] = 11, ["pre"] = { 40083 }, }, -- Stealing Arcane Goods [40085] = { ["start"] = { ["U"] = { 91729 }, }, ["end"] = { ["U"] = { 91729 }, }, ["obj"] = { ["I"] = { 60381 }, }, ["lvl"] = 18, ["min"] = 11, ["pre"] = { 40083 }, }, -- Supplying the Sepulcher [6321] = { ["start"] = { ["U"] = { 6389 }, }, ["end"] = { ["U"] = { 2226 }, }, ["obj"] = { ["I"] = { 16209 }, }, ["race"] = 434, ["lvl"] = 10, ["min"] = 10, ["next"] = { 6323, 6322, 6324 }, }, -- Ride to the Undercity [6323] = { ["start"] = { ["U"] = { 2226 }, }, ["end"] = { ["U"] = { 4556 }, }, ["obj"] = { ["I"] = { 16209 }, }, ["race"] = 434, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 6321 }, ["next"] = { 6322, 6324 }, }, -- Michael Garrett [6322] = { ["start"] = { ["U"] = { 4556 }, }, ["end"] = { ["U"] = { 4551 }, }, ["obj"] = { ["I"] = { 16210 }, }, ["race"] = 434, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 6321, 6323 }, ["next"] = { 6324 }, }, -- Return to Podrig [6324] = { ["start"] = { ["U"] = { 4551 }, }, ["end"] = { ["U"] = { 6389 }, }, ["obj"] = { ["I"] = { 16210 }, }, ["race"] = 434, ["lvl"] = 10, ["min"] = 10, ["pre"] = { 6321, 6323, 6322 }, }, -- The Glowing Shard [6981] = { ["start"] = { ["I"] = { 10441 }, }, ["end"] = { ["U"] = { 8418 }, }, ["obj"] = { ["I"] = { 10441 }, ["U"] = { 3442 }, }, ["lvl"] = 26, ["min"] = 15, ["next"] = { 3369, 3370 }, }, }
local m = {} local PROPERTY_PATTERN = "([%w%-%.]+)=(.*)" local SECTION_PATTERN = "%-%-%- ?([%w%-%.]+)" function m.parse_property(line) property, value = line:match(PROPERTY_PATTERN) if property == nil then error("line isn't a valid property declaration.") end return property, value end function m.read_file_sections(path) local file = love.filesystem.newFile(path) local sections = {} local name = nil local section = nil for line in file:lines() do section_name = line:match(SECTION_PATTERN) if section_name then if name then -- Don't try to save first "nil" section sections[name] = section end section = {} name = section_name else if not section then error("Line outside of section.") end section[#section+1] = line end end if name then sections[name] = section end return sections end return m
-- Converted From LST file data\pathfinder\paizo\roleplaying_game\core_rulebook\cr_feats.lst -- From repository https://github.com/pcgen/pcgen at commit 11ceb52482855f2e5f0f6c108c3dc665b12af237 SetSource({ SourceLong="Core Rulebook", SourceShort="CR", SourceWeb="http://paizo.com/store/downloads/pathfinder/pathfinderRPG/v5748btpy88yj", SourceDate="2009-08", }) DefineAbility({ Name="Acrobatic", Category="FEAT", Description={ Format="You are skilled at leaping, jumping, and flying.", }, SourcePage="p.113", Benefits={ { FormatString="You get a +2 bonus on all Acrobatics and Fly skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Acrobatics\")>=10,4,2)"), Variables={ "Acrobatics", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Fly\")>=10,4,2)"), Variables={ "Fly", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Acrobatic Steps", Category="FEAT", Description={ Format="You can easily move over and through obstacles.", }, SourcePage="p.113", Benefits={ { FormatString="Whenever you move, you may move through up to 15 feet of difficult terrain each round as if it were normal terrain. The effects of this feat stack with those provided by Nimble Moves (allowing you to move normally through a total of 20 feet of difficult terrain each round).", }, }, Bonuses={ { Category="VAR", Formula=Formula("15"), Variables={ "Feat_NimbleMoves_Squares", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Nimble Moves" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 15) or (character.Variables["FeatDexRequirement"] >= 15) end, }, Types={ "General", }, }) DefineAbility({ Name="Agile Maneuvers", Category="FEAT", Description={ Format="You learned to use your quickness in place of brute force when performing combat maneuvers.", }, SourcePage="p.117", Benefits={ { FormatString="You add your Dexterity bonus to your base attack bonus and size bonus when determining your Combat Maneuver Bonus (see Chapter 8) instead of your Strength bonus.", }, }, Bonuses={ { Category="VAR", Formula=Formula("DEX-STR"), Conditions={ function (character, item, sources) return character.Size > "T" end, }, Variables={ "CMB_STAT", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Alertness", Category="FEAT", Description={ Format="You often notice things that others might miss.", }, SourcePage="p.117", Benefits={ { FormatString="You get a +2 bonus on Perception and Sense Motive skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Perception\")>=10,4,2)"), Variables={ "Perception", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Sense Motive\")>=10,4,2)"), Variables={ "Sense Motive", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Alignment Channel", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseString({"Chaos", "Evil", "Good", "Law"}), }, Description={ Format="You can channel your divine energy to harm or heal outsiders that possess your chosen alignment subtype.", }, SourcePage="p.117", Stackable=false, Benefits={ { FormatString="Instead of its normal effect, you can choose to have your ability to channel energy heal or harm outsiders of the chosen alignment subtype. You must make this choice each time you channel energy. If you choose to heal or harm creatures of the chosen alignment subtype, your channel energy has no effect on other creatures. The amount of damage healed or dealt and the DC to halve the damage is otherwise unchanged.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Energy") then return true end return false end) end, }, Types={ "General", "AttackOption", }, }) DefineAbility({ Name="Animal Affinity", Category="FEAT", Description={ Format="You are skilled at working with animals and mounts.", }, SourcePage="p.118", Benefits={ { FormatString="You get a +2 bonus on all Handle Animal and Ride skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Handle Animal\")>=10,4,2)"), Variables={ "Handle Animal", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Ride\")>=10,4,2)"), Variables={ "Ride", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Arcane Armor Mastery", Category="FEAT", Description={ Format="You have mastered the ability to cast spells while wearing armor.", }, SourcePage="p.118", TemporaryBonus={ Bonus={ Category="MISC", Formula=Formula("-20"), Type={ Name="ArmorFailure", }, Variables={ "SPELLFAILURE", }, }, Target="PC", }, Benefits={ { FormatString="As a swift action, reduce the arcane spell failure chance due to the armor you are wearing by 20%% for any spells you cast this round. This bonus replaces, and does not stack with, the bonus granted by Arcane Armor Training.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Arcane Armor Training" then return true end return false end) end, function (character, item, sources) return ((character.CountSpellCastingClasses(7))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 7) end, function (character, item, sources) return (character.IsProficientWithArmorType("Medium")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Armor Proficiency (Medium)" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Arcane Armor Training", Category="FEAT", Description={ Format="You have learned how to cast spells while wearing armor.", }, SourcePage="p.118", TemporaryBonus={ Bonus={ Category="MISC", Formula=Formula("-10"), Type={ Name="ArmorFailure", }, Variables={ "SPELLFAILURE", }, }, Target="PC", }, Benefits={ { FormatString="As a swift action, reduce the arcane spell failure chance due to the armor you are wearing by 10%% for any spells you cast this round.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(3))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 3) end, function (character, item, sources) return (character.IsProficientWithArmorType("Light")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Armor Proficiency (Light)" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Arcane Strike", Category="FEAT", Description={ Format="As a swift action, you can imbue your weapons with a fraction of your power. For 1 round, you gain a +%1 damage bonus and your weapons are treated as magic for the purpose of overcoming damage reduction.", Arguments={ Formula("ArcaneStrikeDamageBonus"), }, }, SourcePage="p.118", TemporaryBonus={ Bonus={ Category="COMBAT", Formula=Formula("ArcaneStrikeDamageBonus"), Variables={ "DAMAGE.Weapon", }, }, Target="PC", }, Benefits={ { FormatString="As a swift action, you can imbue your weapons with a fraction of your power. For 1 round, your weapons deal +1 damage and are treated as magic for the purpose of overcoming damage reduction. For every five caster levels you possess, this bonus increases by +1, to a maximum of +5 at 20th level.", }, }, Bonuses={ { Category="VAR", Formula=Formula("min(1+ArcaneStrikeLVL/5,5)"), Variables={ "ArcaneStrikeDamageBonus", }, }, }, Conditions={ function (character, item, sources) return ((character.CountArcaneSpellCastingClasses(1))) >= 1 or (character.Variables["Caster_Level_Highest__Arcane"] >= 1) or character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("SpellLike") then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Armor Proficiency (Heavy)", Category="FEAT", Description={ Format="You are skilled at wearing heavy armor.", }, DisplayName="Armor Proficiency, Heavy", SourcePage="p.118", AutomaticProficiencies={ { Kind="Armor", Types={ "ArmorProfHeavy", }, }, }, Benefits={ { FormatString="When you wear a type of armor with which you are proficient, the armor check penalty for that armor applies only to Dexterity- and Strength-based skill checks.", }, }, Conditions={ function (character, item, sources) return (character.IsProficientWithArmorType("Medium")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Armor Proficiency (Medium)" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Armor Proficiency (Light)", Category="FEAT", Description={ Format="You are skilled at wearing light armor.", }, DisplayName="Armor Proficiency, Light", SourcePage="p.118", AutomaticProficiencies={ { Kind="Armor", Types={ "ArmorProfLight", }, }, }, Benefits={ { FormatString="When you wear a type of armor with which you are proficient, the armor check penalty for that armor applies only to Dexterity- and Strength-based skill checks.", }, }, Types={ "Combat", }, }) DefineAbility({ Name="Armor Proficiency (Medium)", Category="FEAT", Description={ Format="You are skilled at wearing medium armor.", }, DisplayName="Armor Proficiency, Medium", SourcePage="p.118", AutomaticProficiencies={ { Kind="Armor", Types={ "ArmorProfMedium", }, }, }, Benefits={ { FormatString="When you wear a type of armor with which you are proficient, the armor check penalty for that armor applies only to Dexterity- and Strength-based skill checks.", }, }, Conditions={ function (character, item, sources) return (character.IsProficientWithArmorType("Light")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Armor Proficiency (Light)" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Athletic", Category="FEAT", Description={ Format="You possess inherent physical prowess.", }, SourcePage="p.118", Benefits={ { FormatString="You get a +2 bonus on Climb and Swim skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Climb\")>=10,4,2)"), Variables={ "Climb", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Swim\")>=10,4,2)"), Variables={ "Swim", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Augment Summoning", Category="FEAT", Description={ Format="Your summoned creatures are more powerful and robust than most.", }, SourcePage="p.118", Benefits={ { FormatString="Each creature you conjure with any summon spell gains a +4 enhancement bonus to Strength and Constitution for the duration of the spell that summoned it.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Spell Focus (Conjuration)" then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Bleeding Critical", Category="FEAT", Description={ Format="Your critical hits cause opponents to bleed profusely.", }, SourcePage="p.118", Benefits={ { FormatString="Whenever you score a critical hit with a slashing or piercing weapon, your opponent takes 2d6 points of bleed damage (see Appendix 2) each round on his turn, in addition to the damage dealt by the critical hit. Bleed damage can be stopped by a DC 15 Heal skill check or through any magical healing. The effects of this feat stack.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 11 or (character.Variables["CriticalFocusQualify"] >= 11) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Blind-Fight", Category="FEAT", Description={ Format="You are skillled at attacking opponents that you cannot clearly perceive.", }, SourcePage="p.118", Benefits={ { FormatString="In melee, every time you miss because of concealment (see Chapter 8), you can reroll your miss chance percentile roll one time to see if you actually hit. An invisible attacker gets no advantages related to hitting you in melee. That is, you don't lose your Dexterity bonus to Armor Class, and the attacker doesn't get the usual +2 bonus for being invisible. The invisible attacker's bonuses do still apply for ranged attacks, however. You do not need to make Acrobatics skill checks to move at full speed while blinded.", }, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Blinding Critical", Category="FEAT", Description={ Format="Your critical hits blind your opponents.", }, SourcePage="p.119", Benefits={ { FormatString="Whenever you score a critical hit, your opponent is permanently blinded. A successful Fortitude save reduces this to dazzled for 1d4 rounds. The DC of this Fortitude save is equal to %1. This feat has no effect on creatures that do not rely on eyes for sight or creatures with more than two eyes (although multiple critical hits might cause blindness, at the GM's discretion). Blindness can be cured by heal, regeneration, remove blindness, or similar abilities.", Arguments={ "10+BAB", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 15 or (character.Variables["CriticalFocusQualify"] >= 15) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Brew Potion", Category="FEAT", Description={ Format="You can create magic potions.", }, SourcePage="p.119", Benefits={ { FormatString="You can create a potion of any 3rd-level or lower spell that you know and that targets one or more creatures or objects. Brewing a potion takes 2 hours if its base price is 250 gp or less, otherwise brewing a potion takes 1 day for each 1,000 gp in its base price. When you create a potion, you set the caster level, which must be sufficient to cast the spell in question and no higher than your own level. To brew a potion, you must use up raw materials costing one half this base price. See the magic item creation rules in Chapter 15 for more information. When you create a potion, you make any choices that you would normally make when casting the spell. Whoever drinks the potion is the target of the spell.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(3))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 3) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Catch Off-Guard", Category="FEAT", Description={ Format="Foes are surprised by your skilled use of unorthodox and improvised weapons.", }, SourcePage="p.119", AutomaticProficiencies={ { Kind="Weapon", Types={ "Improvised", }, }, }, Benefits={ { FormatString="You do not suffer any penalties for using an improvised melee weapon. Unarmed opponents are flat-footed against any attacks you make with an improvised melee weapon.", }, }, Types={ "Combat", }, }) DefineAbility({ Name="Channel Smite", Category="FEAT", Description={ Format="You can channel your divine energy through your weapon.", }, SourcePage="p.119", Benefits={ { FormatString="Before you make a melee attack roll, you can choose to spend one use of your channel energy ability as a swift action. If you channel positive energy and you hit an undead creature, that creature takes an amount of additional damage equal to the damage dealt by your channel positive energy ability. If you channel negative energy and you hit a living creature, that creature takes an amount of additional damage equal to the damage dealt by your channel negative energy ability. Your target can make a Will save, as normal, to halve this additional damage. If your attack misses, the channel energy ability is still expended with no effect.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Energy") then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Cleave", Category="FEAT", Description={ Format="You can strike two adjacent foes with a single swing.", }, SourcePage="p.119", Benefits={ { FormatString="As a standard action, you can make a single attack at your full base attack bonus against a foe within reach. If you hit, you deal damage normally and can make an additional attack (using your full base attack bonus) against a foe that is adjacent to the first and also within reach. You can only make one additional attack per round with this feat. When you use this feat, you take a -2 penalty to your Armor Class until your next turn.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Combat Casting", Category="FEAT", Description={ Format="You are adept at spellcasting when threatened or distracted.", }, SourcePage="p.119", Benefits={ { FormatString="You get a +4 bonus on concentration checks made to cast a spell or use a spell-like ability when casting on the defensive or while grappled.", }, }, Types={ "General", }, }) DefineAbility({ Name="Combat Expertise", Category="FEAT", Description={ Format="You can increase your defense at the expense of your accuracy.", }, SourcePage="p.119", TemporaryBonus={ Bonus={ Category="VAR", Formula=Formula("CombatExpertiseModifierAC"), Type={ Name="Base", }, Variables={ "CMD", }, }, Target="PC", }, Benefits={ { FormatString="You can choose to take a %1 penalty on melee attack rolls and combat maneuver checks to gain a +%2 dodge bonus to your Armor Class. You can only choose to use this feat when you declare that you are making an attack or a full-attack action with a melee weapon. The effects of this feat last until your next turn.", Arguments={ "CombatExpertiseModifierAttack", "CombatExpertiseModifierAC", }, }, }, Bonuses={ { Category="VAR", Formula=Formula("((BAB+(FlurryLVL-MonkBAB))/4)+1"), Type={ Name="Base", }, Variables={ "CombatExpertiseModifier", }, }, { Category="VAR", Formula=Formula("-CombatExpertiseModifier"), Type={ Name="Base", }, Variables={ "CombatExpertiseModifierAttack", }, }, { Category="VAR", Formula=Formula("CombatExpertiseModifier"), Type={ Name="Base", }, Variables={ "CombatExpertiseModifierAC", }, }, }, Conditions={ function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, }, Types={ "Combat", "AttackOption", "ModifyAC", }, }) DefineAbility({ Name="Combat Expertise", Category="FEAT", Description={ Format="You can increase your defense at the expense of your accuracy.", }, SourcePage="p.119", TemporaryBonus={ Bonus={ Category="VAR", Formula=Formula("CombatExpertiseModifierAC"), Variables={ "CMD", }, }, Target="PC", }, Benefits={ { FormatString="You can choose to take a %1 penalty on melee attack rolls and combat maneuver checks to gain a +%2 dodge bonus to your Armor Class. You can only choose to use this feat when you declare that you are making an attack or a full-attack action with a melee weapon. The effects of this feat last until your next turn.", Arguments={ "CombatExpertiseModifierAttack", "CombatExpertiseModifierAC", }, }, }, Bonuses={ { Category="VAR", Formula=Formula("floor(BAB/4)+1"), Variables={ "CombatExpertiseModifier", }, }, { Category="VAR", Formula=Formula("-CombatExpertiseModifier"), Variables={ "CombatExpertiseModifierAttack", }, }, { Category="VAR", Formula=Formula("CombatExpertiseModifier"), Variables={ "CombatExpertiseModifierAC", }, }, }, Conditions={ function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) or (character.Variables["DirtyTricksterIntQualify"] >= 1) end, }, Types={ "Combat", "AttackOption", "ModifyAC", }, }) DefineAbility({ Name="Combat Reflexes", Category="FEAT", Description={ Format="You can make additional attacks of opportunity.", }, SourcePage="p.119", Benefits={ { FormatString="You may make %1 additional attacks of opportunity per round. With this feat, you may also make attacks of opportunity while flat-footed.", Arguments={ "CombatReflexesAttacks", }, }, }, Bonuses={ { Category="VAR", Formula=Formula("DEX"), Variables={ "CombatReflexesAttacks", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Command Undead", Category="FEAT", Description={ Format="Using foul powers of necromancy, you can command undead creatures, making them into your servants.", }, SourcePage="p.120", Benefits={ { FormatString="As a standard action, you can use one of your uses of channel negative energy to enslave undead within 30 feet. Undead receive a Will save %1 to negate the effect. Undead that fail their saves fall under your control, obeying your commands to the best of their ability, as if under the effects of control undead. Intelligent undead receive a new saving throw each day to resist your command. You can control up to your effective cleric level in Hit Dice of undead. If you use channel energy in this way, it has no other effect (it does not heal or harm nearby creatures). If an undead creature is under the control of another creature, you must make an opposed Charisma check whenever your orders conflict.", Arguments={ "ClericChannelNegativeEnergyDC", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Negative Energy") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Craft Magic Arms and Armor", Category="FEAT", Description={ Format="You can create magic armor, shields, or weapons.", }, SourcePage="p.120", Benefits={ { FormatString="You can create magic weapons, armor, or shields. Enhancing a weapon, suit of armor, or shield takes 1 day for each 1,000 gp in the price of its magical features. To enhance a weapon, suit of armor, or shield, you must use up raw materials costing half of this total price. See the magic item creation rules in Chapter 15 for more information. The weapon, armor, or shield to be enhanced must be a masterwork item that you provide. Its cost is not included in the above cost. You can also mend a broken magic weapon, suit of armor, or shield if it is one that you could make. Doing so costs half the raw materials and half the time it would take to craft that item in the first place.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(5))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 5) or (character.Variables["MasterCraftsmanRanks"] >= 5) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Craft Rod", Category="FEAT", Description={ Format="You can create magic rods.", }, SourcePage="p.120", Benefits={ { FormatString="You can create magic rods. Crafting a rod takes 1 day for each 1,000 gp in its base price. To craft a rod, you must use up raw materials costing half of its base price. See the magic", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(9))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 9) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Craft Staff", Category="FEAT", Description={ Format="You can create magic staves.", }, SourcePage="p.120", Benefits={ { FormatString="You can create any staff whose prerequisites you meet. Crafting a staff takes 1 day for each 1,000 gp in its base price. To craft a staff, you must use up raw materials costing half of its base price. A newly created staff has 10 charges. See the magic item creation rules in Chapter 15 for more information.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(11))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 11) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Craft Wand", Category="FEAT", Description={ Format="You can create magic wands.", }, SourcePage="p.120", Benefits={ { FormatString="You can create a wand of any 4th-level or lower spell that you know. Crafting a wand takes 1 day for each 1,000 gp in its base price. To craft a wand, you must use up raw materials costing half of this base price. A newly created wand has 50 charges. See the magic item creation rules in Chapter 15 for more information.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(5))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 5) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Craft Wondrous Item", Category="FEAT", Description={ Format="You can create wondrous items, a type of magic item.", }, SourcePage="p.120", Benefits={ { FormatString="You can create a wide variety of magic wondrous items. Crafting a wondrous item takes 1 day for each 1,000 gp in its price. To create a wondrous item, you must use up raw materials costing half of its base price. See the magic item creation rules in Chapter 15 for more information. You can also mend a broken wondrous item if it is one that you could make. Doing so costs half the raw materials and half the time it would take to craft that item.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(3))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 3) or (character.Variables["MasterCraftsmanRanks"] >= 3) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Critical Focus", Category="FEAT", Description={ Format="You are trained in the arts of causing pain.", }, SourcePage="p.120", Benefits={ { FormatString="You receive a +4 circumstance bonus on attack rolls made to confirm critical hits.", }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 9 or (character.Variables["CriticalFocusQualify"] >= 9) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Critical Mastery", Category="FEAT", Description={ Format="Your critical hits cause two additional effects.", }, SourcePage="p.120", Benefits={ { FormatString="When you score a critical hit, you can apply the effects of two critical feats in addition to the damage dealt.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end return false end) end, function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.IsAnyType("Critical") then return true end return false end) end, function (character, item, sources) return (character.Variables["CriticalMasteryQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Dazzling Display", Category="FEAT", Description={ Format="Your skill with your favored weapon can frighten enemies.", }, SourcePage="p.120", Benefits={ { FormatString="While wielding the weapon in which you have Weapon Focus, you can perform a bewildering show of prowess as a full-round action. Make an Intimidate check to demoralize all foes within 30 feet who can see your display.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Weapon Focus" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Deadly Aim", Category="FEAT", Description={ Format="You can make exceptionally deadly ranged attacks by pinpointing a foe's weak spot, at the expense of making the attack less likely to succeed.", }, SourcePage="p.121", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("-DeadlyAimModifier"), Type={ Name="Temporary", }, Variables={ "TOHIT", }, }, Target="EQ|Weapon,Ranged", }, Benefits={ { FormatString="You can choose to take a -%1 penalty on all ranged attack rolls to gain a +%2 bonus on all ranged damage rolls. You must choose to use this feat before making an attack roll and its effects last until your next turn. The bonus damage does not apply to touch attacks or effects that do not deal hit point damage.", Arguments={ "DeadlyAimModifier", "2*DeadlyAimModifier", }, }, }, Bonuses={ { Category="VAR", Formula=Formula("floor(BAB/4)+1"), Variables={ "DeadlyAimModifier", }, }, }, Conditions={ function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Deadly Stroke", Category="FEAT", Description={ Format="With a well-placed strike, you can bring a swift and painful end to most foes.", }, SourcePage="p.121", Benefits={ { FormatString="As a standard action, make a single attack with the weapon for which you have Greater Weapon Focus against a stunned or flat-footed opponent. If you hit, you deal double the normal damage and the target takes 1 point of Constitution bleed (see Appendix 2). The additional damage and bleed is not multiplied on a critical hit.", }, }, Conditions={ function (character, item, sources) return 4 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Dazzling Display" then return true end if ability.Name == "Greater Weapon Focus" then return true end if ability.Name == "Shatter Defenses" then return true end if ability.Name == "Weapon Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Deafening Critical", Category="FEAT", Description={ Format="Your critical hits cause enemies to lose their hearing.", }, SourcePage="p.121", Benefits={ { FormatString="Whenever you score a critical hit against an opponent, the victim is permanently deafened. A successful Fortitude save reduces the deafness to 1 round. The DC of this Fortitude save is equal to 10 + your base attack bonus. This feat has no effect on deaf creatures. This deafness can be cured by heal, regeneration, remove deafness, or a similar ability.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 13 or (character.Variables["CriticalFocusQualify"] >= 13) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Deceitful", Category="FEAT", Description={ Format="You are skilled at deceiving others, both with the spoken word ans with physical disguises.", }, SourcePage="p.121", Benefits={ { FormatString="You get a +2 bonus on all Bluff and Disguise skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Bluff\")>=10,4,2)"), Variables={ "Bluff", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Disguise\")>=10,4,2)"), Variables={ "Disguise", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Defensive Combat Training", Category="FEAT", Description={ Format="You excel at defending yourself from all manner of combat maneuvers.", }, SourcePage="p.121", Benefits={ { FormatString="You treat your total Hit Dice as your base attack bonus when calculating your Combat Maneuver Defense (see Chapter 8).", }, }, Bonuses={ { Category="VAR", Formula=Formula("TL-BAB"), Variables={ "CMD_BAB", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Deflect Arrows", Category="FEAT", Description={ Format="You can know arrows and other projectiles off course, preventing them from hitting you.", }, SourcePage="p.121", Benefits={ { FormatString="You must have at least one hand free (holding nothing) to use this feat. Once per round when you would normally be hit with an attack from a ranged weapon, you may deflect it so that you take no damage from it. You must be aware of the attack and not flat-footed. Attempting to deflect a ranged attack doesn't count as an action. Unusually massive ranged weapons (such as boulders or ballista bolts) and ranged attacks generated by natural attacks or spell effects can't be deflected.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Unarmed Strike" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Deft Hands", Category="FEAT", Description={ Format="You have exceptional manual dexterity.", }, SourcePage="p.121", Benefits={ { FormatString="You get a +2 bonus on Disable Device and Sleight of Hand skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Disable Device\")>=10,4,2)"), Variables={ "Disable Device", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Sleight of Hand\")>=10,4,2)"), Variables={ "Sleight of Hand", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Diehard", Category="FEAT", Description={ Format="You are especially hard to kill. Not only do your wounds automatically stabilize when grievously injured, but you can remain conscious and continue to act even at death's door.", }, SourcePage="p.122", Benefits={ { FormatString="When your hit point total is below 0, but you are not dead, you automatically stabilize. You do not need to make a Constitution check each round to avoid losing additional hit points. You may choose to act as if you were disabled, rather than dying. You must make this decision as soon as you are reduced to negative hit points (even if it isn't your turn). If you do not choose to act as if you were disabled, you immediately fall unconscious. When using this feat, you are staggered. You can take a move action without further injuring yourself, but if you perform any standard action (or any other action deemed as strenuous, including some free actions, such as casting a quickened spell) you take 1 point of damage after completing the act. If your negative hit points are equal to or greater than your Constitution score, you immediately die.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Endurance" then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Disruptive", Category="FEAT", Description={ Format="Your training makes it difficult for enemy spellcasters to safely cast spells near you.", }, SourcePage="p.122", Benefits={ { FormatString="The DC to cast spells defensively increases by +4 for all enemies that are within your threatened area. This increase to casting spells defensively only applies if you are aware of the enemy's location and are capable of taking an attack of opportunity. If you can only take one attack of opportunity per round and have already used that attack, this increase does not apply.", }, }, Conditions={ function (character, item, sources) return (character.Variables["DisruptiveQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Dodge", Category="FEAT", Description={ Format="Your training and reflexes allow you to react swiftly to avoid an opponent's attack.", }, SourcePage="p.122", Benefits={ { FormatString="You gain a +1 dodge bonus to your AC. A condition that makes you lose your Dex bonus to AC also makes you lose the benefits of this feat.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("1"), Type={ Name="Dodge", }, Variables={ "AC", }, }, }, Conditions={ function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Double Slice", Category="FEAT", Description={ Format="Your off-hand weapon while dual-wielding strikes with greater power.", }, SourcePage="p.122", Benefits={ { FormatString="Add your Strength bonus to damage rolls made with your off-hand weapon.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("1"), Variables={ "DAMAGEMULT:0", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Two-Weapon Fighting" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 15) or (character.Variables["FeatDexRequirement"] >= 15) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Elemental Channel", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseString({"Air", "Earth", "Fire", "Water"}), }, Description={ Format="You can channel your divine energy to harm or heal outsiders that possess your chosen elemental subtype.", }, SourcePage="p.122", Stackable=false, Benefits={ { FormatString="Instead of its normal effect, you can choose to have your ability to channel energy heal or harm outsiders of your chosen elemental subtype. You must make this choice each time you channel energy. If you choose to heal or harm creatures of your elemental subtype, your channel energy has no affect on other creatures. The amount of damage healed or dealt and the DC to halve the damage is otherwise unchanged.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Energy") then return true end return false end) end, }, Types={ "General", "AttackOption", }, }) DefineAbility({ Name="Empower Spell", Category="FEAT", AddedSpellLevels=2, Description={ Format="You can increase the power of your spells, causing them to deal more damage.", }, SourcePage="p.122", Benefits={ { FormatString="All variable, numeric effects of an empowered spell are increased by half including bonuses to those dice rolls. Saving throws and opposed rolls are not affected, nor are spells without random variables. An empowered spell uses up a spell slot two levels higher than the spell's actual level.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Empowered", }, }) DefineAbility({ Name="Endurance", Category="FEAT", Description={ Format="Harsh conditions or long exertions do not easily tire you.", }, SourcePage="p.112", Aspects={ { Name="SkillBonus", FormatString="+%1 bonus on Swim checks made to resist nonlethal damage from exhaustion; Constitution checks made to continue running, to avoid nonlethal damage from a forced march, to hold your breath, and to avoid nonlethal damage from starvation or thirst; Fortitude saves made to avoid nonlethal damage from hot or cold environments and to resist damage from suffocation.", Arguments={ "Feat_Endurance_SaveBonus", }, }, }, Benefits={ { FormatString="You gain a +%1 bonus on the following checks and saves: Swim checks made to resist nonlethal damage from exhaustion; Constitution checks made to continue running; Constitution checks made to avoid nonlethal damage from a forced march; Constitution checks made to hold your breath; Constitution checks made to avoid nonlethal damage from starvation or thirst; Fortitude saves made to avoid nonlethal damage from hot or cold environments; and Fortitude saves made to resist damage from suffocation. You may sleep in light or medium armor without becoming fatigued.", Arguments={ "Feat_Endurance_SaveBonus", }, }, }, Bonuses={ { Category="VAR", Formula=Formula("4"), Type={ Name="Base", }, Variables={ "Feat_Endurance_SaveBonus", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Enlarge Spell", Category="FEAT", AddedSpellLevels=1, Description={ Format="You can increase the range of your spells.", }, SourcePage="p.122", Benefits={ { FormatString="You can alter a spell with a range of close, medium, or long to increase its range by 100%%. An enlarged spell uses up a spell slot one level higher than the spell's actual level. Spells whose ranges are not defined by distance, as well as spells whose ranges are not close, medium, or long, do not benefit from this feat.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Enlarged", }, }) DefineAbility({ Name="Eschew Materials", Category="FEAT", Description={ Format="You can cast many spells without needing to utilize minor material components.", }, SourcePage="p.123", Benefits={ { FormatString="You can cast any spell with a material component costing 1 gp or less without needing that component. The casting of the spell still provokes attacks of opportunity as normal. If the spell requires a material component that costs more than 1 gp, you must have the material component on hand to cast the spell, as normal.", }, }, Types={ "General", }, }) DefineAbility({ Name="Exhausting Critical", Category="FEAT", Description={ Format="Your critical hits cause opponents to become exhausted.", }, SourcePage="p.123", Benefits={ { FormatString="When you score a critical hit on a foe, your target immediately becomes exhausted. This feat has no effect on exhausted creatures.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end if ability.Name == "Tiring Critical" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 15 or (character.Variables["CriticalFocusQualify"] >= 15) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Exotic Weapon Proficiency", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return ((true and (((weapon.IsType("Exotic")))))) end), }, Description={ Format="You understand how to use your chosen exotic weapon in combat, and can utilize any special tricks or qualities that exotic weapon might allow.", }, SourcePage="p.123", AutomaticProficiencies={ { Kind="Weapon", Names={ "%LIST", }, }, }, Benefits={ { FormatString="You make attack rolls with the weapon normally.", }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 1 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Extend Spell", Category="FEAT", AddedSpellLevels=1, Description={ Format="You can make your spells last twice as long.", }, SourcePage="p.123", Benefits={ { FormatString="An extended spell lasts twice as long as normal. A spell with a duration of concentration, instantaneous, or permanent is not affected by this feat. An extended spell uses up a spell slot one level higher than the spell's actual level.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Extended", }, }) DefineAbility({ Name="Extra Channel", Category="FEAT", Description={ Format="You can channel divine energy more often.", }, SourcePage="p.123", Benefits={ { FormatString="You can channel energy two additional times per day.", }, }, Bonuses={ { Category="ABILITYPOOL", Formula=Formula("1"), Variables={ "Extra Channel", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Positive Energy", "Channel Negative Energy") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Extra Ki", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseNothing(), }, Description={ Format="You can use your ki pool more times per day than most.", }, SourcePage="p.124", Stackable=true, Benefits={ { FormatString="Your ki pool increases by 2.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "KiPoints", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Ki Pool") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Extra Lay On Hands", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseNothing(), }, Description={ Format="You can use your lay on hands ability more often.", }, SourcePage="p.124", Stackable=true, Benefits={ { FormatString="You can use your lay on hands ability two additional times per day.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "LayOnHandsTimes", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Lay on Hands") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Extra Mercy", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseNothing(), }, Description={ Format="Your lay on hands ability adds an additional mercy.", }, SourcePage="p.124", Stackable=true, Benefits={ { FormatString="Select one additional mercy for which you qualify. When you use lay on hands to heal damage to one target, it also receives the additional effects of this mercy.", }, }, Bonuses={ { Category="ABILITYPOOL", Formula=Formula("1"), Variables={ "Mercy", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Lay on Hands", "Mercy") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Extra Performance", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseNothing(), }, Description={ Format="You can use your bardic performance ability more often than normal", }, SourcePage="p.124", Stackable=true, Benefits={ { FormatString="You can use bardic performance for 6 additional rounds per day.", }, }, Bonuses={ { Category="VAR", Formula=Formula("6"), Variables={ "BardicPerformanceDuration", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Bardic Performance") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Extra Rage", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseNothing(), }, Description={ Format="You can use your rage ability more than narmal.", }, SourcePage="p.124", Stackable=true, Benefits={ { FormatString="You can rage for 6 additional rounds per day.", }, }, Bonuses={ { Category="VAR", Formula=Formula("6"), Variables={ "RageDuration", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Rage") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Far Shot", Category="FEAT", Description={ Format="You are more accurate at longer ranges.", }, SourcePage="p.124", Abilities={ { Category="Internal", Nature="AUTOMATIC", Names={ "Tracker ~ Range Penalty", }, }, }, Benefits={ { FormatString="You only suffer a -1 penalty per full range increment between you and your target when using a ranged weapon.", }, }, Bonuses={ { Category="VAR", Formula=Formula("1"), Type={ Name="Base", }, Variables={ "RangePenaltyValue", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Point-Blank Shot" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Fleet", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseNothing(), }, Description={ Format="You are faster than most.", }, SourcePage="p.124", Stackable=true, Benefits={ { FormatString="While you are wearing light or no armor, your base speed increases by 5 feet. You lose the benefits of this feat if you carry a medium or heavy load.", }, }, Bonuses={ { Category="MOVEADD", Formula=Formula("5"), Conditions={ function (character, item, sources) return (character.Variables["ENCUMBERANCE"] < 1) and (character.Variables["var(\"COUNT[EQTYPE.ARMOR.EQUIPPED.IS.MEDIUM]\")"] < 1) and (character.Variables["var(\"COUNT[EQTYPE.ARMOR.EQUIPPED.IS.HEAVY]\")"] < 1) end, }, Variables={ "TYPE.Walk", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Forge Ring", Category="FEAT", Description={ Format="You can create magic rings.", }, SourcePage="p.124", Benefits={ { FormatString="You can create magic rings. Crafting a ring takes 1 day for each 1,000 gp in its base price. To craft a ring, you must use up raw materials costing half of the base price. See the magic item creation rules in Chapter 15 for more information. You can also mend a broken ring if it is one that you could make. Doing so costs half the raw materials and half the time it would take to forge that ring in the first place.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(7))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 7) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Gorgon's Fist", Category="FEAT", Description={ Format="With one well-placed blow, you leave your target reeling.", }, SourcePage="p.124", Benefits={ { FormatString="As a standard action, make a single unarmed melee attack against a foe whose speed is reduced (such as from Scorpion Style). If the attack hits, you deal damage normally and the target is staggered until the end of your next turn unless it makes a Fortitude saving throw (DC 10 + 1/2 your character level + your Wis modifier). This feat has no effect on targets that are staggered.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Unarmed Strike" then return true end if ability.Name == "Scorpion Style" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Great Cleave", Category="FEAT", Description={ Format="You can strike many adjacent foes with a single blow.", }, SourcePage="p.124", Benefits={ { FormatString="As a standard action, you can make a single attack at your full base attack bonus against a foe within reach. If you hit, you deal damage normally and can make an additional attack (using your full base attack bonus) against a foe that is adjacent to the previous foe and also within reach. If you hit, you can continue to make attacks against foes adjacent to the previous foe, so long as they are within your reach. You cannot attack an individual foe more than once during this attack action. When you use this feat, you take a -2 penalty to your Armor Class until your next turn.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Cleave" then return true end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 4 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Great Fortitude", Category="FEAT", Description={ Format="You are resistant to poisons, diseases, and other deadly maladies.", }, SourcePage="p.124", Benefits={ { FormatString="You get a +2 bonus on all Fortitude saving throws.", }, }, Bonuses={ { Category="SAVE", Formula=Formula("2"), Variables={ "Fortitude", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Greater Bull Rush", Category="FEAT", Description={ Format="Your bull rush attacks throw enemies off balance.", }, SourcePage="p.125", Benefits={ { FormatString="You receive a +2 bonus on checks made to bull rush a foe. This bonus stacks with the bonus granted by Improved Bull Rush. Whenever you bull rush an opponent, his movement provokes attacks of opportunity from all of your allies (but not you).", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_BullRush", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Bull Rush" then return true end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Disarm", Category="FEAT", Description={ Format="You can knock weapons far from an enemy's grasp.", }, SourcePage="p.125", Benefits={ { FormatString="You receive a +2 bonus on checks made to disarm a foe. This bonus stacks with the bonus granted by Improved Disarm. Whenever you successfully disarm an opponent, the weapon lands 15 feet away from its previous wielder, in a random direction.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Disarm", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Expertise" then return true end if ability.Name == "Improved Disarm" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Feint", Category="FEAT", Description={ Format="You are skilled at making foes overreact to your attacks.", }, SourcePage="p.125", Benefits={ { FormatString="Whenever you use feint to cause an opponent to lose his Dexterity bonus, he loses that bonus until the beginning of your next turn, in addition to losing his Dexterity bonus against your next attack.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Expertise" then return true end if ability.Name == "Improved Feint" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Grapple", Category="FEAT", Description={ Format="Maintaining a grapple is second nature to you.", }, SourcePage="p.125", Benefits={ { FormatString="You receive a +2 bonus on checks made to grapple a foe. This bonus stacks with the bonus granted by Improved Grapple. Once you have grappled a creature, maintaining the grapple is a move action. This feat allows you to make two grapple checks each round (to move, harm, or pin your opponent), but you are not required to make two checks. You only need to succeed at one of these checks to maintain the grapple.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Grapple", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Grapple" then return true end if ability.Name == "Improved Unarmed Strike" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Overrun", Category="FEAT", Description={ Format="Enemies must dive to avoid your dangerous move.", }, SourcePage="p.125", Benefits={ { FormatString="You receive a +2 bonus on checks made to overrun a foe. This bonus stacks with the bonus granted by Improved Overrun. Whenever you overrun opponents, they provoke attacks of opportunity if they are knocked prone by your overrun.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Overrun", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Overrun" then return true end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Penetrating Strike", Category="FEAT", Description={ Format="Your attacks with your chosen weapon penetrate the defenses of most creatures.", }, SourcePage="p.125", Benefits={ { FormatString="Your attacks made with weapons selected with Weapon Focus ignore up to 10 points of damage reduction. This amount is reduced to 5 points for damage reduction without a type (such as DR 10/-).", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Penetrating Strike" then return true end if ability.Name == "Weapon Focus" then return true end return false end) end, function (character, item, sources) return (character.Variables["GreatPenetratingStrikeQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Shield Focus", Category="FEAT", Description={ Format="You are skilled at deflecting blows with your shield.", }, SourcePage="p.125", Benefits={ { FormatString="Increase the AC bonus granted by any shield you are using by 1. This bonus stacks with the bonus granted by Shield Focus.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("1"), Type={ Name="Shield", Stack=true, }, Conditions={ function (character, item, sources) return (character.HasEquipped(function (item) return item.IsType("Shield") end)) end, }, Variables={ "AC", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Shield Focus" then return true end return false end) end, function (character, item, sources) return (character.IsProficientWithShieldType("Buckler")) and (character.IsProficientWithShieldType("Light")) and (character.IsProficientWithShieldType("Heavy")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Shield Proficiency" then return true end return false end) end, function (character, item, sources) return (character.Variables["GreatShieldFocusQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Spell Focus", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseSchool(function (character, school) return (((stringMatch(school.Name, "ABILITY=FEAT") or stringMatch(school.Key, "ABILITY=FEAT")) and ((((stringMatch(school.Name, "Spell Focus") or stringMatch(school.Key, "Spell Focus"))))))) end), }, Description={ Format="Any spells you cast from your chosen school of magic are very hard to resist.", }, SourcePage="p.125", Stackable=false, Benefits={ { FormatString="Add +1 to the Difficulty Class for all saving throws against spells from the school of magic you select. This bonus stacks with the bonus from Spell Focus.", }, }, Bonuses={ { Category="DC", Formula=Formula("2"), Type={ Name="SpellFocus", }, Variables={ "SCHOOL.%LIST", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Spell Focus" then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Greater Spell Penetration", Category="FEAT", Description={ Format="Your spells break through spell resistance much more easily than most.", }, SourcePage="p.125", Benefits={ { FormatString="You get a +2 bonus on caster level checks (1d20 + caster level) made to overcome a creature's spell resistance. This bonus stacks with the one from Spell Penetration.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Spell Penetration" then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Greater Sunder", Category="FEAT", Description={ Format="Your devastating strikes cleave through weapons and into their wielders, damaging both item and wielder alike in a single terrific strike.", }, SourcePage="p.125", Benefits={ { FormatString="You receive a +2 bonus on checks made to sunder an item. This bonus stacks with the bonus granted by Improved Sunder. Whenever you sunder to destroy a weapon, shield, or suit of armor, any excess damage is applied to the item's wielder. No damage is transferred if you decide to leave the item with 1 hit point.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Sunder", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Sunder" then return true end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Trip", Category="FEAT", Description={ Format="You can make free attacks on foes that you knock down.", }, SourcePage="p.126", Benefits={ { FormatString="You receive a +2 bonus on checks made to trip a foe. This bonus stacks with the bonus granted by Improved Trip. Whenever you successfully trip an opponent, that opponent provokes attacks of opportunity.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Trip", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Expertise" then return true end if ability.Name == "Improved Trip" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Two-Weapon Fighting", Category="FEAT", Description={ Format="You are incredibly skilled at fighting with two weapons at the same time.", }, SourcePage="p.126", Benefits={ { FormatString="You get a third attack with your off-hand weapon, albeit at a -10 penalty.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("1"), Variables={ "SECONDARYATTACKS", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Two-Weapon Fighting" then return true end if ability.Name == "Two-Weapon Fighting" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 19) or (character.Variables["FeatDexRequirement"] >= 19) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Vital Strike", Category="FEAT", Description={ Format="You can make a single attack that deals a tremendous amount of damage.", }, SourcePage="p.126", Benefits={ { FormatString="When you use the attack action, you can make one attack at your highest base attack bonus that deals additional damage. Roll the weapon's damage dice for the attack four times and add the results together before adding bonuses from Strength, weapon abilities (such as flaming), precision-based damage, and other damage bonuses. These extra damage dice are not multiplied on a critical hit, but are added to the total.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Vital Strike" then return true end if ability.Name == "Vital Strike" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 16 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Weapon Focus", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return (((stringMatch(weapon.Name, "ABILITY=FEAT") or stringMatch(weapon.Key, "ABILITY=FEAT")) and ((((stringMatch(weapon.Name, "Weapon Focus") or stringMatch(weapon.Key, "Weapon Focus"))))))) end), }, Description={ Format="You are a master at your chosen weapon.", }, SourcePage="p.126", Stackable=false, Benefits={ { FormatString="You gain a +1 bonus on attack rolls you make using the selected weapon. This bonus stacks with other bonuses on attack rolls, including those from Weapon Focus.", }, }, Bonuses={ { Category="WEAPONPROF=%LIST", Formula=Formula("GreaterWeaponFocusToHit"), Variables={ "TOHIT", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Weapon Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["GreatWeapFocusQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Greater Weapon Specialization", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return (((stringMatch(weapon.Name, "ABILITY=FEAT") or stringMatch(weapon.Key, "ABILITY=FEAT")) and ((((stringMatch(weapon.Name, "Weapon Specialization") or stringMatch(weapon.Key, "Weapon Specialization"))))))) end), }, Description={ Format="You deal extra damage when using your chosen weapon.", }, SourcePage="p.126", Stackable=false, Benefits={ { FormatString="You gain a +2 bonus on all damage rolls you make using the selected weapon. This bonus to damage stacks with other damage roll bonuses, including any you gain from Weapon Specialization.", }, }, Bonuses={ { Category="WEAPONPROF=%LIST", Formula=Formula("2"), Variables={ "DAMAGE", }, }, }, Conditions={ function (character, item, sources) return 3 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Greater Weapon Focus" then return true end if ability.Name == "Weapon Focus" then return true end if ability.Name == "Weapon Specialization" then return true end return false end) end, function (character, item, sources) return (character.Variables["GreatWeapSpecQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Heighten Spell", Category="FEAT", AddedSpellLevels=1, Description={ Format="You can cast spells as if they were a higher level.", }, SourcePage="p.126", Abilities={ { Category="FEAT", Nature="AUTOMATIC", Types={ "Heighten Spell", }, }, }, Benefits={ { FormatString="A heightened spell has a higher spell level than normal (up to a maximum of 9th level). Unlike other metamagic feats, Heighten Spell actually increases the effective level of the spell that it modifies. All effects dependent on spell level (such as saving throw DCs and ability to penetrate a lesser globe of invulnerability) are calculated according to the heightened level. The heightened spell is as difficult to prepare and cast as a spell of its effective level.", }, }, Bonuses={ { Category="DC", Formula=Formula("1"), Variables={ "FEATBONUS", }, }, }, Types={ "Metamagic", }, Facts={ AppliedName="Heightened +1", }, }) DefineAbility({ Name="Improved Bull Rush", Category="FEAT", Description={ Format="You are skilled at pushing your foes around.", }, SourcePage="p.126", Benefits={ { FormatString="You do not provoke an attack of opportunity when performing a bull rush combat maneuver. In addition, you receive a +2 bonus on checks made to bull rush a foe. You also receive a +2 bonus to your Combat Maneuver Defense whenever an opponent tries to bull rush you.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_BullRush", "CMD_BullRush", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Channel", Category="FEAT", Description={ Format="Your channeled energy is harder to resist.", }, SourcePage="p.126", Benefits={ { FormatString="Add 2 to the DC of saving throws made to resist the effects of your channel energy ability.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "ClericChannelPositiveEnergyDC", }, }, { Category="VAR", Formula=Formula("2"), Variables={ "PaladinChannelPositiveEnergyDC", }, }, { Category="VAR", Formula=Formula("2"), Variables={ "ClericChannelNegativeEnergyDC", }, }, { Category="VAR", Formula=Formula("2"), Variables={ "PowerOverUndeadCommandDC", }, }, { Category="VAR", Formula=Formula("2"), Variables={ "PowerOverUndeadTurnDC", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Positive Energy", "Channel Negative Energy") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Improved Counterspell", Category="FEAT", Description={ Format="You are skilled at countering the spells of others using similar spells.", }, SourcePage="p.126", Benefits={ { FormatString="When counterspelling, you may use a spell of the same school that is one or more spell levels higher than the target spell.", }, }, Types={ "General", }, }) DefineAbility({ Name="Improved Critical", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return ((character.IsProficientWith(weapon))) end), }, Description={ Format="Attacks made with your chosen weapon are quite deadly.", }, SourcePage="p.127", Benefits={ { FormatString="When using the weapon you selected, your threat range is doubled.", }, }, Bonuses={ { Category="WEAPONPROF=%LIST", Formula=Formula("1"), Type={ Name="NonStackingCrit", }, Variables={ "CRITRANGEDOUBLE", }, }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 8 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Improved Disarm", Category="FEAT", Description={ Format="You are skilled at knocking weapons from a foe's grasp.", }, SourcePage="p.127", Benefits={ { FormatString="You do not provoke an attack of opportunity when performing a disarm combat maneuver. In addition, you receive a +2 bonus on checks made to disarm a foe. You also receive a +2 bonus to your Combat Maneuver Defense whenever an opponent tries to disarm you.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Disarm", "CMD_Disarm", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Expertise" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Familiar", Category="FEAT", Description={ Format="This feat allows you to acquire a powerful familiar, but only when they could normally acquire a new familiar.", }, SourcePage="p.127", Abilities={ { Category="Internal", Nature="AUTOMATIC", Names={ "Improved Familiar List", }, }, }, Benefits={ { FormatString="When choosing a familiar, the creatures listed below are also available to you (see the Pathfinder RPG Bestiary for statistics on these creatures). You may choose a familiar with an alignment up to one step away on each alignment axis (lawful through chaotic, good through evil).", }, }, Types={ "General", }, }) DefineAbility({ Name="Improved Feint", Category="FEAT", Description={ Format="You are skilled at fooling your opponents in combat.", }, SourcePage="p.127", Benefits={ { FormatString="You can make a Bluff check to feint in combat as a move action.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Expertise" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Grapple", Category="FEAT", Description={ Format="You are skilled at grappling opponents.", }, SourcePage="p.127", Benefits={ { FormatString="You do not provoke an attack of opportunity when performing a grapple combat maneuver. In addition, you receive a +2 bonus on checks made to grapple a foe. You also receive a +2 bonus to your Combat Maneuver Defense whenever an opponent tries to grapple you.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Grapple", "CMD_Grapple", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Unarmed Strike" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Great Fortitude", Category="FEAT", Description={ Format="You can draw upon an inner reserve to resist diseases, poisons, and other grievous harm.", }, SourcePage="p.127", Benefits={ { FormatString="Once per day, you may reroll a Fortitude save. You must decide to use this ability before the results are revealed. You must take the second roll, even if it is worse.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Great Fortitude" then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Improved Initiative", Category="FEAT", Description={ Format="Your quick reflexes allow you to react quickly to danger.", }, SourcePage="p.127", Benefits={ { FormatString="You get a +4 bonus on initiative checks.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("4"), Variables={ "INITIATIVE", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Improved Iron Will", Category="FEAT", Description={ Format="Your clarity of thought allows you to resist mental attacks.", }, SourcePage="p.127", Benefits={ { FormatString="Once per day, you may reroll a Will save. You must decide to use this ability before the results are revealed. You must take the second roll, even if it is worse.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Iron Will" then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Improved Lightning Reflexes", Category="FEAT", Description={ Format="You have a knack for avoiding danger all around you.", }, SourcePage="p.127", Benefits={ { FormatString="Once per day, you may reroll a Reflex save. You must decide to use this ability before the results are revealed. You must take the second roll, even if it is worse.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Lightning Reflexes" then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Improved Overrun", Category="FEAT", Description={ Format="You are skilled at running down your foes.", }, SourcePage="p.127", Benefits={ { FormatString="You do not provoke an attack of opportunity when performing an overrun combat maneuver. In addition, you receive a +2 bonus on checks made to overrrun a foe. You also receive a +2 bonus to your Combat Maneuver Defense whenever an opponent tries to overrun you. Targets of your overrun attempt may not chose to avoid you.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Overrun", "CMD_Overrun", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Precise Shot", Category="FEAT", Description={ Format="Your ranged attacks ignore anything but total concealment and cover.", }, SourcePage="p.128", Benefits={ { FormatString="Your ranged attacks ignore the AC bonus granted to targets by anything less than total cover, and the miss chance granted to targets by anything less than total concealment. Total cover and total concealment provide their normal benefits against your ranged attacks.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Point-Blank Shot" then return true end if ability.Name == "Precise Shot" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 19) or (character.Variables["FeatDexRequirement"] >= 19) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Improved Shield Bash", Category="FEAT", Description={ Format="You can protect yourself with your shield, even if you use it to attack.", }, SourcePage="p.128", Benefits={ { FormatString="When you perform a shield bash, you may still apply the shield's shield bonus to your AC.", }, }, Conditions={ function (character, item, sources) return (character.IsProficientWithShieldType("Buckler")) and (character.IsProficientWithShieldType("Light")) and (character.IsProficientWithShieldType("Heavy")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Shield Proficiency" then return true end return false end) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Sunder", Category="FEAT", Description={ Format="You are skilled at damaging your foes' weapons and armor.", }, SourcePage="p.128", Benefits={ { FormatString="You do not provoke an attack of opportunity when performing a sunder combat maneuver. In addition, you receive a +2 bonus on checks made to sunder an item. You also receive a +2 bonus to your Combat Maneuver Defense whenever an opponent tries to sunder your gear.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Sunder", "CMD_Sunder", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Power Attack" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Trip", Category="FEAT", Description={ Format="You are skilled at sending your opponents to the ground.", }, SourcePage="p.128", Benefits={ { FormatString="You do not provoke an attack of opportunity when performing a trip combat maneuver. In addition, you receive a +2 bonus on checks made to trip a foe. You also receive a +2 bonus to your Combat Maneuver Defense whenever an opponent tries to trip you.", }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Variables={ "CMB_Trip", "CMD_Trip", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Expertise" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Improved Two-Weapon Fighting", Category="FEAT", Description={ Format="You are skilled at fighting with two weapons.", }, SourcePage="p.128", Benefits={ { FormatString="In addition to the standard single extra attack you get with an off-hand weapon, you get a second attack with it, albeit at a -5 penalty.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("1"), Variables={ "SECONDARYATTACKS", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Two-Weapon Fighting" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 17) or (character.Variables["FeatDexRequirement"] >= 17) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Improved Unarmed Strike", Category="FEAT", Description={ Format="You are skilled while fighting unarmed.", }, SourcePage="p.128", Benefits={ { FormatString="You are considered to be armed even when unarmed-you do not provoke attacks of opportunity when you attack foes while unarmed. Your unarmed strikes can deal lethal or nonlethal damage, at your choice.", }, }, Types={ "Combat", }, }) DefineAbility({ Name="Improved Vital Strike", Category="FEAT", Description={ Format="You can make a single attack that deals a large amount of damage.", }, SourcePage="p.128", Benefits={ { FormatString="When you use the attack action, you can make one attack at your highest base attack bonus that deals additional damage. Roll the weapon's damage dice for the attack three times and add the results together before adding bonuses from Strength, weapon abilities (such as flaming), precision-based damage, and other damage bonuses. These extra damage dice are not multiplied on a critical hit, but are added to the total.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Vital Strike" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Improvised Weapon Mastery", Category="FEAT", Description={ Format="You can turn nearly any object into a deadly weapon, from a razor sharp chair leg to a sack of flour.", }, SourcePage="p.128", Benefits={ { FormatString="You do not suffer any penalties for using an improvised weapon. Increase the amount of damage dealt by the improvised weapon by one step (for example, 1d4 becomes 1d6) to a maximum of 1d8 (2d6 if the improvised weapon is two-handed). The improvised weapon has a critical threat range of 19-20, with a critical multiplier of W2.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Catch Off-Guard" then return true end if ability.Name == "Throw Anything" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 8 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Intimidating Prowess", Category="FEAT", Description={ Format="Your physical might is intimidating to others.", }, SourcePage="p.128", Benefits={ { FormatString="Add your Strength modifier to Intimidate skill checks in addition to your Charisma modifier.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("STR"), Variables={ "Intimidate", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Iron Will", Category="FEAT", Description={ Format="You are more resistant to mental effects.", }, SourcePage="p.129", Benefits={ { FormatString="You get a +2 bonus on all Will saving throws.", }, }, Bonuses={ { Category="SAVE", Formula=Formula("2"), Variables={ "Will", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Leadership", Category="FEAT", Description={ Format="You attract followers to your cause and a companion to join you on your adventure.", }, SourcePage="p.129", Abilities={ { Category="FEAT", Nature="VIRTUAL", Names={ "Leadership Score", }, }, }, Benefits={ { FormatString="This feat enables you to attract a loyal cohort and a number of devoted subordinates who assist you. A cohort is generally an NPC with class levels, while followers are typically lower level NPCs. See Table 5-2 for what level of cohort and how many followers you can recruit.", }, }, Bonuses={ { Category="VAR", Formula=Formula("min((TL-2),(((LeadershipScore+6)*7)/10)-4)"), Variables={ "LeadershipMaxCohortLvl", }, }, { Category="VAR", Formula=Formula("(TL+LeadershipAbilityScoreMod)"), Variables={ "LeadershipScore", }, }, { Category="VAR", Formula=Formula("CHA"), Variables={ "LeadershipAbilityScoreMod", }, }, }, Conditions={ function (character, item, sources) return character.Level >= 7 end, }, Types={ "General", }, }) DefineAbility({ Name="Lightning Reflexes", Category="FEAT", Description={ Format="You have faster reflexes than normal.", }, SourcePage="p.130", Benefits={ { FormatString="You get a +2 bonus on all Reflex saving throws.", }, }, Bonuses={ { Category="SAVE", Formula=Formula("2"), Variables={ "Reflex", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Lightning Stance", Category="FEAT", Description={ Format="The speed at which you move makes it nearly impossible for opponents to strike you.", }, SourcePage="p.130", Benefits={ { FormatString="If you take two actions to move or a withdraw action in a turn, you gain 50%% concealment for 1 round.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Dodge" then return true end if ability.Name == "Wind Stance" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 17) or (character.Variables["FeatDexRequirement"] >= 17) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Lunge", Category="FEAT", Description={ Format="You can strike foes that would normally be out of reach.", }, SourcePage="p.130", Benefits={ { FormatString="You can increase the reach of your melee attacks by 5 feet until the end of your turn by taking a -2 penalty to your AC until your next turn. You must decide to use this ability before any attacks are made.", }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Magical Aptitude", Category="FEAT", Description={ Format="You are skilled at spellcasting and using magic items.", }, SourcePage="p.130", Benefits={ { FormatString="You get a +2 bonus on all Spellcraft checks and Use Magic Device checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Spellcraft\")>=10,4,2)"), Variables={ "Spellcraft", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Use Magic Device\")>=10,4,2)"), Variables={ "Use Magic Device", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Manyshot", Category="FEAT", Description={ Format="You can fire multiple arrows at a single target.", }, SourcePage="p.130", Benefits={ { FormatString="When making a full-attack action with a bow, your first attack fires two arrows. If the attack hits, both arrows hit. Apply precision-based damage (such as sneak attack) and critical hit damage only once for this attack. Damage bonuses from using a composite bow with a high Strength bonus apply to each arrow, as do other damage bonuses, such as a ranger's favored enemy bonus. Damage reduction and resistances apply separately to each arrow.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Point-Blank Shot" then return true end if ability.Name == "Rapid Shot" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 17) or (character.Variables["FeatDexRequirement"] >= 17) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Martial Weapon Proficiency", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return ((not (character.IsProficientWith(weapon)) and (((weapon.IsType("Martial")))))) end), }, Description={ Format="You understand how to use your chosen martial weapon in combat.", }, SourcePage="p.130", AutomaticProficiencies={ { Kind="Weapon", Names={ "%LIST", }, }, }, Benefits={ { FormatString="You make attack rolls with the selected weapon normally (without the non-proficient penalty).", }, }, Conditions={ function (character, item, sources) return not (character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Martial Weapon Proficiency Output" then return true end return false end)) end, }, Types={ "Combat", "MartialWeaponProficiency", }, }) DefineAbility({ Name="Master Craftsman", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseSkill(function (character, skill) return ((character.Ranks(skill) >= 5)) or ((skill.IsType("Craft"))) or ((skill.IsType("Profession"))) end), MaxTimes=1, }, Description={ Format="Your superior crafting skills allow you to create simple magic items.", }, SourcePage="p.130", Stackable=false, Benefits={ { FormatString="Choose one Craft or Profession skill in which you possess at least 5 ranks. You receive a +2 bonus on your chosen Craft or Profession skill. Ranks in your chosen skill count as your caster level for the purposes of qualifying for the Craft Magic Arms and Armor and Craft Wondrous Item feats. You can create magic items using these feats, substituting your ranks in the chosen skill for your total caster level. You must use the chosen skill for the check to create the item. The DC to create the item still increases for any necessary spell requirements (see the magic item creation rules in Chapter 15). You cannot use this feat to create any spell-trigger or spell-activation item.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("2"), Variables={ "LIST", }, }, { Category="VAR", Formula=Formula("var(\"SKILLRANK=%LIST\")"), Variables={ "MasterCraftsmanRanks", }, }, }, Conditions={ function (character, item, sources) return (character.BestSkillOfType("Craft").ranks >= 5) or (character.BestSkillOfType("Profession").ranks >= 5) end, }, Types={ "General", }, }) DefineAbility({ Name="Maximize Spell", Category="FEAT", AddedSpellLevels=3, Description={ Format="Your spells have the maximum possible effect.", }, SourcePage="p.130", Benefits={ { FormatString="All variable, numeric effects of a spell modified by this feat are maximized. Saving throws and opposed rolls are not affected, nor are spells without random variables. A maximized spell uses up a spell slot three levels higher than the spell's actual level. An empowered, maximized spell gains the separate benefits of each feat: the maximum result plus half the normally rolled result.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Maximized", }, }) DefineAbility({ Name="Medusa's Wrath", Category="FEAT", Description={ Format="You can take advantage of your opponent's confusion, delivering multiple blows.", }, SourcePage="p.130", Benefits={ { FormatString="Whenever you use the full-attack action and make at least one unarmed strike, you can make two additional unarmed strikes at your highest base attack bonus. These bonus attacks must be made against a dazed, flat-footed, paralyzed, staggered, stunned, or unconscious foe.", }, }, Conditions={ function (character, item, sources) return 3 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Unarmed Strike" then return true end if ability.Name == "Gorgon's Fist" then return true end if ability.Name == "Scorpion Style" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Mobility", Category="FEAT", Description={ Format="You can easily move through a dangerous melee.", }, SourcePage="p.130", Abilities={ { Category="Internal", Nature="AUTOMATIC", Names={ "Aspect Combat Bonus ~ Mobility", }, }, }, Benefits={ { FormatString="You get a +4 dodge bonus to Armor Class against attacks of opportunity caused when you move out of or within a threatened area. A condition that makes you lose your Dexterity bonus to Armor Class (if any) also makes you lose dodge bonuses. Dodge bonuses stack with each other, unlike most types of bonuses.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Dodge" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Mounted Archery", Category="FEAT", Description={ Format="You are skilled at making ranged attacks while mounted.", }, SourcePage="p.131", Benefits={ { FormatString="The penalty you take when using a ranged weapon while mounted is halved: -2 instead of -4 if your mount is taking a double move, and -4 instead of -8 if your mount is running.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Mounted Combat" then return true end return false end) end, function (character, item, sources) return (character.Skill("Ride").ranks >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Mounted Combat", Category="FEAT", Description={ Format="You are adept at guiding your mount through combat.", }, SourcePage="p.131", Benefits={ { FormatString="Once per round when your mount is hit in combat, you may attempt a Ride check (as an immediate action) to negate the hit. The hit is negated if your Ride check result is greater than the opponent's attack roll.", }, }, Conditions={ function (character, item, sources) return (character.Skill("Ride").ranks >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Natural Spell", Category="FEAT", Description={ Format="You can cast spells even while in a form that cannot normally cast spells.", }, SourcePage="p.131", Benefits={ { FormatString="You can complete the verbal and somatic components of spells while using wild shape. You substitute various noises and gestures for the normal verbal and somatic components of a spell. You can also use any material components or focuses you possess, even if such items are melded within your current form. This feat does not permit the use of magic items while you are in a form that could not ordinarily use them, and you do not gain the ability to speak while using wild shape.", }, }, Conditions={ function (character, item, sources) return (character.Variables["WildShapeProgression"] >= 1) or (character.Variables["ShamanWildShapeProgression"] >= 1) end, function (character, item, sources) return (character.Variables["PreStatScore_WIS"] >= 13) end, }, Types={ "General", }, }) DefineAbility({ Name="Nimble Moves", Category="FEAT", Description={ Format="You can move across a single obstacle with ease.", }, SourcePage="p.131", Aspects={ { Name="CombatBonus", FormatString="You may move through %1 feet of difficult terrain as normal.", Arguments={ "Feat_NimbleMoves_Squares", }, }, }, Benefits={ { FormatString="Whenever you move, you may move through 5 feet of difficult terrain each round as if it were normal terrain. This feat allows you to take a 5-foot step into difficult terrain.", }, }, Bonuses={ { Category="VAR", Formula=Formula("5"), Variables={ "Feat_NimbleMoves_Squares", }, }, }, Conditions={ function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, }, Types={ "General", }, }) DefineAbility({ Name="Penetrating Strike", Category="FEAT", Description={ Format="Your attacks with your chosen weapon are capable of penetrating the defenses of some creatures.", }, SourcePage="p.131", Benefits={ { FormatString="Your attacks made with weapons selected with Weapon Focus ignore up to 5 points of damage reduction. This feat does not apply to damage reduction without a type (such as DR 10/-).", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Weapon Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["PenetratingStrikeQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Persuasive", Category="FEAT", Description={ Format="You are skilled at swaying attitudes and intimidating others into your way of thinking.", }, SourcePage="p.131", Benefits={ { FormatString="You get a +2 bonus on Diplomacy and Intimidate skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Diplomacy\")>=10,4,2)"), Variables={ "Diplomacy", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Intimidate\")>=10,4,2)"), Variables={ "Intimidate", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Pinpoint Targeting", Category="FEAT", Description={ Format="You can target the weak points in your opponent's armor.", }, SourcePage="p.131", Benefits={ { FormatString="As a standard action, make a single ranged attack. The target does not gain any armor, natural armor, or shield bonuses to its Armor Class. You do not gain the benefit of this feat if you move this round.", }, }, Conditions={ function (character, item, sources) return 3 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Precise Shot" then return true end if ability.Name == "Point-Blank Shot" then return true end if ability.Name == "Precise Shot" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 19) or (character.Variables["FeatDexRequirement"] >= 19) end, function (character, item, sources) return character.TotalAttackBonus >= 16 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Point-Blank Shot", Category="FEAT", Description={ Format="You are especially accurate when making ranged attacks against close target.", }, SourcePage="p.131", Benefits={ { FormatString="You get a +1 bonus on attack and damage rolls with ranged weapons at ranges of up to 30 feet.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("1"), Variables={ "TOHIT-SHORTRANGE", "DAMAGE-SHORTRANGE", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Power Attack", Category="FEAT", Description={ Format="You can make exceptionally deadly melee attacks by sacrificing accuracy for strength.", }, SourcePage="p.131", Abilities={ { Category="FEAT", Nature="VIRTUAL", Names={ "Power Attack (Light)", "Power Attack (Off-Hand)", "Power Attack (One-Handed)", "Power Attack (Two-Handed)", }, }, { Category="FEAT", Nature="VIRTUAL", Names={ "Power Attack (Flurry)", }, Conditions={ function (character, item, sources) return ((character.GetLevelOfClass("Monk") >= 1)) >= 1 end, }, }, { Category="FEAT", Nature="VIRTUAL", Names={ "Power Attack (Natural Secondary)", }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Internal" then return false end if ability.IsAnyType("NaturalAttackSecondary") then return true end return false end) end, }, }, { Category="FEAT", Nature="VIRTUAL", Names={ "Power Attack (Natural Primary)", }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Internal" then return false end if ability.IsAnyType("NaturalAttackPrimary") then return true end return false end) end, }, }, { Category="FEAT", Nature="VIRTUAL", Names={ "Power Attack (Natural Primary - Single)", }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Internal" then return false end if ability.IsAnyType("NaturalAttackPrimarySingle") then return true end return false end) end, }, }, }, Benefits={ { FormatString="You can choose to take a -%1 penalty on all melee attack rolls and combat maneuver checks to gain a +%2 bonus on all melee damage rolls. This bonus to damage is increased by half (+50%%) if you are making an attack with a two-handed weapon, a one handed weapon using two hands, or a primary natural weapon that adds 1-1/2 times your Strength modifier on damage rolls. This bonus to damage is halved (-50%%) if you are making an attack with an off-hand weapon or secondary natural weapon. You must choose to use this feat before making an attack roll, and its effects last until your next turn. The bonus damage does not apply to touch attacks or effects that do not deal hit point damage.", Arguments={ "PowerAttackModifier", "PowerAttackDamageModifier", }, }, }, Bonuses={ { Category="VAR", Formula=Formula("(BAB/4)+1"), Variables={ "PowerAttackModifier", }, }, { Category="VAR", Formula=Formula("2"), Variables={ "PowerAttackDamageBase", }, }, { Category="VAR", Formula=Formula("PowerAttackDamageBase*floor(PowerAttackModifier)"), Variables={ "PowerAttackDamageModifier", }, }, { Category="VAR", Formula=Formula("BAB+(FlurryLVL-MonkBAB)"), Variables={ "MonkFlurryPowerAttackModifier", }, }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Precise Shot", Category="FEAT", Description={ Format="You are adept at firing ranged attacks into melee.", }, SourcePage="p.131", Benefits={ { FormatString="You can shoot or throw ranged weapons at an opponent engaged in melee without taking the standard -4 penalty on your attack roll.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Point-Blank Shot" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Quick Draw", Category="FEAT", Description={ Format="You can draw weapons faster than most.", }, SourcePage="p.131", Benefits={ { FormatString="You can draw a weapon as a free action instead of as a move action. You can draw a hidden weapon (see the Sleight of Hand skill) as a move action. A character who has selected this feat may throw weapons at his full normal rate of attacks (much like a character with a bow). Alchemical items, potions, scrolls, and wands cannot be drawn quickly using this feat.", }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 1 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Quicken Spell", Category="FEAT", AddedSpellLevels=4, Description={ Format="You can cast spells in the fraction of the normal time.", }, SourcePage="p.132", Benefits={ { FormatString="Casting a quickened spell is a swift action. You can perform another action, even casting another spell, in the same round as you cast a quickened spell. A spell whose casting time is more than 1 round or 1 full-round action cannot be quickened. A quickened spell uses up a spell slot four levels higher than the spell's actual level. Casting a quickened spell doesn't provoke an attack of opportunity.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Quickened", }, }) DefineAbility({ Name="Rapid Reload", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return (((stringMatch(weapon.Name, "Crossbow (Hand)") or stringMatch(weapon.Key, "Crossbow (Hand)")))) or (((stringMatch(weapon.Name, "Crossbow (Heavy)") or stringMatch(weapon.Key, "Crossbow (Heavy)")))) or (((stringMatch(weapon.Name, "Crossbow (Light)") or stringMatch(weapon.Key, "Crossbow (Light)")))) end), }, Description={ Format="Choose a type of crossbow (hand, light, or heavy). You can reload such weapons quickly.", }, ExtraCondition="Weapon Proficiency (crossbow type chosen).", SourcePage="p.132", Stackable=false, Benefits={ { FormatString="The time required for you to reload your chosen type of crossbow is reduced to a free action (for a hand or light crossbow) or a move action (for a heavy crossbow). Reloading a crossbow still provokes an attack of opportunity.&nl;If you have selected this feat for hand crossbow or light crossbow, you may fire that weapon as many times in a full-attack action as you could attack if you were using a bow.", }, }, Conditions={ function (character, item, sources) return (character.IsProficientWithWeaponType("Crossbow")) end, }, Types={ "Combat", }, Info={ Prerequisite="Weapon Proficiency (crossbow type chosen).", Normal="A character without this feat needs a move action to reload a hand or light crossbow, or a full-round action to reload a heavy crossbow.", Special="You can gain Rapid Reload multiple times. Each time you take the feat, it applies to a new type of crossbow.", }, }) DefineAbility({ Name="Rapid Shot", Category="FEAT", Description={ Format="You can make an additional ranged attack.", }, SourcePage="p.132", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("-2"), Variables={ "TOHIT", }, }, Target="EQ|Weapon,Ranged", }, Benefits={ { FormatString="When making a full-attack action with a ranged weapon, you can fire one additional time this round. All of your attack rolls take a -2 penalty when using Rapid Shot.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Point-Blank Shot" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Ride-By Attack", Category="FEAT", Description={ Format="While mounted, you can move, strike at a foe, and then continue moving.", }, SourcePage="p.132", Benefits={ { FormatString="When you are mounted and use the charge action, you may move and attack as if with a standard charge and then move again (continuing the straight line of the charge). Your total movement for the round can't exceed double your mounted speed. You and your mount do not provoke an attack of opportunity from the opponent that you attack.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Mounted Combat" then return true end return false end) end, function (character, item, sources) return (character.Skill("Ride").ranks >= 1) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Run", Category="FEAT", Description={ Format="You are swift of foot.", }, SourcePage="p.132", Benefits={ { FormatString="When running, you move five times your normal speed (if wearing medium, light, or no armor and carrying no more than a medium load) or four times your speed (if wearing heavy armor or carrying a heavy load). If you make a jump after a running start (see the Acrobatics skill description), you gain a +4 bonus on your Acrobatics check. While running, you retain your Dexterity bonus to your Armor Class.", }, }, Types={ "General", }, }) DefineAbility({ Name="Scorpion Style", Category="FEAT", Description={ Format="You can perform an unarmed strike that greatly hampers your target's movement.", }, SourcePage="p.132", Benefits={ { FormatString="To use this feat, you must make a single unarmed attack as a standard action. If this unarmed attack hits, you deal damage normally, and the target's base land speed is reduced to 5 feet for a number of rounds equal to your Wisdom modifier unless it makes a Fortitude saving throw (DC %1).", Arguments={ "10+(TL/2)+WIS", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Unarmed Strike" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Scribe Scroll", Category="FEAT", Description={ Format="You can create magic scrolls.", }, SourcePage="p.132", Benefits={ { FormatString="You can create a scroll of any spell that you know. Scribing a scroll takes 2 hours if its base price is 250 gp or less, otherwise scribing a scroll takes 1 day for each 1,000 gp in its base price. To scribe a scroll, you must use up raw materials costing half of this base price. See the magic item creation rules in Chapter 15 for more information.", }, }, Conditions={ function (character, item, sources) return ((character.CountSpellCastingClasses(1))) >= 1 or (character.Variables["CasterLevel_Highest"] >= 1) end, }, Types={ "ItemCreation", }, }) DefineAbility({ Name="Selective Channeling", Category="FEAT", Description={ Format="You can choose whom to affect when you channel energy.", }, SourcePage="p.132", Benefits={ { FormatString="When you channel energy, you can choose %1 targets in the area. These targets are not affected by your channeled energy.", Arguments={ "CHA", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Positive Energy", "Channel Negative Energy") then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_CHA"] >= 13) end, }, Types={ "General", }, }) DefineAbility({ Name="Self-Sufficient", Category="FEAT", Description={ Format="You know how to get along in the wild and how to effectively treat wounds.:", }, SourcePage="p.133", Benefits={ { FormatString="You get a +2 bonus on all Heal checks and Survival checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Heal\")>=10,4,2)"), Variables={ "Heal", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Survival\")>=10,4,2)"), Variables={ "Survival", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Shatter Defenses", Category="FEAT", Description={ Format="Your skill with your chosen weapon leaves opponents unable to defend themselves if you strike them when their defenses are already compromised.", }, SourcePage="p.133", Benefits={ { FormatString="Any shaken, frightened, or panicked opponent hit by you this round is flat-footed to your attacks until the end of your next turn. This includes any additional attacks you make this round.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Weapon Focus" then return true end if ability.Name == "Dazzling Display" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Shield Focus", Category="FEAT", Description={ Format="You are skilled at deflecting blows with your shield.", }, SourcePage="p.133", Benefits={ { FormatString="Increase the AC bonus granted by any shield you are using by 1.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("1"), Type={ Name="Shield", Stack=true, }, Conditions={ function (character, item, sources) return (character.HasEquipped(function (item) return item.IsType("Shield") end)) end, }, Variables={ "AC", }, }, }, Conditions={ function (character, item, sources) return (character.IsProficientWithShieldType("Buckler")) and (character.IsProficientWithShieldType("Light")) and (character.IsProficientWithShieldType("Heavy")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Shield Proficiency" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Shield Master", Category="FEAT", Description={ Format="Your mastery of the shield allows you to fight with it without hindrance.", }, SourcePage="p.133", Benefits={ { FormatString="You do not suffer any penalties on attack rolls made with a shield while you are wielding another weapon. Add your shield's shield bonus to attacks and damage rolls made with the shield as if it was an enhancement bonus.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("var(\"ARMOR.SHIELD.EQUIPPED.0.ACBONUS\")-var(\"ARMOR.SHIELD.EQUIPPED.0.BASEAC\")"), Type={ Name="Enhancement", }, Variables={ "TOHIT.ShieldBash", }, }, { Category="COMBAT", Formula=Formula("var(\"ARMOR.SHIELD.EQUIPPED.0.ACBONUS\")-var(\"ARMOR.SHIELD.EQUIPPED.0.BASEAC\")"), Type={ Name="Enhancement", }, Variables={ "DAMAGE.ShieldBash", }, }, { Category="VAR", Formula=Formula("var(\"ARMOR.SHIELD.EQUIPPED.0.ACBONUS\")-var(\"ARMOR.SHIELD.EQUIPPED.0.BASEAC\")"), Type={ Name="Enhancement", }, Variables={ "ShieldBashAttackBonus", "ShieldBashDamageBonus", }, }, }, Conditions={ function (character, item, sources) return 3 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Shield Bash" then return true end if ability.Name == "Shield Slam" then return true end if ability.Name == "Two-Weapon Fighting" then return true end return false end) end, function (character, item, sources) return (character.IsProficientWithShieldType("Buckler")) and (character.IsProficientWithShieldType("Light")) and (character.IsProficientWithShieldType("Heavy")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Shield Proficiency" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Shield Proficiency", Category="FEAT", Description={ Format="You are trained in how to properly use a shield.", }, SourcePage="p.133", AutomaticProficiencies={ { Kind="Shield", Types={ "Buckler", "Heavy", "Light", }, }, }, Benefits={ { FormatString="When you use a shield (except a tower shield), the shield's armor check penalty only applies to Strength- and Dexterity-based skills.", }, }, Types={ "Combat", }, }) DefineAbility({ Name="Shield Slam", Category="FEAT", Description={ Format="In the right position, your shield can be used to send opponents flying.", }, SourcePage="p.133", Benefits={ { FormatString="Any opponents hit by your shield bash are also hit with a free bull rush attack, substituting your attack roll for the combat maneuver check (see Chapter 8). This bull rush does not provoke an attack of opportunity. Opponents who cannot move back due to a wall or other surface are knocked prone after moving the maximum possible distance. You may choose to move with your target if you are able to take a 5-foot step or to spend an action to move this turn.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Shield Bash" then return true end if ability.Name == "Two-Weapon Fighting" then return true end return false end) end, function (character, item, sources) return (character.IsProficientWithShieldType("Buckler")) and (character.IsProficientWithShieldType("Light")) and (character.IsProficientWithShieldType("Heavy")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Shield Proficiency" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Shot on the Run", Category="FEAT", Description={ Format="You can move, fire a ranged weapon, and move again before your foes can react.", }, SourcePage="p.133", Benefits={ { FormatString="As a full-round action, you can move up to your speed and make a single ranged attack at any point during your movement.", }, }, Conditions={ function (character, item, sources) return 3 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Dodge" then return true end if ability.Name == "Mobility" then return true end if ability.Name == "Point-Blank Shot" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 4 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Sickening Critical", Category="FEAT", Description={ Format="Your critical hits cause opponents to become sickened.", }, SourcePage="p.133", Benefits={ { FormatString="Whenever you score a critical hit, your opponent becomes sickened for 1 minute. The effects of this feat do not stack. Additional hits instead add to the effect's duration.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 11 or (character.Variables["CriticalFocusQualify"] >= 11) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Silent Spell", Category="FEAT", AddedSpellLevels=1, Description={ Format="You can cast your spells without making any sound.", }, SourcePage="p.133", Benefits={ { FormatString="A silent spell can be cast with no verbal components. Spells without verbal components are not affected. A silent spell uses up a spell slot one level higher than the spell's actual level.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Silent", }, }) DefineAbility({ Name="Simple Weapon Proficiency", Category="FEAT", Description={ Format="You are trained in the use of basic weapons.", }, SourcePage="p.133", Abilities={ { Category="Internal", Nature="AUTOMATIC", Names={ "Weapon Prof ~ Simple", }, }, }, Benefits={ { FormatString="You make attack rolls with simple weapons without penalty.", }, }, Types={ "General", }, }) DefineAbility({ Name="Skill Focus", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseSkill(function (character, skill) return ((skill.IsType("Base"))) end), }, Description={ Format="You are particularly adept at your chosen skill.", }, SourcePage="p.134", Stackable=false, Benefits={ { FormatString="You get a +3 bonus on all checks involving the chosen skill. If you have 10 or more ranks in that skill, this bonus increases to +6.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("3"), Type={ Name="SkillFocus", }, Variables={ "%LIST", }, }, }, Types={ "General", "SkillFocus", }, }) DefineAbility({ Name="Snatch Arrows", Category="FEAT", Description={ Format="Instead of knocking an arrow or ranged attack aside, you can catch it in mid-flight.", }, SourcePage="p.134", Benefits={ { FormatString="When using the Deflect Arrows feat you may choose to catch the weapon instead of just deflecting it. Thrown weapons can immediately be thrown back as an attack against the original attacker (even though it isn't your turn) or kept for later use. You must have at least one hand free (holding nothing) to use this feat.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Deflect Arrows" then return true end if ability.Name == "Improved Unarmed Strike" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 15) or (character.Variables["FeatDexRequirement"] >= 15) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Spell Focus", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseSchool(function (character, school) return ((true)) end), }, Description={ Format="Any spells you cast of your chosen school of magic are more difficult to resist.", }, SourcePage="p.134", Stackable=false, Benefits={ { FormatString="Add +1 to the Difficulty Class for all saving throws against spells from the school of magic you select.", }, }, Bonuses={ { Category="DC", Formula=Formula("1"), Type={ Name="SpellFocus", }, Variables={ "SCHOOL.%LIST", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Spell Mastery", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseSpell(function (character, spell) return ((spell.IsInClassList("Wizard") and (((character.KnowsSpell(spell)))))) end), }, Description={ Format="You have mastered a small handfull of spells, and can prepare these spells without referencing your spellbooks at all.", }, Selections=Formula("var(\"STAT.3.MOD.NOEQUIP.NOTEMP\")"), SourcePage="p.134", Benefits={ { FormatString="Each time you take this feat, choose a number of spells that you already know equal to your Intelligence modifier. From that point on, you can prepare these spells without referring to a spellbook.", }, }, Conditions={ function (character, item, sources) return (character.Variables["SpellMasteryQualify"] >= 1) end, }, Types={ "General", "WizardBonus", }, }) DefineAbility({ Name="Spell Penetration", Category="FEAT", Description={ Format="Your spells break through spell resistance more easily than most.", }, SourcePage="p.134", Benefits={ { FormatString="You get a +2 bonus on caster level checks (1d20 + caster level) made to overcome a creature's spell resistance.", }, }, Types={ "General", }, }) DefineAbility({ Name="Spellbreaker", Category="FEAT", Description={ Format="You can strike at enemy spellcasters who fail to cast defensively when you threaten them.", }, SourcePage="p.134", Benefits={ { FormatString="Enemies in your threatened area that fail their checks to cast spells defensively provoke attacks of opportunity from you.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Disruptive" then return true end return false end) end, function (character, item, sources) return (character.Variables["SpellBreakerQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Spirited Charge", Category="FEAT", Description={ Format="Your mounted charge deals a tremendous amount of damage.", }, SourcePage="p.134", Benefits={ { FormatString="When mounted and using the charge action, you deal double damage with a melee weapon (or triple damage with a lance).", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Mounted Combat" then return true end if ability.Name == "Ride-By Attack" then return true end return false end) end, function (character, item, sources) return (character.Skill("Ride").ranks >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Spring Attack", Category="FEAT", Description={ Format="You can deftly move up to a foe, strike, and withdraw before he can react.", }, SourcePage="p.134", Benefits={ { FormatString="As a full round action, you can move up to your speed and make a single melee attack without provoking any attacks of opportunity from the target of your attack. You can move both before and after the attack, but you must move at least 10 feet before the attack and the total distance that you move cannot be greater than your speed. You cannot use this ability to attack a foe that is adjacent to you at the start of your turn.", }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Dodge" then return true end if ability.Name == "Mobility" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 4 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Staggering Critical", Category="FEAT", Description={ Format="Your critical hits cause opponents to slow down.", }, SourcePage="p.134", Benefits={ { FormatString="Whenever you score a critical hit, your opponent becomes staggered for 1d4+1 rounds. A successful Fortitude save reduces the duration to 1 round. The DC of this Fortitude save is equal to %1. The effects of this feat do not stack. Additional hits instead add to the duration.", Arguments={ "10+BAB", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 13 or (character.Variables["CriticalFocusQualify"] >= 13) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Stand Still", Category="FEAT", Description={ Format="You can stop foes that try to move past you.", }, SourcePage="p.134", Benefits={ { FormatString="When a foe provokes an attack of opportunity due to moving through your adjacent squares, you can make a combat maneuver check as your attack of opportunity. If successful, the enemy cannot move for the rest of his turn. An enemy can still take the rest of his action, but cannot move. This feat also applies to any creature that attempts to move from a square that is adjacent to you if such movement provokes an attack of opportunity.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Reflexes" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Stealthy", Category="FEAT", Description={ Format="You are good at avoiding attention and slipping out of bonds.", }, SourcePage="p.135", Benefits={ { FormatString="You get a +2 bonus on all Escape Artist and Stealth skill checks. If you have 10 or more ranks in one of these skills, the bonus increases to +4 for that skill.", }, }, Bonuses={ { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Escape Artist\")>=10,4,2)"), Variables={ "Escape Artist", }, }, { Category="SKILL", Formula=Formula("if(skillinfo(\"TOTALRANK\",\"Stealth\")>=10,4,2)"), Variables={ "Stealth", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Step Up", Category="FEAT", Description={ Format="You can close the distance when a foe tries to move away.", }, SourcePage="p.135", Benefits={ { FormatString="Whenever an adjacent foe attempts to take a 5-foot step away from you, you may also make a 5-foot step as an immediate action so long as you end up adjacent to the foe that triggered this ability. If you take this step, you cannot take a 5-foot step during your next turn. If you take an action to move during your next turn, subtract 5 feet from your total movement.", }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 1 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Still Spell", Category="FEAT", AddedSpellLevels=1, Description={ Format="You can cast spells without moving.", }, SourcePage="p.135", Benefits={ { FormatString="A stilled spell can be cast with no somatic components. Spells without somatic components are not affected. A stilled spell uses up a spell slot one level higher than the spell's actual level.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Still", }, }) DefineAbility({ Name="Strike Back", Category="FEAT", Description={ Format="You can strike at foes that attack you using their superior reach, by targeting their limbs or weapons as they come at you.", }, SourcePage="p.135", Benefits={ { FormatString="You can ready an action to make a melee attack against any foe that attacks you in melee, even if the foe is outside of your reach.", }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Stunning Critical", Category="FEAT", Description={ Format="Your critical hits cause opponents to become stunned.", }, SourcePage="p.135", Benefits={ { FormatString="Whenever you score a critical hit, your opponent becomes stunned for 1d4 rounds. A successful Fortitude save reduces this to staggered for 1d4 rounds. The DC of this Fortitude save is equal to %1. The effects of this feat do not stack. Additional hits instead add to the duration.", Arguments={ "10+BAB", }, }, }, Conditions={ function (character, item, sources) return 2 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end if ability.Name == "Staggering Critical" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 17 or (character.Variables["CriticalFocusQualify"] >= 17) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Stunning Fist", Category="FEAT", Description={ Format="You know just where to strike to temporarily stun a foe. %1/day (DC %2)", Arguments={ Formula("StunningFistAttack"), Formula("StunningFistDC"), }, }, SourcePage="p.135", Stackable=false, Abilities={ { Category="Ability Focus", Nature="AUTOMATIC", Names={ "Stunning Fist", }, }, }, Benefits={ { FormatString="You must declare that you are using this feat before you make your attack roll (thus, a failed attack roll ruins the attempt). Stunning Fist forces a foe damaged by your unarmed attack to make a Fortitude saving throw (DC %1), in addition to dealing damage normally. A defender who fails this saving throw is stunned for 1 round (until just before your next turn). A stunned character drops everything held, can't take actions, loses any Dexterity bonus to AC, and takes a -2 penalty to AC. You may attempt a stunning attack once per day for every four levels you have attained (but see Special), and no more than once per round. Constructs, oozes, plants, undead, incorporeal creatures, and creatures immune to critical hits cannot be stunned.", Arguments={ "StunningFistDC", }, }, }, Bonuses={ { Category="VAR", Formula=Formula("2"), Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Ability Focus (Stunning Fist)" then return true end return false end) end, }, Variables={ "StunningFistDC", }, }, { Category="VAR", Formula=Formula("10+(TL/2)+WIS"), Variables={ "StunningFistDC", }, }, { Category="VAR", Formula=Formula("MonkLVL+floor((TL-MonkLVL)/4)"), Type={ Name="NoStack", }, Variables={ "StunningFistAttack", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Improved Unarmed Strike" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_WIS"] >= 13) and (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 8 end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Throw Anything", Category="FEAT", Description={ Format="You are used to throwing things you have on hand.", }, SourcePage="p.135", Benefits={ { FormatString="You do not suffer any penalties for using an improvised ranged weapon. You receive a +1 circumstance bonus on attack rolls made with thrown splash weapons.", }, }, Bonuses={ { Category="WEAPONPROF=TYPE.Splash", Formula=Formula("1"), Variables={ "TOHIT", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Tiring Critical", Category="FEAT", Description={ Format="Your critical hits cause opponents to become fatigued.", }, SourcePage="p.135", Benefits={ { FormatString="Whenever you score a critical hit, your opponent becomes fatigued. This feat has no additional effect on a fatigued or exhausted creature.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Critical Focus" then return true end return false end) end, function (character, item, sources) return character.TotalAttackBonus >= 13 or (character.Variables["CriticalFocusQualify"] >= 13) end, }, Types={ "Combat", "Critical", }, }) DefineAbility({ Name="Toughness", Category="FEAT", Description={ Format="You have enhanced physical stamina.", }, SourcePage="p.135", Benefits={ { FormatString="You gain +%1 hit points.", Arguments={ "max(3,TL)", }, }, { FormatString="You gain +1 hit points whenever you gain a Hit Die (such as when you gain a level).", Conditions={ function (character, item, sources) return character.HitDie >= 3 end, }, }, }, Bonuses={ { Category="HP", Formula=Formula("max(3,TL)"), Conditions={ function (character, item, sources) return (IsRuleEnabled("DAMAGE_HP")) end, }, Variables={ "CURRENTMAX", }, }, }, Types={ "General", }, }) DefineAbility({ Name="Tower Shield Proficiency", Category="FEAT", Description={ Format="You are trained in how to properly use a tower shield.", }, SourcePage="p.135", AutomaticProficiencies={ { Kind="Shield", Types={ "Tower", }, }, }, Benefits={ { FormatString="When you use a tower shield, the shield's armor check penalty only applies to Strength and Dexterity-based skills.", }, }, Conditions={ function (character, item, sources) return (character.IsProficientWithShieldType("Buckler")) and (character.IsProficientWithShieldType("Light")) and (character.IsProficientWithShieldType("Heavy")) or character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Shield Proficiency" then return true end return false end) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Trample", Category="FEAT", Description={ Format="While mounted, you can ride down opponents and thrample them under your mount.", }, SourcePage="p.136", Benefits={ { FormatString="When you attempt to overrun an opponent while mounted, your target may not choose to avoid you. Your mount may make one hoof attack against any target you knock down, gaining the standard +4 bonus on attack rolls against prone targets.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Mounted Combat" then return true end return false end) end, function (character, item, sources) return (character.Skill("Ride").ranks >= 1) end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Turn Undead", Category="FEAT", Description={ Format="Calling upon higher powers, you cause undead to flee from the might of your unleashed divine energy.", }, SourcePage="p.136", Benefits={ { FormatString="You can, as a standard action, use one of your uses of channel positive energy to cause all undead within 30 feet of you to flee, as if panicked. Undead receive a Will save %1 to negate the effect. Undead that fail their save flee for 1 minute. Intelligent undead receive a new saving throw each round to end the effect. If you use channel energy in this way, it has no other effect (it does not heal or harm nearby creatures).", Arguments={ "ClericChannelPositiveEnergyDC", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "Special Ability" then return false end if ability.IsAnyType("Channel Positive Energy") then return true end return false end) end, }, Types={ "General", }, }) DefineAbility({ Name="Two-Weapon Defense", Category="FEAT", Description={ Format="You are skilled at defending yourself while fighting with two weapons.", }, SourcePage="p.136", Benefits={ { FormatString="When wielding a double weapon or two weapons (not including natural weapons or unarmed strikes), you gain a +1 shield bonus to your AC. When you are fighting defensively or using the total defense action, this shield bonus increases to +2.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("TwoWeaponShield"), Type={ Name="Shield", }, Conditions={ function (character, item, sources) return (character.HasEquipped(function (item) return item.IsType("Double") end)) or (character.HasEquippedInPrimaryHand(function (item) return item.IsType("Melee") end)) and (character.HasEquipped(function (item) return item.IsType("Melee") end)) end, }, Variables={ "AC", }, }, { Category="VAR", Formula=Formula("1"), Variables={ "TwoWeaponShield", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Two-Weapon Fighting" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 15) or (character.Variables["FeatDexRequirement"] >= 15) end, }, Types={ "Combat", "ModifyAC", }, }) DefineAbility({ Name="Two-Weapon Fighting", Category="FEAT", Description={ Format="You can fight with a weapon in each of your hands. You can make one extra attack each round with the secondary weapon.", }, SourcePage="p.136", Benefits={ { FormatString="Your penalties on attack rolls for fighting with two weapons are reduced. The penalty for your primary hand lessens by 2 and the one for your off hand lessens by 6. See Two-Weapon Fighting in Chapter 8.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("2"), Variables={ "TOHIT-PRIMARY", }, }, { Category="COMBAT", Formula=Formula("6"), Variables={ "TOHIT-SECONDARY", }, }, }, Conditions={ function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 15) or (character.Variables["FeatDexRequirement"] >= 15) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Two-Weapon Rend", Category="FEAT", Description={ Format="Striking with both your weapons simultanoeusly, you can use them to deliver devastating wounds.", }, SourcePage="p.136", Benefits={ { FormatString="If you hit an opponent with both your primary hand and your off-hand weapon, you deal an additional 1d10 points of damage plus %1. You can only deal this additional damage once each round.", Arguments={ "1.5*STR", }, }, }, Conditions={ function (character, item, sources) return 3 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Double Slice" then return true end if ability.Name == "Improved Two-Weapon Fighting" then return true end if ability.Name == "Two-Weapon Fighting" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 17) or (character.Variables["FeatDexRequirement"] >= 17) end, function (character, item, sources) return character.TotalAttackBonus >= 11 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Unseat", Category="FEAT", Description={ Format="You are skilled at unseating your mounted opponent.", }, SourcePage="p.136", Benefits={ { FormatString="When charging an opponent while mounted and wielding a lance, resolve the attack as normal. If it hits, you may immediately make a free bull rush attempt in addition to the normal damage. If successful, the target is knocked off his horse and lands prone in a space adjacent to his mount that is directly away from you.", }, }, Conditions={ function (character, item, sources) return 3 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Mounted Combat" then return true end if ability.Name == "Power Attack" then return true end if ability.Name == "Improved Bull Rush" then return true end return false end) end, function (character, item, sources) return (character.Skill("Ride").ranks >= 1) end, function (character, item, sources) return character.TotalAttackBonus >= 1 end, function (character, item, sources) return (character.Variables["PreStatScore_STR"] >= 13) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Vital Strike", Category="FEAT", Description={ Format="You make a single attack that deals significantly more damage than normal.", }, SourcePage="p.136", Benefits={ { FormatString="When you use the attack action, you can make one attack at your highest base attack bonus that deals additional damage. Roll the weapon's damage dice for the attack twice and add the results together before adding bonuses from Strength, weapon abilities (such as flaming), precision-based damage, and other damage bonuses. These extra damage dice are not multiplied on a critical hit, but are added to the total.", }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Weapon Finesse", Category="FEAT", Description={ Format="You are trained in using your agility in melee combat, as opposed to brute strength.", }, SourcePage="p.136", Benefits={ { FormatString="With a light weapon, rapier, whip, or spiked chain made for a creature of your size category, you may use your Dexterity modifier instead of your Strength modifier on attack rolls. If you carry a shield, its armor check penalty applies to your attack rolls.", }, }, Bonuses={ { Category="COMBAT", Formula=Formula("((max(STR,DEX)-STR)+SHIELDACCHECK)"), Type={ Name="NotRanged", }, Variables={ "TOHIT.Finesseable", }, }, }, Types={ "Combat", }, }) DefineAbility({ Name="Weapon Focus", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return ((character.IsProficientWith(weapon))) end), }, Description={ Format="You are especially good at using your chosen weapon.", }, SourcePage="p.136", Benefits={ { FormatString="You gain a +1 bonus on all attack rolls you make using the selected weapon.", }, }, Bonuses={ { Category="WEAPONPROF=%LIST", Formula=Formula("WeaponFocusToHit"), Variables={ "TOHIT", }, }, }, Conditions={ function (character, item, sources) return character.TotalAttackBonus >= 1 end, }, Types={ "Combat", "WeaponFocus", }, }) DefineAbility({ Name="Weapon Specialization", Category="FEAT", AllowMultiple=true, Choice={ Choose=ChooseWeaponProficiency(function (character, weapon) return (((stringMatch(weapon.Name, "ABILITY=FEAT") or stringMatch(weapon.Key, "ABILITY=FEAT")) and ((((stringMatch(weapon.Name, "Weapon Focus") or stringMatch(weapon.Key, "Weapon Focus"))))))) end), }, Description={ Format="You deal extra damage when using your chosen weapon.", }, SourcePage="p.137", Benefits={ { FormatString="You gain a +2 bonus on all damage rolls you make using the selected weapon.", }, }, Bonuses={ { Category="WEAPONPROF=%LIST", Formula=Formula("2"), Variables={ "DAMAGE", }, }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Weapon Focus" then return true end return false end) end, function (character, item, sources) return (character.Variables["WeapSpecQualify"] >= 1) end, }, Types={ "Combat", }, }) DefineAbility({ Name="Whirlwind Attack", Category="FEAT", Description={ Format="You can strike out at every foe within reach.", }, SourcePage="p.137", Benefits={ { FormatString="When you use the full-attack action, you can give up your regular attacks and instead make one melee attack at your highest base attack bonus against each opponent within reach. You must make a separate attack roll against each opponent. When you use the Whirlwind Attack feat, you also forfeit any bonus or extra attacks granted by other feats, spells, or abilities.", }, }, Conditions={ function (character, item, sources) return 4 <= character.CountAbilities(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Combat Expertise" then return true end if ability.Name == "Dodge" then return true end if ability.Name == "Mobility" then return true end if ability.Name == "Spring Attack" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_INT"] >= 13) or (character.Variables["CombatFeatIntRequirement"] >= 13) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 13) or (character.Variables["FeatDexRequirement"] >= 13) end, function (character, item, sources) return character.TotalAttackBonus >= 4 end, }, Types={ "Combat", "AttackOption", }, }) DefineAbility({ Name="Widen Spell", Category="FEAT", AddedSpellLevels=3, Description={ Format="You can cast your spells so that they occupy a larger space.", }, SourcePage="p.137", Benefits={ { FormatString="You can alter a burst, emanation, or spread-shaped spell to increase its area. Any numeric measurements of the spell's area increase by 100%%. A widened spell uses up a spell slot three levels higher than the spell's actual level. Spells that do not have an area of one of these four sorts are not affected by this feat.", }, }, Types={ "Metamagic", }, Facts={ AppliedName="Widened", }, }) DefineAbility({ Name="Wind Stance", Category="FEAT", Description={ Format="Your erratic movements make it difficult for enemies to pinpoint your location.", }, SourcePage="p.137", Benefits={ { FormatString="If you move more than 5 feet this turn, you gain 20%% concealment for 1 round against ranged attacks.", }, }, Conditions={ function (character, item, sources) return character.HasAnyAbility(function (ability) if ability.Category ~= "FEAT" then return false end if ability.Name == "Dodge" then return true end return false end) end, function (character, item, sources) return (character.Variables["PreStatScore_DEX"] >= 15) or (character.Variables["FeatDexRequirement"] >= 15) end, function (character, item, sources) return character.TotalAttackBonus >= 6 end, }, Types={ "Combat", }, }) DefineAbility({ Name="Leadership Score", Category="FEAT", TemporaryBonus={ Bonus={ Category="VAR", Formula=Formula("%CHOICE"), Variables={ "LeadershipScore", }, }, Target="PC", }, TemporaryBonusDescription={ Format="Several factors can affect a character's Leadership score, causing it to vary from the base score. Add modifiers as needed.", }, Visible=false, Types={ "Special", "Internal", }, }) DefineAbility({ Name="Power Attack (Off-Hand)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("(PowerAttackDamageBase/2)+PowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,Light;OneHanded", }, Visible=false, }) DefineAbility({ Name="Power Attack (Light)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("PowerAttackDamageBase*PowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,Light;Natural", }, Visible=false, }) DefineAbility({ Name="Power Attack (One-Handed)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("PowerAttackDamageBase*PowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,OneHanded;Natural", }, Visible=false, }) DefineAbility({ Name="Power Attack (Two-Handed)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("(PowerAttackDamageBase*1.5)*PowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,TwoHanded;OneHanded;Natural", }, Visible=false, }) DefineAbility({ Name="Power Attack (Flurry)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("PowerAttackDamageBase*MonkFlurryPowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,Unarmed,Special,Monk", }, Visible=false, }) DefineAbility({ Name="Power Attack (Natural Secondary)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("PowerAttackDamageBase*PowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,Natural,NaturalSecondary", }, Visible=false, }) DefineAbility({ Name="Power Attack (Natural Primary)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("PowerAttackDamageBase*PowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,Natural,NaturalPrimary", }, Visible=false, }) DefineAbility({ Name="Power Attack (Natural Primary - Single)", Category="FEAT", TemporaryBonus={ Bonus={ Category="WEAPON", Formula=Formula("(PowerAttackDamageBase*1.5)*PowerAttackModifier"), Type={ Name="Temporary", }, Variables={ "DAMAGE", }, }, Target="EQ|Weapon,Melee,Natural,NaturalPrimarySingle", }, Visible=false, }) ModifyAbility({ Name="Arcane Strike", Category="FEAT", Bonuses={ { Category="VAR", Formula=Formula("Caster_Level_Total__Arcane"), Variables={ "ArcaneStrikeLVL", }, }, }, }) DefineAbility({ Name="Cleave (Granted by Sylvan Scimitar)", Key="Sylvan Scimitar ~ Cleave", Category="FEAT", Description={ Format="When outdoors, You can strike two adjacent foes with a single swing.", }, SourcePage="p.119", Visible=true, Benefits={ { FormatString="When outdoors, as a standard action, you can make a single attack at your full base attack bonus against a foe within reach. If you hit, you deal damage normally and can make an additional attack (using your full base attack bonus) against a foe that is adjacent to the first and also within reach. You can only make one additional attack per round with this feat. When you use this feat, you take a -2 penalty to your Armor Class until your next turn.", }, }, }) DefineAbility({ Name="Heighten Spell +2", Category="FEAT", AddedSpellLevels=2, Visible=true, Bonuses={ { Category="DC", Formula=Formula("2"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +2", }, }) DefineAbility({ Name="Heighten Spell +3", Category="FEAT", AddedSpellLevels=3, Visible=true, Bonuses={ { Category="DC", Formula=Formula("3"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +3", }, }) DefineAbility({ Name="Heighten Spell +4", Category="FEAT", AddedSpellLevels=4, Visible=true, Bonuses={ { Category="DC", Formula=Formula("4"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +4", }, }) DefineAbility({ Name="Heighten Spell +5", Category="FEAT", AddedSpellLevels=5, Visible=true, Bonuses={ { Category="DC", Formula=Formula("5"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +5", }, }) DefineAbility({ Name="Heighten Spell +6", Category="FEAT", AddedSpellLevels=6, Visible=true, Bonuses={ { Category="DC", Formula=Formula("6"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +6", }, }) DefineAbility({ Name="Heighten Spell +7", Category="FEAT", AddedSpellLevels=7, Visible=true, Bonuses={ { Category="DC", Formula=Formula("7"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +7", }, }) DefineAbility({ Name="Heighten Spell +8", Category="FEAT", AddedSpellLevels=8, Visible=true, Bonuses={ { Category="DC", Formula=Formula("8"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +8", }, }) DefineAbility({ Name="Heighten Spell +9", Category="FEAT", AddedSpellLevels=9, Visible=true, Bonuses={ { Category="DC", Formula=Formula("9"), Variables={ "FEATBONUS", }, }, }, Types={ "Heighten Spell", "Metamagic", }, Facts={ AppliedName="Heightened +9", }, }) ModifyAbility({ Name="Weapon Finesse", Category="Feat", Bonuses={ { Category="VAR", Formula=Formula("1"), Type={ Name="Boolean", }, Variables={ "HasWeaponFinesseFeat", }, }, }, })
local local0 = 0.4 local local1 = 0 - local0 local local2 = 0 - local0 local local3 = 2.2 - local0 local local4 = 0 - local0 local local5 = 20.6 - local0 local local6 = 0 - local0 local local7 = 4 - local0 local local8 = 0 - local0 local local9 = 20.6 - local0 local local10 = 0 - local0 local local11 = 0 - local0 function OnIf_210030(arg0, arg1, arg2) if arg2 == 0 then EyeCollector210030_ActAfter_RealTime(arg0, arg1) end return end function EyeCollector210030Battle_Activate(arg0, arg1) local local0 = {} local local1 = {} local local2 = {} Common_Clear_Param(local0, local1, local2) local local3 = arg0:GetRandam_Int(1, 100) local local4 = 0 local local5 = arg0:GetExcelParam(AI_EXCEL_THINK_PARAM_TYPE__thinkAttr_doAdmirer) local local6 = arg0:GetEventRequest() if arg0:IsFinishTimer(0) == true and arg0:GetDistY(TARGET_ENE_0) < 0.1 then local4 = 1 end if local6 == 10 then arg0:AddTopGoal(GOAL_COMMON_ApproachTarget, 30, POINT_INITIAL, 0.5, TARGET_SELF, false, -1) elseif local6 == 20 then arg0:AddTopGoal(GOAL_COMMON_ApproachTarget, 30, POINT_INITIAL, 0.5, TARGET_SELF, true, -1) elseif arg0:IsInsideTarget(TARGET_ENE_0, AI_DIR_TYPE_B, 240) then local0[20] = 100 elseif 2 <= arg0:GetDist(TARGET_ENE_0) then local0[1] = 1 local0[2] = 0 local0[3] = 0 local0[4] = 100 * local4 else local0[1] = 1 local0[2] = 0 local0[3] = 100 * local4 local0[4] = 0 end local1[1] = REGIST_FUNC(arg0, arg1, EyeCollector210030_Act01) local1[2] = REGIST_FUNC(arg0, arg1, EyeCollector210030_Act02) local1[3] = REGIST_FUNC(arg0, arg1, EyeCollector210030_Act03) local1[4] = REGIST_FUNC(arg0, arg1, EyeCollector210030_Act04) local1[5] = REGIST_FUNC(arg0, arg1, EyeCollector210030_Act05) local1[20] = REGIST_FUNC(arg0, arg1, EyeCollector210030_Act20) Common_Battle_Activate(arg0, arg1, local0, local1, REGIST_FUNC(arg0, arg1, EyeCollector210030_ActAfter_AdjustSpace), local2) return end local0 = 2.4 - local0 function EyeCollector210030_Act01(arg0, arg1, arg2) local local0 = UPVAL0 local local1 = UPVAL0 if local0 <= arg0:GetDist(TARGET_ENE_0) then Approach_Act(arg0, arg1, local0, 0, 0, 3) end if arg0:GetRandam_Int(1, 100) <= 33 then arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3000, TARGET_ENE_0, local1, 0, -1) else arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 10, 3000, TARGET_ENE_0, AttDist0, 0, 120) arg1:AddSubGoal(GOAL_COMMON_ComboFinal, 10, 3001, TARGET_ENE_0, local1, 0) end GetWellSpace_Odds = 50 return GetWellSpace_Odds end function EyeCollector210030_Act02(arg0, arg1, arg2) if arg0:IsInsideTarget(TARGET_ENE_0, AI_DIR_TYPE_R, 180) then arg1:AddSubGoal(GOAL_COMMON_SpinStep, 10, 702, TARGET_ENE_0, 0, AI_DIR_TYPE_B, 0) elseif arg0:IsInsideTarget(TARGET_ENE_0, AI_DIR_TYPE_L, 180) then arg1:AddSubGoal(GOAL_COMMON_SpinStep, 10, 703, TARGET_ENE_0, 0, AI_DIR_TYPE_B, 0) end GetWellSpace_Odds = 0 return GetWellSpace_Odds end local0 = 2.2 - local0 function EyeCollector210030_Act03(arg0, arg1, arg2) local local0 = arg0:GetRandam_Int(1, 100) local local1 = UPVAL0 if local1 <= arg0:GetDist(TARGET_ENE_0) then Approach_Act(arg0, arg1, local1, 0, 0, 3) end arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 10, 3005, TARGET_ENE_0, UPVAL0, 0, 0) arg0:SetTimer(0, 10) GetWellSpace_Odds = 100 return GetWellSpace_Odds end local0 = 4.6 - local0 function EyeCollector210030_Act04(arg0, arg1, arg2) local local0 = arg0:GetRandam_Int(1, 100) local local1 = UPVAL0 if local1 <= arg0:GetDist(TARGET_ENE_0) then Approach_Act(arg0, arg1, local1, 0, 0, 3) end arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 10, 3006, TARGET_ENE_0, UPVAL0, 0, 0) arg0:SetTimer(0, 10) GetWellSpace_Odds = 100 return GetWellSpace_Odds end function EyeCollector210030_Act05(arg0, arg1, arg2) local local0 = arg0:GetDist(TARGET_ENE_0) local local1 = arg0:GetRandam_Int(1, 100) local local2 = arg0:GetRandam_Float(5, 7) local local3 = 0 local local4 = 0 arg1:AddSubGoal(GOAL_COMMON_SidewayMove, local2, TARGET_ENE_0, 0, arg0:GetRandam_Int(30, 45), true, true, -1) arg1:AddSubGoal(GOAL_COMMON_SidewayMove, local2, TARGET_ENE_0, 1, arg0:GetRandam_Int(30, 45), true, true, -1) GetWellSpace_Odds = 0 return GetWellSpace_Odds end function EyeCollector210030_Act20(arg0, arg1, arg2) arg1:AddSubGoal(GOAL_COMMON_Turn, 2.5, TARGET_ENE_0, 30, 0, 0) GetWellSpace_Odds = 0 return GetWellSpace_Odds end function EyeCollector210030_ActAfter_RealTime(arg0, arg1) local local0 = arg0:GetDist(TARGET_ENE_0) local local1 = arg0:GetRandam_Int(1, 100) local local2 = arg0:GetRandam_Int(0, 1) local local3 = arg0:GetRandam_Float(2, 4) if local0 <= 3 then if local1 <= 33 then arg1:AddSubGoal(GOAL_COMMON_LeaveTarget, local3, TARGET_ENE_0, 3, TARGET_ENE_0, true, -1) else arg1:AddSubGoal(GOAL_COMMON_LeaveTarget, local3, TARGET_ENE_0, 3, TARGET_ENE_0, true, -1) arg1:AddSubGoal(GOAL_COMMON_SidewayMove, local3, TARGET_ENE_0, local2, arg0:GetRandam_Int(30, 45), true, true, -1) end elseif local0 <= 6 then if local1 <= 50 then arg1:AddSubGoal(GOAL_COMMON_SidewayMove, local3, TARGET_ENE_0, local2, arg0:GetRandam_Int(30, 45), true, true, -1) else arg1:AddSubGoal(GOAL_COMMON_LeaveTarget, local3, TARGET_ENE_0, 3, TARGET_ENE_0, true, -1) end else arg1:AddSubGoal(GOAL_COMMON_SidewayMove, local3, TARGET_ENE_0, local2, arg0:GetRandam_Int(30, 45), true, true, -1) end return end function EyeCollector210030_ActAfter_AdjustSpace(arg0, arg1, arg2) arg1:AddSubGoal(GOAL_COMMON_If, 10, 0) return end function EyeCollector210030Battle_Update(arg0, arg1) return GOAL_RESULT_Continue end function EyeCollector210030Battle_Terminate(arg0, arg1) return end function EyeCollector210030Battle_Interupt(arg0, arg1) return false end return
-------------------------------------------------------------------------------- -- Module Declaration -- local mod, CL = BigWigs:NewBoss("Kyrak", 1358, 1227) if not mod then return end mod:RegisterEnableMob(76021) mod.engageId = 1758 mod.respawnTime = 25 -------------------------------------------------------------------------------- -- Initialization -- function mod:GetOptions() return { 161199, -- Debilitating Fixation 161203, -- Rejuvenating Serum 161288, -- Vileblood Serum {155037, "TANK"}, -- Eruption }, { [161199] = -10260, [155037] = CL.adds, } end function mod:OnBossEnable() self:Log("SPELL_CAST_START", "DebilitatingFixation", 161199) self:Log("SPELL_CAST_START", "RejuvenatingSerumIncoming", 161203) self:Log("SPELL_CAST_SUCCESS", "RejuvenatingSerum", 161203) self:Log("SPELL_AURA_APPLIED", "VilebloodSerum", 161288) self:Log("SPELL_CAST_START", "Eruption", 155037) end -------------------------------------------------------------------------------- -- Event Handlers -- function mod:DebilitatingFixation(args) self:Message(args.spellId, "yellow", "Alert", CL.casting:format(args.spellName)) self:CDBar(args.spellId, 20) -- 20-23 end function mod:RejuvenatingSerumIncoming(args) self:Message(args.spellId, "orange", "Long", CL.incoming:format(args.spellName)) end function mod:RejuvenatingSerum(args) self:TargetMessage(args.spellId, args.destName, "orange", "Warning", nil, nil, self:Dispeller("magic", true)) end function mod:VilebloodSerum(args) if self:Me(args.destGUID) then self:Message(args.spellId, "blue", "Alarm", CL.underyou:format(args.spellName)) end end function mod:Eruption(args) local raidIcon = CombatLog_String_GetIcon(args.sourceRaidFlags) self:Message(args.spellId, "red", "Info", raidIcon.. args.spellName) end
ITEM.name = "AKS-74N" ITEM.description = "The AK-74 is an assault rifle developed in the early 1970s by Russian designer Mikhail Kalashnikov as the replacement for the earlier AKM. It uses a smaller 5.45×39mm cartridge, replacing the 7.62×39mm chambering of earlier Kalashnikov-pattern weapons. This particular model is made for the Navy and colored appropriately. Features far superior rust and general environmental degradation resistance due to this. Similar in terms of performance and use-based degradation." ITEM.model = "models/weapons/ethereal/item_ak742.mdl" ITEM.class = "cw_kk_ins2_ak742" ITEM.weaponCategory = "primary" ITEM.width = 3 ITEM.height = 2 ITEM.price = 25000 ITEM.weight = 6
Class = require "lib.hump.class" Entity = require "entity" Portal = Class{__includes = Entity, init = function(self, x, y) Entity.init(self, x, y) self.type = "portal" self.l = x-26 self.t = y-26 self.w = 52 self.h = 52 end, image = love.graphics.newImage("data/img/other/portal.png") } function Portal:update() end function Portal:draw() local x,y = self.position:unpack() love.graphics.setColor(255, 255, 255) love.graphics.draw(self.image, x-32, y-32) Entity.draw(self) end return Portal
local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local server_name = 'dotls' local bin_name = 'dot-language-server' local root_files = { '.git', } configs[server_name] = { default_config = { cmd = { bin_name, '--stdio' }, filetypes = { 'dot' }, root_dir = function(fname) return util.root_pattern(unpack(root_files))(fname) or util.path.dirname(fname) end, }, docs = { description = [[ https://github.com/nikeee/dot-language-server `dot-language-server` can be installed via `npm`: ```sh npm install -g dot-language-server ``` ]], }, }
---False in some locale specific files. ---@type boolean TIME_UTIL_WHITE_SPACE_STRIPPABLE = true ---@type number SECONDS_PER_MIN = 0 ---@type number SECONDS_PER_HOUR = 0 ---@type number SECONDS_PER_DAY = 0 ---@type number SECONDS_PER_MONTH = 0 ---@type number SECONDS_PER_YEAR = 0 ---@param seconds number ---@return number ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsToMinutes) function SecondsToMinutes(seconds) end ---@param minutes number ---@return number ---[FrameXML](https://www.townlong-yak.com/framexml/go/MinutesToSeconds) function MinutesToSeconds(minutes) end ---@param testTime number Time in seconds since the Unix epoch ---@param amountOfTime number Amount of time in seconds ---@return boolean ---[FrameXML](https://www.townlong-yak.com/framexml/go/HasTimePassed) function HasTimePassed(testTime, amountOfTime) end ---Seconds formatter to standardize representations of seconds ---[FrameXML](https://www.townlong-yak.com/framexml/live/TimeUtil.lua) SecondsFormatter = {}; ---[FrameXML](https://www.townlong-yak.com/framexml/live/TimeUtil.lua) SecondsFormatter.Abbreviation = { None = 1, Truncate = 2, OneLetter = 3, } ---[FrameXML](https://www.townlong-yak.com/framexml/live/TimeUtil.lua) SecondsFormatter.Interval = { Seconds = 1, Minutes = 2, Hours = 3, Days = 4, } ---@class IntervalDescription_Subtable:table ---@field seconds number ---@field formatString string[] local IntervalDescription_Subtable = {} ---@type table<number, IntervalDescription_Subtable> ---[FrameXML](https://www.townlong-yak.com/framexml/live/TimeUtil.lua) SecondsFormatter.IntervalDescription = { [1] = {}, [2] = {}, [3] = {}, [4] = {} } ---@class SecondsFormatterMixin ---@field approximationSeconds number|nil ---@field defaultAbbreviation number|nil ---@field roundUpLastUnit boolean|nil ---@field stripIntervalWhitespace boolean|nil ---@field convertToLower boolean|nil ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin) SecondsFormatterMixin = {} ---@param approximationSeconds number Threshold for representing the seconds as an approximation (ex. "≤ 2 hours"). ---@param defaultAbbreviation number The default abbreviation for the format. Can be overrridden in `SecondsFormatterMixin:Format()`. Use one of `SecondsFormatter.Abbreviation` ---@param roundUpLastUnit boolean Determines if the last unit in the output format string is ceiled (floored by default). ---@param convertToLower boolean Converts the format string to lowercase. ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:Init) function SecondsFormatterMixin:Init(approximationSeconds, defaultAbbreviation, roundUpLastUnit, convertToLower) end ---@param strip boolean ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:SetStripIntervalWhitespace) function SecondsFormatterMixin:SetStripIntervalWhitespace(strip) end ---@return boolean ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetStripIntervalWhitespace) function SecondsFormatterMixin:GetStripIntervalWhitespace() end ---@return number ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetMaxInterval) function SecondsFormatterMixin:GetMaxInterval() end ---@param interval number Use one of `SecondsFormatter.Interval` ---@return IntervalDescription_Subtable ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetIntervalDescription) function SecondsFormatterMixin:GetIntervalDescription(interval) end ---@param interval number Use one of `SecondsFormatter.Interval` ---@return number|nil ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetIntervalSeconds) function SecondsFormatterMixin:GetIntervalSeconds(interval) end ---@param seconds number ---@return boolean ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:CanApproximate) function SecondsFormatterMixin:CanApproximate(seconds) end ---@return number ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetDefaultAbbreviation) function SecondsFormatterMixin:GetDefaultAbbreviation() end ---@return number ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetApproximationSeconds) function SecondsFormatterMixin:GetApproximationSeconds() end ---@return boolean ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:CanRoundUpLastUnit) function SecondsFormatterMixin:CanRoundUpLastUnit() end ---@param seconds number ---@return number ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetDesiredUnitCount) function SecondsFormatterMixin:GetDesiredUnitCount(seconds) end ---@param seconds number ---@return number ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetMinInterval) function SecondsFormatterMixin:GetMinInterval(seconds) end ---@param interval number Use one of `SecondsFormatter.Interval` ---@param abbreviation number Use one of `SecondsFormatter.Abbreviation` ---@param convertToLower? boolean ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:GetFormatString) function SecondsFormatterMixin:GetFormatString(interval, abbreviation, convertToLower) end ---@param abbreviation number Use one of `SecondsFormatter.Abbreviation` ---@param toLower? boolean ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:FormatZero) function SecondsFormatterMixin:FormatZero(abbreviation, toLower) end ---@param millseconds number ---@param abbreviation? number Use one of `SecondsFormatter.Abbreviation` ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:FormatMillseconds) function SecondsFormatterMixin:FormatMillseconds(millseconds, abbreviation) end ---@param seconds number ---@param abbreviation? number Use one of `SecondsFormatter.Abbreviation` ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsFormatterMixin:Format) function SecondsFormatterMixin:Format(seconds, abbreviation) end ---@param seconds number ---@param displayZeroHours? boolean ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsToClock) function SecondsToClock(seconds, displayZeroHours) end ---@param seconds number ---@param noSeconds? boolean ---@param notAbbreviated? boolean ---@param maxCount? number ---@param roundUp? boolean ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsToTime) function SecondsToTime(seconds, noSeconds, notAbbreviated, maxCount, roundUp) end ---@param mins number ---@param hideDays? boolean Only show days if hideDays is false ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/MinutesToTime) function MinutesToTime(mins, hideDays) end ---@param seconds number ---@return string format ---@return number time ---[FrameXML](https://www.townlong-yak.com/framexml/go/SecondsToTimeAbbrev) function SecondsToTimeAbbrev(seconds) end ---@param day number ---@param month number ---@param year number ---@return string ---[FrameXML](https://www.townlong-yak.com/framexml/go/FormatShortDate) function FormatShortDate(day, month, year) end
local treesitter = {} function treesitter.config() require("nvim-treesitter.configs").setup({ highlight = { enable = true, disable = function(_, _) return vim.bo.filetype == "yaml.ansible" end, }, indent = { enable = true, disable = { "yaml" }, }, incremental_selection = { enable = true, keymaps = { init_selection = "<C-S>", node_incremental = "<C-S>", scope_incremental = "<M-s>", node_decremental = "<C-Q>", }, }, }) end return treesitter
--[[-- Base stream handler class. A stream handler provides a way to deal with an input stream asynchronously. Basicaly it consists in a function that will be called when data is available. If the stream ends then the data function is called with no data allowing to execute specific steps. If the stream has an issue then the error function is called. Streams classes are mainly used by @{jls.net.TcpClient|TCP} @{jls.net.UdpSocket|UDP} protocols. @module jls.io.streams.StreamHandler @pragma nostrip @usage local std = StreamHandler:new(function(self, data) if data then io.stdout:write(data) end end, function(self, err) io.stderr:write(err or 'Stream error') end) -- or local std = StreamHandler:new(function(err, data) if err then io.stderr:write(tostring(err)) elseif data then io.stdout:write(data) end end) ]] local class = require('jls.lang.class') local function onDataCallback(self, data) return self.cb(nil, data) end local function onErrorCallback(self, err) self.cb(err or 'Unspecified error') end --- A StreamHandler class. -- This class could be inherited to process a data stream. -- @type StreamHandler local StreamHandler = class.create(function(streamHandler) --- Creates a stream handler. -- The optional functions take two parameters, the stream and the data or the error -- @tparam[opt] function onDataOrCallback a function to use when receiving data or callback if onError is not specified. -- @tparam[opt] function onError a function to use in case of error. -- @function StreamHandler:new function streamHandler:initialize(onDataOrCallback, onError) if type(onDataOrCallback) == 'function' then if type(onError) == 'function' then self.onData = onDataOrCallback self.onError = onError else self.cb = onDataOrCallback self.onData = onDataCallback self.onError = onErrorCallback end end end --- The specified data is available for this stream. -- @param data the new data to process, nil to indicate the end of the stream. -- @treturn boolean false to indicate that this handler has finish to process the stream. function streamHandler:onData(data) end --- The specified error occured on this stream. -- @param err the error that occured on this stream. function streamHandler:onError(err) end --- Closes this stream handler. -- Do nothing by default. Must support to be called multiple times. function streamHandler:close() end --- Returns this stream handler as a callback function. -- The callback function has two arguments: the error and the data. -- The data could be nil indicating the end of the stream. -- @treturn function the callback function function streamHandler:toCallback() if not self.cb then self.cb = function(err, data) if err then self:onError(err) else return self:onData(data) end end end return self.cb end end) -- This class allows to stream to two streams. -- @type BiStreamHandler local BiStreamHandler = class.create(StreamHandler, function(biStreamHandler, super) -- Creates a @{StreamHandler} with two streams. -- @function BiStreamHandler:new function biStreamHandler:initialize(firstStream, secondStream) super.initialize(self) self.firstStream = StreamHandler.ensureStreamHandler(firstStream) self.secondStream = StreamHandler.ensureStreamHandler(secondStream) end function biStreamHandler:onData(data) local r if self.firstStream:onData(data) == false then r = false end if self.secondStream:onData(data) == false then r = false end return r end function biStreamHandler:onError(err) self.firstStream:onError(err) self.secondStream:onError(err) end function biStreamHandler:close() self.firstStream:close() self.secondStream:close() end end) -- This class allows to stream to multiple streams. -- @type MultipleStreamHandler local MultipleStreamHandler = class.create(StreamHandler, function(multipleStreamHandler, super) -- Creates a @{StreamHandler} with multiple streams. -- @function MultipleStreamHandler:new function multipleStreamHandler:initialize(...) super.initialize(self) self.streams = {...} end function multipleStreamHandler:onData(data) local r for _, stream in ipairs(self.streams) do if stream:onData(data) == false then r = false end end return r end function multipleStreamHandler:onError(err) for _, stream in ipairs(self.streams) do stream:onError(err) end end function multipleStreamHandler:close() for _, stream in ipairs(self.streams) do stream:close() end end end) --- Returns a callback function. -- @param cb a callback function or a StreamHandler. -- @tparam[opt] boolean lazy true to indicate that nil values are valid. -- @treturn function a callback function. function StreamHandler.ensureCallback(cb, lazy) if type(cb) == 'function' then return cb elseif StreamHandler:isInstance(cb) then return cb:toCallback() elseif not lazy or cb ~= nil then error('Invalid argument') end end -- This class allows to wrap a callback function into a stream. local CallbackStreamHandler = class.create(StreamHandler, function(callbackStreamHandler) -- Creates a @{StreamHandler} based on a callback. -- @tparam function cb the callback -- @function CallbackStreamHandler:new function callbackStreamHandler:initialize(cb) --super.initialize(self, cb) self.cb = cb end callbackStreamHandler.onData = onDataCallback callbackStreamHandler.onError = onErrorCallback function callbackStreamHandler:toCallback() return self.cb end end) StreamHandler.CallbackStreamHandler = CallbackStreamHandler --- Returns a StreamHandler. -- @param sh a callback function or a StreamHandler. -- @return a StreamHandler. function StreamHandler.ensureStreamHandler(sh) if type(sh) == 'function' then return CallbackStreamHandler:new(sh) elseif StreamHandler:isInstance(sh) then return sh else error('Invalid argument (type is '..type(sh)..')') end end --- Fills the specified StreamHandler with the specified data. -- This is shortcut for sh:onData(data); sh:onData(nil) -- @tparam StreamHandler sh the StreamHandler to fill. -- @tparam string data the data to process. function StreamHandler.fill(sh, data) if data then sh:onData(data) end sh:onData(nil) end function StreamHandler.bi(...) return BiStreamHandler:new(...) end function StreamHandler.multiple(...) local firstStream, secondStream, thirdStream = ... if thirdStream then return MultipleStreamHandler:new(...) elseif secondStream then return BiStreamHandler:new(firstStream, secondStream) end return firstStream end --- The standard stream writing data to standard output and error to standard error. StreamHandler.std = StreamHandler:new(function(err, data) if err then io.stderr:write(tostring(err)) elseif data then io.stdout:write(data) end end) --- A null stream. StreamHandler.null = StreamHandler:new() return StreamHandler
/run local a,b={4903,4941,4974,6566,6567,6568,6569,6570,6584,6582,6583,6585,6601,6602}for i=1,#a do b=IsQuestFlaggedCompleted(a[i]) print(i.." ("..a[i].."):",b and "\124cFF00FF00" or "\124cFFFF0000Not","Done")end
object_tangible_holiday_empire_day_shared_painting_empire_day_2010_rebel = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_painting_empire_day_2010_rebel.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_painting_empire_day_2010_rebel, "object/tangible/holiday/empire_day/shared_painting_empire_day_2010_rebel.iff") object_tangible_holiday_empire_day_shared_imperial_recruitment_poster = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_imperial_recruitment_poster.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_imperial_recruitment_poster, "object/tangible/holiday/empire_day/shared_imperial_recruitment_poster.iff") object_tangible_holiday_empire_day_shared_imperial_recruitment_poster_defaced = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_imperial_recruitment_poster_defaced.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_imperial_recruitment_poster_defaced, "object/tangible/holiday/empire_day/shared_imperial_recruitment_poster_defaced.iff") object_tangible_holiday_empire_day_shared_rebel_resistance_poster_torn = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_rebel_resistance_poster_torn.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_rebel_resistance_poster_torn, "object/tangible/holiday/empire_day/shared_rebel_resistance_poster_torn.iff") object_tangible_holiday_empire_day_shared_painting_empire_day_2011_rebel = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_painting_empire_day_2011_rebel.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_painting_empire_day_2011_rebel, "object/tangible/holiday/empire_day/shared_painting_empire_day_2011_rebel.iff") object_tangible_holiday_empire_day_shared_painting_empire_day_2011_imperial = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_painting_empire_day_2011_imperial.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_painting_empire_day_2011_imperial, "object/tangible/holiday/empire_day/shared_painting_empire_day_2011_imperial.iff") object_tangible_holiday_empire_day_shared_wedge_antilles_poster = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_wedge_antilles_poster.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_wedge_antilles_poster, "object/tangible/holiday/empire_day/shared_wedge_antilles_poster.iff") object_tangible_holiday_empire_day_shared_rebel_resistance_poster = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_rebel_resistance_poster.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_rebel_resistance_poster, "object/tangible/holiday/empire_day/shared_rebel_resistance_poster.iff") object_tangible_holiday_empire_day_shared_remembrance_day_rebel_banner = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_remembrance_day_rebel_banner.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_remembrance_day_rebel_banner, "object/tangible/holiday/empire_day/shared_remembrance_day_rebel_banner.iff") object_tangible_holiday_empire_day_shared_painting_empire_day_2010_imperial = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_painting_empire_day_2010_imperial.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_painting_empire_day_2010_imperial, "object/tangible/holiday/empire_day/shared_painting_empire_day_2010_imperial.iff") object_tangible_holiday_empire_day_shared_return_of_the_jedi_painting = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_return_of_the_jedi_painting.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_return_of_the_jedi_painting, "object/tangible/holiday/empire_day/shared_return_of_the_jedi_painting.iff") object_tangible_holiday_empire_day_shared_mara_jade_poster = SharedTangibleObjectTemplate:new { clientTemplateFileName = "object/tangible/holiday/empire_day/shared_mara_jade_poster.iff" } ObjectTemplates:addClientTemplate(object_tangible_holiday_empire_day_shared_mara_jade_poster, "object/tangible/holiday/empire_day/shared_mara_jade_poster.iff")
BaseProject "App" files { "**.cpp", "**.h" } links { "lua51", "RTTI", "Utility" } includedirs { ".", "..", "../../Externals/LuaJit/LuaJIT/_build/include" } libdirs { "../../Externals/LuaJit/LuaJIT/_build/lib/lua/5.1" }
--[[ aka - Per directory shell aliases ]] --------------------------------------------------------------------- local io_write = io.write local str_fmt = string.format local str_rep = string.rep local table_concat = table.concat --------------------------------------------------------------------- local _M = {} --------------------------------------------------------------------- _M.CFG_FILE = '.aka' --------------------------------------------------------------------- -- Returns all available CLI options -- function _M.get_available_opts() return { help = {'-h', '--help'}, list = {'-l', '--list'}, } end -- Returns CLI option which matches one of the available options defined -- in `get_available_opts` function -- function _M.get_opt(args) if #args == 1 then -- option can only be a single argument for opt_label, opts in pairs(_M.get_available_opts()) do for _, opt in pairs(opts) do if opt == args[1] then return opt_label end end end end return nil end -- Calls aka module function with the following name: `run_{opt_name}_opt` -- function _M.run_opt(t) return _M['run_' .. t.opt .. '_opt'](t) end -- Prints help message -- function _M.run_help_opt(t) return _M.print_help() end -- Prints all available aliases found in the configuration file -- function _M.run_list_opt(t) local opt = t.opt local cfg = t.config local n = 0 print('Listing all aka aliases...\n') print(str_rep('-', 40)) local list_recur = function(cfg, list_recur) local indent = function() for i = 1, n do io_write(' ') end end for k, v in pairs(cfg) do if type(v) == 'table' then indent() print('- [' .. k .. ']') n = n + 1 list_recur(v, list_recur) else indent() print(str_fmt('- [%s = \'%s\']', tostring(k), tostring(v))) end end n = n - 1 end for k, v in pairs(cfg) do if type(v) == 'table' then print('[' .. k .. ']') n = n + 1 list_recur(v, list_recur) else print(str_fmt('[%s = \'%s\']', tostring(k), tostring(v))) end end print(str_rep('-', 40)) print('') end -- Returns the alias specified by the command line argument if there is -- a match with the configuration file entries. -- -- Returns nil if unable to find a matched alias. -- function _M.get_cmd(cfg, args, idx) if not idx then idx = 1 end local val = cfg[args[idx]] if val then if type(val) == 'table' then -- continue searching deeper return _M.get_cmd(val, args, idx + 1) else -- we found the match, let's check for input arguments local input_args = {} for i = idx + 1, #args do -- skip the arguments used for alias match input_args[#input_args + 1] = ' ' .. args[i] end -- Return cmd and append input arguments if they exist return val .. table_concat(input_args) end end -- Verify that number of arguments match return (idx == #args) and val or nil end -- Prints error message to the screen -- function _M.print_err(err) print(str_fmt('aka: %s\nSee \'aka -h\' or \'aka --help\'', err)) end -- Prints usage message to the screen -- function _M.print_help() print [[ aka - per directory shell aliases Usage: aka alias [sub_alias sub_sub_alias ...] aka -l|--list aka -h|--help Options: -l, --list List all aliases -h, --help Print usage ]] end --------------------------------------------------------------------- return _M
function CDefender_OnEnterCombat(Unit,Event) Unit:RegisterEvent("CDefender_Spell1", 7000, 0) Unit:RegisterEvent("CDefender_Spell2", 16000, 0) end function CDefender_Spell1(Unit,Event) Unit:FullCastSpellOnTarget(38233,Unit:GetClosestPlayer()) end function CDefender_Spell2(Unit,Event) Unit:FullCastSpellOnTarget(38031,Unit:GetClosestPlayer()) end function CDefender_OnLeaveCombat(Unit,Event) Unit:RemoveEvents() end function CDefender_OnDied(Unit,Event) Unit:RemoveEvents() end RegisterUnitEvent(19762, 1, "CDefender_OnEnterCombat") RegisterUnitEvent(19762, 2, "CDefender_OnLeaveCombat") RegisterUnitEvent(19762, 4, "CDefender_OnDied")
format_version = "1.0" rtc_bindings = { { source = "/environment/system_sample_rate", dest = "/global_rtc/init_instance" }, { source = "/environment/instance_id", dest = "/global_rtc/init_instance" } } global_rtc = { init_instance = function(source_property_path, instance_id) local new_no = jbox.make_native_object_rw("Instance", {instance_id}) jbox.store_property("/custom_properties/instance", new_no); end } sample_rate_setup = { native = { 22050, 44100, 48000, 88200, 96000, 192000 }, } local notes = { "/custom_properties/GAIN", "/transport/request_reset_audio", "/environment/system_sample_rate", "/audio_inputs/AudioInL/connected", "/audio_inputs/AudioInR/connected", "/audio_outputs/AudioOutL/connected", "/audio_outputs/AudioOutR/connected", } for N = 1,4 do table.insert(notes,"/custom_properties/BYPASS"..N) table.insert(notes,"/custom_properties/DELAY"..N) table.insert(notes,"/custom_properties/DRY_WET"..N) table.insert(notes,"/custom_properties/CONNECT"..N) table.insert(notes,"/audio_inputs/AudioInL"..N.."/connected") table.insert(notes,"/audio_inputs/AudioInR"..N.."/connected") table.insert(notes,"/audio_outputs/AudioOutL"..N.."/connected") table.insert(notes,"/audio_outputs/AudioOutR"..N.."/connected") end for k,v in pairs(notes) do jbox.trace("Making RT notifier for "..v) end rt_input_setup = { notify = notes }
-- Some aliases for compatibility switches and some to make "/give" commands -- a little easier minetest.register_alias("snow:needles", "default:pine_needles") minetest.register_alias("snow:snow", "default:snow") minetest.register_alias("default_snow", "default:snow") minetest.register_alias("snow:snowball", "default:snow") minetest.register_alias("snowball", "default:snow") minetest.register_alias("snowballs", "default:snow") minetest.register_alias("snow_ball", "default:snow") minetest.register_alias("snow:ice", "default:ice") minetest.register_alias("ice", "default:ice") minetest.register_alias("default_ice", "default:ice") minetest.register_alias("snow:dirt_with_snow", "default:dirt_with_snow") minetest.register_alias("dirtwithsnow", "default:dirt_with_snow") minetest.register_alias("snowdirt", "default:dirt_with_snow") minetest.register_alias("snowydirt", "default:dirt_with_snow") minetest.register_alias("snow:snow_block", "default:snowblock") minetest.register_alias("default:snow_block", "default:snowblock") minetest.register_alias("snowblocks", "default:snowblock") minetest.register_alias("snowbrick", "snow:snow_brick") minetest.register_alias("bricksnow", "snow:snow_brick") minetest.register_alias("snowbricks", "snow:snow_brick") minetest.register_alias("snowybricks", "snow:snow_brick") minetest.register_alias("icysnow", "snow:snow_cobble") minetest.register_alias("snowcobble", "snow:snow_cobble") minetest.register_alias("snowycobble", "snow:snow_cobble") minetest.register_alias("cobblesnow", "snow:snow_cobble") minetest.register_alias("snow:leaves", "default:pine_needles") minetest.register_alias("snow:sapling_pine", "default:pine_sapling") -- To clean up my first stairsplus attempt. -- Stair minetest.register_alias(":default:stair_snowblock", "moreblocks:stair_snowblock") minetest.register_alias(":default:stair_snowblock_half", "moreblocks:stair_snowblock_half") minetest.register_alias(":default:stair_snowblock_right_half", "moreblocks:stair_snowblock_right_half") minetest.register_alias(":default:stair_snowblock_inner", "moreblocks:stair_snowblock_inner") minetest.register_alias(":default:stair_snowblock_outer", "moreblocks:stair_snowblock_outer") minetest.register_alias(":default:stair_snowblock_alt", "moreblocks:stair_snowblock_alt") minetest.register_alias(":default:stair_snowblock_alt_1", "moreblocks:stair_snowblock_alt_1") minetest.register_alias(":default:stair_snowblock_alt_2", "moreblocks:stair_snowblock_2") minetest.register_alias(":default:stair_snowblock_alt_4", "moreblocks:stair_snowblock_alt_4") minetest.register_alias(":default:stair_ice", "moreblocks:stair_ice") minetest.register_alias(":default:stair_ice_half", "moreblocks:stair_ice_half") minetest.register_alias(":default:stair_ice_right_half", "moreblocks:stair_ice_right_half") minetest.register_alias(":default:stair_ice_inner", "moreblocks:stair_ice_inner") minetest.register_alias(":default:stair_ice_outer", "moreblocks:stair_ice_outer") minetest.register_alias(":default:stair_ice_alt", "moreblocks:stair_ice_alt") minetest.register_alias(":default:stair_ice_alt_1", "moreblocks:stair_ice_alt_1") minetest.register_alias(":default:stair_ice_alt_2", "moreblocks:stair_ice_2") minetest.register_alias(":default:stair_ice_alt_4", "moreblocks:stair_ice_alt_4") -- Slab minetest.register_alias(":default:slab_snowblock", "moreblocks:slab_snowblock") minetest.register_alias(":default:slab_snowblock_quarter", "moreblocks:slab_snowblock_quarter") minetest.register_alias(":default:slab_snowblock_three_quarter", "moreblocks:slab_snowblock_three_quarter") minetest.register_alias(":default:slab_snowblock_1", "moreblocks:slab_snowblock_1") minetest.register_alias(":default:slab_snowblock_2", "moreblocks:slab_snowblock_2") minetest.register_alias(":default:slab_snowblock_14", "moreblocks:slab_snowblock_14") minetest.register_alias(":default:slab_snowblock_15", "moreblocks:slab_snowblock_15") minetest.register_alias(":default:slab_ice", "moreblocks:slab_ice") minetest.register_alias(":default:slab_ice_quarter", "moreblocks:slab_ice_quarter") minetest.register_alias(":default:slab_ice_three_quarter", "moreblocks:slab_ice_three_quarter") minetest.register_alias(":default:slab_ice_1", "moreblocks:slab_ice_1") minetest.register_alias(":default:slab_ice_2", "moreblocks:slab_ice_2") minetest.register_alias(":default:slab_ice_14", "moreblocks:slab_ice_14") minetest.register_alias(":default:slab_ice_15", "moreblocks:slab_ice_15") -- Panel minetest.register_alias(":default:panel_snowblock", "moreblocks:panel_snowblock") minetest.register_alias(":default:panel_snowblock_1", "moreblocks:panel_snowblock_1") minetest.register_alias(":default:panel_snowblock_2", "moreblocks:panel_snowblock_2") minetest.register_alias(":default:panel_snowblock_4", "moreblocks:panel_snowblock_4") minetest.register_alias(":default:panel_snowblock_12", "moreblocks:panel_snowblock_12") minetest.register_alias(":default:panel_snowblock_14", "moreblocks:panel_snowblock_14") minetest.register_alias(":default:panel_snowblock_15", "moreblocks:panel_snowblock_15") minetest.register_alias(":default:panel_ice", "moreblocks:panel_ice") minetest.register_alias(":default:panel_ice_1", "moreblocks:panel_ice_1") minetest.register_alias(":default:panel_ice_2", "moreblocks:panel_ice_2") minetest.register_alias(":default:panel_ice_4", "moreblocks:panel_ice_4") minetest.register_alias(":default:panel_ice_12", "moreblocks:panel_ice_12") minetest.register_alias(":default:panel_ice_14", "moreblocks:panel_ice_14") minetest.register_alias(":default:panel_ice_15", "moreblocks:panel_ice_15") -- Micro minetest.register_alias(":default:micro_snowblock", "moreblocks:micro_snowblock") minetest.register_alias(":default:micro_snowblock_1", "moreblocks:micro_snowblock_1") minetest.register_alias(":default:micro_snowblock_2", "moreblocks:micro_snowblock_2") minetest.register_alias(":default:micro_snowblock_4", "moreblocks:micro_snowblock_4") minetest.register_alias(":default:micro_snowblock_12", "moreblocks:micro_snowblock_12") minetest.register_alias(":default:micro_snowblock_14", "moreblocks:micro_snowblock_14") minetest.register_alias(":default:micro_snowblock_15", "moreblocks:micro_snowblock_15") minetest.register_alias(":default:micro_ice", "moreblocks:micro_ice") minetest.register_alias(":default:micro_ice_1", "moreblocks:micro_ice_1") minetest.register_alias(":default:micro_ice_2", "moreblocks:micro_ice_2") minetest.register_alias(":default:micro_ice_4", "moreblocks:micro_ice_4") minetest.register_alias(":default:micro_ice_12", "moreblocks:micro_ice_12") minetest.register_alias(":default:micro_ice_14", "moreblocks:micro_ice_14") minetest.register_alias(":default:micro_ice_15", "moreblocks:micro_ice_15")
local responses = require "kong.tools.responses" local constants = require "kong.constants" local singletons = require "kong.singletons" local mysql = require "resty.mysql" local match = string.match local lower = string.lower local find = string.find local sub = string.sub local ngx_log = ngx.log local request = ngx.req local ngx_error = ngx.ERR local ngx_debug = ngx.DEBUG local ngx_warn = ngx.WARN local decode_base64 = ngx.decode_base64 local ngx_socket_tcp = ngx.socket.tcp local ngx_set_header = ngx.req.set_header local tostring = tostring local AUTHORIZATION = "authorization" local PROXY_AUTHORIZATION = "proxy-authorization" local _M = {} local function retrieve_credentials(authorization_header_value, conf) local username, password if authorization_header_value then local s, e = find(lower(authorization_header_value), "^%s*" .. lower(conf.header_type) .. "%s+") if s == 1 then local cred = sub(authorization_header_value, e + 1) local decoded_cred = decode_base64(cred) username, password = match(decoded_cred, "([^\n]+):([^\n]+)") end end return username, password end local function db_authenticate(given_username, given_password, conf) local is_authenticated local err, suppressed_err, ok -- to prevent sql injections --local name = ngx.unescape_uri(ngx.var.arg_name) --local quoted_name = ngx.quote_sql_str(name) --local sql = "select * from users where name = " .. quoted_name -- local sock = ngx_socket_tcp() -- sock:settimeout(conf.timeout) -- ok, err = sock:connect(conf.db_host, conf.db_port) -- if not ok then -- ngx_log(ngx_error, "[dbauthenticate] failed to connect to " .. conf.db_host .. ":" .. tostring(conf.db_port) .. ": ", err) -- return nil, err -- end -- -- if conf.start_tls then -- local success, err = mysql.start_tls(sock) -- if not success then -- return false, err -- end -- local _, err = sock:sslhandshake(true, conf.db_host, conf.verify_db_host) -- if err ~= nil then -- return false, "failed to do SSL handshake with " .. conf.db_host .. ":" .. tostring(conf.db_port) .. ": " .. err -- end -- end -- -- is_authenticated, err = mysql.bind_request(sock, who, given_password) -- -- ok, suppressed_err = sock:setkeepalive(conf.keepalive) local db, err = mysql:new() if not db then ngx_log(ngx_warn, "[dbauthenticate] failed to instantiate mysql: ", err) return is_authenticated, err end db:set_timeout(1000) -- 1 sec -- or connect to a unix domain socket file listened -- by a mysql server: -- local ok, err, errcode, sqlstate = -- db:connect{ -- path = "/path/to/mysql.sock", -- database = "ngx_test", -- user = "ngx_test", -- password = "ngx_test" } local ok, err, errcode, sqlstate = db:connect{ host = conf.db_host, port = conf.db_port, database = conf.db_name, user = conf.db_user, password = conf.db_passwd, charset = "utf8", max_packet_size = 1024 * 1024, } if not ok then ngx_log(ngx_warn, "[dbauthenticate] failed to connect: ", err, ": ", errcode, " ", sqlstate) return is_authenticated, err end ngx_log(ngx_debug, "[dbauthenticate] connected to mysql.") -- local res, err, errcode, sqlstate = db:query("drop table if exists cats") -- if not res then -- ngx.say("bad result: ", err, ": ", errcode, ": ", sqlstate, ".") -- return -- end -- -- res, err, errcode, sqlstate = db:query("create table cats " -- .. "(id serial primary key, " -- .. "name varchar(5))") -- if not res then -- ngx.say("bad result: ", err, ": ", errcode, ": ", sqlstate, ".") -- return -- end -- -- ngx.say("table cats created.") -- -- res, err, errcode, sqlstate = -- db:query("insert into cats (name) " -- .. "values (\'Bob\'),(\'\'),(null)") -- if not res then -- ngx.say("bad result: ", err, ": ", errcode, ": ", sqlstate, ".") -- return -- end -- -- ngx.say(res.affected_rows, " rows inserted into table cats ", -- "(last insert id: ", res.insert_id, ")") -- run a select query, expected about 10 rows in -- the result set: local query = "select * from " .. conf.db_user_table .. " where " .. conf.db_username_column .. "=\'" .. given_username .. "\' and " .. conf.db_passwd_column .. "=\'" .. given_password .. "\'" ngx_log(ngx.INFO, "pwd : _____" .. given_password .. "____") local res, err, errcode, sqlstate = db:query(query, 10) local cjson = require "cjson" ngx_log(ngx.INFO, "[dbauthenticate] result '", cjson.encode(res), "'") ngx_log(ngx.INFO, "[dbauthenticate] query __ ", query, " __") if not res then ngx_log(ngx_warn, "[dbauthenticate] bad result: ", err, ": ", errcode, ": ", sqlstate, ".") is_authenticated = false else if next(res) == nil then ngx_log(ngx.INFO, "[dbauthenticate] login failed with username '", given_username, "'") is_authenticated = false else ngx_log(ngx.DEBUG, "[dbauthenticate] login succeed with username '", given_username, "'") is_authenticated = true end end -- put it into the connection pool of size 100, -- with 10 seconds max idle timeout local ok, err = db:set_keepalive(10000, 100) if not ok then ngx_log(ngx_warn, "[dbauthenticate] failed to set keepalive: ", err) return is_authenticated, err end -- or just close the connection right away: -- local ok, err = db:close() -- if not ok then -- ngx.say("failed to close: ", err) -- return -- end return is_authenticated, err end local function load_credential(given_username, given_password, conf) ngx_log(ngx_debug, "[dbauthenticate] authenticating user against LDAP server: " .. conf.db_host .. ":" .. conf.db_port) local ok, err = db_authenticate(given_username, given_password, conf) if err ~= nil then ngx_log(ngx_error, err) end if ok == nil then return nil end if ok == false then return false end return {username = given_username, password = given_password} end local function authenticate(conf, given_credentials) local given_username, given_password = retrieve_credentials(given_credentials, conf) if given_username == nil then return false end local cache_key = "dbauthenticate_cache:" .. ngx.ctx.api.id .. ":" .. given_username local credential, err = singletons.cache:get(cache_key, { ttl = conf.cache_ttl, neg_ttl = conf.cache_ttl, }, load_credential, given_username, given_password, conf) if err or credential == nil then return responses.send_HTTP_INTERNAL_SERVER_ERROR(err) end return credential and credential.password == given_password, credential end local function load_consumer(consumer_id, anonymous) local result, err = singletons.dao.consumers:find { id = consumer_id } if not result then if anonymous and not err then err = 'anonymous consumer "' .. consumer_id .. '" not found' end return nil, err end return result end local function set_consumer(consumer, credential) if consumer then -- this can only be the Anonymous user in this case ngx_set_header(constants.HEADERS.CONSUMER_ID, consumer.id) ngx_set_header(constants.HEADERS.CONSUMER_CUSTOM_ID, consumer.custom_id) ngx_set_header(constants.HEADERS.CONSUMER_USERNAME, consumer.username) ngx_set_header(constants.HEADERS.ANONYMOUS, true) ngx.ctx.authenticated_consumer = consumer return end -- here we have been authenticated by db ngx_set_header(constants.HEADERS.CREDENTIAL_USERNAME, credential.username) ngx.ctx.authenticated_credential = credential -- in case of auth plugins concatenation, remove remnants of anonymous ngx.ctx.authenticated_consumer = nil ngx_set_header(constants.HEADERS.ANONYMOUS, nil) ngx_set_header(constants.HEADERS.CONSUMER_ID, nil) ngx_set_header(constants.HEADERS.CONSUMER_CUSTOM_ID, nil) ngx_set_header(constants.HEADERS.CONSUMER_USERNAME, nil) end local function do_authentication(conf) local headers = request.get_headers() local authorization_value = headers[AUTHORIZATION] local proxy_authorization_value = headers[PROXY_AUTHORIZATION] -- If both headers are missing, return 401 if not (authorization_value or proxy_authorization_value) then ngx.header["WWW-Authenticate"] = 'LDAP realm="kong"' return false, {status = 401} end local is_authorized, credential = authenticate(conf, proxy_authorization_value) if not is_authorized then is_authorized, credential = authenticate(conf, authorization_value) end if not is_authorized then return false, {status = 403, message = "Invalid authentication credentials"} end if conf.hide_credentials then request.clear_header(AUTHORIZATION) request.clear_header(PROXY_AUTHORIZATION) end set_consumer(nil, credential) return true end function _M.execute(conf) if ngx.ctx.authenticated_credential and conf.anonymous ~= "" then -- we're already authenticated, and we're configured for using anonymous, -- hence we're in a logical OR between auth methods and we're already done. return end local ok, err = do_authentication(conf) if not ok then if conf.anonymous ~= "" then -- get anonymous user local consumer_cache_key = singletons.dao.consumers:cache_key(conf.anonymous) local consumer, err = singletons.cache:get(consumer_cache_key, nil, load_consumer, conf.anonymous, true) if err then responses.send_HTTP_INTERNAL_SERVER_ERROR(err) end set_consumer(consumer, nil) else return responses.send(err.status, err.message) end end end return _M
---------------------------------------------------------- -- Load RayUI Environment ---------------------------------------------------------- RayUI:LoadEnv("Bags") local B = R:NewModule("Bags", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0") local S = R.Skins local cargBags = _cargBags local consumable = AUCTION_CATEGORY_CONSUMABLES B.modName = L["背包"] _Bags = B function B:Tooltip_Show() GameTooltip:SetOwner(self, "ANCHOR_TOP", 0, 4) GameTooltip:ClearLines() GameTooltip:AddLine(self.ttText) if self.ttText2 then GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine(self.ttText2, self.ttText2desc, 1, 1, 1) end GameTooltip:Show() end function B:Tooltip_Hide() GameTooltip:Hide() end function B:OpenBags() cargBags.blizzard:Show() end function B:CloseBags() cargBags.blizzard:Hide() end -- local equipSetTip = CreateFrame("GameTooltip", "RayUICheckEquipSetTip", R.UIParent, "GameTooltipTemplate") local function CheckEquipmentSet(item) if not item.bagID or not item.slotID then return false end -- equipSetTip:SetOwner(R.UIParent, "ANCHOR_NONE") -- equipSetTip:ClearLines() -- equipSetTip:SetBagItem(item.bagID, item.slotID) -- equipSetTip:Show() -- -- for index = 1, equipSetTip:NumLines() do -- if string.match(_G["RayUICheckEquipSetTipTextLeft" .. index]:GetText(), string.gsub(EQUIPMENT_SETS,"%%s\124r","")) then -- return true -- end -- end return item.isInSet end function B:IsConsumableItem(item) return item.type == AUCTION_CATEGORY_CONSUMABLES and item.rarity ~= LE_ITEM_QUALITY_POOR end function B:Initialize() if not self.db.enable then return end if B.db.bagWidth > 20 then B.db.bagWidth = 10 end if B.db.bankWidth > 20 then B.db.bankWidth = 12 end local RayUI_ContainerFrame = cargBags:NewImplementation("RayUI_ContainerFrame") -- Let the magic begin! RayUI_ContainerFrame:RegisterBlizzard() -- register the frame for use with BLizzard's ToggleBag()-functions -- A highlight function styles the button if they match a certain condition local function highlightFunction(button, match) button:SetAlpha(match and 1 or 0.1) end local f = {} function RayUI_ContainerFrame:OnInit() -- The filters control which items go into which container local INVERTED = -1 -- with inverted filters (using -1), everything goes into this bag when the filter returns false local onlyBags = function(item) return item.bagID >= BACKPACK_CONTAINER and item.bagID <= NUM_BAG_SLOTS and not CheckEquipmentSet(item) and not B:IsConsumableItem(item) end local onlyBank = function(item) return item.bagID == BANK_CONTAINER or item.bagID >= NUM_BAG_SLOTS+1 and item.bagID <= NUM_BAG_SLOTS + NUM_BANKBAGSLOTS and not CheckEquipmentSet(item) and not B:IsConsumableItem(item) end local onlyReagent = function(item) return item.bagID == REAGENTBANK_CONTAINER end local onlyBagSets = function(item) return CheckEquipmentSet(item) and not (item.bagID == BANK_CONTAINER or item.bagID >= NUM_BAG_SLOTS+1 and item.bagID <= NUM_BAG_SLOTS + NUM_BANKBAGSLOTS) end local onlyBagConsumables = function(item) return B:IsConsumableItem(item) and not (item.bagID == BANK_CONTAINER or item.bagID >= NUM_BAG_SLOTS+1 and item.bagID <= NUM_BAG_SLOTS + NUM_BANKBAGSLOTS) end local onlyBankSets = function(item) return CheckEquipmentSet(item) and not (item.bagID >= BACKPACK_CONTAINER and item.bagID <= NUM_BAG_SLOTS) end local onlyBankConsumables = function(item) return B:IsConsumableItem(item) and not (item.bagID >= BACKPACK_CONTAINER and item.bagID <= NUM_BAG_SLOTS) end local onlyRareEpics = function(item) return item.rarity and item.rarity > 3 end local onlyEpics = function(item) return item.rarity and item.rarity > 3 end local hideJunk = function(item) return not item.rarity or item.rarity > 0 end local hideEmpty = function(item) return item.texture ~= nil end local MyContainer = RayUI_ContainerFrame:GetContainerClass() -- Bagpack f.main = MyContainer:New("Main", { Columns = B.db.bagWidth, Bags = "backpack+bags", Movable = true, }) f.main:SetFilter(onlyBags, true) f.main:SetPoint("BOTTOMRIGHT", R.UIParent, "BOTTOMRIGHT", -55, 30) -- bagpack position -- Bank frame and bank bags f.bank = MyContainer:New("Bank", { Columns = B.db.bankWidth, Bags = "bankframe+bank", }) f.bank:SetFilter(onlyBank, true) -- Take only items from the bank frame f.bank:SetPoint("BOTTOMRIGHT", "RayUI_ContainerFrameMain", "BOTTOMLEFT", -25, 0) -- bank frame position f.bank:Hide() -- Hide at the beginning -- Reagent frame and bank bags f.reagent = MyContainer:New("Reagent", {Columns = B.db.bankWidth, Bags = "bankreagent"}) f.reagent:SetFilter(onlyReagent, true) f.reagent:Hide() f.reagent:SetPoint("BOTTOMRIGHT", "RayUI_ContainerFrameMain", "BOTTOMLEFT", -25, 0) f.consumables = MyContainer:New("Consumables", {Columns = B.db.bagWidth, Bags = "backpack+bags"}) f.consumables:SetFilter(onlyBagConsumables, true) f.consumables:SetParent(f.main) f.consumables:SetPoint("BOTTOMLEFT", f.main,"TOPLEFT", 0, 3) f.sets = MyContainer:New("ItemSets", {Columns = B.db.bagWidth, Bags = "backpack+bags"}) f.sets:SetFilter(onlyBagSets, true) f.sets:SetParent(f.main) f.sets:SetPoint("BOTTOMLEFT", f.consumables,"TOPLEFT", 0, 3) f.bankconsumables = MyContainer:New("BankConsumables", {Columns = B.db.bankWidth, Bags = "backpack+bags"}) f.bankconsumables:SetFilter(onlyBankConsumables, true) f.bankconsumables:SetParent(f.bank) f.bankconsumables:SetPoint("BOTTOMLEFT", f.bank,"TOPLEFT", 0, 3) f.banksets = MyContainer:New("BankItemSets", {Columns = B.db.bankWidth, Bags = "bankframe+bank"}) f.banksets:SetFilter(onlyBankSets, true) f.banksets:SetParent(f.bank) f.banksets:SetPoint("BOTTOMLEFT", f.bankconsumables,"TOPLEFT", 0, 3) end -- Bank frame toggling function RayUI_ContainerFrame:OnBankOpened() BankFrame:Show() self:GetContainer("Bank"):Show() end function RayUI_ContainerFrame:OnBankClosed() BankFrame:Hide() self:GetContainer("Bank"):Hide() self:GetContainer("Reagent"):Hide() ReagentBankFrame:Hide() BankFrame.selectedTab = 1 end -- Class: ItemButton appearencence classification local MyButton = RayUI_ContainerFrame:GetItemButtonClass() MyButton:Scaffold("RayUI") function MyButton:OnUpdate(item) -- color the border based on bag type local bagType = select(2, GetContainerNumFreeSlots(self.bagID)); -- ammo / soulshards if(bagType and (bagType > 0 and bagType < 8)) then self.Border:SetVertexColor(0.85, 0.85, 0.35, 1); -- profession bags elseif(bagType and bagType > 4) then self.Border:SetVertexColor(0.1, 0.65, 0.1, 1); -- normal bags else self.Border:SetVertexColor(.7, .7, .7, .9); end end -- Class: BagButton is the template for all buttons on the BagBar local BagButton = RayUI_ContainerFrame:GetClass("BagButton", true, "BagButton") -- We color the CheckedTexture golden, not bright yellow function BagButton:OnCreate() self:GetCheckedTexture():SetVertexColor(0.3, 0.9, 0.9, 0.5) end -- Class: Container (Serves as a base for all containers/bags) -- Fetch our container class that serves as a basis for all our containers/bags local UpdateDimensions = function(self) local width, height = self:LayoutButtons("grid", self.Settings.Columns, 3, 6, -45) --local width, height = self:GetWidth(), self:GetHeight() local margin = 60 -- Normal margin space for infobar if self.BagBar and self.BagBar:IsShown() then margin = margin + 40 -- Bag button space end self:SetHeight(height + margin) end local MyContainer = RayUI_ContainerFrame:GetContainerClass() function MyContainer:OnContentsChanged() -- sort our buttons based on the slotID self:SortButtons("bagSlot") -- Order the buttons in a layout, ("grid", columns, spacing, xOffset, yOffset) or ("circle", radius (optional), xOffset, yOffset) local width, height = self:LayoutButtons("grid", self.Settings.Columns, 3, 6, -45) self:SetSize(width + 12, height + 12) if (self.UpdateDimensions) then self:UpdateDimensions() end -- Update the bag's height if self.name == "ItemSets" or self.name == "Consumables" then local width, height = self:LayoutButtons("grid", self.Settings.Columns, 3, 6, -25) self:SetSize(width + 12, height + 32) end if self.name == "BankItemSets" or self.name == "BankConsumables" then local width, height = self:LayoutButtons("grid", self.Settings.Columns, 3, 6, -25) self:SetSize(width + 12, height + 32) end if RayUI_ContainerFrameItemSets:GetHeight()<33 then f.sets:Hide() else f.sets:Show() end if RayUI_ContainerFrameConsumables:GetHeight()<33 then f.consumables:Hide() else f.consumables:Show() end if RayUI_ContainerFrameBankItemSets:GetHeight()<33 then f.banksets:Hide() else f.banksets:Show() end if RayUI_ContainerFrameBankConsumables:GetHeight()<33 then f.bankconsumables:Hide() else f.bankconsumables:Show() end end -- OnCreate is called every time a new container is created function MyContainer:OnCreate(name, settings) settings = settings or {} self.Settings = settings self.UpdateDimensions = UpdateDimensions self:EnableMouse(true) self:CreateShadow("Background") self:SetBackdropColor(0, 0, 0, 0.9) self:SetBackdropBorderColor(0, 0, 0, 0.8) self:SetParent(settings.Parent or RayUI_ContainerFrame) self:SetFrameStrata("HIGH") if(settings.Movable) then self:SetMovable(true) self:RegisterForClicks("LeftButton", "RightButton") self:SetScript("OnMouseDown", function() self:ClearAllPoints() self:StartMoving() end) end self:SetScript("OnMouseUp", self.StopMovingOrSizing) settings.Columns = settings.Columns or 10 if name == "Bank" or name == "Main" then -- don't need all that junk on "other" sections --Sort Button self.sortButton = CreateFrame("Button", nil, self) self.sortButton:Point("TOPLEFT", self, "TOPLEFT", 5, -4) self.sortButton:Size(16, 16) self.sortButton:SetNormalTexture("Interface\\ICONS\\INV_Pet_Broom") self.sortButton:GetNormalTexture():SetTexCoord(.08, .92, .08, .92) self.sortButton:SetPushedTexture("Interface\\ICONS\\INV_Pet_Broom") self.sortButton:GetPushedTexture():SetTexCoord(.08, .92, .08, .92) self.sortButton.pushed = true self.sortButton:StyleButton(true) self.sortButton.ttText = L["整理背包"] self.sortButton:SetScript("OnEnter", B.Tooltip_Show) self.sortButton:SetScript("OnLeave", B.Tooltip_Hide) self.sortButton:SetScript("OnClick", function() B:CommandDecorator(B.SortBags, self.name == "Bank" and "bank" or "bags")() end) S:CreateBG(self.sortButton) --Bagbar Button self.bagsButton = CreateFrame("Button", nil, self) self.bagsButton:Point("LEFT", self.sortButton, "RIGHT", 3, 0) self.bagsButton:Size(16, 16) self.bagsButton:SetNormalTexture("Interface\\Buttons\\Button-Backpack-Up") self.bagsButton:GetNormalTexture():SetTexCoord(.08, .92, .08, .92) self.bagsButton:SetPushedTexture("Interface\\Buttons\\Button-Backpack-Up") self.bagsButton:GetPushedTexture():SetTexCoord(.08, .92, .08, .92) self.bagsButton.pushed = true self.bagsButton:StyleButton(true) self.bagsButton.ttText = L["显示背包"] self.bagsButton:SetScript("OnEnter", B.Tooltip_Show) self.bagsButton:SetScript("OnLeave", B.Tooltip_Hide) self.bagsButton:SetScript("OnClick", function() if(self.BagBar:IsShown()) then self.BagBar:Hide() else self.BagBar:Show() end self:UpdateDimensions() end) S:CreateBG(self.bagsButton) local infoFrame = CreateFrame("Button", nil, self) infoFrame:Point("TOPLEFT", self, "TOPLEFT", 5, -21) infoFrame:Point("TOPRIGHT", self, "TOPRIGHT", -5, -21) infoFrame:SetHeight(20) -- money! local tagDisplay = self:SpawnPlugin("TagDisplay", "[money]", infoFrame) tagDisplay:SetFont(R["media"].font, R["media"].fontsize) tagDisplay:SetPoint("RIGHT", infoFrame, "RIGHT", 0, 0) -- Plugin: SearchBar local searchText = infoFrame:CreateFontString(nil, "OVERLAY") searchText:SetPoint("LEFT", infoFrame, "LEFT", 0, 0) searchText:SetFont(R["media"].font, R["media"].fontsize) searchText:SetText(SEARCH) -- our searchbar comes up when we click on infoFrame local search = self:SpawnPlugin("SearchBar", infoFrame) search.highlightFunction = highlightFunction -- same as above, only for search search.isGlobal = true -- This would make the search apply to all containers instead of just this one search:ClearAllPoints() search:SetPoint("LEFT", infoFrame, 0, 0) search:SetPoint("RIGHT", infoFrame, 0, 0) search:SetHeight(20) self.Search.Left:Hide() self.Search.Right:Hide() self.Search.Center:Hide() S:ReskinInput(self.Search) -- Plugin: BagBar local bagBar = self:SpawnPlugin("BagBar", settings.Bags) bagBar:SetSize(bagBar:LayoutButtons("grid", 7)) bagBar.highlightFunction = highlightFunction -- from above, optional, used when hovering over bag buttons bagBar.isGlobal = true -- This would make the hover-effect apply to all containers instead of the current one bagBar:Hide() bagBar:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 5, 5) self.BagBar = bagBar -- creating button for toggling BagBar on and off self:UpdateDimensions() local closebutton = CreateFrame("Button", nil, self) closebutton:SetFrameLevel(30) closebutton:SetSize(14,14) S:ReskinClose(closebutton) closebutton:ClearAllPoints() closebutton:SetPoint("TOPRIGHT", -6, -3) closebutton:SetScript("OnClick", function(self) if RayUI_ContainerFrame:AtBank() and self.name == "Bank" then CloseBankFrame() else CloseAllBags() end end) elseif name == "ItemSets" or name == "BankItemSets" then local setname = self:CreateFontString(nil,"OVERLAY") setname:SetPoint("TOPLEFT", self, "TOPLEFT",5,-5) setname:SetFont(R["media"].font, R["media"].fontsize, "THINOUTLINE") setname:SetText(string.format(EQUIPMENT_SETS,' ')) elseif name == "Consumables" or name == "BankConsumables" then local setname = self:CreateFontString(nil,"OVERLAY") setname:SetPoint("TOPLEFT", self, "TOPLEFT",5,-5) setname:SetFont(R["media"].font, R["media"].fontsize, "THINOUTLINE") setname:SetText(consumable) elseif name == "Reagent" then local reagentname = self:CreateFontString(nil,"OVERLAY") reagentname:SetPoint("TOPLEFT", self, "TOPLEFT",5,-5) reagentname:SetFont(R["media"].font, R["media"].fontsize, "THINOUTLINE") reagentname:SetText(REAGENT_BANK) local closebutton = CreateFrame("Button", nil, self) closebutton:SetFrameLevel(30) closebutton:SetSize(14,14) S:ReskinClose(closebutton) closebutton:ClearAllPoints() closebutton:SetPoint("TOPRIGHT", -6, -3) closebutton:SetScript("OnClick", function(self) if RayUI_ContainerFrame:AtBank() then CloseBankFrame() end end) --Sort Button self.sortButton = CreateFrame("Button", nil, self) self.sortButton:Point("TOPLEFT", self, "TOPLEFT", 5, -24) self.sortButton:Size(16, 16) self.sortButton:SetNormalTexture("Interface\\ICONS\\INV_Pet_Broom") self.sortButton:GetNormalTexture():SetTexCoord(.08, .92, .08, .92) self.sortButton:SetPushedTexture("Interface\\ICONS\\INV_Pet_Broom") self.sortButton:GetPushedTexture():SetTexCoord(.08, .92, .08, .92) self.sortButton.pushed = true self.sortButton:StyleButton(true) self.sortButton.ttText = L["整理背包"] self.sortButton:SetScript("OnEnter", B.Tooltip_Show) self.sortButton:SetScript("OnLeave", B.Tooltip_Hide) self.sortButton:SetScript("OnClick", SortReagentBankBags) S:CreateBG(self.sortButton) --Deposit Button self.depositButton = CreateFrame("Button", nil, self) self.depositButton:Point("LEFT", self.sortButton, "RIGHT", 3, 0) self.depositButton:Size(16, 16) self.depositButton:SetNormalTexture("Interface\\ICONS\\misc_arrowdown") self.depositButton:GetNormalTexture():SetTexCoord(.08, .92, .08, .92) self.depositButton:SetPushedTexture("Interface\\ICONS\\misc_arrowdown") self.depositButton:GetPushedTexture():SetTexCoord(.08, .92, .08, .92) self.depositButton.pushed = true self.depositButton:StyleButton(true) self.depositButton.ttText = REAGENTBANK_DEPOSIT self.depositButton:SetScript("OnEnter", B.Tooltip_Show) self.depositButton:SetScript("OnLeave", B.Tooltip_Hide) self.depositButton:SetScript("OnClick", DepositReagentBank) S:CreateBG(self.depositButton) self.reagentToggle = CreateFrame("Button", nil, self) self.reagentToggle:Point("LEFT", self.depositButton, "RIGHT", 3, 0) self.reagentToggle:Size(16, 16) self.reagentToggle:SetNormalTexture("Interface\\Buttons\\Button-Backpack-Up") self.reagentToggle:GetNormalTexture():SetTexCoord(.08, .92, .08, .92) self.reagentToggle:SetPushedTexture("Interface\\Buttons\\Button-Backpack-Up") self.reagentToggle:GetPushedTexture():SetTexCoord(.08, .92, .08, .92) self.reagentToggle.pushed = true self.reagentToggle:StyleButton(true) self.reagentToggle.ttText = BANK self.reagentToggle:SetScript("OnEnter", B.Tooltip_Show) self.reagentToggle:SetScript("OnLeave", B.Tooltip_Hide) S:CreateBG(self.reagentToggle) self.reagentToggle:SetScript("OnClick", function() PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB) ReagentBankFrame:Hide() BankFrame.selectedTab = 1 f.reagent:Hide() f.bank:Show() end) if not IsReagentBankUnlocked() then local buyReagent = CreateFrame("Button", nil, self, "UIPanelButtonTemplate") buyReagent:SetText(BANKSLOTPURCHASE) buyReagent:SetWidth(buyReagent:GetTextWidth() + 20) buyReagent:Point("TOPRIGHT", self, "TOPRIGHT", -6, -21) buyReagent:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_RIGHT") GameTooltip:AddLine(REAGENT_BANK_HELP, 1, 1, 1, true) GameTooltip:Show() end) buyReagent:SetScript("OnLeave", function() GameTooltip:Hide() end) buyReagent:SetScript("OnClick", function() StaticPopup_Show("CONFIRM_BUY_REAGENTBANK_TAB") end) buyReagent:SetScript("OnEvent", function(self, event) if event == "REAGENTBANK_PURCHASED" then f.reagent:OnContentsChanged() end if IsReagentBankUnlocked() then buyReagent:UnregisterAllEvents() buyReagent:Hide() end end) S:Reskin(buyReagent) buyReagent:RegisterEvent("REAGENTBANK_PURCHASED") buyReagent:RegisterEvent("PLAYER_ENTERING_WORLD") end end if name == "Bank" then local bankname = self:CreateFontString(nil,"OVERLAY") bankname:SetPoint("TOPLEFT", self, "TOPLEFT",5,-5) bankname:SetFont(R["media"].font, R["media"].fontsize, "THINOUTLINE") bankname:SetText(BANK) self.sortButton:ClearAllPoints() self.sortButton:SetPoint("LEFT", bankname, "RIGHT", 5, 0) self.reagentToggle = CreateFrame("Button", nil, self) self.reagentToggle:Point("LEFT", self.bagsButton, "RIGHT", 3, 0) self.reagentToggle:Size(16, 16) self.reagentToggle:SetNormalTexture("Interface\\ICONS\\INV_Enchant_DustArcane") self.reagentToggle:GetNormalTexture():SetTexCoord(.08, .92, .08, .92) self.reagentToggle:SetPushedTexture("Interface\\ICONS\\INV_Enchant_DustArcane") self.reagentToggle:GetPushedTexture():SetTexCoord(.08, .92, .08, .92) self.reagentToggle.pushed = true self.reagentToggle:StyleButton(true) self.reagentToggle.ttText = REAGENT_BANK self.reagentToggle:SetScript("OnEnter", B.Tooltip_Show) self.reagentToggle:SetScript("OnLeave", B.Tooltip_Hide) S:CreateBG(self.reagentToggle) self.reagentToggle:SetScript("OnClick", function() PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB) ReagentBankFrame:Show() BankFrame.selectedTab = 2 f.reagent:Show() if not IsReagentBankUnlocked() then f.reagent:SetSize(200, 50) end f.bank:Hide() end) end if name == "Main" or name == "ItemSets" or name == "Consumables" then self:HookScript("OnShow", function() R.Tooltip:GameTooltip_SetDefaultAnchor(GameTooltip) end) self:HookScript("OnHide", function() R.Tooltip:GameTooltip_SetDefaultAnchor(GameTooltip) end) end end self:OpenBags() self:CloseBags() self:RawHook("OpenBag","OpenBags", true) self:HookScript(TradeFrame, "OnShow", "OpenBags") self:HookScript(TradeFrame, "OnHide", "CloseBags") end function B:Info() return L["|cff7aa6d6Ray|r|cffff0000U|r|cff7aa6d6I|r背包模块."] end R:RegisterModule(B:GetName())
local pickers = require "telescope.pickers" local make_entry = require "telescope.make_entry" local finders = require "telescope.finders" local utils = require "telescope.utils" local conf = require("telescope.config").values local M = {} local function list_tests(opts) -- get the lsp_document_symbols; pass in {symbol="Class"} -- to only filter for Kind="Class" -- TODO what if there is more than one class? take the outer one local params = vim.lsp.util.make_position_params() local results_lsp, err = vim.lsp.buf_request_sync(0, "textDocument/documentSymbol", params, opts.timeout or 10000) if err then vim.api.nvim_err_writeln("Error when finding document symbols: " .. err) return end if not results_lsp or vim.tbl_isempty(results_lsp) then print "No results from textDocument/documentSymbol" return end local locations = {} for _, server_results in pairs(results_lsp) do vim.list_extend(locations, vim.lsp.util.symbols_to_items(server_results.result, 0) or {}) end locations = utils.filter_symbols(locations, opts) if locations == nil then -- error message already printed in `utils.filter_symbols` return end if vim.tbl_isempty(locations) then print("no symbols found") return end -- turn the result into a lsp_references request -- construct https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams local params = { textDocument = { uri = vim.uri_from_fname(locations[1].filename) }, position = { line = locations[1].lnum - 1, character = locations[1].col, }, } -- telescope.builtin.lsp.references -- TODO I assume I do not want to include the declaration? params.context = { includeDeclaration = true } local results_lsp, err = vim.lsp.buf_request_sync(0, "textDocument/references", params, opts.timeout or 10000) if err then vim.api.nvim_err_writeln("Error when finding references: " .. err) return end local locations = {} for _, server_results in pairs(results_lsp) do if server_results.result then vim.list_extend(locations, vim.lsp.util.locations_to_items(server_results.result) or {}) end end -- filter locations for tests -- TODO this might differ by language -- would it make sense/be feasible to look for an import/annotation -- to confirm its a test as opposed to just looking for a pattern in the -- filename? -- -- TODO I create a set so test files only occur once -- how do I choose which of the references to take? -- or do I simply override their lnum and col to 0? local tests = {} for _, l in ipairs(locations) do if string.find(l.filename, "[tT]est") then tests[l.filename] = l end end -- turn it into a location list for telescope -- into files local test_locations = {} for _, tl in pairs(tests) do test_locations[#test_locations+1] = { value = tl.filename, } end -- TODO why is the DateTimeUnitTest not included? return test_locations end M.list_tests = list_tests M.list = function(opts) opts = opts or { symbols = "Class" } local locations = list_tests(opts) -- TODO do not show the message. does that mean I don't want the previewer? pickers.new(opts, { prompt_title = "LSP Test References", finder = finders.new_table { results = locations, entry_maker = opts.entry_maker or make_entry.gen_from_file(opts), }, previewer = conf.file_previewer(opts), sorter = conf.generic_sorter(opts), }):find() end return M
return function(req, res, go) if req.socket.tls then return go() end res.code = 301 res.headers["Location"] = "https://" .. req.headers.Host .. req.path res.body = "Redirecting to HTTPS...\n" end
-- © 2011 David Given. -- WordGrinder is licensed under the MIT open source license. See the COPYING -- file in this distribution for the full text. local NextCharInWord = wg.nextcharinword local ReadU8 = wg.readu8 local string_len = string.len local string_char = string.char local string_format = string.format local string_gsub = string.gsub local table_concat = table.concat ----------------------------------------------------------------------------- -- The exporter itself. local function unrtf(s) local ss = {} local o = 1 local n = string_len(s) while (o <= n) do local c = ReadU8(s, o) o = NextCharInWord(s, o) if (c == 92) then ss[#ss+1] = "\\" elseif (c == 123) then ss[#ss+1] = "\\{" elseif (c == 125) then ss[#ss+1] = "\\}" elseif (c < 127) then ss[#ss+1] = string_char(c) elseif (c < 0x10000) then ss[#ss+1] = string_format('\\u%d ', c) else c = c - 0x10000 ss[#ss+1] = string_format('\\u%d', 0xd800 + (c / 0x400)) ss[#ss+1] = string_format('\\u%d ', 0xdc00 + (c % 0x400)) end end return table_concat(ss) end local style_tab = { ["H1"] = {1, '\\fs40\\sb400\\b\\sbasedon0 H1'}, ["H2"] = {2, '\\fs36\\sb360\\b\\sbasedon0 H2'}, ["H3"] = {3, '\\fs32\\sb320\\b\\sbasedon0 H3'}, ["H4"] = {4, '\\fs28\\sb280\\b\\sbasedon0 H4'}, ["P"] = {5, '\\fs28\\sb140\\sbasedon0 P'}, ["L"] = {6, '\\fs28\\sb140\\sbasedon5 L'}, ["LB"] = {7, '\\fs28\\sb140\\sbasedon5 LB'}, ["Q"] = {8, '\\fs28\\sb140\\li500\\sbasedon5 Q'}, ["V"] = {9, '\\fs28\\sb140\\li500\\sbasedon5 V'}, ["PRE"] = {10, '\\fs28\\sb140\\sbasedon5 PRE'}, } local function callback(writer, document) local settings = DocumentSet.addons.htmlexport return ExportFileUsingCallbacks(document, { prologue = function() writer('{\\rtf1\\ansi\\deff0') writer('{\\fonttbl{\\f0 Times New Roman}}') writer('\\deflang1033\\widowctrl') writer('\\uc0') writer('{\\listtable\n') writer('{\\list\\listtemplateid1\\listsimple\n') writer('{\\listlevel\\levelnfc23{\\levelfollow1\\leveltext \\u8226;}\\fi-300\\li500}\n') writer('\\listid1\\listname LB;}\n') writer('}\n') writer('{\\listoverridetable\n') writer('{\\listoverride\\listid1\\listoverridecount0\\ls1}\n') writer('}\n') writer('{\\stylesheet\n') writer('{\\s0 Normal;}\n') for _, s in pairs(style_tab) do writer('{\\s', s[1], ' ', s[2], ';}\n') end writer('}\n') writer('\n') end, rawtext = function(s) writer(s) end, text = function(s) writer(unrtf(s)) end, notext = function(s) end, italic_on = function() writer('\\i ') end, italic_off = function() writer('\\i0 ') end, underline_on = function() writer('\\ul ') end, underline_off = function() writer('\\ul0 ') end, list_start = function() writer('<ul>') end, list_end = function() writer('</ul>') end, paragraph_start = function(style) writer('{\\pard\\s', style_tab[style][1]) if (style == "LB") then writer('\\ls1') end writer(' ') italic = false underline = false --changepara(style) end, paragraph_end = function(style) writer('\\par}\n') end, epilogue = function() writer('}') end }) end function Cmd.ExportRTFFile(filename) return ExportFileWithUI(filename, "Export RTF File", ".rtf", callback) end
Weapon.PrettyName = "FAMAS-F1" Weapon.WeaponID = "swb_css_famas" Weapon.DamageMultiplier = 1.6 Weapon.WeaponType = WEAPON_PRIMARY
--[[ Copyright (c) 2012 Dale James 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. --]] --write a (non-serial) table to a file. The filename should be a property of "data": data._fileName = "*.extn" local jupiter = {saveDir = "save"} jupiter.save = function(data) assert(type(data) == "table", "Tables must be provided to saveFile!") if not love.filesystem.isDirectory(jupiter.saveDir) then assert(love.filesystem.createDirectory(jupiter.saveDir), "Unable to create save directory in " .. love.filesystem.getSaveDirectory() .. "!") end --make the save folder if required file = love.filesystem.newFile(data._fileName) file:open("w") local function serial(table, scope) scope = scope or "" for k, v in pairs(table) do if k ~= "_fileName" then if type(v) == "table" then serial(v, scope .. tostring(k) .. ".") else x = file:write(scope .. k .. "=" .. tostring(v) .. "\n") --write value if not x then return nil end end end end end serial(data) return true end --load a file. If no specific file is given it returns the latest save file jupiter.load = function(name) if not love.filesystem.isDirectory(jupiter.saveDir) then assert(love.filesystem.createDirectory(jupiter.saveDir), "Unable to create save directory in " .. love.filesystem.getSaveDirectory() .. "!") end --load the latest save file if no file is given (useful for 'continue' option) if not name then local saveFiles = love.filesystem.getDirectoryItems(jupiter.saveDir) local orderedFiles = {} for k, file in ipairs(saveFiles) do --ignore files such as .DS_Store if not (file:sub(1, 1) == ".") and file:match("%.save$") then table.insert(orderedFiles, {f = file, t = love.filesystem.getLastModified(jupiter.saveDir .. "/" .. file) or 0}) end end if # orderedFiles ~= 0 then --sort the files in modified order table.sort(orderedFiles, function(a, b) return a.t > b.t end) name = orderedFiles[1] end end --don't do anything if there are no saves if name then if love.filesystem.isFile(name) then local saveFile = {} --data from the file local pointer --find tables local function deserial(value) pointer = saveFile local scope, dotCount = value:gsub("%.", "%1") for x = 1, dotCount do local element = scope:match("^(..-)%.") --get the leftmost index scope = scope:match("^" .. element .. "%.(.+)") --trim the current index for the next iteration element = tonumber(element) and tonumber(element) or element pointer[element] = not pointer[element] and {} or pointer[element] --create the table if needed pointer = pointer[element] --set the pointer to the current level end return scope end --load the data for l in love.filesystem.lines(name) do local k, v = l:match("^(..-)=(.+)$") if k and v then local index = deserial(k) if v ~= "nil" and v ~= "false" then --ignore nil values that may have been set by the player index = tonumber(index) and tonumber(index) or index pointer[index] = tonumber(v) and tonumber(v) or v end end end saveFile._fileName = name return saveFile end end end return jupiter
-- https://github.com/f3fora/cmp-spell -- Setting spell (and spelllang) is mandatory to use spellsuggest. vim.opt.spell = true vim.opt.spelllang = { 'en_us' }
set("foo","bar") log("Foo "..get("foo")) log("Fuz "..get("fuz"))
local gc = Var("GameCommand"); local string_name = gc:GetText() local string_expl = THEME:GetString(Var "LoadingScreen", gc:GetName().."Explanation") local icon_color = ModeIconColors[gc:GetName()]; local t = Def.ActorFrame {}; t[#t+1] = Def.ActorFrame { GainFocusCommand=cmd(stoptweening;bob;effectmagnitude,0,6,0;decelerate,0.05;zoom,1); LoseFocusCommand=cmd(stoptweening;stopeffect;decelerate,0.1;zoom,0.6); LoadActor("_background base")..{ InitCommand=cmd(diffuse,icon_color); }; LoadActor("_background effect"); LoadActor("_gloss"); LoadActor("_stroke"); LoadActor("_cutout"); -- todo: generate a better font for these. LoadFont("Common Large")..{ Text=string.upper(string_name); InitCommand=cmd(y,-12;maxwidth,232); OnCommand=cmd(diffuse,Color.Black;shadowlength,1;shadowcolor,color("#ffffff77");skewx,-0.125); }; LoadFont("Common Normal")..{ Text=string.upper(string_expl); InitCommand=cmd(y,27.5;maxwidth,232); }; LoadActor("_background base") .. { DisabledCommand=cmd(diffuse,color("0,0,0,0.5")); EnabledCommand=cmd(diffuse,color("1,1,1,0")); }; }; return t
local gVehicles = {} MySQL.ready(function() gVehicles = MySQL.Sync.fetchAll('SELECT * FROM vehicle_shop') end) ESX.RegisterServerCallback('fivem-vehicleshop:getVehicles', function(playerId, cb) cb(gVehicles) end) ESX.RegisterServerCallback('fivem-vehicleshop:buyVehicle', function(playerId, cb, vehicleName, plate) local xPlayer = ESX.GetPlayerFromId(playerId) for i = 1, #gVehicles do local vehicle = gVehicles[i] if vehicle.name == vehicleName then if vehicle.stock > 0 then local vehiclePrice = vehicle.price if vehiclePrice and xPlayer.getMoney() >= vehiclePrice then xPlayer.removeMoney(vehiclePrice) MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)', { ['@owner'] = xPlayer.identifier, ['@plate'] = plate, ['@vehicle'] = json.encode( { model = GetHashKey(vehicleName), plate = plate } ) }, function(rowsChanged) xPlayer.showNotification(('O veículo com placa ~y~%s~s~ agora pertence a ~b~você~s~'):format(plate)) vehicle.stock = vehicle.stock - 1 MySQL.Async.execute('UPDATE vehicle_shop SET stock = @stock WHERE name = @vehicleName', { ['@vehicleName'] = vehicleName, ['@stock'] = vehicle.stock }) cb(true) end) else cb(false) end end break end end end) -- https://github.com/esx-framework/esx-legacy/blob/cae7d8e7fddf02658dcbe858d61b5eb8cfcffca8/%5Besx_addons%5D/esx_vehicleshop/server/main.lua#L395 ESX.RegisterServerCallback('fivem-vehicleshop:isPlateTaken', function(source, cb, plate) MySQL.Async.fetchAll('SELECT 1 FROM owned_vehicles WHERE plate = @plate', { ['@plate'] = plate }, function(result) cb(result[1] ~= nil) end) end)
local present, ts_config = pcall(require, "nvim-treesitter.configs") if not present then return end local default = { ensure_installed = { "lua", "vim", }, highlight = { enable = true, use_languagetree = true, }, } local M = {} M.setup = function(override_flag) if override_flag then default = require("core.utils").tbl_override_req("nvim_treesitter", default) end ts_config.setup(default) end return M
ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\master.lvl") -- Load MEU's pre-packaged scripts (required) -- -- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved. -- ScriptCB_DoFile("ME5_Master") -- MEU's master include file (required) ScriptCB_DoFile("ME5_setup_teams") -- MEU's version of setup_teams.lua (required) ScriptCB_DoFile("ME5_ObjectiveConquest") -- MEU's ObjectiveConquest script (required for Conquest matches) -- Create a new MapManager object manager = MapManager:New{ -- Map-specific details bIsModMap = true, -- Whether or not this is a mod map (as opposed to a stock map). gameMode = "conquest", -- The mission's game mode. mapSize = "med", -- Size of the map. Used for determining unit counts. environmentType = "jungle", -- Map's biome (essentially). Used for determining which camo textures to load. ("desert", "jungle", "snow", or "urban") -- In-game music (you can also specify a table of values and one of them will be randomly selected at runtime, example: `musicVariation_SSVxGTH = {"1","3"}` ) musicVariation_SSVxGTH = "3_vrm", -- Music variation to use for SSVxGTH matches. musicVariation_SSVxCOL = "5", -- Music variation to use for SSVxCOL matches. musicVariation_EVGxGTH = "9", -- Music variation to use for EVGxGTH matches. musicVariation_EVGxCOL = "9", -- Music variation to use for EVGxCOL matches. musicVariation_SSVxRPR = "5_mahavid", -- Music variation to use for SSVxRPR matches. -- Online matches onlineSideVar = "SSVxGTH", -- Faction combination to use in online matches. onlineHeroSSV = "shep_engineer", -- SSV hero to use in online matches. onlineHeroGTH = "gethprime_me2", -- GTH hero to use in online matches. onlineHeroCOL = "colgeneral", -- COL hero to use in online matches. onlineHeroEVG = "gethprime_me3", -- EVG hero to use in online matches. -- AI hero spawns (required). CP name, CP spawn path name heroSupportCPs = { {"cp1", "cp1_spawn"}, {"cp2", "cp2_spawn"}, {"cp3", "cp3_spawn"}, {"cp4", "cp4_spawn"}, {"cp5", "cp5_spawn"}, {"cp6", "cp6_spawn"}, }, -- Local ally spawns (required). CP name, CP spawn path name allySpawnCPs = { {"cp1", "cp1_spawn"}, {"cp2", "cp2_spawn"}, {"cp3", "cp3_spawn"}, {"cp4", "cp4_spawn"}, {"cp5", "cp5_spawn"}, {"cp6", "cp6_spawn"}, }, -- Artillery strike path nodes (required only if artillery strikes are desired). Path name, path node ID artilleryNodes = { {"cp1_spawn", 0}, {"cp2_spawn", 0}, {"cp3_spawn", 0}, --{"cp4_spawn", 0}, {"cp5_spawn", 0}, {"cp6_spawn", 0}, }, terrainType = "dirt", -- Type of terrain in the map ("dirt, "sand", or "snow") (required if `artilleryNodes` is specified). } -- Initialize the MapManager manager:Init() -- Randomize which team is ATT/DEF if not ScriptCB_InMultiplayer() then CIS = math.random(1,2) REP = (3 - CIS) else REP = 1 CIS = 2 end HuskTeam = 3 -- The husk team (required, name cannot be changed) ATT = 1 DEF = 2 function ScriptPostLoad() --This defines the CPs. These need to happen first cp1 = CommandPost:New{name = "cp1"} cp2 = CommandPost:New{name = "cp2"} cp3 = CommandPost:New{name = "cp3"} cp4 = CommandPost:New{name = "cp4"} cp5 = CommandPost:New{name = "cp5"} cp6 = CommandPost:New{name = "cp6"} --This sets up the actual objective. This needs to happen after cp's are defined conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true} --This adds the CPs to the objective. This needs to happen after the objective is set up conquest:AddCommandPost(cp1) conquest:AddCommandPost(cp2) conquest:AddCommandPost(cp3) conquest:AddCommandPost(cp4) conquest:AddCommandPost(cp5) conquest:AddCommandPost(cp6) conquest:Start() EnableSPHeroRules() -- Perform various post-load operations manager:Proc_ScriptPostLoad_End() --BlockPlanningGraphArcs("ConnectionCave") DisableBarriers("BarrierCave") end --------------------------------------------------------------------------- -- FUNCTION: ScriptInit -- PURPOSE: This function is only run once -- INPUT: -- OUTPUT: -- NOTES: The name, 'ScriptInit' is a chosen convention, and each -- mission script must contain a version of this function, as -- it is called from C to start the mission. --------------------------------------------------------------------------- function ScriptInit() -- Load our loadscreen ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\Load\\AEI.lvl") SetMemoryPoolSize("ParticleTransformer::ColorTrans", 2367) SetMemoryPoolSize("ParticleTransformer::PositionTr", 1380) SetMemoryPoolSize("ParticleTransformer::SizeTransf", 1533) -- Perform various pre-game operations manager:Proc_ScriptInit_Begin() SetMaxFlyHeight(45) SetMaxPlayerFlyHeight(45) AISnipeSuitabilityDist(60) SetAttackerSnipeRange(90) SetDefenderSnipeRange(150) -- Load the turrets ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\SIDE\\me5tur.lvl", "tur_bldg_mturret", "tur_bldg_laser") -- Load and set up the sides manager:Proc_ScriptInit_SideSetup() -- Load our map-specific sound lvl ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\Sound\\SFL_AEI_Streaming.lvl") -- Level Stats -- ClearWalkers() AddWalkerType(0, 0) -- special -> droidekas AddWalkerType(1, 0) -- 1x2 (1 pair of legs) AddWalkerType(2, 0) -- 2x2 (2 pairs of legs) AddWalkerType(3, 0) -- 3x2 (3 pairs of legs) local weaponCnt = 1024 SetMemoryPoolSize("Aimer", 75) SetMemoryPoolSize("AmmoCounter", weaponCnt) SetMemoryPoolSize("BaseHint", 1024) SetMemoryPoolSize("EnergyBar", weaponCnt) SetMemoryPoolSize("EntityCloth", 0) SetMemoryPoolSize("EntityFlyer", 32) SetMemoryPoolSize("EntityHover", 32) SetMemoryPoolSize("EntityLight", 200) SetMemoryPoolSize("EntitySoundStream", 4) SetMemoryPoolSize("EntitySoundStatic", 32) SetMemoryPoolSize("Navigator", 128) SetMemoryPoolSize("Obstacle", 1024) SetMemoryPoolSize("PathNode", 1024) SetMemoryPoolSize("SoldierAnimation", 417) SetMemoryPoolSize("SoundSpaceRegion", 24) SetMemoryPoolSize("TreeGridStack", 1024) SetMemoryPoolSize("UnitAgent", 128) SetMemoryPoolSize("UnitController", 128) SetMemoryPoolSize("Weapon", weaponCnt) manager:Proc_ScriptInit_MemoryPoolInit() SetSpawnDelay(10.0, 0.25) ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\ME5\\AEI.lvl", "AEI_conquest") SetDenseEnvironment("true") -- Birdies SetNumBirdTypes(1) SetBirdType(0, 0.7, "bird") SetBirdFlockMinHeight(60) -- Fishies SetNumFishTypes(1) SetFishType(0, 0.88, "fish") -- Sound Stats -- Open our map-specific ambient sound streams OpenAudioStream("..\\..\\addon\\ME5\\data\\_LVL_PC\\Sound\\SFL_AEI_Streaming.lvl", "AEI_ambiance") --OpenAudioStream("..\\..\\addon\\ME5\\data\\_LVL_PC\\Sound\\SFL_AEI_Streaming.lvl", "AEI_ambiance") -- Set up music manager:Proc_ScriptInit_MusicSetup() -- Set up common sound stuff SoundFX() -- Camera Stats AddCameraShot(0.588003, -0.024096, -0.807822, -0.033104, -295.404785, 31.805162, -189.417618); -- Island Wide Angle AddCameraShot(0.913883, 0.034342, -0.404237, 0.015190, -133.944977, 13.277077, 72.781090); -- Beach AddCameraShot(0.134694, 0.005500, -0.990047, 0.040425, 106.765259, 31.005287, -192.390869); -- Caves AddCameraShot(-0.454844, 0.063869, -0.879648, -0.123520, -161.709030, 47.911930, -241.780487); -- Crag AddCameraShot(0.990507, -0.137447, -0.002231, -0.000310, -185.309265, 24.109367, -32.575871); -- Dunes AddCameraShot(0.983676, -0.153915, -0.092113, -0.014413, -87.806061, 24.917538, -50.486591); -- Gorge AddCameraShot(0.597136, 0.018231, -0.801560, 0.024472, -77.412819, 23.308689, -214.238998); -- Ravine -- Perform various post-load operations manager:Proc_ScriptInit_End() end
do local developer = GetConVar("developer") _G.DEVELOPER = developer:GetBool() function IsDeveloper(n) return developer:GetInt() >= (n or 1) end end local function lom(path) local f = file.Open(path, 'rb', 'LuaMenu') if not f then ErrorNoHalt("Could not open: " .. path .. '\n') return end local str = f:Read(f:Size()) f:Close() local func = CompileString(str, '@' .. path, false) if isstring(func) then error(func) else return func end end local function lrm(_, _, _, code) local func = CompileString(code, "", false) if isstring(func) then Msg"Invalid syntax> " print(func) return end MsgN("> ", code) xpcall(func, function(err) print(debug.traceback(err)) end) end concommand.Add("lrm", lrm, nil, "Run lua on the menu state.", FCVAR_UNREGISTERED) concommand.Add("lom", lom, nil, "Honestly no idea", FCVAR_UNREGISTERED) function gamemenucommand(str) RunGameUICommand(str) end local function FindInTable(tab, find, parents, depth) depth = depth or 0 parents = parents or "" if (not istable(tab)) then return end if (depth > 3) then return end depth = depth + 1 for k, v in pairs(tab) do if (type(k) == "string") then if (k and k:lower():find(find:lower())) then Msg("\t", parents, k, " - (", type(v), " - ", v, ")\n") end if (istable(v) and k ~= "_R" and k ~= "_E" and k ~= "_G" and k ~= "_M" and k ~= "_LOADED" and k ~= "__index") then local NewParents = parents .. k .. "." FindInTable(v, find, NewParents, depth) end end end end local function Find(ply, command, arguments) if (IsValid(ply) and ply:IsPlayer() and not ply:IsAdmin()) then return end if (not arguments[1]) then return end Msg("Finding '", arguments[1], "':\n\n") FindInTable(_G, arguments[1]) FindInTable(debug.getregistry(), arguments[1]) Msg("\n\n") end concommand.Add("lua_find_menu", Find, nil, "", {FCVAR_DONTRECORD}) local iter iter = function(t, cb) for k, v in next, t do if istable(v) then iter(v, cb) else cb(v, k) end end end hook.Add("MenuStart", "Menu2", function() print"MenuStart" end) hook.Add("ConsoleVisible", "Menu2", function(is) print(is and '\n<Console Activated>' or '\n<Console Deactivated>') end) hook.Add("InGame", "Menu2", function(is) print(is and "InGame" or "Out of game") end) hook.Add("LoadingStatus", "Menu2", function(status) print("LoadingStatus", status) end) local isingame = IsInGame() local wasingame = false local status = GetLoadStatus() local console local alt hook.Add("Think", "Menu2", function() alt = not alt if alt then return end local is = IsInGame() if is ~= isingame then isingame = is wasingame = wasingame or isingame hook.Call("InGame", nil, isingame) end local s = GetLoadStatus() if s ~= status then status = s hook.Call("LoadingStatus", nil, status) end local s = gui.IsConsoleVisible() if s ~= console then console = s hook.Call("ConsoleVisible", nil, console) end end) function WasInGame() return wasingame end local games = engine.GetGames() local addons = engine.GetAddons() hook.Add("GameContentChanged", "Menu2", function() local games_new = engine.GetGames() local _ = games games = games_new local games = _ local addons_new = engine.GetAddons() local _ = addons addons = addons_new local addons = _ local wasmount = false local wasaddon = false for k, new in next, games_new do local old = games[k] assert(old.depot == new.depot) if old.mounted ~= new.mounted then print("MOUNT", new.title, new.mounted and "MOUNTED" or "UNMOUNTED") wasmount = true end end for k, new in next, addons_new do local old for k, v in next, addons do if v.file == new.file then old = v break end end if not old then print("ADDON LOADED:", new.mounted and "(M)" or " ", new.title) wasaddon = true continue end assert(old.depot == new.depot) if old.mounted ~= new.mounted then print("MOUNT", new.title, "\t", new.mounted and "MOUNTED" or "UNMOUNTED") wasaddon = true end end for k, old in next, addons do local new for k, v in next, addons_new do if v.file == old.file then new = v break end end if not new then MsgN("Removed ", old.title) nothing = false continue end end if IsDeveloper(2) then print("MENU: Unhandled GameContentChanged") end hook.Call("GameContentsChanged", nil, wasmount, wasaddon) end) SelectGamemode = function(g) RunConsoleCommand("gamemode", g) end function SetMounted(game, yesno) engine.SetMounted(game.depot, yesno == nil or yesno) end function SearchWorkshop(str) str = string.JavascriptSafe(str) str = "http://steamcommunity.com/workshop/browse?searchtext=" .. str .. "&childpublishedfileid=0&section=items&appid=4000&browsesort=trend&requiredtags[]=-1" gui.OpenURL(str) end if outdated then R"showconsole"() end concommand.Add("whereis", function(_, _, _, path) local absolutePath = util.RelativePathToFull_Menu(path, "GAME") if (not absolutePath or not file.Exists(path, "GAME")) then MsgN"File not found." return end local relativePath = util.FullPathToRelative_Menu(absolutePath, "MOD") -- If the relative path is inside the workshop dir, it's part of a workshop addon if (relativePath and relativePath:match("^workshop[\\/].*")) then local addonInfo = util.RelativePathToGMA_Menu(path) -- Not here? Maybe somebody just put their own file in ./workshop if (addonInfo) then local addonRelativePath = util.RelativePathToFull_Menu(addonInfo.File) MsgN("'", addonInfo.Title, "' - ", addonRelativePath) return end end MsgN(absolutePath) end, nil, "Searches for the highest priority instance of a file within the GAME mount path.") local function ValidateIP(ip) if ip then local chunks = {ip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+):*")} if (#chunks == 4) then for _, v in pairs(chunks) do if tonumber(v) > 255 then return false end end return true end end end function rejoinlast() ip = file.Read("lastserver.txt", "DATA") if not ValidateIP(ip) then MsgN("No previous server.") return end JoinServer(ip) end concommand.Add("rejoinlast", rejoinlast) OriginalJoinServer = JoinServer function JoinServer(ip) file.Write("lastserver.txt", ip) OriginalJoinServer(ip) end
require "UnLua" local UMG_Main_C = Class() function UMG_Main_C:Construct() self.ExitButton.OnClicked:Add(self, UMG_Main_C.OnClicked_ExitButton) --self.ExitButton.OnClicked:Add(self, function(Widget) UE.UKismetSystemLibrary.ExecuteConsoleCommand(Widget, "exit") end ) end function UMG_Main_C:OnClicked_ExitButton() UE.UKismetSystemLibrary.ExecuteConsoleCommand(self, "exit") end return UMG_Main_C
function readInput() local lines = {} local file = io.open("/uploads/input_04.txt", "r") for line in file:lines() do lines[#lines + 1] = compactWhitespaces(line:gsub("\r", "")) end file:close() return lines end function parse(input) local drawnNumbers = split(input[1], ",") local boards = {} local board = {} for i = 3, #input do line = input[i] if line == "" then boards[#boards + 1] = board board = {} else board[#board + 1] = split(trim(line), " ") end end boards[#boards + 1] = board return drawnNumbers, boards end function compactWhitespaces(text) return text:gsub("%s+", " ") end function trim(text) return text:match("^%s*(.-)%s*$") end function split(text, delimiter) parts = {} for part in (text..delimiter):gmatch("(.-)"..delimiter) do parts[#parts + 1] = part end return parts end function drawBoard(board) for row = 1, #board do for column = 1, #board[row] do io.write(board[row][column]) io.write(" ") end io.write("\r") end end function performMove(number, board) local sumOfUnmarked = 0 for row = 1, #board do for column = 1, #board[row] do if board[row][column] == number then board[row][column] = "x" end if board[row][column] ~= "x" then sumOfUnmarked = sumOfUnmarked + tonumber(board[row][column]) end end end local won = false local points = nil for row = 1, #board do if table.concat(board[row], "") == "xxxxx" then won = true points = sumOfUnmarked * number break end end for col = 1, #board[1] do if board[1][col] == "x" and board[2][col] == "x" and board[3][col] == "x" and board[4][col] == "x" and board[5][col] == "x" then won = true points = sumOfUnmarked * number break end end return won, points end function countNonNil(values) local count = 0 for k, v in pairs(values) do if v ~= nil then count = count + 1 end end return count end function solvePuzzle1(input) local drawnNumbers, boards = parse(input) for k1, number in pairs(drawnNumbers) do for k2, board in pairs(boards) do local won, points = performMove(number, board) if won then print("points (first winner):", points) -- 2745 return end end end end function solvePuzzle2(input) local drawnNumbers, boards = parse(input) for k1, number in pairs(drawnNumbers) do for k2, board in pairs(boards) do local won, points = performMove(number, board) if won then if countNonNil(boards) == 1 then print("points (last winner):", points) -- 6594 end boards[k2] = nil end end end end input = readInput() solvePuzzle1(input) solvePuzzle2(input)
util.AddNetworkString("RAM_MapVoteStart") util.AddNetworkString("RAM_MapVoteUpdate") util.AddNetworkString("RAM_MapVoteCancel") util.AddNetworkString("RTV_Delay") MapVote.Continued = false net.Receive("RAM_MapVoteUpdate", function(len, ply) if(MapVote.Allow) then if(IsValid(ply)) then local update_type = net.ReadUInt(3) if(update_type == MapVote.UPDATE_VOTE) then local map_id = net.ReadUInt(32) if(MapVote.CurrentMaps[map_id]) then MapVote.Votes[ply:SteamID()] = map_id net.Start("RAM_MapVoteUpdate") net.WriteUInt(MapVote.UPDATE_VOTE, 3) net.WriteEntity(ply) net.WriteUInt(map_id, 32) net.Broadcast() end end end end end) if file.Exists( "mapvote/recentmaps.txt", "DATA" ) then recentmaps = util.JSONToTable(file.Read("mapvote/recentmaps.txt", "DATA")) else recentmaps = {} end if ConVarExists("mv_maplimit") then PHX.VerboseMsg("[MapVote] Loading ConVars...") MapVote.Config = { MapLimit = GetConVar("mv_maplimit"):GetInt(), TimeLimit = GetConVar("mv_timelimit"):GetInt(), AllowCurrentMap = GetConVar("mv_allowcurmap"):GetBool(), EnableCooldown = GetConVar("mv_cooldown"):GetBool(), MapsBeforeRevote = GetConVar("mv_mapbeforerevote"):GetBool(), RTVPlayerCount = GetConVar("mv_rtvcount"):GetInt(), MapPrefixes = string.Explode(",", GetConVar("mv_map_prefix"):GetString():lower()) } else MapVote.Config = {} end local conv = { ["mv_maplimit"] = function(cvar,old,new) if new && (new != nil || new != "") then MapVote.Config.MapLimit = tonumber(new) end end, ["mv_timelimit"] = function(cvar,old,new) if new && (new != nil || new != "") then MapVote.Config.TimeLimit = tonumber(new) end end, ["mv_allowcurmap"] = function(cvar,old,new) if new && (new != nil || new != "") then MapVote.Config.AllowCurrentMap = tobool(new) end end, ["mv_cooldown"] = function(cvar,old,new) if new && (new != nil || new != "") then MapVote.Config.EnableCooldown = tobool(new) end end, ["mv_mapbeforerevote"] = function(cvar,old,new) if new && (new != nil || new != "") then MapVote.Config.MapsBeforeRevote = tobool(new) end end, ["mv_rtvcount"] = function(cvar,old,new) if new && (new != nil || new != "") then MapVote.Config.RTVPlayerCount = tonumber(new) end end, ["mv_map_prefix"] = function(cvar,old,new) if new && (new != nil || new != "") then MapVote.Config.MapPrefixes = string.Explode(",", new:lower()) end end } -- Precheck when the convar is changed for cvar,func in pairs(conv) do PHX.VerboseMsg("[MapVote] Adding ConVar Callbacks for: "..cvar) cvars.AddChangeCallback(cvar, func) end function CoolDownDoStuff() cooldownnum = MapVote.Config.MapsBeforeRevote or 3 if table.getn(recentmaps) == cooldownnum then table.remove(recentmaps) end local curmap = game.GetMap():lower()..".bsp" if not table.HasValue(recentmaps, curmap) then table.insert(recentmaps, 1, curmap) end file.Write("mapvote/recentmaps.txt", util.TableToJSON(recentmaps)) end function MapVote.GetFromULX() if (!ulx or ulx == nil or !ulx.votemaps or ulx.votemaps == nil) then print("[!PHX] Warning: ULX is not installed, can't get any votemap information!") return {} end return ulx.votemaps end function MapVote.Start(length, current, limit, prefix) current = current or MapVote.Config.AllowCurrentMap or false length = length or MapVote.Config.TimeLimit or 28 limit = limit or MapVote.Config.MapLimit or 24 cooldown = MapVote.Config.EnableCooldown or true prefix = prefix or MapVote.Config.MapPrefixes local is_expression = false local ulxmap = MapVote.GetFromULX() if not prefix then local info = file.Read(GAMEMODE.Folder.."/"..GAMEMODE.FolderName..".txt", "GAME") if(info) then local info = util.KeyValuesToTable(info) prefix = info.maps else error("MapVote Prefix can not be loaded from gamemode") end is_expression = true else if prefix and type(prefix) ~= "table" then prefix = {prefix} end end local maps = {} if GetConVar("mv_use_ulx_votemaps"):GetBool() and (ulxmap or ulxmap ~= nil) then for _,map in pairs(ulxmap) do table.insert(maps, map..".bsp") end else maps = file.Find("maps/*.bsp", "GAME") end local vote_maps = {} local amt = 0 for k, map in RandomPairs(maps) do local mapstr = map:sub(1, -5):lower() if(not current and game.GetMap():lower()..".bsp" == map) then continue end if(cooldown and table.HasValue(recentmaps, map)) then continue end if is_expression then if(string.find(map, prefix)) then -- This might work (from gamemode.txt) vote_maps[#vote_maps + 1] = map:sub(1, -5) amt = amt + 1 end else for k, v in pairs(prefix) do if string.find(map, "^"..v) then vote_maps[#vote_maps + 1] = map:sub(1, -5) amt = amt + 1 break end end end if(limit and amt >= limit) then break end end net.Start("RAM_MapVoteStart") net.WriteUInt(#vote_maps, 32) for i = 1, #vote_maps do net.WriteString(vote_maps[i]) end net.WriteUInt(length, 32) net.Broadcast() MapVote.Allow = true MapVote.CurrentMaps = vote_maps MapVote.Votes = {} timer.Create("RAM_MapVote", length, 1, function() MapVote.Allow = false local map_results = {} for k, v in pairs(MapVote.Votes) do if(not map_results[v]) then map_results[v] = 0 end for k2, v2 in pairs(player.GetAll()) do if(v2:SteamID() == k) then if(MapVote.HasExtraVotePower(v2)) then map_results[v] = map_results[v] + 2 else map_results[v] = map_results[v] + 1 end end end end CoolDownDoStuff() local winner = table.GetWinningKey(map_results) or 1 net.Start("RAM_MapVoteUpdate") net.WriteUInt(MapVote.UPDATE_WIN, 3) net.WriteUInt(winner, 32) net.Broadcast() local map = MapVote.CurrentMaps[winner] timer.Simple(4, function() hook.Run("MapVoteChange", map) RunConsoleCommand("changelevel", map) end) end) end hook.Add( "Shutdown", "RemoveRecentMaps", function() if file.Exists( "mapvote/recentmaps.txt", "DATA" ) then file.Delete( "mapvote/recentmaps.txt" ) end end ) function MapVote.Cancel() if MapVote.Allow then MapVote.Allow = false net.Start("RAM_MapVoteCancel") net.Broadcast() timer.Destroy("RAM_MapVote") end end
-- The main part: how a contest works! require "contest/move" require "contest/pokemon" Contest = {} --[[ In contests, there is a relation between conditions. Excitement: +1 heart +1 star, when same contest-condition move-condition. (e.g. Cool -> Cool contest) Indifference: Nothing changes. (e.g. Beautiful and Tough -> Cool contest) Discontent: -1 heart -1 star. (e.g. Clever and Cute -> Cool contest) In this table there are the move conditions that generates discontent when used in a specific condition contest. Example: A = {"B", "C"} When using a B or C move in a A contest, generates discontent. ]] discontent = { Cool = {"Clever", "Cute"}, Beautiful = {"Clever", "Tough"}, Cute = {"Cool", "Tough"}, Cleverness = {"Beautiful", "Cool"}, Tough = {"Beautiful", "Cute"} } -- In contests, there are some moves that makes a combo. If it happens, i.e. two moves of a combo are performed , there is a +3 bonus. combo = { ["Rain Dance"] = "Weather Ball", ["Sunny Day"] = "Weather Ball", ["Hail"] = "Weather Ball", ["Agility"] = "Baton Pass", ["Agility"] = "Electro Ball" } function Contest:new(condition, pokemons, verbose) assert(condition == "Cool" or condition == "Beautiful" or condition == "Cute" or condition == "Clever" or condition == "Tough", condition .. " is not a valid condition.") -- check if it's provided a valid condition... assert(#pokemons == 4, "There must be 4 participants.") -- and 4 participants. local contest = { condition = condition, -- condition of the contest. pokemons = pokemons, -- the 4 Pokémon participants, in the correct order. Important: each one must have a different name. stars = 0, -- how much stars the star meter has, max is 5. turn = 1, -- turn number, max is 5. dampen = false, -- whether the enthusiasm is dampened or not. If dampened, stores the name of the Pokémon that made it. verbose = verbose, -- show or not info about the contest. fixedord = {}, -- all the Pokémon that have a fixed order. Index are Pokémon names, values means priority: the higher the first. randomoutcomes = {} -- contains all the choices made by random events (e.g. if a Pokémon is nervous or not or the order in case of tie), must be filled for the right move made by the right player if we want the random events to have a specific outcome. Essential for simulations. } -- Events is where all what happens goes, to be represented graphically (or textually). if contest.verbose then -- Only if we must show info about the contest, make the event table. contest.events = {} -- TODO change events so that it has event[turn][pokemon] require "contest/interface" -- and require all you need to display the info. end -- Set prototype. setmetatable(contest, self) self.__index = self self.__tostring = self.tostring return contest end function Contest:tostring() --[[ Format as a string, as follows: ★★☆☆☆ 1. Machoke 💔 2. Masquerain ♥♥ 3. Vileplume ♥♥♥ 4. Gorebyss ♥♥♥♥ ]] local s = "" -- Print the star meter. for i = 1, self.stars do s = s .. "★" end for i = self.stars+1, 5 do s = s .. "☆" end s = s .. "\n" -- Print all participants with hearts and statuses. for i, pokemon in pairs(self.pokemons) do local h, hearts, sym, status = "", math.abs(pokemon.hearts), "", "" if pokemon.protection == 1 then status = status .. "x" elseif pokemon.protection == 2 then status = status .. "X" end if pokemon.nervous == true then status = status .. "~" end if pokemon.hearts >= 0 then sym = "♥" else sym = "💔" end for i = 1, hearts do h = h .. sym end s = s .. i .. ". " .. pokemon.name .. " " .. status .. "\t" .. h .. "\n" end return s end function Contest:clone() -- Clone the contest. local pokemons = {} for i = 1, #self.pokemons do pokemons[i] = self.pokemons[i]:clone() end local clone = Contest:new(self.condition, pokemons, self.verbose) clone.stars = self.stars clone.turn = self.turn clone.dampen = self.dampen clone.fixedord = objclone(self.fixedord) clone.randomoutcomes = objclone(self.randomoutcomes) if self.verbose then clone.events = objclone(self.events) end return clone end function Contest:doMove(pi, mi) local pokemon, move = self.pokemons[pi], self.pokemons[pi].moves[mi] -- current Pokémon moving and current move used. local repeated = (move.name == pokemon.prevmove) -- has it executed the same move used the previous turn? if move.trigger == "repeat" then repeated = false end -- if the move trigger is repeat, it means that the repeat malus should not be applied. -- Execute the move appeal and appeal effect. self:addEvent{"appeal", pokemon = pokemon.name, move = move.name} -- "<Pokémon> si esibisce con <mossa>!" if move.trigger == "start" then move:effect(self, pi) end -- execute move effect to execute at the start. if move.trigger == "appeal" then pokemon.hearts = pokemon.hearts + move:effect(self, pi) -- In this case, the event history is handled by the move:effect function! else pokemon.hearts = pokemon.hearts + move.appeal self:addEvent{"addhearts", hearts = move.appeal} end -- Execute the jam, if the move has jam effect and the active Pokémon is not the first (since it will have no Pokémon to jam). if move.jam > 0 then self:addEvent{"startle"} -- "Cerca di spaventare gli avversari!" local success = false -- -- true if at least one of the previoys Pokémons get startled. for i = 1, pi-1 do -- If the jam must be executed only on the previous one, execute the loop just once (when the index reach the previous Pokémon). Else, execute the whole loop. -- This is to use the same code for jamall and jamonce. if (not move.jamall and i == pi-1) or move.jamall then local prev = self.pokemons[i] -- If there is no protection or user committed suicide (4 means it has committed suicide in a previous turn: in fact, if it has committed suicide in the current turn it can be startled), jam. if prev.protection == 0 and prev.cantmove ~= 4 then local jam if move.trigger == "jam" then jam = move:effect(self, i) else jam = move.jam end if prev.easystartle == true then prev.hearts = prev.hearts - jam*2 self:addEvent{"removehearts", hearts = jam*2, pokemon = prev.name} else prev.hearts = prev.hearts - jam self:addEvent{"removehearts", hearts = jam, pokemon = prev.name} end success = true else -- if there is protection, no jam! -- If the Pokémon is just protected once, remove the protection now that it has protected. if prev.protection == 1 then prev.protection = 0 self:addEvent{"removeprotect", pokemon = prev.name} end end end end if not success then self:addEvent{"miss"} end -- "Ma non ce la fa!" end if move.trigger == "end" then move:effect(self, pi) end -- execute move effect to execute at the end. -- Additional effects. -- Combo bonus: check if it is a combo move and if it has made a combo. if table.haskey(combo, move.name) then self:addEvent{"cancombo"} end -- "Il pubblico si aspetta molto dalla prossima combinazione!" if table.haskey(combo, pokemon.prevmove) and combo[pokemon.prevmove] == move.name then self:addEvent{"combo"} -- "Il pubblico ha apprezzato molto la combinazione con l'esibizione precedente!" pokemon.hearts = pokemon.hearts + 3 -- the combo increases hearts by 3. self:addEvent{"addhearts", hearts = 3} end -- Repeat malus: same move executed twice in a row gives -1 hearts and doesn't make the crowd excited. if repeated then self:addEvent{"repeated", pokemon = pokemon.name} -- "<Pokémon> delude il pubblico ripetendo la stessa esibizione!" pokemon.hearts = pokemon.hearts - 1 self:addEvent{"addhearts", hearts = -1} end -- Same condition bonus: if the move and the contest has the same condition, add a heart and a star. -- Not applied if repeated move or Pokémon has earned no hearts or dampened crowd (but still applied if the Pokémon is the same that dampened the crowd, remember that self.dampen keeps the name of the Pokémon that dampened the crowd if any). if move.condition == self.condition and pokemon.hearts ~= 0 and not repeated and (not self.dampen or self.dampen == pokemon.name) then -- If the move has a special trigger related to the star meter and the condition is satisfied, double the stars. local stars if move.trigger == "stars" then stars = move:effect(self, pi) else stars = 1 self:addEvent{"excited", condition = self.condition, pokemon = pokemon.name} -- "Il pubblico è entusiasta della <virtù> di <Pokémon>!" end local hearts = stars -- remember: if the effect adds two star but we can add only one, we add anyway two hearts. if self.stars + stars > 5 then stars = 5 - self.stars end self.stars = self.stars + stars self:addEvent{"addstars", stars = stars} pokemon.hearts = pokemon.hearts + hearts self:addEvent{"addhearts", hearts = hearts} elseif move.condition == self.condition and pokemon.hearts ~= 0 and not repeated and self.dampen then self:addEvent{"dampen1", dampener = self.dampen} self:addEvent{"dampen2", condition = self.condition, pokemon = pokemon.name} end -- Discontent malus: if the move generates discontent, remove a heart and a star. if move.condition == discontent[self.condition][1] or move.condition == discontent[self.condition][2] then self:addEvent{"discontent", condition = move.condition, pokemon = pokemon.name} -- Il pubblico non sembra colpito dalla <virtù> di <Pokémon>... if self.stars ~= 0 then self.stars = self.stars - 1 self:addEvent{"addstars", stars = -1} end pokemon.hearts = pokemon.hearts - 1 self:addEvent{"addhearts", hearts = -1} -- Remember: if 0 stars, the stars remains the same but the heart is removed anyway. end -- Excitement bonus: If the star meter reaches 5 stars, add 5 hearts and reset the meter. if self.stars == 5 then self:addEvent{"fascinated1", condition = self.condition, pokemon = pokemon.name} -- "Il pubblico è incantato dalla <virtù> di <Pokémon>!" self:addEvent{"fascinated2", condition = self.condition, pokemon = pokemon.name} -- "La Bellezza di <Pokémon> è quasi accecante!" (varia in base alla virtù) self:addEvent{"fascinated3"} -- "L'Esibizione Live ha lasciato il pubblico a bocca aperta!" pokemon.hearts = pokemon.hearts + 5 self:addEvent{"addhearts", hearts = 5} self.stars = 0 self:addEvent{"resetstars"} end end function Contest:doTurn(moves) -- Moves are given by the pair (Pokémon name, move number). -- Important: In this implementation, the Pokémon name is unique, so each Pokémon must have a different name. assert(self.turn < 6, "The contests end after 5 turns") -- error if turn is 6 or above. if self.verbose then self.events[self.turn] = {} end -- start the events for the turn. -- Execute the moves, one for each of the participants, in the correct order. for i = 1, 4 do local pokemon = self.pokemons[i] self:addEvent{"turn", pokemon = pokemon.name} if not pokemon.nervous and pokemon.cantmove == 0 then self:doMove(i, moves[pokemon.name]) pokemon.prevmove = pokemon.moves[moves[pokemon.name]].name -- save the move used, so that if the next turn the move is repeated the malus applies. else if pokemon.nervous then self:addEvent{"nervous", pokemon = pokemon.name} -- "<Pokémon> non riesce a esibirsi per l'emozione!" end if pokemon.cantmove > 0 then self:addEvent{"cantmove", pokemon = pokemon.name} -- "<Pokémon> non può far altro che stare a guardare!" end end -- Save the current state. self:addEvent{"state", state = self:tostring()} end -- Choose the order for the next turn, if tie choose randomly. -- In the table fixedord there are the name of the Pokémons that must have a fixed order (first ones or last ones) associated to a priority value. -- The algorithm generates for every Pokémon a random number in (0,1) if no priority is given. Then there is comparison: -- - if both Pokémon have different hearts and no priority, first is the one with most hearts (since hearts are integer the random number is ininfluent); -- - if both Pokémon have the same hearts, the random number decides who goes first; -- - if a Pokémon has the priority, it's always first: priorities are multiple of 1000, in fact. -- See http://stackoverflow.com/questions/32069912/lua-sort-table-and-randomize-ties for further information. if self.randomoutcomes.fixedord then self.fixedord = self.randomoutcomes.fixedord end -- if the order has been fixed, set it. local rnd = self.fixedord table.sort(self.pokemons, function (a, b) rnd[a.name] = rnd[a.name] or math.random() rnd[b.name] = rnd[b.name] or math.random() return a.hearts + rnd[a.name] > b.hearts + rnd[b.name] end) -- Update the events to add the new order. local pokemons = {} for i = 1, 4 do pokemons[i] = self.pokemons[i].name end self:addEvent{"order", pokemons = pokemons} -- Reset all the participants. for i, pokemon in pairs(self.pokemons) do pokemon.tothearts = pokemon.tothearts + pokemon.hearts pokemon.hearts = 0 pokemon.protection = 0 pokemon.easystartle = false pokemon.nervous = false if pokemon.cantmove == 1 then pokemon.cantmove = 0 elseif pokemon.cantmove == 2 then pokemon.cantmove = 1 elseif pokemon.cantmove == 3 then pokemon.cantmove = 4 end end -- The current turn has ended. Reset all contest stuff. self.turn = self.turn + 1 self.dampen = false self.fixedord = {} self.randomoutcomes = {} -- If we finished all the 5 turns, sort the Pokémons by total hearts earned. if self.turn == 6 then local rnd = {} table.sort(self.pokemons, function (a, b) rnd[a.name] = rnd[a.name] or math.random() rnd[b.name] = rnd[b.name] or math.random() return a.tothearts + rnd[a.name] > b.tothearts + rnd[b.name] end) -- Update the events to add the final result. Overwrite the last order, that has no importance. local pokemons, hearts = {}, {} for i = 1, 4 do pokemons[i] = self.pokemons[i].name end for i = 1, 4 do hearts[i] = self.pokemons[i].tothearts end if self.verbose then self.events[5][#self.events[5]] = {"result", pokemons = pokemons, hearts = hearts} end end end function Contest:isEnded() -- Return true if the contest has endend, i.e. we passed through all the 5 turns. return self.turn == 6 end function Contest:printResult() -- Print the final result of the contest. assert(self:isEnded(), "The contest is not yet ended, you can't have the result.") local s = "-- Results --\n" for i, pokemon in pairs(self.pokemons) do s = s .. i .. ". " .. pokemon.name .. "\t" .. pokemon.tothearts .. "♥\n" end print(s) end function Contest:getResult() -- Return the name of the winner. assert(self:isEnded(), "The contest is not yet ended, you can't have the result.") return self.pokemons[1].name end function Contest:shuffleOrder() -- Shuffle the starting order. for i = 1, 4 do local j = math.random(4) self.pokemons[i], self.pokemons[j] = self.pokemons[j], self.pokemons[i] end end function Contest:getLastPokemonToAppeal(pi) -- Return the last Pokémon that has made an appeal. local i = pi-1 -- Remember: if cantmove == 0 the Pokémon can move and has moves, and if cantmove == 3 the Pokémon has just made a suicide move but yet has moved, so you must not skip it. while i > 0 and (self.pokemons[i].nervous or self.pokemons[i].cantmove == 1 or self.pokemons[i].cantmove == 4) do i = i - 1 end return i end function Contest:addEvent(event) if self.verbose then table.insert(self.events[self.turn], event) end end function Contest:printEvents(turn) printEvents(self.events, turn) end
-- eLua reference manual - SPI module data_en = { -- Title title = "eLua reference manual - SPI module", -- Menu name menu_name = "spi", -- Overview overview = [[This module contains functions for accessing the SPI interfaces of the eLua CPU.</p> <p><span class="warning">IMPORTANT</span>: right now, only master SPI mode is implemented in eLua.]], -- Functions funcs = { { sig = "clock = #spi.setup#( id, type, clock, cpol, cpha, databits )", desc = "Setup the SPI interface", args = { "$id$ - the ID of the SPI interface.", "$type$ - SPI interface type, can be either $spi.MASTER$ or $spi.SLAVE$. $NOTE: currently, only master SPI mode is supported$.", "$clock$ - the clock of the SPI interface.", "$cpol$ - the clock polarity (0 or 1).", "$cpha$ - the clock phase (0 or 1).", "$databits$ - the length of the SPI data word.", }, ret = "The actual clock set on the SPI interface. Depending on the hardware, this might have a different value than the $clock$ parameter." }, { sig = "#spi.sson#( id )", desc = "Select the SS line (Slave Select) of the SPI interface. This is only applicable for SPI interfaces with a dedicated SS pin.", args = "$id$ - the ID of the SPI interface.", }, { sig = "#spi.ssoff#( id )", desc = "Deselect the SS line (Slave Select) of the SPI interface. This is only applicable for SPI interfaces with a dedicated SS pin.", args = "$id$ - the ID of the SPI interface.", }, { sig = "#spi.write#( id, data1, [data2], ..., [datan] )", desc = "Write one or more strings/numbers to the SPI interface.", args = { "$id$ - the ID of the SPI interface.", "$data1$ - the first string/number to send.", "$data2 (optional)$ - the second string/number to send.", "$datan (optional)$ - the %n%-th string/number to send." }, }, { sig = "#spi.readwrite#( id, data1, [data2], ..., [datan] )", desc = "Write one or more strings/numbers to the SPI interface and return the data read from the same interface.", args = { "$id$ - the ID of the SPI interface.", "$data1$ - the first string/number to send.", "$data2 (optional)$ - the second string/number to send.", "$datan (optional)$ - the %n%-th string/number to send." }, ret = "An array with all the data read from the SPI interface." } }, } data_pt = data_en
--- --- See LICENSE file in top directory for copyright information local Store = require "ActiveLua.Store.SQL" require "lunit" lunit.setprivfenv() lunit.import "assertions" lunit.import "checks" -- -- SQL Constructs -- local sql = lunit.TestCase("SQL Construction") function sql:test_basic() local str = Store:_sqlConstructSelect("people") assert_equal("SELECT * FROM people", str) end function sql:test_limitOffset() local str = Store:_sqlConstructSelect ("people", nil, { limit = 10 }) assert_equal("SELECT * FROM people LIMIT 10", str) local str = Store:_sqlConstructSelect ("people", nil, { limit = 10, offset = 2 }) assert_equal("SELECT * FROM people LIMIT 10 OFFSET 2", str) end function sql:test_orderBy() local str = Store:_sqlConstructSelect ("people", nil, { order = "firstName ASC" }) assert_equal("SELECT * FROM people ORDER BY firstName ASC", str) local str = Store:_sqlConstructSelect("people", nil, { order = "firstName ASC, lastName DESC" }) assert_equal("SELECT * FROM people ORDER BY firstName ASC, lastName DESC", str) end function sql:test_select() local str = Store:_sqlConstructSelect ("people", nil, { select = "id, firstName" }) assert_equal("SELECT id, firstName FROM people", str) end function sql:test_criteria() local str = Store:_sqlAddCriteria("", 1) assert_equal(" WHERE id = 1", str) local str = Store:_sqlAddCriteria("", "magic=5") assert_equal(" WHERE magic=5", str) local str = Store:_sqlAddCriteria("", { age = 25, id = {21, 22, 23}}) assert_equal(" WHERE age = 25 AND id IN ( 21, 22, 23 )", str) local str = Store:_sqlAddCriteria("", { id = {22}; age = 25 }) assert_equal(" WHERE id = 22 AND age = 25", str) assert_error("Expected sql conversion error", function() Store:_sqlAddCriteria("", { id = {}}) end) end function sql:test_join() local str = Store:_sqlAddJoin("", "project", { tableName = "developerproject", on = {id = "project_id"} }) assert_equal(" INNER JOIN developerproject ON project.id = developerproject.project_id", str) local str = Store:_sqlAddJoin("", "project", { type = "OUTER", tableName = "developerproject", on = {id = "project_id"} }) assert_equal(" OUTER JOIN developerproject ON project.id = developerproject.project_id", str) assert_error("Expected missing 'on'", function() Store:_sqlAddJoin("", "project", { tableName = "developerproject" }) end) end
function request_update() instrument:send_sysex({0xf0, 0x7e, 0xf7}) end gui:add_toolbutton("Request update", request_update) -- -- Called by the Patch Pirate core -- function parameter_changed(param, value) io.write(string.format("LUA: GUI changed param: %s (%s) = %s\n", param.label, param.id, value)) instrument:send_sysex({0xf0, 0x7f, high8(param.number), low8(param.number), high7(value), low7(value), 0xf7}) end function handle_sysex_data(data) io.write("LUA got sysex: ") for i, d in ipairs(data) do io.write(string.format("%02X", d)) if ((i%4)==0) then io.write(" ") end end io.write("\n") if (data:matches({ 0xf0, 0x7f })) then local param = bit32.bor(bit32.lshift(data[3], 8), data[4]) local value = sexwordfrom7s(data[5], data[6]) io.write(string.format("Got param: %04x %04x\n", param, value)) instrument:update_parameter(param, value) end end
local mongo = require "mongo" local M = {} M.__index = M function M.new() local o = { db = nil } setmetatable(o, M) return o end function M:connect(dbconf) self.conn = mongo.client(dbconf) end function M:use(db_name) self.conn:getDB(db_name) self.db = self.conn[db_name] end function M:find(coll_name, selector, fields) return self.db[coll_name]:find(selector, fields) end function M:find_one(coll_name, cond_tbl) return self.db[coll_name]:findOne(cond_tbl) end function M:insert(coll_name, obj) self.db[coll_name]:insert(obj) end function M:update(coll_name, indexs, obj_fields) self.db[coll_name]:update(indexs, obj_fields) end return M
-- Copyright © 2017 coord.cn. All rights reserved. -- @author QianYe([email protected]) -- @license MIT license local utils = require("miss-core.src.utils") local _M = {} -- @brief xml to lua table -- @param xml {string} -- <xml> -- <appid>123456</appid> -- <test>test</test> -- </xml> -- @return tab {object} -- { -- appid = 123456, -- test = test -- } function _M.decode(xml) local tab = {} local content = xml:match("<xml>(.+)</xml>") if not content then return nil end local lines = utils.split(content, "\n") for i = 1, #lines do local line = lines[i] local key, value = line:match('<(.-)><!%[CDATA%[(.-)%]%]>') if key and value then tab[key] = value else key, value, _ = line:match('<([^>]*)>([^<]*)') if key and value then tab[key] = value end end end return tab end -- @brief lua table to xml -- @param tab {object} -- @return xml {string} function _M.encode(tab) local xml = "<xml>" for key, val in pairs(tab) do xml = xml .. "<" .. key .. "><![CDATA[" .. val .. "]]></" .. key .. ">" end return xml .. "</xml>" end return _M
-------------------------------------------------------------------------------- --- Data walking with fancy checking facilities -- @module lua-aplicado.dsl.tree_walker_with_checker -- This file is a part of lua-nucleo library -- @copyright lua-nucleo authors (see file `COPYRIGHT` for the license) -------------------------------------------------------------------------------- -- Sandbox warning: alias all globals! -------------------------------------------------------------------------------- local assert, error, tostring, rawget, getmetatable, setmetatable = assert, error, tostring, rawget, getmetatable, setmetatable local table_insert, table_remove, table_concat = table.insert, table.remove, table.concat -------------------------------------------------------------------------------- local log, dbg, spam, log_error = import 'lua-aplicado/log.lua' { 'make_loggers' } ( "lua-aplicado/dsl/tree_walker_with_checker", "TWC" ) -------------------------------------------------------------------------------- local arguments, optional_arguments, method_arguments = import 'lua-nucleo/args.lua' { 'arguments', 'optional_arguments', 'method_arguments' } local is_string = import 'lua-nucleo/type.lua' { 'is_string' } local assert_is_function, assert_is_nil = import 'lua-nucleo/typeassert.lua' { 'assert_is_function', 'assert_is_nil' } local timap = import 'lua-nucleo/table-utils.lua' { 'timap' } local do_nothing = import 'lua-nucleo/functional.lua' { 'do_nothing' } local make_checker = import 'lua-nucleo/checker.lua' { 'make_checker' } local unique_object = import 'lua-nucleo/misc.lua' { 'unique_object' } local common_load_schema = import 'lua-nucleo/dsl/common_load_schema.lua' { 'common_load_schema' } local walk_tagged_tree = import 'lua-nucleo/dsl/tagged-tree.lua' { 'walk_tagged_tree' } -------------------------------------------------------------------------------- local create_tree_walker_with_checker_factory do local default_factory do local checker = function(self) method_arguments(self) return self.checker_ end default_factory = function() return { checker = checker; -- checker_ = make_checker(); } end end local prototype_mt do local current_node_path_key = unique_object() local fail = function(self, msg) local path = self:get_current_node_path() local data = path[#path] if not data then self:checker():fail("(???): " .. tostring(msg)) else local where = "" if data.file_ and data.line_ then where = data.file_ .. ":" .. data.line_ .. ": " end self:checker():fail( where .. "bad " .. tostring(data[self.tag_field_]) .. " \"" .. table_concat( self:get_current_node_path_readable(), self.node_path_separator_ ) .. "\": " .. tostring(msg) ) end return self end local ensure = function(self, msg, cond, err) if not cond then if not err then self:fail(msg) else self:fail(msg .. " (" .. tostring(err) .. ")") end end return self end local ensure_equals = function(self, msg, actual, expected) if actual ~= expected then self:fail( msg .. " (actual: `" .. tostring(actual) .. "', expected: `" .. tostring(expected) .. "')" ) end return self end local good = function(self) method_arguments(self) return self:checker():good() end local result = function(self) method_arguments(self) return self:checker():result() end local get_current_node_path = function(self) local path = self[current_node_path_key] if path == nil then path = { } self[current_node_path_key] = path end return path end local get_current_node = function(self) local path = self:get_current_node_path() return path[#path] end local get_node_path_name = function(node, name_field, tag_field) local name = node[name_field] if not is_string(name) or #name > 32 then -- NOTE: arbitrary limitation name = nil end if not name then name = tostring(node[tag_field]) if #name > 32 then name = name:sub(1, 29) .. "..." end name = "(" .. name .. ")" end return name end local get_current_node_path_readable = function(self) method_arguments(self) return timap( get_node_path_name, self:get_current_node_path(), self.name_field_, self.tag_field_ ) end local push_node_to_path = function(self, data) table_insert(self:get_current_node_path(), data) end local pop_node_from_path = function(self, data) local actual_node = table_remove(self:get_current_node_path()) -- Note raw equality check if actual_node ~= data then log_error("current path:", self:get_current_node_path_readable()) log_error( "tried to pop head", get_node_path_name(data, self.name_field_, self.tag_field_) ) error("bad implementation: unbalanced path") end end prototype_mt = { fail = fail; ensure = ensure; ensure_equals = ensure_equals; -- good = good; result = result; -- get_current_node = get_current_node; get_current_node_path = get_current_node_path; get_current_node_path_readable = get_current_node_path_readable; push_node_to_path = push_node_to_path; pop_node_from_path = pop_node_from_path; -- tag_field_ = "id"; name_field_ = "name"; node_path_separator_ = "."; } prototype_mt.__metatable = "twwc" prototype_mt.__index = prototype_mt end local wrap_down, wrap_up do wrap_down = function(handler) arguments("function", handler) return function(walkers, data, key) walkers:push_node_to_path(data) local result = handler(walkers, data, key) if result == "break" then walkers:pop_node_from_path(data) end return result end end wrap_up = function(handler) arguments("function", handler) return function(walkers, data, key) handler(walkers, data, key) walkers:pop_node_from_path(data) end end end local up = { } do up["walker:tag_field"] = function(self, data) assert(self.updown_.tag_field_ == nil, "duplicate tag field definition") self.updown_.tag_field_ = data.name end up["walker:name_field"] = function(self, data) assert(self.updown_.name_field_ == nil, "duplicate name field definition") self.updown_.name_field_ = data.name end up["walker:node_path_separator"] = function(self, data) assert( self.updown_.node_path_separator_ == nil, "duplicate node path separator field definition" ) self.updown_.node_path_separator_ = data.name end up["walker:default_down"] = function(self, data) self:set_down_mt(assert_is_function(data.handler)) end up["walker:default_up"] = function(self, data) self:set_up_mt(assert_is_function(data.handler)) end up["walker:down"] = function(self, data) local name = data.name local down = self.updown_.down if rawget(down, data.name) ~= nil then error( "duplicate walker:down \"" .. tostring(data.name) .. "\" definition" ) end down[data.name] = wrap_down(assert_is_function(data.handler)) end up["walker:up"] = function(self, data) local name = data.name local up = self.updown_.up if rawget(up, data.name) ~= nil then error( "duplicate walker:up \"" .. tostring(data.name) .. "\" definition" ) end up[data.name] = wrap_up(assert_is_function(data.handler)) end up["walker:factory"] = function(self, data) assert_is_nil(self.factory_, "duplicate factory definition") self.factory_ = assert_is_function(data.handler) end end local set_down_mt, set_up_mt do local common_set_mt = function(t, handler, err, mt_name) arguments( "table", t, "function", handler, "string", err, "string", mt_name ) assert(getmetatable(t) == nil, err) setmetatable( t, { __index = function(t, k) local v = handler t[k] = v return v end; __metatable = mt_name; } ) end set_down_mt = function(self, handler) method_arguments( self, "function", handler ) common_set_mt( self.updown_.down, wrap_down(handler), "duplicate default_down call", "twwc.updown.down" ) end set_up_mt = function(self, handler) method_arguments( self, "function", handler ) common_set_mt( self.updown_.up, wrap_up(handler), "duplicate default_up call", "twwc.updown.up" ) end end local fail_at_unknown_down = function(self, data) -- NOTE: Overhead! Move this check at metatable level. if not rawget(self.up, data[self.tag_field_]) then self:fail("unknown language construct") return "break" -- Do not traverse subtree end end create_tree_walker_with_checker_factory = function(chunk, extra_env) extra_env = extra_env or { } arguments( "function", chunk, "table", extra_env ) local schema = common_load_schema(chunk, extra_env, { "walker" }) local updown = { down = { }; up = { }; } updown.__index = updown updown.__metatable = "twwc.updown" local walkers = { up = up; -- set_down_mt = set_down_mt; set_up_mt = set_up_mt; -- updown_ = updown; factory_ = nil; } for i = 1, #schema do -- Note this "id" is not the same as the data tag_field. walk_tagged_tree(schema[i], walkers, "id") end if getmetatable(walkers.updown_.down) == nil then walkers:set_down_mt(fail_at_unknown_down) end if getmetatable(walkers.updown_.up) == nil then walkers:set_up_mt(do_nothing) end local factory = walkers.factory_ or default_factory local mt = setmetatable(updown, prototype_mt) return function(...) local result = factory(...) -- Your walker should provide checker() method. -- See default_factory() implementation. assert(result.down == nil, "bad twwc factory: down defined") assert(result.up == nil, "bad twwc factory: up defined") assert_is_function(result.checker, "bad twwc factory: missing walker") return setmetatable(result, mt) end end end -------------------------------------------------------------------------------- return { create_tree_walker_with_checker_factory = create_tree_walker_with_checker_factory; }
local M = {} package.loaded[...] = M M.prefix = 'view.' local __M = {} __M.__call = function(M, view_name) local ok, template = pcall(require, M.prefix..view_name) if not ok then return nil, 'view not found' end local view = {}; view.template = template; view.type_error = function(path, type_got) return 'ERR('..path..','..type_got..')' end view.render = function(self, args) local evaluate = function(context, path) local value = context ngx.re.gsub(path, '([^\\.]+)', function(part) value = value[part[1]] return part[0] end ) return value end local origin_render = render render = function(template, context) local output = '' local template_pattern = '(\\{!(.+?)#(.+?)#(.+?)\\})|(\\{\\$\\})|(\\{#(.+?)\\})' local start = 1 while(start < string.len(template)) do local from, to = ngx.re.find(string.sub(template, start), template_pattern) if from == nil then output = output..string.sub(template, start) start = string.len(template) else output = output..string.sub(template, start, start + from - 2) local expression = string.sub(template, start + from - 1, start + to - 1) local match = ngx.re.match(expression, template_pattern) start = start + to if match[6] ~= nil then local value = evaluate(context, match[7]) if type(value) ~= 'string' then output = output..self.type_error(match[7], type(value)) else output = output..value end elseif match[1] ~= nil then local skip = 0 local inner_output = nil local origin_k = context[match[3]] local origin_v = context[match[4]] for k, v in pairs(evaluate(context, match[2])) do context[match[3]] = k context[match[4]] = v inner_output, skip = render(string.sub(template, start), context) output = output..inner_output end context[match[3]] = origin_k context[match[4]] = origin_v start = start + skip elseif match[5] ~= nil then return output, start else output = output..match[0] end end end return output, start end local output = render(self.template, args) ngx.print(output) render = origin_render end return view end setmetatable(M, __M) return M