content
stringlengths 5
1.05M
|
|---|
-----------------------------------------
-- ID: 4755
-- Scroll of Fire IV
-- Teaches the black magic Fire IV
-----------------------------------------
function onItemCheck(target)
return target:canLearnSpell(147)
end
function onItemUse(target)
target:addSpell(147)
end
|
-- LÖVE lovecase demo script.
local lovecase = require "lovecase"
function love.load()
local report = lovecase.runAllTestFiles("demo", true)
print(report:printResults())
end
|
-- EDU Bot NodeMCU Lua firmware, 2016 sw@kaltpost.de
-- MIT License (MIT)
-- See LICENSE file for details
require("router")
print("Started telnetd")
s=net.createServer(net.TCP, 180)
s:listen(23, function(c)
function s_output(str)
if(c~=nil)
then c:send(str .. "\n")
end
end
c:on("receive", function(c, l)
s_output(router.route(l))
end)
c:on("disconnection", function(c)
s_output("OK")
end)
end)
|
local lspconfig = require("lspconfig")
-- local lspinstall = require("polarmutex.lsp.install")
-- require('vim.lsp.log').set_level("trace")
-- require('vim.lsp.log').set_level("debug")
require("polarmutex.lsp.handlers")
-- require("polarmutex.lsp.servers.prosemd").setup()
require("polarmutex.lsp.servers.beancount")
require("polarmutex.lsp.servers.clangd")
-- require("polarmutex.lsp.servers.ccls")
require("polarmutex.lsp.servers.efm")
require("polarmutex.lsp.servers.prosemd")
require("polarmutex.lsp.servers.pyright")
require("polarmutex.lsp.servers.sumneko")
-- require("polarmutex.lsp.servers.nlua")
require("polarmutex.lsp.servers.svelte")
require("polarmutex.lsp.servers.typescript")
require("polarmutex.lsp.servers.vimls")
|
--- Animate variables
-- @submodule Actions
local ActionInstance = require("adam.system.action_instance")
local M = {}
-- @treturn ActionInstance
function M.animate_value(source, target, time, delay, finish_event, ease_function)
local action = ActionInstance(function(self)
-- how can i animate table property?
end)
action:set_delay(delay)
action:set_name("animation.animate_value")
return action
end
-- @treturn ActionInstance
function M.play_flipbook(target_url, image, finish_event, delay)
local action = ActionInstance(function(self)
-- how can i animate table property?
target_url = target_url or self:get_adam_instance():get_self()
sprite.play_flipbook(target_url, image, function()
self:finish(finish_event)
end)
end)
action:set_delay(delay)
action:set_name("animation.play_flipbook")
return action
end
return M
|
local module = {}
local actions = game:GetService('ContextActionService')
local setCore = require(game:GetService('ReplicatedStorage').Common.SetCore)
local action_name = 'TogglePhotoMode'
local title_format = 'Press %s to %s'
local attribute_name = 'Invisible'
local toggle = false
local hud
local enable = {
[Enum.CoreGuiType.Chat] = true,
}
local disable = {
[Enum.CoreGuiType.Chat] = false,
}
local function OnKey(_, state)
if state == Enum.UserInputState.Begin then
module.Toggle()
end
return Enum.ContextActionResult.Pass
end
function module.Toggle()
toggle = not toggle
setCore.TryCore('SendNotification', {
Title = [[Photo Mode]],
Text = string.format(title_format, [['L']], toggle and [[disable Photo Mode]] or [[re-enable Photo Mode]]),
Duration = 3
})
setCore.SetEnabled(toggle and disable or enable)
for _, gui in ipairs(hud:GetChildren()) do
local visibility = false
if toggle then
gui:SetAttribute(attribute_name, not gui.Visible)
else
if gui:GetAttribute(attribute_name) then continue end
visibility = true
end
gui.Visible = visibility
end
end
function module.Start(_, newHud)
hud = newHud
actions:BindAction(action_name, OnKey, false, Enum.KeyCode.L)
end
function module.Stop()
actions:UnbindAction(action_name)
end
return module
|
local function isSnowflake(id)
return type(id) == 'string' and #id >= 17 and #id <= 64 and not id:match('%D')
end
env.isSnowflake = isSnowflake
env.tobool = function(v)
v = tostring(v:lower())
return (v == '1' or v == 'on' or v:find('t')) and true or false
end
env.toMember = function(v, g)
if not v or type(g) ~= "table" then return end
local mention = v:match('<@%!?(%d+)>')
local memberID = v:match('%d+')
local id = mention or memberID
if not isSnowflake(id) then return end
return (id and g:getMember(id))
end
env.toChannel = function(v, g)
local channelMention = v:match('<#(%d+)>')
local channelID = v:match('%d+')
local channelName = v:match('[%S%-]+')
local id = channelMention or channelID
if id and isSnowflake(id) then
return client:getChannel(id)
elseif channelName then
return g and g.textChannels:find(function(c)
return c.name == channelName
end)
end
end
env.toMessage = function(v, c)
local guildID, channelID, messageLink = v:match('https://discordapp.com/channels/(%d+)/(%d+)/(%d+)')
local messageID = v:match('%d+')
local id = messageLink or messageID
if not isSnowflake(id) then return end
if type(c) ~= 'table' then
if isSnowflake(channelID) then
c = client:getChannel(channelID)
elseif isSnowflake(c) then
c = client:getChannel(c)
else
c = env.toChannel(c, client:getGuild(guildID))
end
if not c then return end
end
return id and c:getMessage(id)
end
|
-- Created by Elfansoer
--[[
Ability checklist (erase if done/checked):
- Scepter Upgrade
- Break behavior
- Linken/Reflect behavior
- Spell Immune/Invulnerable/Invisible behavior
- Illusion behavior
- Stolen behavior
]]
--------------------------------------------------------------------------------
skywrath_mage_mystic_flare_lua = class({})
LinkLuaModifier( "modifier_skywrath_mage_mystic_flare_lua_thinker", "lua_abilities/skywrath_mage_mystic_flare_lua/modifier_skywrath_mage_mystic_flare_lua_thinker", LUA_MODIFIER_MOTION_NONE )
--------------------------------------------------------------------------------
-- Custom KV
-- AOE Radius
function skywrath_mage_mystic_flare_lua:GetAOERadius()
return self:GetSpecialValueFor( "radius" )
end
--------------------------------------------------------------------------------
-- Ability Start
function skywrath_mage_mystic_flare_lua:OnSpellStart()
-- unit identifier
local caster = self:GetCaster()
local point = self:GetCursorPosition()
-- load data
local duration = self:GetSpecialValueFor( "duration" )
local radius = self:GetSpecialValueFor( "radius" )
-- create thinker
CreateModifierThinker(
caster, -- player source
self, -- ability source
"modifier_skywrath_mage_mystic_flare_lua_thinker", -- modifier name
{ duration = duration }, -- kv
point,
caster:GetTeamNumber(),
false
)
-- play effects
local sound_cast = "Hero_SkywrathMage.MysticFlare.Cast"
EmitSoundOn( sound_cast, caster )
-- scepter effect
if caster:HasScepter() then
local scepter_radius = self:GetSpecialValueFor( "scepter_radius" )
-- find nearby enemies
local enemies = FindUnitsInRadius(
caster:GetTeamNumber(), -- int, your team number
point, -- point, center point
nil, -- handle, cacheUnit. (not known)
scepter_radius, -- float, radius. or use FIND_UNITS_EVERYWHERE
DOTA_UNIT_TARGET_TEAM_ENEMY, -- int, team filter
DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, -- int, type filter
DOTA_UNIT_TARGET_FLAG_FOW_VISIBLE + DOTA_UNIT_TARGET_FLAG_NO_INVIS, -- int, flag filter
0, -- int, order filter
false -- bool, can grow cache
)
local target = nil
local creep = nil
-- prioritize hero
for _,enemy in pairs(enemies) do
-- only enemies outside cast aoe
if (enemy:GetOrigin()-point):Length2D()>radius then
if enemy:IsHero() then
target = enemy
break
elseif not creep then
-- store first found creep
creep = enemy
end
end
end
-- no secondary hero found, find creep
if not target then
target = creep
end
if target then
-- create thinker
CreateModifierThinker(
caster, -- player source
self, -- ability source
"modifier_skywrath_mage_mystic_flare_lua_thinker", -- modifier name
{ duration = duration }, -- kv
target:GetOrigin(),
caster:GetTeamNumber(),
false
)
end
end
end
|
--[[
Original textures from GeMinecraft
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1440575-1-2-5-generation-minecraft-beta-1-2-farming-and
]]
local S = farming.intllib
-- corn seeds
minetest.register_node("hades_extrafarming:seed_corn", {
description = S("Corn Seeds"),
tiles = {"farming_corn_seed.png"},
inventory_image = "farming_corn_seed.png",
wield_image = "farming_corn_seed.png",
drawtype = "signlike",
groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4},
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
sunlight_propagates = true,
selection_box = farming.select,
on_place = function(itemstack, placer, pointed_thing)
return farming.place_seed(itemstack, placer, pointed_thing, "hades_extrafarming:corn_1")
end
})
minetest.register_craft({
type = "shapeless",
output = "hades_extrafarming:seed_corn",
recipe = {"group:food_corn"}
})
-- corn
minetest.register_craftitem("hades_extrafarming:corn", {
description = S("Corn"),
inventory_image = "farming_corn.png",
groups = {food_corn = 1, flammable = 2, food = 2, eatable = 3},
on_use = minetest.item_eat(3)
})
-- corn on the cob (texture by TenPlus1)
minetest.register_craftitem("hades_extrafarming:corn_cob", {
description = S("Corn on the Cob"),
inventory_image = "farming_corn_cob.png",
groups = {food_corn_cooked = 1, flammable = 2, food = 2, eatable = 5},
on_use = minetest.item_eat(5)
})
minetest.register_craft({
type = "cooking",
cooktime = 10,
output = "hades_extrafarming:corn_cob",
recipe = "group:food_corn"
})
-- popcorn
minetest.register_craftitem("hades_extrafarming:popcorn", {
description = S("Popcorn"),
inventory_image = "farming_popcorn.png",
groups = {food_popcorn = 1, flammable = 2, eatable = 4},
on_use = minetest.item_eat(4)
})
minetest.register_craft({
output = "hades_extrafarming:popcorn",
recipe = {
{"group:food_pot", "group:food_oil", "group:food_corn"}
},
replacements = {
{"group:food_pot", "hades_extrafarming:pot"},
{"group:food_oil", "vessels:glass_bottle"}
}
})
-- cornstarch
minetest.register_craftitem("hades_extrafarming:cornstarch", {
description = S("Cornstarch"),
inventory_image = "farming_cornstarch.png",
groups = {food_cornstarch = 1, food_gelatin = 1, food_flammable = 2}
})
minetest.register_craft({
output = "hades_extrafarming:cornstarch",
recipe = {
{"group:food_mortar_pestle", "group:food_corn_cooked", "group:food_baking_tray"},
{"", "group:food_bowl", ""},
},
replacements = {
{"group:food_mortar_pestle", "hades_extrafarming:mortar_pestle"},
{"group:food_baking_tray", "hades_extrafarming:baking_tray"}
}
})
-- ethanol (thanks to JKMurray for this idea)
minetest.register_node("hades_extrafarming:bottle_ethanol", {
description = S("Bottle of Ethanol"),
drawtype = "plantlike",
tiles = {"farming_bottle_ethanol.png"},
inventory_image = "farming_bottle_ethanol.png",
wield_image = "farming_bottle_ethanol.png",
paramtype = "light",
is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = hades_sounds.node_sound_glass_defaults()
})
minetest.register_craft( {
output = "hades_extrafarming:bottle_ethanol",
recipe = {
{"group:food_corn", "group:food_corn", "group:food_corn"},
{"group:food_corn", "vessels:glass_bottle", "group:food_corn"},
{"group:food_corn", "group:food_corn", "group:food_corn"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "hades_extrafarming:bottle_ethanol",
burntime = 80,
replacements = {{"hades_extrafarming:bottle_ethanol", "vessels:glass_bottle"}}
})
-- corn definition
local def = {
drawtype = "plantlike",
tiles = {"farming_corn_1.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = hades_sounds.node_sound_leaves_defaults()
}
-- stage 1
minetest.register_node("hades_extrafarming:corn_1", table.copy(def))
-- stage 2
def.tiles = {"farming_corn_2.png"}
minetest.register_node("hades_extrafarming:corn_2", table.copy(def))
-- stage 3
def.tiles = {"farming_corn_3.png"}
minetest.register_node("hades_extrafarming:corn_3", table.copy(def))
-- stage 4
def.tiles = {"farming_corn_4.png"}
minetest.register_node("hades_extrafarming:corn_4", table.copy(def))
-- stage 5
def.tiles = {"farming_corn_5.png"}
minetest.register_node("hades_extrafarming:corn_5", table.copy(def))
-- stage 6
def.tiles = {"farming_corn_6.png"}
def.visual_scale = 1.9
minetest.register_node("hades_extrafarming:corn_6", table.copy(def))
-- stage 7
def.tiles = {"farming_corn_7.png"}
def.drop = {
items = {
{items = {"hades_extrafarming:corn"}, rarity = 1},
{items = {"hades_extrafarming:corn"}, rarity = 2},
{items = {"hades_extrafarming:corn"}, rarity = 3}
}
}
minetest.register_node("hades_extrafarming:corn_7", table.copy(def))
-- stage 8 (final)
def.tiles = {"farming_corn_8.png"}
def.groups.growing = nil
def.drop = {
items = {
{items = {"hades_extrafarming:corn 2"}, rarity = 1},
{items = {"hades_extrafarming:corn 2"}, rarity = 2},
{items = {"hades_extrafarming:corn 2"}, rarity = 2}
}
}
minetest.register_node("hades_extrafarming:corn_8", table.copy(def))
-- add to registered_plants
farming.registered_plants["hades_extrafarming:corn"] = {
crop = "hades_extrafarming:corn",
seed = "hades_extrafarming:seed_corn",
minlight = farming.min_light,
maxlight = farming.max_light,
steps = 8
}
|
local MP = minetest.get_modpath(minetest.get_current_modname())
local Channel = dofile(MP .. "/util/channel.lua")
local channel
-- auth request from webmail
local function auth_handler(auth)
local handler = minetest.get_auth_handler()
minetest.log("action", "[webmail] auth: " .. auth.name)
local success = false
local entry = handler.get_auth(auth.name)
if entry and minetest.check_password_entry(auth.name, entry.password, auth.password) then
success = true
end
channel.send({
type = "auth",
data = {
name = auth.name,
success = success
}
})
end
-- send request from webmail
local function send_handler(sendmail)
-- send mail from webclient
minetest.log("action", "[webmail] sending mail from webclient: " .. sendmail.src .. " -> " .. sendmail.dst)
mail.send(sendmail.src, sendmail.dst, sendmail.subject, sendmail.body)
end
-- get player messages request from webmail
local function get_player_messages_handler(playername)
channel.send({
type = "player-messages",
playername = playername,
data = mail.messages[playername]
})
end
-- remove mail
local function delete_mail_handler(playername, index)
if mail.messages[playername] and mail.messages[playername][index] then
table.remove(mail.messages[playername], index)
end
end
-- mark mail as read
local function mark_mail_read_handler(playername, index)
if mail.messages[playername] and mail.messages[playername][index] then
mail.messages[playername][index].unread = false
end
end
-- mark mail as unread
local function mark_mail_unread_handler(playername, index)
if mail.messages[playername] and mail.messages[playername][index] then
mail.messages[playername][index].unread = true
end
end
function mail.webmail_send_hook(src,dst,subject,body)
channel.send({
type = "new-message",
data = {
src=src,
dst=dst,
subject=subject,
body=body
}
})
end
mail.register_on_receive(mail.webmail_send_hook)
function mail.webmail_init(http, url, key)
channel = Channel(http, url .. "/api/minetest/channel", {
extra_headers = { "webmailkey: " .. key }
})
channel.receive(function(data)
if data.type == "auth" then
auth_handler(data.data)
elseif data.type == "send" then
send_handler(data.data) -- { src, dst, subject, body }
elseif data.type == "delete-mail" then
delete_mail_handler(data.playername, data.index) -- index 1-based
elseif data.type == "mark-mail-read" then
mark_mail_read_handler(data.playername, data.index) -- index 1-based
elseif data.type == "mark-mail-unread" then
mark_mail_unread_handler(data.playername, data.index) -- index 1-based
elseif data.type == "player-messages" then
get_player_messages_handler(data.data)
end
end)
end
|
#!/usr/local/bin/lua
local aux = require'ferre.aux'
local lpr = require'ferre.bixolon'
local tkt = require'ferre.ticket'
local ex = require'ferre.extras'
local precio = require'ferre.precio'
local fd = require'carlos.fold'
--[[ NEED TO BE REWRITTEN XXX
local ventas = {VENTA=true, FACTURA=true, CREDITO=true}
local function ventap(s)
return (ventas[s] and 'ventas' or 'tickets')
end
--]]
local function tickets(q)
local uid = q.uid
local tag = q.tag or ''
local y,m,d = uid:match'^(%d+)-(%d+)-(%d+)'
local week = ex.asweek(os.time{year=y, month=m, day=d})
local conn = assert(ex.dbconn(week), 'Error while connecting to DB ' .. week)
local QRY = 'SELECT * FROM %s WHERE uid LIKE %q'
assert(conn.exec'ATTACH DATABASE "/db/ferre.db" AS FR')
local nombres = fd.reduce( conn.query'SELECT * FROM empleados', fd.rejig(function(w) return w.nombre, w.id end), fd.merge, {} )
local function fetch()
local p = nombres[math.tointeger(uid:match'(%d+)$')] or 'NaP'
local total = 0
local suma = fd.map(function(w) total = total + w.totalCents; return w end)
-- uid REQUIRED to get DATE & TIME
local ret = {uid=uid, person=p, tag=tag}
ret.datos = fd.reduce( conn.query(string.format(QRY, 'tickets', uid)), fd.map(precio(conn)), suma, fd.into, {} ) -- ventap(tag) : DBase to connect
ret.total = string.format('%.2f', total/100)
return ret
end
lpr( tkt( fetch() ) )
--]]
return 'OK'
end
aux( tickets )
|
local util = require("terrautil")
local T = terralib.irtypes
T:Define [[
TerraData = (Type type) unique
]]
function T.TerraData:init()
function self.__tostring()
return ("terradata<%s>"):format(tostring(self.type))
end
end
-- equivalent to ffi.typeof, takes a cdata object and returns associated terra type object
function terra.typeof(obj)
local mt = getmetatable(obj)
if not T.TerraData:isclassof(mt) then
error(("expected a terradata<T> type but found '%s'"):format(terra.type(obj)))
end
return mt.type
end
-- terra.stringraw is provided by tcompiler.cpp
function terra.string(ptr,len)
local typ = terra.typeof(ptr)
if type(len) ~= "number" then
if terra.types.rawstring ~= typ then
error(("expected a '%s' but found '%s'"):format(tostring(terra.types.rawstring),tostring(typ)))
end
else
if not typ:ispointer() then
error(("expected a pointer type but found '%s'"):format(tostring(typ)))
end
end
return terra.stringraw(ptr,len)
end
function terra.offsetof(terratype,field)
if not T.struct:isclassof(terratype) then
error(("expected a terra struct but found"):format(terra.type(terratype)))
end
terratype:complete()
local layout = terratype:getlayout()
local idx = layout.keytoindex[field]
if not idx then
error(("no field '%s' in struct '%s'"):format(tostring(field),tostring(terratype)))
end
return terra.llvmoffsetof(terra.jitcompilationunit,terratype,idx)
end
function terra.new(terratype,...)
error("NYI - new")
end
function terra.cast(terratype,obj)
terratype:complete()
error("NYI - cast")
end
--[[
### Rules for converting Terra values to Lua objects, adapted from LuaJIT FFI:
integers that can fit in a double --> "number"
boolean -> "boolean"
everything becomes "terradata", which as a "userdata" with sizeof(T) whose payload
is the Terra value, the metatable is per-type and defines standard operations for that type in Lua
###
]]
function T.terrafunction:__call(...)
if not self.ffiwrapper then
local terraffi = require("terraffi")
self.ffiwrapper = terraffi.wrap(self)
end
return self.ffiwrapper(...)
end
|
local player = ...
local mods = SL[ToEnumShortString(player)].ActiveModifiers
-- No judgement in DoNotJudgeMe mode.
if mods.DoNotJudgeMe then
return Def.ActorFrame{
Name="Pane1",
InitCommand=cmd(xy, 0, 250),
LoadActor("otter.png")..{ OnCommand=function(self) self:zoomto(210,130) end }
}
end
return Def.ActorFrame{
Name="Pane1",
-- Position all pane elements on the screen
InitCommand=cmd(xy, 47, 200),
-- labels (like "FANTASTIC, MISS, holds, rolls, etc.")
LoadActor("./JudgmentLabels.lua", player),
-- DP score displayed as a percentage
LoadActor("./Percentage.lua", player),
-- numbers (how many Fantastics? How many misses? etc.)
LoadActor("./JudgmentNumbers.lua", player),
}
|
-----------------------------------------------------
---! @file
---! @brief
------------------------------------------------------
local const = {}
setmetatable(const, {
__index = function (t, k)
return function()
print("unknown field from const: ", k, t)
end
end
})
const.GAMEID = 2013
const.GAMEVERSION = 20170101
const.LOWVERSION = 20160107
---! const values
const.YUNCHENG_CARD_FLOWER = 55
const.YUNCHENG_CARD_BACKGROUND = 56
const.YUNCHENG_PLAYER_CARD_NUM = 17
const.YUNCHENG_LORD_CARD_NUM = 20
const.YUNCHENG_MAX_PLAYER_NUM = 3
const.kCard_ValueLeast = 2
const.kCard_Value3 = 3
const.kCard_Value4 = 4
const.kCard_Value5 = 5
const.kCard_Value6 = 6
const.kCard_Value7 = 7
const.kCard_Value8 = 8
const.kCard_Value9 = 9
const.kCard_ValueT = 10 -- Ten
const.kCard_ValueJ = 11
const.kCard_ValueQ = 12
const.kCard_ValueK = 13
const.kCard_ValueA = 14
const.kCard_Value2 = 15
const.kCard_ValueJoker1 = 16
const.kCard_ValueJoker2 = 17
const.kCard_Joker1 = 53
const.kCard_Joker2 = 54
const.kCardType_Single = 1 -- 单纯类型, seriaNum == 1
const.kCardType_Serial = 2 -- 单顺, 双顺, 三顺(飞机), 4顺
const.kCardType_Rocket = 3 -- 火箭(大小王)
---! game trace
const.YUNCHENG_GAMETRACE_PICKUP = 1 -- 发牌
const.YUNCHENG_GAMETRACE_DISCLOSE = 2 -- 明牌
const.YUNCHENG_GAMETRACE_REFRESH = 3 -- 更新牌面
const.YUNCHENG_GAMETRACE_LANDLORD = 4 -- 叫地主
const.YUNCHENG_GAMETRACE_MULTIPLE = 5 -- 加倍
const.YUNCHENG_GAMETRACE_THROW = 6 -- 出牌
const.YUNCHENG_GAMETRACE_SHOWBOTTOM = 7 -- 显示底牌
const.YUNCHENG_GAMETRACE_BOMBMULT = 8 -- 炸弹, 更新倍数
const.YUNCHENG_GAMETRACE_GAMEOVER = 10
---! table status
const.YUNCHENG_TABLE_STATUS_WAIT_NEWGAME = 5
const.YUNCHENG_TABLE_STATUS_WAIT_PICKUP = 6 -- 发牌
const.YUNCHENG_TABLE_STATUS_WAIT_LANDLORD = 7 -- 叫地主
const.YUNCHENG_TABLE_STATUS_WAIT_MULTIPLE = 8 -- 加倍
const.YUNCHENG_TABLE_STATUS_WAIT_THROW = 9
const.YUNCHENG_TABLE_STATUS_WAIT_GAMEOVER = 10
---! time out
const.YUNCHENG_TIMEOUT_WAIT_PICKUP = 5
const.YUNCHENG_TIMEOUT_WAIT_LANDLORD = 10
const.YUNCHENG_TIMEOUT_WAIT_MULTIPLE = 10
const.YUNCHENG_TIMEOUT_WAIT_THROW = 25
const.YUNCHENG_TIMEOUT_WAIT_OFFLINE = 5
const.YUNCHENG_TIMEOUT_WAIT_GAMEOVER = 2
const.YUNCHENG_TIMEOUT_WAIT_NEWGAME = 3
---! card types
const.kGiftItems = {
egg = 0,
water = 0,
bomb = 0,
cheer = 0,
flower = 0,
kiss = 0,
slap = 0,
car = 0,
house = 0,
}
const.YUNCHENG_ACL_STATUS_RESTART_NO_MASTER = 101; -- 没有人叫地主, 重新开始
const.YUNCHENG_ACL_STATUS_NO_SELECT_CARDS = 102; -- 你没有选择任何牌
const.YUNCHENG_ACL_STATUS_NOT_VALID_TYPE = 103; -- 不能组成有效牌型
const.YUNCHENG_ACL_STATUS_NOT_SAME_TYPE = 104; -- 不是同一牌型
const.YUNCHENG_ACL_STATUS_NOT_BIGGER = 105; -- 打不过别人的牌
const.YUNCHENG_ACL_STATUS_NO_BIG_CARDS = 106; -- 没有牌能大过上家
const.YUNCHENG_ACL_STATUS_NO_YOUR_CARDS = 107; -- 发的牌不是你的牌
const.deltaSeat = function (seatId, delta)
seatId = seatId + (delta and delta or 1)
seatId = (seatId - 1 + const.YUNCHENG_MAX_PLAYER_NUM) % const.YUNCHENG_MAX_PLAYER_NUM + 1
return seatId
end
const.isRocket = function (node)
return node.cardType == const.kCardType_Rocket
end
const.isBomb = function (node)
return node.seralNum==1 and node.mainNum >= 4 and node.subNum == 0
end
const.removeSubset = function (main, sub)
local all = true
for _, n in ipairs(sub) do
local idx = nil
for i,v in ipairs(main) do
if v == n then
idx = i
break
end
end
if not idx then
all = nil
print(n , " not found in main ")
else
table.remove(main, idx)
end
end
return all
end
const.getCardValue = function (card)
if card == const.kCard_Joker1 then
return const.kCard_ValueJoker1;
end
if card == const.kCard_Joker2 then
return const.kCard_ValueJoker2;
end
local t = card % 13;
if t < 3 then
t = t + 13;
end
return t;
end
const.getCardItSelf = function (card)
return card
end
const.getSelCards = function (array, mainFunc, subset, subFunc)
local cards = {}
local subArr = {}
for i, v in ipairs(subset) do
subArr[i] = v
end
for _, sp in ipairs(array) do
local valueT = mainFunc(sp)
for i, v in ipairs(subArr) do
if valueT == subFunc(v) then
table.insert(cards, sp)
table.remove(subArr, i)
break
end
end
end
local ok = false
if #subArr == 0 then
ok = true
end
return ok, cards
end
const.levelScores = {
-1000,
0,
500,
1000,
2000,
5000,
10000,
20000,
50000,
100000,
200000,
500000,
1000000,
2000000,
5000000,
10000000,
20000000,
50000000,
100000000,
200000000,
500000000,
1000000000,
2000000000,
}
const.levelName = {
"包身工",
"短工",
"长工",
"佃户",
"贫农",
"渔夫",
"猎人",
"中农",
"富农",
"掌柜",
"商人",
"衙役",
"小财主",
"大财主",
"小地主",
"大地主",
"知县",
"通判",
"知府",
"总督",
"巡抚",
"丞相",
"帝王",
}
const.findLevelRank = function(score)
local ret = 1
for i = 1, #const.levelScores do
if score >= const.levelScores[i] then
ret = i
else
break
end
end
return ret
end
const.findLevelName = function(lvl)
if not lvl or lvl < 1 then
lvl = 1
elseif lvl > #const.levelScores then
lvl = #const.levelScores
end
local str = const.levelName[lvl]
return str
end
const.getNextLevelScore = function(score)
if score then
local lvl = const.findLevelRank(score) + 1
local nextScore
if not lvl or lvl < 1 then
lvl = 1
elseif lvl > #const.levelScores then
return nil
end
nextScore = const.levelScores[lvl]
return nextScore
end
return 1
end
return const
|
seCDhelperAnchor = {
bDragable = false,
Anchor = {s = "CENTER", r = "CENTER", x = 0, y = 0},
}
RegisterCustomData("seCDhelperAnchor.Anchor")
RegisterCustomData("seCDhelperAnchor.bDragable")
function seCDhelperAnchor.OnFrameCreate()
this:RegisterEvent("UI_SCALED")
end
function seCDhelperAnchor.OnEvent(event)
if event == "UI_SCALED" then
seCDhelperAnchor.UpdateAnchor(this)
seCDhelperAnchor.UpdateDrag()
FireEvent("seBuffTimerAnchorChanged")
end
end
function seCDhelperAnchor.OnFrameDrag()
end
function seCDhelperAnchor.UpdateDrag()
if seCDhelperAnchor.bDragable then
Station.Lookup("Topmost/seCDhelperAnchor"):Show()
else
Station.Lookup("Topmost/seCDhelperAnchor"):Hide()
end
end
function seCDhelperAnchor.OnFrameDragSetPosEnd()
this:CorrectPos()
seCDhelperAnchor.Anchor = GetFrameAnchor(this)
FireEvent("seCDhelperAnchorChanged")
end
function seCDhelperAnchor.OnFrameDragEnd()
this:CorrectPos()
seCDhelperAnchor.Anchor = GetFrameAnchor(this)
FireEvent("seCDhelperAnchorChanged")
end
function seCDhelperAnchor.UpdateAnchor(frame)
local anchor = seCDhelperAnchor.Anchor
frame:SetPoint(anchor.s, 0, 0, anchor.r, anchor.x, anchor.y)
frame:CorrectPos()
end
Wnd.OpenWindow("interface\\seCDhelper\\seCDhelperAnchor.ini", "seCDhelperAnchor")
|
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Wood (Crafting Ingredient)"
ENT.Author = "Lambda Gaming"
ENT.Spawnable = true
ENT.Category = "Crafting Table"
|
--TerrainsInit.lua
--Author: Jack Matters
--Date: 23/05/2018
--Brief: Load in all heightmaps data
--Note: Make filePath relative to CarreGameEngine.vcxproj
--Note: Use this file to load all heightmap data
--Note: "player" MUST BE present and MUST BE spelt correctly
--Note: Needs improvements
AllHeightmaps=
{
terrain=
{
{filePath = "res/terrain/newcity.raw", texFilePath = "res/terrain/grass.jpg", fileSize = 128, scaleX = 100.0, scaleY = 5.0, scaleZ = 100.0, posX = 0.0, posY = 0.0, posZ = 0.0},
},
buildings=
{
--{filePath = "res/terrain/buildingheightmap.raw", texFilePath = "res/terrain/buildingtexture.jpg", fileSize = 16, scaleX = 100.0, scaleY = 4.0, scaleZ = 100.0, posX = 6000.0, posY = -1.0, posZ = 6000.0},
},
}
|
_Parkings = {
--[[{
name = string - REQUIRED,
blipName = string - OPTIONAL,
blipColor = number - OPTIONAL,
zone = PolyZoneObject - REQUIRED,
fee = number - REQUIRED,
entrances = {
vector3(-279.25, -890.39, 30.08)
},
hideEntrance = boolean,
maxcar = number,
showEnter = boolean,
}, ]]
centralParkingArriba = {
name = "Parking Central",
fee = 1200,
maxcar = 25,
entrances = {
vector3(224.52, -738.09, 33.0)
},
zone = PolyZone:Create({
vector2(219.21, -753.44),
vector2(264.1643371582, -768.44061279297),
vector2(271.99243164062, -748.68383789062),
vector2(226.43690490723, -733.07666015625)
}, {
minZ = 34.0,
-- maxZ = 36.5,
}),
},
central397 = {
name = "Parking Central 397",
fee = 800,
maxcar = 15,
entrances = {
vector3(184.13, -724.73, 32.5),
vector3(84.67, -693.39, 30.5),
},
zone = PolyZone:Create({
vector2(186.8207244873, -688.10272216797),
vector2(162.18891906738, -756.45104980469),
vector2(85.613945007324, -728.63720703125),
vector2(100.27899169922, -687.77575683594),
vector2(148.82186889648, -674.33020019531)
}, {
minZ = 32.5,
maxZ = 36.5,
-- debugGrid=true
}),
},
central209 = {
name = "Parking Central 209",
fee = 1000,
maxcar = 15,
entrances = {
vector3(320.74, -700.35, 28.5),
},
zone = PolyZone:Create({
vector2(322.45217895508, -693.83947753906),
vector2(316.6965637207, -707.44232177734),
vector2(284.78912353516, -696.00347900391),
vector2(289.85623168945, -682.06231689453)
}, {
minZ = 28.5,
-- maxZ = 36.5,
}),
},
centralPisoPobre = {
name = "Parking Z.E.R",
maxcar = 8,
fee = 500,
entrances = {
vector3(307.37, -1071.23, 28.3),
},
zone = PolyZone:Create({
vector2(297.74990844727, -1069.1755371094),
vector2(309.69338989258, -1069.5327148438),
vector2(310.73245239258, -1119.4951171875),
vector2(298.04028320312, -1119.7993164062)
}, {
minZ = 28.5,
-- maxZ = 36.5,
}),
},
central213 = {
name = "Parking 213",
maxcar = 10,
entrances = {
vector3(236.2, -1159.61, 28.2),
},
zone = PolyZone:Create({
vector2(297.74990844727, -1069.1755371094),
vector2(309.69338989258, -1069.5327148438),
vector2(310.73245239258, -1119.4951171875),
vector2(298.04028320312, -1119.7993164062)
}, {
minZ = 28.5,
-- maxZ = 36.5,
}),
},
ammunation200 = {
name = "Parking Ammunation",
entrances = {
vector3(54.62, -1058.32, 28.5),
},
maxcar = 10,
zone = PolyZone:Create({
vector2(-3.7880523204803, -1032.8937988281),
vector2(-18.807891845703, -1073.7478027344),
vector2(-0.10139285773039, -1080.2509765625),
vector2(-8.3133583068848, -1105.0218505859),
vector2(14.01505947113, -1113.78515625),
vector2(25.972721099854, -1105.0301513672),
vector2(51.863086700439, -1053.0716552734)
}, {
minZ = 37.0,
-- debugGrid=true
}),
},
ammunationAfuera = {
name = "Parking Ammunation",
entrances = {
vector3(38.57, -1101.62, 27.9),
},
maxcar = 5,
zone = PolyZone:Create({
vector2(51.788486480713, -1090.5505371094),
vector2(38.689666748047, -1084.4910888672),
vector2(20.36407661438, -1119.1564941406),
vector2(31.362049102783, -1123.8967285156)
}, {
minZ = 27.9,
}),
},
parking206 = {
name = "Parking Central 206",
entrances = {
vector3(100.03, -1067.86, 27.9),
},
maxcar = 10,
zone = PolyZone:Create({
vector2(110.2107925415, -1046.8802490234),
vector2(96.416976928711, -1077.8547363281),
vector2(113.95830535889, -1084.5230712891),
vector2(149.40344238281, -1084.4375),
vector2(147.11799621582, -1061.0041503906)
}, {
minZ = 28.0,
maxZ = 32.0,
}),
},
parking584 = {
name = "Parking 584",
fee = 650,
maxcar = 10,
entrances = {
vector3(283.2, -354.98, 44.0),
},
zone = PolyZone:Create({
vector2(295.3505859375, -354.30935668945),
vector2(257.44253540039, -340.56881713867),
vector2(267.17907714844, -313.36639404297),
vector2(305.41983032227, -326.45709228516)
}, {
minZ = 28.5,
-- maxZ = 36.5,
}),
},
parkingEMS = {
name = "Parking EMS",
maxcar = 10,
entrances = {
vector3(-418.87, -295.98, 34.0),
vector3(-427.88, -366.45, 31.5),
},
zone = PolyZone:Create({
vector2(-417.82141113281, -369.45944213867),
vector2(-436.49029541016, -367.00939941406),
vector2(-425.03530883789, -288.87603759766),
vector2(-410.96200561523, -299.06228637695)
}, {
minZ = 31.0,
-- maxZ = 36.5,
}),
jobs = { 'ambulance' }
},
parkingPublicoEMS = {
name = "Parking EMS",
fee = 650,
maxcar = 10,
entrances = {
vector3(-365.90, -318.08, 31.0),
},
zone = PolyZone:Create({
vector2(-339.15124511719, -338.39270019531),
vector2(-329.2507019043, -314.31600952148),
vector2(-403.99453735352, -260.50967407227),
vector2(-420.80554199219, -279.41754150391)
}, {
minZ = 29.0,
-- maxZ = 36.5,
}),
},
parkingGratuitoEMS = {
name = "Parking Gratuit EMS",
maxcar = 10,
entrances = {
vector3(-433.93, -440.62, 31.5),
},
zone = PolyZone:Create({
vector2(-456.51409912109, -443.64981079102),
vector2(-429.50225830078, -446.32495117188),
vector2(-417.80718994141, -455.99887084961),
vector2(-419.85702514648, -465.95944213867),
vector2(-458.37075805664, -459.09002685547)
}, {
minZ = 31.0,
-- maxZ = 36.5,
}),
},
policeStation = {
name = "Parking LSPD",
maxcar = 10,
entrances = {
vector3(-1058.56, -877.3, 5.0),
},
zone = PolyZone:Create({
vector2(-1076.69, -876.02),
vector2(-1051.69, -876.02),
vector2(-1058.56, -876.02),
vector2(-1058.56, -876.02),
vector2(-1058.56, -876.02)
}, {
minZ = 24.0
}),
jobs = { 'police' }
},
taxiStation = {
name = "Parking Taxi",
maxcar = 5,
entrances = {
vector3(914.64, -179.94, 72.8),
},
zone = PolyZone:Create({
vector2(904.5625, -194.25276184082),
vector2(926.24066162109, -160.93862915039),
vector2(914.62322998047, -152.86856079102),
vector2(890.79711914062, -185.71098327637)
}, {
minZ = 72.0
}),
jobs = { 'taxi' }
},
airlinesStation = {
name = "Parking Aeroport",
maxcar = 5,
entrances = {
vector3(-997.39, -2908.48, 13.0),
},
zone = PolyZone:Create({
vector2(-994.00, -2948.52),
vector2(-974.33, -2914.63),
vector2(-996.504, -2901.53),
vector2(-1016.09, -2935.31),
}, {
minZ = 11.0
}),
jobs = { 'aeroportp' }
},
casinoStation = {
name = "Parking Casino",
fee = 1500,
entrances = {
vector3(924.85, -17.07, 77.00),
vector3(879.96, -88.89, 78.00),
},
maxcar = 10,
zone = PolyZone:Create({
vector2(949.90808105469, -36.249973297119),
vector2(934.86785888672, -64.720695495605),
vector2(946.044921875, -81.659622192383),
vector2(943.91174316406, -91.325477600098),
vector2(926.20526123047, -107.20796966553),
vector2(914.86871337891, -107.04007720947),
vector2(851.87188720703, -67.271911621094),
vector2(829.46838378906, -43.58727645874),
vector2(872.38415527344, 13.005387306213)
}, {
minZ = 75.0
-- debugGrid=true
}),
society = "society_casino"
},
parking382 = {
name = "Parking 382",
fee = 3000,
entrances = {
vector3(-279.25, -890.39, 30.08)
},
maxcar = 15,
zone = PolyZone:Create({
vector2(-363.97412109375, -872.61242675781),
vector2(-364.0071105957, -969.91284179688),
vector2(-296.05456542969, -994.67736816406),
vector2(-290.4270324707, -977.08093261719),
vector2(-283.4645690918, -924.81988525391),
vector2(-269.30850219727, -887.85803222656),
vector2(-345.55624389648, -871.81787109375)
}, {
minZ = 30.0
}),
},
parking34 = {
name = "Parking 34",
fee = 3000,
entrances = {
vector3(130.75, -2536.38, 5.0)
},
maxcar = 10,
zone = PolyZone:Create({
vector2(148.78430175781, -2531.8173828125),
vector2(152.84150695801, -2542.2097167969),
vector2(75.531021118164, -2544.5634765625),
vector2(70.752807617188, -2535.9296875),
vector2(83.076271057129, -2518.3356933594),
vector2(87.591773986816, -2522.1508789062)
}, {
minZ = 3.0
})
},
parking949 = {
name = "Parking 949",
fee = 3000,
entrances = {
vector3(1982.02, 3069.0, 46.0)
},
maxcar = 10,
zone = PolyZone:Create({
vector2(2007.9705810547, 3046.9934082031),
vector2(1998.4720458984, 3051.5361328125),
vector2(1978.6236572266, 3062.908203125),
vector2(1994.2033691406, 3088.3896484375),
vector2(2024.9884033203, 3069.0803222656)
}, {
minZ = 43.0
})
},
parking381 = {
name = "Parking 381",
fee = 2000,
entrances = {
vector3(-351.56, -824.39, 30.5)
},
maxcar = 15,
zone = PolyZone:Create({
vector2(-335.12908935547, -825.25671386719),
vector2(-364.66879272461, -826.15881347656),
vector2(-362.58465576172, -707.59173583984),
vector2(-339.78118896484, -707.66369628906),
vector2(-332.00588989258, -682.35296630859),
vector2(-290.8034362793, -682.67749023438),
vector2(-267.15789794922, -750.18212890625)
}, {
minZ = 30.524620056152
})
},
vinedos = {
name = "Parking Vigne",
entrances = {
vector3(-1874.54, 2038.6, 138.5),
vector3(-1884.19, 2007.2, 140.5),
},
maxcar = 10,
zone = PolyZone:Create({
vector2(-1921.6291503906, 2061.9162597656),
vector2(-1929.6076660156, 2028.6848144531),
vector2(-1911.328125, 2023.2541503906),
vector2(-1910.1420898438, 1996.9866943359),
vector2(-1888.1898193359, 1998.5826416016),
vector2(-1875.9741210938, 2044.0516357422)
}, {
minZ = 31.0
}),
jobs = { 'vignep' }
},
delivery = {
name = "Parking d'entrepot",
maxcar = 10,
entrances = {
vector3(1176.27, -3242.90, 5.0),
},
zone = PolyZone:Create({
vector2(1176.07, -3227.78),
vector2(1195.71, -3227.36),
vector2(1195.71, -3257.39),
vector2(1176.85, -3259.11),
}, {
minZ = 4.0,
-- debugGrid = true
}),
jobs = { 'delivery' }
},
concertHall = {
name = "Parking 712",
entrances = {
vector3(657.76, 637.13, 128.91)
},
maxcar = 10,
zone = PolyZone:Create({
vector2(648.55413818359, 581.9736328125),
vector2(619.50964355469, 592.95727539062),
vector2(638.25, 645.68426513672),
vector2(667.80523681641, 634.09625244141)
}, {
minZ = 127.0
})
},
bridgeFBI = {
name = "Parking FIB",
entrances = {
vector3(49.641, -842.167, 29.5),
vector3(57.3828, -882.703, 29.5)
},
maxcar = 10,
zone = PolyZone:Create({
vector2(32.62385559082, -836.03149414062),
vector2(69.494132995605, -849.35815429688),
vector2(61.985488891602, -869.7998046875),
vector2(25.128923416138, -856.58984375)
}, {
minZ = 29.0
})
},
observatory = {
name = "Parking Observatoire",
maxcar = 10,
entrances = {
vector3(-2328.660, 307.502, 168.1),
},
zone = PolyZone:Create({
vector2(-2337.0920410156, 304.27774047852),
vector2(-2323.4580078125, 273.86706542969),
vector2(-2307.0131835938, 281.20922851562),
vector2(-2320.7348632812, 311.54330444336)
}, {
minZ = 29.0
})
},
industrialNorte = {
name = "Parking Industriel",
maxcar = 10,
entrances = {
vector3(2677.527, 1671.026, 23.4885),
},
zone = PolyZone:Create({
vector2(2677.0991210938, 1657.7574462891),
vector2(2655.9072265625, 1657.4002685547),
vector2(2655.56640625, 1698.7482910156),
vector2(2676.9838867188, 1698.9072265625)
}, {
minZ = 22.0
})
},
}
|
include("autolua.lua")
AddLuaCSFolder("cl_various")
AddLuaCSFolder("cl_hud/vgui")
AddLuaCSFolder("cl_hud/menus")
AddLuaCSFolder("cl_hud")
AddLuaSHFolder("sh_various")
AddLuaSHFolder("sh_java")
AddLuaSVFolder("sv_various")
GM.Name = "Gearfox"
GM.Author = "The Maw"
GM.Email = "cjbremer@gmail.com"
GM.Website = "www.devinity2.com"
GM.Version = 1.5
function GM:PlayerNoClip( pl )
return pl:IsAdmin()
end
|
--[[
File name : autoaim_fpscamera.lua
PostRequireScripts:
- [lib/units/cameras/fpcameraplayerbase, aim/autoaim_fpscamera.lua]
Current v1.6.1
Change log :
v1.6.1
Fix a bug that it suddenly stop aiming while in steelsight, but it seems to be normal after re-entering steelsight again.
v1.6
Add aim support when charging melee weapons
v1.5
Add support for auto-shoot.
v1.4
It will not aim the target out of range when using grenade launchers .
v1.3
Add aim support for grenade launchers.
v1.2
Fix the problem that it aims an invalid target.
v1.1
Improve the accuracy while carrying / bleeding out.
v1.0
Initial release.
--]]
local org_get_aim_assist = FPCameraPlayerBase._get_aim_assist
function FPCameraPlayerBase:_get_aim_assist(t, dt)
if self._aim_assisting then
local r_value_x, r_value_y = org_get_aim_assist(self, t, dt)
return r_value_x, r_value_y
else
return 0, 0
end
end
local org_clbk_stop_aim_assist = FPCameraPlayerBase.clbk_stop_aim_assist
function FPCameraPlayerBase:clbk_stop_aim_assist()
self._aim_assisting = nil
org_clbk_stop_aim_assist(self)
end
function FPCameraPlayerBase:chk_autoaim()
if _fps_aim_assist then
if not self._aim_assisting then
if managers.player:player_unit():movement():current_state():in_steelsight() or managers.player:player_unit():movement():current_state():_is_meleeing() or managers.player:player_unit():movement():tased() then
local dir = managers.player:player_unit():camera():forward()
if managers.player:player_unit():inventory():equipped_unit():base():weapon_tweak_data().category == 'grenade_launcher' and self._gl_aiming then dir = self._gl_aiming end
local closest_ray, feedback = managers.player:player_unit():inventory():equipped_unit():base():check_autoaim2(managers.player:player_unit():camera():position(), dir, managers.player:player_unit():movement():current_state():_is_meleeing())
if closest_ray then
local chase_running_target = false
if feedback.is_running then
if feedback.error_dot then
if feedback.error_dot > 0.99 then
chase_running_target = true
end
end
end
self:clbk_aim_assist(closest_ray, chase_running_target)
end
return feedback
end
end
end
end
function FPCameraPlayerBase:clbk_aim_assist(col_ray, chase_running_target)
if col_ray then
if self._aim_assisting then self._aim_assisting = false end
local ray = col_ray.ray
local r1 = self._parent_unit:camera():rotation()
local r2 = self._aim_assist.mrotation or Rotation()
mrotation.set_look_at(r2, ray, math.UP)
local target_yaw = mrotation.yaw(r2)
local target_pitch = mrotation.pitch(r2)
if managers.player:player_unit():inventory():equipped_unit():base():weapon_tweak_data().category == 'grenade_launcher' then --Grenade launchers supported!
local mypos = managers.player:player_unit():camera():position()
local target_pos = col_ray.position
if target_pos then
local tar_vec = Vector3()
mvector3.set(tar_vec, target_pos)
mvector3.subtract(tar_vec, mypos)
local dis = mvector3.normalize(tar_vec)
local target_angle, correct_angle
target_angle = -target_pitch
local arcsin = (2 * dis * 981 * math.cos(target_angle)) / 16000000
if arcsin > 0 and arcsin < 1 then
correct_angle = math.asin(arcsin) * 0.5 - target_angle
target_pitch = correct_angle
self._gl_aiming = Vector3()
mvector3.set(self._gl_aiming, tar_vec)
else
return --Too far
end
end
elseif self._camera_properties.current_tilt ~= 0 then --Carry and shoot? No problem!
if target_pitch ~= 0 then
local a = target_pitch
local b = self._camera_properties.current_tilt
target_pitch = math.atan(math.tan(a) * math.cos(b) * math.cos(b))
local correct_angle_yaw = math.atan(math.tan(a) * math.cos(b) * math.sin(b))
target_yaw = target_yaw + correct_angle_yaw
end
end
local yaw = mrotation.yaw(r1) - target_yaw
local pitch = mrotation.pitch(r1) - target_pitch
if yaw > 180 then
yaw = yaw - 360
elseif yaw < -180 then
yaw = yaw + 360
end
if pitch > 180 then
pitch = pitch - 360
elseif pitch < -180 then
pitch = 360 + pitch
end
mvector3.set_static(self._aim_assist.direction, yaw, -pitch, 0)
self._aim_assist.distance = mvector3.normalize(self._aim_assist.direction)
if self._aim_assist.distance > 0 then
self._tweak_data.aim_assist_speed = self._aim_assist.distance * 5 + 200
if chase_running_target then self._tweak_data.aim_assist_speed = 4000 end
self._aim_assisting = true
else
self._aim_assist.distance = 0
mvector3.set_static(self._aim_assist.direction, 0, 0, 0)
end
end
end
_fps_aim_assist = false
|
local name, _GatherLite = ...;
local HBD = LibStub("HereBeDragons-2.0");
local Pins = LibStub("HereBeDragons-Pins-2.0");
local AceGUI = LibStub("AceGUI-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("GatherLite", true)
local Semver = LibStub("Semver");
--options interface
GatherLite.OptionsPanel = AceGUI:Create("Frame");
_G["GatherLiteOptionPanel"] = GatherLite.OptionsPanel.frame;
table.insert(UISpecialFrames, "GatherLiteOptionPanel");
GatherLite.NewVersionExists = false;
local qNumberOfFrames = 0;
GatherLite.frames = {}
GatherLite.totalNodes = 0;
GatherLite.synchronizing = false
GatherLite.syncedNodes = {
guild = 0,
party = 0
}
GatherLite.syncTimer = nil;
local function RefreshConfig()
LibStub("AceConfigRegistry-3.0"):NotifyChange("GatherLite")
end
function GatherLite:translate(key, ...)
local arg = { ... };
for i, v in ipairs(arg) do
arg[i] = tostring(v);
end
return string.format(L[key], unpack(arg))
end
-- print message
function GatherLite:print(...)
print(GatherLite:Colorize("<" .. _GatherLite.name .. ">", "yellow"), ...)
end
-- print debug message
function GatherLite:debug(...)
if (GatherLite.db.char.debugging) then
print(GatherLite:Colorize("<" .. _GatherLite.name .. " - Debugging>", "blue"), ...)
end
end
-- count table rows
function GatherLite:tablelength(T)
local count = 0
if T then
for _ in pairs(T) do
count = count + 1
end
end
return count
end
-- Make string colorized
function GatherLite:Colorize(str, color)
local c = '';
if color == 'red' then
c = '|cffff0000';
elseif color == 'gray' then
c = '|cFFCFCFCF';
elseif color == 'purple' then
c = '|cFFB900FF';
elseif color == 'blue' then
c = '|cB900FFFF';
elseif color == 'yellow' then
c = '|cFFFFB900';
elseif color == 'green' then
c = "|cFF00FF00";
elseif color == 'white' then
c = "|cffffffff"
elseif color == 'cyan' then
c = "|cff00FFFF"
end
return c .. str .. "|r"
end
-- copy table into another table
function GatherLite:CopyDefaults(src, dst)
if type(src) ~= "table" then
return {}
end
if type(dst) ~= "table" then
dst = {}
end
for k, v in pairs(src) do
if type(v) == "table" then
dst[k] = GatherLite:CopyDefaults(v, dst[k])
elseif type(v) ~= type(dst[k]) then
dst[k] = v
end
end
return dst
end
function GatherLite:ShowSettings()
LibStub("AceConfigDialog-3.0"):Open("GatherLite", GatherLite.OptionsPanel)
end
-- slash commands
function GatherLite:GatherSlash(input)
input = string.trim(input, " ");
if input == "" or not input then
GatherLite:ShowSettings();
return ;
end
if input == "debugging" then
if GatherLite.db.char.debugging then
GGatherLite.db.char.debugging = false;
GatherLite:print("debugging", GatherLite:Colorize("disabled", "red"));
else
GatherLite.db.char.debugging = true;
GatherLite:print("debugging", GatherLite:Colorize("enabled", "green"));
end
end
end
-- find spell type
function GatherLite:findSpellType(spell)
local spellInfo = GetSpellInfo(spell);
-- see if spell is in our list
for k, s in pairs(_GatherLite.spellIDs) do
if k == spellInfo then
return s;
end
end ;
-- spell was not found
return nil;
end
-- find spell
function GatherLite:findSpell(spellID)
-- check if spell is a mining spell
for k, s in pairs(_GatherLite.spellIDs["mining"]) do
if s == spellID then
return "mining", s;
end
end ;
-- check if spell is a herbalism spell
for k, s in pairs(_GatherLite.spellIDs["herbalism"]) do
if s == spellID then
return "herbalism", s;
end
end ;
-- spell type was not found
return nil, nil;
end
-- check distance between player and node
function GatherLite:IsNodeInRange(myPosX, myPosY, nodePosX, nodePosY, spellType)
local distance = ((((myPosX - nodePosX) ^ 2) + ((myPosY - nodePosY) ^ 2)) ^ 0.5)
if spellType == "fish" then
return distance < _GatherLite.gatherSpellRanges.fish
else
return distance < _GatherLite.gatherSpellRanges.default
end ;
end
-- find existing node nearby
function GatherLite:findExistingNode(spellType, x, y, mapID)
for k, node in pairs(_GatherLite.nodes[spellType]) do
if node.position.mapID == mapID and GatherLite:IsNodeInRange(x, y, node.position.x, node.position.y, spellType) then
return node;
end
end
return nil;
end
function GatherLite:findExistingNodeLocal(spellType, x, y, mapID)
for k, node in pairs(GatherLite.db.global.nodes[spellType]) do
if node.position.mapID == mapID and GatherLite:IsNodeInRange(x, y, node.position.x, node.position.y, spellType) then
return node;
end
end
return nil;
end
-- found ore, herb or fish
function GatherLite:foundNode()
if (IsInInstance()) then
return
end
local x, y, mapID = HBD:GetPlayerZonePosition();
local loot = {};
local coin = 0;
local count = GetNumLootItems()
if count == 0 then
GatherLite:debug("Node does not contain any items... skipping");
return
end
for i = 1, count do
local lIcon, lName, lQuantity, lQuality, locked, isQuestItem = GetLootSlotInfo(i)
local slotType = GetLootSlotType(i)
local lLink = GetLootSlotLink(i)
if not isQuestItem then
if (not lLink and slotType == LOOT_SLOT_MONEY) then
local i, j, val
i, j, val = string.find(lName, COPPER_AMOUNT:gsub("%%d", "(%%d+)", 1))
if (i) then
coin = coin + val
end
i, j, val = string.find(lName, SILVER_AMOUNT:gsub("%%d", "(%%d+)", 1))
if (i) then
coin = coin + (val * 100)
end
i, j, val = string.find(lName, GOLD_AMOUNT:gsub("%%d", "(%%d+)", 1))
if (i) then
coin = coin + (val * 10000)
end
if (coin == 0) then
table.insert(loot, {
name = lName,
count = tonumber(lQuantity),
link = lLink
})
end
else
table.insert(loot, {
name = lName,
count = tonumber(lQuantity),
link = lLink
})
end
end
end
-- dont do anything if loot table length is 0
if GatherLite:tablelength(loot) == 0 then
return ;
end ;
local icon, target;
local node = GatherLite:findExistingNodeLocal(_GatherLite.tracker.spellType, x, y, mapID);
if not node then
-- found treasure or node
if _GatherLite.tracker.spellType == "treasure" then
local lIcon, lName, lQuantity, lQuality, currencyID, locked, isQuestItem = GetLootSlotInfo(1)
if not isQuestItem then
target = _GatherLite.tracker.target
icon = 132594
else
GatherLite:debug("Treasure is quest item, do not add to database");
return
end
else
local primary = GetLootSlotLink(1)
if (primary) then
primary = primary:match("item:(%d+)")
if (primary) then
if _GatherLite.tracker.spellType == "fish" then
target = "Fishing spot"
icon = GetItemIcon(6303)
else
target = _GatherLite.tracker.target;
icon = GetItemIcon(primary);
end
elseif not primary and _GatherLite.tracker.spellType == "artifacts" then
target = _GatherLite.tracker.target;
icon = GetItemIcon(1195)
end ;
end
end
-- do nothing if matching failed
if not target and not icon then
return
end
GatherLite:insertDatabaseNode(x, y, mapID, _GatherLite.tracker.spellID, _GatherLite.tracker.spellType, target, icon, loot, coin)
else
local primary = GetLootSlotLink(1)
if (primary) then
primary = primary:match("item:(%d+)")
if (primary) then
if _GatherLite.tracker.spellType == "fish" then
target = "Fishing spot"
icon = GetItemIcon(6303)
else
target = _GatherLite.tracker.target;
icon = GetItemIcon(primary);
end
elseif not primary and _GatherLite.tracker.spellType == "artifacts" then
target = _GatherLite.tracker.target;
icon = GetItemIcon(1195)
end
end
GatherLite:updateDatabaseNode(node, loot, coin, target, icon)
end
end
-- create new node
function GatherLite:insertDatabaseNode(x, y, mapID, spellID, spellType, target, icon, loot, coin)
local locClass, engClass, locRace, engRace, gender, pName = GetPlayerInfoByGUID(UnitGUID('player'));
-- node data
local node = {
GUID = UnitGUID('player'),
type = spellType,
spellID = spellID,
target = string.lower(target),
name = target,
icon = icon,
shared = false,
loot = {},
coins = coin,
position = {
mapID = mapID,
x = x,
y = y
},
date = date('*t'),
player = {
name = pName,
class = engClass,
race = engRace,
realm = GetRealmName()
}
};
for k, item in pairs(loot) do
local exists = GatherLite:findLoot(node.loot, item.name);
if not exists then
table.insert(node.loot, {
name = item.name,
count = item.count,
link = item.link
})
else
node.loot[exists].count = node.loot[exists].count + item.count;
end
end
table.insert(GatherLite.db.global.nodes[spellType], node);
table.insert(_GatherLite.nodes[spellType], node);
GatherLite.totalNodes = GatherLite.totalNodes + 1;
GatherLite:debug("Adding node at " .. "|cff32CD32" .. node.position.x .. " " .. node.position.y .. "|r");
GatherLite:createNode(node)
if IsInGuild() and GatherLite.db.char.p2p.guild then
GatherLite:SendCommMessage(_GatherLite.name .. "Node", GatherLite:Serialize(node), "GUILD")
GatherLite:debug("sharing node with guild");
end
if IsInGroup() and GatherLite.db.char.p2p.party then
GatherLite:SendCommMessage(_GatherLite.name .. "Node", GatherLite:Serialize(node), "PARTY")
GatherLite:debug("sharing node with party");
end
end
-- update existing node
function GatherLite:updateDatabaseNode(node, loot, coin, target, icon)
node.date = date('*t');
if target then
node.name = target;
node.target = string.lower(target);
end
if icon then
node.icon = icon;
end
if node.loot == nil then
node.loot = {};
end
if node.coins == nil then
node.coins = 0;
end
node.coins = node.coins + coin;
for k, item in pairs(loot) do
local exists = GatherLite:findLoot(node.loot, item.name);
if not exists then
table.insert(node.loot, {
name = item.name,
count = item.count,
link = item.link
})
else
node.loot[exists].count = node.loot[exists].count + item.count;
end
end
if IsInGuild() and GatherLite.db.char.p2p.guild then
GatherLite:SendCommMessage(_GatherLite.name .. "Node", GatherLite:Serialize(node), "GUILD")
GatherLite:debug("sharing node with guild");
end
if IsInGroup() and GatherLite.db.char.p2p.party then
GatherLite:SendCommMessage(_GatherLite.name .. "Node", GatherLite:Serialize(node), "PARTY")
GatherLite:debug("sharing node with party");
end
end
-- draw world map nodes
function GatherLite:drawWorldmap()
GatherLite:debug("drawing world map nodes");
for type in pairs(_GatherLite.nodes) do
for k, node in pairs(_GatherLite.nodes[type]) do
GatherLite:createWorldmapNode(node, k);
end
end
for i, frame in ipairs(GatherLite.frames) do
if frame.type == "worldmap" then
frame:SetSize(GatherLite.db.char.worldmap.size, GatherLite.db.char.worldmap.size)
frame:SetAlpha(GatherLite.db.char.worldmap.opacity)
end
end
end
-- draw minimap nodes
function GatherLite:drawMinimap()
if not GatherLite.db.char.enabled or not GatherLite.db.char.minimap.enabled then
return
end
GatherLite:debug("Updating mini map nodes");
for type in pairs(_GatherLite.nodes) do
for k, node in pairs(_GatherLite.nodes[type]) do
GatherLite:createMinimapNode(node, k);
end
end
for i, frame in ipairs(GatherLite.frames) do
if frame.type == "minimap" then
frame:SetSize(GatherLite.db.char.minimap.size, GatherLite.db.char.minimap.size)
frame:SetAlpha(GatherLite.db.char.minimap.opacity)
end
end
end
-- add leadingZeros to number
function GatherLite:leadingZeros(value)
value = tonumber(value);
if (value < 10) then
return "0" .. value;
end ;
return value;
end
-- create tooltip for map node
function GatherLite:createNodeTooltip(self)
local node = self.node;
_GatherLite.tooltip:ClearLines();
_GatherLite.tooltip:SetOwner(self, "TOP");
_GatherLite.tooltip:SetText(node.name);
if node.date then
_GatherLite.tooltip:AddDoubleLine(GatherLite:translate('tooltip.last_visit'), GatherLite:Colorize(GatherLite:leadingZeros(node.date.day) .. '/' .. GatherLite:leadingZeros(node.date.month) .. '/' .. GatherLite:leadingZeros(node.date.year) .. " - " .. GatherLite:leadingZeros(node.date.hour) .. ':' .. GatherLite:leadingZeros(node.date.min) .. ':' .. GatherLite:leadingZeros(node.date.sec), "white"));
end
local lootTable = false
if self.type == "minimap" then
lootTable = GatherLite.db.char.minimap.loot;
elseif self.type == "worldmap" then
lootTable = GatherLite.db.char.worldmap.loot;
end
if node.loot and lootTable then
for k, item in pairs(node.loot) do
if item.count > 0 then
_GatherLite.tooltip:AddDoubleLine(item.link, "x" .. item.count);
else
_GatherLite.tooltip:AddDoubleLine(item.link, "");
end
end
end
if not node.player and node.GUID then
local locClass, engClass, locRace, engRace, gender, pName = GetPlayerInfoByGUID(node.GUID);
node.player = {
name = pName,
class = engClass,
race = engRace,
realm = GetRealmName()
}
end
if node.coins and node.coins > 0 then
SetTooltipMoney(_GatherLite.tooltip, node.coins)
end
if node.player and node.player.name and _GatherLite.classColours[node.player.class] then
_GatherLite.tooltip:AddDoubleLine(GatherLite:translate('tooltip.found_by'), _GatherLite.classColours[node.player.class].fs .. node.player.name .. " - " .. node.player.realm);
end
_GatherLite.tooltip:Show();
_GatherLite.showingTooltip = true;
end
function GatherLite:createFrame()
qNumberOfFrames = qNumberOfFrames + 1
local f = CreateFrame("Button", "GatherLite" .. qNumberOfFrames, nil)
if MBB_Ignore then
table.insert(MBB_Ignore, "GatherLite" .. qNumberOfFrames)
end
f:SetFrameStrata("TOOLTIP");
f:SetWidth(16) -- Set these to whatever height/width is needed
f:SetHeight(16) -- for your Texture
f.node = {};
f.type = nil;
local t = f:CreateTexture(nil, "TOOLTIP")
t:SetWidth(16)
t:SetHeight(16)
t:SetAllPoints(f)
t:SetTexelSnappingBias(0)
t:SetSnapToPixelGrid(false)
f:SetScript("OnEnter", function(self)
GatherLite:createNodeTooltip(self);
end)
f:SetScript("OnLeave", function()
_GatherLite.tooltip:Hide()
end)
f.texture = t;
function f:FakeHide()
if not self.hidden then
self.shouldBeShowing = self:IsShown();
self._show = self.Show;
self.Show = function()
self.shouldBeShowing = true;
end
self:Hide();
self._hide = self.Hide;
self.Hide = function()
self.shouldBeShowing = false;
end
self.hidden = true
end
end
function f:FakeShow()
if self.hidden then
self.hidden = false
self.Show = self._show;
self.Hide = self._hide;
self._show = nil
self._hide = nil
if self.shouldBeShowing then
self:Show();
end
end
end
function f:Unload()
self:SetScript("OnUpdate", nil)
self:SetScript("OnShow", nil)
self:SetScript("OnHide", nil)
self.texture:SetVertexColor(1, 1, 1, 1)
if self ~= nil and self.hidden and self._show ~= nil and self._hide ~= nil then
self.hidden = false
self.Show = self._show;
self.Hide = self._hide;
self._show = nil
self._hide = nil
end
self.shouldBeShowing = nil
self.node = {}
self.type = nil
Pins:RemoveMinimapIcon(GatherLite, self)
Pins:RemoveWorldMapIcon(GatherLite, self)
self:Hide()
end
f:Hide()
table.insert(GatherLite.frames, f)
return f;
end
-- create world map node frame
function GatherLite:createWorldmapNode(node, ik)
if not node.position.mapID and not node.position.x and not node.position.y then
return
end
local x, y, instanceID = HBD:GetWorldCoordinatesFromZone(node.position.x, node.position.y, node.position.mapID);
if not instanceID and not x and not y then
return
end
local f = GatherLite:createFrame();
f:SetAlpha(GatherLite.db.char.worldmap.opacity);
f:SetSize(GatherLite.db.char.worldmap.size, GatherLite.db.char.worldmap.size)
f.texture:SetTexture(node.icon)
f.node = node;
f.type = "worldmap";
--local x, y, instanceID = HBD:GetWorldCoordinatesFromZone(node.position.x, node.position.y, node.position.mapID);
--Pins:AddWorldMapIconWorld("GathererClassic.Worldmap", f, instanceID, x, y);
local flag
if GatherLite.db.char.worldmap.continent then
flag = HBD_PINS_WORLDMAP_SHOW_CONTINENT
end
if GatherLite.db.char.worldmap.neighbors then
Pins:AddWorldMapIconWorld(GatherLite, f, instanceID, x, y, flag);
else
Pins:AddWorldMapIconMap(GatherLite, f, node.position.mapID, node.position.x, node.position.y, flag);
end
end
-- create mini map node frame
function GatherLite:createMinimapNode(node, ik)
if not node.position.mapID and not node.position.x and not node.position.y then
return
end
local x, y, instanceID = HBD:GetWorldCoordinatesFromZone(node.position.x, node.position.y, node.position.mapID);
if not instanceID and not x and not y then
return
end
local f = GatherLite:createFrame();
f:SetAlpha(GatherLite.db.char.minimap.opacity);
f:SetSize(GatherLite.db.char.minimap.size, GatherLite.db.char.minimap.size)
f.texture:SetTexture(node.icon)
f.node = node;
f.type = "minimap";
if GatherLite.db.char.minimap.neighbors then
Pins:AddMinimapIconWorld(GatherLite, f, instanceID, x, y, GatherLite.db.char.minimap.edge);
else
Pins:AddMinimapIconMap(GatherLite, f, node.position.mapID, node.position.x, node.position.y, true, GatherLite.db.char.minimap.edge)
end
end
function GatherLite:createNode(node)
GatherLite:createMinimapNode(node, GatherLite:tablelength(_GatherLite.nodes[node.type]));
GatherLite:createWorldmapNode(node, GatherLite:tablelength(_GatherLite.nodes[node.type]));
end
function GatherLite:addContextItem(args)
local info = UIDropDownMenu_CreateInfo()
info.text = args.text;
info.checked = args.checked;
info.func = args.callback;
info.icon = args.icon;
info.isTitle = args.isTitle;
info.disabled = args.disabled;
info.notCheckable = args.notCheckable;
UIDropDownMenu_AddButton(info)
end
function GatherLite:MinimapContextMenu()
return function(frame, level, menuList)
if level == 1 then
GatherLite:addContextItem({
text = _GatherLite.name,
isTitle = true,
notCheckable = true
});
GatherLite:addContextItem({
text = GatherLite:translate('mining'),
icon = GetItemIcon(2770),
checked = GatherLite.db.char.tracking.mining,
callback = function()
if GatherLite.db.char.tracking.mining then
GatherLite.db.char.tracking.mining = false;
else
GatherLite.db.char.tracking.mining = true;
end ;
end
})
GatherLite:addContextItem({
text = GatherLite:translate('herbalism'),
icon = GetItemIcon(765),
checked = GatherLite.db.char.tracking.herbalism,
callback = function()
if GatherLite.db.char.tracking.herbalism then
GatherLite.db.char.tracking.herbalism = false;
else
GatherLite.db.char.tracking.herbalism = true;
end ;
end
})
if not _GatherLite.isClassic then
GatherLite:addContextItem({
text = GatherLite:translate('archaeology'),
icon = 134435,
checked = GatherLite.db.char.tracking.artifacts,
callback = function()
if GatherLite.db.char.tracking.artifacts then
GatherLite.db.char.tracking.artifacts = false;
else
GatherLite.db.char.tracking.artifacts = true;
end ;
end
})
end
GatherLite:addContextItem({
text = GatherLite:translate('fish'),
icon = GetItemIcon(6303),
checked = GatherLite.db.char.tracking.fish,
callback = function()
if GatherLite.db.char.tracking.fish then
GatherLite.db.char.tracking.fish = false;
else
GatherLite.db.char.tracking.fish = true;
end ;
end
})
GatherLite:addContextItem({
text = GatherLite:translate('treasures'),
icon = 132594,
checked = GatherLite.db.char.tracking.treasure,
callback = function()
if GatherLite.db.char.tracking.treasure then
GatherLite.db.char.tracking.treasure = false;
else
GatherLite.db.char.tracking.treasure = true;
end ;
end
})
end
end
end
function GatherLite:SendVersionCheck()
if IsInGuild() then
GatherLite:SendCommMessage(_GatherLite.name .. "Ver", GatherLite:Serialize(_GatherLite.version), "GUILD")
end
if IsInGroup() then
GatherLite:SendCommMessage(_GatherLite.name .. "Ver", GatherLite:Serialize(_GatherLite.version), "PARTY")
end
end
function GatherLite:VersionCheck(event, msg, channel, sender)
local success, message = GatherLite:Deserialize(msg);
if not success then
return
end
local removeVersion = Semver:Parse(message);
if not removeVersion then
return
end
local localVersion = Semver:Parse(_GatherLite.version);
if not localVersion then
return
end
if localVersion < removeVersion and not GatherLite.NewVersionExists then
GatherLite.NewVersionExists = true;
GatherLite:print("A new version of", _GatherLite.name, "has been detected, please visit curseforge.com to download the latest version, or use the twitch app to keep you addons updated")
end
end
function GatherLite:p2pNode(event, msg, channel, sender)
if (sender == UnitName("player")) then
return
end
if channel == "GUILD" and not GatherLite.db.char.p2p.guild then
return
end
if channel == "PARTY" and not GatherLite.db.char.p2p.party then
return ;
end
local success, node = GatherLite:Deserialize(msg);
if success then
if node.position and node.position.mapID and node.position.x and node.position.y then
if not GatherLite:findExistingNodeLocal(node.type, node.position.x, node.position.y, node.position.mapID) then
node.shared = true;
node.coins = 0;
local isQuest = false;
if node.loot and GatherLite:tablelength(node.loot) > 0 then
for i, item in ipairs(node.loot) do
local name = select(1, GetItemInfo(node.target));
local type = select(6, GetItemInfo(node.target))
if type == "Quest" then
isQuest = true
end
end
else
node.loot = {};
end
if not isQuest then
table.insert(GatherLite.db.global.nodes[node.type], node);
table.insert(_GatherLite.nodes[node.type], node);
GatherLite:createNode(node)
GatherLite:debug("received p2p " .. node.type .. " node from " .. sender);
end
end
end
end
end
function GatherLite:findLoot(list, name)
for item, data in pairs(list) do
if data.name == name then
return item
end
end
end
-- sanitize node to new structure
function GatherLite:sanitizeNode(type, i)
local node = GatherLiteGlobalSettings.database[type][i];
if not node.position or not node.position.mapID or not node.position.x or not node.position.y then
-- remove nodes wich has a faulty position data
GatherLiteGlobalSettings.database[type][i] = nil;
GatherLite:debug("removing unknown node")
elseif GatherLite:tablelength(node.loot) == 0 and not node.shared then
-- remove all nodes thats empty and hasnt been shared with the new p2p system
-- They are probably old quest items being tracked.
GatherLiteGlobalSettings.database[type][i] = nil;
GatherLite:debug("removing empty node")
else
-- update node loot table to avoid duplicate items shown.
local newLoot = {};
for link, data in pairs(GatherLiteGlobalSettings.database[type][i].loot) do
if not tonumber(link) then
local exists = GatherLite:findLoot(newLoot, data.name);
if not exists then
table.insert(newLoot, {
name = data.name,
count = data.count,
link = link
})
else
newLoot[exists].count = newLoot[exists].count + data.count;
end
else
table.insert(newLoot, data)
end
end
GatherLiteGlobalSettings.database[type][i].loot = newLoot;
table.insert(GatherLite.db.global.nodes[type], GatherLiteGlobalSettings.database[type][i]);
GatherLiteGlobalSettings.database[type][i] = nil
end
end
-- sanitize database on load
function GatherLite:sanitizeDatabase()
if not GatherLiteGlobalSettings then
return
end
if not GatherLiteGlobalSettings.database then
return
end
for type in pairs(GatherLiteGlobalSettings.database) do
for i, node in pairs(GatherLiteGlobalSettings.database[type]) do
GatherLite:sanitizeNode(type, i)
end
end
end
function GatherLite:copy(obj, seen)
if type(obj) ~= 'table' then
return obj
end
if seen and seen[obj] then
return seen[obj]
end
local s = seen or {}
local res = setmetatable({}, getmetatable(obj))
s[obj] = res
for k, v in pairs(obj) do
res[GatherLite:copy(k, s)] = GatherLite:copy(v, s)
end
return res
end
function GatherLite:p2pDatabase()
GatherLite:CancelTimer(GatherLite.syncTimer)
if IsInGuild() and GatherLite.db.char.p2p.guild and GatherLite.syncedNodes.guild == 0 and GatherLite.tablelength(GatherLite.db.global.nodes) > 0 then
GatherLite:debug("Starting synchronization with guild")
GatherLite.synchronizing = true;
local totalNodes = GatherLite:copy(GatherLite.totalNodes);
for i, data in pairs(GatherLite.db.global.nodes) do
for i, node in pairs(data) do
GatherLite:SendCommMessage(_GatherLite.name .. "Node", GatherLite:Serialize(node), "GUILD", nil, "BULK", function(args, bytes, totalBytes)
if bytes == totalBytes then
GatherLite.syncedNodes.guild = GatherLite.syncedNodes.guild + 1;
if GatherLite.syncedNodes.guild == totalNodes then
GatherLite.syncedNodes.guild = 0;
GatherLite.syncTimer = GatherLite:ScheduleTimer("p2pDatabase", 3600)
GatherLite.synchronizing = false;
GatherLite:debug("Guild synchronization complete")
end
RefreshConfig();
end
end)
end
end
end
end
function GatherLite:syncCheck()
if GatherLite.synchronizing then
GatherLite:debug("Synchronized", GatherLite.syncedNodes.guild .. "/" .. GatherLite.totalNodes)
end
end
-- event handler
function GatherLite:EventHandler(event, ...)
-- loot window opened
if event == "LOOT_OPENED" then
if (_GatherLite.tracker.spellID and _GatherLite.tracker.ended and GetTime() - _GatherLite.tracker.ended < 1) then
GatherLite:debug("loot window opened")
GatherLite:foundNode();
_GatherLite.tracker.target = nil;
_GatherLite.tracker.spellID = nil;
_GatherLite.tracker.spellType = nil;
elseif (_GatherLite.tracker.spellID and IsFishingLoot()) then
GatherLite:debug("loot window opened")
GatherLite:foundNode();
_GatherLite.tracker.target = nil;
_GatherLite.tracker.spellID = nil;
_GatherLite.tracker.spellType = nil;
end
end
-- spell has ended
if (event == "UNIT_SPELLCAST_SENT") or (event == "UNIT_SPELLCAST_SUCCEEDED") or (event == "UNIT_SPELLCAST_INTERRUPTED") or (event == "UNIT_SPELLCAST_FAILED") then
local spell = select(4, ...)
local target = select(2, ...)
if (event == "UNIT_SPELLCAST_SENT") then
local spellType = GatherLite:findSpellType(spell)
if (spellType) then
GatherLite:debug("Started " .. GetSpellInfo(spell), spell)
_GatherLite.tracker.target = target
_GatherLite.tracker.spellID = spell
_GatherLite.tracker.spellType = spellType
end ;
elseif (event == "UNIT_SPELLCAST_SUCCEEDED") then
_GatherLite.tracker.ended = GetTime()
elseif ((event == "UNIT_SPELLCAST_INTERRUPTED") or (event == "UNIT_SPELLCAST_FAILED")) then
-- Spell failed, cancel the tracking
_GatherLite.tracker.target = nil
_GatherLite.tracker.spellID = nil
_GatherLite.tracker.spellType = nil
end
end
end
function GatherLite:UpdateNodes()
if not GatherLite.db.char.enabled then
for i, frame in ipairs(GatherLite.frames) do
frame:FakeHide();
end
return
end
for i, frame in ipairs(GatherLite.frames) do
if frame.type == "minimap" and GatherLite.db.char.minimap.enabled then
local angle, distance = Pins:GetVectorToIcon(frame);
if GatherLite.db.char.tracking[frame.node.type] and distance and distance < GatherLite.db.char.minimap.distance then
frame:FakeHide();
elseif GatherLite.db.char.tracking[frame.node.type] then
frame:FakeShow();
else
frame:FakeHide();
end
elseif frame.type == "worldmap" and GatherLite.db.char.worldmap.enabled then
if GatherLite.db.char.tracking[frame.node.type] then
frame:FakeShow();
else
frame:FakeHide();
end
else
frame:FakeHide();
end
end
end
function GatherLite:loadDatabase()
if GatherLite.db.char.predefined then
if _GatherLite.database then
for type, arr in pairs(_GatherLite.database) do
for i, node in pairs(arr) do
table.insert(_GatherLite.nodes[type], node)
end
end
end
end
for type, arr in pairs(GatherLite.db.global.nodes) do
for i, node in pairs(arr) do
local pre = GatherLite:findExistingNode(node.type, node.position.x, node.position.y, node.position.mapID);
if not pre then
table.insert(_GatherLite.nodes[type], node)
else
pre.loot = node.loot;
pre.coins = node.coins;
end
GatherLite.totalNodes = GatherLite.totalNodes + 1;
end
end
end
function GatherLite:ResetDatabase()
for i, frame in ipairs(GatherLite.frames) do
frame:Unload()
end
GatherLite.db.global.nodes = {
mining = {},
herbalism = {},
treasure = {},
fish = {},
artifacts = {}
}
_GatherLite.nodes = {
mining = {},
herbalism = {},
treasure = {},
fish = {},
artifacts = {}
}
GatherLite:loadDatabase();
end
function GatherLite:ResetDatabaseType(type)
for i, frame in ipairs(GatherLite.frames) do
if frame.node.type == type then
frame:Unload()
end
end
GatherLite.db.global.nodes[type] = {}
_GatherLite.nodes[type] = {}
end
|
local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
return creature:conjureItem(0, 25760, 1, CONST_ME_MAGIC_BLUE)
end
spell:group("support")
spell:id(92)
spell:name("Conjure Wand of Darkness")
spell:words("exevo gran mort")
spell:cooldown(90 * 1000)
spell:groupCooldown(2 * 1000)
spell:level(41)
spell:mana(250)
spell:soul(0)
spell:isPremium(true)
spell:isSelfTarget(true)
spell:isAggressive(false)
spell:vocation("sorcerer;true", "master sorcerer;true")
spell:needLearn(false)
spell:register()
|
local ffi = require 'ffi'
local bit = require 'bit'
local luagit = {}
local function class(gitType)
local Class = {}
Class.__index = function(t, k)
if Class[k] then
return Class[k]
elseif gitType ~= nil then
local hasfn, gitfn = pcall(function()
return luagit.C['git_'..gitType..'_'..k]
end)
if hasfn then
return function(t, ...)
local isPtrPtr, handle = pcall(function() return t.handle[0] end)
if not isPtrPtr then handle = t.handle end
return gitfn(handle, ...)
end
end
end
end
setmetatable(Class, {
__call = function(cls, ...)
local self = setmetatable({}, cls)
self.type = gitType
self:__init(...)
return self
end,
})
return Class
end
luagit.C = require 'luagit-ffi.ffi'
luagit.Repository = class('repository')
luagit.Index = class('index')
luagit.Tree = class('tree')
luagit.OID = class('oid') -- SHA
luagit.StatusList = class('status_list')
luagit.shutdown = function() luagit.C.git_libgit2_shutdown() end
function luagit.getLastError()
local giterr = luagit.C.giterr_last()
return giterr == nil and nil or {
message = ffi.string(giterr.message),
code = giterr.klass,
}
end
-- luagit.errors = setmetatable({}, {
-- __index = function(k, v) return luagit.C['GIT_'..k] end
-- })
setmetatable(luagit, {
__index = function(lg, key)
return lg.C['git_'..key]
end
})
function makeFlags(prefix, opts)
opts = opts or {}
local flags = 0
for i,opt in pairs(opts) do
flags = bit.bor(flags, luagit.C['GIT_'..prefix..'_'..opt])
end
return flags
end
function makeCheckoutOpts(opts)
opts = opts or {}
return ffi.new('git_checkout_options', {
version = 1,
checkout_strategy = makeFlags('CHECKOUT', opts.strategy),
paths = opts.paths and makeStrArray(opts.paths) or nil,
})
end
function luagit.Repository:__init(path)
self.path = path
self.handle = ffi.new('git_repository*[1]')
luagit.repository_open(self.handle, path)
end
function luagit.Repository:getIndex()
local index = luagit.Index()
luagit.repository_index(index.handle, self.handle[0])
index.repository = self
return index
end
function luagit.Repository:getStatus(opts)
local status = luagit.StatusList()
local flags = makeFlags('STATUS_OPT', opts)
local opts = ffi.new('git_status_options', {version=1, flags=flags})
luagit.status_list_new(status.handle, self.handle[0], opts)
return status
end
function makeSig(sigspec)
return ffi.new('git_signature', {
name=ffi.cast('char*', ffi.new('const char*', sigspec.name)),
email=ffi.cast('char*', ffi.new('const char*', sigspec.email)),
when=ffi.new('git_time', sigspec.when)
})
end
function luagit.Repository:commit(updateRef, author, committer, msg, _tree, parents)
parents = parents or {}
local tree = _tree
if tree.type ~= 'tree' then tree = self:lookupTree(tree) end
author = makeSig(author)
committer = makeSig(committer)
local parentsArr
if #parents > 0 then
parentsArr = ffi.new('git_commit['..#parents..']', parents)
end
local oid = luagit.OID()
luagit.commit_create(oid.handle, self.handle[0], updateRef, author, committer, nil, msg, tree.handle[0], #parents, parentsArr)
if _tree.type ~= 'tree' then
tree:free()
end
return oid
end
function luagit.Repository:lookupTree(oid)
oid = luagit.OID(oid)
local tree = luagit.Tree()
local err = luagit.tree_lookup_prefix(tree.handle, self.handle[0], oid.handle, #oid)
if err ~= 0 then error('Could not look up tree.') end
tree.repository = self
return tree
end
function luagit.Repository:stashSave(stasher, msg, opts)
stasher = makeSig(stasher)
local flags = makeFlags('STASH', opts)
local oid = luagit.OID()
local stashed = luagit.stash_save(oid.handle, self.handle[0], stasher, msg, flags)
return stashed, oid
end
function luagit.Repository:stashPop(index, opts)
opts = opts or {}
local applyOpts = ffi.new('git_stash_apply_options', {
version = 1,
apply_flags = makeFlags('STASH_APPLY', opts.applyFlags),
checkout_options = makeCheckoutOpts(opts.checkoutOpts),
})
return luagit.stash_pop(self.handle[0], index, applyOpts)
end
function luagit.Repository:checkout(ref, opts)
-- this type of function should be autoconverted from the api
opts = (type(ref) == 'table' and ref.type == nil) and ref or opts
local coOpts = makeCheckoutOpts(opts)
if ref.type == 'index' then
return luagit.checkout_index(self.handle[0], ref.handle[0], coOpts)
elseif ref.type == 'tree' or ref.type == 'commit' then
local objHandle = ffi.cast('git_object*', ref.handle[0])
return luagit.checkout_tree(self.handle[0], objHandle, coOpts)
else
return luagit.checkout_head(self.handle[0], coOpts)
end
end
function luagit.Tree:__init()
self.handle = ffi.new('git_tree*[1]')
end
function luagit.Index:__init()
self.handle = ffi.new('git_index*[1]')
luagit.index_new(self.handle)
end
function luagit.Index:addAll(pathspecs, opts, callback, payload)
opts = opts or {}
local ps = ffi.cast('char**', ffi.new('const char*['..#pathspecs..']', pathspecs))
local psArr = ffi.new('git_strarray', {strings=ps, count=#pathspecs})
local flags = makeFlags('INDEX_ADD', opts)
return self:add_all(psArr, flags, callback, payload)
end
function luagit.Index:readTree(treeOrOid)
assert(treeOrOid.type == 'tree' or self.repository ~= nil)
local tree = treeOrOid
if treeOrOid.type ~= 'tree' then
tree = self.repository:lookupTree(treeOrOid)
end
luagit.index_read_tree(self.handle[0], tree.handle[0])
if treeOrOid.type ~= 'tree' then tree:free() end
return self
end
function luagit.Index:writeTree()
local oid = luagit.OID()
luagit.index_write_tree(oid.handle, self.handle[0])
return oid
end
function luagit.Index:write()
print(luagit.index_write(self.handle[0]))
end
function luagit.StatusList:__init()
self.handle = ffi.new('git_status_list*[1]')
end
function luagit.OID:__init(existing)
self.length = 41
if type(existing) == 'table' then -- init from OID object
self.handle = existing.handle
self.length = existing.length
elseif type(existing) == 'cdata' then -- init from handle
self.handle = existing
elseif type(existing) == 'string' then -- init from string
self.handle = ffi.new('git_oid')
self.length = #existing
self:fromstr(existing)
else
self.handle = ffi.new('git_oid')
end
end
function luagit.OID:__tostring()
local cstrlen = #self + 1 -- null terminator
local str = ffi.new('char['..cstrlen..']')
luagit.oid_tostr(str, cstrlen, self.handle)
return ffi.string(str)
end
function luagit.OID:__len() return self.length end
luagit.C.git_libgit2_init()
return luagit
|
local _, Addon = ...
local DDBL = Addon.DethsDBLib
if DDBL.__loaded then return end
local consts = DDBL.consts
local utils = DDBL.utils
local db_cache = {
-- ["AddonName"] = db table
}
-- Creates and returns a new database table.
-- @param {string} addonName - the name of the addon
-- @param {table} defaults - a table of default key-value pairs
function DDBL:Create(addonName, defaults)
local svarKey -- set during validation
do -- Validation
-- params
assert(type(addonName) == "string", "addonName must be a string")
assert(type(defaults) == "table", "defaults must be a table")
assert(type(defaults.Global) == "table", "defaults.Global must be a table")
assert(type(defaults.Profile) == "table", "defaults.Profile must be a table")
-- addon is loaded and svars are available
assert(
select(2, _G.IsAddOnLoaded(addonName)),
consts.ADDON_NOT_LOADED_MSG:format(addonName)
)
-- database for addon does not already exist
assert(
db_cache[addonName] == nil,
("attempt to create existing database for \"%s\""):format(addonName)
)
-- .toc metadata entry for DDBL
svarKey = _G.GetAddOnMetadata(addonName, consts.TOC_ENTRY)
assert(type(svarKey) == "string", consts.TOC_ERROR_MSG:format(addonName))
end
-- Create, store, and return
local db = utils.initialize(svarKey, defaults)
db_cache[addonName] = db
return db
end
-- Allow usage: `Addon.DethsDBLib(...)`
setmetatable(DDBL, { __call = DDBL.Create })
-- ============================================================================
-- Frame
-- ============================================================================
local frame = _G.CreateFrame(
"Frame",
("%s_%s_EventFrame"):format(
DDBL.metadata.name,
DDBL.metadata.version
)
)
function frame:OnEvent(event)
if (event == "PLAYER_LOGOUT") then
-- Deinitialize all databases
for _, db in pairs(db_cache) do
utils.deinitialize(db)
end
end
end
frame:SetScript("OnEvent", frame.OnEvent)
frame:RegisterEvent("PLAYER_LOGOUT")
|
local M = {}
local ccomp = require 'complementree.comparators'
local filter = require 'complementree.filters'
local utils = require 'complementree.utils'
local function complete(col, matches)
if matches and #matches > 0 then
vim.fn.complete(col, matches)
return true
else
return false
end
end
function M.combine(...)
local funcs = { ... }
return function(...)
local matches = {}
local coherent_p = nil
for _, f in pairs(funcs) do
local m, p = f(...)
if not coherent_p then
coherent_p = p
end
if coherent_p == p then
vim.list_extend(matches, m)
end
end
return matches, coherent_p
end
end
function M.optional(mandat, opt)
return function(ltc, lnum)
local matches, prefix = mandat(ltc, lnum)
if #matches > 0 then
local m, p = opt(ltc, lnum)
if p == prefix then
vim.list_extend(matches, m)
end
return matches, prefix
else
return {}, ''
end
end
end
-- TODO(vigoux): do we even need this anymore ?
function M.non_empty_prefix(func)
return function(ltc, lnum)
local compl, prefix = func(ltc, lnum)
if #prefix > 1 then
return complete(#ltc - #prefix + 1, compl)
else
return false
end
end
end
function M.wrap(func)
return function(ltc, lnum)
local compl, prefix = func(ltc, lnum)
return complete(#ltc - #prefix + 1, compl)
end
end
function M.pipeline(source, ...)
local current = source
for _, func in ipairs { ... } do
current = func(current)
end
return M.wrap(current)
end
function M.chain(...)
local funcs = { ... }
return function(...)
for _, f in pairs(funcs) do
local c, pref = f(...)
if #c > 0 then
return c, pref
end
end
return {}, ''
end
end
return M
|
Hooks:PostHook(PlayerManager, "check_skills", "Addon_Perks_PlayerManager_check_skills", function(self)
if self:has_category_upgrade("melee", "stacking_hit_damage_multiplier") then -- Fix here to avoid skill being triggered by other perkdecks
local function speed_up_on_melee_kill(weapon_unit, variant)
if variant == "melee" or weapon_unit:base():is_category("saw") then
self:activate_temporary_upgrade("temporary", "dodgeopath_speed")
self:activate_temporary_upgrade("temporary", "dodgeopath_invulnerability_on_kill")
managers.hud:activate_local_ability_radial_with_fullscreen(3)
local player_unit = self:player_unit()
local stamina_regen = player_unit:movement():_max_stamina()
player_unit:movement():add_stamina(stamina_regen)
end
end
self:register_message(Message.OnEnemyKilled, "speed_up_on_melee_kill_dodgeopath", speed_up_on_melee_kill)
else
self:unregister_message(Message.OnEnemyKilled, "speed_up_on_melee_kill_dodgeopath")
end
if self:has_category_upgrade("player", "redacted_pain") then
local function redacted_on_kill(weapon_unit, variant)
local player_unit = self:player_unit()
local char_damage = managers.player and managers.player:player_unit() and managers.player:player_unit():character_damage()
if char_damage then
local healing = char_damage:_max_health() * 0.04
char_damage:restore_health(healing, true)
end
end
self:register_message(Message.OnEnemyKilled, "redacted_on_kill", redacted_on_kill)
else
self:unregister_message(Message.OnEnemyKilled, "redacted_on_kill")
end
end)
local VPPP_PlayerManager_movement_speed_multiplier = PlayerManager.movement_speed_multiplier
function PlayerManager:movement_speed_multiplier(speed_state, bonus_multiplier, upgrade_level, health_ratio)
local multiplier = VPPP_PlayerManager_movement_speed_multiplier(self, speed_state, bonus_multiplier, upgrade_level, health_ratio)
multiplier = self:multiply_by_temporary_value_boost(multiplier, "dodgeopath_speed", 1.5)
return multiplier
end
local VPPP_PlayerManager_skill_dodge_chance = PlayerManager.skill_dodge_chance
function PlayerManager:skill_dodge_chance(running, crouching, on_zipline, override_armor, detection_risk)
local chance = VPPP_PlayerManager_skill_dodge_chance(self, running, crouching, on_zipline, override_armor, detection_risk)
-- local player = managers.player:player_unit()
chance = self:give_temporary_value_boost(chance, "dodgeopath_invulnerability_on_kill", 1)
return chance
end
function PlayerManager:get_striker_stacks()
return self._decaying_stacks.striker_stacks or 0
end
function PlayerManager:update_striker_stacks(value)
local newValue = self._decaying_stacks.striker_stacks + value
self._decaying_stacks.striker_stacks = math.min(math.max(newValue, 0), 1);
end
Hooks:PostHook(PlayerManager, "_setup", "VPPP_PlayerManager__setup", function(self)
self._decaying_stacks = self._decaying_stacks or {}
self._decaying_stacks.striker_stacks = 0
end)
local strikerDecayInterval = 1 -- 1s between one decay and the other
PlayerManager.strikerStackIncrease = 0.015
PlayerManager.strikerStackDecrease = -0.02
function PlayerManager:striker_decay_update(player, t)
if not self:has_category_upgrade("player", "striker_accuracy_to_damage") or not player then
return
end
self._striker_stack_decay_t = self._striker_stack_decay_t or t + strikerDecayInterval
if self._striker_stack_decay_t <= t and managers and managers.hud then
self._striker_stack_decay_t = self._striker_stack_decay_t + strikerDecayInterval
self:update_striker_stacks(-managers.player.strikerStackIncrease)
local char_damage = managers.player and managers.player:player_unit() and managers.player:player_unit():character_damage()
if char_damage and self:get_striker_stacks() > 0 then
local healing = char_damage:_max_health() * managers.player.strikerStackIncrease * self:get_striker_stacks()
-- mx_log("healing:"..tostring(healing).."_max_health"..tostring(char_damage:_max_health()))
char_damage:restore_health(healing, true)
end
managers.hud:set_info_meter_fast(nil, {
icon = "guis/dlcs/coco/textures/pd2/hud_absorb_stack_icon_01",
max = 1,
current = self:get_striker_stacks(),
total = 1
})
end
end
Hooks:PostHook(PlayerManager, "_internal_load", "Striker_PlayerManager__internal_load", function(self)
if self:has_category_upgrade("player", "striker_accuracy_to_damage") and managers and managers.hud then
managers.hud:set_info_meter(nil, {
icon = "guis/dlcs/coco/textures/pd2/hud_absorb_stack_icon_01",
max = 1,
current = self:get_striker_stacks(),
total = self:get_striker_stacks()
})
self:update_cocaine_hud()
end
end)
local redactedDecayInterval = 1 -- 1s between one decay and the other
function PlayerManager:redacted_decay_update(player, t)
if not self:has_category_upgrade("player", "redacted_pain") or not player and managers.groupai and not managers.groupai:state():whisper_mode()then
return
end
self._redacted_decay_t = self._redacted_decay_t or t + redactedDecayInterval
if self._redacted_decay_t <= t then
self._redacted_decay_t = self._redacted_decay_t + redactedDecayInterval
local char_damage = managers.player and managers.player:player_unit() and managers.player:player_unit():character_damage()
if char_damage and not char_damage._dead and not char_damage._bleed_out and not char_damage._check_berserker_done then
local damage = (char_damage:_max_health() * 0.01)
char_damage:stealth_set_health(char_damage:get_real_health() - damage)
char_damage:_check_bleed_out(true) -- To avoid the "walking around with 0HP" shit
end
end
end
local redactedBoostInterval = 30 -- 30s
function PlayerManager:redacted_boosts_update(player, t)
self.redacted_boost_stacks = self.redacted_boost_stacks or 0
self.redacted_boost_stacks = self.redacted_boost_stacks + 1
mx_log_chat('redacted_boost_stacks', self.redacted_boost_stacks)
end
Hooks:PostHook(PlayerManager, "update", "VPPP_PlayerManager_update", function(self, t, dt)
local player = self:player_unit()
self:striker_decay_update(player, t)
self:redacted_decay_update(player, t)
self:generic_decay_update(t, 'redacted_boosts', redactedBoostInterval, self.redacted_boosts_update)
end)
function PlayerManager:generic_decay_update(t, decay_key, decayInterval, callback)
local player = self:player_unit()
self[decay_key] = self[decay_key] or t + decayInterval
if self[decay_key] <= t then
self[decay_key] = self[decay_key] + decayInterval
callback(self, player, t)
end
end
Hooks:AddHook("PlayerManager_upgrade_value_overrides", "PlayerManager_upgrade_value_overrides_perkthrowables", function(self, category, upgrade, default, result)
local new_result = nil
local player_extra_ammo_multiplier = category == "player" and upgrade == "extra_ammo_multiplier"
if player_extra_ammo_multiplier and self:has_category_upgrade("player", "lonestar_extra_ammo_multiplier") then
new_result = self:upgrade_value("player", "lonestar_extra_ammo_multiplier") + result -- Add +X% ammo
end
return new_result
end)
function PlayerManager:_attempt_lonestar_rage()
local activated = self:generic_attempt("lonestar_rage")
if activated then
self:player_unit():movement():current_state()._equipped_unit:base():on_reload()
managers.hud:set_ammo_amount(self:player_unit():movement():current_state()._equipped_unit:base():selection_index(), self:player_unit():movement():current_state()._equipped_unit:base():ammo_info())
end
return activated
end
|
--Saber
local plr = game:service'Players'.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local torso = char:findFirstChild("Torso")
local head = char.Head
local ra = char:findFirstChild("Right Arm")
local la = char:findFirstChild("Left Arm")
local rl = char:findFirstChild("Right Leg")
local ll = char:findFirstChild("Left Leg")
local rs = torso:findFirstChild("Right Shoulder")
local ls = torso:findFirstChild("Left Shoulder")
local equipped = false
local debounce = false
local slashing = false
local blocking = false
local blocking2 = false
local stoopidstuff = Instance.new("BoolValue", char)
stoopidstuff.Name = "stoopidstuff"
stoopidstuff.Value = true
local healing = false
local storedhealth
local storewalkspeed = char:findFirstChild("Humanoid").WalkSpeed
local damage = 30
local colors = {"Royal purple", "Cyan", "Really red", "Lime green"}
function part(parent, size, formfactor, color, collide, transparency)
local p=Instance.new("Part", parent)
p.FormFactor=formfactor
p.CanCollide=false
p.Size=size
p.Locked=true
p.Transparency=transparency
p.Position=torso.Position
p.BrickColor=color
p.FrontSurface="SmoothNoOutlines"
p.BackSurface="SmoothNoOutlines"
p.LeftSurface="SmoothNoOutlines"
p.BottomSurface="SmoothNoOutlines"
p.TopSurface="SmoothNoOutlines"
p.RightSurface="SmoothNoOutlines"
return p
end
function wedge(parent, size, formfactor, color, collide)
local p=Instance.new("Wedge", parent)
p.FormFactor=formfactor
p.CanCollide=false
p.Size=size
p.Locked=true
p.Position = torso.Position
p.BrickColor=color
p.FrontSurface="SmoothNoOutlines"
p.BackSurface="SmoothNoOutlines"
p.LeftSurface="SmoothNoOutlines"
p.BottomSurface="SmoothNoOutlines"
p.TopSurface="SmoothNoOutlines"
p.RightSurface="SmoothNoOutlines"
return p
end
function weld(c0, c1, part1, part0)
local wel=Instance.new("Weld", char)
wel.Part0 = part0
wel.Part1 = part1
wel.C0 = c0
wel.C1 = c1
return wel
end
function specialmesh(parent, meshType, scale, meshId)
local mesh = Instance.new("SpecialMesh", parent)
mesh.Scale = scale
mesh.MeshType = meshType
mesh.MeshId = meshId
return mesh
end
function equip()
ar = Instance.new("Part", char)
ar.FormFactor = "Custom"
ar.Size = Vector3.new(1, 1, 1)
ar.Transparency = 1
ar.CanCollide = false
ar.Locked = true
ar:BreakJoints()
fakel = Instance.new("Weld", char)
fakel.Part0 = char.Torso
fakel.Part1 = ar
coroutine.wrap(function()
for angle = 0, 45, 5 do
if fakel == nil then return end
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(0), math.rad(0))
wait()
end
end)()
welditbro = Instance.new("Weld", char)
welditbro.C0 = CFrame.new(0, 0.5, 0)
welditbro.Part0 = ra
welditbro.Part1 = ar
end
function block()
if not equipped then return end
stoopidstuff.Value = true
damage = 2
char:findFirstChild("Humanoid").WalkSpeed = 6
storedhealth = char:findFirstChild("Humanoid").Health
for angle = 0, 70, 10 do
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45), math.rad(angle), 0)
wait()
end
coroutine.wrap(function()
while blocking do
if not blocking then return end
char:findFirstChild("Humanoid").Health = storedhealth
game:service'RunService'.Stepped:wait()
end
end)()
end
function unblock()
stoopidstuff.Value = false
if not equipped then return end
damage = 30
char:findFirstChild("Humanoid").WalkSpeed = storewalkspeed
for angle = 70, 0, -10 do
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45), math.rad(angle), 0)
wait()
end
blocking = false
end
function block2()
if not equipped then return end
stoopidstuff.Value = true
damage = 2
char:findFirstChild("Humanoid").WalkSpeed = 6
storedhealth = char:findFirstChild("Humanoid").Health
for angle = 0, 50, 10 do
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45 + angle/6), 0, -math.rad(angle))
wait()
end
coroutine.wrap(function()
while blocking2 do
if not blocking2 then return end
char:findFirstChild("Humanoid").Health = storedhealth
game:service'RunService'.Stepped:wait()
end
end)()
end
function unblock2()
stoopidstuff.Value = false
if not equipped then return end
damage = 30
char:findFirstChild("Humanoid").WalkSpeed = storewalkspeed
for angle = 50, 0, -10 do
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45 + angle/6), math.rad(0), -math.rad(angle))
wait()
end
blocking2 = false
end
function heal()
ar2 = Instance.new("Part", char)
ar2.FormFactor = "Custom"
ar2.Size = Vector3.new(1, 1, 1)
ar2.Transparency = 1
ar2.CanCollide = false
ar2.Locked = true
ar2:BreakJoints()
fakel2 = Instance.new("Weld", char)
fakel2.Part0 = torso
fakel2.Part1 = ar2
welditbro2 = Instance.new("Weld", char)
welditbro2.C0 = CFrame.new(0, 0.5, 0)
welditbro2.Part0 = la
welditbro2.Part1 = ar2
for angle = 0, 170, 5 do
fakel2.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(0), math.rad(0))
wait()
end
local ball = Instance.new("Part", char)
ball.FormFactor = "Custom"
ball.BrickColor = BrickColor.new("Lime green")
ball.Anchored = true
ball.CanCollide = false
ball.TopSurface = 0
ball.BottomSurface = 0
ball.Transparency = 0.4
ball.Locked = true
ball.Shape = "Ball"
ball.CFrame = torso.CFrame
local mesh = Instance.new("SpecialMesh", ball)
mesh.MeshType = "Sphere"
coroutine.wrap(function()
for i = 0.2, 8, 0.1 do
mesh.Scale = Vector3.new(i, i, i)
ball.Transparency = ball.Transparency + 0.005
wait()
end
ball:Destroy()
end)()
local splash = Instance.new("Part", char)
splash.FormFactor = "Custom"
splash.BrickColor = BrickColor.new("Lime green")
splash.Transparency = 0
splash.Anchored = true
splash.CanCollide = false
splash.BottomSurface = 0
splash.TopSurface = 0
splash.Locked = true
local mesh = Instance.new("SpecialMesh", splash)
mesh.MeshType = "FileMesh"
mesh.Scale = Vector3.new(1, 1, 1)
mesh.MeshId = "http://www.roblox.com/asset/?id=3270017"
splash:BreakJoints()
splash.CFrame = ball.CFrame * CFrame.Angles(math.rad(90), 0, 0)
coroutine.resume(coroutine.create(function()
for i = 0, 50, 0.5 do
mesh.Scale = Vector3.new(i, i, 1)
splash.Transparency = splash.Transparency + 0.01
wait()
end
splash:Destroy()
end))
char:findFirstChild("Humanoid").Health = char:findFirstChild("Humanoid").Health + 1000
wait(0.5)
welditbro2:Destroy()
fakel2:Destroy()
ar2:Destroy()
ls.Parent = torso
wait(1)
healing = false
end
function slash()
if blocking then return end
if blocking2 then return end
if not equipped then return end
damage = 80
for angle = 45, 95, 10 do
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(angle/2), 0)
wait()
end
for angle = 95, 5, -20 do
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(angle/2), 0)
wait()
end
for angle = 5, 45, 10 do
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(angle), math.rad(angle/angle - 5), 0)
wait()
end
slashing = false
fakel.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.rad(45), 0, 0)
damage = 30
wait(0.2)
end
function deequip()
pcall(function()
ar:Destroy()
fakel:Destroy()
welditbro:Destroy()
end)
end
local part1 = part(char, Vector3.new(0.2, 1.4, 0.2), "Custom", BrickColor.new("Black"), 0)
Instance.new("CylinderMesh", part1)
local weld1 = weld(CFrame.new(0, 0, 1) * CFrame.Angles(math.pi/2, 0, 0), CFrame.new(), ra, part1)
local part2 = part(char, Vector3.new(0.4, 0.4, 0.4), "Custom", BrickColor.new("Black"), 0)
Instance.new("CylinderMesh", part2)
local weld3 = weld(CFrame.new(0, 0.65, 0), CFrame.new(), part2, part1)
local part3 = part(char, Vector3.new(0.3, 4.4, 0.3), "Custom", BrickColor.White(), 0)
local mesh1 = specialmesh(part3, "Head", Vector3.new(0.8, 1, 0.8), "")
local weld4 = weld(CFrame.new(0, 2.9, 0), CFrame.new(), part3, part1)
local part4 = part(char, Vector3.new(0.4, 4.4, 0.4), "Custom", BrickColor.new(colors[math.random(1, #colors)]), 0)
local mesh2 = specialmesh(part4, "Head", Vector3.new(1, 1.01, 1), "")
local weld5 = weld(CFrame.new(0, 2.9, 0), CFrame.new(), part4, part1)
local pl = Instance.new("PointLight", part4)
pl.Color = part4.BrickColor.Color
pl.Brightness = 0
part3.Transparency = 1
part4.Transparency = 1
part4.Touched:connect(function(hit)
if not equipped then return end
if debounce then return end
debounce = true
coroutine.wrap(function()
pcall(function()
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if hit.Parent.Name == char.Name then return end
if hit.Parent:findFirstChild("stoopidstuff") ~= nil and hit.Parent:findFirstChild("stoopidstuff").Value == true then
return
end
damagerandom = damage + math.random(0, 10)
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damagerandom
coroutine.wrap(function()
local prt = Instance.new("Part", char)
prt.FormFactor = "Custom"
prt.Size = Vector3.new(0.1, 0.1, 0.1)
prt.Transparency = 1
prt.CanCollide = false
prt.CFrame = CFrame.new(part4.CFrame.x, part4.CFrame.y, part4.CFrame.z)
prt.Anchored = true
coroutine.resume(coroutine.create(function()
for i = 2, 10, 0.05 do
if prt == nil then return end
prt.CFrame = prt.CFrame * CFrame.new(0, 0.05, 0)
game:service'RunService'.Stepped:wait()
end
end))
local bg = Instance.new("BillboardGui")
bg.Parent = prt
bg.Adornee = prt
bg.Size = UDim2.new(4, 0, 3.5, 0)
bg.ExtentsOffset = Vector3.new(0, 0, 0)
local lol = Instance.new("TextLabel")
lol.Size = UDim2.new(1.3, 0, 0.4, 0)
lol.TextScaled = true
lol.TextWrapped = true
lol.BackgroundTransparency = 0.4
lol.Parent = bg
lol.FontSize = "Size24"
lol.TextColor3 = Color3.new(1, 0, 0)
lol.TextStrokeTransparency = 0
lol.Font = "ArialBold"
lol.Text = "-"..damagerandom
wait(5)
prt:Destroy()
end)()
end
end)
end)()
wait(0.1)
debounce = false
end)
mouse.Button1Down:connect(function(mouse)
if slashing then return end
if not equipped then return end
if blocking2 then return end
if blocking then return end
slashing = true
slash()
end)
mouse.KeyUp:connect(function(key)
if key == "f" then
if not equipped then return end
if not blocking then return end
unblock()
char:findFirstChild("Humanoid").MaxHealth = 100
end
if key == "g" then
if not equipped then return end
if not blocking2 then return end
unblock2()
char:findFirstChild("Humanoid").MaxHealth = 100
end
end)
mouse.KeyDown:connect(function(key)
if key == "f" then
if not equipped then return end
if blocking then return end
if blocking2 then return end
blocking = true
block()
end
if key == "g" then
if not equipped then return end
if blocking then return end
if blocking2 then return end
blocking2 = true
block2()
end
if key == "v" then
if healing then return end
if slashing then return end
healing = true
heal()
end
if key == "q" then
if blocking2 then return end
if blocking then return end
equipped = not equipped
if equipped then
coroutine.wrap(function()
while equipped do
part4.Transparency = 0.6
pl.Brightness = 0.6
wait(0.05)
part4.Transparency = 0.7
pl.Brightness = 0.8
wait(0.05)
end
end)()
weld1.Part1 = ra
weld1.C0 = CFrame.new(0, 0, 1) * CFrame.Angles(math.pi/2, 0, 0)
part3.Transparency = 0
local sound = Instance.new("Sound", char.Head)
sound.SoundId = [[rbxasset://sounds\Rocket whoosh 01.wav]]
sound.Pitch = 3
sound.Volume = 1
sound:play()
equip()
wait(1)
sound:stop()
sound:Destroy()
else
deequip()
wait(0.1)
weld1.Part1 = rl
weld1.C0 = CFrame.new(-0.6,-0.8,-0.2) * CFrame.Angles(math.pi/4, 0, 0)
part3.Transparency = 1
pl.Brightness = 0
part4.Transparency = 1
end
end
end)
while true do
if slashing then
local clone = part4:clone()
clone.Anchored = true
clone.Parent = workspace
clone.Name = "trail"
clone:findFirstChild("Mesh"):Destroy()
Instance.new("BlockMesh", clone)
clone.Mesh.Scale = clone.Mesh.Scale - Vector3.new(0.8, 0, 0) + Vector3.new(0, 0, 1.6)
coroutine.wrap(function()
for i = 0, 20 do
clone.Transparency = clone.Transparency + 0.05
clone.Mesh.Scale = clone.Mesh.Scale - Vector3.new(0.05, 0.05, 0.05)
wait()
end
clone:Destroy()
end)()
end
wait()
end
|
util.keep_running()
require("natives-1640181023")
-- Yoinked From MoistScript, hope moist won't mind :)
SoundAnnoy = {
{"CHARACTER_SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Air_Defenses_Disabled", "DLC_sum20_Business_Battle_AC_Sounds"},
{"Air_Defences_Activated", "DLC_sum20_Business_Battle_AC_Sounds"},
{"TIME_LAPSE_MASTER", "0"},
{"Lester_Laugh_Phone", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"Leave_Horn", "DLC_Apartment_Yacht_Streams_Soundset"},
{"Arrive_Horn", "DLC_Apartment_Yacht_Streams_Soundset"},
{"Moor_SEASHARK3_Engine", "DLC_Apartment_Yacht_Streams_Soundset"},
{"Turret_Camera_Hum_Loop", "DLC_BTL_Terrobyte_Turret_Sounds"},
{"Fire", "DLC_BTL_Terrobyte_Turret_Sounds"},
{"Moor_Boat_Engine", "DLC_Apartment_Yacht_Streams_Soundset"},
{"VULKAN_LOCK_ON_AMBER", 0},
{"VULKAN_LOCK_ON_RED", 0},
{"cannon_activating_loop", "dlc_xm_orbital_cannon_sounds"},
{"cannon_charge_fire_loop", "dlc_xm_orbital_cannon_sounds"},
{"DLC_XM_Explosions_Orbital_Cannon", 0},
{"TIMER", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Timer_10s", "DLC_HALLOWEEN_FVJ_Sounds"},
{"TIMER_STOP", "HUD_MINI_GAME_SOUNDSET"},
{"5s_To_Event_Start_Countdown", "GTAO_FM_Events_Soundset"},
{"10s", "MP_MISSION_COUNTDOWN_SOUNDSET"},
{"5s", "MP_MISSION_COUNTDOWN_SOUNDSET"},
{"5_Second_Timer", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"5_SEC_WARNING", "HUD_MINI_GAME_SOUNDSET"},
{"3_2_1_NON_RACE", "HUD_MINI_GAME_SOUNDSET"},
{"3_2_1", "HUD_MINI_GAME_SOUNDSET"},
{"WIND", "EXTREME_01_SOUNDSET"},
{"HOUSE_FIRE", "JOSH_03_SOUNDSET"},
{"Hot_Tub_Loop", "GTAO_Yacht_SoundSet"},
{"Arming_Countdown", "GTAO_Speed_Convoy_Soundset"},
{"Bomb_Disarmed", "GTAO_Speed_Convoy_Soundset"},
{"Boss_Blipped", "GTAO_Magnate_Hunt_Boss_SoundSet"},
{"Boss_Message_Orange", "GTAO_Boss_Goons_FM_Soundset"},
{"1st_Person_Transition", "PLAYER_SWITCH_CUSTOM_SOUNDSET"},
{"Apt_Style_Purchase", "DLC_APT_Apartment_SoundSet"},
{"ARM_WRESTLING_WHOOSH_MASTER", "0"},
{"ASSASSINATIONS_HOTEL_TIMER_COUNTDOWN", "ASSASSINATION_MULTI"},
{"ATM_WINDOW", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"BASE_JUMP_PASSED", "HUD_AWARDS"},
{"Bed", "WastedSounds"},
{"Beep_Green", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"Blade_Appear", "APT_BvS_Soundset"},
{"BOATS_PLANES_HELIS_BOOM", "MP_LOBBY_SOUNDS"},
{"Breaker_01", "DLC_HALLOWEEN_FVJ_Sounds"},
{"Breaker_02", "DLC_HALLOWEEN_FVJ_Sounds"},
{"Bus_Schedule_Pickup", "DLC_PRISON_BREAK_HEIST_SOUNDS"},
{"CABLE_SNAPS", "CONSTRUCTION_ACCIDENT_1_SOUNDS"},
{"CAM_PAN_DARTS", "HUD_MINI_GAME_SOUNDSET"},
{"Camera_Shoot", "Phone_Soundset_Franklin"},
{"CANCEL", "HUD_FREEMODE_SOUNDSET"},
{"CAR_BIKE_WHOOSH", "MP_LOBBY_SOUNDS"},
{"CHALLENGE_UNLOCKED", "HUD_AWARDS"},
{"CHECKPOINT_AHEAD", "HUD_MINI_GAME_SOUNDSET"},
{"CHECKPOINT_BEHIND", "HUD_MINI_GAME_SOUNDSET"},
{"Checkpoint_Cash_Hit", "GTAO_FM_Events_Soundset"},
{"Checkpoint_Hit", "GTAO_FM_Events_Soundset"},
{"CHECKPOINT_MISSED", "HUD_MINI_GAME_SOUNDSET"},
{"CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET"},
{"CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET"},
{"Checkpoint_Teammate", "GTAO_Shepherd_Sounds"},
{"CHECKPOINT_UNDER_THE_BRIDGE", "HUD_MINI_GAME_SOUNDSET"},
{"Click", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"CLICK_BACK", "WEB_NAVIGATION_SOUNDS_PHONE"},
{"Click_Fail", "WEB_NAVIGATION_SOUNDS_PHONE"},
{"Click_Special", "WEB_NAVIGATION_SOUNDS_PHONE"},
{"CLOSED", "MP_PROPERTIES_ELEVATOR_DOORS"},
{"CONFIRM_BEEP", "HUD_MINI_GAME_SOUNDSET"},
{"CONTINUE", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Continue_Accepted", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Continue_Appears", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Crash", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"Criminal_Damage_High_Value", "GTAO_FM_Events_Soundset"},
{"Criminal_Damage_Kill_Player", "GTAO_FM_Events_Soundset"},
{"Criminal_Damage_Low_Value", "GTAO_FM_Events_Soundset"},
{"Cycle_Item", "DLC_Dmod_Prop_Editor_Sounds"},
{"DELETE", "HUD_DEATHMATCH_SOUNDSET"},
{"Delete_Placed_Prop", "DLC_Dmod_Prop_Editor_Sounds"},
{"Deliver_Pick_Up", "HUD_FRONTEND_MP_COLLECTABLE_SOUNDS"},
{"DiggerRevOneShot", "BulldozerDefault"},
{"Door_Open", "DOCKS_HEIST_FINALE_2B_SOUNDS"},
{"Drill_Pin_Break", "DLC_HEIST_FLEECA_SOUNDSET"},
{"Dropped", "HUD_FRONTEND_MP_COLLECTABLE_SOUNDS"},
{"EDIT", "HUD_DEATHMATCH_SOUNDSET"},
{"Start_Squelch", "CB_RADIO_SFX"},
{"End_Squelch", "CB_RADIO_SFX"},
{"Enemy_Capture_Start", "GTAO_Magnate_Yacht_Attack_Soundset"},
{"Enemy_Deliver", "HUD_FRONTEND_MP_COLLECTABLE_SOUNDS"},
{"Enemy_Pick_Up", "HUD_FRONTEND_MP_COLLECTABLE_SOUNDS"},
{"Enter_1st", "GTAO_FM_Events_Soundset"},
{"Enter_Area", "DLC_Lowrider_Relay_Race_Sounds"},
{"Enter_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds"},
{"ERROR", "HUD_AMMO_SHOP_SOUNDSET"},
{"Event_Message_Purple", "GTAO_FM_Events_Soundset"},
{"Event_Start_Text", "GTAO_FM_Events_Soundset"},
{"EXIT", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Exit_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds"},
{"Failure", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"Falling_Crates", "EXILE_1"},
{"Faster_Bar_Full", "RESPAWN_ONLINE_SOUNDSET"},
{"Faster_Click", "RESPAWN_ONLINE_SOUNDSET"},
{"FestiveGift", "Feed_Message_Sounds"},
{"FIRST_PLACE", "HUD_MINI_GAME_SOUNDSET"},
{"FLIGHT_SCHOOL_LESSON_PASSED", "HUD_AWARDS"},
{"FLYING_STREAM_END_INSTANT", "FAMILY_5_SOUNDS"},
{"FocusIn", "HintCamSounds"},
{"FocusOut", "HintCamSounds"},
{"Friend_Deliver", "HUD_FRONTEND_MP_COLLECTABLE_SOUNDS"},
{"Friend_Pick_Up", "HUD_FRONTEND_MP_COLLECTABLE_SOUNDS"},
{"GO", "HUD_MINI_GAME_SOUNDSET"},
{"Goal", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"GOLF_BIRDIE", "HUD_AWARDS"},
{"GOLF_EAGLE", "HUD_AWARDS"},
{"GOLF_HUD_HOLE_IN_ONE_MASTER", "0"},
{"GOLF_HUD_SCORECARD_MASTER", "0"},
{"GOLF_NEW_RECORD", "HUD_AWARDS"},
{"Goon_Paid_Small", "GTAO_Boss_Goons_FM_Soundset"},
{"Grab_Parachute", "BASEJUMPS_SOUNDS"},
{"Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS"},
{"Hack_Success", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS"},
{"BBQ_EXPLODE", "JOSH_03_SOUNDSET"},
{"HACKING_CLICK", "0"},
{"HACKING_CLICK_BAD", "0"},
{"HACKING_CLICK_GOOD", "0"},
{"HACKING_MOVE_CURSOR", "0"},
{"Hang_Up", "Phone_SoundSet_Michael"},
{"HIGHLIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Highlight_Accept", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Highlight_Cancel", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Highlight_Error", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Highlight_Move", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"HIGHLIGHT_NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Hit", "RESPAWN_ONLINE_SOUNDSET"},
{"Hit_1", "LONG_PLAYER_SWITCH_SOUNDS"},
{"Hit_In", "PLAYER_SWITCH_CUSTOM_SOUNDSET"},
{"Hit_Out", "PLAYER_SWITCH_CUSTOM_SOUNDSET"},
{"HORDE_COOL_DOWN_TIMER", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"HUD_FREEMODE_CANCEL_MASTER", "0"},
{"Kill_List_Counter", "GTAO_FM_Events_Soundset"},
{"LEADERBOARD", "HUD_MINI_GAME_SOUNDSET"},
{"Lights_On", "GTAO_MUGSHOT_ROOM_SOUNDS"},
{"LIMIT", "DLC_APT_YACHT_DOOR_SOUNDS"},
{"Load_Scene", "DLC_Dmod_Prop_Editor_Sounds"},
{"LOCAL_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"LOCAL_PLYR_CASH_COUNTER_INCREASE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"LOOSE_MATCH", "HUD_MINI_GAME_SOUNDSET"},
{"Lose_1st", "GTAO_FM_Events_Soundset"},
{"LOSER", "HUD_AWARDS"},
{"Map_Roll_Down", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Map_Roll_Up", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"MARKER_ERASE", "HEIST_BULLETIN_BOARD_SOUNDSET"},
{"MARTIN1_DISTANT_TRAIN_HORNS_MASTER", "0"},
{"MEDAL_BRONZE", "HUD_AWARDS"},
{"MEDAL_GOLD", "HUD_AWARDS"},
{"MEDAL_SILVER", "HUD_AWARDS"},
{"MEDAL_UP", "HUD_MINI_GAME_SOUNDSET"},
{"Menu_Accept", "Phone_SoundSet_Default"},
{"Mission_Pass_Notify", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"MP_5_SECOND_TIMER", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"MP_AWARD", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"MP_Flash", "WastedSounds"},
{"MP_IDLE_KICK", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"MP_IDLE_TIMER", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"MP_Impact", "WastedSounds"},
{"MP_RANK_UP", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"MP_WAVE_COMPLETE", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"NAV", "HUD_AMMO_SHOP_SOUNDSET"},
{"Nav_Arrow_Ahead", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"Nav_Arrow_Behind", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"Nav_Arrow_Left", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"Nav_Arrow_Right", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"NAV_LEFT_RIGHT", "HUD_FREEMODE_SOUNDSET"},
{"NAV_UP_DOWN", "HUD_FREEMODE_SOUNDSET"},
{"Near_Miss_Counter_Reset", "GTAO_FM_Events_Soundset"},
{"NO", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Object_Collect_Player", "GTAO_FM_Events_Soundset"},
{"Object_Dropped_Remote", "GTAO_FM_Events_Soundset"},
{"Off_High", "MP_RADIO_SFX"},
{"OK", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"ON", "NOIR_FILTER_SOUNDS"},
{"On_Call_Player_Join", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"Oneshot_Final", "MP_MISSION_COUNTDOWN_SOUNDSET"},
{"OOB_Cancel", "GTAO_FM_Events_Soundset"},
{"OOB_Start", "GTAO_FM_Events_Soundset"},
{"OPEN_WINDOW", "LESTER1A_SOUNDS"},
{"OPENED", "MP_PROPERTIES_ELEVATOR_DOORS"},
{"OTHER_TEXT", "HUD_AWARDS"},
{"Out_Of_Area", "DLC_Lowrider_Relay_Race_Sounds"},
{"Out_Of_Bounds_Timer", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"Paper_Shuffle", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Parcel_Vehicle_Lost", "GTAO_FM_Events_Soundset"},
{"Payment_Non_Player", "DLC_HEISTS_GENERIC_SOUNDS"},
{"Payment_Player", "DLC_HEISTS_GENERIC_SOUNDS"},
{"Pen_Tick", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"PERSON_SCROLL", "HEIST_BULLETIN_BOARD_SOUNDSET"},
{"PERSON_SELECT", "HEIST_BULLETIN_BOARD_SOUNDSET"},
{"Phone_Generic_Key_02", "HUD_MINIGAME_SOUNDSET"},
{"PICK_UP", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Pin_Bad", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS"},
{"PIN_BUTTON", "ATM_SOUNDS"},
{"Pin_Centred", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS"},
{"Pin_Good", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS"},
{"PIPES_LAND", "CONSTRUCTION_ACCIDENT_1_SOUNDS"},
{"Place_Prop_Fail", "DLC_Dmod_Prop_Editor_Sounds"},
{"Place_Prop_Success", "DLC_Dmod_Prop_Editor_Sounds"},
{"Player_Collect", "DLC_PILOT_MP_HUD_SOUNDS"},
{"Player_Enter_Line", "GTAO_FM_Cross_The_Line_Soundset"},
{"Player_Exit_Line", "GTAO_FM_Cross_The_Line_Soundset"},
{"Power_Down", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"Pre_Screen_Stinger", "DLC_HEISTS_FAILED_SCREEN_SOUNDS"},
{"PS2A_MONEY_LOST", "PALETO_SCORE_2A_BANK_SS"},
{"PURCHASE", "HUD_LIQUOR_STORE_SOUNDSET"},
{"Put_Away", "Phone_SoundSet_Michael"},
{"QUIT", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"QUIT_WHOOSH", "HUD_MINI_GAME_SOUNDSET"},
{"RACE_PLACED", "HUD_AWARDS"},
{"RAMP_DOWN", "TRUCK_RAMP_DOWN"},
{"RAMP_UP", "TRUCK_RAMP_DOWN"},
{"RANK_UP", "HUD_AWARDS"},
{"REMOTE_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"REMOTE_PLYR_CASH_COUNTER_INCREASE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS"},
{"Reset_Prop_Position", "DLC_Dmod_Prop_Editor_Sounds"},
{"RESTART", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"RETRY", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"ROBBERY_MONEY_TOTAL", "HUD_FRONTEND_CUSTOM_SOUNDSET"},
{"ROPE_CUT", "ROPE_CUT_SOUNDSET"},
{"ROUND_ENDING_STINGER_CUSTOM", "CELEBRATION_SOUNDSET"},
{"Save_Scene", "DLC_Dmod_Prop_Editor_Sounds"},
{"SCOPE_UI_MASTER", "0"},
{"ScreenFlash", "WastedSounds"},
{"SCREEN_SWIPE", "CELEBRATION_SWIPE"},
{"SELECT", "HUD_FREEMODE_SOUNDSET"},
{"Select_Placed_Prop", "DLC_Dmod_Prop_Editor_Sounds"},
{"Shard_Disappear", "GTAO_FM_Events_Soundset"},
{"SHOOTING_RANGE_ROUND_OVER", "HUD_AWARDS"},
{"Short_Transition_In", "PLAYER_SWITCH_CUSTOM_SOUNDSET"},
{"Short_Transition_Out", "PLAYER_SWITCH_CUSTOM_SOUNDSET"},
{"SKIP", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Start", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"STUN_COLLECT", "MINUTE_MAN_01_SOUNDSET"},
{"Success", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"Swap_Sides", "DLC_HALLOWEEN_FVJ_Sounds"},
{"SWING_SHUT", "GTAO_APT_DOOR_DOWNSTAIRS_GLASS_SOUNDS"},
{"Tattooing_Oneshot", "TATTOOIST_SOUNDS"},
{"Tattooing_Oneshot_Remove", "TATTOOIST_SOUNDS"},
{"Team_Capture_Start", "GTAO_Magnate_Yacht_Attack_Soundset"},
{"TENNIS_MATCH_POINT", "HUD_AWARDS"},
{"TENNIS_POINT_WON", "HUD_AWARDS"},
{"TextHit", "WastedSounds"},
{"TOGGLE_ON", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"Turn", "DLC_HEIST_HACKING_SNAKE_SOUNDS"},
{"UNDER_THE_BRIDGE", "HUD_AWARDS"},
{"WAYPOINT_SET", "HUD_FRONTEND_DEFAULT_SOUNDSET"},
{"WEAPON_ATTACHMENT_EQUIP", "HUD_AMMO_SHOP_SOUNDSET"},
{"WEAPON_ATTACHMENT_UNEQUIP", "HUD_AMMO_SHOP_SOUNDSET"},
{"WEAPON_PURCHASE", "HUD_AMMO_SHOP_SOUNDSET"},
{"WEAPON_SELECT_ARMOR", "HUD_AMMO_SHOP_SOUNDSET"},
{"Whistle", "DLC_TG_Running_Back_Sounds"},
{"Whoosh_1s_L_to_R", "MP_LOBBY_SOUNDS"},
{"Whoosh_1s_R_to_L", "MP_LOBBY_SOUNDS"},
{"WIN", "HUD_AWARDS"},
{"Zone_Enemy_Capture", "DLC_Apartments_Drop_Zone_Sounds"},
{"Zone_Neutral", "DLC_Apartments_Drop_Zone_Sounds"},
{"Zone_Team_Capture", "DLC_Apartments_Drop_Zone_Sounds"},
{"Zoom_In", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Zoom_Left", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Zoom_Out", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
{"Zoom_Right", "DLC_HEIST_PLANNING_BOARD_SOUNDS"},
}
local getPlayerPed = PLAYER.GET_PLAYER_PED
local getEntityCoords = ENTITY.GET_ENTITY_COORDS
local menuroot = menu.my_root()
local function AudioAnnoyance(Ker_SND, Ker_AUD)
for i=0, 31, 1 do
Ker_pped = getPlayerPed(i)
Ker_pos = getEntityCoords(Ker_pped)
AUDIO.PLAY_SOUND_FRONTEND(-1, Ker_SND, Ker_AUD, true)
AUDIO.PLAY_SOUND_FROM_COORD(-1, Ker_SND, Ker_pos.x, Ker_pos.y, Ker_pos.z, Ker_AUD, true, 999999999, true)
end
end
local soundsList = menu.list(menu.my_root(), "Play Sounds throughout the map.", {"Ksounds", "soundslist", "soundannoy"}, "A list of sounds that can be played throughout the entire freemode lobby. Sounds provided by Moist through his MoistScript.")
for i = 1, #SoundAnnoy do
menu.action(soundsList, SoundAnnoy[i][1], {}, "", function()
local snd, aud
snd = tostring(SoundAnnoy[i][1])
aud = tostring(SoundAnnoy[i][2])
AudioAnnoyance(snd, aud)
end)
menu.toggle_loop(soundsList, SoundAnnoy[i][1], {}, "", function ()
local snd, aud
snd = tostring(SoundAnnoy[i][1])
aud = tostring(SoundAnnoy[i][2])
AudioAnnoyance(snd, aud)
end)
end
|
---
-- Sink a signal to a file, serialized in JSON. Samples are serialized
-- individually and newline delimited. This sink accepts any data type that
-- implements `to_json()`.
--
-- @category Sinks
-- @block JSONSink
-- @tparam[opt=io.stdout] string|file|int file Filename, file object, or file descriptor
--
-- @signature in:supported >
--
-- @usage
-- -- Sink JSON serialized samples to stdout
-- local snk = radio.JSONSink()
-- top:connect(src, snk)
--
-- -- Sink JSON serialized samples to a file
-- local snk = radio.JSONSink('out.json')
-- top:connect(src, snk)
local ffi = require('ffi')
local block = require('radio.core.block')
local JSONSink = block.factory("JSONSink")
function JSONSink:instantiate(file)
if type(file) == "number" then
self.fd = file
elseif type(file) == "string" then
self.filename = file
elseif file == nil then
-- Default to io.stdout
self.file = io.stdout
end
-- Accept all input types that implement to_json()
self:add_type_signature({block.Input("in", function (type) return type.to_json ~= nil end)}, {})
end
function JSONSink:initialize()
if self.filename then
self.file = ffi.C.fopen(self.filename, "wb")
if self.file == nil then
error("fopen(): " .. ffi.string(ffi.C.strerror(ffi.errno())))
end
elseif self.fd then
self.file = ffi.C.fdopen(self.fd, "wb")
if self.file == nil then
error("fdopen(): " .. ffi.string(ffi.C.strerror(ffi.errno())))
end
end
-- Register open file
self.files[self.file] = true
end
function JSONSink:process(x)
for i = 0, x.length-1 do
local s = x.data[i]:to_json() .. "\n"
-- Write to file
if ffi.C.fwrite(s, 1, #s, self.file) ~= #s then
error("fwrite(): " .. ffi.string(ffi.C.strerror(ffi.errno())))
end
end
-- Flush file
if ffi.C.fflush(self.file) ~= 0 then
error("fflush(): " .. ffi.string(ffi.C.strerror(ffi.errno())))
end
end
function JSONSink:cleanup()
if self.filename then
if ffi.C.fclose(self.file) ~= 0 then
error("fclose(): " .. ffi.string(ffi.C.strerror(ffi.errno())))
end
elseif self.fd then
if ffi.C.fflush(self.file) ~= 0 then
error("fflush(): " .. ffi.string(ffi.C.strerror(ffi.errno())))
end
else
self.file:flush()
end
end
return JSONSink
|
return {'cdtje'}
|
--==================--
local libUnitMove = {}
--==================--
-- < Modules > --
local math2 = require "math2"
local table2 = require "table2"
--========================================================--
-- class unitMove2D --
-- --
-- Handles movement of a unit with key input of a player. --
--========================================================--
libUnitMove.unitMove2D = setmetatable({
Name = "New 2D Player Controller",
--== Auto-Update Functionality On Change ==--
PlayerId, -- int. Change to set which player this controls.
Unit, -- (native) unithandle. Change to set which unit is controlled by movement.
Speed = 270, -- Movespeed
KeyUp = OSKEY_W, -- (native) oskeytype. Keybind to move up
KeyLeft = OSKEY_A, -- (native) oskeytype. Keybind to move left
KeyDown = OSKEY_S, -- (native) oskeytype. Keybind to move down
KeyRight = OSKEY_D, -- (native) oskeytype. Keybind to move right
Enabled = true, -- Change to enable or disable movement
--== Read-Only ==--
CurrVec, -- math2.vec3. Current movement vector based on pressed keys.
IsUp = false, -- Is the player currently pressing Up key
IsLeft = false, -- Is the player currently pressing Left key
IsDown = false, -- Is the player currently pressing Down key
IsRight = false, -- Is the player currently pressing Right key
Trigs = {}, -- Triggers used for movement
--=============--
-- Constructor --
--=============--
new = function(self, o)
o = o or {}
-- Init default params and methods --
o.Trigs = {}
o.CurrVec = math2.vec3:new()
setmetatable(o, {__index = self})
-- This class is a supaTable --
local tbl = table2.supaTable:new(o)
-- Set read-only properties (supaTable) --
tbl:setReadOnly(true, "CurrVec")
tbl:setReadOnly(true, "IsUp")
tbl:setReadOnly(true, "IsLeft")
tbl:setReadOnly(true, "IsDown")
tbl:setReadOnly(true, "IsRight")
tbl:setReadOnly(true, "Trigs")
-- Auto-update movement functionality (supaTable) --
tbl:watchProp(function(t,k,v)
tbl:initKeyPressTrigs()
end, "PlayerId", false)
tbl:watchProp(function(t,k,v)
tbl:initKeyPressTrigs()
end, "KeyUp", false)
tbl:watchProp(function(t,k,v)
tbl:initKeyPressTrigs()
end, "KeyLeft", false)
tbl:watchProp(function(t,k,v)
tbl:initKeyPressTrigs()
end, "KeyDown", false)
tbl:watchProp(function(t,k,v)
tbl:initKeyPressTrigs()
end, "KeyRight", false)
-- Main --
tbl:initMainMovementTrig()
tbl:initKeyPressTrigs()
return tbl
end,
-------------------------
--<< PRIVATE METHODS >>--
-------------------------
initMainMovementTrig = function(self)
local updatePeriod = 1/60
getmetatable(self.Trigs).__index.Main = CreateTrigger() --Set read-only prop (supaTable)
DisableTrigger(self.Trigs.Main)
TriggerRegisterTimerEventPeriodic(self.Trigs.Main, updatePeriod)
TriggerAddAction(self.Trigs.Main, function()
self:move(updatePeriod)
end)
end,
initKeyPressTrigs = function(self)
if (self.PlayerId == nil) then return end
-- Used to set read-only properties (supaTable) --
local tbl = getmetatable(self).__index
local tblTrigs = getmetatable(self.Trigs).__index
-- For each event type --
local inputs = {
"Up",
"Left",
"Down",
"Right"
}
for k, v in pairs(inputs) do
-- Cleanup old KeyPress trig --
if ((self.Trigs[v .. "Press"] ~= nil)) then
DestroyTrigger(self.Trigs[v .. "Press"])
end
-- Cleanup old KeyRelease trig --
if (self.Trigs[v .. "Release"] ~= nil) then
DestroyTrigger(self.Trigs[v .. "Release"])
end
if (GetPlayerSlotState(Player(self.PlayerId)) == PLAYER_SLOT_STATE_PLAYING) then
-- New KeyPress trig --
tblTrigs[v .. "Press"] = CreateTrigger()
BlzTriggerRegisterPlayerKeyEvent(self.Trigs[v .. "Press"], Player(self.PlayerId), self["Key" .. v], 0, true)
TriggerAddAction(self.Trigs[v .. "Press"], function()
-- Update movement calculations --
if (self["Is" .. v] == true) then return end
tbl["Is" .. v] = true
self:updateMovementVector()
-- Only turn on trig while moving --
local delayCompensationFactor = 0.04
if (self.CurrVec:length() > 0) then
self:move(delayCompensationFactor) --delay fix
EnableTrigger(self.Trigs.Main)
end
end)
-- New KeyRelease trig --
tblTrigs[v .. "Release"] = CreateTrigger()
BlzTriggerRegisterPlayerKeyEvent(self.Trigs[v .. "Release"], Player(self.PlayerId), self["Key" .. v], 0, false)
TriggerAddAction(self.Trigs[v .. "Release"], function()
-- Update movement calculations --
tbl["Is" .. v] = false
self:updateMovementVector()
-- Turn off trig while not moving --
if (self.CurrVec:length() == 0) then
DisableTrigger(self.Trigs.Main)
end
end)
end
end
end,
updateMovementVector = function(self)
local x = 0
if (self.IsLeft) then x = x - 1 end
if (self.IsRight) then x = x + 1 end
local y = 0
if (self.IsDown) then y = y - 1 end
if (self.IsUp) then y = y + 1 end
-- Set read-only props (supaTable) --
local tbl = getmetatable(self).__index
local tblCurrVec = getmetatable(self.CurrVec).__index
tblCurrVec.x = x
tblCurrVec.y = y
tblCurrVec:normalize()
end,
move = function(self, scalar)
if (self.Unit == nil) then return end
if (self.Enabled ~= true) then return end
scalar = scalar or 1
local newX = GetUnitX(self.Unit) + (self.Speed * self.CurrVec.x * scalar)
local newY = GetUnitY(self.Unit) + (self.Speed * self.CurrVec.y * scalar)
if (IsTerrainPathable(newX, newY, PATHING_TYPE_ANY)) then
SetUnitPosition(self.Unit, newX, newY)
end
end,
},{
--===========--
-- Metatable --
--===========--
})
--==============--
return libUnitMove
--==============--
|
return {
no_consumer = true,
fields = {
client_id = { type = "string", required = true },
client_secret = { type = "string", required = true },
discovery = { type = "string", required = true, default = "https://.well-known/openid-configuration" },
introspection_endpoint = { type = "string", required = false },
timeout = { type = "number", required = false },
introspection_endpoint_auth_method = { type = "string", required = false },
bearer_only = { type = "string", required = true, default = "no" },
realm = { type = "string", required = true, default = "kong" },
redirect_uri_path = { type = "string" },
scope = { type = "string", required = true, default = "openid" },
response_type = { type = "string", required = true, default = "code" },
ssl_verify = { type = "string", required = true, default = "no" },
token_endpoint_auth_method = { type = "string", required = true, default = "client_secret_post" },
session_secret = { type = "string", required = false },
recovery_page_path = { type = "string" },
logout_path = { type = "string", required = false, default = '/logout' },
redirect_after_logout_uri = { type = "string", required = false, default = '/' },
filters = { type = "string" },
verify_only = { type = "string", required = true, default = "no"},
}
}
|
local stringutils = {}
--[[
@param str 待分割字符串
@param delimiter 分割字符
--]]
function stringutils.split(str,delimiter)
if str == nil or str == "" or delimiter == nil then
return nil
end
local result = {}
for match in (str .. delimiter):gmatch("(.-)" .. delimiter) do
table.insert(result,match)
end
return result
end
--[[
去除字符串空格
--]]
function stringutils.trim(str)
if str == nil or tostring(str) == "userdata: NULL" then
return ""
end
local result,count = string.gsub(str,"%s","")
return result
end
return stringutils
|
--######################################################### Camera def
--#{
--/** \brief Creates a basic thirdperson camera.
--
--\param name char Name of the new camera [optional]
--\return chilCameraObject newCamera Returns a camera object
--\ingroup Lua_Camera
-- -- */
--void chilCreateThirdPersonCamera(char name) {}
--#}
function chilCreateThirdPersonCamera(name)
local newCamera = {}
newCamera.alpha = 0; -- camera orientation on the x axis
newCamera.azimuth = 0; -- camera orientation on the y axis
newCamera.tsi = 0; -- something
newCamera.x = 0.0; -- x pos.
newCamera.y = 0.0; -- y pos.
newCamera.z = 10.0; -- z pos.
newCamera.fov = 40.0;
newCamera.left = false;
newCamera.right = false;
newCamera.up = false;
newCamera.down = false;
newCamera.forward = false;
newCamera.backward = false;
newCamera.lock1open = false;
newCamera.lock2open = false;
newCamera.zoomin = false;
newCamera.zoomout = false;
newCamera.zoomspeed = 2.0;
newCamera.movespeed = 1.0*0.0166666;
newCamera.orthoWidth = 50.0;
newCamera.type = "Perspective"
newCamera.xmax = 10000;
newCamera.xmin =-10000;
newCamera.ymax = 10000;
newCamera.ymin =-10000;
newCamera.zmax = 10000;
newCamera.zmin =-10000;
newCamera.sceneScope,newCamera.displayerScope = chiGetScene();
newCamera.callbackReference = newCamera;
--===================================================== Update function
newCamera.Update = function(this)
currentScene,currentDisplayer = chiGetScene();
chiBindScene(this.sceneScope,this.displayerScope);
if (this.type=="Orthographic") then
chiGraphicsCameraType(2);
else
chiGraphicsCameraType(1);
end
chiGraphicsOrientCamera(0,this.alpha,this.azimuth,this.tsi);
chiGraphicsPositionCamera(this.x,this.y,this.z);
chiBindScene(currentScene,currentDisplayer);
end
--===================================================== Callback function
newCamera.callbackFunction = function(this)
--print(chi_frameRate);
if (WM_KEYDN.occured and (WM_KEYDN.iPar4 == this.sceneScope)) then
--print(string.format("WM_KEYDN %6.4f",chi_programTime));
if (WM_KEYDN.iPar0 == 65) then this.left = true; end
if (WM_KEYDN.iPar0 == 68) then this.right = true; end
if (WM_KEYDN.iPar0 == 87) then this.forward = true; end
if (WM_KEYDN.iPar0 == 83) then this.backward = true; end
if (WM_KEYDN.iPar0 == 69) then this.up = true; end
if (WM_KEYDN.iPar0 == 81) then this.down = true; end
end
if (WM_MOUSEMOVE.occured) then
--print(string.format("Object selected: %d",WM_MOUSEMOVE.iPar5));
end
if (WM_KEYUP.occured or WM_MOUSELEAVE.occured) then
--print(string.format("WM_KEYUP %6.4f",chi_programTime));
if (WM_KEYUP.iPar0 == 65) then this.left = false; end
if (WM_KEYUP.iPar0 == 68) then this.right = false; end
if (WM_KEYUP.iPar0 == 87) then this.forward = false; end
if (WM_KEYUP.iPar0 == 83) then this.backward = false; end
if (WM_KEYUP.iPar0 == 69) then this.up = false; end
if (WM_KEYUP.iPar0 == 81) then this.down = false; end
if (WM_MOUSELEAVE.occured) then
this.left = false;
this.right = false;
this.forward = false;
this.backward = false;
this.up = false;
this.down = false;
this.lock2open=false;
end
end
local dx = 0;
local dy = 0;
local dz = 0;
if ((this.left) ) then dx = 0.0 - this.movespeed; end
if ((this.right) ) then dx = 0.0 + this.movespeed; end
if ((this.forward) ) then dy = 0.0 + this.movespeed; end
if ((this.backward)) then dy = 0.0 - this.movespeed; end
--if ((this.up) ) then end
--if ((this.down) ) then end
--
this.x = this.x + dx;
this.y = this.y + dy;
this.z = this.z + dz;
if (this.x>this.xmax) then this.x = this.x + dx; end
if (this.x<this.xmin) then this.x = this.x + dx; end
if (this.y>this.ymax) then this.y = this.y + dy; end
if (this.y<this.ymin) then this.y = this.y + dy; end
if (this.z>this.zmax) then this.z = this.z + dz; end
if (this.z<this.zmin) then this.z = this.z + dz; end
this.Update(this);
end
newCamera.CameraControl = newCamera.callbackFunction
print("Third person camera made")
return newCamera;
end
|
return Def.ActorFrame{
InitCommand=function(self) self:Center() end,
LoadActor("usbicon.png")..{
InitCommand=function(self) self:shadowlength(1) end,
OnCommand=function(self) self:zoom(0.6):glow(1,1,1,1):glowshift():diffusealpha(0):sleep(1):decelerate(2):diffusealpha(1):sleep(6):linear(0.75):diffusealpha(0) end,
},
LoadFont("Common Normal")..{
Text=ScreenString("Top"),
InitCommand=function(self) self:shadowlength(1):y(-60):diffusealpha(0) end,
OnCommand=function(self) self:sleep(2.0):decelerate(1):diffusealpha(1):sleep(6):linear(0.75):diffusealpha(0) end,
},
LoadFont("Common Normal")..{
Text=ScreenString("Bottom"),
InitCommand=function(self) self:shadowlength(1):y(60):diffusealpha(0) end,
OnCommand=function(self) self:sleep(3.0):decelerate(1):diffusealpha(1):sleep(5):linear(0.75):diffusealpha(0) end,
}
}
|
--------------------------------------------------------------------------------
-- Generic relay with configureable parameters
--------------------------------------------------------------------------------
-- Copyright (C) 2013-2018 Metrostroi Team & FoxWorks Aerospace s.r.o.
-- Contains proprietary code. See license.txt for additional information.
--------------------------------------------------------------------------------
Metrostroi.DefineSystem("Relay")
local relay_types = {
["PK-162"] = {
pneumatic = true,
contactor = true,
},
["Switch"] = {
contactor = true,
},
["GV_10ZH"] = {
contactor = true,
normally_closed = true,
},
["VA21-29"] = {
contactor = true,
normally_closed = true,
bass = true,
},
["AVU-045"] = {
bass = true,
},
["Switch"] = {
close_time = 0,
open_time = 0,
},
["ARS"] = {
close_time = 0,
open_time = 0,
}
}
function TRAIN_SYSTEM:Initialize(parameters,extra_parameters)
----------------------------------------------------------------------------
-- Initialize parameters
if not parameters then parameters = {} end
if type(parameters) ~= "table" then
relay_type = parameters
if relay_types[relay_type] then
parameters = relay_types[relay_type]
else
--print("[sys_relay.lua] Unknown relay type: "..parameters)
parameters = {}
end
parameters.relay_type = relay_type
end
-- Create new table
local old_param = parameters
parameters = {} for k,v in pairs(old_param) do parameters[k] = v end
-- Add extra parameters
if type(extra_parameters) == "table" then
for k,v in pairs(extra_parameters) do
parameters[k] = v
end
end
-- Contactors have different failure modes
parameters.contactor = parameters.contactor or false
-- Should the relay be initialized in 'closed' state
parameters.normally_closed = parameters.normally_closed or false
-- Time in which relay will close (seconds)
parameters.close_time = parameters.close_time or 0.050
-- Time in which relay will open (seconds)
parameters.open_time = parameters.open_time or 0.050
-- Is relay latched (stays in its position even without voltage)
parameters.latched = parameters.latched or false
-- Should relay be spring-returned to initial position
parameters.returns = parameters.returns or (not parameters.latched)
-- Trigger level for the relay
parameters.trigger_level = parameters.trigger_level or 0.5
for k,v in pairs(parameters) do
self[k] = v
end
----------------------------------------------------------------------------
-- Relay parameters
if self.close_time == 0 then
FailSim.AddParameter(self,"CloseTime", { value = parameters.close_time})
else
FailSim.AddParameter(self,"CloseTime", { value = parameters.close_time, precision = self.contactor and 0.35 or 0.10, min = 0.010, varies = true })
end
if self.open_time == 0 then
FailSim.AddParameter(self,"OpenTime", { value = parameters.open_time})
else
FailSim.AddParameter(self,"OpenTime", { value = parameters.open_time, precision = self.contactor and 0.35 or 0.10, min = 0.010, varies = true })
end
-- Did relay short-circuit?
FailSim.AddParameter(self,"ShortCircuit", { value = 0.000, precision = 0.00 })
-- Was there a spurious trip?
FailSim.AddParameter(self,"SpuriousTrip", { value = 0.000, precision = 0.00 })
-- Calculate failure parameters
local MTBF = parameters.MTBF or 1000000 -- cycles, mean time between failures
local MFR = 1/MTBF -- cycles^-1, total failure rate
local openWeight,closeWeight
-- FIXME
openWeight = self.open_weight or 0.25
closeWeight = self.close_weight or 0.25
--[[if self.Contactor then
openWeight = 0.25
closeWeight = 0.25
elseif self.NormallyOpen then
openWeight = 0.4
closeWeight = 0.1
else
openWeight = 0.1
closeWeight = 0.4
end]]--
-- Add failure points
FailSim.AddFailurePoint(self, "CloseTime", "Mechanical problem (close time not nominal)",
{ type = "precision", value = 0.5, mfr = MFR*0.65*openWeight, recurring = true } )
FailSim.AddFailurePoint(self, "OpenTime", "Mechanical problem (open time not nominal)",
{ type = "precision", value = 0.5, mfr = MFR*0.65*closeWeight , recurring = true } )
FailSim.AddFailurePoint(self, "CloseTime", "Stuck closed",
{ type = "value", value = 1e9, mfr = MFR*0.65*openWeight, dmtbf = 0.2 } )
FailSim.AddFailurePoint(self, "OpenTime", "Stuck open",
{ type = "value", value = 1e9, mfr = MFR*0.65*closeWeight , dmtbf = 0.4 } )
FailSim.AddFailurePoint(self, "SpuriousTrip", "Spurious trip",
{ type = "on", mfr = MFR*0.20, dmtbf = 0.4 } )
--FailSim.AddFailurePoint(self, "ShortCircuit", "Short-circuit",
--{ type = "on", mfr = MFR*0.15, dmtbf = 0.2 } )
----------------------------------------------------------------------------
-- Initial relay state
if self.normally_closed then
self.TargetValue = 1.0
self.Value = 1.0
else
self.TargetValue = self.defaultvalue or 0.0
self.Value = self.defaultvalue or 0.0
end
-- Time when relay should change its value
self.Time = 0
self.ChangeTime = nil
self.Blocked = 0
-- This increases precision at cost of perfomance
self.SubIterations = parameters.iterations or 1--relay
end
function TRAIN_SYSTEM:Inputs()
return { "Open","Close","+","-","Set","Toggle","Block","OpenBypass","Check","OpenTime","CloseTime"}
end
function TRAIN_SYSTEM:Outputs()
return { "Value" , "Blocked","TargetValue"}
end
function TRAIN_SYSTEM:TriggerInput(name,value)
-- Boolean values accepted
if type(value) == "boolean" then value = value and 1 or 0 end
if name == "OpenTime" then
self.open_time = value
FailSim.AddParameter(self,"OpenTime", { value = self.open_time})
end
if name == "CloseTime" then
self.close_time = value
FailSim.AddParameter(self,"CloseTime", { value = self.close_time})
end
if name == "Reset" then
if self.normally_closed then
self:TriggerInput("Set",1)
else
self:TriggerInput("Set",self.defaultvalue or 0.0)
end
end
--print(name)
if name == "Check" then
if value < 0 and self.Value == 1 then
self:TriggerInput("Set",0)
--self:TriggerInput("Set",0)
self.Train:PlayOnce("av_off","cabin",0.7,70)
end
return
end
if value == -1 and self.relay_type == "VA21-29" then
self:TriggerInput("Set",0)
return
end
if name == "OpenBypass" then
if (not self.ChangeTime) and (self.TargetValue ~= 0.0) then
self.ChangeTime = self.Time + FailSim.Value(self,"OpenTime")
end
self.TargetValue = 0.0
if self.ChangeTime==self.Time and self.Train.DeltaTime then self:Think(self.Train.DeltaTime) end
return
end
if self.Blocked > 0 and name ~= "Block" and (name == "Close" and self.relay_type == "PK-162" or self.relay_type ~= "PK-162") then return end
-- Open/close coils of the relay
if (name == "Block") then
self.Blocked = value
elseif (name == "Close") and (value > self.trigger_level) and (self.Value ~= 1.0 or self.TargetValue ~= 1.0) then --(self.TargetValue ~= 1.0 and self.rpb))
if self.pneumatic and self.Train.Pneumatic.TrainLinePressure < 3 then return end
if (not self.ChangeTime) or (self.TargetValue ~= 1.0) then
self.ChangeTime = self.Time + FailSim.Value(self,"CloseTime")
--if self.rvt then print(FailSim.Value(self,"CloseTime")) end
end
--if self.rpb and
if self.Value == 1.0 then self.ChangeTime = nil end
self.TargetValue = 1.0
if self.ChangeTime==self.Time and self.Train.DeltaTime then self:Think(self.Train.DeltaTime) end
elseif (name == "Open") and (value > self.trigger_level) and (self.Value ~= 0.0 or self.TargetValue ~= 0.0) then
if (not self.ChangeTime) or (self.TargetValue ~= 0.0) then
self.ChangeTime = self.Time + FailSim.Value(self,"OpenTime")
end
self.TargetValue = 0.0
if self.ChangeTime==self.Time and self.Train.DeltaTime then self:Think(self.Train.DeltaTime) end
elseif name == "NoOpenTime" and value > 0 then
self.ChangeTime = self.Time
elseif (name == "+") and (self.Value < (self.maxvalue or self.three_position and 2 or 1)) and value > 0 then
self.ChangeTime = self.Time + FailSim.Value(self,"CloseTime")
self.TargetValue = math.min(self.maxvalue or self.three_position and 2 or 1,self.Value+1)
if self.ChangeTime==self.Time and self.Train.DeltaTime then self:Think(self.Train.DeltaTime) end
elseif (name == "-") and (self.Value > 0) and value > 0 then
self.ChangeTime = self.Time + FailSim.Value(self,"OpenTime")
self.TargetValue = math.max(0.0,self.Value-1)
if self.ChangeTime==self.Time and self.Train.DeltaTime then self:Think(self.Train.DeltaTime) end
elseif name == "Set" then
if self.pneumatic and value > 0 and self.Train.Pneumatic.TrainLinePressure < 3 then return end
if self.maxvalue then
if not self.ChangeTime then
self.ChangeTime = self.Time + FailSim.Value(self,"OpenTime")
end
self.TargetValue = math.max(0.0,math.min(self.maxvalue,math.floor(value)))
if self.ChangeTime==self.Time and self.Train.DeltaTime then self:Think(self.Train.DeltaTime) end
elseif self.three_position then
if not self.ChangeTime then
self.ChangeTime = self.Time + FailSim.Value(self,"OpenTime")
end
self.TargetValue = math.max(0.0,math.min(2.0,math.floor(value)))
if self.ChangeTime==self.Time and self.Train.DeltaTime then self:Think(self.Train.DeltaTime) end
else
if value > self.trigger_level
then self:TriggerInput("Close",self.trigger_level+1)
else self:TriggerInput("Open",self.trigger_level+1)
end
end
elseif (name == "Toggle") and (value > 0.5) then
if self.maxvalue then
self:TriggerInput("Set",self.Value > self.maxvalue-1 and 0 or self.Value+1)
elseif self.three_position then
self:TriggerInput("Set",self.Value > 1 and 0 or self.Value+1)
else
self:TriggerInput("Set",(1.0 - self.Value)*(self.trigger_level+1))
end
end
end
function TRAIN_SYSTEM:Think(dT)
--print(self.relay_type)
self.Time = self.Time + dT
--if self.relay_type == "VA21-29" then
--if self.Value
--if self.Value == -1 then print(self.Name) end
-- Short-circuited relay
if FailSim.Value(self,"ShortCircuit") > 0.5 then
self.Value = 1.0
return
end
-- Spurious trip
if FailSim.Value(self,"SpuriousTrip") > 0.5 then
self.SpuriousTripTimer = self.Time + (0.5 + 2.5*math.random())
FailSim.ResetParameter(self,"SpuriousTrip",0.0)
FailSim.Age(self,1)
-- Simulate switch right away
self.Value = 1.0 - self.Value
self.TargetValue = self.Value
self.ChangeTime = nil
end
if self.SpuriousTripTimer and (self.Time > self.SpuriousTripTimer) then
self.Value = self.TargetValue
self.SpuriousTripTimer = nil
end
-- Switch relay
if self.ChangeTime and (self.Time > self.ChangeTime) and not self.SpuriousTripTimer then
-- Electropneumatic relays make this sound
if self.bass and self.Value ~= self.TargetValue then
--[[
if self.Value ~= 0.0 and self.maxvalue ~= 2 or self.Value ~= 1.0 and self.maxvalue == 2 then
if self.av3 then self.Train:PlayOnce("vu22b_on","cabin") end
if self.igla then self.Train:PlayOnce("igla_on","cabin") end
if self.button then self.Train:PlayOnce("button_press","cabin",0.51) end
if self.vud then self.Train:PlayOnce("vu22_on","cabin") end
if self.uava then self.Train:PlayOnce("uava_on","cabin") end
if self.pb then self.Train:PlayOnce("switch6","cabin") end
if self.programm then self.Train:PlayOnce("inf_on","cabin") end
if self.programm1 then self.Train:PlayOnce("triple_up-0","cabin") end
if self.programm2 then self.Train:PlayOnce("triple_down-0","cabin") end
if self.av then self.Train:PlayOnce("auto_on","cabin") end
if self.mainav then self.Train:PlayOnce("mainauto_on","cabin") end
if self.krishka then self.Train:PlayOnce("kr_close","cabin") end
if self.paketnik then self.Train:PlayOnce("pak_on","cabin") end
if self.switch then self.Train:PlayOnce("switch_on","cabin") end
if self.rcr then self.Train:PlayOnce("rcr_on","cabin") end
end
if self.Value == 0.0 and self.maxvalue ~= 2 or self.Value == 1.0 and self.maxvalue == 2 then
if self.av3 then self.Train:PlayOnce("vu22b_off","cabin") end
if self.igla then self.Train:PlayOnce("igla_off","cabin") end
if self.button then self.Train:PlayOnce("button_release","cabin",0.56) end
if self.vud then self.Train:PlayOnce("vu22_off","cabin") end
if self.uava then self.Train:PlayOnce("uava_off","cabin") end
if self.pb then self.Train:PlayOnce("switch6_off","cabin") end
if self.programm then self.Train:PlayOnce("inf_off","cabin") end
if self.programm1 then self.Train:PlayOnce("triple_0-up","cabin") end
if self.programm2 then self.Train:PlayOnce("triple_0-down","cabin") end
if self.av then self.Train:PlayOnce("auto_off","cabin") end
if self.mainav then self.Train:PlayOnce("mainauto_off","cabin") end
if self.krishka then self.Train:PlayOnce("kr_open","cabin") end
if self.paketnik then self.Train:PlayOnce("pak_off","cabin") end
if self.switch then self.Train:PlayOnce("switch_off","cabin") end
if self.rcr then self.Train:PlayOnce("rcr_off","cabin") end
end
]]
if self.bass_separate then
if self.TargetValue > 0 then
self.Train:PlayOnce(self.Name.."_on","bass",1)
else
self.Train:PlayOnce(self.Name.."_off","bass",1)
end
else
self.Train:PlayOnce(self.Name,"bass",self.TargetValue)
end
end
self.Value = self.TargetValue
self.ChangeTime = nil
-- Age relay a little
FailSim.Age(self,1)
end
end
|
-- handler.lua
-- https://docs.konghq.com/gateway-oss/2.4.x/plugin-development/custom-logic/
local BasePlugin = require "kong.plugins.base_plugin"
local redis = require "resty.redis"
local kong = kong
local function retrieve_credentials()
-- get val from redis
local red = redis:new()
red:set_timeouts(1000, 1000, 1000) -- 1 sec
local ok, err = red:connect("demo-redis", 6379) -- redis host address in docker network
if not ok then
kong.log.inspect("----- my-custom-plugin retrieve_credentials error -----")
error(err)
end
local redis_val = red:hget("ht", "field")
kong.log.inspect(redis_val)
return redis_val
end
local CustomHandler = BasePlugin:extend()
CustomHandler.VERSION = "1.0.0"
-- https://docs.konghq.com/gateway-oss/2.4.x/plugin-development/custom-logic/#plugins-execution-order
CustomHandler.PRIORITY = 10
function CustomHandler:new()
CustomHandler.super.new(self, "my-custom-plugin")
kong.log.inspect("----- my-custom-plugin new -----")
end
function CustomHandler:access(config)
-- Executed for every request from a client and before it is being proxied to the upstream service.
kong.log.inspect("----- my-custom-plugin access -----")
CustomHandler.super.access(self)
kong.log.inspect(config)
local cache_name = kong.request.get_headers()["x-cache-auth"]
local cache_delete = kong.request.get_headers()["x-del-auth"]
-- https://docs.konghq.com/enterprise/2.3.x/plugin-development/entities-cache/
if cache_delete then
-- delete cache:
-- Lua memory cache - local to an Nginx worker process
-- Shared memory cache (SHM) - local to an Nginx node
kong.cache:invalidate(cache_delete)
return kong.response.exit(200, {message = "Auth deleted"})
end
if cache_name then
-- get and save cache from redis, then put it to upstream request
kong.log.inspect("----- my-custom-plugin access cache-----", cache_name)
-- !!! Retrieves the value from the cache
local credential, err = kong.cache:get(cache_name, nil, retrieve_credentials, cache_name)
if err then
kong.log.err(err)
return kong.response.exit(500, {message = "Unexpected error"})
end
if not credential then
return kong.response.exit(401, {message = "Invalid credentials"})
end
kong.log.inspect(credential)
kong.service.request.set_header("X-API-Key", credential)
end
kong.log.inspect("----- my-custom-plugin access end-----")
end
return CustomHandler
|
require 'laia.ClassWithOptions'
require 'laia.SignalHandler'
require 'warp_ctc'
local xlua = wrequire 'xlua'
local CTCTrainer, Parent = torch.class('laia.CTCTrainer',
'laia.ClassWithOptions')
-- Basic usage example:
-- trainer = CTCTrainer(model, train_batcher, valid_batcher, optim.rmsprop)
-- trainer:start()
-- while true do
-- train_epoch_info = trainer:trainEpoch(rmsprop_opts)
-- valid_epoch_info = trainer:validEpoch()
-- print(train_epoch_info.loss, valid_epoch_info.loss)
-- end
local function check_nan(x, m)
return x:ne(x):sum()
end
local function check_inf(x, m)
return x:ge(math.huge):sum() + x:le(-math.huge):sum()
end
function CTCTrainer:__init(model, train_batcher, valid_batcher, optimizer)
Parent.__init(self, {
batch_size = 16,
use_distortions = false,
use_distortions_after = 0,
cer_trim = 0,
snapshot_interval = 0,
display_progress_bar = false,
num_samples_epoch = 0,
grad_clip = 0,
check_nan = false,
check_inf = false,
normalize_loss = true,
shuffle_valid = false,
batchChunkSize = 0,
})
self._model = model
self._train_batcher = train_batcher
self._valid_batcher = valid_batcher
self._optimizer = optimizer
-- Use :start() to initialize the trainer
self._initialized = false
end
function CTCTrainer:setModel(model)
self._model = model
self._initialized = false
return self
end
function CTCTrainer:setTrainBatcher(batcher)
self._train_batcher = batcher
self._initialized = false
return self
end
function CTCTrainer:setValidBatcher(batcher)
self._valid_batcher = batcher
self._initialized = false
return self
end
function CTCTrainer:setOptimizer(optimizer)
self._optimizer = optimizer
self._initialized = false
return self
end
function CTCTrainer:setDistorter(distorter)
self._distorter = distorter
self._initialized = false
if self._distorter and self._opt.use_distortions then
laia.log.info('CTCTrainer uses the distorter:\n' ..
self._distorter:__tostring__())
end
return self
end
function CTCTrainer:setAdversarialRegularizer(regularizer)
self._adversarial_regularizer = regularizer
self._initialized = false
if self._adversarial_regularizer then
laia.log.info('CTCTrainer uses the adversarial regularizer:\n' ..
self._adversarial_regularizer:__tostring__())
end
return self
end
function CTCTrainer:setWeightRegularizer(regularizer)
self._weight_regularizer = regularizer
self._initialized = false
if self._weight_regularizer then
laia.log.info('CTCTrainer uses the weight regularizer:\n' ..
self._weight_regularizer:__tostring__())
end
return self
end
function CTCTrainer:registerOptions(parser, advanced)
advanced = advanced or false
parser:option(
'--batch_size -b', 'Batch size', self._opt.batch_size, laia.toint)
:gt(0)
:bind(self._opt, 'batch_size')
:advanced(advanced)
parser:option(
'--use_distortions',
'If true, augment the training set using random distortions.',
self._opt.use_distortions, laia.toboolean)
:bind(self._opt, 'use_distortions')
:advanced(advanced)
parser:option(
'--use_distortions_after',
'Start using distortions after this epoch (set this value to 0 to use ' ..
'distortions from the beginning).',
self._opt.use_distortions_after, laia.toint)
:bind(self._opt, 'use_distortions_after')
:gt(0)
:advanced(advanced)
parser:option(
'--cer_trim', 'For computing CER, removes leading, trailing and ' ..
'repetitions of given symbol number (i.e. space).',
self._opt.cer_trim, laia.toint)
:argname('<sym>')
:ge(0)
:bind(self._opt, 'cer_trim')
:advanced(advanced)
--[[
parser:option(
'--snapshot_interval',
'If n>0, create a snapshot of the model every n batches.',
self._opt.snapshot_interval, laia.toint)
:argname('<n>')
:ge(0)
:bind(self._opt, 'snapshot_interval')
:advanced(advanced)
--]]
parser:option(
'--grad_clip', 'If c>0, clip gradients to the range [-c,+c].',
self._opt.grad_clip, tonumber)
:argname('<c>')
:ge(0)
:bind(self._opt, 'grad_clip')
:advanced(advanced)
parser:option(
'--display_progress_bar',
'Display a progress bar on the terminal showing the status ' ..
'of the training and validation epoch. Note: if you ' ..
'redirect the output to a file, the progress bar is not ' ..
'displayed.', self._opt.display_progress_bar, laia.toboolean)
:bind(self._opt, 'display_progress_bar')
:advanced(advanced)
parser:option(
'--num_samples_epoch',
'Number of training samples to process in each epoch; ' ..
'If n=0, this value is equal to the number of samples in the training '..
'partition.', self._opt.num_samples_epoch, laia.toint)
:argname('<n>')
:ge(0)
:bind(self._opt, 'num_samples_epoch')
:advanced(advanced)
parser:option(
'--check_nan', 'If true, check for NaN values during training.',
self._opt.check_nan, laia.toboolean)
:bind(self._opt, 'check_nan')
:advanced(advanced)
parser:option(
'--check_inf', 'If true, check for infinity values during training.',
self._opt.check_inf, laia.toboolean)
:bind(self._opt, 'check_inf')
:advanced(advanced)
parser:option(
'--normalize_loss', 'If true, normalize the loss among the batch size and the length of the samples.',
self._opt.normalize_loss, laia.toboolean)
:bind(self._opt, 'normalize_loss')
:advanced(advanced)
parser:option(
'--shuffle_valid', 'If true, shuffle the validation data on each epoch.',
self._opt.shuffle_valid, laia.toboolean)
:bind(self._opt, 'shuffle_valid')
:advanced(advanced)
parser:option(
'--batch_chunk_size', 'If >0, split the batch in chunks of this size (in' ..
' MB). Useful to perform constant batch size updates with scarce memory.',
self._opt.batchChunkSize, laia.toint)
:bind(self._opt, 'batchChunkSize')
:advanced(advanced)
end
function CTCTrainer:checkOptions()
assert(self._opt.batch_size > 0 and laia.isint(self._opt.batch_size),
('Batch size must be positive integer (value = %s)'):format(
self._opt.batch_size))
assert(laia.isint(self._opt.cer_trim),
('CER trim symbol must be an integer (value = %s)'):format(
self._opt.cer_trim))
assert(laia.isint(self._opt.snapshot_interval),
('Snapshot interval must be an integer (value = %s)'):format(
self._opt.snapshot_interval))
assert(type(self._opt.grad_clip) == 'number',
('Gradient clip value must be a number (value = %s)'):format(
self._opt.grad_clip))
assert(type(self._opt.display_progress_bar) == 'boolean',
('Display progress bar must be a boolean (value = %s)'):format(
self._opt.display_progress_bar))
assert(type(self._opt.check_nan) == 'boolean',
('Expected a boolean value (got value = %s)')
:format(self._opt.check_nan))
assert(type(self._opt.check_inf) == 'boolean',
('Expected a boolean value (got value = %s)')
:format(self._opt.check_inf))
-- Log some warnings
if self._opt.display_progress_bar and not xlua then
laia.log.warn('Progress bar not displayed, xlua was not found')
end
if self._opt.display_progress_bar and not laia.stdout_isatty then
laia.log.warn('Progress bar not displayed, stdout is redirected')
end
end
function CTCTrainer:start()
assert(self._model ~= nil)
assert(self._train_batcher ~= nil and self._train_batcher:numSamples() > 0)
assert(self._optimizer ~= nil)
assert(self._distorter or not self._opt.use_distortions,
'No distorter passed to the CTCTrainer, but --use_distortions=true')
assert(self._train_batcher:symCount()[0] == 0,
'CTC non-character symbol found in transcripts')
-- Flatten the model parameters into a single big chunk of memory.
self._parameters, self._gradParameters = self._model:getParameters()
-- Define some buffers that will be used for different batches to avoid
-- multiple data allocation/dellocation.
self._gradOutput = torch.Tensor():type(self._model:type())
self._tr_batch_img = torch.Tensor():type(self._train_batcher:cacheType())
self._va_batch_img =
self._valid_batcher and torch.Tensor():type(self._valid_batcher:cacheType())
-- Total number of precessed training and validation batches, used to update
-- the monitor snapshot only at certain times.
self._num_processed_train_batches = 0
self._num_processed_valid_batches = 0
-- Compute the number of training samples to process in each epoch.
-- Note: This number may be different from the total number of training
-- samples, or the value of --num_samples_epoch, because of the batch_size.
if self._opt.num_samples_epoch > 0 then
self._train_num_samples = self._opt.batch_size *
math.ceil(self._opt.num_samples_epoch / self._opt.batch_size)
else
self._train_num_samples = self._opt.batch_size *
math.ceil(self._train_batcher:numSamples() / self._opt.batch_size)
end
-- Compute the number of validation samples to process in each epoch.
-- See Note before.
self._valid_num_samples = self._valid_batcher and (self._opt.batch_size *
math.ceil(self._valid_batcher:numSamples() / self._opt.batch_size))
self._currEpoch = 0
self._initialized = true
end
function CTCTrainer:trainEpoch(optimizer_params, batcher_reset_params)
assert(self._initialized, 'CTCTrainer must be initialized with :start()')
self._currEpoch = self._currEpoch + 1
-- Reset batcher with the given parameters
self._train_batcher:epochReset(batcher_reset_params)
-- Useful information for monitoring the performance on trainining data
local epoch_info = {
loss = 0,
num_frames = 0,
posteriors = {},
num_ins_ops = {},
num_del_ops = {},
num_sub_ops = {},
hyp_trim = {},
ref_trim = {},
time_start = os.time(),
time_end = nil,
numChunks = {},
numChunkSamples = {},
}
for b=1,self._train_num_samples,self._opt.batch_size do
-- If exit signal was captured, terminate
if laia.SignalHandler.ExitRequested() then return nil end
-- Load batch from batcher
local batch_img, batch_gt, batch_sizes = self._train_batcher:next(
self._opt.batch_size, self._tr_batch_img)
-- Ensure that batch is in the same device (GPU vs CPU) as the model
batch_img = batch_img:type(self._model:type())
-- Apply distortions, if a distorter was given
if self._distorter and self._opt.use_distortions and
self._currEpoch > self._opt.use_distortions_after then
if b == 1 then
laia.log.debug('Applying distortions on the training data (this ' ..
'message only shown for the first batch on each epoch).')
end
batch_img = self._distorter:distort(batch_img)
end
-- Run optimizer on the batch
self._optimizer(
function(_)
local batch_costs = self:_trainBatch(batch_img, batch_gt)
CTCTrainer._updateCosts(epoch_info, batch_costs)
return batch_costs.loss, self._gradParameters
end, self._parameters, optimizer_params)
-- Show progress bar only if running on a tty
if xlua and laia.stdout_isatty and self._opt.display_progress_bar then
xlua.progress(b + self._opt.batch_size - 1, self._train_num_samples)
end
-- Update number of processed batches
self._num_processed_train_batches = self._num_processed_train_batches + 1
end
epoch_info.time_end = os.time()
return epoch_info
end
function CTCTrainer:validEpoch(batcher_reset_params)
assert(self._initialized, 'CTCTrainer must be initialized with :start()')
-- Reset batcher with the given parameters
self._valid_batcher:epochReset(batcher_reset_params)
-- Useful information for monitoring the performance on validation data
local epoch_info = {
loss = 0,
num_frames = 0,
posteriors = {},
num_ins_ops = {},
num_del_ops = {},
num_sub_ops = {},
hyp_trim = {},
ref_trim = {},
time_start = os.time(),
time_end = nil,
numChunks = {},
numChunkSamples = {},
}
for b=1,self._valid_num_samples,self._opt.batch_size do
-- If exit signal was captured, terminate
if laia.SignalHandler.ExitRequested() then return nil end
-- Load batch from batcher
local batch_img, batch_gt, batch_sizes = self._valid_batcher:next(
self._opt.batch_size, self._va_batch_img)
-- Ensure that batch is in the same device as the model
batch_img = batch_img:type(self._model:type())
-- Forward pass
local batch_costs = self:_fbPass(batch_img, batch_gt, false)
CTCTrainer._updateCosts(epoch_info, batch_costs)
-- Show progress bar only if running on a tty
if xlua and laia.stdout_isatty and self._opt.display_progress_bar then
xlua.progress(b + self._opt.batch_size - 1, self._valid_num_samples)
end
-- Update number of processed batches
self._num_processed_valid_batches = self._num_processed_valid_batches + 1
end
epoch_info.time_end = os.time()
return epoch_info
end
-- Perform forward/backward on a training batch, and apply the regularizers
-- to obtain the regularized loss function and the gradient of it w.r.t. the
-- model parameters.
-- Note: This updates self._gradParameters directly and returs the different
-- costs on the training batch for monitoring purposes. See the call to
-- optimizer() in trainEpoch() to see how this method is used.
function CTCTrainer:_trainBatch(batch_img, batch_gt)
-- Regular backpropagation pass
local batch_costs = self:_fbPass(batch_img, batch_gt, true)
-- Adversarial samples regularization
if self._adversarial_regularizer then
batch_costs.loss = self._adversarial_regularizer:regularize(
batch_costs.loss, self._model, batch_img,
function(x) return self:_fbPass(x, batch_gt, true).loss end)
end
-- Weight decay regularization
if self._weight_regularizer then
batch_costs.loss = self._weight_regularizer:regularize(
batch_costs.loss, self._model)
end
-- Clip gradients
if self._opt.grad_clip > 0 then
-- Number of clamped gradients, for debugging purposes
local ncg = torch.abs(self._gradParameters):gt(self._opt.grad_clip):sum()
if ncg > 0 then
laia.log.debug(('%d [%.2f%%] gradients clamped to [-%g,%g]'):format(
ncg, 100 * ncg / self._gradParameters:nElement(),
self._opt.grad_clip, self._opt.grad_clip))
self._gradParameters:clamp(-self._opt.grad_clip, self._opt.grad_clip)
end
end
return batch_costs
end
-- Perform forward (and optionally, backprop) pass. This is common
-- code used for both training and evaluation of the model.
function CTCTrainer:_fbPass(batch_img, batch_gt, do_backprop)
do_backprop = do_backprop or false
local gradParamAcc = nil
if do_backprop then
self._model:training()
-- TOOD(jpuigcerver): We should not need this copy, since model:backward()
-- should accumulate the gradients unless model:zeroGradParameters() is
-- called, however this does not seem to work properly.
gradParamAcc = self._gradParameters:clone():zero()
else
self._model:evaluate()
end
self._model:clearState()
local batchSize = batch_img:size(1)
assert(batchSize == #batch_gt,
('The number of transcripts is not equal to the number of images '..
'(expected = %d, actual = %d)'):format(batchSize, #batch_gt))
-- If the batch is too big to fill in memory, split the batch in chunks
-- but perform a single model update (gradients are accumulated)
local numChunks, numChunkSamples = 1, batchSize
local batchSizeMB =
batch_img:nElement() * batch_img:elementSize() / 1048576
local sampleSizeMB =
batch_img[1]:nElement() * batch_img:elementSize() / 1048576
if not self.warnSampleSize and self._opt.batchChunkSize > 0 and
sampleSizeMB > self._opt.batchChunkSize then
laia.log.warn(
('Your maximum batch chunk size is smaller than the size ' ..
'of one sample (%.2fMB vs. %.2fMB). If memory is scarce, Laia ' ..
'might crash soon. This message won\'t be shown again.')
:format(self._opt.batchChunkSize, sampleSizeMB))
self.warnSampleSize = true
end
if self._opt.batchChunkSize > 0 then
numChunks = math.min(math.ceil(batchSizeMB / self._opt.batchChunkSize), batchSize)
numChunkSamples = math.ceil(batchSize / numChunks)
end
local numFrames = 0
local batch_losses = {}
local batch_dc_trim, batch_gt_trim = {}, {}
local batch_num_ins_ops, batch_num_del_ops, batch_num_sub_ops = {}, {}, {}
for chunkStart=1,batchSize,numChunkSamples do
if chunkStart + numChunkSamples - 1 > batchSize then
numChunkSamples = batchSize - chunkStart + 1
end
local chunkImg = batch_img:narrow(1, chunkStart, numChunkSamples)
local chunkGt = table.subrange(batch_gt, chunkStart, chunkStart + numChunkSamples - 1)
-- Forward pass
self._model:forward(chunkImg)
local output = self._model.output
numFrames = numFrames + output:size(1)
-- Check output size
assert(self._train_batcher:numSymbols() == output:size(2),
('Expected model output to have %d dimensions and got %d'):format(
self._train_batcher:numSymbols(), output:size(2)))
-- Check NaNs
if self._opt.check_nan then
local n = check_nan(output)
local p = n / output:nElement() * 100
assert(n == 0, 'Found %d (%.2f%%) NaN values during forward!', n, p)
end
-- Check NaNs
if self._opt.check_inf then
local n = check_inf(output)
local p = n / output:nElement() * 100
assert(n == 0, 'Found %d (%.2f%%) inf values during forward!', n, p)
end
-- Set _gradOutput to have the same size as the output and fill it with zeros
self._gradOutput = self._gradOutput:typeAs(output):resizeAs(output):zero()
-- TODO(jpuigcerver): This assumes that all sequences have the same number
-- of frames, which should not be the case, since padding should be ignored!
local sizes = {}
local seq_len = output:size(1) / chunkImg:size(1)
for i=1,chunkImg:size(1) do table.insert(sizes, seq_len) end
-- Compute loss function and gradients w.r.t. the output
if self._model:type() == 'torch.CudaTensor' then
local chunkLosses = gpu_ctc(output, self._gradOutput, chunkGt, sizes)
table.extend(batch_losses, chunkLosses)
elseif self._model:type() == 'torch.FloatTensor' then
local chunkLosses = cpu_ctc(output, self._gradOutput, chunkGt, sizes)
table.extend(batch_losses, chunkLosses)
else
laia.log.fatal(
('CTC is not implemented for tensors of type %q'):format(output:type()))
end
-- Check NaNs
if self._opt.check_nan then
local n = check_nan(self._gradOutput)
local p = n / self._gradOutput:nElement() * 100
assert(n == 0, 'Found %d (%.2f%%) NaN values during CTC!', n, p)
end
-- Check NaNs
if self._opt.check_inf then
local n = check_inf(self._gradOutput)
local p = n / self._gradOutput:nElement() * 100
assert(n == 0, 'Found %d (%.2f%%) inf values during CTC!', n, p)
end
-- Compute gradients of the loss function w.r.t parameters
if do_backprop then
self._model:zeroGradParameters()
self._model:backward(chunkImg, self._gradOutput)
-- Check NaNs
if self._opt.check_nan then
local n = check_nan(self._gradParameters)
local p = n / self._gradParameters:nElement() * 100
assert(n == 0, 'Found %d (%.2f%%) NaN values during backward!', n, p)
end
-- Check NaNs
if self._opt.check_inf then
local n = check_inf(self._gradParameters)
local p = n / self._gradParameters:nElement() * 100
assert(n == 0, 'Found %d (%.2f%%) inf values during backward!', n, p)
end
gradParamAcc:add(self._gradParameters)
end
-- Perform framewise decoding to estimate CER
local chunkDecode = laia.framewise_decode(chunkImg:size(1), output)
for i=1,#chunkDecode do
local dc_i = chunkDecode[i]
local gt_i = chunkGt[i]
if self._opt.cer_trim > 0 then
dc_i = laia.symbol_trim(dc_i, self._opt.cer_trim)
gt_i = laia.symbol_trim(gt_i, self._opt.cer_trim)
end
local _, edit_ops = laia.levenshtein(gt_i, dc_i)
table.insert(batch_num_ins_ops, edit_ops.ins)
table.insert(batch_num_del_ops, edit_ops.del)
table.insert(batch_num_sub_ops, edit_ops.sub)
table.insert(batch_dc_trim, dc_i)
table.insert(batch_gt_trim, gt_i)
end
end
if do_backprop then
-- Copy accumulated gradients back to
self._gradParameters:copy(gradParamAcc)
-- Make gradients independent of the batch size and sequence length
if self._opt.normalize_loss then
self._gradParameters:div(numFrames)
end
end
-- Return, for each sample in the batch, the total loss (including
-- regularization terms, adversarial, etc), the posterior probability
-- of the reference sequence, number of edit operations of each type, the
-- decoded (hypothesis) sequence and the reference sequence (after triming).
return {
-- Sum individual batch losses
loss = table.reduce(batch_losses, operator.add, 0),
-- Batch Size x Length of samples
num_frames = numFrames,
-- Convert losses to (log-)posteriors, i.e loss = -log p(y|x), per sample!
posteriors = table.map(batch_losses, function(x) return -x end),
-- Number of insertion operations (after trimming), for each sample!
num_ins_ops = batch_num_ins_ops,
-- Number of deletion operations (after trimming), for each sample!
num_del_ops = batch_num_del_ops,
-- Number of subtitution operations (after trimming), for each sample!
num_sub_ops = batch_num_sub_ops,
-- Hypothesis transcript (after trimming), for each sample!
hyp_trim = batch_dc_trim,
-- Reference transcript (after trimming), for each sample!
ref_trim = batch_gt_trim,
--
--
-- These are not costs, but are useful information to monitor.
-- Number of chunks in which the batch was divided
numChunks = {numChunks},
numChunkSamples = {numChunkSamples},
}
end
-- Usage:
-- a = { loss = 5, posteriors = {-0.2} }
-- b = { loss = 2, posteriors = {-0.01, -1.1} }
-- CTCTrainer._updateCosts(a, b)
-- print(a)
-- { loss = 7, posteriors = {-0.2, -0.01, -1.1} }
function CTCTrainer._updateCosts(dst, src)
for k,v in pairs(src) do
if type(v) == 'number' then
assert(type(dst[k]) == 'number')
dst[k] = dst[k] + v
elseif type(v) == 'table' then
assert(type(dst[k]) == 'table')
table.foreach(v, function(i, x) table.insert(dst[k], x) end)
end
end
end
-- Usage:
-- a = { loss = 5, posteriors = {-0.2, -0.5} }
-- CTCTrainer._resetCosts(a)
-- print(a)
-- { loss = 0, posteriors = { } }
function CTCTrainer._resetCosts(dst)
for k,v in pairs(dst) do
if type(v) == 'number' then
dst[k] = 0
elseif type(v) == 'table' then
dst[k] = {}
end
end
end
return CTCTrainer
|
return {
{
name = "2018-1219-151200_init_routebyselector",
up = [[
CREATE TABLE IF NOT EXISTS route_by_selector(
id uuid,
selector_name text UNIQUE,
service_id uuid REFERENCES services(id) ON DELETE CASCADE,
service_name text,
value text,
created_at timestamp without time zone default (CURRENT_TIMESTAMP(0) at time zone 'utc'),
op_time timestamp without time zone default (CURRENT_TIMESTAMP(0) at time zone 'utc'),
PRIMARY KEY (id)
);
DO $$
BEGIN
IF (SELECT to_regclass('route_by_selector_service_id')) IS NULL THEN
CREATE INDEX route_by_selector_service_id ON route_by_selector(service_id);
END IF;
IF (SELECT to_regclass('route_by_selector_selector_name')) IS NULL THEN
CREATE INDEX route_by_selector_selector_name ON route_by_selector(selector_name);
END IF;
END$$;
]],
down = [[
DROP TABLE route_by_selector;
]]
}
}
|
-- used as a resource manager to load only used images, sounds, fonts
Resource=class:new()
function Resource:init()
self.images={}
self.sounds={}
self.musics={}
self.fonts={}
self.lastPlayedSound=nil
end
function Resource:exists(fileName)
local file=File:new()
if file:exists(fileName)==false then
dbg("File "..fileName.." does not exist")
return false
end
return true
end
-- load font resource
function Resource:loadFont(fontName,fontSize)
fontSize=fontSize or 14
if fontName==nil then
return nil
end
local ident=fontName.."|"..fontSize
local font=self.fonts[ident]
if font==nil then
local fullPath="data/font/"..fontName..".ttf"
if self:exists(fullPath)==false then
return nil
end
font=love.graphics.newFont(fullPath,fontSize)
if font~=nil then
self.fonts[ident]=font
end
end
return font
end
-- load image resource
-- directory for file
-- imageName : only file name without extension, extension is always .png because of compression
function Resource:loadImage(directory,imageName)
if directory==nil or imageName==nil then
return nil
end
local image=self.images[imageName]
if image==nil then
local fullPath="data/"..directory.."/"..imageName..".png"
if self:exists(fullPath)==false then
return nil
end
image=love.graphics.newImage(fullPath)
if image~=nil then
self.images[imageName]=image
end
end
return image
end
-- load sound resource
function Resource:loadSound(soundName)
if soundName==nil then
return nil
end
local sound=self.sounds[soundName]
if sound==nil then
local fullPath="data/sound/"..soundName..".wav"
if self:exists(fullPath)==false then
return nil
end
sound=love.audio.newSource(fullPath,"static")
if sound~=nil then
self.sounds[soundName]=sound
end
end
return sound
end
-- load music resource
function Resource:loadMusic(musicName)
if musicName==nil then
return nil
end
local music=resources.musics[musicName]
if music==nil then
local fullPath="data/music/"..musicName..".ogg"
if self:exists(fullPath)==false then
return nil
end
music=love.audio.newSource(fullPath,"stream")
if music~=nil then
self.musics[musicName]=music
end
end
return music
end
-- play sounds
function Resource:soundPlay(sound,loop)
if self.lastPlayedSound~=nil then
soundStop(self.lastPlayedSound)
end
if sound~=nil then
sound:setLooping(default(loop,false))
sound:play()
end
self.lastPlayedSound=sound
end
-- stop sound playing
function Resource:soundStop(sound)
if sound~=nil then
sound:stop()
end
self.lastPlayedSound=nil
end
-- set volume for audio output
function Resource:soundSetVolume(volume)
love.audio.setVolume(volume)
end
|
-----------------------------------
-- Area: Selbina
-- NPC: Lucia
-- !pos 30.552 -2.558 -30.023 248
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
if player:getZPos() > -28.750 then
player:startEvent(221, player:getGil(), 100)
else
player:startEvent(235)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 221 and player:getZPos() < -28.750 then
player:delGil(100)
end
end
|
eventMgr.subscribe("on_load_done", function(e)
local v1 = versionNumber.new("1.0.0")
local v2 = versionNumber.new("1.0.1")
local v3 = versionNumber.new("0.1.9")
assert(v1 == v1, "versionNumber eq fail")
assert(v1 < v2, "versionNumber lt fail")
assert(v1 > v3, "versionNumber gt fail")
assert(v1 <= v1, "versionNumber le fail")
assert(v3 <= v1, "versionNumber le fail")
printA("[tests.lua]: All tests passed")
end)
|
object_tangible_loot_generic_usable_handheld_viewscreen_2_generic = object_tangible_loot_generic_usable_shared_handheld_viewscreen_2_generic:new {
}
ObjectTemplates:addTemplate(object_tangible_loot_generic_usable_handheld_viewscreen_2_generic, "object/tangible/loot/generic/usable/handheld_viewscreen_2_generic.iff")
|
local util = require('vim.lsp.util')
local api = vim.api
local M = {}
--- bufnr → true|nil
--- to throttle refreshes to at most one at a time
local active_refreshes = {}
--- bufnr -> client_id -> lenses
local lens_cache_by_buf = setmetatable({}, {
__index = function(t, b)
local key = b > 0 and b or api.nvim_get_current_buf()
return rawget(t, key)
end
})
local namespaces = setmetatable({}, {
__index = function(t, key)
local value = api.nvim_create_namespace('vim_lsp_codelens:' .. key)
rawset(t, key, value)
return value
end;
})
--@private
M.__namespaces = namespaces
--@private
local function execute_lens(lens, bufnr, client_id)
local line = lens.range.start.line
api.nvim_buf_clear_namespace(bufnr, namespaces[client_id], line, line + 1)
-- Need to use the client that returned the lens → must not use buf_request
local client = vim.lsp.get_client_by_id(client_id)
assert(client, 'Client is required to execute lens, client_id=' .. client_id)
client.request('workspace/executeCommand', lens.command, function(...)
local result = vim.lsp.handlers['workspace/executeCommand'](...)
M.refresh()
return result
end, bufnr)
end
--- Return all lenses for the given buffer
---
---@return table (`CodeLens[]`)
function M.get(bufnr)
local lenses_by_client = lens_cache_by_buf[bufnr]
if not lenses_by_client then return {} end
local lenses = {}
for _, client_lenses in pairs(lenses_by_client) do
vim.list_extend(lenses, client_lenses)
end
return lenses
end
--- Run the code lens in the current line
---
function M.run()
local line = api.nvim_win_get_cursor(0)[1]
local bufnr = api.nvim_get_current_buf()
local options = {}
local lenses_by_client = lens_cache_by_buf[bufnr] or {}
for client, lenses in pairs(lenses_by_client) do
for _, lens in pairs(lenses) do
if lens.range.start.line == (line - 1) then
table.insert(options, {client=client, lens=lens})
end
end
end
if #options == 0 then
vim.notify('No executable codelens found at current line')
elseif #options == 1 then
local option = options[1]
execute_lens(option.lens, bufnr, option.client)
else
local options_strings = {"Code lenses:"}
for i, option in ipairs(options) do
table.insert(options_strings, string.format('%d. %s', i, option.lens.command.title))
end
local choice = vim.fn.inputlist(options_strings)
if choice < 1 or choice > #options then
return
end
local option = options[choice]
execute_lens(option.lens, bufnr, option.client)
end
end
--- Display the lenses using virtual text
---
---@param lenses table of lenses to display (`CodeLens[] | null`)
---@param bufnr number
---@param client_id number
function M.display(lenses, bufnr, client_id)
if not lenses or not next(lenses) then
return
end
local lenses_by_lnum = {}
for _, lens in pairs(lenses) do
local line_lenses = lenses_by_lnum[lens.range.start.line]
if not line_lenses then
line_lenses = {}
lenses_by_lnum[lens.range.start.line] = line_lenses
end
table.insert(line_lenses, lens)
end
local ns = namespaces[client_id]
local num_lines = api.nvim_buf_line_count(bufnr)
for i = 0, num_lines do
local line_lenses = lenses_by_lnum[i] or {}
api.nvim_buf_clear_namespace(bufnr, ns, i, i + 1)
local chunks = {}
local num_line_lenses = #line_lenses
for j, lens in ipairs(line_lenses) do
local text = lens.command and lens.command.title or 'Unresolved lens ...'
table.insert(chunks, {text, 'LspCodeLens' })
if j < num_line_lenses then
table.insert(chunks, {' | ', 'LspCodeLensSeparator' })
end
end
if #chunks > 0 then
api.nvim_buf_set_extmark(bufnr, ns, i, 0, { virt_text = chunks })
end
end
end
--- Store lenses for a specific buffer and client
---
---@param lenses table of lenses to store (`CodeLens[] | null`)
---@param bufnr number
---@param client_id number
function M.save(lenses, bufnr, client_id)
local lenses_by_client = lens_cache_by_buf[bufnr]
if not lenses_by_client then
lenses_by_client = {}
lens_cache_by_buf[bufnr] = lenses_by_client
local ns = namespaces[client_id]
api.nvim_buf_attach(bufnr, false, {
on_detach = function(b) lens_cache_by_buf[b] = nil end,
on_lines = function(_, b, _, first_lnum, last_lnum)
api.nvim_buf_clear_namespace(b, ns, first_lnum, last_lnum)
end
})
end
lenses_by_client[client_id] = lenses
end
--@private
local function resolve_lenses(lenses, bufnr, client_id, callback)
lenses = lenses or {}
local num_lens = vim.tbl_count(lenses)
if num_lens == 0 then
callback()
return
end
--@private
local function countdown()
num_lens = num_lens - 1
if num_lens == 0 then
callback()
end
end
local ns = namespaces[client_id]
local client = vim.lsp.get_client_by_id(client_id)
for _, lens in pairs(lenses or {}) do
if lens.command then
countdown()
else
client.request('codeLens/resolve', lens, function(_, _, result)
if result and result.command then
lens.command = result.command
-- Eager display to have some sort of incremental feedback
-- Once all lenses got resolved there will be a full redraw for all lenses
-- So that multiple lens per line are properly displayed
api.nvim_buf_set_extmark(
bufnr,
ns,
lens.range.start.line,
0,
{ virt_text = {{ lens.command.title, 'LspCodeLens' }} }
)
end
countdown()
end, bufnr)
end
end
end
--- |lsp-handler| for the method `textDocument/codeLens`
---
function M.on_codelens(err, _, result, client_id, bufnr)
assert(not err, vim.inspect(err))
M.save(result, bufnr, client_id)
-- Eager display for any resolved (and unresolved) lenses and refresh them
-- once resolved.
M.display(result, bufnr, client_id)
resolve_lenses(result, bufnr, client_id, function()
M.display(result, bufnr, client_id)
active_refreshes[bufnr] = nil
end)
end
--- Refresh the codelens for the current buffer
---
--- It is recommended to trigger this using an autocmd or via keymap.
---
--- <pre>
--- autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh()
--- </pre>
---
function M.refresh()
local params = {
textDocument = util.make_text_document_params()
}
local bufnr = api.nvim_get_current_buf()
if active_refreshes[bufnr] then
return
end
active_refreshes[bufnr] = true
vim.lsp.buf_request(0, 'textDocument/codeLens', params)
end
return M
|
object_mobile_npc_dressed_collection_npc_female_human_02 = object_mobile_shared_npc_dressed_collection_npc_female_human_02:new {
}
ObjectTemplates:addTemplate(object_mobile_npc_dressed_collection_npc_female_human_02, "object/mobile/npc_dressed_collection_npc_female_human_02.iff")
|
local filepath = require "util/filepath"
local result = {}
for k, filepath in ipairs( filepath.list_files( "ChallengeFight:fight_data", "*.lua", true )) do
local name = filepath:match( "(.+)[.]lua$" )
if name then
local temp = require(name)
table.insert(result, temp)
end
end
function AddChallengeFightEntry(entry)
table.insert(result, entry)
end
return result
|
-------------------------------------------------------------------------------
--- AUTHOR: Nostrademous
-------------------------------------------------------------------------------
local Chat = {}
Chat.Name = "Chat"
Chat.NumArgs = 3
-------------------------------------------------
function Chat:Call( hHero, sMsg, bAllChat )
hHero:ActionImmediate_Chat(sMsg[1], bAllChat[1])
end
-------------------------------------------------
return Chat
|
return cubictest.formatter:new {
["Suite Start"] = function(self, run, event)
end,
["Specification Start"] = function(self, run, event)
self:write_ln("#### %s", run.target.description)
end,
["TestCase Start"] = function(self, run, event)
self.step_index = 0
self:write_ln("###### … %s", run.target.description)
end,
["Step"] = function(self, run, event)
self.step_index = self.step_index + 1
if not run.success and #(run.events)-3 <= self.step_index then
-- intentional whitespace at the end for line break
self:write_ln(" %d. ~~**%s** %s~~ ", self.step_index, event.conjunction, event.description)
else
self:write_ln(" %d. **%s** %s", self.step_index, event.conjunction, event.description)
end
end,
["TestCase Error"] = function(self, run, event)
if event.effect == "skipped" then
self:write_ln(" Skipped: failed assumption")
return
end
self:write_ln(" Fail with:\n")
self:write_ln(event.message:prefix_lines(" > "))
end,
["TestCase End"] = function(self, run, event)
self:write_ln()
end,
["Specification End"] = function(self, run, event)
end,
["Specification Error"] = function(self, run, event)
self:write_ln("##### … Its setup fails with:")
self:write_ln(event.message:prefix_lines("> "))
end,
["Suite End"] = function(self, run, event)
self:write_ln("## Summary")
local run_time = event.time - run.events[1].time
self:write_ln(" * Run in %.2fs", run_time/1000000)
local specs_total = run.stats:get_total()
self:write_ln(" * %d specifications (%s) in %.2fms/spec",
specs_total, tostring(run.stats), run_time/specs_total/1000)
local cases_total = run.children_stats:get_total()
self:write_ln(" * %d tests (%s) in %.2fms/test",
cases_total, tostring(run.children_stats), run_time/cases_total/1000)
end,
}
|
--===========================================================================--
-- --
-- System.Serialization --
-- --
--===========================================================================--
--===========================================================================--
-- Author : kurapica125@outlook.com --
-- URL : http://github.com/kurapica/PLoop --
-- Create Date : 2015/07/22 --
-- Update Date : 2019/02/28 --
-- Version : 1.1.0 --
--===========================================================================--
PLoop(function(_ENV)
export {
type = type,
rawset = rawset,
rawget = rawget,
ipairs = ipairs,
pairs = pairs,
getmetatable = getmetatable,
strformat = string.format,
safeset = Toolset.safeset,
isclass = Class.Validate,
isstruct = Struct.Validate,
isenum = Enum.Validate,
issubtype = Class.IsSubType,
isselfreferenced = Struct.IsSelfReferenced,
getarrayelement = Struct.GetArrayElement,
getmembers = Struct.GetMembers,
getfeatures = Class.GetFeatures,
getstructcategory = Struct.GetStructCategory,
MEMBER = StructCategory.MEMBER,
CUSTOM = StructCategory.CUSTOM,
ARRAY = StructCategory.ARRAY,
getnamespace = Namespace.Validate,
validenum = Enum.ValidateValue,
validstruct = Struct.ValidateValue,
validprop = Property.Validate,
gettemplate = Class.GetTemplate,
gettemplatepars = Class.GetTemplateParameters,
getstructtemplate = Struct.GetTemplate,
getstrcuttemppars = Struct.GetTemplateParameters,
getbasestruct = Struct.GetBaseStruct,
}
export { Enum, Struct, Class, Property }
-----------------------------------------------------------
-- storage --
-----------------------------------------------------------
local _SerializableType = {}
local _SerializeInfo = {}
local _NonSerializableInfo = {}
-----------------------------------------------------------
-- helpers --
-----------------------------------------------------------
export {
savenonserializable = false,
regSerializableType = false,
saveTypeInfo = false,
isSerializable = false,
isSerializableType = false,
serialize = false,
deserialize = false,
}
savenonserializable = function(smem) _NonSerializableInfo = safeset(_NonSerializableInfo, smem, true) end
-- Reset the cache if re-defined
Runtime.OnTypeDefined = Runtime.OnTypeDefined + function(type, target) if _SerializeInfo[target] then _SerializeInfo[target] = false end end
function regSerializableType(type)
_SerializableType = safeset(_SerializableType, type, true)
end
function saveTypeInfo(type)
_SerializeInfo = safeset(_SerializeInfo, type, true)
-- Cache the field info for quick access
if isclass(type) and not issubtype(type, ISerializable) then
local fieldInfo = {}
for name, prop in getfeatures(type) do
if validprop(prop) and not _NonSerializableInfo[prop] and prop:IsReadable() and prop:IsWritable() then
local ptype = prop:GetType()
if not ptype then
fieldInfo[name] = false
elseif isSerializableType(ptype) then
fieldInfo[name] = ptype
end
end
end
_SerializeInfo = safeset(_SerializeInfo, type, fieldInfo)
elseif isstruct(type) and getstructcategory(type) == MEMBER then
local fieldInfo = {}
for _, mem in getmembers(type) do
if not _NonSerializableInfo[mem] then
local mtype = mem:GetType()
if not mtype then
fieldInfo[mem:GetName()] = false
elseif isSerializableType(mtype) then
fieldInfo[mem:GetName()] = mtype
end
end
end
_SerializeInfo = safeset(_SerializeInfo, type, fieldInfo)
end
end
function chkSerializableType(type, cache)
if isenum (type) then return true end
if isclass(type) then
local template = gettemplate(type)
if template and isSerializableType(template) then
for _, par in ipairs{ gettemplatepars(type) } do if getnamespace(par) and not isSerializableType(par) then return false end end
return true
end
return false
end
if not isstruct(type) then return false end
local category = getstructcategory(type)
if category == CUSTOM then
local base = getbasestruct(type)
if base and isSerializableType(base) then return true end
local template = getstructtemplate(type)
if template and isSerializableType(template) then
for _, par in ipairs{ getstrcuttemppars(type) } do if getnamespace(par) and not isSerializableType(par) then return false end end
return true
end
elseif category == ARRAY then
cache = cache or isselfreferenced(type) and {}
if cache then cache[type] = true end
if isSerializableType(getarrayelement(type), cache) then
return true
end
elseif category == MEMBER then
cache = cache or isselfreferenced(type) and {}
if cache then cache[type] = true end
for _, member in getmembers(type) do
if not _NonSerializableInfo[member] then
local mtype = member:GetType()
if mtype and not isSerializableType(mtype, cache) then return false end
end
end
return true
end
return false
end
function isSerializableType(type, cache)
if not type then return false end
if _SerializeInfo[type] then return true end
if cache and cache[type]then return true end
if _SerializableType[type] or chkSerializableType(type, cache) then
saveTypeInfo(type)
return true
end
return false
end
function isSerializable(obj)
local otype = type(obj)
if otype == "table" then
local cls = getmetatable(obj)
return (cls == nil or isSerializableType(cls)) and true or false
else
return otype == "string" or otype == "number" or otype == "boolean"
end
end
function serialize(object, otype, cache)
if cache[object] then throw("Duplicated object is not supported by System.Serialization") end
cache[object] = true
local storage = {}
local stype = otype or getmetatable(object)
if isclass(stype) then
if issubtype(stype, ISerializable) then
local sinfo = SerializationInfo(storage, cache)
object:Serialize(sinfo)
else
local srinfo = _SerializeInfo[stype]
if srinfo and type(srinfo) == "table" then
for name, ptype in pairs(srinfo) do
local val = object[name]
if val ~= nil then
if type(val) == "table" then
val = serialize(val, ptype, cache)
end
storage[name] = val
end
end
else
for name, prop in getfeatures(stype) do
if validprop(prop) and not _NonSerializableInfo[prop] and prop:IsReadable() and prop:IsWritable() then
local ptype = prop:GetType()
if not ptype or isSerializableType(ptype) then
local val = object[name]
if val ~= nil then
if type(val) == "table" then
val = serialize(val, ptype, cache)
end
storage[name] = val
end
end
end
end
end
end
elseif isstruct(stype) then
local scategory = getstructcategory(stype)
if scategory == ARRAY then
local etype = getarrayelement(stype)
for i, val in ipairs(object) do
if isSerializable(val) then
if type(val) == "table" then val = serialize(val, etype, cache) end
storage[i] = val
end
end
elseif scategory == MEMBER then
local srinfo = _SerializeInfo[stype]
if srinfo and type(srinfo) == "table" then
for name, mtype in pairs(srinfo) do
local val = object[name]
if val ~= nil then
if type(val) == "table" then
val = serialize(val, mtype, cache)
end
storage[name] = val
end
end
else
for _, mem in getmembers(stype) do
if not _NonSerializableInfo[mem] then
local mtype = mem:GetType()
if not mtype or isSerializableType(mtype) then
local name = mem:GetName()
local val = object[name]
if val ~= nil then
if type(val) == "table" then
val = serialize(val, mtype, cache)
end
storage[name] = val
end
end
end
end
end
else
stype = nil
end
else
stype = nil
end
if not stype then
for k, v in pairs(object) do
local tk = type(k)
if (tk == "string" or tk == "number") and isSerializable(v) then
if type(v) == "table" then v = serialize(v, nil, cache) end
storage[k] = v
end
end
else
-- save the object type
storage[Serialization.ObjectTypeField] = stype
end
return storage
end
function deserialize(storage, otype)
if type(storage) == "table" then
local dtype = storage[Serialization.ObjectTypeField]
if dtype ~= nil then
storage[Serialization.ObjectTypeField] = nil
dtype = getnamespace(dtype)
if dtype and (isclass(dtype) or isstruct(dtype)) then otype = dtype end
end
otype = dtype or otype
if otype then
if isclass(otype) then
if issubtype(otype, ISerializable) then
return otype(SerializationInfo(storage))
else
local srinfo = _SerializeInfo[otype]
if srinfo and type(srinfo) == "table" then
for name, ptype in pairs(srinfo) do
local val = storage[name]
if val ~= nil then
storage[name] = deserialize(val, ptype)
end
end
else
for name, prop in getfeatures(otype) do
if validprop(prop) and not _NonSerializableInfo[prop] and prop:IsWritable() then
local val = storage[name]
if val ~= nil then
storage[name] = deserialize(val, prop:GetType())
end
end
end
end
-- As init-table
return otype(storage)
end
elseif isstruct(otype) then
local scategory = getstructcategory(otype)
if scategory == ARRAY then
local etype = getarrayelement(otype)
for i, v in ipairs(storage) do
storage[i] = deserialize(v, etype)
end
return otype(storage)
elseif scategory == MEMBER then
local srinfo = _SerializeInfo[otype]
if srinfo and type(srinfo) == "table" then
for name, mtype in pairs(srinfo) do
local val = storage[name]
if val ~= nil then
storage[name] = deserialize(val, mtype)
end
end
else
for _, mem in getmembers(otype) do
if not _NonSerializableInfo[mem] then
local name = mem:GetName()
local val = storage[name]
if val ~= nil then
storage[name] = deserialize(val, mem:GetType())
end
end
end
end
return otype(storage)
end
end
end
-- Default for no-type data or custom table struct data
for k, v in pairs(storage) do
if type(v) == "table" then
storage[k] = deserialize(v)
end
end
return storage
else
if otype then
if isstruct(otype) and getstructcategory(otype) == CUSTOM then
return validstruct(otype, storage)
elseif isenum(otype) then
return validenum(otype, storage)
else
throw(strformat("Deserialize non-table data to %s is not supported.", tostring(otype)))
end
else
return storage
end
end
end
--- Serialization is the process of converting the state of an object into a form that can be persisted or transported.
__Final__() __Sealed__()
interface (_ENV, "System.Serialization") (function (_ENV)
export {
regSerializableType = regSerializableType,
savenonserializable = savenonserializable,
isSerializableType = isSerializableType,
isSerializable = isSerializable,
serialize = serialize,
deserialize = deserialize,
error = error,
type = type,
}
export { AttributeTargets, StructCategory, Struct }
--- indicates that a class or custom struct can be serialized
__Sealed__() __Final__()
class "__Serializable__" { IAttachAttribute,
AttachAttribute = function (self, target, targettype, owner, name, stack)
if targettype == AttributeTargets.Struct and Struct.GetStructCategory(target) ~= StructCategory.CUSTOM then
error("the `__Serializable__` can only applied on custom struct or class", stack + 1)
end
regSerializableType(target)
end,
AttributeTarget = { type = AttributeTargets, default = AttributeTargets.Struct + AttributeTargets.Class },
}
--- indicates that a member of struct or property of class can't be serialized
__Sealed__() __Final__()
class "__NonSerialized__" { IAttachAttribute,
AttachAttribute = function (self, target, targettype, owner, name, stack)
savenonserializable(target)
end,
AttributeTarget = { type = AttributeTargets, default = AttributeTargets.Property + AttributeTargets.Member },
}
--- allows classes to control its own serialization and deserialization,
-- the class should define a method *Serialize* used to save its properties
-- into the serialization info, also need a constructor that can accept
-- the data of System.Serialization.SerializationInfo
__Sealed__()
interface "ISerializable" {
--- Use a SerializationInfo to serialize the target object
-- @owner ISerializable
-- @method Serialize
-- @param info the serialization info
__Abstract__(),
Serialize = function(self, info) end
}
--- represents the serializable values
__Sealed__()
struct "Serializable" { function(val) return not isSerializable(val) and (onlyvalid or "the %s must be serializable") or nil end }
--- represents the serializable types
__Sealed__()
struct "SerializableType" { function(type, onlyvalid) return not isSerializableType(type) and (onlyvalid or "the %s must be a serializable type") or nil end }
--- stores all the data needed to serialize or deserialize an object
__Sealed__() __Final__()
class "SerializationInfo" {
--- save the object data to the SerializationInfo
-- @owner SerializationInfo
-- @method SetValue
-- @param name -- the field name
-- @param value -- the field value
-- @param type -- the value type
SetValue = function(self, name, value, vtype)
if value == nil then return end
if not isSerializable(value) then
throw("SerializationInfo:SetValue(name, value[, valuetype]) - value must be serializable")
end
if type(value) == "table" then
self.__storage[name] = serialize(value, vtype, self.__cache)
else
self.__storage[name] = value
end
end,
--- get the object data from the SerializationInfo
-- @owner SerializationInfo
-- @method GetValue
-- @param name -- the field name
-- @param type -- the value type
-- @return value -- the field value
GetValue = function(self, name, vtype)
local val = self.__storage[name]
if type(val) == "table" then
return deserialize(val, vtype)
else
return val
end
end,
__new = function(_, storage, cache)
return { __storage = storage, __cache = cache }, true
end,
}
--- Provide a format for serialization. Used to serialize the table data to target format or convert the target format data to the table data
__Abstract__() __Sealed__()
class "FormatProvider" (function(_ENV)
--- Serialize the common lua data to the target format for storage.
__Abstract__()
function Serialize(self, data, writer) end
--- Deserialize the data to common lua data.
__Abstract__()
function Deserialize(self, reader) end
end)
-----------------------------------------------------------------------
-- static property --
-----------------------------------------------------------------------
--- The field that used to store the object type
__Static__()
property "ObjectTypeField" { type = NEString, default = "__PLoop_Serial_ObjectType" }
-----------------------------------------------------------------------
-- static method --
-----------------------------------------------------------------------
__Arguments__{ FormatProvider, Any + Function + System.IO.TextReader, SerializableType/nil }
__Static__() function Deserialize(provider, reader, otype)
return deserialize(provider:Deserialize(reader), otype)
end
__Arguments__{ FormatProvider, Serializable, (Function + System.IO.TextWriter)/nil }
__Static__() function Serialize(provider, object, writer)
if type(object) ~= "table" then return provider:Serialize(object, writer) end
return provider:Serialize(serialize(object, nil, {}), writer)
end
__Arguments__{ FormatProvider, Serializable, SerializableType, (Function + System.IO.TextWriter)/nil }
__Static__() function Serialize(provider, object, otype, writer)
if type(object) ~= "table" then return provider:Serialize(object, writer) end
return provider:Serialize(serialize(object, otype, {}), writer)
end
end)
-----------------------------------------------------------------------
-- prepare --
-----------------------------------------------------------------------
regSerializableType(Boolean)
regSerializableType(String)
regSerializableType(Number)
regSerializableType(AnyBool)
regSerializableType(NEString)
regSerializableType(PositiveNumber)
regSerializableType(NegativeNumber)
regSerializableType(Integer)
regSerializableType(NaturalNumber)
regSerializableType(NegativeInteger)
regSerializableType(Guid)
export { Serialization, Serialization.SerializationInfo, Serialization.ISerializable }
end)
|
-- example
local loader = require "ase-loader"
local sprite = {}
function sprite:load(dir)
local file = loader(dir)
-- size
self.width = file.header.width
self.height = file.header.height
self.frames = {}
self.tags = {}
self.active = "" -- active tag
self.index = 1 -- actual frame
self.time = 0 -- current time elapsed
for _, frame in ipairs(file.header.frames) do
for _, chunk in ipairs(frame.chunks) do
-- frame image data
if chunk.type == 0x2005 then
local cel = chunk.data
local buffer = love.data.decompress("data", "zlib", cel.data)
local data = love.image.newImageData(cel.width, cel.height, "rgba8", buffer)
local image = love.graphics.newImage(data)
local canvas = love.graphics.newCanvas(self.width, self.height)
-- you need to draw in a canvas before.
-- frame images can be of different sizes
-- but never bigger than the header width and height
love.graphics.setCanvas(canvas)
love.graphics.draw(image, cel.x, cel.y)
love.graphics.setCanvas()
table.insert(self.frames, {
image = canvas,
duration = frame.frame_duration / 1000})
-- tag
elseif chunk.type == 0x2018 then
for i, tag in ipairs(chunk.data.tags) do
-- first tag as default
if i == 1 then
self.active = tag.name
end
-- aseprite use 0 notation to begin
-- but in lua, everthing starts in 1
tag.to = tag.to + 1
tag.from = tag.from + 1
tag.frames = tag.to - tag.from
self.tags[tag.name] = tag
end
end
end
end
end
function sprite:play(name)
assert(self.tags[name], "invalid tag: " .. name)
-- if arent playing...
-- prevent indexes bigger than tag to
if self.active ~= name then
self.index = self.tags[name].from
end
self.active = name
end
function sprite:update(delta)
assert(self.active, "no tag playing, sure you set this in aseprite?")
local tag = self.tags[self.active]
-- time tracker are useless on single frames...
if (tag.to - tag.from) ~= 0 then
self.time = self.time + delta
-- next frame
if self.time >= self.frames[self.index].duration then
self.index = self.index + 1
self.time = 0 -- you can change to "self.time - frame.duration" as well
-- reach the end, return to begin
if self.index > tag.to then
self.index = tag.from
end
end
end
end
function sprite:draw(x, y, angle, sx, sy)
love.graphics.draw(self.frames[self.index].image, x, y, angle, sx, sy)
end
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
sprite:load("player.ase")
sprite:play("run")
end
function love.update(delta)
sprite:update(delta)
end
function love.draw()
sprite:draw(0, 0, 0, 10, 10)
end
|
local c = reflection:getClass("net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket")
local mode = c.Mode.START_FALL_FLYING
local p = player:getPlayer()
local rawP = p:getRaw()
p:getAbilities():setFlying(true)
function fuck()
rawP.networkHandler:sendPacket(luajava.new(c, rawP, mode))
end
fuck()
|
--- The client implemented by socketchannel of skynet
local base = require 'enip.ab.client.unconnected'
local command = require 'enip.command.base'
local reply_parser = require 'enip.reply.parser'
local socketchannel = require 'socketchannel'
local client = base:subclass('FREEIOE_APP_PLC_ENIP_CIP_CLIENT')
local function protect_call(obj, func, ...)
assert(obj and func)
local f = obj[func]
if not f then
return nil, "Object has no function "..func
end
local ret = {xpcall(f, debug.traceback, obj, ...)}
if not ret[1] then
return nil, table.concat(ret, '', 2)
end
return table.unpack(ret, 2)
end
function client:set_logger(log)
self._log = log
end
function client:connect()
local conn_path = self:conn_path()
local log = self._log
assert(conn_path:proto() == 'tcp', 'Only TCP is supported')
self._channel = socketchannel.channel({
host = conn_path:address(),
port = conn_path:port(),
nodelay = true,
response = function(...)
local ret = {xpcall(self.sock_dispatch, debug.traceback, self, ...)}
if not ret[1] then
local err = ret[2]
if err ~= socketchannel.error then
err = table.concat(ret, '', 2)
end
if log then
log:error("Socket error:", err)
end
if self.reconnect then
self:reconnect()
end
return nil, err
end
return table.unpack(ret, 2)
end,
overload = function(...)
return self:sock_overload(...)
end,
auth = function(sock)
local r, err = self:register_session()
if not r then
log:error('register_session error', err)
assert(r, err)
end
--[[
local ret, err = pcall(self.register_session, self)
if not ret then
if log then
log:error("Auth method error", err)
end
end
]]--
end
})
self._channel:connect(false) -- non-block mode connect
return true
end
function client:sock_dispatch(sock)
local min_size = command.min_size()
local raw, err = sock:read(min_size)
local cmd, data_len = command.parse_header(raw)
if data_len > 0 then
local data_raw, err = sock:read(data_len)
if not data_raw then
return nil, err
end
raw = raw..data_raw
end
if self._hex_dump then
self._hex_dump('IN', raw)
end
local reply, err = reply_parser(cmd, raw)
if not reply then
self._log:error('reply parser error:', err)
return nil, err
end
local session = reply:session()
return session:context(), reply ~= nil, reply or err
end
function client:sock_overload(is_overload)
if is_overload then
self:close()
end
end
function client:invalid_session()
local r, err = self:register_session()
if not r then
self._log:error("Invalid session try to register session again but failed", err)
end
end
function client:close()
self._channel:close()
return true
end
function client:set_dump(func)
self._hex_dump = func
end
function client:request(request, response)
assert(request.to_hex, "Request needs to be one object")
assert(request.session, "Session missing")
local session = request:session()
if not self._channel then
return nil, "Channel not initialized"
end
local req_raw = request:to_hex()
if self._hex_dump then
self._hex_dump('OUT', req_raw)
end
local r, resp, err = pcall(self._channel.request, self._channel, req_raw, session:context())
if not r then
return nil, resp, err
end
return response(resp, err)
end
return client
|
--[[
The MIT License (MIT)
Copyright (c) 2016 Subhojit Basu
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.
--]]
function bot(myloc,food,frnd)
--local dir = getDir(myloc,food[math.random(#food)]);
if #food == 0 then
return {x=0,y=0}
end
local dist = {};
local shortest=math.huge;
local index = -1;
for i=1,#food do
dist[i] = getDist(myloc,food[i]);
if dist[i] < shortest then
shortest,index = dist[i],i;
end
end
--local dir = getDir(myloc,food[1]);
local dir = getDir(myloc,food[index]);
local move;
if dir < 90 then
move = {x=0,y=1};
elseif dir < 180 then
move = {x=-1,y=0};
elseif dir < 270 then
move = {x=0,y=-1};
else
move = {x=1,y=0};
end
return move;
end
function getDir(loc1,loc2)
local deg = math.deg(math.atan((loc2.y-loc1.y)/(loc2.x-loc1.x)));
while deg < 0 do
deg = deg + 360;
end
return deg;
end
function getDist(loc1,loc2)
return math.sqrt((loc1.x-loc2.x)^2 + (loc1.y-loc2.y)^2)
end
|
require "outerInterpreter"
tinyLuaForth=function(inDictFilePath)
print "--- tiny LuaForth 1.2 ---"; dofile(inDictFilePath)
while true do io.write("-> ")
local line=io.read(); if line=="" then print("bye."); break end
local result=outerInterpreter(line)
print(result==nil and " ok." or "unknown word '"..result.."'")
end
end
|
---------------------------------------------------------------------------
-- SoarETX widget --
-- --
-- Author: Jesper Frickmann --
-- Date: 2022-02-08 --
-- Version: 1.0.0 --
-- --
-- Copyright (C) EdgeTX --
-- --
-- License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html --
-- --
-- This program is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License version 2 as --
-- published by the Free Software Foundation. --
-- --
-- This program is distributed in the hope that it will be useful --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --
-- GNU General Public License for more details. --
---------------------------------------------------------------------------
local options = {
{ "Version", VALUE, 1, 1, 99 },
{ "FileName", STRING, "" }
}
local soarGlobals
-- Load a Lua component dynamically based on option values
local function Load(widget)
local chunk, errMsg = loadScript(soarGlobals.path .. widget.options.Version .. "/" .. widget.options.FileName .. ".lua")
if errMsg then
widget.errMsg = errMsg
else
chunk(widget, soarGlobals)
end
end
-- Initialize the first time this widget is instantiated
local function init()
soarGlobals = {
path = "/WIDGETS/SoarETX/",
battery = 0,
batteryParameter = 1
}
-- Functions to handle persistent model parameters stored in curve 32
local parameterCurve = model.getCurve(31)
if not parameterCurve then
error("Curve #32 is missing! It is used to store persistent model parameters for Lua.")
end
-- Work around the stupid fact that getCurve and setCurve tables are incompatible...
local y = parameterCurve.y
parameterCurve.y = { }
for i = 1, parameterCurve.points do
parameterCurve.y[i] = y[i - 1]
end
function soarGlobals.getParameter(idx)
return parameterCurve.y[idx]
end
function soarGlobals.setParameter(idx, value)
parameterCurve.y[idx] = value
model.setCurve(31, parameterCurve)
end
end
local function create(zone, options)
if not soarGlobals then
init()
end
local widget = {
zone = zone,
options = options
}
Load(widget)
return widget
end
local function update(widget, options)
if options.Version ~= widget.options.Version or options.FileName ~= widget.options.FileName then
local zone = widget.zone
-- Erase all fields in widget
local keys = { }
for key in pairs(widget) do
keys[#keys + 1] = key
end
for i, key in ipairs(keys) do
widget[key] = nil
end
widget.zone = zone
widget.options = options
Load(widget)
end
end
local function refresh(widget, event, touchState)
if widget.errMsg then
lcd.drawTextLines(0, 0, widget.zone.w, widget.zone.h, widget.errMsg .. "\nPlease check widget settings!", COLOR_THEME_WARNING)
else
widget.refresh(event, touchState)
end
end
local function background(widget)
if widget.background then
widget.background()
end
end
return {
name = "SoarETX",
create = create,
refresh = refresh,
options = options,
update = update,
background = background
}
|
-- Access the Lightroom SDK namespaces.
local LrDialogs = import "LrDialogs"
local LrLogger = import "LrLogger"
local LrApplication = import "LrApplication"
local LrTasks = import "LrTasks"
local LrErrors = import "LrErrors"
-- Create the logger and enable the print function.
local myLogger = LrLogger("nosleepLogger")
myLogger:enable("logfile") -- print or logfile
-------------------------------------------------------------------------------
-- Write trace information to the logger.
local function outputToLog(message)
myLogger:trace(message)
end
-------------------------------------------------------------------------------
-- Split a string into tokens.
local function mysplit (inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
-------------------------------------------------------------------------------
-- Options
local dryRun = true -- Set to false to actually update the photo titles.
local collectionSetName = "From Lightroom" -- Set to the collection set of interest.
-------------------------------------------------------------------------------
-- This function sets the titles of the photos within each collection to the
-- name of the collection. I.e. all collections are expected to be named with
-- a year/month prefix:
--
-- 2017-03 Family Picnic
-- 2018-10 Halloween
-- 2018-11 Thanksgiving
--
-- The function performs some validation of the format of the collection names
-- and then sets the title of each photo to the collection name with the
-- year/month prefix changed to a suffix:
--
-- Family Picnic (2017-03)
-- Halloween (2018-10)
-- Thanksgiving (2018-11)
local function go()
local catalog = LrApplication.activeCatalog()
LrTasks.startAsyncTask(
function()
outputToLog("Script started: " .. catalog:getPath())
-- Step through each high-level collection
for i, v in ipairs(catalog:getChildCollectionSets()) do
if collectionSetName == v:getName() then
outputToLog("Found '" .. collectionSetName .. "'")
for i, v in ipairs(v:getChildCollections()) do
-- Extract contents of the folder name
local tokens = mysplit(v:getName(), ' ')
local datePrefix = tokens[1]
-- Make sure the date prefix has the right length
if #datePrefix ~= 7 then
LrErrors.throwUserError("Error: Bad date prefix: " .. datePrefix)
end
-- Make sure the date prefix contains a dash
if string.match(datePrefix, "-") == false then
LrErrors.throwUserError("Error: Bad date prefix: " .. datePrefix)
end
-- Make sure the year and month look legit
local date_tokens = mysplit(datePrefix, "-")
local year = tonumber(date_tokens[1])
local month = tonumber(date_tokens[2])
if datePrefix ~= "0000-00" then
if year < 1950 or year > 2020 then
LrErrors.throwUserError("Error: Bad year: " .. year)
end
if month < 1 or month > 12 then
LrErrors.throwUserError("Error: Bad month: " .. month)
end
end
-- Generate the title and log it.
local title = v:getName():sub(9,#v:getName())
outputToLog("Updating " .. tostring(#v:getPhotos()) .. " photo titles to '" .. title .. "'")
-- Update the title for all photos in this folder.
catalog:withWriteAccessDo(
"Title Update",
function()
for i, p in ipairs(v:getPhotos()) do
if dryRun == false then
p:setRawMetadata('title', title)
end
end
end
) -- withWriteAccessDo
end -- for getChildCollections
end -- if target collection
end -- for collection sets
outputToLog("Script stopped")
end -- function
) -- async task
end
go()
|
export['cel.sequence'] {
[[Defines the factories for the sequence.x and sequence.y metacels]];
functiondef['cel.sequence.x(t)'] {
[[Creates a new horizontal sequence.]];
[[The sequence is influx until this function returns.]];
code[=[
cel.sequence.x {
gap = number,
}
]=];
params = {
param.number[[gap - the amount of space to leave between links in the sequence. Default is 0.]];
};
returns = {
param['sequence.x'][[a new horizontal sequence.]];
};
};
functiondef['cel.sequence.y(t)'] {
[[Creates a new vertical sequence.]];
[[The sequence is influx until this function returns.]];
code[=[
cel.sequence.y {
gap = number,
}
]=];
params = {
param.number[[gap - the amount of space to leave between links in the sequence. Default is 0.]];
};
returns = {
param['sequence.y'][[a new vertical sequence.]];
};
};
functiondef['cel.sequence.x.new([gap [, face]])'] {
[[Creates a new horizontal sequence.]];
params = {
param.number[[gap - amount of space to leave between links in the sequence. Default is 0.]];
param.face[[face - face or face name.]];
};
returns = {
param['sequence.x'][[a new horizontal sequence.]];
};
};
functiondef['cel.sequence.y.new([gap [, face]])'] {
[[Creates a new vertical sequence.]];
params = {
param.number[[gap - amount of space to leave between links in the sequence. Default is 0.]];
param.face[[face - face or face name.]];
};
returns = {
param['sequence.y'][[a new vertical sequence.]];
};
};
celdef['sequence'] {
[[A cel that arranges its links into a vertical or horizontal sequence.]];
[[A sequence is a cel that provides automatic layout. For each link the top/left is aligned with the
bottom/right (with an optional gap) of the link that comes before it in the sequence. For a vertical sequence its
height, minh and maxh are always the sum of the heights of its links, and its width is the smallest width necessary
to ensure that no part of any of its links are clipped. A sequence does support linkers as well as it can, but keep
in mind that the dimensions of a sequence are calculated from the dimensions and positions of its links, and a linker
will be enforced when the dimensions of the sequence change. Each link is put into a (virtual) slot, for a vertical
sequence the width of the slot is the width of the sequence, the height of the slot is the height of the link. The
slot w and h are the hostw and hosth that the linker will see. Because the slot h is the link h, the any change the
y and h returned from a linker are ignored and 0, and slot.h are used. The height of a link/slot can be changed
by explicitly resizing the link.
]];
[[The position(y for vertical, x for horizontal) of a link in the sequence is the sum of the
link.dimension + gap (dimension is height for vertical, width for horizontal) of the links
that precede it in the sequence. If the sequence is in flux then the links position is not
enforced until the sequence is no longer in flux.]];
functiondef['sequence:get(index)'] {
[[Get a link by index.]];
params = {
param.integer[[index - An array index.]];
};
returns = {
param.cel[[the cel that is linked to the sequence at the specified index, or nil.]];
};
};
functiondef['sequence:insert(index, link)'] {
[[links the given cel to the sequence, inserting it at the given index.]];
[[This is a shortcut for using link, when a linker is not required.]];
params = {
param.integer[[index - An array index. If not provided then link is appended to the end of the sequence]];
param.integer[[link - The cel to link to the sequence.]];
};
returns = {
param.sequence[[self]];
};
};
functiondef['sequence:insert(link)'] {
[[links the given cel to the end of the sequence]];
[[This is a shortcut for using link, when a linker is not required.]];
params = {
param.integer[[link - The cel to link to the sequence.]];
};
returns = {
param.sequence[[self]];
};
};
functiondef['sequence:remove(index)'] {
[[unlinks the cel at the given index.]];
[[If the index is invalid the sequence remains unmutated.]];
params = {
param.integer[[index - An array index.]];
};
returns = {
param.sequence[[self]];
};
};
functiondef['sequence:clear()'] {
[[effciently unlinks all cels from the sequence.]];
[[The sequence will be in flux for the duration of clear().]];
returns = {
param.sequence[[self]];
};
};
functiondef['sequence:len()'] {
[[returns number of cels in the sequence.]];
returns = {
param.integer[[The number of cels in the sequence.]];
};
};
functiondef['sequence:next(link)'] {
[[Get the cel which has an index that is 1 greater than the index of the given link in the sequence.]];
params = {
param.cel[[link - a cel linked to the sequence, if the cel is not in the sequence nil is returned.]];
};
returns = {
param.cel[[the link following the given link in the sequence, or nil]];
};
};
functiondef['sequence:prev(link)'] {
[[Get the cel which has an index that is 1 less than the index of the given link in the sequence.]];
params = {
param.cel[[link - a cel linked to the sequence, if the cel is not in the sequence nil is returned.]];
};
returns = {
param.cel[[the link preceding the given link in the sequence, or nil]];
};
};
functiondef['sequence:indexof(link)'] {
[[Get the array index of the given link in the sequence.]];
params = {
param.cel[[link - a cel linked to the sequence, if the cel is not in the sequence nil is returned.]];
};
returns = {
param.integer[[the array index of the given link in the sequence, or nil.]];
};
};
functiondef['sequence:flux(callback, ...)'] {
[[Puts the sequence into flux and calls the given function.]];
[[Before the function is called the sequence is reconciled, meaning that all links are in
sequence and the sequence dimensions are the minimum size such that no link is clipped by
the sequence. After the callback function returns the sequence is reconciled again.]];
params = {
param['function'][[callback - a callback function, it will be called as callback(...).]];
param['...'][[... - parameters passed to the callback function.]];
};
returns = {
param.sequence[[self]];
};
};
functiondef['sequence:beginflux([reconcile])'] {
[[Puts the sequence into flux.]];
[[When a sequence is in flux it will not automatically reconcile.]];
[[An equal number of calls to endflux are required to take the sequence out of flux.]];
params = {
param.boolean[[reconcile - If true the sequence is reconciled.]];
};
returns = {
param.sequence[[self]];
};
};
functiondef['sequence:endflux([reconcile])'] {
[[Takes a sequence out of flux and reconciles it.]];
[[An equal number of calls to beginflux/endflux are required to take the sequence out of flux.]];
params = {
param.boolean[[reconcile - If false the sequence will not be reconciled if it is still in flux.]];
};
returns = {
param.sequence[[self]];
};
};
functiondef['sequence:pick(x, y)'] {
[[Returns the link at the give xy coordinate in the sequence.]];
[[x is ignored for a vertical sequence, y is ignored for a horizontal sequence.]];
[[TODO document which link is picked when it falls on a gap]];
params = {
param.number[[x - For a horizontal sequence the x coordinate.]];
param.number[[y - For a vertical sequence the y coordinate..]];
};
returns = {
param.cel[[The link closest to the x coordinate for a horizontal sequence,
or closest to the y coordinate for a vertical sequence]];
};
};
functiondef['sequence:ilinks()'] {
[[Returns an iterator function and the sequence.]];
code[=[
for index, link in sequence:ilinks() do end
]=];
[[will iterate over each link in the sequence starting a the first link.]];
returns = {
param.iterator[[an iterator function]];
param.listbox[[the sequence, iterator function invariant state]];
};
};
functiondef['sort'] {
[[TODO]]
};
functiondef['swap'] {
[[TODO]]
};
functiondef['replace'] {
[[TODO]]
};
};
--[===[
metaceldef['sequence'] {
functions = {
functiondef['__describeslot'] {
[[TODO]]
};
}
};
--]===]
};
|
function onCreate()
makeLuaSprite('ready', 'ready', 0, 0)
makeLuaSprite('readyCL', 'readyCL', 0, 0)
scaleObject('ready', 0.6, 0.6)
scaleObject('readyCL', 0.6, 0.6)
screenCenter('ready', 'xy')
screenCenter('readyCL', 'xy')
addLuaSprite('ready', true)
addLuaSprite('readyCL', true)
setObjectCamera('ready', 'hud')
setObjectCamera('readyCL', 'hud')
setProperty('readyCL.visible', false)
doTweenX('RXS0', 'ready.scale', 0.65, 0.5, 'quadInOut')
doTweenY('RYS0', 'ready.scale', 0.65, 0.5, 'quadInOut')
end
local allowCountdown = false
function onStartCountdown()
if not allowCountdown then
setPropertyFromClass('flixel.FlxG', 'mouse.visible', true);
setProperty('boyfriend.stunned', true)
setProperty('botplayTxt.visible', false)
return Function_Stop
end
return Function_Continue
end
local pause = false
local esc = false
function onSongStart()
pause = true
setProperty('boyfriend.stunned', false)
if botplay then
setProperty('botplayTxt.visible', true)
end
end
local MR = false
function onUpdate(elapsed)
setProperty('readyCL.scale.x', getProperty('ready.scale.x') + 0.1)
setProperty('readyCL.scale.y', getProperty('ready.scale.y') + 0.1)
if not allowCountdown and (keyReleased('space') or getPropertyFromClass('flixel.FlxG', 'keys.justReleased.ENTER')) or (mouseReleased() and MR) and not startedCountdown then
allowCountdown = true
startCountdown()
playSound('clickText')
removeLuaSprite('ready', true)
removeLuaSprite('readyCL', true)
setPropertyFromClass('flixel.FlxG', 'mouse.visible', false);
end
if getPropertyFromClass('flixel.FlxG', 'keys.justReleased.ESCAPE') and not esc and pause then
esc = true
pause = false
endSong()
end
if getPropertyFromClass('flixel.FlxG', 'keys.justReleased.ESCAPE') and esc then
pause = false
endSong()
end
if getMouseX('hud') > getProperty('ready.x') and getMouseY('hud') > getProperty('ready.y') and getMouseX('hud') < getProperty('ready.x') + getProperty('ready.width') and getMouseY('hud') < getProperty('ready.y') + getProperty('ready.height') then
setProperty('ready.visible', false)
setProperty('readyCL.visible', true)
MR = true
else
setProperty('ready.visible', true)
setProperty('readyCL.visible', false)
MR = false
end
end
function onTweenCompleted(t)
if t == 'RXS0' then
doTweenX('RXS2', 'ready.scale', 0.6, 0.5, 'quadInOut')
doTweenY('RYS2', 'ready.scale', 0.6, 0.5, 'quadInOut')
elseif t == 'RXS2' then
doTweenX('RXS0', 'ready.scale', 0.65, 0.5, 'quadInOut')
doTweenY('RYS0', 'ready.scale', 0.65, 0.5, 'quadInOut')
end
end
function onPause()
if not pause then
return Function_Stop
end
if esc then
endSong()
end
return Function_Continue
end
|
_G.__MOCK_GMOD_CONVARS = {}
function _G.__MOCK_GMOD_RESET_CONVAR (id)
_G.__MOCK_GMOD_CONVARS [id] = nil
end
_G.__CONSOLE_PRINTER_NONE = true
return {
CreateConVar = function (id, default)
_G.__MOCK_GMOD_CONVARS [id] = _G.__MOCK_GMOD_CONVARS [id] or default
return {
GetString = function ()
if _G.__CONSOLE_PRINTER_NONE then return "NONE" end
return _G.__MOCK_GMOD_CONVARS [id]
end,
SetString = function (_, newVal)
_G.__MOCK_GMOD_CONVARS [id] = newVal
end
}
end,
Color = function (r, g, b, a)
return {
r = math.min (tonumber (r) or 0, 255),
g = math.min (tonumber (g) or 0, 255),
b = math.min (tonumber (b) or 0, 255),
a = math.min (tonumber (a) or 0, 255)
}
end,
unpack = table.unpack
}
|
--------------------------------------------------------------------------------
-- Login Server Settings -------------------------------------------------------
--------------------------------------------------------------------------------
require("ablogin")
log_dir = "c:/Users/Stefan Ascher/Documents/Visual Studio 2015/Projects/ABx/Bin/logs/ablogin"
|
--[[
Copyright 2012 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]
local fmt = require('string').format
local Error = require('core').Error
local ProtocolError = Error:extend()
function ProtocolError:initialize(msg)
Error.initialize(self, self.message)
self['original'] = msg
self['code'] = msg['code'] or 'unknown'
self['type'] = msg['type'] or 'unknown'
self['msg'] = msg['message'] or 'no message'
self.message = fmt('%s error: code=%s, message=%s',
self['type'], self['code'], self['msg'])
end
local VersionError = Error:extend()
function VersionError:initialize(msg, resp)
Error.initialize(self)
self.message = fmt(
'Version mismatch: message_version=%s response_version=%s',
msg.v or 'unknown',
resp.v or 'unknown')
end
local InvalidMethodError = Error:extend()
function InvalidMethodError:initialize(method)
Error.initialize(self)
self.message = fmt('invalid method method=%s', method)
self.method = method
end
local exports = {}
exports.ProtocolError = ProtocolError
exports.VersionError = VersionError
exports.InvalidMethodError = InvalidMethodError
return exports
|
--------------------------------
-- @module Scale9Sprite
-- @extend Sprite
-- @parent_module ccui
--------------------------------
-- @overload self, cc.Sprite, rect_table, bool, vec2_table, size_table, rect_table
-- @overload self, cc.Sprite, rect_table, bool, rect_table
-- @function [parent=#Scale9Sprite] updateWithSprite
-- @param self
-- @param #cc.Sprite sprite
-- @param #rect_table rect
-- @param #bool rotated
-- @param #vec2_table offset
-- @param #size_table originalSize
-- @param #rect_table capInsets
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Creates and returns a new sprite object with the specified cap insets.<br>
-- You use this method to add cap insets to a sprite or to change the existing<br>
-- cap insets of a sprite. In both cases, you get back a new image and the<br>
-- original sprite remains untouched.<br>
-- param capInsets The values to use for the cap insets.<br>
-- return A Scale9Sprite instance.
-- @function [parent=#Scale9Sprite] resizableSpriteWithCapInsets
-- @param self
-- @param #rect_table capInsets
-- @return Scale9Sprite#Scale9Sprite ret (return value: ccui.Scale9Sprite)
--------------------------------
-- Returns the Cap Insets
-- @function [parent=#Scale9Sprite] getCapInsets
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- Change the state of 9-slice sprite.<br>
-- see `State`<br>
-- param state A enum value in State.<br>
-- since v3.4
-- @function [parent=#Scale9Sprite] setState
-- @param self
-- @param #int state
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- brief Change the bottom sprite's cap inset.<br>
-- param bottomInset The values to use for the cap inset.
-- @function [parent=#Scale9Sprite] setInsetBottom
-- @param self
-- @param #float bottomInset
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- Initializes a 9-slice sprite with an sprite frame name and with the specified<br>
-- cap insets.<br>
-- Once the sprite is created, you can then call its "setContentSize:" method<br>
-- to resize the sprite will all it's 9-slice goodness interact.<br>
-- It respects the anchorPoint too.<br>
-- param spriteFrameName The sprite frame name.<br>
-- param capInsets The values to use for the cap insets.<br>
-- return True if initializes success, false otherwise.
-- @function [parent=#Scale9Sprite] initWithSpriteFrameName
-- @param self
-- @param #string spriteFrameName
-- @param #rect_table capInsets
-- @return bool#bool ret (return value: bool)
--------------------------------
-- brief Get the original no 9-sliced sprite<br>
-- return A sprite instance.
-- @function [parent=#Scale9Sprite] getSprite
-- @param self
-- @return Sprite#Sprite ret (return value: cc.Sprite)
--------------------------------
-- brief Change the top sprite's cap inset.<br>
-- param topInset The values to use for the cap inset.
-- @function [parent=#Scale9Sprite] setInsetTop
-- @param self
-- @param #float topInset
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- Set the slice sprite rendering type.<br>
-- When setting to SIMPLE, only 4 vertexes is used to rendering.<br>
-- otherwise 16 vertexes will be used to rendering.<br>
-- see RenderingType
-- @function [parent=#Scale9Sprite] setRenderingType
-- @param self
-- @param #int type
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- @overload self, cc.Sprite, rect_table, rect_table
-- @overload self, cc.Sprite, rect_table, bool, rect_table
-- @overload self, cc.Sprite, rect_table, bool, vec2_table, size_table, rect_table
-- @function [parent=#Scale9Sprite] init
-- @param self
-- @param #cc.Sprite sprite
-- @param #rect_table rect
-- @param #bool rotated
-- @param #vec2_table offset
-- @param #size_table originalSize
-- @param #rect_table capInsets
-- @return bool#bool ret (return value: bool)
--------------------------------
-- brief Change the preferred size of Scale9Sprite.<br>
-- param size A delimitation zone.
-- @function [parent=#Scale9Sprite] setPreferredSize
-- @param self
-- @param #size_table size
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- brief copies self to copy
-- @function [parent=#Scale9Sprite] copyTo
-- @param self
-- @param #ccui.Scale9Sprite copy
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- brief Change inner sprite's sprite frame.<br>
-- param spriteFrame A sprite frame pointer.<br>
-- param capInsets The values to use for the cap insets.
-- @function [parent=#Scale9Sprite] setSpriteFrame
-- @param self
-- @param #cc.SpriteFrame spriteFrame
-- @param #rect_table capInsets
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- Query the current bright state.<br>
-- return @see `State`<br>
-- since v3.7
-- @function [parent=#Scale9Sprite] getState
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- brief Query the bottom sprite's cap inset.<br>
-- return The bottom sprite's cap inset.
-- @function [parent=#Scale9Sprite] getInsetBottom
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- brief Toggle 9-slice feature.<br>
-- If Scale9Sprite is 9-slice disabled, the Scale9Sprite will rendered as a normal sprite.<br>
-- warning: Don't use setScale9Enabled(false), use setRenderingType(RenderingType::SIMPLE) instead.<br>
-- The setScale9Enabled(false) is kept only for back back compatibility.<br>
-- param enabled True to enable 9-slice, false otherwise.<br>
-- js NA
-- @function [parent=#Scale9Sprite] setScale9Enabled
-- @param self
-- @param #bool enabled
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- brief Query whether the Scale9Sprite is enable 9-slice or not.<br>
-- return True if 9-slice is enabled, false otherwise.<br>
-- js NA
-- @function [parent=#Scale9Sprite] isScale9Enabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#Scale9Sprite] resetRender
-- @param self
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- Return the slice sprite rendering type.
-- @function [parent=#Scale9Sprite] getRenderingType
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- brief Query the right sprite's cap inset.<br>
-- return The right sprite's cap inset.
-- @function [parent=#Scale9Sprite] getInsetRight
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- brief Query the sprite's original size.<br>
-- return Sprite size.
-- @function [parent=#Scale9Sprite] getOriginalSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @overload self, rect_table, string
-- @overload self, string, rect_table, rect_table
-- @function [parent=#Scale9Sprite] initWithFile
-- @param self
-- @param #string file
-- @param #rect_table rect
-- @param #rect_table capInsets
-- @return bool#bool ret (return value: bool)
--------------------------------
-- brief Query the top sprite's cap inset.<br>
-- return The top sprite's cap inset.
-- @function [parent=#Scale9Sprite] getInsetTop
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- brief Change the left sprite's cap inset.<br>
-- param leftInset The values to use for the cap inset.
-- @function [parent=#Scale9Sprite] setInsetLeft
-- @param self
-- @param #float leftInset
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- Initializes a 9-slice sprite with an sprite frame and with the specified<br>
-- cap insets.<br>
-- Once the sprite is created, you can then call its "setContentSize:" method<br>
-- to resize the sprite will all it's 9-slice goodness interact.<br>
-- It respects the anchorPoint too.<br>
-- param spriteFrame The sprite frame object.<br>
-- param capInsets The values to use for the cap insets.<br>
-- return True if initializes success, false otherwise.
-- @function [parent=#Scale9Sprite] initWithSpriteFrame
-- @param self
-- @param #cc.SpriteFrame spriteFrame
-- @param #rect_table capInsets
-- @return bool#bool ret (return value: bool)
--------------------------------
-- brief Query the Scale9Sprite's preferred size.<br>
-- return Scale9Sprite's preferred size.
-- @function [parent=#Scale9Sprite] getPreferredSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- Set the Cap Insets in Points using the untrimmed size as reference
-- @function [parent=#Scale9Sprite] setCapInsets
-- @param self
-- @param #rect_table insets
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- brief Query the left sprite's cap inset.<br>
-- return The left sprite's cap inset.
-- @function [parent=#Scale9Sprite] getInsetLeft
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- brief Change the right sprite's cap inset.<br>
-- param rightInset The values to use for the cap inset.
-- @function [parent=#Scale9Sprite] setInsetRight
-- @param self
-- @param #float rightInset
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
--------------------------------
-- @overload self, string, rect_table, rect_table
-- @overload self
-- @overload self, rect_table, string
-- @overload self, string, rect_table
-- @overload self, string
-- @function [parent=#Scale9Sprite] create
-- @param self
-- @param #string file
-- @param #rect_table rect
-- @param #rect_table capInsets
-- @return Scale9Sprite#Scale9Sprite ret (return value: ccui.Scale9Sprite)
--------------------------------
-- @overload self, string, rect_table
-- @overload self, string
-- @function [parent=#Scale9Sprite] createWithSpriteFrameName
-- @param self
-- @param #string spriteFrameName
-- @param #rect_table capInsets
-- @return Scale9Sprite#Scale9Sprite ret (return value: ccui.Scale9Sprite)
--------------------------------
-- @overload self, cc.SpriteFrame, rect_table
-- @overload self, cc.SpriteFrame
-- @function [parent=#Scale9Sprite] createWithSpriteFrame
-- @param self
-- @param #cc.SpriteFrame spriteFrame
-- @param #rect_table capInsets
-- @return Scale9Sprite#Scale9Sprite ret (return value: ccui.Scale9Sprite)
--------------------------------
-- Initializes a 9-slice sprite with an sprite frame name.<br>
-- Once the sprite is created, you can then call its "setContentSize:" method<br>
-- to resize the sprite will all it's 9-slice goodness interact.<br>
-- It respects the anchorPoint too.<br>
-- param spriteFrameName The sprite frame name.<br>
-- return True if initializes success, false otherwise.
-- @function [parent=#Scale9Sprite] initWithSpriteFrameName
-- @param self
-- @param #string spriteFrameName
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @overload self, string
-- @overload self, string, rect_table
-- @function [parent=#Scale9Sprite] initWithFile
-- @param self
-- @param #string file
-- @param #rect_table rect
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#Scale9Sprite] init
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Default constructor.<br>
-- js ctor<br>
-- lua new
-- @function [parent=#Scale9Sprite] Scale9Sprite
-- @param self
-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite)
return nil
|
local util = require("__bzzirconium__.data-util");
local nuclear_plate = mods.bzlead and "lead-plate" or "iron-plate"
util.replace_some_ingredient("stone-furnace", "stone", 1, "zircon", 1)
if not mods["Krastorio2"] then
util.replace_some_ingredient("steel-furnace", "stone-brick", 4, "zircon", 6)
util.replace_some_ingredient("electric-furnace", "stone-brick", 5, "zirconia", 5)
end
if mods["Krastorio2"] then
util.replace_some_ingredient("low-density-structure", "copper-plate", 5, "zirconia", 5)
else
util.replace_some_ingredient("low-density-structure", "copper-plate", 10, "zirconia", 10)
end
util.add_ingredient("explosives", "zirconium-plate", 1)
util.add_ingredient("nuclear-reactor", "zirconium-plate", 100)
local ufc_amt = mods["Krastorio2"] and 1 or 5
util.replace_some_ingredient("uranium-fuel-cell", nuclear_plate, 5, "zirconium-plate", ufc_amt)
if not mods.bztungsten then
util.add_ingredient("nuclear-fuel", "zirconium-plate", 1)
end
util.add_ingredient("rocket-engine-nozzle", "zirconia", 1)
util.add_to_product("rocket-engine-nozzle", "rocket-engine-nozzle", 1)
util.add_time("rocket-engine-nozzle", 5)
if util.me.use_cermet() then
util.add_ingredient("rocket-control-unit", "cermet", 1)
util.add_ingredient("speed-module-3", "cermet", 1)
util.add_ingredient("productivity-module-3", "cermet", 1)
util.add_ingredient("effectivity-module-3", "cermet", 1)
util.add_ingredient("beacon", "cermet", 10)
util.add_ingredient("spidertron", "cermet", 8)
if not util.fe_plus("Machines") then
util.add_ingredient("assembling-machine-3", "cermet", 2)
else
util.add_ingredient("assembling-machine-4", "cermet", 2)
util.add_ingredient("assembling-machine-5", "cermet", 2)
util.add_ingredient("chemical-plant-mk3", "cermet", 2)
util.add_ingredient("oil-refinery-mk3", "cermet", 4)
end
end
-- More FE+
if util.fe_plus("Machines") then
util.add_ingredient("electric-furnace-mk2", "zirconia", 10)
util.add_ingredient("electric-furnace-mk3", "zirconia", 10)
util.add_ingredient("oil-refinery-mk2", "zirconia", 10)
util.add_ingredient("pumpjack-mk2", "zirconia", 10)
end
-- Krastorio2
if mods["Krastorio2"] then
util.replace_some_ingredient("matter-stabilizer", "imersium-plate", 1, "zirconium-plate", 5)
util.add_ingredient("kr-advanced-furnace", "zirconia", 60)
if util.me.use_cermet() then
util.add_ingredient("ai-core", "cermet", 2)
util.add_ingredient("kr-matter-assembler", "cermet", 4)
end
util.replace_some_ingredient("stone-brick", "stone", 5, "zircon", 5)
if mods["space-exploration"] then
util.replace_some_ingredient("se-stone-brick-vulcanite", "stone", 2, "zircon", 2)
end
if not mods.bztungsten then
util.add_ingredient("matter-research-data", "zirconia", 5)
end
end
-- Space Exploration
if mods["space-exploration"] then
util.replace_some_ingredient("se-aeroframe-scaffold", "se-aeroframe-pole", 1, "zirconia", 2)
util.replace_some_ingredient("se-heat-shielding", "stone-tablet", 10, "zirconia", 10)
util.replace_ingredient("se-heat-shielding-iridium", "stone-tablet", "zirconia")
util.add_ingredient("se-thruster-suit", "zirconium-plate", 10)
util.add_ingredient("se-space-thermodynamics-laboratory", "zirconium-plate", 20)
if util.me.use_cermet() then
util.add_ingredient("se-quantum-processor", "cermet", 1)
util.add_ingredient("se-space-mechanical-laboratory", "cermet", 40)
end
if not mods.bztungsten then
util.add_ingredient("se-hot-thermodynamics-data", "zirconium-plate", 1)
util.add_product("se-hot-thermodynamics-data", {name="zirconium-plate", amount=1, probability=0.50})
end
util.add_ingredient("se-experimental-alloys-data", "zirconium-plate", 1)
util.add_to_product("se-experimental-alloys-data", "se-experimental-alloys-data", 1)
util.add_to_product("se-experimental-alloys-data", "se-scrap", 1)
util.add_to_ingredient("se-experimental-alloys-data", "se-empty-data", 1)
end
-- AAI
util.add_ingredient("industrial-furnace", "zirconium-plate", 4)
-- Aircraft
util.add_ingredient("gunship", "zirconia", 10)
util.add_ingredient("cargo-plane", "zirconia", 20)
util.add_ingredient("jet", "zirconia", 50)
util.add_ingredient("flying-fortress", "zirconia", 80)
util.add_ingredient("aircraft-afterburner", "zirconia", 5)
util.add_ingredient("mega-furnace", "zirconia", 5)
util.add_ingredient("nuclear-furnace-4", "zirconia", 400)
util.add_ingredient("nuclear-furnace-5", "zirconium-plate", 400)
util.replace_some_ingredient("breeder-fuel-cell", nuclear_plate, 5, "zirconium-plate", 5)
util.replace_some_ingredient("mox-fuel-cell", nuclear_plate, 5, "zirconium-plate", 5)
util.replace_some_ingredient("MOX-fuel", nuclear_plate, 5, "zirconium-plate", 5)
util.add_ingredient("advanced-electric-furnace-rampant-industry", "zirconia", 50)
-- Realistic Reactors
util.add_ingredient("realistic-reactor", "zirconium-plate", 100)
util.add_ingredient("breeder-reactor", "zirconium-plate", 100)
-- Plutonium Energy
util.add_ingredient("MOX-reactor", "zirconium-plate", 400)
-- Schall
util.add_ingredient("Schall-radioactive-waste-incinerator", "zirconia", 25)
-- RITEG
util.add_ingredient("RITEG-1", "zirconium-plate", 10)
util.add_ingredient("RITEG-cyan", "zirconium-plate", 10)
util.add_ingredient("RITEG-breeder", "zirconium-plate", 10)
-- Nixie tubes
util.add_ingredient("nixie-tube", "zirconium-plate", 1)
util.add_ingredient("nixie-tube-alpha", "zirconium-plate", 1)
util.add_ingredient("nixie-tube-small", "zirconium-plate", 1)
util.add_ingredient("SNTD-old-nixie-tube", "zirconium-plate", 1)
util.add_ingredient("SNTD-nixie-tube", "zirconium-plate", 1)
util.add_ingredient("SNTD-nixie-tube-small", "zirconium-plate", 1)
-- RFP
util.add_ingredient("rfp-reactor", "zirconium-plate", 1000)
util.add_ingredient("rfp-reactor", "zirconia", 1000)
util.add_ingredient("rfp-aneutronic-reactor", "zirconium-plate", 5000)
util.add_ingredient("rfp-particle-accelerator", "zirconium-plate", 1000)
util.add_ingredient("rfp-particle-decelerator", "zirconium-plate", 1000)
util.replace_some_ingredient("rfp-matter-antimatter-fuel-cell-empty", "steel-plate", 10, "zirconium-plate", 10)
-- Cermet in other mods
if util.me.use_cermet() then
util.add_ingredient("advanced-assembler-rampant-industry", "cermet", 30)
util.add_ingredient("advanced-electric-furnace-rampant-industry", "cermet", 30)
util.add_ingredient("advanced-oil-refinery-rampant-industry", "cermet", 30)
if mods["modules-t4"] then
util.add_ingredient("speed-module-4", "cermet", 6)
util.add_ingredient("productivity-module-4", "cermet", 6)
util.add_ingredient("effectivity-module-4", "cermet", 6)
end
-- Various assemblers
if mods["zombiesextended-core"] then
util.add_ingredient("assembling-machine-mk1", "cermet", 1)
util.add_ingredient("assembling-machine-mk2", "cermet", 1)
util.add_ingredient("assembling-machine-mk3", "cermet", 1)
end
-- Bob's machines
util.add_ingredient("chemical-plant-3", "cermet", 2)
util.add_ingredient("chemical-plant-4", "cermet", 2)
util.add_ingredient("assembling-machine-4", "cermet", 3)
util.add_ingredient("assembling-machine-5", "cermet", 4)
util.add_ingredient("assembling-machine-6", "cermet", 5)
util.add_ingredient("oil-refinery-3", "cermet", 10)
util.add_ingredient("oil-refinery-4", "cermet", 10)
util.add_ingredient("bob-mining-drill-4", "cermet", 5)
util.add_ingredient("bob-area-mining-drill-4", "cermet", 5)
end
-- Bob's - bobplates
util.replace_some_ingredient("plutonium-fuel-cell", nuclear_plate, 5, "zirconium-plate", 5)
-- True nukes
util.replace_some_ingredient("tritium-breeder-fuel-cell", nuclear_plate, 5, "zirconium-plate", 5)
-- Hazmat suit
util.replace_some_ingredient("mil-grade-fuel-cell", nuclear_plate, 5, "zirconium-plate", 5)
-- Power Armor Mk3
util.add_ingredient("pamk3-battmk3", "zirconium-plate", 5)
util.add_ingredient("pamk3-pamk4", "zirconium-plate", 10)
|
function onCastSpell(creature, variant)
return creature:conjureItem(2389, 7367, 1, CONST_ME_MAGIC_GREEN)
end
|
--[[
sh_chatmessage.lua
MrGrimm
Utility to allow sending/broadcasting messages
with the use of colors, etc.
--]]
if SERVER then
util.AddNetworkString( "ChatMessage" )
local Player = FindMetaTable( "Player" )
--[[------------------------------------------------
Name: Broadcast()
Desc: Sends a message to all players.
--]]------------------------------------------------
function util.Broadcast(...)
local args = {...}
net.Start( "ChatMessage" )
net.WriteTable( args )
net.Broadcast()
end
--[[------------------------------------------------
Name: PlayerMsg()
Desc: Sends a message to a single player.
--]]------------------------------------------------
function Player:PlayerMsg(...)
local args = {...}
net.Start( "ChatMessage" )
net.WriteTable( args )
net.Send( self )
end
else -- CLIENT
net.Receive( "ChatMessage", function( len )
local msg = net.ReadTable()
chat.AddText( unpack( msg ) )
end)
end
|
-- For a full example, see the original library's readme.
-- https://github.com/Quenty/NevermoreEngine/tree/version2/Modules/Server/DataStore
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local DataStoreService = require(ServerStorage.DataStoreService)
local Janitor = require(ReplicatedStorage.Janitor)
local PlayerDataStoreManager = require(ServerStorage.PlayerDataStoreManager)
local dataStoreManager = PlayerDataStoreManager.new(
DataStoreService:GetDataStore("PlayerData"), -- Load the base Roblox store however you want
function(player: Player)
return tostring(player.UserId)
end
)
local playerJanitors: {[Player]: any} = {}
local function loadStats(playerJanitor, mainStore)
local leaderboard = Instance.new("Folder")
leaderboard.Name = "leaderstats"
local moneyValue = Instance.new("IntValue")
moneyValue.Name = "Money"
moneyValue.Parent = leaderboard
playerJanitor:AddPromise(mainStore:Load("money", 0)):andThen(function(money)
moneyValue.Value = money
playerJanitor:Add(mainStore:StoreOnValueChange("money", moneyValue), "Disconnect")
end):catch(function(problem)
warn("Failed to load", tostring(problem))
end):finally(function()
moneyValue.Value += 10
end)
return leaderboard
end
local function playerAdded(player: Player)
local playerJanitor = Janitor.new()
playerJanitors[player] = playerJanitor
local dataStore = dataStoreManager:GetDataStore(player)
local mainStore = dataStore:GetSubStore("MainStore")
local leaderboard = loadStats(playerJanitor, mainStore)
leaderboard.Parent = player
end
local function playerRemoving(player: Player)
local playerJanitor = playerJanitors[player]
if playerJanitor then
playerJanitors[player] = playerJanitor:Destroy()
end
end
Players.PlayerAdded:Connect(playerAdded)
Players.PlayerRemoving:Connect(playerRemoving)
for _, player in ipairs(Players:GetPlayers()) do
if playerJanitors[player] then
continue
end
playerAdded(player)
end
|
fx_version "adamant"
games {"rdr3"}
rdr3_warning "I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships."
client_scripts {
"@_core/lib/utils.lua",
"@_core/config/Items.lua",
"client.lua",
"client_drop.lua"
}
server_scripts {
"@_core/lib/utils.lua",
"server.lua"
}
ui_page "nui/index.html"
files {
"nui/fonts/*",
"nui/*",
"nui/images/*",
"nui/images/items/*"
}
|
include("terms")
style =
{["off_color"] = "fff",
["on_color"] = "fff",
["line_color"] = "00f",
["line_width"] = "3"};
inter_style =
{["off_color"] = "fff",
["on_color"] = "f30",
["line_color"] = "000",
["line_width"] = "2"};
out_style =
{["off_color"] = "fff",
["on_color"] = "0cf",
["line_color"] = "000",
["line_width"] = "2"};
include("shapes")
ind = math.random(2)
position = place[ind]
mycanvas = function()
if (ind == 1) then
results = "result[0] == 1 && result[1] == 0 && result[2] == 1 && result[3] == 0"
else
results = "result[0] == 0 && result[1] == 1 && result[2] == 0 && result[3] == 1"
end
scale = 1
lib.start_canvas(350, 250, "center", results)
lib.add_ellipse(150, 100, 120, 80, style, false, false)
lib.add_triangle(180, 80, 70, 50, inter_style, false, true)
lib.add_rectangle(60, 190, 80, 30, out_style, false, true)
diamond(lib, 90, 120, scale, inter_style, false, true)
cross(lib, 250, 170, scale, out_style, false, true)
lib.end_canvas()
end
|
local checktype = SF.CheckType
local checkluatype = SF.CheckLuaType
local checkpermission = SF.Permissions.check
-------------------------------------------------------------------------------
-- Vehicle functions.
-------------------------------------------------------------------------------
SF.Vehicles = {}
--- Vehicle type
local vehicle_methods, vehicle_metamethods = SF.RegisterType("Vehicle")
SF.Vehicles.Methods = vehicle_methods
SF.Vehicles.Metatable = vehicle_metamethods
local wrap, unwrap, pwrap
SF.AddHook("postload", function()
pwrap = SF.Players.Wrap
SF.ApplyTypeDependencies(vehicle_methods, vehicle_metamethods, SF.Entities.Metatable)
wrap, unwrap = SF.CreateWrapper(vehicle_metamethods, true, false, debug.getregistry().Vehicle, SF.Entities.Metatable)
SF.Vehicles.Wrap = wrap
SF.Vehicles.Unwrap = unwrap
end)
--- To string
-- @shared
function vehicle_metamethods:__tostring()
local ent = unwrap(self)
if not ent then return "(null entity)"
else return tostring(ent) end
end
if SERVER then
-- Register privileges
local P = SF.Permissions
P.registerPrivilege("vehicle.eject", "Vehicle eject", "Removes a driver from vehicle", { entities = {} })
P.registerPrivilege("vehicle.kill", "Vehicle kill", "Kills a driver in vehicle", { entities = {} })
P.registerPrivilege("vehicle.strip", "Vehicle strip", "Strips weapons from a driver in vehicle", { entities = {} })
P.registerPrivilege("vehicle.lock", "Vehicle lock", "Allow vehicle locking/unlocking", { entities = {} })
--- Returns the driver of the vehicle
-- @server
-- @return Driver of vehicle
function vehicle_methods:getDriver ()
checktype(self, vehicle_metamethods)
local ent = unwrap(self)
if not (ent and ent:IsValid()) then SF.Throw("Invalid entity", 2) end
return pwrap(ent:GetDriver())
end
--- Ejects the driver of the vehicle
-- @server
function vehicle_methods:ejectDriver ()
checktype(self, vehicle_metamethods)
local ent = unwrap(self)
if not (ent and ent:IsValid()) then SF.Throw("Invalid entity", 2) end
local driver = ent:GetDriver()
if driver:IsValid() then
driver:ExitVehicle()
end
end
--- Returns a passenger of a vehicle
-- @server
-- @param n The index of the passenger to get
-- @return The passenger or NULL if empty
function vehicle_methods:getPassenger (n)
checktype(self, vehicle_metamethods)
checkluatype(n, TYPE_NUMBER)
local ent = unwrap(self)
if not (ent and ent:IsValid()) then SF.Throw("Invalid entity", 2) end
return pwrap(ent:GetPassenger(n))
end
--- Kills the driver of the vehicle
-- @server
function vehicle_methods:killDriver ()
checktype(self, vehicle_metamethods)
local ent = unwrap(self)
if not (ent and ent:IsValid()) then SF.Throw("Invalid entity", 2) end
checkpermission(SF.instance, ent, "vehicle.kill")
local driver = ent:GetDriver()
if driver:IsValid() then
driver:Kill()
end
end
--- Strips weapons of the driver
-- @param class Optional weapon class to strip. Otherwise all are stripped.
-- @server
function vehicle_methods:stripDriver (class)
checktype(self, vehicle_metamethods)
if class ~= nil then checkluatype(class, TYPE_STRING) end
local ent = unwrap(self)
if not (ent and ent:IsValid()) then SF.Throw("Invalid entity", 2) end
checkpermission(SF.instance, ent, "vehicle.strip")
local driver = ent:GetDriver()
if driver:IsValid() then
if class then
driver:StripWeapon(class)
else
driver:StripWeapons()
end
end
end
--- Will lock the vehicle preventing players from entering or exiting the vehicle.
-- @server
function vehicle_methods:lock()
checktype(self, vehicle_metamethods)
local ent = unwrap(self)
if not (ent and ent:IsValid()) then SF.Throw("Invalid entity", 2) end
checkpermission(SF.instance, ent, "vehicle.lock")
local n = "SF_CanExitVehicle"..ent:EntIndex()
hook.Add("CanExitVehicle", n, function(v) if v==ent then return false end end)
ent:CallOnRemove(n, function() hook.Remove("CanExitVehicle", n) end)
ent:Fire("Lock")
end
--- Will unlock the vehicle.
-- @server
function vehicle_methods:unlock()
checktype(self, vehicle_metamethods)
local ent = unwrap(self)
if not (ent and ent:IsValid()) then SF.Throw("Invalid entity", 2) end
checkpermission(SF.instance, ent, "vehicle.lock")
hook.Remove("CanExitVehicle", "SF_CanExitVehicle"..ent:EntIndex())
ent:Fire("Unlock")
end
end
|
--[[
Module:Rectangle
Author:DylanYang
Time:2021-01-26 19:22:00
]]
local interface = require("patterns.creational.factory.Shape")
local _M = Class("Rectangle", interface)
local public = _M.public
function public:Draw()
print(string.format("Factory Test: I'm a %s%s !", self.__name, "(矩形)"))
end
return _M
|
--[[
Multicolor Awesome WM theme 2.0
github.com/lcpz
--]]
local gears = require("gears")
local lain = require("lain")
local awful = require("awful")
local wibox = require("wibox")
local os = os
local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility
local theme = {}
theme.confdir = os.getenv("HOME") .. "/.config/awesome/themes/multicolor"
theme.wallpaper = theme.confdir .. "/wall.png"
theme.font = "xos4 Terminus 8"
theme.menu_bg_normal = "#000000"
theme.menu_bg_focus = "#000000"
theme.bg_normal = "#000000"
theme.bg_focus = "#000000"
theme.bg_urgent = "#000000"
theme.fg_normal = "#aaaaaa"
theme.fg_focus = "#ff8c00"
theme.fg_urgent = "#af1d18"
theme.fg_minimize = "#ffffff"
theme.border_width = 1
theme.border_normal = "#1c2022"
theme.border_focus = "#606060"
theme.border_marked = "#3ca4d8"
theme.menu_border_width = 0
theme.menu_width = 130
theme.menu_submenu_icon = theme.confdir .. "/icons/submenu.png"
theme.menu_fg_normal = "#aaaaaa"
theme.menu_fg_focus = "#ff8c00"
theme.menu_bg_normal = "#050505dd"
theme.menu_bg_focus = "#050505dd"
theme.widget_temp = theme.confdir .. "/icons/temp.png"
theme.widget_uptime = theme.confdir .. "/icons/ac.png"
theme.widget_cpu = theme.confdir .. "/icons/cpu.png"
theme.widget_weather = theme.confdir .. "/icons/dish.png"
theme.widget_fs = theme.confdir .. "/icons/fs.png"
theme.widget_mem = theme.confdir .. "/icons/mem.png"
theme.widget_note = theme.confdir .. "/icons/note.png"
theme.widget_note_on = theme.confdir .. "/icons/note_on.png"
theme.widget_netdown = theme.confdir .. "/icons/net_down.png"
theme.widget_netup = theme.confdir .. "/icons/net_up.png"
theme.widget_mail = theme.confdir .. "/icons/mail.png"
theme.widget_batt = theme.confdir .. "/icons/bat.png"
theme.widget_clock = theme.confdir .. "/icons/clock.png"
theme.widget_vol = theme.confdir .. "/icons/spkr.png"
theme.taglist_squares_sel = theme.confdir .. "/icons/square_a.png"
theme.taglist_squares_unsel = theme.confdir .. "/icons/square_b.png"
theme.tasklist_plain_task_name = true
theme.tasklist_disable_icon = true
theme.useless_gap = 0
theme.layout_tile = theme.confdir .. "/icons/tile.png"
theme.layout_tilegaps = theme.confdir .. "/icons/tilegaps.png"
theme.layout_tileleft = theme.confdir .. "/icons/tileleft.png"
theme.layout_tilebottom = theme.confdir .. "/icons/tilebottom.png"
theme.layout_tiletop = theme.confdir .. "/icons/tiletop.png"
theme.layout_fairv = theme.confdir .. "/icons/fairv.png"
theme.layout_fairh = theme.confdir .. "/icons/fairh.png"
theme.layout_spiral = theme.confdir .. "/icons/spiral.png"
theme.layout_dwindle = theme.confdir .. "/icons/dwindle.png"
theme.layout_max = theme.confdir .. "/icons/max.png"
theme.layout_fullscreen = theme.confdir .. "/icons/fullscreen.png"
theme.layout_magnifier = theme.confdir .. "/icons/magnifier.png"
theme.layout_floating = theme.confdir .. "/icons/floating.png"
theme.titlebar_close_button_normal = theme.confdir .. "/icons/titlebar/close_normal.png"
theme.titlebar_close_button_focus = theme.confdir .. "/icons/titlebar/close_focus.png"
theme.titlebar_minimize_button_normal = theme.confdir .. "/icons/titlebar/minimize_normal.png"
theme.titlebar_minimize_button_focus = theme.confdir .. "/icons/titlebar/minimize_focus.png"
theme.titlebar_ontop_button_normal_inactive = theme.confdir .. "/icons/titlebar/ontop_normal_inactive.png"
theme.titlebar_ontop_button_focus_inactive = theme.confdir .. "/icons/titlebar/ontop_focus_inactive.png"
theme.titlebar_ontop_button_normal_active = theme.confdir .. "/icons/titlebar/ontop_normal_active.png"
theme.titlebar_ontop_button_focus_active = theme.confdir .. "/icons/titlebar/ontop_focus_active.png"
theme.titlebar_sticky_button_normal_inactive = theme.confdir .. "/icons/titlebar/sticky_normal_inactive.png"
theme.titlebar_sticky_button_focus_inactive = theme.confdir .. "/icons/titlebar/sticky_focus_inactive.png"
theme.titlebar_sticky_button_normal_active = theme.confdir .. "/icons/titlebar/sticky_normal_active.png"
theme.titlebar_sticky_button_focus_active = theme.confdir .. "/icons/titlebar/sticky_focus_active.png"
theme.titlebar_floating_button_normal_inactive = theme.confdir .. "/icons/titlebar/floating_normal_inactive.png"
theme.titlebar_floating_button_focus_inactive = theme.confdir .. "/icons/titlebar/floating_focus_inactive.png"
theme.titlebar_floating_button_normal_active = theme.confdir .. "/icons/titlebar/floating_normal_active.png"
theme.titlebar_floating_button_focus_active = theme.confdir .. "/icons/titlebar/floating_focus_active.png"
theme.titlebar_maximized_button_normal_inactive = theme.confdir .. "/icons/titlebar/maximized_normal_inactive.png"
theme.titlebar_maximized_button_focus_inactive = theme.confdir .. "/icons/titlebar/maximized_focus_inactive.png"
theme.titlebar_maximized_button_normal_active = theme.confdir .. "/icons/titlebar/maximized_normal_active.png"
theme.titlebar_maximized_button_focus_active = theme.confdir .. "/icons/titlebar/maximized_focus_active.png"
local markup = lain.util.markup
-- Textclock
os.setlocale(os.getenv("LANG")) -- to localize the clock
local clockicon = wibox.widget.imagebox(theme.widget_clock)
local mytextclock = wibox.widget.textclock(markup("#7788af", "%A %d %B ") .. markup("#ab7367", ">") .. markup("#de5e1e", " %H:%M "))
mytextclock.font = theme.font
-- Calendar
theme.cal = lain.widget.cal({
attach_to = { mytextclock },
notification_preset = {
font = "xos4 Terminus 10",
fg = theme.fg_normal,
bg = theme.bg_normal
}
})
-- Weather
local weathericon = wibox.widget.imagebox(theme.widget_weather)
theme.weather = lain.widget.weather({
city_id = 2643743, -- placeholder (London)
notification_preset = { font = "xos4 Terminus 10", fg = theme.fg_normal },
weather_na_markup = markup.fontfg(theme.font, "#eca4c4", "N/A "),
settings = function()
descr = weather_now["weather"][1]["description"]:lower()
units = math.floor(weather_now["main"]["temp"])
widget:set_markup(markup.fontfg(theme.font, "#eca4c4", descr .. " @ " .. units .. "°C "))
end
})
-- / fs
--[[ commented because it needs Gio/Glib >= 2.54
local fsicon = wibox.widget.imagebox(theme.widget_fs)
theme.fs = lain.widget.fs({
notification_preset = { font = "xos4 Terminus 10", fg = theme.fg_normal },
settings = function()
widget:set_markup(markup.fontfg(theme.font, "#80d9d8", string.format("%.1f", fs_now["/"].used) .. "% "))
end
})
--]]
-- Mail IMAP check
--[[ commented because it needs to be set before use
local mailicon = wibox.widget.imagebox()
theme.mail = lain.widget.imap({
timeout = 180,
server = "server",
mail = "mail",
password = "keyring get mail",
settings = function()
if mailcount > 0 then
mailicon:set_image(theme.widget_mail)
widget:set_markup(markup.fontfg(theme.font, "#cccccc", mailcount .. " "))
else
widget:set_text("")
--mailicon:set_image() -- not working in 4.0
mailicon._private.image = nil
mailicon:emit_signal("widget::redraw_needed")
mailicon:emit_signal("widget::layout_changed")
end
end
})
--]]
-- CPU
local cpuicon = wibox.widget.imagebox(theme.widget_cpu)
local cpu = lain.widget.cpu({
settings = function()
widget:set_markup(markup.fontfg(theme.font, "#e33a6e", cpu_now.usage .. "% "))
end
})
-- Coretemp
local tempicon = wibox.widget.imagebox(theme.widget_temp)
local temp = lain.widget.temp({
settings = function()
widget:set_markup(markup.fontfg(theme.font, "#f1af5f", coretemp_now .. "°C "))
end
})
-- Battery
local baticon = wibox.widget.imagebox(theme.widget_batt)
local bat = lain.widget.bat({
settings = function()
local perc = bat_now.perc ~= "N/A" and bat_now.perc .. "%" or bat_now.perc
if bat_now.ac_status == 1 then
perc = perc .. " plug"
end
widget:set_markup(markup.fontfg(theme.font, theme.fg_normal, perc .. " "))
end
})
-- ALSA volume
local volicon = wibox.widget.imagebox(theme.widget_vol)
theme.volume = lain.widget.alsa({
settings = function()
if volume_now.status == "off" then
volume_now.level = volume_now.level .. "M"
end
widget:set_markup(markup.fontfg(theme.font, "#7493d2", volume_now.level .. "% "))
end
})
-- Net
local netdownicon = wibox.widget.imagebox(theme.widget_netdown)
local netdowninfo = wibox.widget.textbox()
local netupicon = wibox.widget.imagebox(theme.widget_netup)
local netupinfo = lain.widget.net({
settings = function()
if iface ~= "network off" and
string.match(theme.weather.widget.text, "N/A")
then
theme.weather.update()
end
widget:set_markup(markup.fontfg(theme.font, "#e54c62", net_now.sent .. " "))
netdowninfo:set_markup(markup.fontfg(theme.font, "#87af5f", net_now.received .. " "))
end
})
-- MEM
local memicon = wibox.widget.imagebox(theme.widget_mem)
local memory = lain.widget.mem({
settings = function()
widget:set_markup(markup.fontfg(theme.font, "#e0da37", mem_now.used .. "M "))
end
})
-- MPD
local mpdicon = wibox.widget.imagebox()
theme.mpd = lain.widget.mpd({
settings = function()
mpd_notification_preset = {
text = string.format("%s [%s] - %s\n%s", mpd_now.artist,
mpd_now.album, mpd_now.date, mpd_now.title)
}
if mpd_now.state == "play" then
artist = mpd_now.artist .. " > "
title = mpd_now.title .. " "
mpdicon:set_image(theme.widget_note_on)
elseif mpd_now.state == "pause" then
artist = "mpd "
title = "paused "
else
artist = ""
title = ""
--mpdicon:set_image() -- not working in 4.0
mpdicon._private.image = nil
mpdicon:emit_signal("widget::redraw_needed")
mpdicon:emit_signal("widget::layout_changed")
end
widget:set_markup(markup.fontfg(theme.font, "#e54c62", artist) .. markup.fontfg(theme.font, "#b2b2b2", title))
end
})
function theme.at_screen_connect(s)
-- Quake application
s.quake = lain.util.quake({ app = awful.util.terminal })
-- If wallpaper is a function, call it with the screen
local wallpaper = theme.wallpaper
if type(wallpaper) == "function" then
wallpaper = wallpaper(s)
end
gears.wallpaper.maximized(wallpaper, s, true)
-- Tags
awful.tag(awful.util.tagnames, s, awful.layout.layouts)
-- Create a promptbox for each screen
s.mypromptbox = awful.widget.prompt()
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
s.mylayoutbox = awful.widget.layoutbox(s)
s.mylayoutbox:buttons(my_table.join(
awful.button({}, 1, function () awful.layout.inc( 1) end),
awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[1] ) end),
awful.button({}, 3, function () awful.layout.inc(-1) end),
awful.button({}, 4, function () awful.layout.inc( 1) end),
awful.button({}, 5, function () awful.layout.inc(-1) end)))
-- Create a taglist widget
s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
-- Create a tasklist widget
s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons)
-- Create the wibox
s.mywibox = awful.wibar({ position = "top", screen = s, height = 20, bg = theme.bg_normal, fg = theme.fg_normal })
-- Add widgets to the wibox
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
--s.mylayoutbox,
s.mytaglist,
s.mypromptbox,
mpdicon,
theme.mpd.widget,
},
--s.mytasklist, -- Middle widget
nil,
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
wibox.widget.systray(),
--mailicon,
--theme.mail.widget,
netdownicon,
netdowninfo,
netupicon,
netupinfo.widget,
volicon,
theme.volume.widget,
memicon,
memory.widget,
cpuicon,
cpu.widget,
--fsicon,
--theme.fs.widget,
weathericon,
theme.weather.widget,
tempicon,
temp.widget,
baticon,
bat.widget,
clockicon,
mytextclock,
},
}
-- Create the bottom wibox
s.mybottomwibox = awful.wibar({ position = "bottom", screen = s, border_width = 0, height = 20, bg = theme.bg_normal, fg = theme.fg_normal })
-- Add widgets to the bottom wibox
s.mybottomwibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
},
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
s.mylayoutbox,
},
}
end
return theme
|
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "plugins.lua",
command = 'source % | PackerCompile',
})
local execute = vim.api.nvim_command
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path })
execute 'packadd packer.nvim'
end
vim.api.nvim_command('packadd packer.nvim')
return require('packer').startup(function()
use 'wbthomason/packer.nvim'
use { 'christianchiarulli/nvcode-color-schemes.vim',
opt = true,
cond = function() return false end
}
use {
'titanzero/zephyrium',
config = function()
vim.cmd [[colorscheme zephyrium]]
end,
opt = true,
cond = function() return true end
}
use {
'rebelot/kanagawa.nvim',
config = function()
vim.cmd [[colorscheme kanagawa]]
end,
opt = true,
cond = function() return false end
}
use {
'EdenEast/nightfox.nvim',
config = function()
vim.g.nightfox_style = "palefox"
require('nightfox').set()
end,
opt = true,
cond = function() return false end
}
--------------QoL------------
use {
'JoosepAlviste/nvim-ts-context-commentstring',
config = function()
require 'nvim-treesitter.configs'.setup {
context_commentstring = {
enable = true,
enable_autocmd = false,
}
}
end
}
use {
'numToStr/Comment.nvim',
config = function()
require('Comment').setup({
toggler = {
line = '<leader>cl',
},
opleader = {
---Block-comment keymap
block = '<leader>ci',
},
pre_hook = function(ctx)
local U = require 'Comment.utils'
local location = nil
if ctx.ctype == U.ctype.block then
location = require('ts_context_commentstring.utils').get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
location = require('ts_context_commentstring.utils').get_visual_start_location()
end
return require('ts_context_commentstring.internal').calculate_commentstring {
key = ctx.ctype == U.ctype.line and '__default' or '__multiline',
location = location,
}
end,
})
end
}
use {
'windwp/nvim-autopairs',
config = function()
require('nvim-autopairs').setup {
fast_wrap = {},
}
end
}
use { 'p00f/nvim-ts-rainbow', ft = { 'clojure', 'html', 'vue' } }
use 'romgrk/barbar.nvim' -- Best bufferline
use {
'NTBBloodbath/galaxyline.nvim',
opt = true,
cond = function() return true end,
config = function() require('mygalaxyline') end
}
use 'farmergreg/vim-lastplace'
-------------dev tools---------
use 'simrat39/symbols-outline.nvim'
use { 'tpope/vim-fireplace', ft = 'clojure' } -- enables clojure development
use {
'kyazdani42/nvim-tree.lua',
config = function()
vim.g.nvim_tree_git_hl = 1
vim.g.nvim_tree_highlight_opened_files = 1
vim.g.nvim_tree_respect_buf_cwd = 1
local tree_cb = require 'nvim-tree.config'.nvim_tree_callback
require 'nvim-tree'.setup {
update_cwd = true,
view = {
width = 27,
mappings = {
list = {
{ key = { "h", "l" }, cb = tree_cb("edit") },
{ key = { "<CR>" }, cb = tree_cb("cd") }
}
}
},
filters = {
exclude = { '.git', 'node_modules', '.cache', 'target', '.o', 'bin' },
},
diagnostics = {
enable = true
},
renderer = {
indent_markers = {
enable = true,
},
},
}
end
}
---------------git------------
use {
'TimUntersberger/neogit',
config = function()
require('neogit').setup {
integrations = {
diffview = true
},
}
end
}
use {
'lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup {
signs = {
add = { hl = 'GitSignsAdd', text = '+', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
change = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
delete = { hl = 'GitSignsDelete', text = '-', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
topdelete = { hl = 'GitSignsDelete', text = '-', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
},
current_line_blame_opts = {
delay = 10,
}
}
end
}
use {
'sindrets/diffview.nvim',
config = function()
local cb = require 'diffview.config'.diffview_callback
require 'diffview'.setup {
diff_binaries = false, -- Show diffs for binaries
use_icons = true, -- Requires nvim-web-devicons
file_panel = {
width = 35,
},
key_bindings = {
disable_defaults = false, -- Disable the default key bindings
-- The `view` bindings are active in the diff buffers, only when the current
-- tabpage is a Diffview.
view = {
["<tab>"] = cb("select_next_entry"), -- Open the diff for the next file
["<s-tab>"] = cb("select_prev_entry"), -- Open the diff for the previous file
["<leader>e"] = cb("focus_files"), -- Bring focus to the files panel
["<leader>b"] = cb("toggle_files"), -- Toggle the files panel.
},
file_panel = {
["j"] = cb("next_entry"), -- Bring the cursor to the next file entry
["<down>"] = cb("next_entry"),
["k"] = cb("prev_entry"), -- Bring the cursor to the previous file entry.
["<up>"] = cb("prev_entry"),
["<cr>"] = cb("select_entry"), -- Open the diff for the selected entry.
["o"] = cb("select_entry"),
["<2-LeftMouse>"] = cb("select_entry"),
["-"] = cb("toggle_stage_entry"), -- Stage / unstage the selected entry.
["S"] = cb("stage_all"), -- Stage all entries.
["U"] = cb("unstage_all"), -- Unstage all entries.
["R"] = cb("refresh_files"), -- Update stats and entries in the file list.
["<tab>"] = cb("select_next_entry"),
["<s-tab>"] = cb("select_prev_entry"),
["<leader>e"] = cb("focus_files"),
["<leader>b"] = cb("toggle_files"),
}
}
}
end
}
--------nvim-lsp---------
use {
'neovim/nvim-lspconfig',
opt = true,
cond = function() return true end,
config = function() require('lsps') end
}
use {
'tami5/lspsaga.nvim',
config = function()
local saga = require 'lspsaga'
saga.init_lsp_saga {
error_sign = '',
warn_sign = '',
hint_sign = '',
infor_sign = '',
code_action_prompt = {
enable = false,
sign = true,
sign_priority = 20,
virtual_text = true,
},
max_preview_lines = 20,
border_style = "round"
}
end
}
use 'williamboman/nvim-lsp-installer'
use {
"hrsh7th/nvim-cmp",
requires = {
"L3MON4D3/LuaSnip",
"rafamadriz/friendly-snippets",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-path",
"onsails/lspkind-nvim",
'hrsh7th/cmp-cmdline',
"saadparwaiz1/cmp_luasnip"
},
config = function()
local luasnip = require('luasnip')
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load({ paths = { "./snips" } })
local has_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
return false
end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local cmp = require 'cmp'
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
cmp_autopairs.lisp[#cmp_autopairs.lisp + 1] = "racket"
cmp.setup {
snippet = {
expand = function(args)
require 'luasnip'.lsp_expand(args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
{ name = 'luasnip' },
{ name = 'cmp_tabnine' },
{ name = 'path' },
{ name = 'buffer' }
},
formatting = {
format = require("lspkind").cmp_format({ with_text = true, menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
path = "[Path]",
cmp_tabnine = "[TabNine]",
luasnip = "[LuaSnip]"
}) }),
},
}
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}),
mapping = cmp.mapping.preset.cmdline({}), -- This line
})
end
}
use { 'tzachar/cmp-tabnine', run = './install.sh' }
use {
"ray-x/lsp_signature.nvim",
config = function()
require "lsp_signature".setup()
end
}
-------------telescope---------
use {
'nvim-lua/telescope.nvim',
config = function()
require('telescope').setup({
defaults = {
file_sorter = require('telescope.sorters').get_fzy_sorter
}
})
end
}
use 'nvim-lua/popup.nvim'
use 'nvim-lua/plenary.nvim'
use {
'windwp/nvim-spectre',
config = function()
require('spectre').setup()
end
}
--------------misc------------
use { 'ron-rs/ron.vim', ft = 'ron' }
use {
'nvim-treesitter/nvim-treesitter',
-- commit = '668de0951a36ef17016074f1120b6aacbe6c4515',
run = ':TSUpdate',
config = function() require('misc') end
}
use 'nvim-treesitter/nvim-treesitter-textobjects'
use 'kyazdani42/nvim-web-devicons'
use {
'norcalli/nvim-colorizer.lua',
config = function() require('colorizer').setup() end
}
use {
'akinsho/nvim-toggleterm.lua',
config = function()
require("toggleterm").setup {
open_mapping = [[<A-d>]],
direction = 'float',
float_opts = {
border = 'curved',
},
}
end
}
use 'mfussenegger/nvim-dap'
use {
'rcarriga/nvim-dap-ui',
config = function()
require("dapui").setup()
end
}
use {
'simrat39/rust-tools.nvim',
}
end)
|
-- This file manages npc reaction levels to emotes and spatial
emoteReactionLevels = {
{ "backhand", 3 },
{ "bang", 3 },
{ "bodyslam", 3 },
{ "halfnelson", 3 },
{ "nelson", 3 },
{ "noogie", 3 },
{ "punch", 3 },
{ "slap", 3 },
{ "spit", 3 },
{ "strangle", 3 },
{ "tackle", 3 },
{ "bonk", 2 },
{ "claw", 2 },
{ "drool", 2 },
{ "elbow", 2 },
{ "lick", 2 },
{ "pet", 2 },
{ "pinch", 2 },
{ "provoke", 2 },
{ "puke", 2 },
{ "swat", 2 },
{ "twistarm", 2 },
{ "whap", 2 },
{ "fiddle", 2 },
{ "knockwood", 2 },
{ "lean", 2 },
{ "mosh", 2 },
{ "flail", 2 },
{ "charge", 2 },
{ "chestpuff", 2 },
{ "peyoo", 1 },
{ "echuta", 2 },
{ "fistpalm", 2 },
{ "poke", 2 },
{ "combhair", 1 },
{ "hug", 1 },
{ "kiss", 1 },
{ "melt", 1 },
{ "nuzzle", 1 },
{ "pat", 1 },
{ "scratch", 1 },
{ "slobber", 1 },
{ "snog", 1 },
{ "squeeze", 1 },
{ "stomp", 1 },
{ "sweat", 1 },
{ "toss", 1 },
{ "tug", 1 },
{ "tweak", 1 },
{ "covereyes", 1 },
{ "embrace", 1 },
{ "hi5", 1 },
{ "nap", 1 },
{ "pillow", 1 },
{ "prod", 1 },
{ "pull", 1 },
{ "push", 1 },
{ "ruffle", 1 },
{ "spin", 1 },
{ "stretch", 1 },
{ "tickle", 1 },
{ "brandish", 1 },
{ "burp", 1 },
{ "chestpound", 1 },
{ "curse", 1 },
{ "deride", 1 },
{ "flame", 1 },
{ "hand", 1 },
{ "pound", 1 },
{ "roar", 1 },
{ "adjust", 1 },
{ "boggle", 1 },
{ "chase", 1 },
{ "dance", 1 },
{ "diagnose", 1 },
{ "feel", 1 },
{ "fool", 1 },
{ "fume", 1 },
{ "gag", 1 },
{ "glare", 1 },
{ "growl", 1 },
{ "hiss", 1 },
{ "hose", 1 },
{ "mimic", 1 },
{ "mourn", 1 },
{ "mutter", 1 },
{ "pucker", 1 },
{ "raspberry", 1 },
{ "scare", 1 },
{ "scold", 1 },
{ "scowl", 1 },
{ "sharpen", 1 },
{ "slit", 1 },
{ "smell", 1 },
{ "snarl", 1 },
{ "sneer", 1 },
{ "steam", 1 },
{ "throwat", 1 },
{ "throwdown", 1 },
{ "tongue", 1 },
{ "veto", 1 },
{ "yawn", 1 },
}
emoteReactionFines = {
-- { EmoteLevel, IsImperial, IsHuman, RankComparison, CreditFine, FactionFine, Knockdown, quipMin, quipMax, responseEmote }
-- RankComparison: -1 = inferior rank than npc, 0 = same rank as npc, 1 = superior rank than npc
-- Inferior Ranked Imperials --
{ 3, true, true, -1, 3500, 35, true, 21, 24, "" },
{ 3, true, false, -1, 5000, 50, true, 13, 16, "" },
{ 2, true, true, -1, 2000, 20, false, 21, 24, "" },
{ 2, true, false, -1, 5000, 20, true, 13, 16, "" },
{ 1, true, true, -1, 500, 50, false, 21, 24, "" },
{ 1, true, false, -1, 2000, 20, false, 13, 16, "" },
{ 0, true, true, -1, 0, 0, false, 0, 0, "" }, -- No reaction
{ 0, true, false, -1, 500, 5, false, 13, 16, "" },
-- Superior Ranked Imperials --
{ 3, true, true, 1, 0, 0, false, 35, 36, "standing_placate" },
{ 3, true, false, 1, 0, 0, false, 35, 36, "standing_placate" },
{ 2, true, true, 1, 0, 0, false, 35, 36, "salute2" },
{ 2, true, false, 1, 0, 0, false, 35, 36, "salute2" },
{ 1, true, true, 1, 0, 0, false, 37, 39, "salute1" },
{ 1, true, false, 1, 0, 0, false, 37, 39, "salute1" },
{ 0, true, true, 1, 0, 0, false, -1, -1, "salute1" },
{ 0, true, false, 1, 0, 0, false, -1, -1, "salute1" },
-- Equal Ranked Imperials --
{ 3, true, true, 0, 0, 25, false, 25, 26, "" },
{ 3, true, false, 0, 0, 50, false, 21, 24, "" },
{ 2, true, true, 0, 0, 25, false, 25, 26, "" },
{ 2, true, false, 0, 0, 50, false, 21, 24, "" },
{ 1, true, true, 0, 0, 0, false, -1, -1, "" },
{ 1, true, false, 0, 0, 0, false, -1, -1, "" },
{ 0, true, true, 0, 0, 0, false, -1, -1, "" },
{ 0, true, false, 0, 0, 0, false, -1, -1, "" },
-- Non Imperials --
{ 3, false, true, 0, 3500, 35, true, 31, 34, "" },
{ 3, false, false, 0, 5000, 50, true, 27, 30, "" },
{ 2, false, true, 0, 2000, 20, false, 31, 34, "" },
{ 2, false, false, 0, 5000, 50, true, 27, 30, "" },
{ 1, false, true, 0, 500, 5, false, 31, 34, "" },
{ 1, false, false, 0, 3500, 35, false, 27, 30, "" },
{ 0, false, true, 0, 0, 0, false, -1, -1, "" }, -- No reaction
{ 0, false, false, 0, 1000, 10, false, 27, 30, "" },
}
-- This is the list of npcs that have reactions and their reaction rank
-- Their rank is compared to player faction rank to determine if they are superior/inferior/equal in rank
imperialReactionRanks = {
{ "imperial_cadet_squadleader", 1, 1 },
{ "imperial_civil_patrolman", 1, 1 },
{ "imperial_private", 1, 1 },
{ "imperial_trooper", 1, 1 },
{ "imperial_lance_corporal", 2, 2 },
{ "imperial_senior_cadet", 2, 2 },
{ "imperial_civil_patrol_corporal", 3, 3 },
{ "imperial_corporal", 3, 3 },
{ "imperial_staff_corporal", 4, 4 },
{ "imperial_civil_patrol_sergeant", 5, 5 },
{ "imperial_sergeant", 5, 5 },
{ "imperial_staff_sergeant", 6, 6 },
{ "imperial_master_sergeant", 7, 7 },
{ "imperial_sergeant_major", 7, 7 },
{ "imperial_warrant_officer_ii", 8, 8 },
{ "imperial_warrant_officer_i", 9, 9 },
{ "imperial_second_lieutenant", 10, 10 },
{ "imperial_civil_patrol_commander", 11, 11 },
{ "imperial_first_lieutenant", 11, 11 },
{ "imperial_army_captain", 12, 12 },
{ "imperial_civil_patrol_captain", 12, 12},
{ "stormtrooper_captain", 12, 12 },
{ "imperial_major", 13, 13 },
{ "stormtrooper_major", 13, 13 },
{ "imperial_lieutenant_colonel", 14, 14 },
{ "imperial_colonel", 15, 15 },
{ "high_colonel", 16, 16 },
{ "imperial_brigadier_general", 16, 16 },
{ "imperial_major_genera", 17, 17 },
{ "imperial_lieutenant_general", 18, 18 },
{ "imperial_general", 19, 19 },
{ "imperial_high_general", 20, 20 },
{ "imperial_surface_marshal", 21, 21},
{ "coa3_rebel_research_attacker1", 1, 7 },
{ "imperial_medic", 1, 7 },
{ "imperial_noncom", 1, 7 },
{ "imperial_recruiter", 1, 7 },
{ "imperial_retreat_guard", 1, 7 },
{ "imperial_sharpshooter", 1, 7 },
{ "lance_bombardier", 1, 7 },
{ "sand_trooper", 1, 7 },
{ "scout_trooper", 1, 7 },
{ "storm_commando", 1, 7 },
{ "stormtrooper", 1, 7 },
{ "stormtrooper_black_hole", 1, 7 },
{ "stormtrooper_medic", 1, 7 },
{ "stormtrooper_rifleman", 1, 7 },
{ "stormtrooper_sniper", 1, 7 },
{ "stranded_imperial_soldier", 1, 7 },
{ "swamp_trooper", 1, 7 },
{ "swamp_trooper_anti_gungan", 1, 7 },
{ "veteran_compforce_trooper", 1, 7 },
{ "bombardier", 8, 13 },
{ "coa3_information_imperial", 8, 13 },
{ "coa3_rebel_research_attacker2", 8, 13 },
{ "coa3_tactical_imperial", 8, 13 },
{ "comm_operator", 8, 13 },
{ "command_security_guard", 8, 13 },
{ "detention_security_guard", 8, 13 },
{ "imperial_pilot", 8, 13 },
{ "special_missions_engineer", 8, 13 },
{ "stormtrooper_black_hole_squad_leader", 8, 13 },
{ "stormtrooper_bombardier", 8, 13 },
{ "stormtrooper_squad_leader", 8, 13 },
{ "stranded_imperial_pilot", 8, 13 },
{ "imperial_moff", 14, 21 },
{ "stranded_imperial_officer", 14, 21 },
{ "assault_trooper", 5, 18 },
{ "dark_trooper", 5, 18 },
{ "elite_dark_trooper", 5, 18 },
{ "elite_sand_trooper", 5, 18 },
{ "imperial_exterminator", 19, 21 },
{ "imperial_inquisitor", 19, 21 },
}
|
loadstring(game:GetObjects('rbxassetid://339069795')[1].Source)()
|
local Rectangle = GameObject:extend()
function Rectangle:new(zone, x, y, opts, w, h)
Rectangle.super.new(self, zone, x, y, opts)
self.width = w
self.height = h
end
function Rectangle:update(dt)
Rectangle.super:update(dt)
end
function Rectangle:draw()
love.graphics.rectangle('fill', self.x - self.width/2, self.y - self.height/2, self.width, self.height)
end
return Rectangle
|
local map = {}
map.width = 100
map.height = 10
map.tilewidth = 256
map.tileheight = 256
map.tilecount = 2
map.tiles = {
{
id = 0,
image = love.graphics.newImage("art/level1-1.png"),
width = 256,
height = 256
},
{
id = 1,
image = love.graphics.newImage("art/level1-3.png"),
width = 256,
height = 256
}
}
map.mapData = {
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
}
return map;
|
-- Credits to linerider64 for making this script
ModelName = "Gilgamesh"
attack = false
attacktype = 1
Hitdeb = 0
Hitdeb2 = 0
name = "ace28545"
----------------------------
--Customize mediafire
Rage = 0
Rage = 200
mindamage = 10
maxdamage = 40
crtmaxdamage = 60
omindamage = mindamage
omaxdamage = maxdamage
ocrtmaxdamage = crtmaxdamage
crtrate = 100/5
HP = 2000
WS = 16
jump = 50
--100%/critpercentage
oblkbrkr = 3
blockbreaker = oblkbrkr
handlecolor = BrickColor.new("Really black")
bcolor = BrickColor.new("Institutional white")
gemcolor = BrickColor.new("Really black")
-------------------------------------------------------------------------------------------------------------------------------------
if game.Workspace:findFirstChild(ModelName,true) ~= nil then
game.Workspace:findFirstChild(ModelName,true).Parent = nil
end
local bodyholder = Instance.new("Model")
bodyholder.Name = ModelName
bodyholder.Parent = game.Workspace
Character = bodyholder
ev = Instance.new("BoolValue",bodyholder)
ev.Name = "EquippedVal"
ev.Value = false
--[[blk = Instance.new("BoolValue",bodyholder)
blk.Name = "Block"
blk.Value = false]]
blkc = Instance.new("IntValue",blk)
blkc.Name = "BlockPower"
blkc.Value = blockpower
SpawnPos = Instance.new("Vector3Value",script)
SpawnPos.Name = "SpawnPos"
SpawnPos.Value = Vector3.new(0,20,0)
local Head = Instance.new("Part")
Head.formFactor = 3
Head.CanCollide = true
Head.Name = "Head"
Head.Locked = true
Head.Size = Vector3.new(4,2,2)
Head.Parent = bodyholder
Head.BrickColor = BrickColor.new("White")
local smh = Instance.new("SpecialMesh",Head)
smh.Scale = Vector3.new(1.25,1.25,1.25)
local Torso = Instance.new("Part")
Torso.formFactor = 3
Torso.CanCollide = true
Torso.Name = "Torso"
Torso.Locked = true
Torso.Size = Vector3.new(4,4,2)
Torso.Parent = bodyholder
Torso.BrickColor = BrickColor.new("Really black")
Torso.Reflectance = 0.1
Torso.CFrame = CFrame.new(SpawnPos.Value)
local bg=Instance.new("BodyGyro")
bg.Parent=Torso
bg.P = 3000
bg.maxTorque = Vector3.new(1000,1000,1000)
local msht = Instance.new("BlockMesh",Torso)
local RightArm = Instance.new("Part")
RightArm.formFactor = 3
RightArm.CanCollide = true
RightArm.Name = "Right Arm"
RightArm.Locked = true
RightArm.Size = Vector3.new(2,4,2)
RightArm.Parent = bodyholder
RightArm.BrickColor = BrickColor.new("Really red")
local mshra = Instance.new("BlockMesh",RightArm)
local LeftArm = Instance.new("Part")
LeftArm.formFactor = 3
LeftArm.CanCollide = true
LeftArm.Name = "Left Arm"
LeftArm.Locked = true
LeftArm.Size = Vector3.new(2,4,2)
LeftArm.Parent = bodyholder
LeftArm.BrickColor = BrickColor.new("Really red")
local mshla = Instance.new("BlockMesh",LeftArm)
local RightLeg = Instance.new("Part")
RightLeg.formFactor = 3
RightLeg.CanCollide = true
RightLeg.Name = "Right Leg"
RightLeg.Locked = true
RightLeg.Size = Vector3.new(2,4,2)
RightLeg.Parent = bodyholder
RightLeg.BrickColor = BrickColor.new("Really black")
local mshrl = Instance.new("BlockMesh",RightLeg)
local LeftLeg = Instance.new("Part")
LeftLeg.formFactor = 3
LeftLeg.CanCollide = true
LeftLeg.Name = "Left Leg"
LeftLeg.Locked = true
LeftLeg.Size = Vector3.new(2,4,2)
LeftLeg.Parent = bodyholder
LeftLeg.BrickColor = BrickColor.new("Really black")
local mshll = Instance.new("BlockMesh",LeftLeg)
--player
player = nil
--welds
RW, LW , RWL, LWL = Instance.new("Weld"), Instance.new("Weld"), Instance.new("Weld"), Instance.new("Weld")
--what anim
anim = "none"
--save shoulders
AoETrue = {}
Neck = Instance.new("Motor")
--derp
RW.Part0 = Character.Torso
RW.Part1 = Character["Right Arm"]
RW.C0 = CFrame.new(3, 1, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
RW.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
RW.Parent = bodyholder
--
LW.Part0 = Character.Torso
LW.Part1 = Character["Left Arm"]
LW.C0 = CFrame.new(-3, 1, 0)
LW.C1 = CFrame.new(0, 1, 0)
LW.Parent = bodyholder
--
RWL.Part0 = Character.Torso
RWL.Part1 = Character["Right Leg"]
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(0, 0, 0)
RWL.C1 = CFrame.new(1, 2, 0)
RWL.Parent = bodyholder
--
LWL.Part0 = Character.Torso
LWL.Part1 = Character["Left Leg"]
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(0, 0, 0)
LWL.C1 = CFrame.new(-1, 2, 0)
LWL.Parent = bodyholder
--
Neck.Part0 = Character.Torso
Neck.Part1 = Character.Head
Neck.C0 = CFrame.new(0, 2, 0) * CFrame.Angles(0, 0, 0)
Neck.C1 = CFrame.new(0, -1, 0)
Neck.Parent = bodyholder
----
--
armorholder = Instance.new("Model")
armorholder.Name = "Armor"
armorholder.Parent = bodyholder
ap1 = Instance.new("Part")
ap1.formFactor = 3
ap1.CanCollide = false
ap1.Name = "HelmP1"
ap1.Locked = true
ap1.Size = Vector3.new(2.7,1.5,0.2)
ap1.Parent = armorholder
ap1.BrickColor = BrickColor.new("Really red")
am1 = Instance.new("BlockMesh",ap1)
aw1 = Instance.new("Weld")
aw1.Parent = ap1
aw1.Part0 = ap1
aw1.Part1 = Head
aw1.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw1.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-20), 0, 0) * CFrame.new(0, -1, 1.1)
ap1a = Instance.new("Part")
ap1a.formFactor = 3
ap1a.CanCollide = false
ap1a.Name = "HelmP1a"
ap1a.Locked = true
ap1a.Size = Vector3.new(0.3,1.5,0.2)
ap1a.Parent = armorholder
ap1a.BrickColor = BrickColor.new("Really red")
am1a = Instance.new("BlockMesh",ap1a)
aw1a = Instance.new("Weld")
aw1a.Parent = ap1a
aw1a.Part0 = ap1a
aw1a.Part1 = Head
aw1a.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw1a.C0 = CFrame.fromEulerAnglesXYZ(math.rad(10), 0, 0) * CFrame.new(0, 0.4, 1.3)
ap2 = Instance.new("Part")
ap2.formFactor = 3
ap2.CanCollide = false
ap2.Name = "HelmP2"
ap2.Locked = true
ap2.Size = Vector3.new(0.2,0.75,1)
ap2.Parent = armorholder
ap2.BrickColor = BrickColor.new("Really red")
am2 = Instance.new("BlockMesh",ap2)
aw2 = Instance.new("Weld")
aw2.Parent = ap2
aw2.Part0 = ap2
aw2.Part1 = Head
aw2.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw2.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(-1.25, -1, 0.55)
ap3 = Instance.new("Part")
ap3.formFactor = 3
ap3.CanCollide = false
ap3.Name = "HelmP3"
ap3.Locked = true
ap3.Size = Vector3.new(0.2,0.75,1)
ap3.Parent = armorholder
ap3.BrickColor = BrickColor.new("Really red")
am3 = Instance.new("BlockMesh",ap3)
aw3 = Instance.new("Weld")
aw3.Parent = ap3
aw3.Part0 = ap3
aw3.Part1 = Head
aw3.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw3.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(1.25, -1, 0.55)
ap4 = Instance.new("Part")
ap4.formFactor = 3
ap4.CanCollide = false
ap4.Name = "HelmP4"
ap4.Locked = true
ap4.Size = Vector3.new(4,2.2,2.2)
ap4.Parent = armorholder
ap4.BrickColor = BrickColor.new("Really red")
am4 = Instance.new("SpecialMesh",ap4)
am4.Scale = Vector3.new(1.25,1.25,1.25)
aw4 = Instance.new("Weld")
aw4.Parent = ap4
aw4.Part0 = ap4
aw4.Part1 = Head
aw4.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw4.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(0, 0, -0.1)
ap5 = Instance.new("Part")
ap5.formFactor = 3
ap5.CanCollide = false
ap5.Name = "HelmP5"
ap5.Locked = true
ap5.Size = Vector3.new(2,0.5,0.2)
ap5.Parent = armorholder
ap5.BrickColor = BrickColor.new("Really black")
am5 = Instance.new("BlockMesh",ap5)
aw5 = Instance.new("Weld")
aw5.Parent = ap5
aw5.Part0 = ap5
aw5.Part1 = Head
aw5.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw5.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(0, 0, 1.15)
ap6 = Instance.new("Part")
ap6.formFactor = 3
ap6.CanCollide = false
ap6.Name = "HelmP6"
ap6.Locked = true
ap6.Size = Vector3.new(0.2,1.5,2.5)
ap6.Parent = armorholder
ap6.BrickColor = BrickColor.new("Really red")
am6 = Instance.new("BlockMesh",ap6)
aw6 = Instance.new("Weld")
aw6.Parent = ap6
aw6.Part0 = ap6
aw6.Part1 = Head
aw6.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw6.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(1.25, 0.25, 0)
ap7 = Instance.new("Part")
ap7.formFactor = 3
ap7.CanCollide = false
ap7.Name = "HelmP7"
ap7.Locked = true
ap7.Size = Vector3.new(0.2,1.5,2.5)
ap7.Parent = armorholder
ap7.BrickColor = BrickColor.new("Really red")
am7 = Instance.new("BlockMesh",ap7)
aw7 = Instance.new("Weld")
aw7.Parent = ap7
aw7.Part0 = ap7
aw7.Part1 = Head
aw7.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw7.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(-1.25, 0.25, 0)
ap8 = Instance.new("Part")
ap8.formFactor = 3
ap8.CanCollide = false
ap8.Name = "HelmP8"
ap8.Locked = true
ap8.Size = Vector3.new(0.2,2,1)
ap8.Parent = armorholder
ap8.BrickColor = BrickColor.new("Really red")
am8 = Instance.new("BlockMesh",ap8)
aw8 = Instance.new("Weld")
aw8.Parent = ap8
aw8.Part0 = ap8
aw8.Part1 = Head
aw8.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw8.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(-1.25, 0.25, -1)
ap9 = Instance.new("Part")
ap9.formFactor = 3
ap9.CanCollide = false
ap9.Name = "HelmP9"
ap9.Locked = true
ap9.Size = Vector3.new(0.2,2,1)
ap9.Parent = armorholder
ap9.BrickColor = BrickColor.new("Really red")
am9 = Instance.new("BlockMesh",ap9)
aw9 = Instance.new("Weld")
aw9.Parent = ap9
aw9.Part0 = ap9
aw9.Part1 = Head
aw9.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw9.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(1.25, 0.25, -1)
ap9 = Instance.new("Part")
ap9.formFactor = 3
ap9.CanCollide = false
ap9.Name = "HelmP9"
ap9.Locked = true
ap9.Size = Vector3.new(2.7,2,0.2)
ap9.Parent = armorholder
ap9.BrickColor = BrickColor.new("Really red")
am9 = Instance.new("BlockMesh",ap9)
aw9 = Instance.new("Weld")
aw9.Parent = ap9
aw9.Part0 = ap9
aw9.Part1 = Head
aw9.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw9.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(0, 0.25, -1.5)
ap10 = Instance.new("Part")
ap10.formFactor = 3
ap10.CanCollide = false
ap10.Name = "HelmP10"
ap10.Locked = true
ap10.Size = Vector3.new(0.2,1,0.2)
ap10.Parent = armorholder
ap10.BrickColor = BrickColor.new("Really blue")
am10 = Instance.new("CylinderMesh",ap10)
aw10 = Instance.new("Weld")
aw10.Parent = ap10
aw10.Part0 = ap10
aw10.Part1 = Head
aw10.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw10.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-45), 0, 0) * CFrame.new(0, -1.5, -1.5)
ap11 = Instance.new("Part")
ap11.formFactor = 3
ap11.CanCollide = false
ap11.Name = "HelmP11"
ap11.Locked = true
ap11.Size = Vector3.new(1.5,1.5,1.5)
ap11.Parent = armorholder
ap11.BrickColor = BrickColor.new("White")
am11 = Instance.new("SpecialMesh",ap11)
am11.MeshType = "Sphere"
aw11 = Instance.new("Weld")
aw11.Parent = ap11
aw11.Part0 = ap11
aw11.Part1 = ap10
aw11.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw11.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(0, -1, 0)
ap12 = Instance.new("Part")
ap12.formFactor = 3
ap12.CanCollide = false
ap12.Name = "HelmP12"
ap12.Locked = true
ap12.Size = Vector3.new(1,1,1)
ap12.Parent = armorholder
ap12.BrickColor = BrickColor.new("White")
am12 = Instance.new("SpecialMesh",ap12)
am12.MeshId = "http://www.roblox.com/asset/?id=1778999"
am12.Scale = Vector3.new(1.1,1,1.1)
aw12 = Instance.new("Weld")
aw12.Parent = ap12
aw12.Part0 = ap12
aw12.Part1 = ap10
aw12.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw12.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(0, -2, 0)
ap13 = Instance.new("Part")
ap13.formFactor = 3
ap13.CanCollide = false
ap13.Name = "HelmP13"
ap13.Locked = true
ap13.Size = Vector3.new(1,1,1)
ap13.Parent = armorholder
ap13.BrickColor = BrickColor.new("Really blue")
ap13.Reflectance = 0.1
am13 = Instance.new("SpecialMesh",ap13)
am13.MeshType = "Sphere"
am13.Scale = Vector3.new(1,1,1)
aw13 = Instance.new("Weld")
aw13.Parent = ap13
aw13.Part0 = ap13
aw13.Part1 = Head
aw13.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw13.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(1.25, 0.5, 0.25)
ap14 = Instance.new("Part")
ap14.formFactor = 3
ap14.CanCollide = false
ap14.Name = "HelmP14"
ap14.Locked = true
ap14.Size = Vector3.new(1,1,1)
ap14.Parent = armorholder
ap14.BrickColor = BrickColor.new("Really blue")
ap14.Reflectance = 0.1
am14 = Instance.new("SpecialMesh",ap14)
am14.MeshType = "Sphere"
am14.Scale = Vector3.new(1,1,1)
aw14 = Instance.new("Weld")
aw14.Parent = ap14
aw14.Part0 = ap14
aw14.Part1 = Head
aw14.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw14.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(-1.25, 0.5, 0.25)
ap15 = Instance.new("Part")
ap15.formFactor = 3
ap15.CanCollide = false
ap15.Name = "HelmP15"
ap15.Locked = true
ap15.Size = Vector3.new(2.5,1.5,0.2)
ap15.Parent = armorholder
ap15.BrickColor = BrickColor.new("New Yeller")
ap15.Reflectance = 0.1
am15 = Instance.new("BlockMesh",ap15)
aw15 = Instance.new("Weld")
aw15.Parent = ap15
aw15.Part0 = ap15
aw15.Part1 = Head
aw15.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw15.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-10), 0, 0) * CFrame.new(0, 1, 1.75)
ap16 = Instance.new("Part")
ap16.formFactor = 3
ap16.CanCollide = false
ap16.Name = "HelmP16"
ap16.Locked = true
ap16.Size = Vector3.new(0.2,1,2.5)
ap16.Parent = armorholder
ap16.BrickColor = BrickColor.new("New Yeller")
ap16.Reflectance = 0.1
am16 = Instance.new("BlockMesh",ap16)
aw16 = Instance.new("Weld")
aw16.Parent = ap16
aw16.Part0 = ap16
aw16.Part1 = Head
aw16.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw16.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(-20), 0) * CFrame.new(-1.6, 1.25, 0.6)
ap17 = Instance.new("Part")
ap17.formFactor = 3
ap17.CanCollide = false
ap17.Name = "HelmP17"
ap17.Locked = true
ap17.Size = Vector3.new(0.2,1,2.5)
ap17.Parent = armorholder
ap17.BrickColor = BrickColor.new("New Yeller")
ap17.Reflectance = 0.1
am17 = Instance.new("BlockMesh",ap17)
aw17 = Instance.new("Weld")
aw17.Parent = ap17
aw17.Part0 = ap17
aw17.Part1 = Head
aw17.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw17.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(20), 0) * CFrame.new(1.6, 1.25, 0.6)
ap18 = Instance.new("Part")
ap18.formFactor = 3
ap18.CanCollide = false
ap18.Name = "HelmP18"
ap18.Locked = true
ap18.Size = Vector3.new(0.2,1.5,1.5)
ap18.Parent = armorholder
ap18.BrickColor = BrickColor.new("Really red")
ap18.Reflectance = 0.1
am18 = Instance.new("BlockMesh",ap18)
aw18 = Instance.new("Weld")
aw18.Parent = ap18
aw18.Part0 = ap18
aw18.Part1 = Head
aw18.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw18.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(30), 0) * CFrame.new(-1.7, 1, -1.1)
ap19 = Instance.new("Part")
ap19.formFactor = 3
ap19.CanCollide = false
ap19.Name = "HelmP19"
ap19.Locked = true
ap19.Size = Vector3.new(0.2,1.5,1.5)
ap19.Parent = armorholder
ap19.BrickColor = BrickColor.new("Really red")
ap19.Reflectance = 0.1
am19 = Instance.new("BlockMesh",ap19)
aw19 = Instance.new("Weld")
aw19.Parent = ap19
aw19.Part0 = ap19
aw19.Part1 = Head
aw19.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw19.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(-30), 0) * CFrame.new(1.7, 1, -1.1)
ap20 = Instance.new("Part")
ap20.formFactor = 3
ap20.CanCollide = false
ap20.Name = "HelmP20"
ap20.Locked = true
ap20.Size = Vector3.new(2.7,1.5,0.2)
ap20.Parent = armorholder
ap20.BrickColor = BrickColor.new("Really red")
ap20.Reflectance = 0.1
am20 = Instance.new("BlockMesh",ap20)
aw20 = Instance.new("Weld")
aw20.Parent = ap20
aw20.Part0 = ap20
aw20.Part1 = Head
aw20.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw20.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(0, 1, -1.7)
ap21 = Instance.new("Part")
ap21.formFactor = 3
ap21.CanCollide = false
ap21.Name = "HelmP21"
ap21.Locked = true
ap21.Size = Vector3.new(0.2,0.2,0.2)
ap21.Parent = armorholder
ap21.Transparency = 0.9
ap21.BrickColor = BrickColor.new("New Yeller")
am21 = Instance.new("BlockMesh",ap21)
aw21 = Instance.new("Weld")
aw21.Parent = ap21
aw21.Part0 = ap21
aw21.Part1 = Head
aw21.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw21.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(0.55, 0.15, 1.2)
ap22 = Instance.new("Part")
ap22.formFactor = 3
ap22.CanCollide = false
ap22.Name = "HelmP22"
ap22.Locked = true
ap22.Size = Vector3.new(0.2,0.2,0.2)
ap22.Parent = armorholder
ap22.BrickColor = BrickColor.new("New Yeller")
ap22.Transparency = 0.9
am22 = Instance.new("BlockMesh",ap22)
aw22 = Instance.new("Weld")
aw22.Parent = ap22
aw22.Part0 = ap22
aw22.Part1 = Head
aw22.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw22.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(-0.55, 0.15, 1.2)
ap23 = Instance.new("Part")
ap23.formFactor = 3
ap23.CanCollide = false
ap23.Name = "HelmP23"
ap23.Locked = true
ap23.Size = Vector3.new(1,1,1)
ap23.Parent = armorholder
ap23.BrickColor = BrickColor.new("Dark stone grey")
ap23.Reflectance = 0.1
am23 = Instance.new("BlockMesh",ap23)
am23.Scale = Vector3.new(4,2,1.5)
aw23 = Instance.new("Weld")
aw23.Parent = ap23
aw23.Part0 = ap23
aw23.Part1 = Torso
aw23.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw23.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(0, -1, 1)
ap24 = Instance.new("Part")
ap24.formFactor = 3
ap24.CanCollide = false
ap24.Name = "HelmP24"
ap24.Locked = true
ap24.Size = Vector3.new(1,1,1)
ap24.Parent = armorholder
ap24.BrickColor = BrickColor.new("Dark stone grey")
ap24.Reflectance = 0.1
am24 = Instance.new("BlockMesh",ap24)
am24.Scale = Vector3.new(2,1,1.5)
aw24 = Instance.new("Weld")
aw24.Parent = ap24
aw24.Part0 = ap24
aw24.Part1 = Torso
aw24.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw24.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(-1.2, -0.5, 1.2)
ap25 = Instance.new("Part")
ap25.formFactor = 3
ap25.CanCollide = false
ap25.Name = "HelmP25"
ap25.Locked = true
ap25.Size = Vector3.new(1,1,1)
ap25.Parent = armorholder
ap25.BrickColor = BrickColor.new("Dark stone grey")
ap25.Reflectance = 0.1
am25 = Instance.new("BlockMesh",ap25)
am25.Scale = Vector3.new(2,1,1.5)
aw25 = Instance.new("Weld")
aw25.Parent = ap25
aw25.Part0 = ap25
aw25.Part1 = Torso
aw25.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw25.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(1.2, -0.5, 1.2)
ap26 = Instance.new("Part")
ap26.formFactor = 3
ap26.CanCollide = false
ap26.Name = "HelmP26"
ap26.Locked = true
ap26.Size = Vector3.new(1,1,1)
ap26.Parent = armorholder
ap26.BrickColor = BrickColor.new("Dark stone grey")
ap26.Reflectance = 0.1
am26 = Instance.new("SpecialMesh",ap26)
am26.Scale = Vector3.new(1.2,2,1.5)
am26.MeshType = "Wedge"
aw26 = Instance.new("Weld")
aw26.Parent = ap26
aw26.Part0 = ap26
aw26.Part1 = Torso
aw26.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw26.C0 = CFrame.fromEulerAnglesXYZ(math.rad(180), math.rad(-90), 0) * CFrame.new(1, 0.5, 1.2)
ap27 = Instance.new("Part")
ap27.formFactor = 3
ap27.CanCollide = false
ap27.Name = "HelmP27"
ap27.Locked = true
ap27.Size = Vector3.new(1,1,1)
ap27.Parent = armorholder
ap27.BrickColor = BrickColor.new("Dark stone grey")
ap27.Reflectance = 0.1
am27 = Instance.new("SpecialMesh",ap27)
am27.Scale = Vector3.new(1.2,2,1.5)
am27.MeshType = "Wedge"
aw27 = Instance.new("Weld")
aw27.Parent = ap27
aw27.Part0 = ap27
aw27.Part1 = Torso
aw27.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw27.C0 = CFrame.fromEulerAnglesXYZ(math.rad(180), math.rad(90), 0) * CFrame.new(-1, 0.5, 1.2)
ap28 = Instance.new("Part")
ap28.formFactor = 3
ap28.CanCollide = false
ap28.Name = "HelmP28"
ap28.Locked = true
ap28.Size = Vector3.new(1,1,1)
ap28.Parent = armorholder
ap28.BrickColor = BrickColor.new("Mid grey")
ap28.Reflectance = 0.1
am28 = Instance.new("SpecialMesh",ap28)
am28.Scale = Vector3.new(3.5,3.5,1)
am28.MeshType = "Sphere"
aw28 = Instance.new("Weld")
aw28.Parent = ap28
aw28.Part0 = ap28
aw28.Part1 = Torso
aw28.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw28.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(0, 0, 1)
ap29 = Instance.new("Part")
ap29.formFactor = 3
ap29.CanCollide = false
ap29.Name = "HelmP29"
ap29.Locked = true
ap29.Size = Vector3.new(1,1,1)
ap29.Parent = armorholder
ap29.BrickColor = BrickColor.new("Really black")
ap29.Reflectance = 0.1
am29 = Instance.new("BlockMesh",ap29)
am29.Scale = Vector3.new(4.1,1,2.1)
aw29 = Instance.new("Weld")
aw29.Parent = ap29
aw29.Part0 = ap29
aw29.Part1 = Torso
aw29.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw29.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(0, 2-0.5, 0)
ap30 = Instance.new("Part")
ap30.formFactor = 3
ap30.CanCollide = false
ap30.Name = "HelmP30"
ap30.Locked = true
ap30.Size = Vector3.new(1,1,1)
ap30.Parent = armorholder
ap30.BrickColor = BrickColor.new("New Yeller")
ap30.Reflectance = 0.1
am30 = Instance.new("CylinderMesh",ap30)
am30.Scale = Vector3.new(1.5,1,1.5)
aw30 = Instance.new("Weld")
aw30.Parent = ap30
aw30.Part0 = ap30
aw30.Part1 = Torso
aw30.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw30.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(0), 0) * CFrame.new(0, 2-0.5, 1)
ap30a = Instance.new("Part")
ap30a.formFactor = 3
ap30a.CanCollide = false
ap30a.Name = "HelmP30a"
ap30a.Locked = true
ap30a.Size = Vector3.new(1,1,1)
ap30a.Parent = armorholder
ap30a.BrickColor = BrickColor.new("New Yeller")
ap30a.Reflectance = 0.1
am30a = Instance.new("CylinderMesh",ap30a)
am30a.Scale = Vector3.new(0.75,1,0.75)
aw30a = Instance.new("Weld")
aw30a.Parent = ap30a
aw30a.Part0 = ap30a
aw30a.Part1 = Torso
aw30a.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw30a.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(20)) * CFrame.new(0.5, 2.2, 1)
ap31a = Instance.new("Part")
ap31a.formFactor = 3
ap31a.CanCollide = false
ap31a.Name = "HelmP31a"
ap31a.Locked = true
ap31a.Size = Vector3.new(1,1,1)
ap31a.Parent = armorholder
ap31a.BrickColor = BrickColor.new("New Yeller")
ap31a.Reflectance = 0.1
am31a = Instance.new("CylinderMesh",ap31a)
am31a.Scale = Vector3.new(0.75,1,0.75)
aw31a = Instance.new("Weld")
aw31a.Parent = ap31a
aw31a.Part0 = ap31a
aw31a.Part1 = Torso
aw31a.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw31a.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(-20)) * CFrame.new(-0.5, 2.2, 1)
ap32a = Instance.new("Part")
ap32a.formFactor = 3
ap32a.CanCollide = false
ap32a.Name = "HelmP32a"
ap32a.Locked = true
ap32a.Size = Vector3.new(1,3,1)
ap32a.Parent = armorholder
ap32a.BrickColor = BrickColor.new("New Yeller")
ap32a.Reflectance = 0.1
am32a = Instance.new("CylinderMesh",ap32a)
am32a.Scale = Vector3.new(0.75,1,0.75)
aw32a = Instance.new("Weld")
aw32a.Parent = ap32a
aw32a.Part0 = ap32a
aw32a.Part1 = Torso
aw32a.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw32a.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(-0.75, 4, 1)
ap33a = Instance.new("Part")
ap33a.formFactor = 3
ap33a.CanCollide = false
ap33a.Name = "HelmP33a"
ap33a.Locked = true
ap33a.Size = Vector3.new(1,3,1)
ap33a.Parent = armorholder
ap33a.BrickColor = BrickColor.new("New Yeller")
ap33a.Reflectance = 0.1
am33a = Instance.new("CylinderMesh",ap33a)
am33a.Scale = Vector3.new(0.75,1,0.75)
aw33a = Instance.new("Weld")
aw33a.Parent = ap33a
aw33a.Part0 = ap33a
aw33a.Part1 = Torso
aw33a.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw33a.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0.75, 4, 1)
ap31 = Instance.new("Part")
ap31.formFactor = 3
ap31.CanCollide = false
ap31.Name = "HelmP31"
ap31.Locked = true
ap31.Size = Vector3.new(1,1,1)
ap31.Parent = armorholder
ap31.BrickColor = BrickColor.new("Dark stone grey")
ap31.Reflectance = 0.1
am31 = Instance.new("BlockMesh",ap31)
am31.Scale = Vector3.new(1.7,1,1.1)
aw31 = Instance.new("Weld")
aw31.Parent = ap31
aw31.Part0 = ap31
aw31.Part1 = Torso
aw31.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw31.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(-1.25, -0.8, -1.2)
ap32 = Instance.new("Part")
ap32.formFactor = 3
ap32.CanCollide = false
ap32.Name = "HelmP32"
ap32.Locked = true
ap32.Size = Vector3.new(1,1,1)
ap32.Parent = armorholder
ap32.BrickColor = BrickColor.new("Dark stone grey")
ap32.Reflectance = 0.1
am32 = Instance.new("BlockMesh",ap32)
am32.Scale = Vector3.new(1.7,1,1.1)
aw32 = Instance.new("Weld")
aw32.Parent = ap32
aw32.Part0 = ap32
aw32.Part1 = Torso
aw32.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw32.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(1.25, -0.8, -1.2)
ap33 = Instance.new("Part")
ap33.formFactor = 3
ap33.CanCollide = false
ap33.Name = "HelmP33"
ap33.Locked = true
ap33.Size = Vector3.new(1,1,1)
ap33.Parent = armorholder
ap33.BrickColor = BrickColor.new("Mid grey")
ap33.Reflectance = 0.1
am33 = Instance.new("SpecialMesh",ap33)
am33.Scale = Vector3.new(1.1,1.5,1.5)
am33.MeshType = "Wedge"
aw33 = Instance.new("Weld")
aw33.Parent = ap33
aw33.Part0 = ap33
aw33.Part1 = Torso
aw33.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw33.C0 = CFrame.fromEulerAnglesXYZ(math.rad(180), math.rad(90), 0) * CFrame.new(-1.25, 0.45, -1.2)
ap34 = Instance.new("Part")
ap34.formFactor = 3
ap34.CanCollide = false
ap34.Name = "HelmP34"
ap34.Locked = true
ap34.Size = Vector3.new(1,1,1)
ap34.Parent = armorholder
ap34.BrickColor = BrickColor.new("Mid grey")
ap34.Reflectance = 0.1
am34 = Instance.new("SpecialMesh",ap34)
am34.Scale = Vector3.new(1.1,1.5,1.5)
am34.MeshType = "Wedge"
aw34 = Instance.new("Weld")
aw34.Parent = ap34
aw34.Part0 = ap34
aw34.Part1 = Torso
aw34.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw34.C0 = CFrame.fromEulerAnglesXYZ(math.rad(180), math.rad(-90), 0) * CFrame.new(1.25, 0.45, -1.2)
ap35 = Instance.new("Part")
ap35.formFactor = 3
ap35.CanCollide = false
ap35.Name = "HelmP35"
ap35.Locked = true
ap35.Size = Vector3.new(3,0.5,2)
ap35.Parent = armorholder
ap35.BrickColor = BrickColor.new("Really black")
ap35.Reflectance = 0.1
am35 = Instance.new("BlockMesh",ap35)
aw35 = Instance.new("Weld")
aw35.Parent = ap35
aw35.Part0 = ap35
aw35.Part1 = LeftArm
aw35.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw35.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(0.5, -2, 0)
ap36 = Instance.new("Part")
ap36.formFactor = 3
ap36.CanCollide = false
ap36.Name = "HelmP36"
ap36.Locked = true
ap36.Size = Vector3.new(3.1,0.5,2.1)
ap36.Parent = armorholder
ap36.BrickColor = BrickColor.new("New Yeller")
ap36.Reflectance = 0.1
am36 = Instance.new("BlockMesh",ap36)
am36.Scale = Vector3.new(1,0.9,1)
aw36 = Instance.new("Weld")
aw36.Parent = ap36
aw36.Part0 = ap36
aw36.Part1 = LeftArm
aw36.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw36.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), 0) * CFrame.new(0.5, -2, 0)
ap37 = Instance.new("Part")
ap37.formFactor = 3
ap37.CanCollide = false
ap37.Name = "HelmP37"
ap37.Locked = true
ap37.Size = Vector3.new(3,0.3,2)
ap37.Parent = armorholder
ap37.BrickColor = BrickColor.new("Really black")
ap37.Reflectance = 0.1
am37 = Instance.new("BlockMesh",ap37)
aw37 = Instance.new("Weld")
aw37.Parent = ap37
aw37.Part0 = ap37
aw37.Part1 = LeftArm
aw37.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw37.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(-20)) * CFrame.new(0.5+1, -2+0.5, 0)
ap38 = Instance.new("Part")
ap38.formFactor = 3
ap38.CanCollide = false
ap38.Name = "HelmP38"
ap38.Locked = true
ap38.Size = Vector3.new(3.1,0.3,2.1)
ap38.Parent = armorholder
ap38.BrickColor = BrickColor.new("New Yeller")
ap38.Reflectance = 0.1
am38 = Instance.new("BlockMesh",ap38)
am38.Scale = Vector3.new(1,0.9,1)
aw38 = Instance.new("Weld")
aw38.Parent = ap38
aw38.Part0 = ap38
aw38.Part1 = LeftArm
aw38.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw38.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(-20)) * CFrame.new(0.5+1, -2+0.5, 0)
ap39 = Instance.new("Part")
ap39.formFactor = 3
ap39.CanCollide = false
ap39.Name = "HelmP39"
ap39.Locked = true
ap39.Size = Vector3.new(4.1,0.75,2.1)
ap39.Parent = armorholder
ap39.BrickColor = BrickColor.new("Pastel yellow")
am39 = Instance.new("SpecialMesh",ap39)
am39.Scale = Vector3.new(1,1,1)
am39.MeshType = "Sphere"
aw39 = Instance.new("Weld")
aw39.Parent = ap39
aw39.Part0 = ap39
aw39.Part1 = ap38
aw39.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw39.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(1, 0.25, 0)
ap40 = Instance.new("Part")
ap40.formFactor = 3
ap40.CanCollide = false
ap40.Name = "HelmP40"
ap40.Locked = true
ap40.Size = Vector3.new(2.15,2.5,2.15)
ap40.Parent = armorholder
ap40.BrickColor = BrickColor.new("Really black")
ap40.Reflectance = 0.1
am40 = Instance.new("BlockMesh",ap40)
am40.Scale = Vector3.new(1,1,1)
aw40 = Instance.new("Weld")
aw40.Parent = ap40
aw40.Part0 = ap40
aw40.Part1 = LeftArm
aw40.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw40.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 0.5, 0)
ap41 = Instance.new("Part")
ap41.formFactor = 3
ap41.CanCollide = false
ap41.Name = "HelmP41"
ap41.Locked = true
ap41.Size = Vector3.new(2,0.4,2)
ap41.Parent = armorholder
ap41.BrickColor = BrickColor.new("White")
ap41.Reflectance = 0.1
am41 = Instance.new("BlockMesh",ap41)
am41.Scale = Vector3.new(1.01,1.01,1.01)
aw41 = Instance.new("Weld")
aw41.Parent = ap41
aw41.Part0 = ap41
aw41.Part1 = LeftArm
aw41.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw41.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 2-0.2, 0)
ap42 = Instance.new("Part")
ap42.formFactor = 3
ap42.CanCollide = false
ap42.Name = "HelmP42"
ap42.Locked = true
ap42.Size = Vector3.new(2,1.5,2.1)
ap42.Parent = armorholder
ap42.BrickColor = BrickColor.new("Really blue")
ap42.Reflectance = 0.1
am42 = Instance.new("SpecialMesh",ap42)
am42.MeshType = "Sphere"
aw42 = Instance.new("Weld")
aw42.Parent = ap42
aw42.Part0 = ap42
aw42.Part1 = LeftArm
aw42.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw42.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0.5, 0.5, 0)
ap43 = Instance.new("Part")
ap43.formFactor = 3
ap43.CanCollide = false
ap43.Name = "HelmP43"
ap43.Locked = true
ap43.Size = Vector3.new(2,1.5,2.1)
ap43.Parent = armorholder
ap43.BrickColor = BrickColor.new("New Yeller")
ap43.Reflectance = 0.1
am43 = Instance.new("SpecialMesh",ap43)
am43.MeshType = "Sphere"
am43.Scale = Vector3.new(0.9,1.3,1.01)
aw43 = Instance.new("Weld")
aw43.Parent = ap43
aw43.Part0 = ap43
aw43.Part1 = LeftArm
aw43.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw43.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0.5, 0.5, 0)
ap44 = Instance.new("Part")
ap44.formFactor = 3
ap44.CanCollide = false
ap44.Name = "HelmP44"
ap44.Locked = true
ap44.Size = Vector3.new(2,1.5,2.1)
ap44.Parent = armorholder
ap44.BrickColor = BrickColor.new("Really blue")
ap44.Reflectance = 0.1
am44 = Instance.new("SpecialMesh",ap44)
am44.MeshType = "Sphere"
aw44 = Instance.new("Weld")
aw44.Parent = ap44
aw44.Part0 = ap44
aw44.Part1 = RightArm
aw44.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw44.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(-0.5, 0.5, 0)
ap45 = Instance.new("Part")
ap45.formFactor = 3
ap45.CanCollide = false
ap45.Name = "HelmP45"
ap45.Locked = true
ap45.Size = Vector3.new(2,1.5,2.1)
ap45.Parent = armorholder
ap45.BrickColor = BrickColor.new("New Yeller")
ap45.Reflectance = 0.1
am45 = Instance.new("SpecialMesh",ap45)
am45.MeshType = "Sphere"
am45.Scale = Vector3.new(0.9,1.3,1.01)
aw45 = Instance.new("Weld")
aw45.Parent = ap45
aw45.Part0 = ap45
aw45.Part1 = RightArm
aw45.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw45.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(-0.5, 0.5, 0)
ap46 = Instance.new("Part")
ap46.formFactor = 3
ap46.CanCollide = false
ap46.Name = "HelmP46"
ap46.Locked = true
ap46.Size = Vector3.new(2.15,2.5,2.15)
ap46.Parent = armorholder
ap46.BrickColor = BrickColor.new("Really black")
ap46.Reflectance = 0.1
am46 = Instance.new("BlockMesh",ap46)
am46.Scale = Vector3.new(1,1,1)
aw46 = Instance.new("Weld")
aw46.Parent = ap46
aw46.Part0 = ap46
aw46.Part1 = RightArm
aw46.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw46.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 0.5, 0)
ap47 = Instance.new("Part")
ap47.formFactor = 3
ap47.CanCollide = false
ap47.Name = "HelmP47"
ap47.Locked = true
ap47.Size = Vector3.new(2,0.4,2)
ap47.Parent = armorholder
ap47.BrickColor = BrickColor.new("White")
ap47.Reflectance = 0.1
am47 = Instance.new("BlockMesh",ap47)
am47.Scale = Vector3.new(1.01,1.01,1.01)
aw47 = Instance.new("Weld")
aw47.Parent = ap47
aw47.Part0 = ap47
aw47.Part1 = RightArm
aw47.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw47.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 2-0.2, 0)
ap48 = Instance.new("Part")
ap48.formFactor = 3
ap48.CanCollide = false
ap48.Name = "HelmP48"
ap48.Locked = true
ap48.Size = Vector3.new(2.15,1.15,2.15)
ap48.Parent = armorholder
ap48.BrickColor = BrickColor.new("Really black")
ap48.Reflectance = 0.1
am48 = Instance.new("BlockMesh",ap48)
am48.Scale = Vector3.new(1,1,1)
aw48 = Instance.new("Weld")
aw48.Parent = ap48
aw48.Part0 = ap48
aw48.Part1 = RightArm
aw48.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw48.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, -1.5, 0)
ap49 = Instance.new("Part")
ap49.formFactor = 3
ap49.CanCollide = false
ap49.Name = "HelmP49"
ap49.Locked = true
ap49.Size = Vector3.new(3,1.1,2.25)
ap49.Parent = armorholder
ap49.BrickColor = BrickColor.new("New Yeller")
ap49.Reflectance = 0.1
am49 = Instance.new("BlockMesh",ap49)
am49.Scale = Vector3.new(1,1,1)
aw49 = Instance.new("Weld")
aw49.Parent = ap49
aw49.Part0 = ap49
aw49.Part1 = RightArm
aw49.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw49.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, -1.5, 0)
ap50 = Instance.new("Part")
ap50.formFactor = 3
ap50.CanCollide = false
ap50.Name = "HelmP50"
ap50.Locked = true
ap50.Size = Vector3.new(1.5,1.5,2.5)
ap50.Parent = armorholder
ap50.BrickColor = BrickColor.new("Really blue")
ap50.Reflectance = 0.1
am50 = Instance.new("SpecialMesh",ap50)
am50.MeshType = "Sphere"
aw50 = Instance.new("Weld")
aw50.Parent = ap50
aw50.Part0 = ap50
aw50.Part1 = RightArm
aw50.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw50.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0.5, -1.25, 0)
ap51 = Instance.new("Part")
ap51.formFactor = 3
ap51.CanCollide = false
ap51.Name = "HelmP51"
ap51.Locked = true
ap51.Size = Vector3.new(1,1,2.2)
ap51.Parent = armorholder
ap51.BrickColor = BrickColor.new("Really blue")
ap51.Reflectance = 0.1
am51 = Instance.new("SpecialMesh",ap51)
am51.MeshType = "Sphere"
aw51 = Instance.new("Weld")
aw51.Parent = ap51
aw51.Part0 = ap51
aw51.Part1 = RightArm
aw51.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw51.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(-1, -0.75, 0)
ap52 = Instance.new("Part")
ap52.formFactor = 3
ap52.CanCollide = false
ap52.Name = "HelmP52"
ap52.Locked = true
ap52.Size = Vector3.new(2.1,2,2.1)
ap52.Parent = armorholder
ap52.BrickColor = BrickColor.new("Mid grey")
ap52.Reflectance = 0.1
am52 = Instance.new("BlockMesh",ap52)
aw52 = Instance.new("Weld")
aw52.Parent = ap52
aw52.Part0 = ap52
aw52.Part1 = RightLeg
aw52.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw52.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1, 0.1)
ap53 = Instance.new("Part")
ap53.formFactor = 3
ap53.CanCollide = false
ap53.Name = "HelmP53"
ap53.Locked = true
ap53.Size = Vector3.new(1.5,2.5,2.1)
ap53.Parent = armorholder
ap53.BrickColor = BrickColor.new("New Yeller")
ap53.Reflectance = 0.1
am53 = Instance.new("BlockMesh",ap53)
aw53 = Instance.new("Weld")
aw53.Parent = ap53
aw53.Part0 = ap53
aw53.Part1 = RightLeg
aw53.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw53.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1-0.5, 0.15)
ap54 = Instance.new("Part")
ap54.formFactor = 3
ap54.CanCollide = false
ap54.Name = "HelmP54"
ap54.Locked = true
ap54.Size = Vector3.new(1.8,2.5,2.1)
ap54.Parent = armorholder
ap54.BrickColor = BrickColor.new("Mid grey")
ap54.Reflectance = 0.1
am54 = Instance.new("BlockMesh",ap54)
aw54 = Instance.new("Weld")
aw54.Parent = ap54
aw54.Part0 = ap54
aw54.Part1 = RightLeg
aw54.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw54.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1-0.75, 0.1)
ap55 = Instance.new("Part")
ap55.formFactor = 3
ap55.CanCollide = false
ap55.Name = "HelmP55"
ap55.Locked = true
ap55.Size = Vector3.new(2.2,1.5,2.1)
ap55.Parent = armorholder
ap55.BrickColor = BrickColor.new("New Yeller")
ap55.Reflectance = 0.1
am55 = Instance.new("BlockMesh",ap55)
aw55 = Instance.new("Weld")
aw55.Parent = ap55
aw55.Part0 = ap55
aw55.Part1 = RightLeg
aw55.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw55.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1, 0.101)
ap56 = Instance.new("Part")
ap56.formFactor = 3
ap56.CanCollide = false
ap56.Name = "HelmP52"
ap56.Locked = true
ap56.Size = Vector3.new(2.1,2,2.1)
ap56.Parent = armorholder
ap56.BrickColor = BrickColor.new("Mid grey")
ap56.Reflectance = 0.1
am56 = Instance.new("BlockMesh",ap56)
aw56 = Instance.new("Weld")
aw56.Parent = ap56
aw56.Part0 = ap56
aw56.Part1 = LeftLeg
aw56.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw56.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1, 0.1)
ap57 = Instance.new("Part")
ap57.formFactor = 3
ap57.CanCollide = false
ap57.Name = "HelmP53"
ap57.Locked = true
ap57.Size = Vector3.new(1.5,2.5,2.1)
ap57.Parent = armorholder
ap57.BrickColor = BrickColor.new("New Yeller")
ap57.Reflectance = 0.1
am57 = Instance.new("BlockMesh",ap57)
aw57 = Instance.new("Weld")
aw57.Parent = ap57
aw57.Part0 = ap57
aw57.Part1 = LeftLeg
aw57.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw57.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1-0.5, 0.15)
ap58 = Instance.new("Part")
ap58.formFactor = 3
ap58.CanCollide = false
ap58.Name = "HelmP54"
ap58.Locked = true
ap58.Size = Vector3.new(1.8,2.5,2.1)
ap58.Parent = armorholder
ap58.BrickColor = BrickColor.new("Mid grey")
ap58.Reflectance = 0.1
am58 = Instance.new("BlockMesh",ap58)
aw58 = Instance.new("Weld")
aw58.Parent = ap58
aw58.Part0 = ap58
aw58.Part1 = LeftLeg
aw58.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw58.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1-0.75, 0.1)
ap59 = Instance.new("Part")
ap59.formFactor = 3
ap59.CanCollide = false
ap59.Name = "HelmP55"
ap59.Locked = true
ap59.Size = Vector3.new(2.2,1.5,2.1)
ap59.Parent = armorholder
ap59.BrickColor = BrickColor.new("New Yeller")
ap59.Reflectance = 0.1
am59 = Instance.new("BlockMesh",ap59)
aw59 = Instance.new("Weld")
aw59.Parent = ap59
aw59.Part0 = ap59
aw59.Part1 = LeftLeg
aw59.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw59.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 1, 0.101)
ap60 = Instance.new("Part")
ap60.formFactor = 3
ap60.CanCollide = false
ap60.Name = "HelmP60"
ap60.Locked = true
ap60.Size = Vector3.new(4,3,0.2)
ap60.Parent = armorholder
ap60.BrickColor = BrickColor.new("Really red")
am60 = Instance.new("BlockMesh",ap60)
aw60 = Instance.new("Weld")
aw60.Parent = ap60
aw60.Part0 = ap60
aw60.Part1 = Torso
aw60.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw60.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0, 4.5-1.5, -1.1)
ap61 = Instance.new("Part")
ap61.formFactor = 3
ap61.CanCollide = false
ap61.Name = "HelmP61"
ap61.Locked = true
ap61.Size = Vector3.new(0.2,3,2)
ap61.Parent = armorholder
ap61.BrickColor = BrickColor.new("Really red")
am61 = Instance.new("BlockMesh",ap61)
aw61 = Instance.new("Weld")
aw61.Parent = ap61
aw61.Part0 = ap61
aw61.Part1 = Torso
aw61.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw61.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(2.1, 4.5-1.5,0)
ap62 = Instance.new("Part")
ap62.formFactor = 3
ap62.CanCollide = false
ap62.Name = "HelmP62"
ap62.Locked = true
ap62.Size = Vector3.new(0.2,3,2)
ap62.Parent = armorholder
ap62.BrickColor = BrickColor.new("Really red")
am62 = Instance.new("BlockMesh",ap62)
aw62 = Instance.new("Weld")
aw62.Parent = ap62
aw62.Part0 = ap62
aw62.Part1 = Torso
aw62.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
aw62.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(-2.1, 4.5-1.5,0)
RAP = Instance.new("Part")
RAP.formFactor = 0
RAP.CanCollide = false
RAP.Name = "RAPart"
RAP.Locked = true
RAP.Size = Vector3.new(1,1,1)
RAP.Parent = bodyholder
RAP.Transparency = 1
w = Instance.new("Weld")
w.Parent = RAP
w.Part0 = RAP
w.Part1 = RightArm
w.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(0, 2, 0)
LAP = Instance.new("Part")
LAP.formFactor = 0
LAP.CanCollide = false
LAP.Name = "LAPart"
LAP.Locked = true
LAP.Size = Vector3.new(1,1,1)
LAP.Parent = bodyholder
LAP.Transparency = 1
wl = Instance.new("Weld")
wl.Parent = LAP
wl.Part0 = LAP
wl.Part1 = LeftArm
wl.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
wl.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0) * CFrame.new(0, 2, 0)
swordholder = Instance.new("Model")
swordholder.Name = "Weapon"
swordholder.Parent = bodyholder
prt1 = Instance.new("Part")
prt1.formFactor = 3
prt1.CanCollide = false
prt1.Name = "NaginataHandle"
prt1.Locked = true
prt1.Size = Vector3.new(0.5,15,0.5)
prt1.Parent = swordholder
prt1.BrickColor = BrickColor.new("Really red")
m1 = Instance.new("CylinderMesh",prt1)
w1 = Instance.new("Weld")
w1.Parent = prt1
w1.Part0 = prt1
w1.Part1 = LAP
w1.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w1.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90+10), math.rad(0), math.rad(0)) * CFrame.new(0,0,0)
prt2 = Instance.new("Part")
prt2.formFactor = 3
prt2.CanCollide = false
prt2.Name = "NaginataBlade"
prt2.Locked = true
prt2.Size = Vector3.new(0.5,3,0.5)
prt2.Parent = swordholder
prt2.BrickColor = BrickColor.new("Mid grey")
prt2.Reflectance = 0.2
m2 = Instance.new("BlockMesh",prt2)
w2 = Instance.new("Weld")
w2.Parent = prt2
w2.Part0 = prt2
w2.Part1 = prt1
w2.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w2.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,-7.5,0)
prt3 = Instance.new("Part")
prt3.formFactor = 3
prt3.CanCollide = false
prt3.Name = "NaginataBlade"
prt3.Locked = true
prt3.Size = Vector3.new(0.5,0.5,3)
prt3.Parent = swordholder
prt3.BrickColor = BrickColor.new("Mid grey")
prt3.Reflectance = 0.2
m3 = Instance.new("BlockMesh",prt3)
w3 = Instance.new("Weld")
w3.Parent = prt3
w3.Part0 = prt3
w3.Part1 = prt1
w3.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w3.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,-7.5,0)
prt4 = Instance.new("Part")
prt4.formFactor = 3
prt4.CanCollide = false
prt4.Name = "NaginataBlade"
prt4.Locked = true
prt4.Size = Vector3.new(0.5,0.5,3)
prt4.Parent = swordholder
prt4.BrickColor = BrickColor.new("Mid grey")
prt4.Reflectance = 0.2
m4 = Instance.new("SpecialMesh",prt4)
m4.MeshType = "Wedge"
w4 = Instance.new("Weld")
w4.Parent = prt4
w4.Part0 = prt4
w4.Part1 = prt1
w4.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w4.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0,-7.5+1.25,1.5)
prt5 = Instance.new("Part")
prt5.formFactor = 3
prt5.CanCollide = false
prt5.Name = "NaginataBlade"
prt5.Locked = true
prt5.Size = Vector3.new(0.5,0.5,3)
prt5.Parent = swordholder
prt5.BrickColor = BrickColor.new("Mid grey")
prt5.Reflectance = 0.2
m5 = Instance.new("SpecialMesh",prt5)
m5.MeshType = "Wedge"
w5 = Instance.new("Weld")
w5.Parent = prt5
w5.Part0 = prt5
w5.Part1 = prt1
w5.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w5.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(180), math.rad(0)) * CFrame.new(0,-7.5+1.25,-1.5)
prt6 = Instance.new("Part")
prt6.formFactor = 3
prt6.CanCollide = false
prt6.Name = "NaginataBlade"
prt6.Locked = true
prt6.Size = Vector3.new(0.5,2,3)
prt6.Parent = swordholder
prt6.BrickColor = BrickColor.new("Mid grey")
prt6.Reflectance = 0.2
m6 = Instance.new("SpecialMesh",prt6)
m6.MeshType = "Wedge"
w6 = Instance.new("Weld")
w6.Parent = prt6
w6.Part0 = prt6
w6.Part1 = prt1
w6.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w6.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(180), math.rad(0)) * CFrame.new(0,-10.75,1)
prt7 = Instance.new("Part")
prt7.formFactor = 3
prt7.CanCollide = false
prt7.Name = "NaginataBlade"
prt7.Locked = true
prt7.Size = Vector3.new(0.5,0.5,4)
prt7.Parent = swordholder
prt7.BrickColor = BrickColor.new("Mid grey")
prt7.Reflectance = 0.2
m7 = Instance.new("BlockMesh",prt7)
w7 = Instance.new("Weld")
w7.Parent = prt7
w7.Part0 = prt7
w7.Part1 = prt1
w7.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w7.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,-9,0)
prt8 = Instance.new("Part")
prt8.formFactor = 3
prt8.CanCollide = false
prt8.Name = "NaginataBlade"
prt8.Locked = true
prt8.Size = Vector3.new(0.5,0.5,1)
prt8.Parent = swordholder
prt8.BrickColor = BrickColor.new("Mid grey")
prt8.Reflectance = 0.2
m8 = Instance.new("SpecialMesh",prt8)
m8.MeshType = "Wedge"
w8 = Instance.new("Weld")
w8.Parent = prt8
w8.Part0 = prt8
w8.Part1 = prt1
w8.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w8.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0,-8.25,1.75)
prt9 = Instance.new("Part")
prt9.formFactor = 3
prt9.CanCollide = false
prt9.Name = "NaginataBlade"
prt9.Locked = true
prt9.Size = Vector3.new(0.5,0.5,1)
prt9.Parent = swordholder
prt9.BrickColor = BrickColor.new("Mid grey")
prt9.Reflectance = 0.2
m9 = Instance.new("SpecialMesh",prt9)
m9.MeshType = "Wedge"
w9 = Instance.new("Weld")
w9.Parent = prt9
w9.Part0 = prt9
w9.Part1 = prt1
w9.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w9.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(180), math.rad(0)) * CFrame.new(0,-8.25,-1.75)
prt10 = Instance.new("Part")
prt10.formFactor = 3
prt10.CanCollide = false
prt10.Name = "NaginataBlade"
prt10.Locked = true
prt10.Size = Vector3.new(0.5,0.5,1)
prt10.Parent = swordholder
prt10.BrickColor = BrickColor.new("Mid grey")
prt10.Reflectance = 0.2
m10 = Instance.new("SpecialMesh",prt10)
m10.MeshType = "Wedge"
w10 = Instance.new("Weld")
w10.Parent = prt10
w10.Part0 = prt10
w10.Part1 = prt1
w10.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w10.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(180), math.rad(0)) * CFrame.new(0,-9-0.7,-1.75)
prt11 = Instance.new("Part")
prt11.formFactor = 3
prt11.CanCollide = false
prt11.Name = "NaginataBottom"
prt11.Locked = true
prt11.Size = Vector3.new(1,1,1)
prt11.Parent = swordholder
prt11.BrickColor = BrickColor.new("Mid grey")
prt11.Reflectance = 0.2
m11 = Instance.new("SpecialMesh",prt11)
m11.MeshType = "Sphere"
w11 = Instance.new("Weld")
w11.Parent = prt11
w11.Part0 = prt11
w11.Part1 = prt1
w11.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
w11.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(180), math.rad(0)) * CFrame.new(0,7.5,0)
pprt1 = Instance.new("Part")
pprt1.formFactor = 3
pprt1.CanCollide = false
pprt1.Name = "ExcaliburHandle"
pprt1.Locked = true
pprt1.Size = Vector3.new(1,3,1)
pprt1.Parent = swordholder
pprt1.BrickColor = BrickColor.new("Really black")
mm1 = Instance.new("CylinderMesh",pprt1)
ww1 = Instance.new("Weld")
ww1.Parent = pprt1
ww1.Part0 = pprt1
ww1.Part1 = RAP
ww1.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww1.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0,0,0)
pprt2 = Instance.new("Part")
pprt2.formFactor = 3
pprt2.CanCollide = false
pprt2.Name = "ExcaliburCrest"
pprt2.Locked = true
pprt2.Size = Vector3.new(1,2,2)
pprt2.Parent = swordholder
pprt2.BrickColor = BrickColor.new("New Yeller")
mm2 = Instance.new("SpecialMesh",pprt2)
mm2.MeshType = "Sphere"
ww2 = Instance.new("Weld")
ww2.Parent = pprt2
ww2.Part0 = pprt2
ww2.Part1 = pprt1
ww2.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww2.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,-2,0)
pprt3 = Instance.new("Part")
pprt3.formFactor = 3
pprt3.CanCollide = false
pprt3.Name = "ExcaliburCrest"
pprt3.Locked = true
pprt3.Size = Vector3.new(1,2,1)
pprt3.Parent = swordholder
pprt3.BrickColor = BrickColor.new("New Yeller")
mm3 = Instance.new("SpecialMesh",pprt3)
mm3.MeshId = "http://www.roblox.com/asset/?id=1778999"
mm3.Scale = Vector3.new(0.5,1,1)
ww3 = Instance.new("Weld")
ww3.Parent = pprt3
ww3.Part0 = pprt3
ww3.Part1 = pprt1
ww3.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww3.C0 = CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0,-2,1)
pprt4 = Instance.new("Part")
pprt4.formFactor = 3
pprt4.CanCollide = false
pprt4.Name = "ExcaliburCrest"
pprt4.Locked = true
pprt4.Size = Vector3.new(1,2,1)
pprt4.Parent = swordholder
pprt4.BrickColor = BrickColor.new("New Yeller")
mm4 = Instance.new("SpecialMesh",pprt4)
mm4.MeshId = "http://www.roblox.com/asset/?id=1778999"
mm4.Scale = Vector3.new(0.5,1,1)
ww4 = Instance.new("Weld")
ww4.Parent = pprt4
ww4.Part0 = pprt4
ww4.Part1 = pprt1
ww4.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww4.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(0), math.rad(0)) * CFrame.new(0,-2,-1)
for i = -1 , 1 do
pprt5 = Instance.new("Part")
pprt5.formFactor = 3
pprt5.CanCollide = false
pprt5.Name = "ExcaliburCrest"
pprt5.Locked = true
pprt5.Size = Vector3.new(1,2,1)
pprt5.Parent = swordholder
pprt5.BrickColor = BrickColor.new("Really red")
mm5 = Instance.new("SpecialMesh",pprt5)
mm5.MeshId = "http://www.roblox.com/asset/?id=1778999"
mm5.Scale = Vector3.new(0.1,1.3,1.2)
ww5 = Instance.new("Weld")
ww5.Parent = pprt5
ww5.Part0 = pprt5
ww5.Part1 = pprt2
ww5.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww5.C0 = CFrame.new(0,-1.5,0) * CFrame.fromEulerAnglesXYZ(math.rad(-90+30*i), math.rad(0), math.rad(0))
end
for i = -1 , 1 do
pprt6 = Instance.new("Part")
pprt6.formFactor = 3
pprt6.CanCollide = false
pprt6.Name = "ExcaliburCrest"
pprt6.Locked = true
pprt6.Size = Vector3.new(1,2,1)
pprt6.Parent = swordholder
pprt6.BrickColor = BrickColor.new("Really red")
mm6 = Instance.new("SpecialMesh",pprt6)
mm6.MeshId = "http://www.roblox.com/asset/?id=1778999"
mm6.Scale = Vector3.new(0.1,1.3,1.2)
ww6 = Instance.new("Weld")
ww6.Parent = pprt6
ww6.Part0 = pprt6
ww6.Part1 = pprt2
ww6.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww6.C0 = CFrame.new(0,-1.5,0) * CFrame.fromEulerAnglesXYZ(math.rad(90+30*i), math.rad(0), math.rad(0))
end
pprt7 = Instance.new("Part")
pprt7.formFactor = 3
pprt7.CanCollide = false
pprt7.Name = "ExcaliburCrest"
pprt7.Locked = true
pprt7.Size = Vector3.new(1,0.5,1)
pprt7.Parent = swordholder
pprt7.BrickColor = BrickColor.new("Really red")
mm7 = Instance.new("CylinderMesh",pprt7)
mm7.Scale = Vector3.new(1.2,1,1.2)
ww7 = Instance.new("Weld")
ww7.Parent = pprt7
ww7.Part0 = pprt7
ww7.Part1 = pprt1
ww7.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww7.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,1.5,0)
pprt8 = Instance.new("Part")
pprt8.formFactor = 3
pprt8.CanCollide = false
pprt8.Name = "ExcaliburBlade"
pprt8.Locked = true
pprt8.Size = Vector3.new(0.2,10,1)
pprt8.Parent = swordholder
pprt8.BrickColor = BrickColor.new("Really red")
mm8 = Instance.new("BlockMesh",pprt8)
mm8.Scale = Vector3.new(1,1,1)
ww8 = Instance.new("Weld")
ww8.Parent = pprt8
ww8.Part0 = pprt8
ww8.Part1 = pprt1
ww8.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww8.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,-2.5-5,0)
pprt9 = Instance.new("Part")
pprt9.formFactor = 3
pprt9.CanCollide = false
pprt9.Name = "ExcaliburBlade"
pprt9.Locked = true
pprt9.Size = Vector3.new(0.2,10,1.5)
pprt9.Parent = swordholder
pprt9.BrickColor = BrickColor.new("Bright orange")
mm9 = Instance.new("BlockMesh",pprt9)
mm9.Scale = Vector3.new(0.9,1,1)
ww9 = Instance.new("Weld")
ww9.Parent = pprt9
ww9.Part0 = pprt9
ww9.Part1 = pprt1
ww9.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww9.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,-2.5-5,0)
pprt10 = Instance.new("Part")
pprt10.formFactor = 3
pprt10.CanCollide = false
pprt10.Name = "ExcaliburTip"
pprt10.Locked = true
pprt10.Size = Vector3.new(0.2,0.75,2)
pprt10.Parent = swordholder
pprt10.BrickColor = BrickColor.new("Bright orange")
mm10 = Instance.new("SpecialMesh",pprt10)
mm10.Scale = Vector3.new(0.9,1,1)
mm10.MeshType = "Wedge"
ww10 = Instance.new("Weld")
ww10.Parent = pprt10
ww10.Part0 = pprt10
ww10.Part1 = pprt1
ww10.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww10.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(0), math.rad(0)) * CFrame.new(0,-12.5-1,-0.375)
pprt11 = Instance.new("Part")
pprt11.formFactor = 3
pprt11.CanCollide = false
pprt11.Name = "ExcaliburTip"
pprt11.Locked = true
pprt11.Size = Vector3.new(0.2,0.75,2)
pprt11.Parent = swordholder
pprt11.BrickColor = BrickColor.new("Bright orange")
mm11 = Instance.new("SpecialMesh",pprt11)
mm11.Scale = Vector3.new(0.9,1,1)
mm11.MeshType = "Wedge"
ww11 = Instance.new("Weld")
ww11.Parent = pprt11
ww11.Part0 = pprt11
ww11.Part1 = pprt1
ww11.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww11.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(180), math.rad(0)) * CFrame.new(0,-12.5-1,0.375)
pprt12 = Instance.new("Part")
pprt12.formFactor = 3
pprt12.CanCollide = false
pprt12.Name = "ExcaliburTip"
pprt12.Locked = true
pprt12.Size = Vector3.new(0.2,0.5,2)
pprt12.Parent = swordholder
pprt12.BrickColor = BrickColor.new("Really red")
mm12 = Instance.new("SpecialMesh",pprt12)
mm12.Scale = Vector3.new(1,1,1)
mm12.MeshType = "Wedge"
ww12 = Instance.new("Weld")
ww12.Parent = pprt12
ww12.Part0 = pprt12
ww12.Part1 = pprt1
ww12.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww12.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(0), math.rad(0)) * CFrame.new(0,-12.5-1,-0.25)
pprt13 = Instance.new("Part")
pprt13.formFactor = 3
pprt13.CanCollide = false
pprt13.Name = "ExcaliburTip"
pprt13.Locked = true
pprt13.Size = Vector3.new(0.2,0.5,2)
pprt13.Parent = swordholder
pprt13.BrickColor = BrickColor.new("Really red")
mm13 = Instance.new("SpecialMesh",pprt13)
mm13.Scale = Vector3.new(1,1,1)
mm13.MeshType = "Wedge"
ww13 = Instance.new("Weld")
ww13.Parent = pprt13
ww13.Part0 = pprt13
ww13.Part1 = pprt1
ww13.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww13.C0 = CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(180), math.rad(0)) * CFrame.new(0,-12.5-1,0.25)
pprt14 = Instance.new("Part")
pprt14.formFactor = 3
pprt14.CanCollide = false
pprt14.Name = "ExcaliburBladeHitbox"
pprt14.Locked = true
pprt14.Size = Vector3.new(0.2,12,1.5)
pprt14.Parent = swordholder
pprt14.Transparency = 1
ww14 = Instance.new("Weld")
ww14.Parent = pprt14
ww14.Part0 = pprt14
ww14.Part1 = pprt1
ww14.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0,0)
ww14.C0 = CFrame.fromEulerAnglesXYZ(math.rad(0), math.rad(0), math.rad(0)) * CFrame.new(0,-8.5,0)
function unequipweld()
end
unequipweld()
function equipweld()
end
function ss(parent,p) --Slash
local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
SlashSound.Parent = parent
SlashSound.Volume = .7
SlashSound.Pitch = p
SlashSound.PlayOnRemove = true
coroutine.resume(coroutine.create(function()
wait()
SlashSound.Parent = nil
end))
end
function uss(parent,p) --unsheath
local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxasset://sounds\\unsheath.wav"
SlashSound.Parent = parent
SlashSound.Volume = .7
SlashSound.Pitch = p
SlashSound.PlayOnRemove = true
coroutine.resume(coroutine.create(function()
wait()
SlashSound.Parent = nil
end))
end
function ms(parent,p) --Metal Cling Sound
local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxasset://sounds\\metal.ogg"
SlashSound.Parent = parent
SlashSound.Volume = 1
SlashSound.Pitch = p
SlashSound.PlayOnRemove = true
coroutine.resume(coroutine.create(function()
wait()
SlashSound.Parent = nil
end))
end
--
--
function returndmg()
mindamage = omindamage
maxdamage = omaxdamage
crtmaxdamage = ocrtmaxdamage
end
function subdmg(sub)
mindamage = omindamage - sub
maxdamage = omaxdamage - sub
crtmaxdamage = ocrtmaxdamage - sub
end
function prcntdmg(sub)
mindamage = math.floor(omindamage - (omindamage*(sub/100)))
maxdamage = math.floor(omaxdamage - (omaxdamage*(sub/100)))
crtmaxdamage = math.floor(ocrtmaxdamage - (ocrtmaxdamage*(sub/100)))
end
function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end
local function rayCast(Pos, Dir, Max, Ignore) -- Origin Position , Direction, MaxDistance , IgnoreDescendants
return game.Workspace:FindPartOnRay(Ray.new(Pos, Dir.unit * (Max or 999.999)), Ignore)
end
function equipanim()
attack = true
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20*i), 0, math.rad(45*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-20*i), 0, math.rad(-45*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(0, 0, math.rad(20*i))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(0, 0, math.rad(-20*i))
LWL.C1 = CFrame.new(-1, 2, 0)
end
attack = false
end
function damagesplat(dmg,hit,crit,blocked)
local mo = Instance.new("Model")
mo.Name = dmg
local pa = Instance.new("Part",mo)
pa.formFactor = 3
pa.Size = Vector3.new(0.8,0.3,0.8)
if crit then
pa.BrickColor = BrickColor.new("New Yeller")
elseif not crit then
pa.BrickColor = BrickColor.new("Really red")
end
if blocked then pa.BrickColor = BrickColor.new("Really blue") end
pa.CFrame = CFrame.new(hit.Position) * CFrame.new(0, 3, 0)
pa.Name = "Head"
local hah = Instance.new("Humanoid")
hah.Parent = mo
hah.MaxHealth = 0
hah.Health = 0
local bp = Instance.new("BodyPosition")
bp.P = 14000
bp.maxForce = Vector3.new(math.huge, math.huge, math.huge)
bp.position = hit.Position + Vector3.new(0, 5, 0)
coroutine.resume(coroutine.create(function()
wait()
mo.Parent = Character
bp.Parent = pa
wait(1.4)
mo:remove()
end))
return pa
end
function damage(hum,dmg,critornot)
local pa = damagesplat(dmg,hum.Torso,critornot)
hum:TakeDamage(dmg)
coroutine.resume(coroutine.create(function()
tagHumanoid(hum,Player)
wait(1)
untagHumanoid(hum)
end))
return pa
end
function AddRage(add)
Rage = Rage + add
if Rage > MaxRage then
Rage = MaxRage
end
end
function OT(hit) --Normal Damage
if Hitdeb == 1 then return end
if hit.Parent == nil then return end
local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil and hum ~= Character.Humanoid then
if hum.Health <= 0 then return end
local critrandomizer = math.random(crtrate)
if critrandomizer ~= 1 then
local rndmdamage = math.random(mindamage,maxdamage)
damage(hum,rndmdamage,false)
elseif critrandomizer == 1 then
local rndmdamage = math.random(maxdamage,crtmaxdamage)
damage(hum,rndmdamage,true)
end
Hitdeb = 1
end
end
function OT2(hit) --Normal Damage
if Hitdeb2 == 1 then return end
if hit.Parent == nil then return end
local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil and hum ~= Character.Humanoid then
if hum.Health <= 0 then return end
local critrandomizer = math.random(crtrate)
if critrandomizer ~= 1 then
local rndmdamage = math.random(mindamage,maxdamage)*2
damage(hum,rndmdamage,false)
elseif critrandomizer == 1 then
local rndmdamage = math.random(maxdamage,crtmaxdamage)*2
damage(hum,rndmdamage,true)
end
Hitdeb2 = 1
end
end
function AoE(p,magnitude)
local c = game.Workspace:GetChildren();
for i = 1, #c do
local hum = c[i]:findFirstChild("Humanoid")
if hum ~= nil and hum.Health ~= 0 then
local head = c[i]:findFirstChild("Head");
if head ~= nil then
local mag = (head.Position - p).magnitude;
if mag <= magnitude and c[i].Name ~= Character.Name then
local foundd = false
for ii = 1 , #AoETrue do
if AoETrue[ii] == c[i].Name then
foundd = true
end
end
if foundd then
end
--
if not foundd then
local critrandomizer = math.random(crtrate)
if critrandomizer ~= 1 then
local rndmdamage = math.random(mindamage,maxdamage)
damage(hum,rndmdamage,false)
elseif critrandomizer == 1 then
local rndmdamage = math.random(maxdamage,crtmaxdamage)
damage(hum,rndmdamage,true)
end
table.insert(AoETrue,c[i].Name)
end
end
end
end
end
for ii = 1 , #AoETrue do
table.remove(AoETrue,#AoETrue)
end
end
--
--
function effect(Color,Ref,LP,P1)
local effectsmsh = Instance.new("BlockMesh")
effectsmsh.Scale = Vector3.new(1,1,1)
effectsmsh.Name = "Mesh"
local effectsg = Instance.new("Part")
effectsg.formFactor = 3
effectsg.CanCollide = false
effectsg.Name = "Eff"
effectsg.Locked = true
effectsg.Anchored = true
effectsg.Size = Vector3.new(0.2,1,0.2)
effectsg.Parent = bodyholder
effectsmsh.Parent = effectsg
effectsg.BrickColor = BrickColor.new(Color)
effectsg.Reflectance = Ref
local point1 = P1
local mg = (LP.p - point1.p).magnitude
effectsg.Size = Vector3.new(0.2,mg,0.2)
effectsg.CFrame = CFrame.new((LP.p+point1.p)/2,point1.p) * CFrame.Angles(math.rad(90),0,0)
coroutine.resume(coroutine.create(function()
for i = 0 , 1 , 0.1 do
wait()
effectsg.Transparency = 1*i
effectsmsh.Scale = Vector3.new(1-1*i,1,1-1*i)
end
wait()
effectsg.Parent = nil
end))
end
--
con,con2,con3 = nil,nil,nil
conn,conn2,conn3 = nil,nil,nil
function dmg1cnnct()
if con ~= nil then
con:disconnect()
Hitdeb = 0
end
con = prt1.Touched:connect(OT)
con2 = prt7.Touched:connect(OT)
con3 = prt2.Touched:connect(OT)
end
function dmg1dc()
if con ~= nil then
con:disconnect()
Hitdeb = 0
end
if con2 ~= nil then
con2:disconnect()
Hitdeb = 0
end
if con3 ~= nil then
con3:disconnect()
Hitdeb = 0
end
end
function dmg2cnnct()
if con ~= nil then
con:disconnect()
Hitdeb = 0
end
conn = pprt14.Touched:connect(OT2)
conn2 = pprt1.Touched:connect(OT2)
end
function dmg2dc()
if conn ~= nil then
conn:disconnect()
Hitdeb2 = 0
end
if conn2 ~= nil then
conn2:disconnect()
Hitdeb2 = 0
end
if conn3 ~= nil then
conn3:disconnect()
Hitdeb2 = 0
end
end
function rptddmg(value,des,inc)
coroutine.resume(coroutine.create(function()
repeat
wait(inc)
Hitdeb = 0
until value == des
end))
end
function atktype(s,e)
coroutine.resume(coroutine.create(function ()
attacktype = e
wait(0.25)
attacktype = s
end))
end
walking = false
jumping = false
Target = nil
function Walk()
--if attack==true then return end
if walking then return end
for i = 0.1 , 1 , 0.1 do
if jumping then return end
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20-40*i), 0, math.rad(45+20*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-20-40*i), 0, math.rad(-45-20*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(math.rad(45*i), 0, math.rad(20-10*i))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(math.rad(-45*i), 0, math.rad(-20+10*i))
LWL.C1 = CFrame.new(-1, 2, 0)
end
repeat
for i = 0.1 , 1 , 0.1 do
if jumping then return end
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-60-5*i), 0, math.rad(65))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-60-5*i), 0, math.rad(-65))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(math.rad(45-90*i), 0, math.rad(10))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(math.rad(-45+90*i), 0, math.rad(-10))
LWL.C1 = CFrame.new(-1, 2, 0)
end
for i = 0.1 , 1 , 0.1 do
if jumping then return end
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-65+5*i), 0, math.rad(65))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-65+5*i), 0, math.rad(-65))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(math.rad(-45+90*i), 0, math.rad(10))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(math.rad(45-90*i), 0, math.rad(-10))
LWL.C1 = CFrame.new(-1, 2, 0)
end
until not walking or jumping
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-60+40*i), 0, math.rad(65-20*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-60+40*i), 0, math.rad(-65+20*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(math.rad(45-45*i), 0, math.rad(10+10*i))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(math.rad(-45+45*i), 0, math.rad(-10-10*i))
LWL.C1 = CFrame.new(-1, 2, 0)
end
end
function Jump()
if attack==true then return end
if jumping then return end
jumping = true
Character.Humanoid.PlatformStand=false
Character.Humanoid.Jump=true
local vel = Instance.new("BodyVelocity",Torso)
vel.maxForce = Vector3.new(0,1,0) * math.huge
vel.P = vel.P * 5
vel.velocity = Vector3.new(0,jump,0)
coroutine.resume(coroutine.create(function()
wait() wait() wait() wait()
vel.Parent=nil
end))
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20+200*i), 0, math.rad(45-20*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-20+200*i), 0, math.rad(-45+20*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(math.rad(-10*i), 0, math.rad(20-10*i))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(math.rad(-10*i), 0, math.rad(-20+10*i))
LWL.C1 = CFrame.new(-1, 2, 0)
end
wait(1)
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(180-200*i), 0, math.rad(25+20*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(180-200*i), 0, math.rad(-25-20*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(math.rad(-10+10*i), 0, math.rad(10+10*i))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(math.rad(-10+10*i), 0, math.rad(-10-10*i))
LWL.C1 = CFrame.new(-1, 2, 0)
end
jumping = false
end
function NaginataSpin()
attack = true
dmg1cnnct()
local LastPoint = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
ss(Head,math.random())
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20), 0, math.rad(45))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-20+110*i), 0, math.rad(-45+35*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(100+20*i), math.rad(90*i), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("White",0.5,LastPoint,Point)
LastPoint = Point
end
Hitdeb2 = 0
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20), 0, math.rad(45))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(90), 0, math.rad(-10+20*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(120), math.rad(90+360*i), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("White",0.5,LastPoint,Point)
LastPoint = Point
end
Hitdeb2 = 0
for i = 0.15 , 1 , 0.15 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20), 0, math.rad(45))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(90), 0, math.rad(10-10*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(120), math.rad(90+270*i), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("White",0.5,LastPoint,Point)
LastPoint = Point
end
dmg1dc()
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20), 0, math.rad(45))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(90-110*i), 0, math.rad(-45*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(120-20*i), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
end
wait(0.2)
attack = false
end
function DualThrust()
attack = true
ss(Head,math.random())
dmg1cnnct()
dmg2cnnct()
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20+90*i), 0, math.rad(45-65*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-20+90*i), 0, math.rad(-45+65*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(100+80*i), math.rad(0), math.rad(0)) * CFrame.new(0, 5*i, 0)
ww1.C0 = CFrame.Angles(math.rad(90+90*i), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
end
local LastPoint = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
local LastPoint2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
for i = 0.2 , 1 , 0.2 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(70), 0, math.rad(-20+110*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(70), 0, math.rad(20-110*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(180), math.rad(0), math.rad(0)) * CFrame.new(0, 5, 0)
ww1.C0 = CFrame.Angles(math.rad(180), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("Bright violet",0.5,LastPoint,Point)
LastPoint = Point
local Point2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
effect("Really red",0.5,LastPoint2,Point2)
LastPoint2 = Point2
end
for i = 0.2 , 1 , 0.2 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(70), 0, math.rad(90+10*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(70), 0, math.rad(-90-10*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(180), math.rad(0), math.rad(0)) * CFrame.new(0, 5, 0)
ww1.C0 = CFrame.Angles(math.rad(180), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("Bright violet",0.5,LastPoint,Point)
LastPoint = Point
local Point2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
effect("Really red",0.5,LastPoint2,Point2)
LastPoint2 = Point2
end
dmg1dc()
dmg2dc()
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(70-90*i), 0, math.rad(100-55*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(70-90*i), 0, math.rad(-100+55*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(180-80*i), math.rad(0), math.rad(0)) * CFrame.new(0, 5-5*i, 0)
ww1.C0 = CFrame.Angles(math.rad(180-90*i), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("Bright violet",0.5,LastPoint,Point)
LastPoint = Point
local Point2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
effect("Really red",0.5,LastPoint2,Point2)
LastPoint2 = Point2
end
wait(0.5)
attack = false
end
function Slash1()
attack = true
ss(Head,math.random())
dmg1cnnct()
dmg2cnnct()
for i = 0.2 , 1 , 0.2 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20+220*i), 0, math.rad(45-65*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-20+220*i), 0, math.rad(-45+65*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(100), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
ww1.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
end
local LastPoint = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
local LastPoint2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
for i = 0.2 , 1 , 0.2 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(200+10*i), 0, math.rad(-20))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(200+10*i), 0, math.rad(20))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(100), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
ww1.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("Bright violet",0.5,LastPoint,Point)
LastPoint = Point
local Point2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
effect("Really red",0.5,LastPoint2,Point2)
LastPoint2 = Point2
end
Hitdeb = 0
Hitdeb2 = 0
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(210-220*i), 0, math.rad(-20-20*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(210-220*i), 0, math.rad(20+20*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(100), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
ww1.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
local Point = prt4.CFrame * CFrame.new(0,prt4.Size.Y/-2,0)
effect("Bright violet",0.5,LastPoint,Point)
LastPoint = Point
local Point2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
effect("Really red",0.5,LastPoint2,Point2)
LastPoint2 = Point2
end
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-10-10*i), 0, math.rad(-40+85*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-10-10*i), 0, math.rad(40-85*i))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
w1.C0 = CFrame.Angles(math.rad(100), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
ww1.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
end
dmg2dc()
dmg1dc()
attack = false
end
function Slash2()
attack = true
ss(Head,math.random())
dmg2cnnct()
for i = 0.2 , 1 , 0.2 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20+90*i), 0, math.rad(45+45*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, math.rad(90*i), 0)
ww1.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
end
local LastPoint2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
Hitdeb2 = 0
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(70), 0, math.rad(90-140*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, math.rad(90), 0)
ww1.C0 = CFrame.Angles(math.rad(90+130*i), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
local Point2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
effect("Really red",0.5,LastPoint2,Point2)
LastPoint2 = Point2
end
Hitdeb2 = 0
for i = 0.1 , 1 , 0.2 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(70+10*i), 0, math.rad(90-140))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, math.rad(90), 0)
ww1.C0 = CFrame.Angles(math.rad(90+130), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
end
ss(Head,math.random())
for i = 0.1 , 1 , 0.2 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(80), 0, math.rad(90-140+140*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, math.rad(90), 0)
ww1.C0 = CFrame.Angles(math.rad(90+130-130*i), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
local Point2 = pprt14.CFrame * CFrame.new(0,pprt14.Size.Y/2,0)
effect("Really red",0.5,LastPoint2,Point2)
LastPoint2 = Point2
end
dmg2dc()
for i = 0.1 , 1 , 0.1 do
wait()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(80-100*i), 0, math.rad(90-45*i))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, math.rad(90-90*i), 0)
ww1.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
end
attack = false
end
function returnwelds()
RW.C0 = CFrame.new(3, 1, 0) * CFrame.Angles(math.rad(-20), 0, math.rad(45))
RW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
LW.C0 = CFrame.new(-3, 1, 0) * CFrame.Angles(math.rad(-20), 0, math.rad(-45))
LW.C1 = CFrame.new(0, 1, 0) * CFrame.Angles(0, 0, 0)
RWL.C0 = CFrame.new(2, -2, 0) * CFrame.Angles(0, 0, math.rad(20))
RWL.C1 = CFrame.new(1, 2, 0)
LWL.C0 = CFrame.new(-2, -2, 0) * CFrame.Angles(0, 0, math.rad(-20))
LWL.C1 = CFrame.new(-1, 2, 0)
w1.C0 = CFrame.Angles(math.rad(100), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
ww1.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.new(0, 0, 0)
Neck.C0 = CFrame.new(0, 2, 0) * CFrame.Angles(0, 0, 0)
end
function Attackk(mag)
if attack then return end
if mag <= 8 then
local rndm = math.random(1,3)
if rndm == 1 then
NaginataSpin()
elseif rndm == 2 then
Slash1()
elseif rndm == 3 then
Slash2()
end
elseif mag > 8 then
local rndm = math.random(1,1)
if rndm == 1 then
DualThrust()
end
end
end
local BG = Instance.new("BodyGyro",Torso)
BG.cframe = Torso.CFrame
BG.maxTorque = Vector3.new(0, math.huge,0)
BGSpin = 0
function FindTarget()
local c = game.Workspace:GetChildren();
local nearestmag = 1500
local nearestprsn = nil
for i = 1, #c do
local hum = c[i]:findFirstChild("Humanoid")
if hum ~= nil and hum.Health ~= 0 then
local head = c[i]:findFirstChild("Head");
if head ~= nil then
local mag = (head.Position - Torso.Position).magnitude;
if mag <= 1500 and c[i].Name ~= Character.Name then
if mag < nearestmag then
nearestmag = mag
nearestprsn = c[i]
end
end
end
end
end
Target = nearestprsn
end
local Humanoid = Instance.new("Humanoid",bodyholder)
Humanoid.MaxHealth = HP
equipanim()
wait(1)
coroutine.resume(coroutine.create(function(Hum)
for i=1,30 do
wait()
Hum.MaxHealth=2000
Hum.Health=2000
end
end),Humanoid)
bodyholder:MakeJoints()
Humanoid.Health = HP
Humanoid.WalkSpeed = WS
wait(1)
bodyholder.Torso.CFrame = CFrame.new(SpawnPos.Value)
Humanoid.Health = HP
script.Parent = Character
repeat
wait(0.1)
Humanoid.Sit=false
Humanoid.PlatformStand=false
FindTarget()
if Target ~= nil then
BG.cframe = CFrame.new(Torso.Position,Target.Torso.Position) * CFrame.Angles(0,math.rad(BGSpin),0)
local mag = (Torso.Position-Target.Torso.Position).magnitude
if mag <= 20 then
Attackk(mag)
end
--
pcall(function()
local pos4 = Vector3.new(Target.Torso.Position.x,bodyholder.Torso.Position.Y,Target.Torso.Position.z)
bg.cframe = CFrame.new(bodyholder.Torso.Position,pos4)
Humanoid:MoveTo(Target.Torso.Position + CFrame.new(Torso.Position,Target.Torso.Position).lookVector * -6,Target.Torso)
end)
if Target.Torso.Position.y > Torso.Position.y+5 then
coroutine.resume(coroutine.create(Jump))
end
--
else
BG.cframe = Torso.cframe
Humanoid:MoveTo(Torso.Position,Torso)
end
if true then
if (Torso.Velocity * Vector3.new(1,0,1)).magnitude > 2 then
--coroutine.resume(coroutine.create(Walk))
walking = true
elseif (Torso.Velocity * Vector3.new(1,0,1)).magnitude < 2 then
walking = false
end
else
walking = false
end
until Humanoid.Health <= 0
wait(5)
Character.Parent = nil--mediafire
|
modifier_centaur_rage_channeling = class({})
function modifier_centaur_rage_channeling:OnCreated(params)
if IsServer() then
self.caster = self:GetCaster()
self.ability = self:GetAbility()
self.team = self.caster:GetTeamNumber()
self.radius = self.ability:GetSpecialValueFor("radius")
self.count = 7
self.angle_diff = 360/self.count
self:OnIntervalThink()
self:StartIntervalThink(1.0)
end
end
function modifier_centaur_rage_channeling:OnIntervalThink()
self.caster:StartGestureWithPlaybackRate(ACT_DOTA_CAST_ABILITY_1, 1.5)
local origin = self.caster:GetAbsOrigin()
for i = 0, self.count - 1 do
local direction = RotatePosition(Vector(0,0,0), QAngle(0, 200 + self.angle_diff * i, 0), Vector(1,0,0))
local previous_range = 0
for j = 0,1 do
local range = previous_range + RandomInt(self.radius * 2, 1000)
local point = RotatePosition(origin, QAngle(0, self.angle_diff * i, 0), origin + Vector(range, 0, 0))
CreateModifierThinker(
self.caster, --hCaster
self.ability, --hAbility
"modifier_centaur_rage_thinker", --modifierName
{ sound = j },
point, --vOrigin
self.team, --nTeamNumber
false --bPhantomBlocker
)
previous_range = range
end
end
end
function modifier_centaur_rage_channeling:OnDestroy()
if IsServer() then
self.ability:StartCooldown(self.ability:GetCooldown(0))
self.caster:FadeGesture(ACT_DOTA_CAST_ABILITY_1)
end
end
function modifier_centaur_rage_channeling:GetStatusLabel() return "Ultimate" end
function modifier_centaur_rage_channeling:GetStatusPriority() return 5 end
function modifier_centaur_rage_channeling:GetStatusStyle() return "Ultimate" end
if IsClient() then require("wrappers/modifiers") end
Modifiers.Channeling(modifier_centaur_rage_channeling)
Modifiers.Status(modifier_centaur_rage_channeling)
|
-- Copyright (c) 2020 Trevor Redfern
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
local types = require "game.rules.character.types"
local createSlice = require "moonpie.redux.create_slice"
local tables = require "moonpie.tables"
return createSlice {
[types.ADD] = function(state, action)
return tables.concatArray(state, { action.payload.character })
end,
[types.BUY_ATTRIBUTE_POINT] = function(state, action)
local Attributes = require "game.rules.character.attributes"
local c, attr = action.payload.character, action.payload.attribute
if c.attributes.buyPoints > 0 and c.attributes[attr] < Attributes.pointBuyMaximum() then
c.attributes[attr] = c.attributes[attr] + 1
c.attributes.buyPoints = c.attributes.buyPoints - 1
end
return state
end,
[types.NEW] = function(state, action)
return tables.concatArray(state, { action.payload.character })
end,
[types.REMOVE] = function(state, action)
return tables.select(state,
function(character)
if character ~= action.payload.character then
return character
end
end)
end,
[types.SELL_ATTRIBUTE_POINT] = function(state, action)
local Attributes = require "game.rules.character.attributes"
local c, attr = action.payload.character, action.payload.attribute
if c.attributes[attr] > Attributes.pointBuyMinimum() then
c.attributes[attr] = c.attributes[attr] - 1
c.attributes.buyPoints = c.attributes.buyPoints + 1
end
return state
end,
[types.SET_ATTRIBUTE] = function(state, action)
local character = action.payload.character
character.attributes[action.payload.attribute] = action.payload.value
return state
end,
[types.SET_HEALTH] = function(state, action)
local colors = require "game.rules.graphics.colors"
local c = action.payload.character
c.health = action.payload.health
if c.sprite then
if c.health < 10 then
c.sprite.color = colors.lowHealth
else
c.sprite.color = colors.drawDefault
end
end
return state
end,
[types.SET_NAME] = function(state, action)
local c = action.payload.character
c.name = action.payload.name
return state
end,
[types.SET_POSITION] = function(state, action)
local c = action.payload.character
c.position = action.payload.position
return state
end,
}
|
Config = {}
Config.Location = vector4(-163.89, 302.22, 99.42, 94.23)
Config.Drink = {
[1] = {
label = "Water",
description = "Water Bottle",
item = "water_bottle", --item that will be given
required = {}, -- required items to make (empty if no items required)
progressbar = "Grabbing Water", -- text to display on progressbar
progresstime = 5000, -- time required to make in milliseconds
dictionary = 'amb@prop_human_bbq@male@idle_a', --dictionary name for animation
animname = "idle_b", --animation name
},
[2] = {
label = "Orange Juice",
description = "Orange Juice",
item = "orangejuice", --item that will be given
required = {}, -- required items to make (empty if no items required)
progressbar = "Grabbing Juice", -- text to display on progressbar
progresstime = 5000, -- time required to make in milliseconds
dictionary = 'amb@prop_human_bbq@male@idle_a', --dictionary name for animation
animname = "idle_b", --animation name
},
[3] = {
label = "Hot Tea",
description = "Oolong Tea",
item = "oolongtea", --item that will be given
required = {}, -- required items to make (empty if no items required)
progressbar = "Grabbing Tea", -- text to display on progressbar
progresstime = 5000, -- time required to make in milliseconds
dictionary = 'amb@prop_human_bbq@male@idle_a', --dictionary name for animation
animname = "idle_b", --animation name
},
[4] = {
label = "Ice Tea",
description = "Milk Tea",
item = "milktea", --item that will be given
required = {}, -- required items to make (empty if no items required)
progressbar = "Grabbing Tea", -- text to display on progressbar
progresstime = 5000, -- time required to make in milliseconds
dictionary = 'amb@prop_human_bbq@male@idle_a', --dictionary name for animation
animname = "idle_b", --animation name
},
[5] = {
label = "Alcohol",
description = "Chivas with Green Tea",
item = "chivastea", --item that will be given
required = {}, -- required items to make (empty if no items required)
progressbar = "Grabbing Tea", -- text to display on progressbar
progresstime = 5000, -- time required to make in milliseconds
dictionary = 'amb@prop_human_bbq@male@idle_a', --dictionary name for animation
animname = "idle_b", --animation name
},
}
Config.Prep = {
[1] = {
label = "Make Seasoning",
description = "Onion | Salt | Papper ",
item = "seasoning", --item that will be given
required = {
[1] = {itemName = "onion", amount = 1},
[2] = {itemName = "salt", amount = 1},
[3] = {itemName = "papper", amount = 1},
},
progressbar = "Making Seasoning", -- text to display on progressbar
progresstime = 10000, -- in milliseconds
dictionary = "mini@repair", --dictionary name for animation
animname = "fixing_a_player", --animation name
},
[2] = {
label = "Make Fried Seasoning",
description = "Onion [2] | Chilly [2] | Oil | Salt | Papper",
item = "friedseasoning", --item that will be given
required = {
[1] = {itemName = "onion", amount = 2},
[2] = {itemName = "chilly", amount = 2},
[3] = {itemName = "oil", amount = 1},
[4] = {itemName = "salt", amount = 1},
[5] = {itemName = "papper", amount = 1},
},
progressbar = "Making Fried Seasoning", -- text to display on progressbar
progresstime = 10000, -- in milliseconds
dictionary = "mini@repair", --dictionary name for animation
animname = "fixing_a_player", --animation name
},
[3] = {
label = "Rice",
description = "Take a Rice Bowl",
item = "rice", --item that will be given
required = {}, -- required items to make
progressbar = "Take a Rice Bowl", -- text to display on progressbar
progresstime = 5000, -- in milliseconds
dictionary = "mini@repair", --dictionary name for animation
animname = "fixing_a_player", --animation name
},
[4] = {
label = "Egg",
description = "Take a Egg",
item = "egg", --item that will be given
required = {}, -- required items to make
progressbar = "Take a Egg", -- text to display on progressbar
progresstime = 1000, -- in milliseconds
dictionary = "mini@repair", --dictionary name for animation
animname = "fixing_a_player", --animation name
},
}
Config.Oven = {
[1] = {
label = "Fried Rice with Egg",
description = "Rice | Fried Seasoning | Egg",
item = "friendrice", --item that will be given
required = {
[1] = {itemName = "rice", amount = 1},
[2] = {itemName = "friedseasoning", amount = 1},
[3] = {itemName = "egg", amount = 1},
}, -- required items to make
progressbar = "Making Fried Rice", -- text to display on progressbar
progresstime = 15000, -- in milliseconds
dictionary = "anim@mp_player_intmenu@key_fob@", --dictionary name for animation
animname = "fob_click", --animation name
},
[2] = {
label = "Fried Noodles with Egg",
description = "Noodle | Fried Seasoning | Egg",
item = "friednoodle", --item that will be given
required = {
[1] = {itemName = "noodle", amount = 1},
[2] = {itemName = "friedseasoning", amount = 1},
[3] = {itemName = "egg", amount = 1},
}, -- required items to make
progressbar = "Making Fried Noodle", -- text to display on progressbar
progresstime = 15000, -- in milliseconds
dictionary = "anim@mp_player_intmenu@key_fob@", --dictionary name for animation
animname = "fob_click", --animation name
},
[3] = {
label = "Scrambled Egg with Tomato",
description = "Egg | Seasoning | Tomato",
item = "scrambledegg", --item that will be given
required = {
[1] = {itemName = "egg", amount = 2},
[2] = {itemName = "seasoning", amount = 1},
[3] = {itemName = "tomato", amount = 2},
}, -- required items to make
progressbar = "Making Scrambled Egg", -- text to display on progressbar
progresstime = 15000, -- in milliseconds
dictionary = "anim@mp_player_intmenu@key_fob@", --dictionary name for animation
animname = "fob_click", --animation name
},
[4] = {
label = "Boiled Fish with Mushroom",
description = "Fish | Seasoning | Mushroom",
item = "boiledfish", --item that will be given
required = {
[1] = {itemName = "fish", amount = 2},
[2] = {itemName = "seasoning", amount = 1},
[3] = {itemName = "mushroom", amount = 1},
}, -- required items to make
progressbar = "Making Cheese Pizza", -- text to display on progressbar
progresstime = 15000, -- in milliseconds
dictionary = "anim@mp_player_intmenu@key_fob@", --dictionary name for animation
animname = "fob_click", --animation name
},
[5] = {
label = "Spicy Chicken",
description = "Chicken | Sour Sauce | Chilly | Paprika",
item = "spicychicken", --item that will be given
required = {
[1] = {itemName = "chicken", amount = 1},
[2] = {itemName = "soursauce", amount = 1},
[3] = {itemName = "chilly", amount = 1},
[4] = {itemName = "paprika", amount = 1},
}, -- required items to make
progressbar = "Making Spicy Chicken", -- text to display on progressbar
progresstime = 15000, -- in milliseconds
dictionary = "anim@mp_player_intmenu@key_fob@", --dictionary name for animation
animname = "fob_click", --animation name
},
[6] = {
label = "Sweet and Sour Crispy Prawn",
description = "Crispy Prawn | Sour Sauce | Oyster Sauce",
item = "crispyprawn", --item that will be given
required = {
[1] = {itemName = "crispyprawn", amount = 1},
[2] = {itemName = "soursauce", amount = 1},
[3] = {itemName = "oystersauce", amount = 1},
}, -- required items to make
progressbar = "Making Crispy Prawn", -- text to display on progressbar
progresstime = 15000, -- in milliseconds
dictionary = "anim@mp_player_intmenu@key_fob@", --dictionary name for animation
animname = "fob_click", --animation name
},
}
|
local proto = luci.model.network:register_protocol("iwifi")
function proto.get_i18n(_)
return luci.i18n.translate("Hebei Unicom iWiFi Client")
end
function proto.opkg_package(_)
return "iwifi"
end
function proto.is_installed(_)
return nixio.fs.access("/lib/netifd/proto/iwifi.sh")
end
|
ENT.Type = "point"
ENT.Base = "base_point"
function ENT:Initialize()
end
function ENT:KeyValue( key, value )
end
|
-- Copy program
local shell = require("shell")
local filesystem = require("filesystem")
local args, options = shell.parse(...)
if #args < 2 then
print("Usage: copy [-r] [-v] src dest")
print("-v: Verbose")
print("-r: Recursive")
return
end
local function copy(src, dst)
if options.v then
print(src .. " -> " .. dst)
end
filesystem.copy(src, dst)
end
local function copyDir(src, dst)
if not filesystem.isDirectory(src) or not filesystem.isDirectory(dst) then
print("Source or destination isn't directory")
return
end
if options.v then
print(src .. " -> " .. dst)
end
local name = filesystem.name(src)
for k, v in filesystem.list(src) do
local path = src .. "/" .. k
if filesystem.isDirectory(path) then
if not filesystem.exists(dst .. "/" .. k) then
filesystem.makeDirectory(dst .. "/" .. k)
end
copyDir(path, dst .. "/" .. k)
else
copy(path, dst .. "/" .. k)
end
end
end
local src = shell.resolve(args[1]) or args[1]
local dst = shell.resolve(args[2]) or args[2]
if options.r then
if not filesystem.exists(dst) then
if options.v then
print("Creating " .. dst)
end
filesystem.makeDirectory(dst)
end
copyDir(src, dst)
else
copy(src, dst)
end
print("Copied.")
|
-----------------------------------
-- Area: East Ronfaure
-- NPC: Stone Monument
-- Involved in quest "An Explorer's Footsteps"
-- !pos 77.277 -2.894 -517.376 101
-----------------------------------
local ID = require("scripts/zones/East_Ronfaure/IDs");
-----------------------------------
function onTrigger(player,npc)
player:startEvent(900);
end;
function onTrade(player,npc,trade)
if (trade:getItemCount() == 1 and trade:hasItemQty(571,1)) then
player:tradeComplete();
player:addItem(570);
player:messageSpecial(ID.text.ITEM_OBTAINED,570);
player:setCharVar("anExplorer-CurrentTablet",0x00002);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
end;
|
-- Dependencies
-- global debug flag
require "resources/Debug"
-- Global flags
require "resources/Flags"
-- Data Tables and helper functions
require "resources/DataTables"
-- local debug flag
local thisDebug = false;
local isDebug = Debug.IsDebug() and thisDebug;
-- Instantiate ourself
if EntityHurt == nil then
EntityHurt = {}
end
-- Event Listener
function EntityHurt:OnEntityHurt(event)
-- Get Event Data
isHero = EntityHurt:GetIsHero(event)
-- Drop out for non hero damage
if not isHero then return end
-- Get other event data
victim, attacker, damage, damageType = EntityHurt:GetEntityHurtEventData(event)
-- drop out if somehow there is no victim
if victim == nil then return end
-- drop out of the victim has no stats table
if victim.stats == nil then return end
-- Add damage to the victim's table
victim.stats.damageTable[damageType] = victim.stats.damageTable[damageType] + damage
-- Debug Print
if isDebug then
print('Damage Table for ' .. victim.stats.name)
DeepPrintTable(victim.stats.damageTable)
end
end
-- returns true if the victim was a hero
function EntityHurt:GetIsHero(event)
-- IsHero
local isHero = false;
local victim = EntIndexToHScript(event.entindex_killed);
if victim:IsHero() and victim:IsRealHero() and not victim:IsIllusion() and not victim:IsClone() then
isHero = true;
end
return isHero;
end
-- returns other useful data from the event
function EntityHurt:GetEntityHurtEventData(event)
local attacker = nil;
local victim = nil;
if event.entindex_attacker ~= nil and event.entindex_killed ~= nil then
attacker = EntIndexToHScript(event.entindex_attacker)
victim = EntIndexToHScript(event.entindex_killed)
end
-- Lifted from Anarchy. Props!
-- Damage Type
local damageType = nil;
if event.entindex_inflictor~=nil then
inflictor_table=EntIndexToHScript(event.entindex_inflictor):GetAbilityKeyValues()
if inflictor_table['AbilityUnitDamageType'] == nil then -- assume item damage is magical
damageType='DAMAGE_TYPE_MAGICAL'
else
damageType=tostring(inflictor_table['AbilityUnitDamageType'])
end
else
damageType=tostring('DAMAGE_TYPE_PHYSICAL')
end
-- get damage value
local damage=event.damage
return victim, attacker, damage, damageType;
end
-- Registers Event Listener
function EntityHurt:RegisterEvents()
if not Flags.isEntityHurtRegistered then
ListenToGameEvent("entity_hurt", Dynamic_Wrap(EntityHurt, 'OnEntityHurt'), EntityHurt)
Flags.isEntityHurtRegistered = true;
if isDebug then
print("EntityHurt Event Listener Registered.")
end
end
end
|
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- F I N A L C U T P R O A P I --
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--- === cp.apple.finalcutpro.main.Viewer ===
---
--- Viewer Module.
--------------------------------------------------------------------------------
--
-- EXTENSIONS:
--
--------------------------------------------------------------------------------
local log = require("hs.logger").new("viewer")
local inspect = require("hs.inspect")
local just = require("cp.just")
local prop = require("cp.prop")
local axutils = require("cp.ui.axutils")
local PrimaryWindow = require("cp.apple.finalcutpro.main.PrimaryWindow")
local SecondaryWindow = require("cp.apple.finalcutpro.main.SecondaryWindow")
local id = require("cp.apple.finalcutpro.ids") "Viewer"
--------------------------------------------------------------------------------
--
-- THE MODULE:
--
--------------------------------------------------------------------------------
local Viewer = {}
-- TODO: Add documentation
function Viewer.matches(element)
-- Viewers have a single 'AXContents' element
local contents = element:attributeValue("AXContents")
return contents and #contents == 1
and contents[1]:attributeValue("AXRole") == "AXSplitGroup"
and #(contents[1]) > 0
end
-- TODO: Add documentation
function Viewer:new(app, eventViewer)
local o = {
_app = app,
_eventViewer = eventViewer
}
return prop.extend(o, Viewer)
end
-- TODO: Add documentation
function Viewer:app()
return self._app
end
-----------------------------------------------------------------------
--
-- BROWSER UI:
--
-----------------------------------------------------------------------
-- TODO: Add documentation
function Viewer:UI()
return axutils.cache(self, "_ui", function()
local app = self:app()
if self:isMainViewer() then
return self:findViewerUI(app:secondaryWindow(), app:primaryWindow())
else
return self:findEventViewerUI(app:secondaryWindow(), app:primaryWindow())
end
end,
Viewer.matches)
end
-----------------------------------------------------------------------
--
-- VIEWER UI:
--
-----------------------------------------------------------------------
-- TODO: Add documentation
function Viewer:findViewerUI(...)
for i = 1,select("#", ...) do
local window = select(i, ...)
if window then
local top = window:viewerGroupUI()
local ui = nil
if top then
for i,child in ipairs(top) do
-- There can be two viwers enabled
if Viewer.matches(child) then
-- Both the event viewer and standard viewer have the ID, so pick the right-most one
if ui == nil or ui:position().x < child:position().x then
ui = child
end
end
end
end
if ui then return ui end
end
end
return nil
end
-----------------------------------------------------------------------
--
-- EVENT VIEWER UI:
--
-----------------------------------------------------------------------
-- TODO: Add documentation
function Viewer:findEventViewerUI(...)
for i = 1,select("#", ...) do
local window = select(i, ...)
if window then
local top = window:viewerGroupUI()
local ui = nil
local viewerCount = 0
if top then
for i,child in ipairs(top) do
-- There can be two viwers enabled
if Viewer.matches(child) then
viewerCount = viewerCount + 1
-- Both the event viewer and standard viewer have the ID, so pick the left-most one
if ui == nil or ui:position().x > child:position().x then
ui = child
end
end
end
end
-- Can only be the event viewer if there are two viewers.
if viewerCount == 2 then
return ui
end
end
end
return nil
end
-- TODO: Add documentation
Viewer.isEventViewer = prop.new(function(self)
return self._eventViewer
end):bind(Viewer)
-- TODO: Add documentation
Viewer.isMainViewer = prop.new(function(self)
return not self._eventViewer
end):bind(Viewer)
-- TODO: Add documentation
Viewer.isOnSecondary = prop.new(function(self)
local ui = self:UI()
return ui and SecondaryWindow.matches(ui:window())
end):bind(Viewer)
-- TODO: Add documentation
Viewer.isOnPrimary = prop.new(function(self)
local ui = self:UI()
return ui and PrimaryWindow.matches(ui:window())
end):bind(Viewer)
-- TODO: Add documentation
Viewer.isShowing = prop.new(function(self)
return self:UI() ~= nil
end):bind(Viewer)
-- TODO: Add documentation
function Viewer:showOnPrimary()
local menuBar = self:app():menuBar()
-- if it is on the secondary, we need to turn it off before enabling in primary
if self:isOnSecondary() then
menuBar:selectMenu({"Window", "Show in Secondary Display", "Viewers"})
end
if self:isEventViewer() and not self:isShowing() then
-- Enable the Event Viewer
menuBar:selectMenu({"Window", "Show in Workspace", "Event Viewer"})
end
return self
end
-- TODO: Add documentation
function Viewer:showOnSecondary()
local menuBar = self:app():menuBar()
if not self:isOnSecondary() then
menuBar:selectMenu({"Window", "Show in Secondary Display", "Viewers"})
end
if self:isEventViewer() and not self:isShowing() then
-- Enable the Event Viewer
menuBar:selectMenu({"Window", "Show in Workspace", "Event Viewer"})
end
return self
end
-- TODO: Add documentation
function Viewer:hide()
local menuBar = self:app():menuBar()
if self:isEventViewer() then
-- Uncheck it from the primary workspace
if self:isShowing() then
menuBar:selectMenu({"Window", "Show in Workspace", "Event Viewer"})
end
elseif self:isOnSecondary() then
-- The Viewer can only be hidden from the Secondary Display
menuBar:selectMenu({"Window", "Show in Secondary Display", "Viewers"})
end
return self
end
-- TODO: Add documentation
function Viewer:topToolbarUI()
return axutils.cache(self, "_topToolbar", function()
local ui = self:UI()
return ui and axutils.childFromTop(ui, 1)
end)
end
-- TODO: Add documentation
function Viewer:bottomToolbarUI()
return axutils.cache(self, "_bottomToolbar", function()
local ui = self:UI()
return ui and axutils.childFromBottom(ui, 1)
end)
end
-- TODO: Add documentation
function Viewer:hasPlayerControls()
return self:bottomToolbarUI() ~= nil
end
-- TODO: Add documentation
function Viewer:formatUI()
return axutils.cache(self, "_format", function()
local ui = self:topToolbarUI()
return ui and axutils.childFromLeft(ui, id "Format")
end)
end
-- TODO: Add documentation
function Viewer:getFormat()
local format = self:formatUI()
return format and format:value()
end
-- TODO: Add documentation
function Viewer:getFramerate()
local format = self:getFormat()
local framerate = format and string.match(format, ' %d%d%.?%d?%d?[pi]')
return framerate and tonumber(string.sub(framerate, 1,-2))
end
-- TODO: Add documentation
function Viewer:getTitle()
local titleText = axutils.childFromLeft(self:topToolbarUI(), id "Title")
return titleText and titleText:value()
end
return Viewer
|
local tbl =
{
name = "SQL",
description = "Database module for Advisor data persistency.",
loadOrder = {},
server_only = true,
}
return Module(tbl)
|
--- LSP Lua Config here ---
--- Go
require("lspconfig").gopls.setup{
on_attach = function()
-- in normal mode, map <keys> to <action> in ONLY this buffer.
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
vim.keymap.set("n", "<leader>cd", vim.lsp.buf.definition, { buffer = 0 })
vim.keymap.set("n", "<leader>ct", vim.lsp.buf.type_definition, { buffer = 0 })
vim.keymap.set("n", "<leader>cr", vim.lsp.buf.references, { buffer = 0 })
vim.keymap.set("n", "<leader>cR", vim.lsp.buf.rename, { buffer = 0 })
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { buffer = 0 })
vim.keymap.set("n", "<C-n>", vim.diagnostic.goto_next, { buffer = 0 })
vim.keymap.set("n", "<C-p>", vim.diagnostic.goto_prev, { buffer = 0 })
end,
}
|
-- Todo: Find a better solution to implement this
local oldOnResearchComplete = RoboticsFactory.OnResearchComplete
function RoboticsFactory:OnResearchComplete(researchId)
oldOnResearchComplete(self, researchId)
if researchId == kTechId.UpgradeRoboticsFactory then
local supplyDiff = LookupTechData(kTechId.ARCRoboticsFactory, kTechDataSupply, 0)
- LookupTechData(kTechId.RoboticsFactory, kTechDataSupply, 0)
local team = self:GetTeam()
if supplyDiff > 0 and team and team.AddSupplyUsed then
team:AddSupplyUsed(supplyDiff)
self.supplyAdded = true
end
end
end
|
--[[
� 2012 CloudSixteen.com do not share, re-distribute or modify
without permission of its author (kurozael@gmail.com).
--]]
ITEM.name = "Notepad";
ITEM.cost = 5;
ITEM.model = "models/props_office/notepad_terranova.mdl";
ITEM.weight = 0.1;
ITEM.flag = "g"
ITEM.category = "Other"
ITEM.description = "A clean notepad, useful for note taking.";
ITEM.functions.Edit = {
icon = "icon16/book_edit.png",
OnRun = function(item)
local client = item.player
local character = client:GetCharacter()
if(item:GetData("character")) then
if(character:GetID() != item:GetData("character")) then
return false, "You don't own this notepad!"
end
end
item:SetData("character", character:GetID())
netstream.Start(client, "ViewNotepad", item:GetData("text"), item.id, true);
return false
end
}
ITEM.functions.View = {
icon = "icon16/book_open.png",
OnRun = function(item)
local client = item.player
netstream.Start(client, "ViewNotepad", item:GetData("text"))
return false
end
}
ITEM.functions.Lock = {
icon = "icon16/lock.png",
OnRun = function(item)
item:SetData("locked", false)
return false
end,
OnCanRun = function(item)
local client = item.player
local owner = item:GetData("character", 0)
if(!item:GetData("locked")) then
return false
end
if(owner == 0 or owner == client:GetCharacter():GetID()) then
return true
end
return false
end
}
ITEM.functions.Unlock = {
icon = "icon16/lock_open.png",
OnRun = function(item)
item:SetData("locked", true)
return false
end,
OnCanRun = function(item)
local client = item.player
local owner = item:GetData("character", 0)
if(item:GetData("locked")) then
return false
end
if(owner == 0 or owner == client:GetCharacter():GetID()) then
return true
end
return false
end
}
ITEM.functions.take.OnCanRun = function(item)
local owner = item:GetData("character", 0)
return IsValid(item.entity) and ((owner == 0 or owner == item.player:GetCharacter():GetID() or item:GetData("locked", false)))
end
|
local typedefs = require "kong.db.schema.typedefs"
local schema = {
name = "jwt-crafter",
fields = {
{ consumer = typedefs.no_consumer }, -- this plugin cannot be configured on a consumer (typical for auth plugins)
{ protocols = typedefs.protocols_http },
{ config = {
type = "record",
fields = {
{ expires_in = { type = "number", default = 8 * 60 * 60 } }
}
}
}
}
}
return schema
|
local m = require 'model_helpers'
local error_handler = require 'error_handler'
local Pipeline = require 'models.pipeline'
local Service = require 'models.service'
local statsd = require 'statsd_wrapper'
local get_service_and_user_from_host = function(host)
return string.match(host, "^(.*)%-([^.]+)")
end
local get_user_and_service_from_proxy = function(header)
local base64 = header:match("^Basic (.+)$")
local credentials = ngx.decode_base64(base64)
return credentials:match("^(.+):(.+)$")
end
local service, user
local proxy_authorization = ngx.var.http_proxy_authorization
local proxy_mode
if proxy_authorization then -- probably proxy mode
user, service = get_user_and_service_from_proxy(proxy_authorization)
proxy_mode = 'proxy'
end
if not user or not service then
service, user = get_service_and_user_from_host(ngx.var.host)
proxy_mode = 'manual'
end
local service, url = Service:find_by_endpoint_code(service)
error_handler.execute_and_report(function()
assert(service, "no service for ".. ngx.var.host)
local pipeline = service and Pipeline:get(service)
assert(pipeline, "no pipeline for service ".. service._id)
if proxy_mode == 'proxy' then -- cleanup proxy auth header
ngx.req.clear_header('Proxy-Authorization')
if url == '*' then
url = "http://" .. ngx.var.http_host
end
url = url:gsub('localhost', '127.0.0.1', 1)
end
Pipeline.execute(pipeline, url)
statsd.time('proxy.request', ngx.now() - ngx.req.start_time())
end)
ngx.exit(ngx.OK)
|
function onResourceStart()
if markersTable then
for i=1, #markersTable do
local m1 = createMarker(markersTable[i][1],markersTable[i][2],markersTable[i][3], "arrow",1,255,255,0,0)-- MTA bug : alpha doenst work on Arrow markers (should auto fix when the bug is corrected)
setElementDimension(m1, 95419)
setElementData(m1, "warpX", markersTable[i][4])
setElementData(m1, "warpY", markersTable[i][5])
setElementData(m1, "warpZ", markersTable[i][6])
local m2 = createMarker(markersTable[i][4],markersTable[i][5],markersTable[i][6], "arrow",1,255,255,0,0)-- MTA bug : alpha doenst work on Arrow markers(should auto fix when the bug is corrected)
setElementDimension(m2, 95419)
setElementData(m2, "warpX", markersTable[i][1])
setElementData(m2, "warpY", markersTable[i][2])
setElementData(m2, "warpZ", markersTable[i][3])
addEventHandler("onClientMarkerHit", m1, onPlayerMarkerHit)
addEventHandler("onClientMarkerLeave", m1, onPlayerMarkerLeave)
addEventHandler("onClientMarkerHit", m2, onPlayerMarkerHit)
addEventHandler("onClientMarkerLeave", m2, onPlayerMarkerLeave)
end
end
label = guiCreateLabel(0, 0.8, 1, 0.1, "Press F to climb the ladder", true)
guiSetVisible(label,false)
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onResourceStart)
function onPlayerMarkerHit (hitElement)
if hitElement == localPlayer and not (guiGetVisible(label) == true) then
guiSetVisible(label,true)
guiLabelSetHorizontalAlign(label, "center", false)
bindKey("f", "down", startClimb, source, hitElement)
end
end
function onPlayerMarkerLeave (leftPlayer)
if leftPlayer == localPlayer then
if label then
guiSetVisible(label, false)
end
unbindKey("f")
end
end
function startClimb(keyPressed,state, marker, player)
if player == localPlayer then
local x = getElementData(marker, "warpX")
local y = getElementData(marker, "warpY")
local z = getElementData(marker, "warpZ")
fadeCamera(false, 1)
setTimer ( fadeCamera, 1500, 1, true, 1 )
if label then
guiSetVisible(label, false)
end
if x and y and z then
setTimer ( setElementPosition, 1500, 1, player, x, y, z-0.7 )
end
end
end
|
--[[
@Authors: Ben Dol (BeniS)
@Details: Event class for event logic/callback.
]]
Event = {}
Event.__index = Event
Event.__class = "Event"
Event.new = function(id, event, callback, state)
ev = {
id = 0,
event = {},
callback = {},
state = nil
}
if type(id) ~= 'number' then
error('invalid id provided.')
end
ev.id = id
ev.event = event
ev.callback = callback
ev.state = state
setmetatable(ev, Event)
return ev
end
-- gets/sets
function Event:getId()
return self.id
end
function Event:setId(id)
self.id = id
end
function Event:getEvent()
return self.event
end
function Event:setEvent(event)
self.event = event
end
function Event:getCallback()
return self.callback
end
function Event:setCallback(callback)
self.callback = callback
end
function Event:getState()
return self.state
end
function Event:setState(state)
self.state = state
end
-- methods
function Event:stopEvent()
removeEvent(self.event)
self.event = nil
end
|
local M = {}
function M.get(cp)
return {
DiagnosticError = { fg = cp.catppuccin5 },
DiagnosticWarning = { fg = cp.catppuccin8 },
DiagnosticInformation = { fg = cp.catppuccin9 },
DiagnosticHint = { fg = cp.hint },
LspFloatWinNormal = { bg = cp.catppuccin13 },
LspFloatWinBorder = { fg = cp.catppuccin9 },
LspSagaBorderTitle = { fg = cp.catppuccin2 },
LspSagaHoverBorder = { fg = cp.catppuccin9 },
LspSagaRenameBorder = { fg = cp.catppuccin7 },
LspSagaDefPreviewBorder = { fg = cp.catppuccin7 },
LspSagaCodeActionBorder = { fg = cp.catppuccin9 },
LspSagaFinderSelection = { fg = cp.catppuccin12 },
LspSagaCodeActionTitle = { fg = cp.catppuccin91 },
LspSagaCodeActionContent = { fg = cp.purple },
LspSagaSignatureHelpBorder = { fg = cp.catppuccin5 },
ReferencesCount = { fg = cp.purple },
DefinitionCount = { fg = cp.purple },
DefinitionIcon = { fg = cp.catppuccin9 },
ReferencesIcon = { fg = cp.catppuccin9 },
TargetWord = { fg = cp.catppuccin2 },
}
end
return M
|
nssm:register_mob("nssm:morgut", "Morgut", {
type = "monster",
hp_max = 35,
hp_min = 28,
collisionbox = {-0.3, -0.1, -0.3, 0.3, 1.8, 0.3},
visual = "mesh",
rotate= 270,
mesh = "morgut.x",
textures = {{"morgut.png"}},
visual_size = {x=5, y=5},
makes_footstep_sound = true,
view_range = 26,
walk_velocity = 0.5,
reach =2,
run_velocity = 4,
damage = 4,
runaway = true,
jump = true,
sounds = {
random = "morgut",
},
drops = {
{name = "nssm:life_energy",
chance = 1,
min = 1,
max = 3,},
{name = "nssm:gluttonous_soul_fragment",
chance = 3,
min = 1,
max = 1,},
},
armor = 70,
drawtype = "front",
water_damage = 0,
fear_height = 4,
floats = 1,
lava_damage = 0,
light_damage = 0,
group_attack=true,
attack_animals=true,
knock_back=1,
blood_texture="morparticle.png",
stepheight=1.1,
on_rightclick = nil,
attack_type = "dogfight",
animation = {
speed_normal = 15,
speed_run = 30,
stand_start = 10,
stand_end = 40,
walk_start = 50,
walk_end = 90,
run_start = 100,
run_end = 120,
punch_start = 130,
punch_end = 160,
},
do_custom = function (self)
self.flag = (self.flag or 0)
if self.inv_flag ~= 1 then
self.inventory = {}
for i=1,32 do
self.inventory[i]={name = '', num = 0}
end
end
self.inv_flag = (self.inv_flag or 1)
if self.flag == 1 then
self.state = ""
mobs:set_animation(self, "run")
self.object:setyaw(self.dir)
self:set_velocity(4)
if os.time() - self.morgut_timer > 3 then
self.flag = 0
self.state = "stand"
end
end
end,
custom_attack = function (self)
self.curr_attack = (self.curr_attack or self.attack)
self.morgut_timer = (self.morgut_timer or os.time())
self.dir = (self.dir or 0)
if (os.time() - self.morgut_timer) > 1 then
if self.attack then
local s = self.object:get_pos()
local p = self.attack:get_pos()
mobs:set_animation(self, "punch")
local m = 2
minetest.add_particlespawner({
amount = 6,
time = 1,
minpos = {x=p.x-0.5, y=p.y-0.5, z=p.z-0.5},
maxpos = {x=p.x+0.5, y=p.y+0.5, z=p.z+0.5},
minvel = {x=(s.x-p.x)*m, y=(s.y-p.y)*m, z=(s.z-p.z)*m},
maxvel = {x=(s.x-p.x)*m, y=(s.y-p.y)*m, z=(s.z-p.z)*m},
minacc = {x=s.x-p.x, y=s.y-p.y, z=s.z-p.z},
maxacc = {x=s.x-p.x, y=s.y-p.y, z=s.z-p.z},
minexptime = 0.2,
maxexptime = 0.3,
minsize = 2,
maxsize = 3,
collisiondetection = false,
texture = "roasted_duck_legs.png"
})
minetest.after(1, function (self)
if self then
if self.attack:is_player() then
local pname = self.attack:get_player_name()
local player_inv = minetest.get_inventory({type='player', name = pname})
if player_inv:is_empty('main') then
--minetest.chat_send_all("Inventory empty")
else
for i = 1,32 do
--minetest.chat_send_all("Inventory is not empty")
local items = player_inv:get_stack('main', i)
local n = items:get_name()
if minetest.get_item_group(n, "eatable")==1 then
local index
local found = 0
for j = 1,32 do
if found == 0 then
if self.inventory[j].num == 0 then
--found an empty place
found = 2
index = j
else
--found a corrsponding itemstack
if self.inventory[j].name == n then
self.inventory[j].num = self.inventory[j].num +1
found = 1
end
end
end
end
if found == 2 then
self.inventory[index].name = n
self.inventory[index].num = 1
end
items:take_item()
player_inv:set_stack('main', i, items)
end
end
end
mobs:set_animation(self, "run")
self.flag = 1
self.morgut_timer = os.time()
self.curr_attack = self.attack
self.state = ""
local pyaw = self.curr_attack: get_look_horizontal()+math.pi/2
self.dir = pyaw
self.object:setyaw(pyaw)
if self then
self:set_velocity(4)
end
end
end
end,self)
end
end
end,
on_die = function(self)
local pos = self.object:get_pos()
if (self.inventory ~= nil) then
local elem
for i = 1,32 do
if self.inventory[i].num~=0 then
local items = ItemStack(self.inventory[i].name.." "..self.inventory[i].num)
local obj = minetest.add_item(pos, items)
obj:setvelocity({
x = math.random(-1, 1),
y = 6,
z = math.random(-1, 1)
})
end
end
end
self.object:remove()
end,
})
|
-- drop every n'th element from a list
-- > dropEvery({'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k'}, 3)
-- {'a', 'b', 'd', 'e', 'g', 'h', 'k'}
dropEvery = function (t, n)
local res = {}
for i = 1, #t do
if i % n ~= 0 then
table.insert(res, t[i])
end
end
return res
end
dofile 'dumper.lua'
print(DataDumper(dropEvery({'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k'}, 3)))
|
local fc = {
_AUTHOR = "Brandon Blanker Lim-it @flamendless",
_DESCRIPTION = "A simple gui window with two options, perfect for yes or no dialogue box",
_VERSION = "0.1",
}
local dpi = love.window.getDPIScale()
if love.system.getOS() == "Android" then
dpi = dpi/1.5
end
local count = 1
local button_count = 1
local cursor = 0
local getColor = function()
local c = {}
for i = 1, 3 do
c[i] = math.random(0, 1)
end
return c
end
local point_to_rect = function(mx,my, x,y,w,h)
return mx > x and mx <= x + w and my > y and my <= y + h
end
function fc:show()
self.state = true
end
function fc:hide()
self.state = false
end
local SHOW_GDPR = true
function fc:GDPR_check()
if love.filesystem.getInfo("gdrp") then
local _gdrp = love.filesystem.read("gdrp")
if _gdrp == "accept" then
SHOW_GDPR = false
end
end
end
function fc:validate()
if love.filesystem.exists("gdrp") then
local _g = love.filesystem.read("gdrp")
return _g
end
end
function fc:GDPR_init()
if SHOW_GDPR == false then return end
self:addWindow()
self:addButton("I Agree", function()
love.filesystem.write("gdrp", "accept")
self:hide()
end)
self:addButton("I Refuse", function()
love.filesystem.write("gdrp", "refuse")
self:hide()
end)
self:show()
self:start()
end
function fc:init()
math.randomseed(os.time())
self.text = "\tThe game wishes to display ads. Allowing ads will help the developer earn income. If you want to support the game, please accept.\n\n\t The ads to be displayed will not use any of your personal data. This is a consensus in compliance with the GDPR.\n\n\tYou can revoke the consent anytime by going to game settings"
self.font = love.graphics.newFont(22 * dpi)
self.padding = 16
self.isShow = false
self.buttons = {}
self.windows = {}
local base = {}
base.count = count
base.x = 32
base.y = 32
base.w = love.graphics.getWidth() - (base.x * 2)
base.h = love.graphics.getHeight() - (base.y * 2)
base.color = {77/255, 77/255, 77/255, 155/255}
self:registerWindow(base)
self:GDPR_check()
end
function fc:registerWindow(w)
self.windows[count] = w
count = count + 1
end
function fc:registerButton(b, current)
self.buttons[button_count] = b
if button_count == 1 then
local b = self.buttons[1]
b.x = current.x + current.w/2 - b.w/2
else
local b_left = self.buttons[1]
local b_right = self.buttons[2]
if b_left then
b_left.x = current.x + current.w/4 - b_left.w/2
end
if b_right then
b_right.x = current.x + current.w/2 + current.w/4 - b_right.w/2
end
end
button_count = button_count + 1
end
function fc:addWindow()
local w = {}
w.count = count
w.x = 32 + (self.padding * count)
w.y = 32 + (self.padding * count)
w.w = love.graphics.getWidth() - (w.x * 2)
w.h = love.graphics.getHeight() - (w.y * 2)
w.color = {255/255, 255/255, 255/255, 255/255}
self:registerWindow(w)
end
function fc:addButton(text, fn)
local current = self.windows[count - 1]
local b = {}
b.text = text
b.callback = fn or function() end
b.index = button_count
b.isHover = false
b.w = current.w/4
b.h = current.h/8
b.x = 0
b.y = current.y + current.h - b.h - self.padding * 2
b.hoverColor = {255/255,0,0,125/255}
b.color = {77/255,77/255,77/255,255/255}
self:registerButton(b, current)
end
function fc:update(dt)
if #self.buttons > 0 then
local mx, my = love.mouse.getPosition()
for k,btn in pairs(self.buttons) do
btn.isHover = false
if cursor == btn.index then
btn.isHover = true
end
if point_to_rect(mx,my, btn.x,btn.y,btn.w,btn.h) then
cursor = btn.index
btn.isHover = true
end
end
end
if self.thread:isRunning() then
self.channel:push(self.state)
end
end
local thread = [[
local isRunning = true
while (isRunning) do
if love.thread.getChannel("state"):pop() == false then
print("stopped")
isRunning = false
break
end
end
]]
function fc:start()
local t = love.thread.newThread(thread)
local c = love.thread.getChannel("state")
t:start()
self.thread = t
self.channel = c
end
function fc:draw()
if not self.state then return end
love.graphics.push()
love.graphics.origin()
love.graphics.setColor(255/255,255/255,255/255,255/255)
for k,v in pairs(self.windows) do
love.graphics.setColor(v.color)
love.graphics.rectangle("fill", v.x, v.y, v.w, v.h)
--print text
if v.count == count - 1 then
love.graphics.setColor(0,0,0,255/255)
love.graphics.setFont(self.font)
love.graphics.printf(self.text, v.x + self.padding, v.y + self.padding * 2, v.w - self.padding * 2)
end
end
for k,v in pairs(self.buttons) do
if v.isHover then love.graphics.setColor(v.hoverColor)
else love.graphics.setColor(v.color)
end
love.graphics.rectangle("fill", v.x, v.y, v.w, v.h)
if v.text then
love.graphics.setColor(255/255,255/255,255/255,255/255)
love.graphics.setFont(self.font)
love.graphics.print(v.text,
v.x + v.w/2 - self.font:getWidth(v.text)/2,
v.y + v.h/2 - self.font:getHeight(v.text)/2)
end
end
love.graphics.setColor(255/255,255/255,255/255,255/255)
love.graphics.pop()
end
function fc:mousepressed(mx,my,mb,istouch)
if not self.state then return end
if #self.buttons > 0 then
for k,v in pairs(self.buttons) do
if mb == 1 or istouch then
if v.isHover then v.callback() end
end
end
end
end
function fc:touchpressed(id,tx,ty)
if not self.state then return end
if #self.buttons > 0 then
for k,v in pairs(self.buttons) do
if point_to_rect(tx,ty, v.x,v.y,v.w,v.h) then
cursor = v.index
v.callback()
end
end
end
end
function fc:getState()
return self.state
end
return fc
|
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- Copyright (C) 2008.
-- Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:GetInfo()
return {
name = "AdvPlayersList",
desc = "Playerlist. Use tweakmode (ctrl+F11) to customize.",
author = "Marmoth. (spiced up by Floris)",
date = "25 april 2015",
version = "21.0",
license = "GNU GPL, v2 or later",
layer = -4,
enabled = true, -- loaded by default?
}
end
--Changelog
-- before v8.0 developed outside of BA by Marmoth
-- v9.0 (Bluestone): modifications to deal with twice as many players/specs; specs are rendered in a small font and cpu/ping does not show for them.
-- v9.1 ([teh]decay): added notification about shared resources
-- v10 (Bluestone): Better use of opengl for a big speed increase & less spaghetti
-- v11 (Bluestone): Get take info from cmd_idle_players
-- v11.1 (Bluestone): Added TrueSkill column
-- v11.2 (Bluestone): Remove lots of hardcoded crap about module names/pictures
-- v11.3 (Bluestone): More cleaning up
-- v11.4 (Bluestone): Mute people with ctrl+click on their name
-- v12 (Floris): Restyled looks + added imageDirectory var + HD-ified rank and some other icons
-- v13 (Floris): Added scale buttons. Added grey cpu/ping icons for spectators. Resized elements. Textured bg. Spec label click to unfold/fold. Added guishader. Lockcamera on doubleclick. Ping in ms/sec/min. Shows dot icon in front of tracked player. HD-ified lots of other icons. Speccing/dead player keep their color. Improved e/m share gui responsiveness. + removed the m_spec option
-- v14 (Floris): Added country flags + Added camera icons for locked camera + specs show bright when they are broadcasting new lockcamera positions + bugfixed lockcamera for specs. Added small gaps between in tweakui icons. Auto scales with resolution changes.
-- v15 (Floris): Integrated LockCamers widget code
-- v16 (Floris): Added chips next to gambling-spectators for betting system
-- v17 (Floris): Added alliances display and button and /cputext option
-- v18 (Floris): Player system shown on tooltip + added FPS counter + replaced allycursor data with activity gadget data (all these features need gadgets too)
-- v19 (Floris): added player resource bars
-- v20 (Floris): added /alwayshidespecs + fixed drawing when playerlist is at the leftside of the screen
-- v21 (Floris): added toggle LoS and /specfullview when camera tracking a player
--------------------------------------------------------------------------------
-- Widget Scale
--------------------------------------------------------------------------------
local customScale = 1
local customScaleStep = 0.025
local pointDuration = 40
local cpuText = false
local drawAlliesLabel = false
local alwaysHideSpecs = false
local lockcameraHideEnemies = false --true
local lockcameraLos = false --true
--------------------------------------------------------------------------------
-- SPEED UPS
--------------------------------------------------------------------------------
local Spring_GetGameSeconds = Spring.GetGameSeconds
local Spring_GetGameFrame = Spring.GetGameFrame
local Spring_GetAllyTeamList = Spring.GetAllyTeamList
local Spring_GetTeamInfo = Spring.GetTeamInfo
local Spring_GetTeamList = Spring.GetTeamList
local Spring_GetPlayerInfo = Spring.GetPlayerInfo
local Spring_GetPlayerList = Spring.GetPlayerList
local Spring_GetTeamColor = Spring.GetTeamColor
local Spring_GetLocalAllyTeamID = Spring.GetLocalAllyTeamID
local Spring_GetLocalTeamID = Spring.GetLocalTeamID
local Spring_GetLocalPlayerID = Spring.GetLocalPlayerID
local Spring_ShareResources = Spring.ShareResources
local Spring_GetTeamUnitCount = Spring.GetTeamUnitCount
local Echo = Spring.Echo
local Spring_GetTeamResources = Spring.GetTeamResources
local Spring_SendCommands = Spring.SendCommands
local Spring_GetConfigInt = Spring.GetConfigInt
local Spring_GetMouseState = Spring.GetMouseState
local Spring_GetAIInfo = Spring.GetAIInfo
local Spring_GetTeamRulesParam = Spring.GetTeamRulesParam
local Spring_IsGUIHidden = Spring.IsGUIHidden
local Spring_GetDrawFrame = Spring.GetDrawFrame
local Spring_GetTeamColor = Spring.GetTeamColor
local Spring_GetMyTeamID = Spring.GetMyTeamID
local Spring_AreTeamsAllied = Spring.AreTeamsAllied
local GetCameraState = Spring.GetCameraState
local SetCameraState = Spring.SetCameraState
local GetCameraNames = Spring.GetCameraNames
local gl_Texture = gl.Texture
local gl_Rect = gl.Rect
local gl_TexRect = gl.TexRect
local gl_Color = gl.Color
local gl_CreateList = gl.CreateList
local gl_BeginEnd = gl.BeginEnd
local gl_DeleteList = gl.DeleteList
local gl_CallList = gl.CallList
local gl_Text = gl.Text
local gl_GetTextWidth = gl.GetTextWidth
local gl_GetTextHeight = gl.GetTextHeight
--------------------------------------------------------------------------------
-- IMAGES
--------------------------------------------------------------------------------
local imageDirectory = ":n:LuaUI/Images/advplayerslist/"
local flagsDirectory = imageDirectory.."flags/"
local bgcorner = "LuaUI/Images/bgcorner.png"
local pics = {
chipPic = imageDirectory.."chip.dds",
currentPic = imageDirectory.."indicator.dds",
unitsPic = imageDirectory.."units.dds",
energyPic = imageDirectory.."energy.dds",
metalPic = imageDirectory.."metal.dds",
notFirstPic = imageDirectory.."notfirst.dds",
notFirstPicWO = imageDirectory.."notfirstwo.png",
pingPic = imageDirectory.."ping.dds",
cpuPic = imageDirectory.."cpu.dds",
selectPic = imageDirectory.."select.png",
barPic = imageDirectory.."bar.png",
amountPic = imageDirectory.."amount.png",
pointPic = imageDirectory.."point.dds",
lowPic = imageDirectory.."low.dds",
arrowPic = imageDirectory.."arrow.dds",
arrowdPic = imageDirectory.."arrowd.png",
takePic = imageDirectory.."take.dds",
crossPic = imageDirectory.."cross.dds",
pointbPic = imageDirectory.."pointb.png",
takebPic = imageDirectory.."takeb.png",
seespecPic = imageDirectory.."seespec.png",
indentPic = imageDirectory.."indent.png",
cameraPic = imageDirectory.."camera.dds",
countryPic = imageDirectory.."country.dds",
readyTexture = imageDirectory.."indicator.dds",
drawPic = imageDirectory.."draw.dds",
allyPic = imageDirectory.."ally.dds",
resourcesPic = imageDirectory.."res.png",
resbarPic = imageDirectory.."resbar.png",
resbarBgPic = imageDirectory.."resbarBg.png",
barGlowCenterPic= imageDirectory.."barglow-center.dds",
barGlowEdgePic = imageDirectory.."barglow-edge.dds",
cpuPingPic = imageDirectory.."cpuping.dds",
specPic = imageDirectory.."spec.png",
chatPic = imageDirectory.."chat.dds",
sidePic = imageDirectory.."side.dds",
sharePic = imageDirectory.."share.dds",
namePic = imageDirectory.."name.dds",
idPic = imageDirectory.."id.dds",
tsPic = imageDirectory.."ts.dds",
sizednPic = imageDirectory.."sizedn.dds",
sizeupPic = imageDirectory.."sizeup.dds",
rank0 = imageDirectory.."ranks/rank0.dds",
rank1 = imageDirectory.."ranks/rank1.dds",
rank2 = imageDirectory.."ranks/rank2.dds",
rank3 = imageDirectory.."ranks/rank3.dds",
rank4 = imageDirectory.."ranks/rank4.dds",
rank5 = imageDirectory.."ranks/rank5.dds",
rank6 = imageDirectory.."ranks/rank6.dds",
rank7 = imageDirectory.."ranks/rank7.dds",
rank8 = imageDirectory.."ranks/rank_unknown.dds",
}
local sidePics = {} -- loaded in SetSidePics function
local sidePicsWO = {} -- loaded in SetSidePics function
local originalColourNames = {} -- loaded in SetOriginalColourNames, format is originalColourNames['name'] = colourString
--------------------------------------------------------------------------------
-- Colors
--------------------------------------------------------------------------------
local pingCpuColors = {
[1] = {r = 0.11, g = 0.82, b = 0.11},
[2] = {r = 0.4, g = 0.75, b = 0.2},
[3] = {r = 0.72, g = 0.72, b = 0.2},
[4] = {r = 0.82, g = 0.27, b = 0.18},
[5] = {r = 1, g = 0.15, b = 0.3}
}
--------------------------------------------------------------------------------
-- Time Variables
--------------------------------------------------------------------------------
local blink = true
local lastTime = 0
local blinkTime = 0
local now = 0
--------------------------------------------------------------------------------
-- LockCamera variables
--------------------------------------------------------------------------------
local transitionTime = 1 --how long it takes the camera to move when trackign a player
local listTime = 14 --how long back to look for recent broadcasters
local myPlayerID = Spring.GetMyPlayerID()
local lockPlayerID
local lastBroadcasts = {}
local recentBroadcasters = {}
local newBroadcaster = false
local totalTime = 0
local playerScores = {}
local aliveAllyTeams = {}
local myLastCameraState
--------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------
local playSounds = true
local buttonclick = 'LuaUI/Sounds/buildbar_waypoint.wav'
local sliderdrag = 'LuaUI/Sounds/buildbar_rem.wav'
local lastActivity = {}
local lastFpsData = {}
local lastSystemData = {}
local lastGpuMemData = {}
--------------------------------------------------------------------------------
-- Tooltip
--------------------------------------------------------------------------------
local tipText
--------------------------------------------------------------------------------
-- Players counts and info
--------------------------------------------------------------------------------
-- local player info
local myAllyTeamID
local myTeamID
local mySpecStatus,fullView,_ = Spring.GetSpectatingState()
--General players/spectator count and tables
local player = {}
local playerSpecs = {}
local playerReadyState = {}
local numberOfSpecs = 0
--To determine faction at start
local sideOneDefID = UnitDefNames.armcom.id
local sideTwoDefID = UnitDefNames.corcom.id
local teamSideOne = "arm"
local teamSideTwo = "core"
--Name for absent/resigned players
local absentName = " --- "
--Did the game start yet?
local gameStarted = false
--------------------------------------------------------------------------------
-- Button check variable
--------------------------------------------------------------------------------
local clickToMove = nil -- click detection for moving the widget
local moveStart = nil -- position of the cursor before dragging the widget
local energyPlayer = nil -- player to share energy with (nil when no energy sharing)
local metalPlayer = nil -- player to share metal with(nil when no metal sharing)
local amountEM = 0 -- amount of metal/energy to share/ask
local amountEMMax = nil -- max amount of metal/energy to share/ask
local sliderPosition = 0 -- slider position in metal and energy sharing
local sliderOrigin = nil -- position of the cursor before dragging the widget
local firstclick = 0 --
local dblclickPeriod = 0.4
local backgroundMargin = 7
local widgetRelRight = 0
--------------------------------------------------------------------------------
-- GEOMETRY VARIABLES
--------------------------------------------------------------------------------
local vsx,vsy = gl.GetViewSizes()
local openClose = 0
local widgetTop = 0
local widgetRight = 1
local widgetHeight = 0
local widgetWidth = 0
local widgetPosX = vsx-200
local widgetPosY = 0
local widgetScale = 1
local expandDown = false
local expandLeft = true
local right
local activePlayers = {}
local labelOffset = 18
local separatorOffset = 4
local playerOffset = 17
local specOffset = 12
local drawList = {}
local teamN
local prevClickTime = os.clock()
local specListShow = true
--------------------------------------------------
-- Modules
--------------------------------------------------
local modules = {}
local modulesCount = 0
local m_indent; modulesCount = modulesCount + 1
local m_rank; modulesCount = modulesCount + 1
local m_side; modulesCount = modulesCount + 1
local m_ID; modulesCount = modulesCount + 1
local m_name; modulesCount = modulesCount + 1
local m_share; modulesCount = modulesCount + 1
local m_chat; modulesCount = modulesCount + 1
local m_cpuping; modulesCount = modulesCount + 1
local m_diplo; modulesCount = modulesCount + 1
local m_sizedn; modulesCount = modulesCount + 1
local m_sizeup; modulesCount = modulesCount + 1
-- these are not considered as normal module since they dont take any place and wont affect other's position
-- (they have no module.width and are not part of modules)
local m_point; modulesCount = modulesCount + 1
local m_take; modulesCount = modulesCount + 1
local m_seespec; modulesCount = modulesCount + 1
local position = 1
m_indent = {
name = "indent",
spec = true, --display for specs?
play = true, --display for players?
active = true, --display? (overrides above)
default = true, --display by default?
width = 9,
position = position,
posX = 0,
pic = pics["indentPic"],
noPic = true,
}
position = position + 1
m_ID = {
name = "id",
spec = true,
play = true,
active = false,
width = 17,
position = position,
posX = 0,
pic = pics["idPic"],
}
position = position + 1
m_rank = {
name = "rank",
spec = true, --display for specs?
play = true, --display for players?
active = true, --display? (overrides above)
default = false, --display by default?
width = 18,
position = position,
posX = 0,
pic = pics["rank6"],
}
position = position + 1
m_country = {
name = "country",
spec = true,
play = true,
active = true,
default = true,
width = 20,
position = position,
posX = 0,
pic = pics["countryPic"],
}
position = position + 1
m_side = {
name = "side",
spec = true,
play = true,
active = false,
width = 18,
position = position,
posX = 0,
pic = pics["sidePic"],
}
position = position + 1
m_skill = {
name = "skill",
spec = true,
play = true,
active = true,
width = 18,
position = position,
posX = 0,
pic = pics["tsPic"],
}
position = position + 1
m_name = {
name = "name",
spec = true,
play = true,
active = true,
alwaysActive = true,
width = 10,
position = position,
posX = 0,
pic = pics["namePic"],
noPic = true,
picGap = 7,
}
position = position + 1
m_cpuping = {
name = "cpuping",
spec = true,
play = true,
active = true,
width = 24,
position = position,
posX = 0,
pic = pics["cpuPingPic"],
}
position = position + 1
m_resources = {
name = "resources",
spec = true,
play = true,
active = true,
width = 28,
position = position,
posX = 0,
pic = pics["resourcesPic"],
picGap = 7,
}
position = position + 1
m_share = {
name = "share",
spec = false,
play = true,
active = true,
width = 50,
position = position,
posX = 0,
pic = pics["sharePic"],
}
position = position + 1
m_chat = {
name = "chat",
spec = false,
play = true,
active = false,
width = 18,
position = position,
posX = 0,
pic = pics["chatPic"],
}
position = position + 1
local fixedallies = tonumber(Spring.GetModOptions().fixedallies)
local drawAllyButton = false --(not fixedallies or fixedallies == 0)
m_alliance = {
name = "ally",
spec = false,
play = true,
active = true,
width = 16,
position = position,
posX = 0,
pic = pics["allyPic"],
noPic = false,
}
if not drawAllyButton then
m_alliance.width = 0
end
position = position + 1
m_sizedn = {
name = "sizedn",
spec = true,
play = true,
active = true,
alwaysActive = true,
width = 0,
position = position,
posX = 0,
pic = pics["sizednPic"],
}
position = position + 1
m_sizeup = {
name = "sizeup",
spec = true,
play = true,
active = true,
alwaysActive = true,
width = 0,
position = position,
posX = 0,
pic = pics["sizeupPic"],
}
position = position + 1
modules = {
m_indent,
m_rank,
m_country,
m_ID,
m_side,
m_name,
m_skill,
m_resources,
m_cpuping,
m_alliance,
m_share,
m_chat,
m_sizedn,
m_sizeup,
}
m_point = {
active = true,
defaut = true, -- defaults dont seem to be accesible on widget data load
pic = pics["pointbPic"],
}
m_take = {
active = true,
default = true,
pic = pics["takePic"],
}
m_seespec = {
active = true,
default = true,
pic = pics["seespecPic"],
}
local specsLabelOffset = 0
local teamsizeVersusText = ""
---------------------------------------------------------------------------------------------------
-- Geometry
---------------------------------------------------------------------------------------------------
function SetModulesPositionX()
m_name.width = SetMaxPlayerNameWidth()
table.sort(modules, function(v1,v2)
return v1.position < v2.position
end)
pos = 1
for _,module in ipairs(modules) do
module.posX = pos
if module.active == true then
if mySpecStatus == true then
if module.spec == true then
pos = pos + module.width
end
else
if module.play == true then
pos = pos + module.width
end
end
end
widgetWidth = pos + 1
if widgetWidth < 20 then
widgetWidth = 20
end
if widgetWidth + widgetPosX > vsx then
widgetPosX = vsx - (widgetWidth * widgetScale) - widgetRelRight
end
if widgetRight - widgetWidth < 0 then
widgetRight = widgetWidth
end
if expandLeft == true then
widgetPosX = vsx - (widgetWidth * widgetScale) - widgetRelRight
else
widgetRight = widgetPosX + widgetWidth
end
end
end
function SetMaxPlayerNameWidth()
-- determines the maximal player name width (in order to set the width of the widget)
local t = Spring_GetPlayerList()
local maxWidth = 14*gl_GetTextWidth(absentName) + 8 -- 8 is minimal width
local name = ""
local nextWidth = 0
for _,wplayer in ipairs(t) do
name,_,spec = Spring_GetPlayerInfo(wplayer)
local charSize
if spec then charSize = 11 else charSize = 14 end
nextWidth = charSize*gl_GetTextWidth(name)+8
if nextWidth > maxWidth then
maxWidth = nextWidth
end
end
return maxWidth
end
function GetNumberOfSpecs()
local pList = Spring_GetPlayerList()
local count = 0
local name = ""
for _,playerID in ipairs(pList) do
_,active,spec = Spring_GetPlayerInfo(playerID)
if spec and active then count = count + 1 end
end
return count
end
function GeometryChange()
--check if disappeared off the edge of screen
widgetRight = widgetWidth + widgetPosX
if widgetRight > vsx-(backgroundMargin * widgetScale) then
widgetRight = vsx - (backgroundMargin * widgetScale)
widgetPosX = vsx - ((widgetWidth + backgroundMargin) * widgetScale) - widgetRelRight
end
if widgetPosX + widgetWidth/2 > vsx/2 then
right = true
else
right = false
end
end
local function UpdateAlliances()
playerList = Spring_GetPlayerList()
teamList = Spring_GetTeamList()
for _,playerID in pairs (playerList) do
if not player[playerID].spec then
local alliances = {}
for _,player2ID in pairs (playerList) do
if not player[playerID].spec and not player[player2ID].spec and playerID ~= player2ID and player[playerID].team ~= nil and player[player2ID].team ~= nil and player[playerID].allyteam ~= player[player2ID].allyteam and Spring_AreTeamsAllied(player[player2ID].team, player[playerID].team) then
table.insert(alliances, player2ID)
end
end
player[playerID].alliances = alliances
end
end
end
---------------------------------------------------------------------------------------------------
-- LockCamera stuff
---------------------------------------------------------------------------------------------------
local function UpdateRecentBroadcasters()
recentBroadcasters = {}
local i = 1
for playerID, info in pairs(lastBroadcasts) do
lastTime = info[1]
if (totalTime - lastTime <= listTime or playerID == lockPlayerID) then
if (totalTime - lastTime <= listTime) then
recentBroadcasters[playerID] = totalTime - lastTime
end
i = i + 1
end
end
end
local function LockCamera(playerID)
if playerID and playerID ~= myPlayerID and playerID ~= lockPlayerID then
if lockcameraHideEnemies and not select(3,Spring_GetPlayerInfo(playerID)) then
if not fullView then
sceduledSpecFullView = 1
Spring.SendCommands("specfullview")
else
sceduledSpecFullView = 2
Spring.SendCommands("specfullview")
end
if lockcameraLos and mySpecStatus and Spring.GetMapDrawMode()~="los" then
Spring.SendCommands("togglelos")
end
elseif lockcameraHideEnemies and select(3,Spring_GetPlayerInfo(playerID)) then
if not fullView then
Spring.SendCommands("specfullview")
end
end
lockPlayerID = playerID
myLastCameraState = myLastCameraState or GetCameraState()
local info = lastBroadcasts[lockPlayerID]
if info then
SetCameraState(info[2], transitionTime)
end
else
if myLastCameraState then
SetCameraState(myLastCameraState, transitionTime)
myLastCameraState = nil
end
if lockcameraHideEnemies and lockPlayerID and not select(3,Spring_GetPlayerInfo(lockPlayerID)) then
if not fullView then
Spring.SendCommands("specfullview")
end
if lockcameraLos and mySpecStatus and Spring.GetMapDrawMode()=="los" then
Spring.SendCommands("togglelos")
end
end
lockPlayerID = nil
end
UpdateRecentBroadcasters()
end
function GpuMemEvent(playerID, percentage)
lastGpuMemData[playerID] = percentage
end
function FpsEvent(playerID, fps)
lastFpsData[playerID] = fps
end
function SystemEvent(playerID, system)
-- dont trust the recieved data, limiting abuse
local lines, length = 0, 0
local function helper(line) lines=lines+1; if string.len(line) then length = string.len(line) end return "" end
helper((system:gsub("(.-)\r?\n", helper)))
if lines <= 9 and length <= 64 then
lastSystemData[playerID] = system
end
end
function ActivityEvent(playerID)
lastActivity[playerID] = os.clock()
end
function CameraBroadcastEvent(playerID,cameraState)
--if cameraState is empty then transmission has stopped
if not cameraState then
if lastBroadcasts[playerID] then
lastBroadcasts[playerID] = nil
newBroadcaster = true
end
if lockPlayerID == playerID then
LockCamera()
end
return
end
if not lastBroadcasts[playerID] and not newBroadcaster then
newBroadcaster = true
end
lastBroadcasts[playerID] = {totalTime, cameraState}
if playerID == lockPlayerID then
SetCameraState(cameraState, transitionTime)
end
end
---------------------------------------------------------------------------------------------------
-- Init/GameStart (creating players)
---------------------------------------------------------------------------------------------------
function RecvPlayerScores(newPlayerScores)
playerScores = newPlayerScores or {}
end
function widget:Initialize()
if not WG["background_opacity_custom"] then
WG["background_opacity_custom"] = {0,0,0,0.5}
end
widgetHandler:RegisterGlobal('getPlayerScoresAdvplayerslist', RecvPlayerScores)
widgetHandler:RegisterGlobal('CameraBroadcastEvent', CameraBroadcastEvent)
widgetHandler:RegisterGlobal('ActivityEvent', ActivityEvent)
widgetHandler:RegisterGlobal('FpsEvent', FpsEvent)
widgetHandler:RegisterGlobal('GpuMemEvent', GpuMemEvent)
widgetHandler:RegisterGlobal('SystemEvent', SystemEvent)
UpdateRecentBroadcasters()
mySpecStatus,fullView,_ = Spring.GetSpectatingState()
if Spring.GetGameFrame() <= 0 then
if mySpecStatus and not alwaysHideSpecs then
specListShow = true
else
specListShow = false
end
end
if (Spring.GetConfigInt("ShowPlayerInfo")==1) then
Spring.SendCommands("info 0")
end
if Spring.GetGameFrame()>0 then
gameStarted = true
end
GeometryChange()
SetModulesPositionX()
SetSidePics()
InitializePlayers()
SortList()
WG['advplayerlist_api'] = {}
WG['advplayerlist_api'].GetPosition = function()
local margin = backgroundMargin
local BLcornerX = widgetPosX - margin
local BLcornerY = widgetPosY - margin
local TRcornerX = widgetPosX + widgetWidth + margin
local TRcornerY = widgetPosY + widgetHeight - 1 + margin
local leftPos = BLcornerX - ((widgetPosX - BLcornerX) * (widgetScale-1))
local bottomPos = BLcornerY - ((widgetPosY - BLcornerY) * (widgetScale-1))
local rightPos = TRcornerX - ((widgetPosX - TRcornerX) * (widgetScale-1))
local topPos = TRcornerY - ((widgetPosY - TRcornerY) * (widgetScale-1))
return {topPos,leftPos,bottomPos,rightPos,widgetScale,right}
end
WG['advplayerlist_api'].GetLockPlayerID = function()
return lockPlayerID
end
WG['advplayerlist_api'].SetLockPlayerID = function(playerID)
LockCamera(playerID)
end
WG['advplayerlist_api'].GetLockHideEnemies = function()
return lockcameraHideEnemies
end
WG['advplayerlist_api'].SetLockHideEnemies = function(value)
lockcameraHideEnemies = value
if lockPlayerID and not select(3,Spring_GetPlayerInfo(lockPlayerID)) then
if not lockcameraHideEnemies then
if not fullView then
Spring.SendCommands("specfullview")
if lockcameraLos and mySpecStatus and Spring.GetMapDrawMode()=="los" then
Spring.SendCommands("togglelos")
end
end
else
if fullView then
Spring.SendCommands("specfullview")
if lockcameraLos and mySpecStatus and Spring.GetMapDrawMode()~="los" then
Spring.SendCommands("togglelos")
end
end
end
end
end
WG['advplayerlist_api'].GetLockLos = function()
return lockcameraLos
end
WG['advplayerlist_api'].SetLockLos = function(value)
lockcameraLos = value
if lockcameraHideEnemies and mySpecStatus and lockPlayerID and not select(3,Spring_GetPlayerInfo(lockPlayerID)) then
if lockcameraLos and Spring.GetMapDrawMode()~="los" then
Spring.SendCommands("togglelos")
elseif not lockcameraLos and Spring.GetMapDrawMode()=="los" then
Spring.SendCommands("togglelos")
end
end
end
end
function widget:GameFrame(n)
if n > 0 and not gameStarted then
if mySpecStatus and not alwaysHideSpecs then
specListShow = true
else
specListShow = false
end
gameStarted = true
SetSidePics()
InitializePlayers()
SetOriginalColourNames()
SortList()
end
end
function widget:Shutdown()
if (WG['guishader_api'] ~= nil) then
WG['guishader_api'].RemoveRect('advplayerlist')
end
WG['advplayerlist_api'] = nil
widgetHandler:DeregisterGlobal('CameraBroadcastEvent')
widgetHandler:DeregisterGlobal('ActivityEvent')
widgetHandler:DeregisterGlobal('FpsEvent')
widgetHandler:DeregisterGlobal('GpuMemEvent')
widgetHandler:DeregisterGlobal('SystemEvent')
if ShareSlider then
gl_DeleteList(ShareSlider)
end
if MainList then
gl_DeleteList(MainList)
end
if Background then
gl_DeleteList(Background)
end
if lockPlayerID and mySpecStatus and Spring.GetMapDrawMode()=="los" then
Spring.SendCommands("togglelos")
end
end
function SetSidePics()
--record readyStates
playerList = Spring.GetPlayerList()
for _,playerID in pairs (playerList) do
playerReadyState[playerID] = Spring.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState")
end
--set factions, from TeamRulesParam when possible and from initial info if not
teamList = Spring_GetTeamList()
for _, team in ipairs(teamList) do
local teamSide
if Spring_GetTeamRulesParam(team, 'startUnit') then
local startunit = Spring_GetTeamRulesParam(team, 'startUnit')
if startunit == sideOneDefID then
teamSide = teamSideOne
end
if startunit == sideTwoDefID then
teamSide = teamSideTwo
end
else
_,_,_,_,teamSide = Spring_GetTeamInfo(team)
end
if teamSide then
sidePics[team] = imageDirectory..teamSide.."_default.png"
sidePicsWO[team] = imageDirectory..teamSide.."wo_default.png"
else
sidePics[team] = imageDirectory.."default.png"
sidePicsWO[team] = imageDirectory.."defaultwo.png"
end
end
end
function InitializePlayers()
myPlayerID = Spring_GetLocalPlayerID()
myTeamID = Spring_GetLocalTeamID()
myAllyTeamID = Spring_GetLocalAllyTeamID()
for i = 0, 128 do
player[i] = {}
end
GetAllPlayers()
end
function GetAllPlayers()
local noplayer
local allteams = Spring_GetTeamList()
teamN = table.maxn(allteams) - 1 --remove gaia
for i = 0,teamN-1 do
local teamPlayers = Spring_GetPlayerList(i, true)
player[i + 64] = CreatePlayerFromTeam(i)
for _,playerID in ipairs(teamPlayers) do
player[playerID] = CreatePlayer(playerID)
end
playerSpecs[i] = true -- (this isnt correct when team consists of only AI)
end
specPlayers = Spring_GetTeamList()
for _,playerID in ipairs(specPlayers) do
local active,_,spec = Spring_GetPlayerInfo(playerID)
if spec == true then
if active == true then
player[playerID] = CreatePlayer(playerID)
end
end
end
end
function GetAliveAllyTeams()
aliveAllyTeams = {}
local allteams = Spring_GetTeamList()
teamN = table.maxn(allteams) - 1 --remove gaia
for i = 0,teamN-1 do
local _,_, isDead, _, _, tallyteam = Spring_GetTeamInfo(i)
if not isDead then
aliveAllyTeams[tallyteam] = true
end
end
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function GetSkill(playerID)
local customtable = select(11,Spring_GetPlayerInfo(playerID)) -- player custom table
local tsMu = customtable.skill
local tsSigma = customtable.skilluncertainty
local tskill = ""
if tsMu then
tskill = tsMu and tonumber(tsMu:match("%d+%.?%d*")) or 0
tskill = round(tskill,0)
if string.find(tsMu, ")") then
tskill = "\255"..string.char(190)..string.char(140)..string.char(140) .. tskill -- ')' means inferred from lobby rank
else
-- show privacy mode
local priv = ""
if string.find(tsMu, "~") then -- '~' means privacy mode is on
priv = "\255"..string.char(200)..string.char(200)..string.char(200) .. "*"
end
--show sigma
if tsSigma then -- 0 is low sigma, 3 is high sigma
tsSigma=tonumber(tsSigma)
local tsRed, tsGreen, tsBlue
if tsSigma > 2 then
tsRed, tsGreen, tsBlue = 190, 130, 130
elseif tsSigma == 2 then
tsRed, tsGreen, tsBlue = 140, 140, 140
elseif tsSigma == 1 then
tsRed, tsGreen, tsBlue = 195, 195, 195
elseif tsSigma < 1 then
tsRed, tsGreen, tsBlue = 250, 250, 250
end
tskill = priv .. "\255"..string.char(tsRed)..string.char(tsGreen)..string.char(tsBlue) .. tskill
else
tskill = priv .. "\255"..string.char(195)..string.char(195)..string.char(195) .. tskill --should never happen
end
end
else
tskill = "\255"..string.char(160)..string.char(160)..string.char(160) .. "?"
end
return tskill
end
function CreatePlayer(playerID)
--generic player data
local tname,_, tspec, tteam, tallyteam, tping, tcpu, tcountry, trank = Spring_GetPlayerInfo(playerID)
local _,_,_,_, tside, tallyteam = Spring_GetTeamInfo(tteam)
local tred, tgreen, tblue = Spring_GetTeamColor(tteam)
--skill
local tskill
tskill = GetSkill(playerID)
--cpu/ping
tpingLvl = GetPingLvl(tping)
tcpuLvl = GetCpuLvl(tcpu)
tping = tping * 1000 - ((tping * 1000) % 1)
tcpu = tcpu * 100 - ((tcpu * 100) % 1)
-- resources
local energy, energyStorage, energyIncome, metal, metalStorage, metalIncome = 0,1,0,1,0,0
if aliveAllyTeams[tallyteam] ~= nil and (mySpecStatus or myAllyTeamID == tallyteam) then
energy, energyStorage,_, energyIncome = Spring_GetTeamResources(tteam, "energy")
metal, metalStorage,_, metalIncome = Spring_GetTeamResources(tteam, "metal")
energy = math.floor(energy)
metal = math.floor(metal)
if energy < 0 then energy = 0 end
if metal < 0 then metal = 0 end
end
return {
rank = trank,
skill = tskill,
name = tname,
team = tteam,
allyteam = tallyteam,
red = tred,
green = tgreen,
blue = tblue,
dark = GetDark(tred,tgreen,tblue),
side = tside,
pingLvl = tpingLvl,
cpuLvl = tcpuLvl,
ping = tping,
cpu = tcpu,
country = tcountry,
dead = false,
spec = tspec,
ai = false,
energy = energy,
energyStorage = energyStorage,
metal = metal,
metalStorage = metalStorage,
}
end
function CreatePlayerFromTeam(teamID) -- for when we don't have a human player occupying the slot, also when a player changes team (dies)
local _,_, isDead, isAI, tside, tallyteam = Spring_GetTeamInfo(teamID)
local tred, tgreen, tblue = Spring_GetTeamColor(teamID)
local tname, ttotake, tskill
local tdead = true
if isAI then
local version
_,_,_,_, tname, version = Spring_GetAIInfo(teamID)
if type(version) == "string" then
tname = "AI:" .. tname .. "-" .. version
else
tname = "AI:" .. tname
end
ttotake = false
tdead = false
tai = true
else
if Spring_GetGameSeconds() < 0.1 then
tname = absentName
ttotake = false
tdead = false
else
ttotake = IsTakeable(teamID)
end
tai = false
end
if tname == nil then
tname = absentName
end
tskill = ""
-- resources
local energy, energyStorage, energyIncome, metal, metalStorage, metalIncome = 0,1,0,1,0,0
if aliveAllyTeams[tallyteam] ~= nil and (mySpecStatus or myAllyTeamID == tallyteam) then
energy, energyStorage,_, energyIncome = Spring_GetTeamResources(teamID, "energy") or 0
metal, metalStorage,_, metalIncome = Spring_GetTeamResources(teamID, "metal") or 0
energy = math.floor(energy)
metal = math.floor(metal)
if energy < 0 then energy = 0 end
if metal < 0 then metal = 0 end
end
return{
rank = 8, -- "don't know which" value
skill = tskill,
name = tname,
team = teamID,
allyteam = tallyteam,
red = tred,
green = tgreen,
blue = tblue,
dark = GetDark(tred, tgreen, tblue),
side = tside,
totake = ttotake,
dead = tdead,
spec = false,
ai = tai,
energy = energy,
energyStorage = energyStorage,
metal = metal,
metalStorage = metalStorage,
}
end
function UpdatePlayerResources()
local energy, energyStorage, metal, metalStorage = 0, 1, 0 ,1
for playerID,_ in pairs(player) do
if player[playerID].name and not player[playerID].spec and player[playerID].team then
if aliveAllyTeams[player[playerID].allyteam] ~= nil and (mySpecStatus or myAllyTeamID == player[playerID].allyteam) then
energy, energyStorage,_, energyIncome = Spring_GetTeamResources(player[playerID].team, "energy")
metal, metalStorage,_, metalIncome = Spring_GetTeamResources(player[playerID].team, "metal")
if energy == nil then -- need to be there for when you do /specfullview
energy, energyStorage, energyIncome, metal, metalStorage, metalIncome = 0, 0, 0, 0, 0, 0
else
energy = math.floor(energy)
metal = math.floor(metal)
if energy < 0 then energy = 0 end
if metal < 0 then metal = 0 end
end
player[playerID].energy = energy
player[playerID].energyIncome = energyIncome
player[playerID].energyStorage = energyStorage
player[playerID].metal = metal
player[playerID].metalIncome = metalIncome
player[playerID].metalStorage = metalStorage
end
end
end
end
function GetDark(red,green,blue)
-- Determines if the player color is dark (i.e. if a white outline for the sidePic is needed)
if red + green*1.2 + blue*0.4 < 0.8 then return true end
return false
end
function SetOriginalColourNames()
-- Saves the original team colours associated to team teamID
for playerID,_ in pairs(player) do
if player[playerID].name then
if player[playerID].spec then
originalColourNames[playerID] = "\255\255\255\255"
else
originalColourNames[playerID] = colourNames(player[playerID].team)
end
end
end
end
---------------------------------------------------------------------------------------------------
-- Sorting player data
-- note: SPADS ensures that order of playerIDs/teams/allyteams as appropriate reflects TS (mu) order
---------------------------------------------------------------------------------------------------
function SortList()
local teamList
local myOldSpecStatus = mySpecStatus
_,_, mySpecStatus,_,_,_,_,_,_ = Spring_GetPlayerInfo(myPlayerID)
-- checks if a team has died
if mySpecStatus ~= myOldSpecStatus then
if mySpecStatus == true then
teamList = Spring_GetTeamList()
for _, team in ipairs(teamList) do --
_,_, isDead = Spring_GetTeamInfo(team)
if isDead == false then
Spec(team)
break
end
end
end
end
myAllyTeamID = Spring_GetLocalAllyTeamID()
myTeamID = Spring_GetLocalTeamID()
drawList = {}
drawListOffset = {}
vOffset = 0
-- calls the (cascade) sorting for players
vOffset = SortAllyTeams(vOffset)
-- calls the sortings for specs if see spec is on
--if m_chat.active == true then
vOffset = SortSpecs(vOffset)
--end
-- set the widget height according to space needed to show team
widgetHeight = vOffset + 3
-- move the widget if list is too long
if widgetHeight + widgetPosY > vsy then
widgetPosY = vsy - widgetHeight
end
if widgetTop - widgetHeight < 0 then
--widgetTop = widgetHeight
end
-- set the widget Y position or the top of the widget according to expand direction
if expandDown == true then
widgetPosY = widgetTop - widgetHeight
else
widgetTop = widgetPosY + widgetHeight
end
end
function SortAllyTeams(vOffset)
-- adds ally teams to the draw list (own ally team first)
-- (labels and separators are drawn)
local allyTeamID
local allyTeamList = Spring_GetAllyTeamList()
local firstenemy = true
local isFirstDrawnTeam = true
allyTeamsCount = table.maxn(allyTeamList)-1
--find own ally team
vOffset = 12/2.66
for allyTeamID = 0, allyTeamsCount - 1 do
if allyTeamID == myAllyTeamID then
vOffset = vOffset + labelOffset - 3
if drawAlliesLabel then
table.insert(drawListOffset, vOffset)
table.insert(drawList, -2) -- "Allies" label
vOffset = SortTeams(allyTeamID, vOffset)+2 -- Add the teams from the allyTeam
else
vOffset = SortTeams(allyTeamID, vOffset-labelOffset)
end
break
end
end
-- add the others
for allyTeamID = 0, allyTeamsCount-1 do
if allyTeamID ~= myAllyTeamID then
if firstenemy == true then
vOffset = vOffset + 13
vOffset = vOffset + labelOffset - 3
table.insert(drawListOffset, vOffset)
table.insert(drawList, -3) -- "Enemies" label
firstenemy = false
else
vOffset = vOffset + separatorOffset
table.insert(drawListOffset, vOffset)
table.insert(drawList, -4) -- Enemy teams separator
end
vOffset = SortTeams(allyTeamID, vOffset)+2 -- Add the teams from the allyTeam
end
end
return vOffset
end
local deadPlayerHeightReduction = 10
function SortTeams(allyTeamID, vOffset)
-- Adds teams to the draw list (own team first)
--(teams are not visible as such unless they are empty or AI)
local teamID
local teamsList = Spring_GetTeamList(allyTeamID)
--add teams
for _,teamID in ipairs(teamsList) do
table.insert(drawListOffset, vOffset)
table.insert(drawList, -1)
vOffset = SortPlayers(teamID,allyTeamID,vOffset) -- adds players form the team
local _,_, isDead, _, _, _ = Spring_GetTeamInfo(teamID)
if isDead then
vOffset = vOffset - (deadPlayerHeightReduction/2)
end
end
return vOffset
end
function SortPlayers(teamID,allyTeamID,vOffset)
-- Adds players to the draw list (self first)
local playersList = Spring_GetPlayerList(teamID,true)
local noPlayer = true
local _,_,_, isAi = Spring_GetTeamInfo(teamID)
-- add own player (if not spec)
if myTeamID == teamID then
if player[myPlayerID].name ~= nil then
if mySpecStatus == false then
vOffset = vOffset + playerOffset
table.insert(drawListOffset, vOffset)
table.insert(drawList, myPlayerID) -- new player (with ID)
player[myPlayerID].posY = vOffset
noPlayer = false
end
end
end
-- add other players (if not spec)
for _,playerID in ipairs(playersList) do
if playerID ~= myPlayerID then
if player[playerID].name ~= nil then
if player[playerID].spec ~= true then
vOffset = vOffset + playerOffset
table.insert(drawListOffset, vOffset)
table.insert(drawList, playerID) -- new player (with ID)
player[playerID].posY = vOffset
noPlayer = false
end
end
end
end
-- add AI teams
if isAi == true then
vOffset = vOffset + playerOffset
table.insert(drawListOffset, vOffset)
table.insert(drawList, 64 + teamID) -- new AI team (instead of players)
player[64 + teamID].posY = vOffset
noPlayer = false
end
-- add no player token if no player found in this team at this point
if noPlayer == true then
vOffset = vOffset + playerOffset - (deadPlayerHeightReduction/2)
table.insert(drawListOffset, vOffset)
table.insert(drawList, 64 + teamID) -- no players team
player[64 + teamID].posY = vOffset
if Spring_GetGameFrame() > 0 then
player[64+teamID].totake = IsTakeable(teamID)
end
end
return vOffset
end
function SortSpecs(vOffset)
-- Adds specs to the draw list
local playersList = Spring_GetPlayerList(-1,true)
local noSpec = true
for _,playerID in ipairs(playersList) do
_,active,spec = Spring_GetPlayerInfo(playerID)
if spec and active then
if player[playerID].name ~= nil then
-- add "Specs" label if first spec
if noSpec == true then
vOffset = vOffset + 13
vOffset = vOffset + labelOffset - 2
table.insert(drawListOffset, vOffset)
table.insert(drawList, -5)
noSpec = false
specJoinedOnce = true
vOffset = vOffset + 4
end
-- add spectator
if specListShow == true then
vOffset = vOffset + specOffset
table.insert(drawListOffset, vOffset)
table.insert(drawList, playerID)
player[playerID].posY = vOffset
noPlayer = false
end
end
end
end
-- add "Specs" label
if specJoinedOnce and noSpec then
vOffset = vOffset + 13
vOffset = vOffset + labelOffset - 2
table.insert(drawListOffset, vOffset)
table.insert(drawList, -5)
vOffset = vOffset + 4
end
return vOffset
end
---------------------------------------------------------------------------------------------------
-- Draw control
---------------------------------------------------------------------------------------------------
local PrevGameFrame
local MainList
local Background
local ShareSlider
function widget:DrawScreen()
if Spring_IsGUIHidden() then return end
local scaleDiffX = -((widgetPosX*widgetScale)-widgetPosX)/widgetScale
local scaleDiffY = -((widgetPosY*widgetScale)-widgetPosY)/widgetScale
gl.Scale(widgetScale,widgetScale,0)
gl.Translate(scaleDiffX,scaleDiffY,0)
-- update lists frequently if there is mouse interaction
local NeedUpdate = false
local mouseX,mouseY = Spring_GetMouseState()
if (mouseX > widgetPosX + m_name.posX + m_name.width - 5) and (mouseX < widgetPosX + widgetWidth) and (mouseY > widgetPosY - 16) and (mouseY < widgetPosY + widgetHeight) then
local DrawFrame = Spring_GetDrawFrame()
local CurGameFrame = Spring_GetGameFrame()
if PrevGameFrame == nil then PrevGameFrame = CurGameFrame end
if (DrawFrame%5==0) or (CurGameFrame>PrevGameFrame+1) then
--Echo(DrawFrame)
NeedUpdate = true
end
end
if NeedUpdate then
--Spring.Echo("DS APL update")
CreateLists()
PrevGameFrame = CurGameFrame
end
-- draws the background
gl_Color(WG["background_opacity_custom"])
if Background then
gl_CallList(Background)
else
CreateBackground()
end
-- draws the main list
if MainList then
gl_CallList(MainList)
else
CreateMainList()
end
-- draws share energy/metal sliders
if ShareSlider then
gl_CallList(ShareSlider)
else
CreateShareSlider()
end
local scaleReset = widgetScale / widgetScale / widgetScale
gl.Translate(-scaleDiffX,-scaleDiffY,0)
gl.Scale(scaleReset,scaleReset,0)
end
function CreateLists()
CheckTime() --this also calls CheckPlayers
UpdateRecentBroadcasters()
UpdateAlliances()
GetAliveAllyTeams()
if m_resources.active then
UpdateResources()
end
UpdatePlayerResources()
--Create lists
CreateBackground()
CreateMainList()
CreateShareSlider()
end
---------------------------------------------------------------------------------------------------
-- Background gllist
---------------------------------------------------------------------------------------------------
local function DrawRectRound(px,py,sx,sy,cs,ignoreBorder)
gl.TexCoord(0.8,0.8)
gl.Vertex(px+cs, py, 0)
gl.Vertex(sx-cs, py, 0)
gl.Vertex(sx-cs, sy, 0)
gl.Vertex(px+cs, sy, 0)
gl.Vertex(px, py+cs, 0)
gl.Vertex(px+cs, py+cs, 0)
gl.Vertex(px+cs, sy-cs, 0)
gl.Vertex(px, sy-cs, 0)
gl.Vertex(sx, py+cs, 0)
gl.Vertex(sx-cs, py+cs, 0)
gl.Vertex(sx-cs, sy-cs, 0)
gl.Vertex(sx, sy-cs, 0)
local offset = 0.05 -- texture offset, because else gaps could show
-- top left
if (py+((sy-py)*widgetScale) >= vsy-backgroundMargin or px <= backgroundMargin) and ignoreBorder == nil then o = 0.5 else o = offset end
gl.TexCoord(o,o)
gl.Vertex(px, sy, 0)
gl.TexCoord(o,1-o)
gl.Vertex(px+cs, sy, 0)
gl.TexCoord(1-o,1-o)
gl.Vertex(px+cs, sy-cs, 0)
gl.TexCoord(1-o,o)
gl.Vertex(px, sy-cs, 0)
-- top right
if (py+((sy-py)*widgetScale) >= vsy-backgroundMargin or (px+((sx-px)*widgetScale)) >= vsx-backgroundMargin) and ignoreBorder == nil then o = 0.5 else o = offset end
gl.TexCoord(o,o)
gl.Vertex(px, py, 0)
gl.TexCoord(o,1-o)
gl.Vertex(px+cs, py, 0)
gl.TexCoord(1-o,1-o)
gl.Vertex(px+cs, py+cs, 0)
gl.TexCoord(1-o,o)
gl.Vertex(px, py+cs, 0)
-- bottom left
if (py <= backgroundMargin or px <= backgroundMargin) and ignoreBorder == nil then o = 0.5 else o = offset end
gl.TexCoord(o,o)
gl.Vertex(sx, py, 0)
gl.TexCoord(o,1-o)
gl.Vertex(sx-cs, py, 0)
gl.TexCoord(1-o,1-o)
gl.Vertex(sx-cs, py+cs, 0)
gl.TexCoord(1-o,o)
gl.Vertex(sx, py+cs, 0)
-- bottom right
if (py <= backgroundMargin or (px+((sx-px)*widgetScale)) >= vsx-backgroundMargin) and ignoreBorder == nil then o = 0.5 else o = offset end
gl.TexCoord(o,o)
gl.Vertex(sx, sy, 0)
gl.TexCoord(o,1-o)
gl.Vertex(sx-cs, sy, 0)
gl.TexCoord(1-o,1-o)
gl.Vertex(sx-cs, sy-cs, 0)
gl.TexCoord(1-o,o)
gl.Vertex(sx, sy-cs, 0)
end
function RectRound(px,py,sx,sy,cs,ignoreBorder) -- (coordinates work differently than the RectRound func in other widgets)
gl.Texture(bgcorner)
gl.BeginEnd(GL.QUADS, DrawRectRound, px,py,sx,sy,cs,ignoreBorder)
gl.Texture(false)
end
function CreateBackground()
if Background then
gl_DeleteList(Background)
end
local margin = backgroundMargin
local BLcornerX = widgetPosX - margin
local BLcornerY = widgetPosY - margin
local TRcornerX = widgetPosX + widgetWidth + margin
local TRcornerY = widgetPosY + widgetHeight - 1 + margin
if (WG['guishader_api'] ~= nil) then
local left = BLcornerX - ((widgetPosX - BLcornerX) * (widgetScale-1))
local bottom = BLcornerY - ((widgetPosY - BLcornerY) * (widgetScale-1))
local right = TRcornerX - ((widgetPosX - TRcornerX) * (widgetScale-1))
local top = TRcornerY - ((widgetPosY - TRcornerY) * (widgetScale-1))
WG['guishader_api'].InsertRect(left,bottom,right,top,'advplayerlist')
end
Background = gl_CreateList(function()
RectRound(BLcornerX,BLcornerY,TRcornerX,TRcornerY,6)
local padding = 2.75
gl_Color(1,1,1,0.025)
RectRound(BLcornerX+padding,BLcornerY+padding,TRcornerX-padding,TRcornerY-padding,padding,true)
--DrawRect(BLcornerX,BLcornerY,TRcornerX,TRcornerY)
-- draws highlight (top and left sides)
--gl_Color(0.44,0.44,0.44,0.38)
--gl_Rect(widgetPosX-margin-1, widgetPosY + widgetHeight +margin, widgetPosX + widgetWidth+margin, widgetPosY + widgetHeight-1+margin)
--gl_Rect(widgetPosX-margin-1 , widgetPosY-margin, widgetPosX-margin, widgetPosY-margin + widgetHeight + 1 - 1+margin+margin)
gl_Color(1,1,1,1)
end)
end
---------------------------------------------------------------------------------------------------
-- Main (player) gllist
---------------------------------------------------------------------------------------------------
function UpdateResources()
if energyPlayer ~= nil then
if energyPlayer.team == myTeamID then
local current,storage = Spring_GetTeamResources(myTeamID,"energy")
amountEMMax = storage - current
amountEM = amountEMMax*sliderPosition/39
amountEM = amountEM-(amountEM%1)
else
amountEMMax = Spring_GetTeamResources(myTeamID,"energy")
amountEM = amountEMMax*sliderPosition/39
amountEM = amountEM-(amountEM%1)
end
end
if metalPlayer ~= nil then
if metalPlayer.team == myTeamID then
local current, storage = Spring_GetTeamResources(myTeamID,"metal")
amountEMMax = storage - current
amountEM = amountEMMax*sliderPosition/39
amountEM = amountEM-(amountEM%1)
else
amountEMMax = Spring_GetTeamResources(myTeamID,"metal")
amountEM = amountEMMax*sliderPosition/39
amountEM = amountEM-(amountEM%1)
end
end
end
function CheckTime()
local period = 0.5
now = os.clock()
if now > (lastTime + period) then
lastTime = now
CheckPlayersChange()
if blink == true then
blink = false
else
blink = true
end
for playerID =0, 63 do
if player[playerID] ~= nil then
if player[playerID].pointTime ~= nil then
if player[playerID].pointTime <= now then
player[playerID].pointX = nil
player[playerID].pointY = nil
player[playerID].pointZ = nil
player[playerID].pointTime = nil
end
end
end
end
end
end
function CreateMainList(tip)
--Spring.Echo("List Updated")
numberOfSpecs = GetNumberOfSpecs()
local mouseX,mouseY = Spring_GetMouseState()
local leader
if MainList then
gl_DeleteList(MainList)
end
MainList = gl_CreateList(function()
drawTipText = nil
for i, drawObject in ipairs(drawList) do
if drawObject == -5 then
specsLabelOffset = drawListOffset[i]
local specAmount = numberOfSpecs
if numberOfSpecs == 0 or (specListShow and numberOfSpecs < 10) then
specAmount = ""
end
DrawLabel(" Spectators "..specAmount, drawListOffset[i], specListShow)
if Spring.GetGameFrame() <= 0 then
if specListShow then
DrawLabelTip("(click to hide specs)", drawListOffset[i], 95)
else
DrawLabelTip("(click to show specs)", drawListOffset[i], 95)
end
end
elseif drawObject == -4 then
DrawSeparator(drawListOffset[i])
elseif drawObject == -3 then
DrawLabel(" Enemies", drawListOffset[i], true)
elseif drawObject == -2 then
DrawLabel(" Allies", drawListOffset[i], true)
if Spring.GetGameFrame() <= 0 then
DrawLabelTip("(dbl-click playername to track)", drawListOffset[i], 46)
end
elseif drawObject == -1 then
leader = true
else
DrawPlayer(drawObject, leader, drawListOffset[i], mouseX, mouseY)
end
-- draw player tooltip later so they will be on top of players drawn below
if tipText ~= nil then
drawTipText = tipText
drawTipMouseX = mouseX
drawTipMouseY = mouseY
end
end
if drawTipText ~= nil then
tipText = drawTipText
DrawTip(drawTipMouseX, drawTipMouseY)
end
end)
end
function DrawLabel(text, vOffset, drawSeparator)
if widgetWidth < 67 then
text = string.sub(text, 0, 1)
end
gl_Color(0,0,0,0.2)
gl_Text(text, widgetPosX - 1, widgetPosY + widgetHeight -vOffset+6.6, 12, "")
gl_Text(text, widgetPosX + 1, widgetPosY + widgetHeight -vOffset+6.6, 12, "")
gl_Color(0.9,0.9,0.9,0.75)
gl_Text(text, widgetPosX, widgetPosY + widgetHeight -vOffset+7.5, 12, "n")
if drawSeparator then
--DrawSeparator(vOffset)
end
end
function DrawLabelTip(text, vOffset, xOffset)
if widgetWidth < 67 then
text = string.sub(text, 0, 1)
end
gl_Color(0,0,0,0.08)
gl_Text(text, widgetPosX + xOffset - 1, widgetPosY + widgetHeight -vOffset+6.8, 10, "")
gl_Text(text, widgetPosX + xOffset + 1, widgetPosY + widgetHeight -vOffset+6.8, 10, "")
gl_Color(0.9,0.9,0.9,0.35)
gl_Text(text, widgetPosX + xOffset, widgetPosY + widgetHeight -vOffset+7.5, 10, "n")
end
function DrawSeparator(vOffset)
vOffset = vOffset - 2
gl_Color(0.55,0.55,0.55,0.45)
gl_Rect(widgetPosX+2, widgetPosY + widgetHeight -vOffset+(1/widgetScale), widgetPosX + widgetWidth-2, widgetPosY + widgetHeight -vOffset)
gl_Color(0,0,0,0.3)
gl_Rect(widgetPosX+2, widgetPosY + widgetHeight -vOffset, widgetPosX + widgetWidth-2, widgetPosY + widgetHeight -vOffset-(1/widgetScale))
gl_Color(1,1,1)
end
function DrawLabelRightside(text, vOffset)
local textLength = (gl_GetTextWidth(text)*12)*widgetScale
gl_Color(1,1,1,0.13)
gl_Text(text, widgetRight - textLength, widgetPosY + widgetHeight -vOffset+7.5, 12, "n")
end
function RecvPlayerBetList(newPlayerBetList)
playerBetList = newPlayerBetList or {}
end
function DrawPlayer(playerID, leader, vOffset, mouseX, mouseY)
tipY = nil
local rank = player[playerID].rank
local skill = player[playerID].skill
local name = player[playerID].name
local team = player[playerID].team
local allyteam = player[playerID].allyteam
local side = player[playerID].side
local red = player[playerID].red
local green = player[playerID].green
local blue = player[playerID].blue
local dark = player[playerID].dark
local pingLvl = player[playerID].pingLvl
local cpuLvl = player[playerID].cpuLvl
local ping = player[playerID].ping
local cpu = player[playerID].cpu
local country = player[playerID].country
local spec = player[playerID].spec
local totake = player[playerID].totake
local needm = player[playerID].needm
local neede = player[playerID].neede
local dead = player[playerID].dead
local ai = player[playerID].ai
local alliances = player[playerID].alliances
local posY = widgetPosY + widgetHeight - vOffset
local tipPosY = widgetPosY + ((widgetHeight - vOffset)*widgetScale)
local alpha = 0.44-- alpha used to show inactivity for specs
if WG['betfrontend'] ~= nil then
--playerScores = WG['betfrontend'].GetPlayerScores()
end
--if mySpecStatus then
alpha = 0.33
local alphaActivity = 0
-- keyboard/mouse activity
if lastActivity[playerID] ~= nil and type(lastActivity[playerID]) == "number" then
alphaActivity = (8 - math.floor(now-lastActivity[playerID])) / 5.5
if alphaActivity > 1 then alphaActivity = 1 end
if alphaActivity < 0 then alphaActivity = 0 end
alphaActivity = 0.33 + (alphaActivity*0.21)
alpha = alphaActivity
end
-- camera activity
if recentBroadcasters[playerID] ~= nil and type(recentBroadcasters[playerID]) == "number" then
local alphaCam = (13 - math.floor(recentBroadcasters[playerID])) / 8.5
if alphaCam > 1 then alphaCam = 1 end
if alphaCam < 0 then alphaCam = 0 end
alpha = 0.33 + (alphaCam*0.42)
if alpha < alphaActivity then alpha = alphaActivity end
end
--else
-- alpha = 0.44
--end
if mouseY >= tipPosY and mouseY <= tipPosY + (16*widgetScale) then tipY = true end
if (lockPlayerID ~= nil and lockPlayerID == playerID) then -- active
DrawCamera(posY, true)
end
if spec == false then --player
if not dead and alliances ~= nil and #alliances > 0 then
DrawAlliances(alliances, posY)
end
if leader == true then -- take / share buttons
if mySpecStatus == false then
if allyteam == myAllyTeamID then
if m_take.active == true then
if totake == true then
DrawTakeSignal(posY)
if tipY == true then TakeTip(mouseX) end
end
end
if m_share.active == true and dead ~= true then
DrawShareButtons(posY, needm, neede)
if tipY == true then ShareTip(mouseX, playerID) end
end
end
if drawAllyButton and dead ~= true then
if tipY == true then AllyTip(mouseX, playerID) end
end
else
if m_indent.active == true and Spring_GetMyTeamID() == team then
DrawDot(posY)
end
end
gl_Color(red,green,blue,1)
if m_ID.active == true then
DrawID(team, posY, dark, dead)
end
if m_skill.active == true then
DrawSkill(skill, posY, dark, name)
end
end
gl_Color(red,green,blue,1)
if m_rank.active == true then
DrawRank(rank, posY)
end
if m_country.active == true and country ~= "" then
DrawCountry(country, posY)
end
--gl_Color(red,green,blue,1)
gl_Color(1,1,1,0.45)
if name ~= absentName and m_side.active == true then
DrawSidePic(team, playerID, posY, leader, dark, ai)
end
gl_Color(red,green,blue,1)
if m_name.active == true then
DrawName(name, team, posY, dark, playerID)
end
if m_alliance.active == true and drawAllyButton and not mySpecStatus and not dead and team ~= myTeamID then
DrawAlly(posY, player[playerID].team)
end
if m_resources.active and aliveAllyTeams[allyteam] ~= nil and player[playerID].energy ~= nil then
if mySpecStatus or myAllyTeamID == allyteam then
local e = player[playerID].energy
local es = player[playerID].energyStorage
local ei = player[playerID].energyIncome
local m = player[playerID].metal
local ms = player[playerID].metalStorage
local mi = player[playerID].metalIncome
if es > 0 then
DrawResources(e, es, m, ms, posY, dead)
if tipY == true then ResourcesTip(mouseX, e, es, ei, m, ms, mi) end
end
end
end
else -- spectator
gl_Color(1,1,1,1)
if specListShow == true and m_name.active == true then
if playerSpecs[playerID] ~= nil and (lockPlayerID ~= nil and lockPlayerID ~= playerID or lockPlayerID == nil) then
if recentBroadcasters[playerID] ~= nil and type(recentBroadcasters[playerID]) == "number" then
DrawCamera(posY, false)
end
end
if playerScores[playerID] ~= nil then
DrawChips(playerID, posY)
end
DrawSmallName(name, team, posY, false, playerID, alpha)
end
end
if m_cpuping.active == true then
if cpuLvl ~= nil then -- draws CPU usage and ping icons (except AI and ghost teams)
DrawPingCpu(pingLvl,cpuLvl,posY,spec,1,cpu,lastFpsData[playerID])
if tipY == true then PingCpuTip(mouseX, ping, cpu, lastFpsData[playerID], lastGpuMemData[playerID], lastSystemData[playerID], name) end
end
end
gl_Color(1,1,1,1)
if playerID < 64 then
if m_chat.active == true and mySpecStatus == false and spec == false then
if playerID ~= myPlayerID then
DrawChatButton(posY)
end
end
if m_point.active then
if player[playerID].pointTime ~= nil then
if player[playerID].allyteam == myAllyTeamID or mySpecStatus == true then
--if blink == true then
DrawPoint(posY, player[playerID].pointTime-now)
--end
if tipY == true then PointTip(mouseX) end
end
end
end
end
leader = false
gl_Texture(false)
end
function DrawTakeSignal(posY)
if blink == true then -- Draws a blinking rectangle if the player of the same team left (/take option)
if right then
gl_Color(0.7,0.7,0.7)
gl_Texture(pics["arrowPic"])
DrawRect(widgetPosX - 14, posY, widgetPosX, posY + 16)
gl_Color(1,1,1)
gl_Texture(pics["takePic"])
DrawRect(widgetPosX - 57, posY - 15, widgetPosX - 12, posY + 32)
else
local leftPosX = widgetPosX + widgetWidth
gl_Color(0.7,0.7,0.7)
gl_Texture(pics["arrowPic"])
DrawRect(leftPosX + 14, posY, leftPosX, posY + 16)
gl_Color(1,1,1)
gl_Texture(pics["takePic"])
DrawRect(leftPosX + 12, posY - 15, leftPosX + 57, posY + 32)
end
end
end
function DrawShareButtons(posY, needm, neede)
gl_Color(1,1,1,1)
gl_Texture(pics["unitsPic"]) -- Share UNIT BUTTON
DrawRect(m_share.posX + widgetPosX + 1, posY, m_share.posX + widgetPosX + 17, posY + 16)
gl_Texture(pics["energyPic"]) -- share ENERGY BUTTON
DrawRect(m_share.posX + widgetPosX + 17, posY, m_share.posX + widgetPosX + 33, posY + 16)
gl_Texture(pics["metalPic"]) -- share METAL BUTTON
DrawRect(m_share.posX + widgetPosX + 33, posY, m_share.posX + widgetPosX + 49, posY + 16)
gl_Texture(pics["lowPic"])
if needm == true then
DrawRect(m_share.posX + widgetPosX + 33, posY, m_share.posX + widgetPosX + 49, posY + 16)
end
if neede == true then
DrawRect(m_share.posX + widgetPosX + 17, posY, m_share.posX + widgetPosX + 33, posY + 16)
end
gl_Texture(false)
end
function DrawChatButton(posY)
gl_Texture(pics["chatPic"])
DrawRect(m_chat.posX + widgetPosX + 1, posY, m_chat.posX + widgetPosX + 17, posY + 16)
end
function DrawResources(energy, energyStorage, metal, metalStorage, posY, dead)
local paddingLeft = 2
local paddingRight = 2
local barWidth = m_resources.width - paddingLeft - paddingRight
local y1Offset = 7
local y2Offset = 5
if dead then
y1Offset = 7.4
y2Offset = 6
end
gl_Color(1,1,1,0.14)
gl_Texture(pics["resbarBgPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset, m_resources.posX + widgetPosX + paddingLeft + barWidth, posY + y2Offset)
gl_Color(1,1,1,1)
gl_Texture(pics["resbarPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset, m_resources.posX + widgetPosX + paddingLeft + ((barWidth/metalStorage)*metal), posY + y2Offset)
if ((barWidth/metalStorage)*metal) > 0.8 then
local glowsize = 12
gl_Color(1,1,1.2,0.033)
gl_Texture(pics["barGlowCenterPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset+glowsize, m_resources.posX + widgetPosX + paddingLeft + ((barWidth/metalStorage)*metal), posY + y2Offset-glowsize)
gl_Texture(pics["barGlowEdgePic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft-(glowsize*1.8), posY + y1Offset+glowsize, m_resources.posX + widgetPosX + paddingLeft, posY + y2Offset-glowsize)
DrawRect(m_resources.posX + widgetPosX + paddingLeft + ((barWidth/metalStorage)*metal)+(glowsize*1.8), posY + y1Offset+glowsize, m_resources.posX + widgetPosX + paddingLeft + ((barWidth/metalStorage)*metal), posY + y2Offset-glowsize)
end
if not dead then
y1Offset = 11
y2Offset = 9
else
y1Offset = 10
y2Offset = 8.6
end
gl_Color(1,1,0,0.14)
gl_Texture(pics["resbarBgPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset, m_resources.posX + widgetPosX + paddingLeft + barWidth, posY + y2Offset)
gl_Color(1,1,0,1)
gl_Texture(pics["resbarPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset, m_resources.posX + widgetPosX + paddingLeft + ((barWidth/energyStorage)*energy), posY + y2Offset)
if ((barWidth/energyStorage)*energy) > 0.8 then
local glowsize = 12
gl_Color(1,1,0.2,0.033)
gl_Texture(pics["barGlowCenterPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset+glowsize, m_resources.posX + widgetPosX + paddingLeft + ((barWidth/energyStorage)*energy), posY + y2Offset-glowsize)
gl_Texture(pics["barGlowEdgePic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft-(glowsize*1.8), posY + y1Offset+glowsize, m_resources.posX + widgetPosX + paddingLeft, posY + y2Offset-glowsize)
DrawRect(m_resources.posX + widgetPosX + paddingLeft + ((barWidth/energyStorage)*energy)+(glowsize*1.8), posY + y1Offset+glowsize, m_resources.posX + widgetPosX + paddingLeft + ((barWidth/energyStorage)*energy), posY + y2Offset-glowsize)
end
end
function DrawChips(playerID, posY)
local xPos = m_name.posX + widgetPosX - 6
gl_Color(0.75,0.75,0.75,0.8)
gl_Text(playerScores[playerID].score, xPos-5, posY+4, 9.5, "r")
gl_Color(1,1,1,1)
gl_Texture(pics["chipPic"])
DrawRect(xPos+4, posY+3.5, xPos-2.5, posY + 10)
end
function DrawSidePic(team, playerID, posY, leader, dark, ai)
if gameStarted then
if leader == true then
gl_Texture(sidePics[team]) -- sets side image (for leaders)
else
gl_Texture(pics["notFirstPic"]) -- sets image for not leader of team players
end
DrawRect(m_side.posX + widgetPosX + 2, posY+1, m_side.posX + widgetPosX + 16, posY + 15) -- draws side image
--[[if dark == true then -- draws outline if player color is dark
gl_Color(1,1,1)
if leader == true then
gl_Texture(sidePicsWO[team])
else
gl_Texture(notFirstPicWO)
end
DrawRect(m_side.posX + widgetPosX + 2, posY+1,m_side.posX + widgetPosX + 16, posY + 15)
gl_Texture(false)
end
]]--
gl_Texture(false)
else
DrawState(playerID, m_side.posX + widgetPosX, posY)
end
end
function DrawRank(rank, posY)
if rank == 0 then
DrawRankImage(pics["rank0"], posY)
elseif rank == 1 then
DrawRankImage(pics["rank1"], posY)
elseif rank == 2 then
DrawRankImage(pics["rank2"], posY)
elseif rank == 3 then
DrawRankImage(pics["rank3"], posY)
elseif rank == 4 then
DrawRankImage(pics["rank4"], posY)
elseif rank == 5 then
DrawRankImage(pics["rank5"], posY)
elseif rank == 6 then
DrawRankImage(pics["rank6"], posY)
elseif rank == 7 then
DrawRankImage(pics["rank7"], posY)
else
--DrawRankImage(rank8, posY)
end
gl_Color(1,1,1,1)
end
function DrawRankImage(rankImage, posY)
gl_Color(1,1,1)
gl_Texture(rankImage)
DrawRect(m_rank.posX + widgetPosX + 3, posY+1, m_rank.posX + widgetPosX + 17, posY + 15)
end
local function RectQuad(px,py,sx,sy)
local o = 0.008 -- texture offset, because else grey line might show at the edges
gl.TexCoord(o,1-o)
gl.Vertex(px, py, 0)
gl.TexCoord(1-o,1-o)
gl.Vertex(sx, py, 0)
gl.TexCoord(1-o,o)
gl.Vertex(sx, sy, 0)
gl.TexCoord(o,o)
gl.Vertex(px, sy, 0)
end
function DrawRect(px,py,sx,sy)
--local px,py,sx,sy,cs = math.floor(px),math.floor(py),math.ceil(sx),math.ceil(sy),math.floor(cs)
gl.BeginEnd(GL.QUADS, RectQuad, px,py,sx,sy)
end
function DrawAlly(posY, team)
if Spring_AreTeamsAllied(team, myTeamID) then
gl_Color(0,1,0, 0.44)
else
gl_Color(1,0,0, 0.44)
end
gl_Texture(pics["allyPic"])
DrawRect(m_alliance.posX + widgetPosX + 3, posY+1, m_alliance.posX + widgetPosX + 17, posY + 15)
end
function DrawCountry(country, posY)
if country ~= nil and country ~= "??" then
gl_Texture(flagsDirectory..string.upper(country)..".dds")
gl_Color(1,1,1)
DrawRect(m_country.posX + widgetPosX + 3, posY+1, m_country.posX + widgetPosX + 17, posY + 15)
end
end
function DrawDot(posY)
gl_Color(1,1,1,0.70)
gl_Texture(pics["currentPic"])
DrawRect(m_indent.posX + widgetPosX-1 , posY+3, m_indent.posX + widgetPosX + 7, posY + 11)
end
function DrawCamera(posY,active)
if active ~= nil and active then
gl_Color(1,1,1,0.7)
else
gl_Color(1,1,1,0.13)
end
gl_Texture(pics["cameraPic"])
DrawRect(m_indent.posX + widgetPosX-1.5 , posY+2, m_indent.posX + widgetPosX + 9, posY + 12.4)
end
function colourNames(teamID)
nameColourR,nameColourG,nameColourB,nameColourA = Spring_GetTeamColor(teamID)
R255 = math.floor(nameColourR*255) --the first \255 is just a tag (not colour setting) no part can end with a zero due to engine limitation (C)
G255 = math.floor(nameColourG*255)
B255 = math.floor(nameColourB*255)
if ( R255%10 == 0) then
R255 = R255+1
end
if( G255%10 == 0) then
G255 = G255+1
end
if ( B255%10 == 0) then
B255 = B255+1
end
return "\255"..string.char(R255)..string.char(G255)..string.char(B255) --works thanks to zwzsg
end
function DrawState(playerID, posX, posY)
-- note that adv pl list uses a phantom pID for absent players, so this will always show unready for players not ingame
local ready = (playerReadyState[playerID]==1) or (playerReadyState[playerID]==2) or (playerReadyState[playerID]==-1)
local hasStartPoint = (playerReadyState[playerID]==4)
if ai then
gl_Color(0.1,0.1,0.97,1)
else
if ready then
gl_Color(0.1,0.95,0.2,1)
else
if hasStartPoint then
gl_Color(1,0.65,0.1,1)
else
gl_Color(0.8,0.1,0.1,1)
end
end
end
gl_Texture(pics["readyTexture"])
DrawRect(posX, posY - 1 , posX + 16, posY + 16)
gl_Color(1,1,1,1)
end
function DrawAlliances(alliances, posY) -- still a problem is that teams with the same/similar color can be misleading
local posX = widgetPosX + m_name.posX
local width = m_name.width / #alliances
local padding = 2
for i,playerID in pairs(alliances) do
if player[playerID] ~= nil and player[playerID].red ~= nil then
gl_Color(0,0,0,0.25)
RectRound(posX+(width*(i-1)), posY - 3 , posX + (width*i), posY + 19, 2)
gl_Color(player[playerID].red, player[playerID].green, player[playerID].blue, 0.5)
RectRound(posX+(width*(i-1)) + padding, posY - 3 + padding , posX + (width*i)- padding, posY + 19 - padding, 2)
end
end
gl_Color(1,1,1,1)
end
function DrawName(name, team, posY, dark, playerID)
local willSub = ""
if not gameStarted then
if playerID>=64 then
willSub = (Spring.GetGameRulesParam("Player" .. (playerID-64) .. "willSub")==1) and " (sub)" or "" --pID-64 because apl uses dummy playerIDs for absent players
else
willSub = (Spring.GetGameRulesParam("Player" .. (playerID) .. "willSub")==1) and " (sub)" or ""
end
end
local nameText = name .. willSub
local nameColourR,nameColourG,nameColourB,nameColourA = Spring_GetTeamColor(team)
local xPadding = 0
-- includes readystate icon if factions arent shown
if not gameStarted and not m_side.active then
xPadding = 16
DrawState(playerID, m_name.posX + widgetPosX, posY)
end
if (nameColourR + nameColourG*1.2 + nameColourB*0.4) < 0.8 then
gl_Text(colourNames(team) .. nameText, m_name.posX + widgetPosX + 3 + xPadding, posY + 4, 14, "o") -- draws name
else
gl_Color(0,0,0,0.45)
gl_Text(nameText, m_name.posX + widgetPosX + 2 + xPadding, posY + 3, 14, "n") -- draws name
gl_Text(nameText, m_name.posX + widgetPosX + 4 + xPadding, posY + 3, 14, "n") -- draws name
gl_Color(nameColourR,nameColourG,nameColourB,1)
gl_Text(nameText, m_name.posX + widgetPosX + 3 + xPadding, posY + 4, 14, "n") -- draws name
end
gl_Color(1,1,1)
end
function DrawSmallName(name, team, posY, dark, playerID, alpha)
if team ~= nil then
if originalColourNames[playerID] then
name = originalColourNames[playerID] .. name
end
local textindent = 4
local explayerindent = -3
if m_indent.active or m_rank.active or m_side.active or m_ID.active then
textindent = 0
end
local nameColourR,nameColourG,nameColourB,nameColourA = 1,1,1,1
if playerSpecs[playerID] ~= nil then
nameColourR,nameColourG,nameColourB,nameColourA = Spring_GetTeamColor(team)
if (nameColourR + nameColourG*1.2 + nameColourB*0.4) < 0.8 then
gl_Text(colourNames(team) .. name, m_name.posX + textindent + explayerindent + widgetPosX + 3, posY + 4, 11, "o")
else
gl_Color(0,0,0,0.3)
gl_Text(name, m_name.posX + textindent + explayerindent + widgetPosX + 2, posY + 3.2, 11, "n") -- draws name
gl_Text(name, m_name.posX + textindent + explayerindent + widgetPosX + 4, posY + 3.2, 11, "n") -- draws name
gl_Color(nameColourR,nameColourG,nameColourB,0.78)
gl_Text(name, m_name.posX + textindent + explayerindent + widgetPosX + 3, posY + 4, 11, "n")
end
else
gl_Color(0,0,0,0.3)
gl_Text(name, m_name.posX + textindent + widgetPosX + 2.2, posY + 3.3, 10, "n")
gl_Text(name, m_name.posX + textindent + widgetPosX + 3.8, posY + 3.3, 10, "n")
gl_Color(1,1,1,alpha)
gl_Text(name, m_name.posX + textindent + widgetPosX + 3, posY + 4, 10, "n")
end
gl_Color(1,1,1)
end
end
function DrawID(playerID, posY, dark, dead)
local spacer = ""
if playerID < 10 then
spacer = " "
end
local fontSize = 11
local deadspace = 0
if dead then
fontSize = 8
deadspace = 1.5
gl_Color(0,0,0,0.4)
else
gl_Color(0,0,0,0.6)
end
--gl_Text(colourNames(playerID) .. " ".. playerID .. "", m_ID.posX + widgetPosX+4.5, posY + 5, 11, "o")
gl_Text(spacer .. playerID .. "", m_ID.posX + deadspace + widgetPosX+4.5, posY + 4.1, fontSize, "n")
if dead then
gl_Color(1,1,1,0.33)
else
gl_Color(1,1,1,0.5)
end
gl_Text(spacer .. playerID .. "", m_ID.posX + deadspace + widgetPosX+4.5, posY + 5, fontSize, "n")
gl_Color(1,1,1)
end
function DrawSkill(skill, posY, dark)
gl_Text(skill, m_skill.posX + widgetPosX + m_skill.width - 2, posY + 5.3, 9.5, "or")
gl_Color(1,1,1)
end
function DrawPingCpu(pingLvl, cpuLvl, posY, spec, alpha, cpu, fps)
gl_Texture(pics["pingPic"])
if spec then
local grayvalue = 0.3 + (pingLvl / 15)
gl_Color(grayvalue,grayvalue,grayvalue,(0.2*pingLvl))
DrawRect(m_cpuping.posX + widgetPosX + 12, posY+1, m_cpuping.posX + widgetPosX + 21, posY + 14)
else
gl_Color(pingCpuColors[pingLvl].r,pingCpuColors[pingLvl].g,pingCpuColors[pingLvl].b)
DrawRect(m_cpuping.posX + widgetPosX + 12, posY+1, m_cpuping.posX + widgetPosX + 24, posY + 15)
end
grayvalue = 0.7 + (cpu/135)
if cpuText ~= nil and cpuText then
if type(cpu) == "number" then
if cpu > 99 then
cpu = 99
end
if spec then
gl_Color(0,0,0,0.1+(grayvalue*0.4))
gl_Text(cpu, m_cpuping.posX + widgetPosX+11, posY + 4.3, 9, "r")
gl_Color(grayvalue,grayvalue,grayvalue,0.66*alpha*grayvalue)
gl_Text(cpu, m_cpuping.posX + widgetPosX+11, posY + 5.3, 9, "r")
else
gl_Color(0,0,0,0.12+(grayvalue*0.44))
gl_Text(cpu, m_cpuping.posX + widgetPosX+11, posY + 4.3, 9.5, "r")
gl_Color(grayvalue,grayvalue,grayvalue,0.8*alpha*grayvalue)
gl_Text(cpu, m_cpuping.posX + widgetPosX+11, posY + 5.3, 9.5, "r")
end
gl_Color(1,1,1)
end
else
if fps ~= nil then
if fps > 99 then
fps = 99
end
grayvalue = 0.95 - (fps/195)
if spec then
gl_Color(0,0,0,0.1+(grayvalue*0.4))
gl_Text(fps, m_cpuping.posX + widgetPosX+11, posY + 4.3, 9, "r")
gl_Color(grayvalue,grayvalue,grayvalue,0.77*alpha*grayvalue)
gl_Text(fps, m_cpuping.posX + widgetPosX+11, posY + 5.3, 9, "r")
else
gl_Color(0,0,0,0.12+(grayvalue*0.44))
gl_Text(fps, m_cpuping.posX + widgetPosX+11, posY + 4.3, 9.5, "r")
gl_Color(grayvalue,grayvalue,grayvalue,alpha*grayvalue)
gl_Text(fps, m_cpuping.posX + widgetPosX+11, posY + 5.3, 9.5, "r")
end
gl_Color(1,1,1)
else
gl_Texture(pics["cpuPic"])
if spec then
gl_Color(grayvalue,grayvalue,grayvalue,0.1+(0.14*cpuLvl))
DrawRect(m_cpuping.posX + widgetPosX + 2 , posY+1, m_cpuping.posX + widgetPosX + 13, posY + 14)
else
gl_Color(pingCpuColors[cpuLvl].r,pingCpuColors[cpuLvl].g,pingCpuColors[cpuLvl].b)
DrawRect(m_cpuping.posX + widgetPosX + 1, posY+1, m_cpuping.posX + widgetPosX + 14, posY + 15)
end
end
end
end
function DrawPoint(posY,pointtime)
if right == true then
gl_Color(1,0,0,pointtime/pointDuration)
gl_Texture(pics["arrowPic"])
DrawRect(widgetPosX - 18, posY, widgetPosX - 2, posY+ 14)
gl_Color(1,1,1,pointtime/pointDuration)
gl_Texture(pics["pointPic"])
DrawRect(widgetPosX - 33, posY-1, widgetPosX - 17, posY + 15)
else
leftPosX = widgetPosX + widgetWidth
gl_Color(1,0,0,pointtime/pointDuration)
gl_Texture(pics["arrowPic"])
DrawRect(leftPosX + 18, posY, leftPosX + 2, posY + 14)
gl_Color(1,1,1,pointtime/pointDuration)
gl_Texture(pics["pointPic"])
DrawRect(leftPosX + 33, posY-1, leftPosX + 17, posY + 15)
end
gl_Color(1,1,1,1)
end
function TakeTip(mouseX)
if right == true then
if mouseX >= widgetPosX - 57 * widgetScale and mouseX <= widgetPosX - 1 * widgetScale then
tipText = "Click to take abandoned units"
end
else
local leftPosX = widgetPosX + widgetWidth
if mouseX >= leftPosX + 1 * widgetScale and mouseX <= leftPosX + 57 * widgetScale then
tipText = "Click to take abandoned units"
end
end
end
function ShareTip(mouseX, playerID)
if playerID == myPlayerID then
if mouseX >= widgetPosX + (m_share.posX + 1) * widgetScale and mouseX <= widgetPosX + (m_share.posX + 17) * widgetScale then
tipText = "Double click to ask for Unit support"
elseif mouseX >= widgetPosX + (m_share.posX + 19) * widgetScale and mouseX <= widgetPosX + (m_share.posX + 35) * widgetScale then
tipText = "Click and drag to ask for Energy"
elseif mouseX >= widgetPosX + (m_share.posX + 37) * widgetScale and mouseX <= widgetPosX + (m_share.posX + 53) * widgetScale then
tipText = "Click and drag to ask for Metal"
end
else
if mouseX >= widgetPosX + (m_share.posX + 1) * widgetScale and mouseX <= widgetPosX + (m_share.posX + 17) * widgetScale then
tipText = "Double click to share Units"
elseif mouseX >= widgetPosX + (m_share.posX + 19) * widgetScale and mouseX <= widgetPosX + (m_share.posX + 35) * widgetScale then
tipText = "Click and drag to share Energy"
elseif mouseX >= widgetPosX + (m_share.posX + 37) * widgetScale and mouseX <= widgetPosX + (m_share.posX + 53) * widgetScale then
tipText = "Click and drag to share Metal"
end
end
end
function AllyTip(mouseX, playerID)
if mouseX >= widgetPosX + (m_alliance.posX + 1) * widgetScale and mouseX <= widgetPosX + (m_alliance.posX + 11) * widgetScale then
if Spring_AreTeamsAllied(player[playerID].team, myTeamID) then
tipText = "Click to become enemy"
else
tipText = "Click to become ally"
end
end
end
function ResourcesTip(mouseX, e, es, ei, m, ms, mi)
if mouseX >= widgetPosX + (m_resources.posX + 1) * widgetScale and mouseX <= widgetPosX + (m_resources.posX + m_resources.width) * widgetScale then
if e > 1000 then
e = math.floor(e / 100) * 100
else
e = math.floor(e / 10) * 10
end
if m > 1000 then
m = math.floor(m / 100) * 100
else
m = math.floor(m / 10) * 10
end
if ei == nil then
ei = 0
mi = 0
end
ei = math.floor(ei)
mi = math.floor(mi)
if ei > 1000 then
ei = math.floor(ei / 100) * 100
elseif ei > 100 then
ei = math.floor(ei / 10) * 10
end
if mi > 200 then
mi = math.floor(mi / 10) * 10
end
if e >= 10000 then e = math.floor(e/1000).."k" end
if m >= 10000 then e = math.floor(m/1000).."k" end
if ei >= 10000 then ei = math.floor(ei/1000).."k" end
if mi >= 10000 then ei = math.floor(mi/1000).."k" end
tipText = "\255\255\255\000+"..ei.."\n\255\255\255\000"..e.."\n\255\255\255\255"..m.."\n\255\255\255\255+"..mi
end
end
function PingCpuTip(mouseX, pingLvl, cpuLvl, fps, gpumem, system, name)
if mouseX >= widgetPosX + (m_cpuping.posX + 13) * widgetScale and mouseX <= widgetPosX + (m_cpuping.posX + 23) * widgetScale then
if pingLvl < 2000 then
pingLvl = pingLvl.." ms"
elseif pingLvl >= 2000 and pingLvl < 60000 then
pingLvl = round(pingLvl/1000,0).." sec"
elseif pingLvl >= 60000 then
pingLvl = round(pingLvl/60000,0).." min"
end
tipText = "Ping: "..pingLvl
elseif mouseX >= widgetPosX + (m_cpuping.posX + 1) * widgetScale and mouseX <= widgetPosX + (m_cpuping.posX + 11) * widgetScale then
tipText = "Cpu: "..cpuLvl.."%"
if fps ~= nil then
tipText = "FPS: "..fps.." "..tipText
end
if gpumem ~= nil then
tipText = tipText.." Gpu mem: "..gpumem.."%"
end
if system ~= nil then
tipText = "\255\000\000\000"..name.."\n\255\233\180\180"..tipText.."\n\255\240\240\240"..system
end
end
end
function PointTip(mouseX)
if right == true then
if mouseX >= widgetPosX - 28 * widgetScale and mouseX <= widgetPosX - 1 * widgetScale then
tipText = "Click to reach the last point set by the player"
end
else
local leftPosX = widgetPosX + widgetWidth
if mouseX >= leftPosX + 1 * widgetScale and mouseX <= leftPosX + 28 * widgetScale then
tipText = "Click to reach the last point set by the player"
end
end
end
function stringToLines(str)
local t = {}
local function helper(line) table.insert(t, line) return "" end
helper((str:gsub("(.-)\r?\n", helper)))
return t
end
function DrawTip(mouseX, mouseY)
local scaleDiffX = -((widgetPosX*widgetScale)-widgetPosX)/widgetScale
local scaleDiffY = -((widgetPosY*widgetScale)-widgetPosY)/widgetScale
local scaleReset = widgetScale / widgetScale / widgetScale
gl.Translate(-scaleDiffX,-scaleDiffY,0)
gl.Scale(scaleReset,scaleReset,0)
text = tipText --this is needed because we're inside a gllist
if text ~= nil then
local fontSize = 14*widgetScale
local tw = fontSize*gl_GetTextWidth(text) + (20*widgetScale)
local _, lines = string.gsub(text, "\n", "")
lines = lines + 1
local lineHeight = fontSize + (fontSize/4.5)
local th = lineHeight * lines + (fontSize*0.75)
local oldWidgetScale = widgetScale
widgetScale = 1
local bottomY = mouseY-(th-(26*oldWidgetScale))
local ycorrection = 0
if bottomY < 0 then ycorrection = (15*widgetScale)-bottomY end
local padding = -1.8*oldWidgetScale
local xoffset = -15*oldWidgetScale
if right then
gl_Color(0.8,0.8,0.8,0.75)
RectRound(mouseX-tw+padding+xoffset, bottomY+ycorrection+padding, mouseX+xoffset-padding, (mouseY+(26*oldWidgetScale)+ycorrection)-padding, 4.5*oldWidgetScale)
padding = 0*oldWidgetScale
gl_Color(0,0,0,0.28)
RectRound(mouseX-tw+padding+xoffset, bottomY+ycorrection+padding, mouseX+xoffset-padding, (mouseY+(26*oldWidgetScale)+ycorrection)-padding, 3.5*oldWidgetScale)
else
xoffset = 22*oldWidgetScale
gl_Color(0.8,0.8,0.8,0.75)
RectRound(mouseX+padding+xoffset, bottomY+ycorrection+padding, mouseX+tw+xoffset-padding, (mouseY+(26*oldWidgetScale)+ycorrection)-padding, 4.5*oldWidgetScale)
padding = 0*oldWidgetScale
gl_Color(0,0,0,0.28)
RectRound(mouseX+padding+xoffset, bottomY+ycorrection+padding, mouseX+tw+xoffset+padding, (mouseY+(26*oldWidgetScale)+ycorrection)-padding, 3.5*oldWidgetScale)
end
widgetScale = oldWidgetScale
-- draw text
local textLines = stringToLines(text)
th = 0
gl.BeginText()
for i, line in ipairs(textLines) do
if right then
gl_Text('\255\244\244\244'..line, mouseX+xoffset+(8*widgetScale)-tw, mouseY+(8*widgetScale)+ycorrection+th, fontSize, "o")
else
gl_Text('\255\244\244\244'..line, mouseX+xoffset+(8*widgetScale), mouseY+(8*widgetScale)+ycorrection+th, fontSize, "o")
end
th = th - lineHeight
end
gl.EndText()
end
tipText = nil
gl.Color(1,1,1,1)
gl.Scale(widgetScale,widgetScale,0)
gl.Translate(scaleDiffX,scaleDiffY,0)
end
---------------------------------------------------------------------------------------------------
-- Share slider gllist
---------------------------------------------------------------------------------------------------
function CreateShareSlider()
if ShareSlider then
gl_DeleteList(ShareSlider)
end
ShareSlider = gl_CreateList(function()
local posY
if energyPlayer ~= nil then
posY = widgetPosY + widgetHeight - energyPlayer.posY
gl_Texture(pics["barPic"])
DrawRect(m_share.posX + widgetPosX + 16,posY-3,m_share.posX + widgetPosX + 34,posY+58)
gl_Texture(pics["energyPic"])
DrawRect(m_share.posX + widgetPosX + 17,posY+sliderPosition,m_share.posX + widgetPosX + 33,posY+16+sliderPosition)
gl_Texture(pics["amountPic"])
if right == true then
DrawRect(m_share.posX + widgetPosX - 28,posY-1+sliderPosition, m_share.posX + widgetPosX + 19,posY+17+sliderPosition)
gl_Texture(false)
gl_Text(amountEM.."", m_share.posX + widgetPosX - 5,posY+3+sliderPosition)
else
DrawRect(m_share.posX + widgetPosX + 76,posY-1+sliderPosition, m_share.posX + widgetPosX + 31,posY+17+sliderPosition)
gl_Texture(false)
gl_Text(amountEM.."", m_share.posX + widgetPosX + 55,posY+3+sliderPosition)
end
elseif metalPlayer ~= nil then
posY = widgetPosY + widgetHeight - metalPlayer.posY
gl_Texture(pics["barPic"])
DrawRect(m_share.posX + widgetPosX + 32,posY-3,m_share.posX + widgetPosX + 50,posY+58)
gl_Texture(pics["metalPic"])
DrawRect(m_share.posX + widgetPosX + 33, posY+sliderPosition,m_share.posX + widgetPosX + 49,posY+16+sliderPosition)
gl_Texture(pics["amountPic"])
if right == true then
DrawRect(m_share.posX + widgetPosX - 12,posY-1+sliderPosition, m_share.posX + widgetPosX + 35,posY+17+sliderPosition)
gl_Texture(false)
gl_Text(amountEM.."", m_share.posX + widgetPosX + 11,posY+3+sliderPosition)
else
DrawRect(m_share.posX + widgetPosX + 88,posY-1+sliderPosition, m_share.posX + widgetPosX + 47,posY+17+sliderPosition)
gl_Texture(false)
gl_Text(amountEM.."", m_share.posX + widgetPosX + 71,posY+3+sliderPosition)
end
end
end)
end
function GetCpuLvl(cpuUsage)
-- set the 5 cpu usage levels (green to red)
if cpuUsage < 0.15 then return 1
elseif cpuUsage < 0.3 then return 2
elseif cpuUsage < 0.45 then return 3
elseif cpuUsage < 0.65 then return 4
else return 5
end
end
function GetPingLvl(ping)
-- set the 5 ping levels (green to red)
if ping < 0.15 then return 1
elseif ping < 0.3 then return 2
elseif ping < 0.7 then return 3
elseif ping < 1.5 then return 4
else return 5
end
end
---------------------------------------------------------------------------------------------------
-- Mouse
---------------------------------------------------------------------------------------------------
local prevClickedName
local clickedName
function widget:MousePress(x,y,button) --super ugly code here
local t = false -- true if the object is a team leader
local clickedPlayer
local posY
local clickTime = os.clock()
if button == 1 then
local alt,ctrl,meta,shift = Spring.GetModKeyState()
sliderPosition = 0
amountEM = 0
-- spectators label onclick
posY = widgetPosY + widgetHeight - specsLabelOffset
if numberOfSpecs > 0 and IsOnRect(x, y, widgetPosX + 2, posY+2, widgetPosX + widgetWidth - 2, posY+20) then
specListShow = not specListShow
SetModulesPositionX() --why?
SortList()
CreateLists()
return true
end
for _,i in ipairs(drawList) do -- i = object #
if i > -1 then
clickedPlayer = player[i]
clickedPlayer.id = i
clickedName = clickedPlayer.name
posY = widgetPosY + widgetHeight - clickedPlayer.posY
end
if mySpecStatus == true then
if i == -1 then
t = true
else
t = false
if m_point.active then
if i > -1 and i < 64 then
if clickedPlayer.pointTime ~= nil then
if right == true then
if IsOnRect(x,y, widgetPosX - 33, posY - 2,widgetPosX - 17, posY + 16) then --point button
Spring.SetCameraTarget(clickedPlayer.pointX,clickedPlayer.pointY,clickedPlayer.pointZ,1) -- --
return true --
end --
else --
if IsOnRect(x,y, widgetPosX + widgetWidth + 17, posY-2,widgetPosX + widgetWidth + 33, posY + 16) then --
Spring.SetCameraTarget(clickedPlayer.pointX,clickedPlayer.pointY,clickedPlayer.pointZ,1) --
return true
end
end
end
end
end
end
if i>-1 and i<64 then
if m_name.active and clickedPlayer.name ~= absentName and IsOnRect(x, y, m_name.posX + widgetPosX +1, posY, m_name.posX + widgetPosX + m_name.width, posY+16) then
if ctrl then
Spring_SendCommands{"toggleignore "..clickedPlayer.name}
return true
end
if (mySpecStatus or player[i].allyteam == myAllyTeamID) and clickTime - prevClickTime < dblclickPeriod and clickedName == prevClickedName then
LockCamera(i)
prevClickedName = ''
if not clickedPlayer.spec then
Spring_SendCommands{"specteam "..i}
end
SortList()
CreateLists()
return true
end
prevClickedName = clickedName
end
end
else
if t == true then
if clickedPlayer.allyteam == myAllyTeamID then
if m_take.active == true then
if clickedPlayer.totake == true then
if right == true then
if IsOnRect(x,y, widgetPosX - 57, posY ,widgetPosX - 12, posY + 17) then --take button
Take(clickedPlayer.team, clickedPlayer.name, i) --
return true --
end --
else --
if IsOnRect(x,y, widgetPosX + widgetWidth + 12, posY ,widgetPosX + widgetWidth + 57, posY + 17) then --
Take(clickedPlayer.team, clickedPlayer.name, i) --
return true
end
end
end
end
if m_share.active == true and clickedPlayer.dead ~= true then
if IsOnRect(x, y, m_share.posX + widgetPosX +1, posY, m_share.posX + widgetPosX +17,posY+16) then -- share units button
if release ~= nil then --
if release >= now then --
if clickedPlayer.team == myTeamID then --
Spring_SendCommands("say a: I need unit support!") -- (ask)
else --
local suc = Spring.GetSelectedUnitsCount()
Spring_SendCommands("say a: I gave "..suc.." units to "..clickedPlayer.name..".")
local su = Spring.GetSelectedUnits()
for _,uid in ipairs(su) do
local ux,uy,uz = Spring.GetUnitPosition(uid)
Spring.MarkerAddPoint(ux,uy,uz)
end
Spring_ShareResources(clickedPlayer.team, "units") --
end
end
release = nil
else
firstclick = now+1
end
return true
end
if IsOnRect(x, y, m_share.posX + widgetPosX +17, posY, m_share.posX + widgetPosX +33,posY+16) then -- share energy button (initiates the slider)
energyPlayer = clickedPlayer
return true
end
if IsOnRect(x, y, m_share.posX + widgetPosX +33, posY, m_share.posX + widgetPosX +49,posY+16) then -- share metal button (initiates the slider)
metalPlayer = clickedPlayer
return true
end
end
end
end
if i == -1 then
t = true
else
t = false
if i > -1 and i < 64 then
--chat button
if m_chat.active == true then
if IsOnRect(x, y, m_chat.posX + widgetPosX +1, posY, m_chat.posX + widgetPosX +17,posY+16) then
Spring_SendCommands("chatall","pastetext /w "..clickedPlayer.name..' \1')
return true
end
end
--ally button
if m_alliance.active == true and drawAllyButton and not mySpecStatus and player[i] ~= nil and player[i].dead ~= true and i ~= myPlayerID then
if IsOnRect(x, y, m_alliance.posX + widgetPosX +1, posY, m_alliance.posX + widgetPosX + m_alliance.width,posY+16) then
if Spring_AreTeamsAllied(player[i].team, myTeamID) then
Spring_SendCommands("ally "..player[i].allyteam.." 0")
else
Spring_SendCommands("ally "..player[i].allyteam.." 1")
end
return true
end
end
--point
if m_point.active then
if clickedPlayer.pointTime ~= nil then
if clickedPlayer.allyteam == myAllyTeamID then
if right == true then
if IsOnRect(x,y, widgetPosX - 28, posY - 1,widgetPosX - 12, posY + 17) then
Spring.SetCameraTarget(clickedPlayer.pointX,clickedPlayer.pointY,clickedPlayer.pointZ,1)
return true
end
else
if IsOnRect(x,y, widgetPosX + widgetWidth + 12, posY-1,widgetPosX + widgetWidth + 28, posY + 17) then
Spring.SetCameraTarget(clickedPlayer.pointX,clickedPlayer.pointY,clickedPlayer.pointZ,1)
return true
end
end
end
end
end
--name
if m_name.active and clickedPlayer.name ~= absentName and IsOnRect(x, y, m_name.posX + widgetPosX +1, posY, m_name.posX + widgetPosX + m_name.width, posY+12) then
if ctrl then
Spring_SendCommands{"toggleignore "..clickedPlayer.name}
return true
end
if (mySpecStatus or player[i].allyteam == myAllyTeamID) and clickTime - prevClickTime < dblclickPeriod and clickedName == prevClickedName then
LockCamera(clickedPlayer.team)
prevClickedName = ''
if not clickedPlayer.spec then
Spring_SendCommands{"specteam "..clickedPlayer.team}
end
SortList()
CreateLists()
return true
end
prevClickedName = clickedName
end
end
end
end
end
end
prevClickTime = clickTime
end
local mouseX, mouseY = 0,0
function widget:MouseMove(x,y,dx,dy,button)
mouseX, mouseY = x, y
local moveStartX, moveStartY
if energyPlayer ~= nil or metalPlayer ~= nil then -- move energy/metal share slider
if sliderOrigin == nil then
sliderOrigin = y
end
sliderPosition = (y-sliderOrigin) * (1/widgetScale)
if sliderPosition < 0 then sliderPosition = 0 end
if sliderPosition > 39 then sliderPosition = 39 end
local prevAmountEM = amountEM
UpdateResources()
if playSounds and (lastSliderSound == nil or os.clock() - lastSliderSound > 0.05) and amountEM ~= prevAmountEM then
lastSliderSound = os.clock()
Spring.PlaySoundFile(sliderdrag, 0.3, 'ui')
end
end
end
function widget:MouseRelease(x,y,button)
if button == 1 then
if firstclick ~= nil then -- double click system for share units
release = firstclick
firstclick = nil
else
release = nil
end
if energyPlayer ~= nil then -- share energy/metal mouse release
if energyPlayer.team == myTeamID then
if amountEM == 0 then
Spring_SendCommands("say a: I need Energy!")
else
Spring_SendCommands("say a: I need "..amountEM.." Energy!")
end
elseif amountEM > 0 then
Spring_ShareResources(energyPlayer.team, "energy", amountEM)
Spring_SendCommands("say a: I sent "..amountEM.." energy to "..energyPlayer.name)
end
sliderOrigin = nil
amountEMMax = nil
sliderPosition = nil
amountEM = nil
energyPlayer = nil
end
if metalPlayer ~= nil then
if metalPlayer.team == myTeamID then
if amountEM == 0 then
Spring_SendCommands("say a: I need Metal!")
else
Spring_SendCommands("say a: I need "..amountEM.." Metal!")
end
elseif amountEM > 0 then
Spring_ShareResources(metalPlayer.team, "metal", amountEM)
Spring_SendCommands("say a: I sent "..amountEM.." metal to "..metalPlayer.name)
end
sliderOrigin = nil
amountEMMax = nil
sliderPosition = nil
amountEM = nil
metalPlayer = nil
end
end
end
function Spec(teamID)
Spring_SendCommands{"specteam "..teamID}
specTarget = teamID
SortList()
end
---------------------------------------------------------------------------------------------------
-- Tweak mode
---------------------------------------------------------------------------------------------------
function IsOnRect(x, y, BLcornerX, BLcornerY,TRcornerX,TRcornerY)
-- calc scale offset
BLcornerX = BLcornerX - ((widgetPosX - BLcornerX) * (widgetScale-1))
BLcornerY = BLcornerY - ((widgetPosY - BLcornerY) * (widgetScale-1))
TRcornerX = TRcornerX - ((widgetPosX - TRcornerX) * (widgetScale-1))
TRcornerY = TRcornerY - ((widgetPosY - TRcornerY) * (widgetScale-1))
-- check if the mouse is in a rectangle
return x >= BLcornerX and x <= TRcornerX
and y >= BLcornerY
and y <= TRcornerY
end
local function DrawGreyRect()
gl_Color(0.2,0.2,0.2,0.25)
gl_Rect(widgetPosX, widgetPosY, widgetPosX + widgetWidth, widgetPosY + widgetHeight)
gl_Color(1,1,1,1)
end
local function DrawTweakButton(module, localLeft, localOffset, localBottom)
gl_Texture(module.pic)
DrawRect(localLeft + localOffset, localBottom + 11, localLeft + localOffset + 16, localBottom + 27)
if module.active ~= true and module.alwaysActive == nil then
gl_Texture(pics["crossPic"])
DrawRect(localLeft + localOffset, localBottom + 11, localLeft + localOffset + 16, localBottom + 27)
end
end
local function DrawTweakButtons()
local minSize = (modulesCount-1) * 16 + 2
local localLeft = widgetPosX
local localBottom = widgetPosY + widgetHeight - 28
local localOffset = 1 --see func above, these track how far right we've got TODO: pass values
gl_Color(0,0,0,0.5)
RectRound(localLeft-3, localBottom + 8, localLeft + widgetWidth+3, localBottom + 30, 5, true)
gl_Color(1,1,1,1)
--if localLeft + minSize > vsx then localLeft = vsx - minSize end
if localBottom < 0 then localBottom = 0 end
for n,module in pairs(modules) do
if module.noPic == nil or module.noPic == false then
if mySpecStatus == false or mySpecStatus == true and module.spec then
DrawTweakButton(module, localLeft, localOffset, localBottom)
localOffset = localOffset + 16
end
end
if module.picGap ~= nil then
if mySpecStatus == false or mySpecStatus == true and module.spec then
localOffset = localOffset + module.picGap
end
end
end
end
local function DrawArrows()
gl_Color(1,1,1,0.4)
gl_Texture(pics["arrowdPic"])
if expandDown == true then
DrawRect(widgetPosX, widgetPosY - 15, widgetRight, widgetPosY - 1)
else
DrawRect(widgetPosX, widgetTop + 15, widgetRight, widgetTop + 1)
end
gl_Texture(pics["arrowPic"])
if expandLeft == true then
DrawRect(widgetPosX - 1, widgetPosY, widgetPosX - 15, widgetTop)
else
DrawRect(widgetRight + 1, widgetPosY, widgetRight + 15, widgetTop)
end
gl_Color(1,1,1,1)
gl_Texture(false)
end
function widget:TweakDrawScreen()
local scaleDiffX = -((widgetPosX*widgetScale)-widgetPosX)/widgetScale
local scaleDiffY = -((widgetPosY*widgetScale)-widgetPosY)/widgetScale
gl.Scale(widgetScale,widgetScale,0)
gl.Translate(scaleDiffX,scaleDiffY,0)
--DrawGreyRect()
DrawTweakButtons()
--DrawArrows()
CreateMainList()
CreateBackground()
local scaleReset = widgetScale / widgetScale / widgetScale
gl.Translate(-scaleDiffX,-scaleDiffY,0)
gl.Scale(scaleReset,scaleReset,0)
end
function checkButton(module, x, y, localLeft, localOffset, localBottom)
if IsOnRect(x, y, localLeft + localOffset, localBottom + 11, localLeft + localOffset + 16, localBottom + 27) then
if module.alwaysActive == nil then
module.active = not module.active
SetModulesPositionX() --why?
SortList()
-- adjust because of widget scaling
local widthDiff = (module.width * widgetScale) - module.width
if module.active then
widgetRight = widgetRight - widthDiff
else
widgetRight = widgetRight + widthDiff
end
else
if module.name == "sizedn" then
customScaleDown()
elseif module.name == "sizeup" then
customScaleUp()
end
end
CreateLists()
return true
else
return false
end
end
function widget:TweakMousePress(x,y,button)
if button == 1 then
local localLeft = widgetPosX
local localBottom = widgetPosY + widgetHeight - 28
local localOffset = 1
if localBottom < 0 then localBottom = 0 end
--if localLeft + 181 > vsx then localLeft = vsx - 181 end
for _,module in pairs(modules) do
if module.noPic == nil or module.noPic == false then
if mySpecStatus == false or mySpecStatus == true and module.spec then
if checkButton(module,x,y,localLeft,localOffset,localBottom) then return true end
localOffset = localOffset + 16
end
end
if module.picGap ~= nil then
if mySpecStatus == false or mySpecStatus == true and module.spec then
localOffset = localOffset + module.picGap
end
end
end
elseif button == 2 or button == 3 then
if IsOnRect(x, y, widgetPosX, widgetPosY, widgetPosX + widgetWidth, widgetPosY + widgetHeight) then
clickToMove = true
return true
end
end
end
function widget:TweakMouseMove(x,y,dx,dy,button)
if clickToMove ~= nil then
if moveStartX == nil then -- move widget on y axis
moveStartX = x - widgetPosX
end
if moveStartY == nil then -- move widget on y axis
moveStartY = y - widgetPosY
end
widgetPosX = widgetPosX + dx
widgetPosY = widgetPosY + dy
if widgetPosY <= (backgroundMargin*widgetScale) then
widgetPosY = (backgroundMargin*widgetScale)
expandDown = false --expandDown=false only if we are right on the bottom of the screen
end
if widgetPosY + (widgetHeight * widgetScale) >= vsy -(backgroundMargin*widgetScale) then
widgetPosY = vsy - (widgetHeight * widgetScale) -(backgroundMargin*widgetScale)
expandDown = true
end
if widgetPosX <= (backgroundMargin*widgetScale) then --expandLeft=false only when we are precisely on the left edge of the screen
widgetPosX = (backgroundMargin*widgetScale)
expandLeft = false
end
if widgetPosX + (widgetWidth * widgetScale) >= vsx-(backgroundMargin*widgetScale) then
widgetPosX = vsx - (widgetWidth * widgetScale) - (backgroundMargin*widgetScale)
expandLeft = true
end
widgetTop = widgetPosY + widgetHeight
widgetRight = widgetPosX + widgetWidth
widgetRelRight = vsx - (widgetPosX + (widgetWidth*widgetScale))
if widgetPosX + widgetWidth/2 > vsx/2 then
right = true
else
right = false
end
end
end
function widget:TweakMouseRelease(x,y,button)
clickToMove = nil -- ends the share slider process
end
---------------------------------------------------------------------------------------------------
-- Save/load
---------------------------------------------------------------------------------------------------
function widget:GetConfigData(data) -- save
if m_side ~= nil then
--put module.active into a table
local m_active_Table = {}
for n,module in pairs(modules) do
m_active_Table[module.name] = module.active
end
local settings = {
--view
customScale = customScale,
vsx = vsx,
vsy = vsy,
widgetRelRight = widgetRelRight,
widgetPosX = widgetPosX,
widgetPosY = widgetPosY,
widgetRight = widgetRight,
widgetTop = widgetTop,
expandDown = expandDown,
expandLeft = expandLeft,
specListShow = specListShow,
m_pointActive = m_point.active,
m_takeActive = m_take.active,
m_seespecActive = m_seespec.active,
m_active_Table = m_active_Table,
cpuText = cpuText,
lockPlayerID = lockPlayerID,
specListShow = specListShow,
gameFrame = Spring.GetGameFrame(),
lastSystemData = lastSystemData,
alwaysHideSpecs = alwaysHideSpecs,
--lockcameraHideEnemies = lockcameraHideEnemies,
--lockcameraLos = lockcameraLos,
}
return settings
end
end
function widget:SetConfigData(data) -- load
if data.customScale ~= nil then
customScale = data.customScale
end
if data.specListShow ~= nil then
specListShow = data.specListShow
end
if data.alwaysHideSpecs ~= nil then
alwaysHideSpecs = data.alwaysHideSpecs
end
if data.lockcameraHideEnemies ~= nil then
--lockcameraHideEnemies = data.lockcameraHideEnemies
end
if data.lockcameraLos ~= nil then
--lockcameraLos = data.lockcameraLos
end
--view
if data.expandDown ~= nil and data.widgetRight ~= nil then
expandDown = data.expandDown
expandLeft = data.expandLeft
specListShow = data.specListShow
local oldvsx = data.vsx
local oldvsy = data.vsy
if oldvsx == nil then
oldvsx = vsx
oldvsy = vsy
end
local dx = vsx - oldvsx
local dy = vsy - oldvsy
if expandDown == true then
widgetTop = data.widgetTop + dy
if widgetTop > vsy then
widgetTop = vsy
end
else
widgetPosY = data.widgetPosY
end
if expandLeft == true then
widgetRelRight = data.widgetRelRight or 0
widgetRight = vsx - (widgetWidth * (widgetScale-1)) - widgetRelRight --align right of widget to right of screen
widgetPosX = widgetRight - (widgetWidth*widgetScale)
if widgetRight > vsx then
widgetRight = vsx
end
else
widgetPosX = data.widgetPosX --align left of widget to left of screen
end
end
if data.lockPlayerID ~= nil and Spring.GetGameFrame()>0 then
lockPlayerID = data.lockPlayerID
if lockPlayerID and not select(3,Spring_GetPlayerInfo(lockPlayerID)) then
if not lockcameraHideEnemies then
if not fullView then
Spring.SendCommands("specfullview")
if lockcameraLos and mySpecStatus and Spring.GetMapDrawMode()=="los" then
Spring.SendCommands("togglelos")
end
end
else
if fullView then
Spring.SendCommands("specfullview")
if lockcameraLos and mySpecStatus and Spring.GetMapDrawMode()~="los" then
Spring.SendCommands("togglelos")
end
end
end
end
end
if data.cpuText ~= nil then
cpuText = data.cpuText
end
--not technically modules
m_point.active = true -- m_point.default doesnt work
if data.m_pointActive ~= nil then
m_point.active = data.m_pointActive
end
m_take.active = true -- m_take.default doesnt work
if data.m_takeActive ~= nil then
m_take.active = data.m_takeActive
end
m_seespec.active = true -- m_seespec.default doesnt work
if data.m_seespecActive ~= nil then
m_seespec.active = data.m_seespecActive
end
--load module.active from table
local m_active_Table = data.m_active_Table or {}
for name,active in pairs(m_active_Table) do
--find module with matching name
for _,module in pairs(modules) do
if module.name == name then
if name == "ally" then -- needs to be always active (some aready stored it as false before, this makes sure its corrected)
module.active = true
else
module.active = module.default
if active ~= nil then
module.active = active
end
end
end
end
end
SetModulesPositionX()
if data.lastSystemData ~= nil and data.gameFrame ~= nil and data.gameFrame <= Spring.GetGameFrame() and data.gameFrame > Spring.GetGameFrame()-300 then
lastSystemData = data.lastSystemData
end
end
function widget:TextCommand(command)
if (string.find(command, "cputext") == 1 and string.len(command) == 7) then
cpuText = not cpuText
end
if (string.find(command, "alwayshidespecs") == 1 and string.len(command) == 15) then
alwaysHideSpecs = not alwaysHideSpecs
if alwaysHideSpecs then
Spring.Echo("AdvPlayersList: always hiding specs")
specListShow = false
else
Spring.Echo("AdvPlayersList: not always hiding specs")
end
end
end
---------------------------------------------------------------------------------------------------
-- Player related changes
---------------------------------------------------------------------------------------------------
function CheckPlayersChange()
local sorting = false
for i = 0,63 do
local name,active,spec,teamID,allyTeamID,pingTime,cpuUsage, country, rank = Spring_GetPlayerInfo(i)
if active == false then
if player[i].name ~= nil then -- NON SPEC PLAYER LEAVING
if player[i].spec==false then
if table.maxn(Spring_GetPlayerList(player[i].team,true)) == 0 then
player[player[i].team + 64] = CreatePlayerFromTeam(player[i].team)
sorting = true
end
end
player[i].name = nil
player[i] = {}
sorting = true
end
elseif active == true and name ~= nil then
if spec ~= player[i].spec then -- PLAYER SWITCHING TO SPEC STATUS
if spec == true then
if table.maxn(Spring_GetPlayerList(player[i].team,true)) == 0 then -- (update the no players team)
player[player[i].team + 64] = CreatePlayerFromTeam(player[i].team)
end
player[i].team = nil -- remove team
end
player[i].spec = spec -- consider player as spec
sorting = true
end
if teamID ~= player[i].team then -- PLAYER CHANGING TEAM
if table.maxn(Spring_GetPlayerList(player[i].team,true)) == 0 then -- check if there is no more player in the team + update
player[player[i].team + 64] = CreatePlayerFromTeam(player[i].team)
end
player[i].team = teamID
player[i].red, player[i].green, player[i].blue = Spring_GetTeamColor(teamID)
player[i].dark = GetDark(player[i].red, player[i].green, player[i].blue)
player[i].skill = GetSkill(i)
sorting = true
end
if player[i].name == nil then
player[i] = CreatePlayer(i)
end
if allyTeamID ~= player[i].allyteam then
player[i].allyteam = allyTeamID
updateTake(allyTeamID)
sorting = true
end
-- Update stall / cpu / ping info for each player
if player[i].spec == false then
player[i].needm = GetNeed("metal",player[i].team)
player[i].neede = GetNeed("energy",player[i].team)
player[i].rank = rank
else
player[i].needm = false
player[i].neede = false
end
player[i].pingLvl = GetPingLvl(pingTime)
player[i].cpuLvl = GetCpuLvl(cpuUsage)
player[i].ping = pingTime*1000-((pingTime*1000)%1)
player[i].cpu = cpuUsage*100-((cpuUsage*100)%1)
end
if teamID and Spring_GetGameFrame() > 0 then
local totake = IsTakeable(teamID)
player[i].totake = totake
if totake then
sorting = true
else
player[i].name = name
end
end
end
if sorting == true then -- sorts the list again if change needs it
SortList()
SetModulesPositionX() -- change the X size if needed (change of widest name)
end
end
function GetNeed(resType,teamID)
local current, _, pull, income = Spring_GetTeamResources(teamID, resType)
if current == nil then return false end
local loss = pull - income
if loss > 0 then
if loss*5 > current then
return true
end
end
return false
end
local reportTake = false
local tookTeamID
local tookTeamName
local tookFrame = -120
function updateTake(allyTeamID)
for i = 0,teamN-1 do
if player[i + 64].allyTeam == allyTeamID then
player[i + 64] = CreatePlayerFromTeam(i)
end
end
end
function Take(teamID,name, i)
-- sends the /take command to spring
reportTake = true
tookTeamID = teamID
tookTeamName = name
tookFrame = Spring.GetGameFrame()
Spring_SendCommands("luarules take2 " .. teamID)
return
end
function widget:TeamDied(teamID)
player[teamID+64] = CreatePlayerFromTeam(teamID)
SortList()
end
---------------------------------------------------------------------------------------------------
-- Take related stuff
---------------------------------------------------------------------------------------------------
function IsTakeable(teamID)
if Spring_GetTeamRulesParam(teamID, "numActivePlayers") == 0 then
local units = Spring_GetTeamUnitCount(teamID)
local energy = Spring_GetTeamResources(teamID,"energy")
local metal = Spring_GetTeamResources(teamID,"metal")
if units and energy and metal then
if (units > 0) or (energy > 1000) or (metal > 100) then
return true
end
end
else
return false
end
end
--timers
local timeCounter = 0
local updateRate = 0.75
local updateRatePreStart = 0.25
local lastTakeMsg = -120
function widget:Update(delta) --handles takes & related messages
totalTime = totalTime + delta
timeCounter = timeCounter + delta
curFrame = Spring_GetGameFrame()
mySpecStatus,fullView,_ = Spring.GetSpectatingState()
if sceduledSpecFullView ~= nil then -- this is needed else the minimap/world doesnt update properly
Spring.SendCommands("specfullview")
sceduledSpecFullView = sceduledSpecFullView - 1
if sceduledSpecFullView == 0 then
sceduledSpecFullView = nil
end
end
if lockPlayerID ~= nil then
Spring.SetCameraState(Spring.GetCameraState(), transitionTime)
end
if energyPlayer ~= nil or metalPlayer ~= nil then
CreateShareSlider()
end
if curFrame >= 30 + tookFrame then
if lastTakeMsg + 120 < tookFrame and reportTake then
local teamID = tookTeamID
local afterE = Spring_GetTeamResources(teamID,"energy")
local afterM = Spring_GetTeamResources(teamID, "metal")
local afterU = Spring_GetTeamUnitCount(teamID)
local toSay = "say a: I took " .. tookTeamName .. ". "
if afterE and afterM and afterU then
if afterE > 1.0 or afterM > 1.0 or afterU > 0 then
toSay = toSay .. "Left " .. math.floor(afterU) .. " units, " .. math.floor(afterE) .. " energy and " .. math.floor(afterM) .. " metal."
end
end
Spring_SendCommands(toSay)
for j = 0,127 do
if player[j].allyteam == myAllyTeamID then
if player[j].totake == true then
player[j] = CreatePlayerFromTeam(player[j].team)
SortList()
end
end
end
lastTakeMsg = tookFrame
reportTake = false
else
reportTake = false
end
end
-- update lists to take account of allyteam faction changes before gamestart
if not curFrame or curFrame <=0 then
if timeCounter < updateRatePreStart then
return
else
timeCounter = 0
SetSidePics() --if the game hasn't started, update factions
CreateLists()
end
end
-- update lists every now and then, just to make sure
if timeCounter < updateRate then
return
else
timeCounter = 0
CreateLists()
end
end
---------------------------------------------------------------------------------------------------
-- Other callins
---------------------------------------------------------------------------------------------------
function updateWidgetScale()
if customScale < 0.6 then
customScale = 0.6
end
widgetScale = (0.7 + (vsx*vsy / 5000000)) * customScale
end
function customScaleUp()
widgetPosX = widgetPosX - (widgetWidth*customScaleStep)
widgetRight = widgetPosX + widgetWidth
customScale = customScale + customScaleStep
updateWidgetScale()
end
function customScaleDown()
widgetPosX = widgetPosX + (widgetWidth*customScaleStep)
widgetRight = widgetPosX + widgetWidth
customScale = customScale - customScaleStep
updateWidgetScale()
end
function widget:ViewResize(viewSizeX, viewSizeY)
local dx, dy = vsx - viewSizeX, vsy - viewSizeY
vsx, vsy = viewSizeX, viewSizeY
updateWidgetScale()
if expandDown == true then
widgetTop = widgetTop - dy
widgetPosY = widgetTop - widgetHeight
end
if expandLeft == true then
widgetRight = widgetRight - dx
widgetPosX = vsx - (widgetWidth * widgetScale) - widgetRelRight
end
end
function widget:MapDrawCmd(playerID, cmdType, px, py, pz) -- get the points drawn (to display point indicator)
if m_point.active then
if cmdType == "point" then
player[playerID].pointX = px
player[playerID].pointY = py
player[playerID].pointZ = pz
player[playerID].pointTime = now + pointDuration
end
end
local osClock = os.clock()
if cmdType == 'line' then
--mapDrawNicknameTime[playerID] = osClock
--AddCommandSpotter('map_draw', x, y, z, osClock, false, playerID)
end
end
|
return {'baxter','bax','baxters'}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.