repo_name stringlengths 6 69 | path stringlengths 6 178 | copies stringclasses 278
values | size stringlengths 4 7 | content stringlengths 671 917k | license stringclasses 15
values |
|---|---|---|---|---|---|
LuaDist2/dromozoa-tree | dromozoa/tree/model.lua | 3 | 3896 | -- Copyright (C) 2015 Tomoyuki Fujimori <moyu@dromozoa.com>
--
-- This file is part of dromozoa-tree.
--
-- dromozoa-tree is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- dromozoa-tree 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.
--
-- You should have received a copy of the GNU General Public License
-- along with dromozoa-tree. If not, see <http://www.gnu.org/licenses/>.
local empty = require "dromozoa.commons.empty"
local pairs = require "dromozoa.commons.pairs"
local class = {}
function class.new()
return {
n = 0;
p = {};
c = {};
ns = {};
ps = {};
}
end
function class:create_node()
local uid = self.n + 1
self.n = uid
self.p[uid] = 0
self.c[uid] = 0
self.ns[uid] = uid
self.ps[uid] = uid
return uid
end
function class:delete_node(uid)
self.p[uid] = nil
self.c[uid] = nil
self.ns[uid] = nil
self.ps[uid] = nil
end
function class:empty()
return empty(self.p)
end
function class:each_node()
return pairs(self.p)
end
function class:count_node()
local count = 0
for _ in pairs(self.p) do
count = count + 1
end
return count
end
function class:parent_node(uid)
return self.p[uid]
end
function class:next_sibling_node(uid)
return self.ns[uid]
end
function class:prev_sibling_node(uid)
return self.ps[uid]
end
function class:append_child(uid, vid)
local p = self.p
local c = self.c
p[vid] = uid
local next_id = c[uid]
if next_id == 0 then
c[uid] = vid
else
local ns = self.ns
local ps = self.ps
local prev_id = ps[next_id]
ns[prev_id] = vid
ns[vid] = next_id
ps[vid] = prev_id
ps[next_id] = vid
end
end
function class:insert_sibling(next_id, vid)
local p = self.p
local c = self.c
local ns = self.ns
local ps = self.ps
local uid = p[next_id]
p[vid] = uid
if c[uid] == next_id then
c[uid] = vid
end
local prev_id = ps[next_id]
ns[prev_id] = vid
ns[vid] = next_id
ps[vid] = prev_id
ps[next_id] = vid
end
function class:remove_node(vid)
local p = self.p
local c = self.c
local ns = self.ns
local uid = p[vid]
p[vid] = 0
local next_id = ns[vid]
if next_id == vid then
c[uid] = 0
else
local ps = self.ps
if c[uid] == vid then
c[uid] = next_id
end
local prev_id = ps[vid]
ns[prev_id] = next_id
ps[next_id] = prev_id
end
end
function class:each_child(uid)
local vid = self.c[uid]
if vid == 0 then
return function () end
else
local ns = self.ns
local last_id = self.ps[vid]
return coroutine.wrap(function ()
while true do
local next_id = ns[vid]
coroutine.yield(vid)
if vid == last_id then
break
end
vid = next_id
end
end)
end
end
function class:count_children(uid)
local vid = self.c[uid]
if vid == 0 then
return 0
else
local ns = self.ns
local count = 0
local start_id = vid
repeat
count = count + 1
vid = ns[vid]
until vid == start_id
return count
end
end
function class:is_root(uid)
return self.p[uid] == 0
end
function class:is_leaf(uid)
return self.c[uid] == 0
end
function class:is_isolated(uid)
return self.p[uid] == 0 and self.c[uid] == 0
end
function class:is_first_child(uid)
return self.c[self.p[uid]] == uid
end
function class:is_last_child(uid)
return self.ps[self.c[self.p[uid]]] == uid
end
local metatable = {
__index = class;
}
return setmetatable(class, {
__call = function ()
return setmetatable(class.new(), metatable)
end;
})
| gpl-3.0 |
LeMagnesium/minetest-minetestforfun-server | mods/signs_lib/init.lua | 9 | 32729 | -- This mod provides the visible text on signs library used by Home Decor
-- and perhaps other mods at some point in the future. Forked from thexyz's/
-- PilzAdam's original text-on-signs mod and rewritten by Vanessa Ezekowitz
-- and Diego Martinez
-- textpos = {
-- { delta = {entity position for 0° yaw}, exact yaw expression }
-- { delta = {entity position for 180° yaw}, exact yaw expression }
-- { delta = {entity position for 270° yaw}, exact yaw expression }
-- { delta = {entity position for 90° yaw}, exact yaw expression }
-- }
-- CWz's keyword interact mod uses this setting.
local current_keyword = minetest.setting_get("interact_keyword") or "iaccept"
signs_lib = {}
screwdriver = screwdriver or {}
signs_lib.wallmounted_rotate = function(pos, node, user, mode, new_param2)
if mode ~= screwdriver.ROTATE_AXIS then return false end
minetest.swap_node(pos, {name = node.name, param2 = (node.param2 + 1) % 6})
for _, v in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
local e = v:get_luaentity()
if e and e.name == "signs:text" then
v:remove()
end
end
signs_lib.update_sign(pos)
return true
end
signs_lib.modpath = minetest.get_modpath("signs_lib")
signs_lib.regular_wall_sign_model = {
nodebox = {
type = "wallmounted",
wall_side = { -0.5, -0.25, -0.4375, -0.4375, 0.375, 0.4375 },
wall_bottom = { -0.4375, -0.5, -0.25, 0.4375, -0.4375, 0.375 },
wall_top = { -0.4375, 0.4375, -0.375, 0.4375, 0.5, 0.25 }
},
textpos = {
nil,
nil,
{delta = {x = 0.43, y = 0.07, z = 0 }, yaw = math.pi / -2},
{delta = {x = -0.43, y = 0.07, z = 0 }, yaw = math.pi / 2},
{delta = {x = 0, y = 0.07, z = 0.43 }, yaw = 0},
{delta = {x = 0, y = 0.07, z = -0.43 }, yaw = math.pi},
}
}
signs_lib.metal_wall_sign_model = {
nodebox = {
type = "fixed",
fixed = {-0.4375, -0.25, 0.4375, 0.4375, 0.375, 0.5}
},
textpos = {
{delta = {x = 0, y = 0.07, z = 0.43 }, yaw = 0},
{delta = {x = 0.43, y = 0.07, z = 0 }, yaw = math.pi / -2},
{delta = {x = 0, y = 0.07, z = -0.43 }, yaw = math.pi},
{delta = {x = -0.43, y = 0.07, z = 0 }, yaw = math.pi / 2},
}
}
signs_lib.yard_sign_model = {
nodebox = {
type = "fixed",
fixed = {
{-0.4375, -0.25, -0.0625, 0.4375, 0.375, 0},
{-0.0625, -0.5, -0.0625, 0.0625, -0.1875, 0},
}
},
textpos = {
{delta = {x = 0, y = 0.07, z = -0.068}, yaw = 0},
{delta = {x = -0.068, y = 0.07, z = 0 }, yaw = math.pi / -2},
{delta = {x = 0, y = 0.07, z = 0.068}, yaw = math.pi},
{delta = {x = 0.068, y = 0.07, z = 0 }, yaw = math.pi / 2},
}
}
signs_lib.hanging_sign_model = {
nodebox = {
type = "fixed",
fixed = {
{-0.4375, -0.3125, -0.0625, 0.4375, 0.3125, 0},
{-0.4375, 0.25, -0.03125, 0.4375, 0.5, -0.03125},
}
},
textpos = {
{delta = {x = 0, y = -0.02, z = -0.063}, yaw = 0},
{delta = {x = -0.063, y = -0.02, z = 0 }, yaw = math.pi / -2},
{delta = {x = 0, y = -0.02, z = 0.063}, yaw = math.pi},
{delta = {x = 0.063, y = -0.02, z = 0 }, yaw = math.pi / 2},
}
}
signs_lib.sign_post_model = {
nodebox = {
type = "fixed",
fixed = {
{-0.4375, -0.25, -0.1875, 0.4375, 0.375, -0.125},
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125},
}
},
textpos = {
{delta = {x = 0, y = 0.07, z = -0.188}, yaw = 0},
{delta = {x = -0.188, y = 0.07, z = 0 }, yaw = math.pi / -2},
{delta = {x = 0, y = 0.07, z = 0.188 }, yaw = math.pi},
{delta = {x = 0.188, y = 0.07, z = 0 }, yaw = math.pi / 2},
}
}
-- Boilerplate to support localized strings if intllib mod is installed.
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
signs_lib.gettext = S
-- the list of standard sign nodes
signs_lib.sign_node_list = {
"default:sign_wall_wood",
"signs:sign_yard",
"signs:sign_hanging",
"signs:sign_wall_green",
"signs:sign_wall_yellow",
"signs:sign_wall_red",
"signs:sign_wall_white_red",
"signs:sign_wall_white_black",
"signs:sign_wall_orange",
"signs:sign_wall_blue",
"signs:sign_wall_brown",
"locked_sign:sign_wall_locked"
}
local default_sign, default_sign_image
-- Default sign was renamed in 0.4.14. Support both & old versions.
if minetest.registered_nodes["default:sign_wall_wood"] then
default_sign = "default:sign_wall_wood"
default_sign_image = "default_sign_wood.png"
else
default_sign = "default:sign_wall"
default_sign_image = "default_sign_wall.png"
end
--table copy
function signs_lib.table_copy(t)
local nt = { };
for k, v in pairs(t) do
if type(v) == "table" then
nt[k] = signs_lib.table_copy(v)
else
nt[k] = v
end
end
return nt
end
-- infinite stacks
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
signs_lib.expect_infinite_stacks = false
else
signs_lib.expect_infinite_stacks = true
end
-- CONSTANTS
local MP = minetest.get_modpath("signs_lib")
-- Used by `build_char_db' to locate the file.
local FONT_FMT = "%s/hdf_%02x.png"
-- Simple texture name for building text texture.
local FONT_FMT_SIMPLE = "hdf_%02x.png"
-- Path to the textures.
local TP = MP.."/textures"
local TEXT_SCALE = {x=0.8, y=0.5}
-- Lots of overkill here. KISS advocates, go away, shoo! ;) -- kaeza
local PNG_HDR = string.char(0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A)
-- Read the image size from a PNG file.
-- Returns image_w, image_h.
-- Only the LSB is read from each field!
local function read_image_size(filename)
local f = io.open(filename, "rb")
f:seek("set", 0x0)
local hdr = f:read(8)
if hdr ~= PNG_HDR then
f:close()
return
end
f:seek("set", 0x13)
local ws = f:read(1)
f:seek("set", 0x17)
local hs = f:read(1)
f:close()
return ws:byte(), hs:byte()
end
-- Set by build_char_db()
local LINE_HEIGHT
local SIGN_WIDTH
local COLORBGW, COLORBGH
-- Size of the canvas, in characters.
-- Please note that CHARS_PER_LINE is multiplied by the average character
-- width to get the total width of the canvas, so for proportional fonts,
-- either more or fewer characters may fit on a line.
local CHARS_PER_LINE = 30
local NUMBER_OF_LINES = 6
-- 6 rows, max 80 chars per, plus a bit of fudge to
-- avoid excess trimming (e.g. due to color codes)
local MAX_INPUT_CHARS = 600
-- This holds the individual character widths.
-- Indexed by the actual character (e.g. charwidth["A"])
local charwidth
-- helper functions to trim sign text input/output
local function trim_input(text)
return text:sub(1, math.min(MAX_INPUT_CHARS, text:len()))
end
local function build_char_db()
charwidth = { }
-- To calculate average char width.
local total_width = 0
local char_count = 0
for c = 32, 126 do
local w, h = read_image_size(FONT_FMT:format(TP, c))
if w and h then
local ch = string.char(c)
charwidth[ch] = w
total_width = total_width + w
char_count = char_count + 1
end
end
COLORBGW, COLORBGH = read_image_size(TP.."/slc_n.png")
assert(COLORBGW and COLORBGH, "error reading bg dimensions")
LINE_HEIGHT = COLORBGH
-- XXX: Is there a better way to calc this?
SIGN_WIDTH = math.floor((total_width / char_count) * CHARS_PER_LINE)
end
local sign_groups = {choppy=2, dig_immediate=2}
local fences_with_sign = { }
-- some local helper functions
local function split_lines_and_words_old(text)
local lines = { }
local line = { }
if not text then return end
for word in text:gmatch("%S+") do
if word == "|" then
table.insert(lines, line)
if #lines >= NUMBER_OF_LINES then break end
line = { }
elseif word == "\\|" then
table.insert(line, "|")
else
table.insert(line, word)
end
end
table.insert(lines, line)
return lines
end
local function split_lines_and_words(text)
if not text then return end
text = string.gsub(text, "@KEYWORD", current_keyword)
local lines = { }
for _, line in ipairs(text:split("\n")) do
table.insert(lines, line:split(" "))
end
return lines
end
local math_max = math.max
local function fill_line(x, y, w, c)
c = c or "0"
local tex = { }
for xx = 0, math.max(0, w), COLORBGW do
table.insert(tex, (":%d,%d=slc_%s.png"):format(x + xx, y, c))
end
return table.concat(tex)
end
local function make_line_texture(line, lineno)
local width = 0
local maxw = 0
local words = { }
local cur_color = 0
-- We check which chars are available here.
for word_i, word in ipairs(line) do
local chars = { }
local ch_offs = 0
local word_l = #word
local i = 1
while i <= word_l do
local c = word:sub(i, i)
if c == "#" then
local cc = tonumber(word:sub(i+1, i+1), 16)
if cc then
i = i + 1
cur_color = cc
end
else
local w = charwidth[c]
if w then
width = width + w + 1
if width >= (SIGN_WIDTH - charwidth[" "]) then
width = 0
else
maxw = math_max(width, maxw)
end
if #chars < MAX_INPUT_CHARS then
table.insert(chars, {
off=ch_offs,
tex=FONT_FMT_SIMPLE:format(c:byte()),
col=("%X"):format(cur_color),
})
end
ch_offs = ch_offs + w
end
end
i = i + 1
end
width = width + charwidth[" "] + 1
maxw = math_max(width, maxw)
table.insert(words, { chars=chars, w=ch_offs })
end
-- Okay, we actually build the "line texture" here.
local texture = { }
local start_xpos = math.floor((SIGN_WIDTH - maxw) / 2)
local xpos = start_xpos
local ypos = (LINE_HEIGHT * lineno)
cur_color = nil
for word_i, word in ipairs(words) do
local xoffs = (xpos - start_xpos)
if (xoffs > 0) and ((xoffs + word.w) > maxw) then
table.insert(texture, fill_line(xpos, ypos, maxw, "n"))
xpos = start_xpos
ypos = ypos + LINE_HEIGHT
lineno = lineno + 1
if lineno >= NUMBER_OF_LINES then break end
table.insert(texture, fill_line(xpos, ypos, maxw, cur_color))
end
for ch_i, ch in ipairs(word.chars) do
if ch.col ~= cur_color then
cur_color = ch.col
table.insert(texture, fill_line(xpos + ch.off, ypos, maxw, cur_color))
end
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
end
table.insert(texture, (":%d,%d=hdf_20.png"):format(xpos + word.w, ypos))
xpos = xpos + word.w + charwidth[" "]
if xpos >= (SIGN_WIDTH + charwidth[" "]) then break end
end
table.insert(texture, fill_line(xpos, ypos, maxw, "n"))
table.insert(texture, fill_line(start_xpos, ypos + LINE_HEIGHT, maxw, "n"))
return table.concat(texture), lineno
end
local function make_sign_texture(lines)
local texture = { ("[combine:%dx%d"):format(SIGN_WIDTH, LINE_HEIGHT * NUMBER_OF_LINES) }
local lineno = 0
for i = 1, #lines do
if lineno >= NUMBER_OF_LINES then break end
local linetex, ln = make_line_texture(lines[i], lineno)
table.insert(texture, linetex)
lineno = ln + 1
end
table.insert(texture, "^[makealpha:0,0,0")
return table.concat(texture, "")
end
local function set_obj_text(obj, text, new)
local split = new and split_lines_and_words or split_lines_and_words_old
obj:set_properties({
textures={make_sign_texture(split(text))},
visual_size = TEXT_SCALE,
})
end
signs_lib.construct_sign = function(pos, locked)
local meta = minetest.get_meta(pos)
meta:set_string(
"formspec",
"size[6,4]"..
"textarea[0,-0.3;6.5,3;text;;${text}]"..
"button_exit[2,3.4;2,1;ok;Write]"..
"background[-0.5,-0.5;7,5;bg_signs_lib.jpg]")
meta:set_string("infotext", "")
end
signs_lib.destruct_sign = function(pos)
local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
local e = v:get_luaentity()
if e and e.name == "signs:text" then
v:remove()
end
end
end
local function make_infotext(text)
text = trim_input(text)
local lines = split_lines_and_words(text) or {}
local lines2 = { }
for _, line in ipairs(lines) do
table.insert(lines2, (table.concat(line, " "):gsub("#[0-9a-fA-F]", ""):gsub("##", "#")))
end
return table.concat(lines2, "\n")
end
signs_lib.update_sign = function(pos, fields, owner)
-- First, check if the interact keyword from CWz's mod is being set,
-- or has been changed since the last restart...
local meta = minetest.get_meta(pos)
local stored_text = meta:get_string("text") or ""
current_keyword = rawget(_G, "mki_interact_keyword") or current_keyword
if fields then -- ...we're editing the sign.
if fields.text and string.find(dump(fields.text), "@KEYWORD") then
meta:set_string("keyword", current_keyword)
else
meta:set_string("keyword", nil)
end
elseif string.find(dump(stored_text), "@KEYWORD") then -- we need to check if the password is being set/changed
local stored_keyword = meta:get_string("keyword")
if stored_keyword and stored_keyword ~= "" and stored_keyword ~= current_keyword then
signs_lib.destruct_sign(pos)
meta:set_string("keyword", current_keyword)
local ownstr = ""
if owner then ownstr = "Locked sign, owned by "..owner.."\n" end
meta:set_string("infotext", ownstr..string.gsub(make_infotext(stored_text), "@KEYWORD", current_keyword).." ")
end
end
local new
if fields then
fields.text = trim_input(fields.text)
local ownstr = ""
if owner then ownstr = "Locked sign, owned by "..owner.."\n" end
meta:set_string("infotext", ownstr..string.gsub(make_infotext(fields.text), "@KEYWORD", current_keyword).." ")
meta:set_string("text", fields.text)
meta:set_int("__signslib_new_format", 1)
new = true
else
new = (meta:get_int("__signslib_new_format") ~= 0)
end
local text = meta:get_string("text")
if text == nil then return end
local objects = minetest.get_objects_inside_radius(pos, 0.5)
local found
for _, v in ipairs(objects) do
local e = v:get_luaentity()
if e and e.name == "signs:text" then
if found then
v:remove()
else
set_obj_text(v, text, new)
found = true
end
end
end
if found then
return
end
-- if there is no entity
local sign_info
local signnode = minetest.get_node(pos)
if signnode.name == "signs:sign_yard" then
sign_info = signs_lib.yard_sign_model.textpos[minetest.get_node(pos).param2 + 1]
elseif signnode.name == "signs:sign_hanging" then
sign_info = signs_lib.hanging_sign_model.textpos[minetest.get_node(pos).param2 + 1]
elseif string.find(signnode.name, "sign_wall") then
if signnode.name == default_sign
or signnode.name == "locked_sign:sign_wall_locked" then
sign_info = signs_lib.regular_wall_sign_model.textpos[minetest.get_node(pos).param2 + 1]
else
sign_info = signs_lib.metal_wall_sign_model.textpos[minetest.get_node(pos).param2 + 1]
end
else -- ...it must be a sign on a fence post.
sign_info = signs_lib.sign_post_model.textpos[minetest.get_node(pos).param2 + 1]
end
if sign_info == nil then
return
end
local text = minetest.add_entity({x = pos.x + sign_info.delta.x,
y = pos.y + sign_info.delta.y,
z = pos.z + sign_info.delta.z}, "signs:text")
text:setyaw(sign_info.yaw)
end
-- What kind of sign do we need to place, anyway?
function signs_lib.determine_sign_type(itemstack, placer, pointed_thing, locked)
local name
name = minetest.get_node(pointed_thing.under).name
if fences_with_sign[name] then
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
minetest.record_protection_violation(pointed_thing.under,
placer:get_player_name())
return itemstack
end
else
name = minetest.get_node(pointed_thing.above).name
local def = minetest.registered_nodes[name]
if not def.buildable_to then
return itemstack
end
if minetest.is_protected(pointed_thing.above, placer:get_player_name()) then
minetest.record_protection_violation(pointed_thing.above,
placer:get_player_name())
return itemstack
end
end
local node=minetest.get_node(pointed_thing.under)
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
else
local above = pointed_thing.above
local under = pointed_thing.under
local dir = {x = under.x - above.x,
y = under.y - above.y,
z = under.z - above.z}
local wdir = minetest.dir_to_wallmounted(dir)
local placer_pos = placer:getpos()
if placer_pos then
dir = {
x = above.x - placer_pos.x,
y = above.y - placer_pos.y,
z = above.z - placer_pos.z
}
end
local fdir = minetest.dir_to_facedir(dir)
local pt_name = minetest.get_node(under).name
local signname = itemstack:get_name()
if fences_with_sign[pt_name] and signname == default_sign then
minetest.add_node(under, {name = fences_with_sign[pt_name], param2 = fdir})
elseif wdir == 0 and signname == default_sign then
minetest.add_node(above, {name = "signs:sign_hanging", param2 = fdir})
elseif wdir == 1 and signname == default_sign then
minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir})
elseif signname ~= default_sign
and signname ~= "locked_sign:sign_wall_locked" then -- it's a metal wall sign.
minetest.add_node(above, {name = signname, param2 = fdir})
else -- it must be a default or locked wooden wall sign
minetest.add_node(above, {name = signname, param2 = wdir }) -- note it's wallmounted here!
if locked then
local meta = minetest.get_meta(above)
local owner = placer:get_player_name()
meta:set_string("owner", owner)
end
end
if not signs_lib.expect_infinite_stacks then
itemstack:take_item()
end
return itemstack
end
end
function signs_lib.receive_fields(pos, formname, fields, sender, lock)
if minetest.is_protected(pos, sender:get_player_name()) then
minetest.record_protection_violation(pos,
sender:get_player_name())
return
end
local lockstr = lock and "locked " or ""
if fields and fields.text and fields.ok then
minetest.log("action", S("%s wrote \"%s\" to "..lockstr.."sign at %s"):format(
(sender:get_player_name() or ""),
fields.text,
minetest.pos_to_string(pos)
))
if lock then
signs_lib.update_sign(pos, fields, sender:get_player_name())
else
signs_lib.update_sign(pos, fields)
end
end
end
minetest.register_node(":"..default_sign, {
description = S("Sign"),
inventory_image = default_sign_image,
wield_image = default_sign_image,
node_placement_prediction = "",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "wallmounted",
drawtype = "nodebox",
node_box = signs_lib.regular_wall_sign_model.nodebox,
tiles = {"signs_wall_sign.png"},
groups = sign_groups,
on_place = function(itemstack, placer, pointed_thing)
return signs_lib.determine_sign_type(itemstack, placer, pointed_thing)
end,
on_construct = function(pos)
signs_lib.construct_sign(pos)
end,
on_destruct = function(pos)
signs_lib.destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
signs_lib.receive_fields(pos, formname, fields, sender)
end,
on_punch = function(pos, node, puncher)
signs_lib.update_sign(pos)
end,
on_rotate = signs_lib.wallmounted_rotate
})
minetest.register_node(":signs:sign_yard", {
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = signs_lib.yard_sign_model.nodebox,
selection_box = {
type = "fixed",
fixed = {-0.4375, -0.5, -0.0625, 0.4375, 0.375, 0}
},
tiles = {"signs_top.png", "signs_bottom.png", "signs_side.png", "signs_side.png", "signs_back.png", "signs_front.png"},
groups = {choppy=2, dig_immediate=2},
drop = default_sign,
on_construct = function(pos)
signs_lib.construct_sign(pos)
end,
on_destruct = function(pos)
signs_lib.destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
signs_lib.receive_fields(pos, formname, fields, sender)
end,
on_punch = function(pos, node, puncher)
signs_lib.update_sign(pos)
end,
})
minetest.register_node(":signs:sign_hanging", {
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = signs_lib.hanging_sign_model.nodebox,
selection_box = {
type = "fixed",
fixed = {-0.45, -0.275, -0.049, 0.45, 0.5, 0.049}
},
tiles = {
"signs_hanging_top.png",
"signs_hanging_bottom.png",
"signs_hanging_side.png",
"signs_hanging_side.png",
"signs_hanging_back.png",
"signs_hanging_front.png"
},
groups = {choppy=2, dig_immediate=2},
drop = default_sign,
on_construct = function(pos)
signs_lib.construct_sign(pos)
end,
on_destruct = function(pos)
signs_lib.destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
signs_lib.receive_fields(pos, formname, fields, sender)
end,
on_punch = function(pos, node, puncher)
signs_lib.update_sign(pos)
end,
})
minetest.register_node(":signs:sign_post", {
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = signs_lib.sign_post_model.nodebox,
tiles = {
"signs_post_top.png",
"signs_post_bottom.png",
"signs_post_side.png",
"signs_post_side.png",
"signs_post_back.png",
"signs_post_front.png",
},
groups = {choppy=2, dig_immediate=2},
drop = {
max_items = 2,
items = {
{ items = { default_sign }},
{ items = { "default:fence_wood" }},
},
},
})
-- Locked wall sign
minetest.register_privilege("sign_editor", "Can edit all locked signs")
minetest.register_node(":locked_sign:sign_wall_locked", {
description = S("Sign"),
inventory_image = "signs_locked_inv.png",
wield_image = "signs_locked_inv.png",
node_placement_prediction = "",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "wallmounted",
drawtype = "nodebox",
node_box = signs_lib.regular_wall_sign_model.nodebox,
tiles = { "signs_wall_sign_locked.png" },
groups = sign_groups,
on_place = function(itemstack, placer, pointed_thing)
return signs_lib.determine_sign_type(itemstack, placer, pointed_thing, true)
end,
on_construct = function(pos)
signs_lib.construct_sign(pos, true)
end,
on_destruct = function(pos)
signs_lib.destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local pname = sender:get_player_name() or ""
if pname ~= owner and pname ~= minetest.setting_get("name")
and not minetest.check_player_privs(pname, {sign_editor=true}) then
return
end
signs_lib.receive_fields(pos, formname, fields, sender, true)
end,
on_punch = function(pos, node, puncher)
signs_lib.update_sign(pos)
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local pname = player:get_player_name()
return pname == owner or pname == minetest.setting_get("name")
or minetest.check_player_privs(pname, {sign_editor=true})
end,
on_rotate = signs_lib.wallmounted_rotate
})
-- metal, colored signs
local sign_colors = { "green", "yellow", "red", "white_red", "white_black", "orange", "blue", "brown" }
for _, color in ipairs(sign_colors) do
minetest.register_node(":signs:sign_wall_"..color, {
description = S("Sign ("..color..", metal)"),
inventory_image = "signs_"..color.."_inv.png",
wield_image = "signs_"..color.."_inv.png",
node_placement_prediction = "",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = signs_lib.metal_wall_sign_model.nodebox,
tiles = {
"signs_metal_tb.png",
"signs_metal_tb.png",
"signs_metal_sides.png",
"signs_metal_sides.png",
"signs_metal_back.png",
"signs_"..color.."_front.png"
},
groups = sign_groups,
on_place = function(itemstack, placer, pointed_thing)
return signs_lib.determine_sign_type(itemstack, placer, pointed_thing)
end,
on_construct = function(pos)
signs_lib.construct_sign(pos)
end,
on_destruct = function(pos)
signs_lib.destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
signs_lib.receive_fields(pos, formname, fields, sender)
end,
on_punch = function(pos, node, puncher)
signs_lib.update_sign(pos)
end,
})
end
local signs_text_on_activate
signs_text_on_activate = function(self)
local meta = minetest.get_meta(self.object:getpos())
local text = meta:get_string("text")
local new = (meta:get_int("__signslib_new_format") ~= 0)
if text then
text = trim_input(text)
set_obj_text(self.object, text, new)
end
end
minetest.register_entity(":signs:text", {
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "upright_sprite",
textures = {},
on_activate = signs_text_on_activate,
})
-- And the good stuff here! :-)
function signs_lib.register_fence_with_sign(fencename, fencewithsignname)
local def = minetest.registered_nodes[fencename]
local def_sign = minetest.registered_nodes[fencewithsignname]
if not (def and def_sign) then
minetest.log("warning", "[signs_lib] Attempt to register unknown node as fence")
return
end
def = signs_lib.table_copy(def)
def_sign = signs_lib.table_copy(def_sign)
fences_with_sign[fencename] = fencewithsignname
def_sign.on_place = function(itemstack, placer, pointed_thing, ...)
local node_above = minetest.get_node_or_nil(pointed_thing.above)
local node_under = minetest.get_node_or_nil(pointed_thing.under)
local def_above = node_above and minetest.registered_nodes[node_above.name]
local def_under = node_under and minetest.registered_nodes[node_under.name]
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local playername = placer:get_player_name()
if minetest.is_protected(pointed_thing.under, playername) then
minetest.record_protection_violation(pointed_thing.under, playername)
return itemstack
end
if minetest.is_protected(pointed_thing.above, playername) then
minetest.record_protection_violation(pointed_thing.above, playername)
return itemstack
end
if def_under and def_under.on_rightclick then
return def_under.on_rightclick(pointed_thing.under, node_under, placer, itemstack) or itemstack
elseif def_under and def_under.buildable_to then
minetest.add_node(pointed_thing.under, {name = fencename, param2 = fdir})
if not signs_lib.expect_infinite_stacks then
itemstack:take_item()
end
placer:set_wielded_item(itemstack)
elseif def_above and def_above.buildable_to then
minetest.add_node(pointed_thing.above, {name = fencename, param2 = fdir})
if not signs_lib.expect_infinite_stacks then
itemstack:take_item()
end
placer:set_wielded_item(itemstack)
end
return itemstack
end
def_sign.on_construct = function(pos, ...)
signs_lib.construct_sign(pos)
end
def_sign.on_destruct = function(pos, ...)
signs_lib.destruct_sign(pos)
end
def_sign.on_receive_fields = function(pos, formname, fields, sender)
signs_lib.receive_fields(pos, formname, fields, sender)
end
def_sign.on_punch = function(pos, node, puncher, ...)
signs_lib.update_sign(pos)
end
local fencename = fencename
def_sign.after_dig_node = function(pos, node, ...)
node.name = fencename
minetest.add_node(pos, node)
end
def_sign.drop = default_sign
minetest.register_node(":"..fencename, def)
minetest.register_node(":"..fencewithsignname, def_sign)
table.insert(signs_lib.sign_node_list, fencewithsignname)
minetest.log("verbose", S("Registered %s and %s"):format(fencename, fencewithsignname))
end
build_char_db()
minetest.register_alias("homedecor:fence_wood_with_sign", "signs:sign_post")
minetest.register_alias("sign_wall_locked", "locked_sign:sign_wall_locked")
signs_lib.register_fence_with_sign("default:fence_wood", "signs:sign_post")
-- restore signs' text after /clearobjects and the like
minetest.register_abm({
nodenames = signs_lib.sign_node_list,
interval = 15,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
signs_lib.update_sign(pos)
end
})
-- locked sign
minetest.register_craft({
output = "locked_sign:sign_wall_locked",
recipe = {
{"group:wood", "group:wood", "group:wood"},
{"group:wood", "group:wood", "default:steel_ingot"},
{"", "group:stick", ""},
}
})
--Alternate recipe.
minetest.register_craft({
output = "locked_sign:sign_wall_locked",
recipe = {
{default_sign},
{"default:steel_ingot"},
},
})
-- craft recipes for the metal signs
minetest.register_craft( {
output = "signs:sign_wall_green 4",
recipe = {
{ "dye:dark_green", "dye:white", "dye:dark_green" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_green 2",
recipe = {
{ "dye:dark_green", "dye:white", "dye:dark_green" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
}) ]]-- Removed. Item "steel:sheet_metal" is unknown //MFF(Mg|08/09/15)
minetest.register_craft( {
output = "signs:sign_wall_yellow 4",
recipe = {
{ "dye:yellow", "dye:black", "dye:yellow" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_yellow 2",
recipe = {
{ "dye:yellow", "dye:black", "dye:yellow" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
}) ]]-- Removed. Item "steel:sheet_metal" is unknown //MFF(Mg|08/09/15)
minetest.register_craft( {
output = "signs:sign_wall_red 4",
recipe = {
{ "dye:red", "dye:white", "dye:red" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_red 2",
recipe = {
{ "dye:red", "dye:white", "dye:red" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
}) ]]-- Removed. Item "steel:sheet_metal" is unknown //MFF(Mg|08/09/15)
minetest.register_craft( {
output = "signs:sign_wall_white_red 4",
recipe = {
{ "dye:white", "dye:red", "dye:white" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_white_red 2",
recipe = {
{ "dye:white", "dye:red", "dye:white" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
}) ]]-- Removed. Item "steel:sheet_metal" is unknown //MFF(Mg|08/09/15)
minetest.register_craft( {
output = "signs:sign_wall_white_black 4",
recipe = {
{ "dye:white", "dye:black", "dye:white" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_white_black 2",
recipe = {
{ "dye:white", "dye:black", "dye:white" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
}) ]]-- Removed. Item "steel:sheet_metal" is unknown //MFF(Mg|08/09/15)
minetest.register_craft( {
output = "signs:sign_wall_orange 4",
recipe = {
{ "dye:orange", "dye:black", "dye:orange" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_orange 2",
recipe = {
{ "dye:orange", "dye:black", "dye:orange" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
}) ]]-- Removed. Item "steel:sheet_metal" is unknown //MFF(Mg|08/09/15)
minetest.register_craft( {
output = "signs:sign_wall_blue 4",
recipe = {
{ "dye:blue", "dye:white", "dye:blue" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_blue 2",
recipe = {
{ "dye:blue", "dye:white", "dye:blue" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
})]] -- Disabled. steel:sheet_metal is unknown //MFF(Mg|08/04/15)
minetest.register_craft( {
output = "signs:sign_wall_brown 4",
recipe = {
{ "dye:brown", "dye:white", "dye:brown" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
--[[minetest.register_craft( {
output = "signs:sign_wall_brown 2",
recipe = {
{ "dye:brown", "dye:white", "dye:brown" },
{ "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
},
})]] -- Disabled. steel:sheet_metal is unknown //MFF(Mg|08/04/15)
if minetest.setting_get("log_mods") then
minetest.log("action", S("signs loaded"))
end
| unlicense |
zynjec/darkstar | scripts/globals/items/porcupine_pie.lua | 11 | 1808 | -----------------------------------------
-- ID: 5156
-- Item: porcupine_pie
-- Food Effect: 30Min, All Races
-----------------------------------------
-- HP 55
-- Strength 6
-- Vitality 2
-- Intelligence -3
-- Mind 3
-- HP recovered while healing 2
-- MP recovered while healing 2
-- Accuracy 5
-- Attack % 18 (cap 95)
-- Ranged Attack % 18 (cap 95)
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,14400,5156)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.HP, 55)
target:addMod(dsp.mod.STR, 6)
target:addMod(dsp.mod.VIT, 2)
target:addMod(dsp.mod.INT, -3)
target:addMod(dsp.mod.MND, 3)
target:addMod(dsp.mod.HPHEAL, 2)
target:addMod(dsp.mod.MPHEAL, 2)
target:addMod(dsp.mod.ACC, 5)
target:addMod(dsp.mod.FOOD_ATTP, 18)
target:addMod(dsp.mod.FOOD_ATT_CAP, 95)
target:addMod(dsp.mod.FOOD_RATTP, 18)
target:addMod(dsp.mod.FOOD_RATT_CAP, 95)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 55)
target:delMod(dsp.mod.STR, 6)
target:delMod(dsp.mod.VIT, 2)
target:delMod(dsp.mod.INT, -3)
target:delMod(dsp.mod.MND, 3)
target:delMod(dsp.mod.HPHEAL, 2)
target:delMod(dsp.mod.MPHEAL, 2)
target:delMod(dsp.mod.ACC, 5)
target:delMod(dsp.mod.FOOD_ATTP, 18)
target:delMod(dsp.mod.FOOD_ATT_CAP, 95)
target:delMod(dsp.mod.FOOD_RATTP, 18)
target:delMod(dsp.mod.FOOD_RATT_CAP, 95)
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Al_Zahbi/npcs/Chochoroon.lua | 14 | 1035 | -----------------------------------
-- Area: Al Zahbi
-- NPC: Chochoroon
-- Type: Appraiser
-- @zone 48
-- @pos -42.739 -1 -45.987
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0104);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/abilities/feather_step.lua | 1 | 7964 | -----------------------------------
-- Ability: Stutter Step
-- Applies Weakened Daze. Lowers the targets magic resistance. If successful, you will earn two Finishing Moves.
-- Obtained: Dancer Level 40
-- TP Required: 10%
-- Recast Time: 00:05
-- Duration: First Step lasts 1 minute, each following Step extends its current duration by 30 seconds.
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/weaponskills");
require("scripts/globals/jsr_ability");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
if (player:getAnimation() ~= 1) then
return MSGBASIC_REQUIRES_COMBAT,0;
else
if (player:hasStatusEffect(EFFECT_TRANCE)) then
return 0,0;
elseif (player:getTP() < 80) then
return MSGBASIC_NOT_ENOUGH_TP,0;
else
return 0,0;
end
end
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability,action)
-- Only remove TP if the player doesn't have Trance.
if not player:hasStatusEffect(EFFECT_TRANCE) then
player:delTP(doConserveTP(player, 80));
end;
local hit = 3;
local effect = 1;
if math.random() <= getHitRate(player,target,true,player:getMod(MOD_STEP_ACCURACY)) then
hit = 7;
local mjob = player:getMainJob();
local daze = 1;
if (mjob == 19) then
if (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_1)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_1):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_1);
if (player:hasStatusEffect(EFFECT_PRESTO)) then
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_3,1,0,90);
daze = 3;
effect = 3;
else
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_2,1,0,90);
daze = 2;
effect = 2;
end
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_2)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_2):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_2);
if (player:hasStatusEffect(EFFECT_PRESTO)) then
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_4,1,0,90);
daze = 3;
effect = 4;
else
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_3,1,0,90);
daze = 2;
effect = 3;
end
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_3)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_3):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_3);
if (player:hasStatusEffect(EFFECT_PRESTO)) then
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_5,1,0,90);
daze = 3;
effect = 5;
else
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_4,1,0,90);
daze = 2;
effect = 4;
end
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_4)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_4):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_4);
if (player:hasStatusEffect(EFFECT_PRESTO)) then
daze = 3;
else
daze = 2;
end
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_2,1,0,90);
effect = 5;
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_5)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_5):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_5);
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_3,1,0,90);
daze = 1;
effect = 5;
else
if (player:hasStatusEffect(EFFECT_PRESTO)) then
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_2,1,0,90);
daze = 3;
effect = 2;
else
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_1,1,0,90);
daze = 2;
effect = 1;
end
end;
else
if (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_1)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_1):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_1);
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_2,1,0,90);
effect = 2;
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_2)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_2):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_2);
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_3,1,0,90);
effect = 3;
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_3)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_3):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_3);
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_4,1,0,90);
effect = 4;
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_4)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_4):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_4);
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_5,1,0,90);
effect = 5;
elseif (target:hasStatusEffect(EFFECT_BEWILDERED_DAZE_5)) then
local duration = target:getStatusEffect(EFFECT_BEWILDERED_DAZE_5):getDuration();
target:delStatusEffectSilent(EFFECT_BEWILDERED_DAZE_5);
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_5,1,0,90);
effect = 5;
else
target:addStatusEffect(EFFECT_BEWILDERED_DAZE_1,1,0,90);
effect = 1;
end;
end
if (player:hasStatusEffect(EFFECT_FINISHING_MOVE_1)) then
player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_1);
player:addStatusEffect(EFFECT_FINISHING_MOVE_1+daze,1,0,7200);
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_2)) then
player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_2);
player:addStatusEffect(EFFECT_FINISHING_MOVE_2+daze,1,0,7200);
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_3)) then
player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_3);
if (daze > 2) then
daze = 2;
end;
player:addStatusEffect(EFFECT_FINISHING_MOVE_3+daze,1,0,7200);
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_4)) then
player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_4);
player:addStatusEffect(EFFECT_FINISHING_MOVE_5,1,0,7200);
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_5)) then
else
player:addStatusEffect(EFFECT_FINISHING_MOVE_1 - 1 + daze,1,0,7200);
end;
else
ability:setMsg(158);
end
action:animation(target:getID(), getStepAnimation(player:getWeaponSkillType(SLOT_MAIN)))
action:speceffect(target:getID(), hit)
return effect
end;
| gpl-3.0 |
qaisjp/openframe | client/gui/progressbar_class.lua | 1 | 7334 | push([[
-----------------------------------------------------------
--- /client/gui/progressbar_class.lua ---
--- Part of openFrame project ---
--- Written by 50p. Additional changes by Orange. ---
--- Lately edited in revision number 13 by Orange ---
--- Licensed under BSD licence ---
-----------------------------------------------------------
-- Class: ProgressBar Class
-- Class which allows to easily add progressbars to windows/screen.
ProgressBar = { };
ProgressBar.__index = ProgressBar;
-- Function: ProgressBar:Create
-- Creates a progressbar
--
-- Required Arguments:
-- x - (float/integer) Space from left side of screen/window
-- y - (float/integer) Space from top side of screen/window
-- width - (float/integer) Width of the progressbar
-- height - (float/integer) Height of the progressbar
--
-- Optional arguments:
-- text - (string) Text of the progressbar's caption
-- relative - (bool) Are the x/y/width/height values relative?
-- parent - (GUI) Parent of the progressbar
--
-- Returns:
-- The result is a progressbar object
function ProgressBar:Create( x, y, width, height, text, relative, parent )
local progbar = {
gui = false,
lbl = false,
onclick = { },
onmouseenter = { },
onmouseleave = { },
cursorovergui = false,
_dragable = false
};
for i, f in pairs( GUISharedFuncs ) do
if
(
( i ~= "__index" ) and
( i ~= "Dragable" ) and
( i ~= "Font" ) and
( i ~= "Text" ) and
( i ~= "Size" )
)
then
progbar[ i ] = f;
end
end
if type( text ) == "boolean" then
relative = text;
end
progbar.gui = guiCreateProgressBar( x, y, width, height, ( type( relative ) == "boolean" ) and relative or false, parent );
if( progbar.gui ) then
if type( text ) == "string" then
progbar.lbl = Label:Create( 0, 0, width, height, text or "", ( type( relative ) == "boolean" ) and relative or false, progbar.gui );
progbar.lbl:VerticalAlign( "center" );
progbar.lbl:HorizontalAlign( "center" );
progbar.lbl:Color( 255, 255, 0 );
end
setmetatable( progbar, self );
self.__index = self;
addEventHandler( "onClientGUIClick",
( type( progbar.lbl ) == "table" ) and progbar.lbl.gui or progbar.gui,
function( mouseBtn, state, x, y )
if type( progbar.onclick ) == "table" then
for i, f in pairs( progbar.onclick ) do
f( progbar, mouseBtn, state, x, y );
end
end
end,
false
);
addEventHandler( "onClientMouseEnter",
( type( progbar.lbl ) == "table" ) and progbar.lbl.gui or progbar.gui,
function( x, y )
GUICollection.guiMouseIsOver = progbar;
if type( progbar.onmouseenter ) == "table" then
for _, f in pairs( progbar.onmouseenter ) do
if type( f ) == "function" then
f( progbar, x, y );
end
end
end
end,
false
)
addEventHandler( "onClientMouseLeave",
( type( progbar.lbl ) == "table" ) and progbar.lbl.gui or progbar.gui,
function( x, y )
GUICollection.guiMouseIsOver = false;
if type( progbar.onmouseleave ) == "table" then
for _, f in pairs( progbar.onmouseleave ) do
if type( f ) == "function" then
f( progbar, x, y );
end
end
end
end,
false
)
return progbar;
end
return false;
end
-- Function: ProgressBar:Font
-- Returns or sets the font
--
-- Optional arguments:
-- newfont - (string) The new font name
--
-- Returns:
-- If tried to set, true or false. If tried to get it, returns current font.
function ProgressBar:Font( newfont )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if type( newfont ) == "string" then
if type( self.lbl ) == "table" then
return self.lbl:Font( newfont );
end
outputDebugString( "this progressbar doesn't have a label!", 0 );
return false;
end
return guiGetFont( self.gui )
end
-- Function: ProgressBar:LabelColor
-- Returns or sets the color of progressbar's label.
--
-- Optional arguments:
-- r - (integer) Value of red color
-- g - (integer) Value of green color
-- b - (integer) Value of blue color
--
-- Returns:
-- If tried to set, true or false. If tried to get, three integers with values.
function ProgressBar:LabelColor( r, g, b )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if
(
( type( r ) == "number" ) and
( type( g ) == "number" ) and
( type( b ) == "number" )
)
then
if type( self.lbl ) == "table" then
return self.lbl:Color( r, g, b );
end
outputDebugString( "this progressbar doesn't have a label!", 0 );
return false;
end
return guiGetText( self.gui );
end
-- Function: ProgressBar:Progress
-- Returns or sets the progress
--
-- Optional arguments:
-- progress - (integer) Current progress displayed on progressbar
--
-- Returns:
-- If tried to set, true or false. If tried to get it, returns current progress.
function ProgressBar:Progress( progress )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( progress ) == "number" ) then
return guiProgressBarSetProgress( self.gui, progress );
end
return guiProgressBarGetProgress( self.gui );
end
-- Function: ProgressBar:Text
-- Returns or sets the progressbar's text
--
-- Optional arguments:
-- text - (string) Progressbar's text to set
--
-- Returns:
-- If tried to set, true or false. If tried to get it, returns current text.
function ProgressBar:Text( value )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if type( value ) == "string" then
if type( self.lbl ) == "table" then
return self.lbl:Text( value );
end
outputDebugString( "this progressbar doesn't have a label!", 0 );
return false;
end
return guiGetText( self.gui );
end
-- Function: ProgressBar:Size
-- Returns or sets the progressbar's size
--
-- Optional arguments:
-- width - (string) New width to set
-- height - (string) New height to set
-- relative - (bool) Is width and height relative?
--
-- Returns:
-- If tried to set, true or false. If tried to get it, returns current size.
function ProgressBar:Size( width, height, relative )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( width ) == "number" ) and ( type( height ) == "number" ) then
local temp = guiSetSize( self.gui, width, height, ( type( relative ) == "boolean" ) and relative or false );
if temp then
if type( self.lbl ) == "table" then
self.lbl:Size( 1, 1, true );
end
return temp;
end
end
return guiGetSize( self.gui, ( type( width ) == "boolean" ) and width or false )
end
]]) | mit |
JarnoVgr/InfectedWars | entities/weapons/iw_mp5/shared.lua | 1 | 1867 | --[[-----------------------------------------------------------------------------
* Infected Wars, an open source Garry's Mod game-mode.
*
* Infected Wars is the work of multiple authors,
* a full list can be found in CONTRIBUTORS.md.
* For more information, visit https://github.com/JarnoVgr/InfectedWars
*
* Infected Wars is free software: you can redistribute it and/or modify
* it under the terms of the MIT License.
*
* A full copy of the MIT License can be found in LICENSE.txt.
-----------------------------------------------------------------------------]]
if SERVER then
AddCSLuaFile("shared.lua")
end
SWEP.HoldType = "ar2"
if CLIENT then
SWEP.PrintName = "MP5"
SWEP.Slot = 2
SWEP.SlotPos = 1
SWEP.IconLetter = "x"
killicon.AddFont("iw_mp5", "CSKillIcons", SWEP.IconLetter, Color(255, 80, 0, 255 ))
end
function SWEP:InitializeClientsideModels()
self.VElements = {
["ammo"] = { type = "Quad", bone = "v_weapon.MP5_Parent", rel = "", pos = Vector(-0.331, 3.086, 3.25), angle = Angle(0, 0, 170.475), size = 0.012, draw_func = function(wep) DrawWeaponInfo(wep) end}
}
self.WElements = {}
end
SWEP.Base = "iw_base"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_smg_mp5.mdl"
SWEP.WorldModel = "models/weapons/w_smg_mp5.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Sound = Sound("Weapon_MP5Navy.Single")
SWEP.Primary.Recoil = 2.2
SWEP.Primary.Damage = 12
SWEP.Primary.NumShots = 1
SWEP.Primary.ClipSize = 30
SWEP.Primary.Delay = 0.09
SWEP.Primary.DefaultClip = SWEP.Primary.ClipSize * 5
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "SMG1"
SWEP.Primary.Cone = 0.07
SWEP.Primary.ConeMoving = 0.14
SWEP.Primary.ConeCrouching = 0.05
SWEP.MuzzleEffect = "rg_muzzle_rifle"
SWEP.ShellEffect = "rg_shelleject"
| mit |
visualfc/go-ui | make/ui/lineedit.lua | 1 | 3172 | module("lineedit")
name = "LineEdit"
base = "Widget"
comment = [[
InputMask:
A ASCII alphabetic character required. A-Z, a-z.
a ASCII alphabetic character permitted but not required.
N ASCII alphanumeric character required. A-Z, a-z, 0-9.
n ASCII alphanumeric character permitted but not required.
X Any character required.
x Any character permitted but not required.
9 ASCII digit required. 0-9.
0 ASCII digit permitted but not required.
D ASCII digit required. 1-9.
d ASCII digit permitted but not required (1-9).
# ASCII digit or plus/minus sign permitted but not required.
H Hexadecimal character required. A-F, a-f, 0-9.
h Hexadecimal character permitted but not required.
B Binary character required. 0-1.
b Binary character permitted but not required.
> All following alphabetic characters are uppercased.
< All following alphabetic characters are lowercased.
! Switch off case conversion.
\ Use \ to escape the special characters listed above to use them as separators.
InputMask Example:
000.000.000.000;_ IP address; blanks are _.
HH:HH:HH:HH:HH:HH;_ MAC address
0000-00-00 ISO Date; blanks are space
>AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;# License number; blanks are - and all (alphabetic) characters are converted to uppercase.
]]
funcs = [[
+ Init()
+ InitWithText(text string)
@ SetText(text string)
@ Text() (text string)
@ SetInputMask(text string)
@ InputMask() (text string)
@ SetAlignment(value Alignment)
@ Alignment() (value Alignment)
@ SetCursorPos(pos int)
@ CursorPos() (pos int)
@ SetDragEnabled(b bool)
@ DragEnabled() (b bool)
@ SetReadOnly(b bool)
@ IsReadOnly() (b bool)
@ SetFrame(b bool)
@ HasFrame() (b bool)
@ IsRedoAvailable() (b bool)
@ HasSelected() (b bool)
@ SelectedText() (text string)
@ SelStart() (start int)
SetSel(start int,length int)
CancelSel()
SelectAll()
Copy()
Cut()
Paste()
Redo()
Undo()
Clear()
* OnTextChanged(fn func(string))
* OnEditingFinished(fn func())
* OnReturnPressed(fn func())
]]
qtdrv = {
inc = "<QLineEdit>",
name = "QLineEdit *",
Init = [[
drvNewObj(a0,new QLineEdit);
]],
InitWithText = [[
drvNewObj(a0, new QLineEdit(drvGetString(a1)));
]],
SetText = "setText",
Text = "text",
SetInputMask = "setInputMask",
InputMask = "inputMask",
SetAlignment = "setAlignment",
Alignment = "alignment",
SetCursorPos = "setCursorPosition",
CursorPos = "cursorPosition",
SetDragEnabled = "setDragEnabled",
DragEnabled = "dragEnabled",
SetReadOnly = "setReadOnly",
IsReadOnly = "isReadOnly",
SetFrame = "setFrame",
HasFrame = "hasFrame",
IsRedoAvailable = "isRedoAvailable",
HasSelected = "hasSelectedText",
SelectedText = "selectedText",
SelStart = "selectionStart",
SetSel = "setSelection",
CancelSel = "deselect",
SelectAll = "selectAll",
Copy = "copy",
Cut = "cut",
Paste = "paste",
Redo = "redo",
Undo = "undo",
Clear = "clear",
OnTextChanged = [[
QObject::connect(self,SIGNAL(textChanged(QString)),drvNewSignal(self,a1,a2),SLOT(call(QString)));
]],
OnEditingFinished = [[
QObject::connect(self,SIGNAL(editingFinished(QString)),drvNewSignal(self,a1,a2),SLOT(call(QString)));
]],
OnReturnPressed = [[
QObject::connect(self,SIGNAL(returnPressed(QString)),drvNewSignal(self,a1,a2),SLOT(call(QString)));
]],
}
| bsd-2-clause |
Colettechan/darkstar | scripts/globals/items/dragon_steak.lua | 18 | 1866 | -----------------------------------------
-- ID: 4350
-- Item: dragon_steak
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Health 25
-- Strength 7
-- Intelligence -3
-- Health Regen While Healing 2
-- Attack % 20
-- Attack Cap 150
-- Ranged ATT % 20
-- Ranged ATT Cap 150
-- Demon Killer 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,4350);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 25);
target:addMod(MOD_STR, 7);
target:addMod(MOD_INT, -3);
target:addMod(MOD_HPHEAL, 2);
target:addMod(MOD_FOOD_ATTP, 20);
target:addMod(MOD_FOOD_ATT_CAP, 150);
target:addMod(MOD_FOOD_RATTP, 20);
target:addMod(MOD_FOOD_RATT_CAP, 150);
target:addMod(MOD_DEMON_KILLER, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 25);
target:delMod(MOD_STR, 7);
target:delMod(MOD_INT, -3);
target:delMod(MOD_HPHEAL, 2);
target:delMod(MOD_FOOD_ATTP, 20);
target:delMod(MOD_FOOD_ATT_CAP, 150);
target:delMod(MOD_FOOD_RATTP, 20);
target:delMod(MOD_FOOD_RATT_CAP, 150);
target:delMod(MOD_DEMON_KILLER, 5);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Kazham/npcs/Hari_Pakhroib.lua | 29 | 3020 | -----------------------------------
-- Area: Kazham
-- NPC: Hari Pakhroib
-- Starts and Finishes Quest: Greetings to the Guardian
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/globals/titles");
require("scripts/zones/Kazham/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
Guardian = player:getQuestStatus(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
Pamamas = player:getVar("PamamaVar");
pfame = player:getFameLevel(KAZHAM)
needToZone = player:needToZone();
if (Guardian == QUEST_ACCEPTED) then
if (Pamamas == 1) then
player:startEvent(0x0047); --Finish Quest
else
player:startEvent(0x0045,0,4596); --Reminder Dialogue
end
elseif (Guardian == QUEST_AVAILABLE and pfame >= 7) then
player:startEvent(0x0044,4596,4596,4596); --Start Quest
elseif (Guardian == QUEST_COMPLETED and needToZone == false) then
if (Pamamas == 2) then
player:startEvent(0x0047); --Finish quest dialogue (no different csid between initial and repeats)
else
player:startEvent(0x0048); --Dialogue for after completion of quest
end
elseif (Guardian == QUEST_COMPLETED and needToZone == true) then
player:startEvent(0x0048);
else
player:startEvent(0x0054); --Standard Dialogue
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0044 and option == 1) then
player:addQuest(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
player:setVar("PamamaVar",0);
elseif (csid == 0x0047) then
if (Pamamas == 1) then --First completion of quest; set title, complete quest, and give higher fame
player:addGil(GIL_RATE*5000);
player:messageSpecial(GIL_OBTAINED, 5000);
player:completeQuest(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
player:addFame(WINDURST,100);
player:addTitle(KAZHAM_CALLER);
player:setVar("PamamaVar",0);
player:needToZone(true);
elseif (Pamamas == 2) then --Repeats of quest; give only gil and less fame
player:addGil(GIL_RATE*5000);
player:messageSpecial(GIL_OBTAINED, 5000);
player:addFame(WINDURST,30);
player:setVar("PamamaVar",0);
player:needToZone(true);
end
end
end;
| gpl-3.0 |
zynjec/darkstar | scripts/globals/abilities/pets/attachments/mana_tank.lua | 11 | 1151 | -----------------------------------
-- Attachment: Mana Tank
-----------------------------------
require("scripts/globals/automaton")
require("scripts/globals/status")
-----------------------------------
function onEquip(pet)
-- We do not have support to do a fraction of a percent so we rounded
local frame = pet:getAutomatonFrame()
if frame == dsp.frames.HARLEQUIN then
pet:addMod(dsp.mod.MPP, 5)
elseif frame == dsp.frames.STORMWAKER then
pet:addMod(dsp.mod.MPP, 4)
end
end
function onUnequip(pet)
local frame = pet:getAutomatonFrame()
if frame == dsp.frames.HARLEQUIN then
pet:delMod(dsp.mod.MPP, 5)
elseif frame == dsp.frames.STORMWAKER then
pet:delMod(dsp.mod.MPP, 4)
end
end
function onManeuverGain(pet, maneuvers)
onUpdate(pet, maneuvers)
end
function onManeuverLose(pet, maneuvers)
onUpdate(pet, maneuvers - 1)
end
function onUpdate(pet, maneuvers)
local power = 0
if maneuvers > 0 then
power = math.floor(maneuvers + (pet:getMaxMP() * (0.2 * maneuvers) / 100))
end
updateModPerformance(pet, dsp.mod.REFRESH, 'mana_tank_mod', power)
end
| gpl-3.0 |
Arashbrsh/cccdpay | plugins/gnuplot.lua | 622 | 1813 | --[[
* Gnuplot plugin by psykomantis
* dependencies:
* - gnuplot 5.00
* - libgd2-xpm-dev (on Debian distr) for more info visit: https://libgd.github.io/pages/faq.html
*
]]
-- Gnuplot needs absolute path for the plot, so i run some commands to find where we are
local outputFile = io.popen("pwd","r")
io.input(outputFile)
local _pwd = io.read("*line")
io.close(outputFile)
local _absolutePlotPath = _pwd .. "/data/plot.png"
local _scriptPath = "./data/gnuplotScript.gpl"
do
local function gnuplot(msg, fun)
local receiver = get_receiver(msg)
-- We generate the plot commands
local formattedString = [[
set grid
set terminal png
set output "]] .. _absolutePlotPath .. [["
plot ]] .. fun
local file = io.open(_scriptPath,"w");
file:write(formattedString)
file:close()
os.execute("gnuplot " .. _scriptPath)
os.remove (_scriptPath)
return _send_photo(receiver, _absolutePlotPath)
end
-- Check all dependencies before executing
local function checkDependencies()
local status = os.execute("gnuplot -h")
if(status==true) then
status = os.execute("gnuplot -e 'set terminal png'")
if(status == true) then
return 0 -- OK ready to go!
else
return 1 -- missing libgd2-xpm-dev
end
else
return 2 -- missing gnuplot
end
end
local function run(msg, matches)
local status = checkDependencies()
if(status == 0) then
return gnuplot(msg,matches[1])
elseif(status == 1) then
return "It seems that this bot miss a dependency :/"
else
return "It seems that this bot doesn't have gnuplot :/"
end
end
return {
description = "use gnuplot through telegram, only plot single variable function",
usage = "!gnuplot [single variable function]",
patterns = {"^!gnuplot (.+)$"},
run = run
}
end
| gpl-2.0 |
vatanambib/uzzbot | plugins/quotes.lua | 651 | 1630 | local quotes_file = './data/quotes.lua'
local quotes_table
function read_quotes_file()
local f = io.open(quotes_file, "r+")
if f == nil then
print ('Created a new quotes file on '..quotes_file)
serialize_to_file({}, quotes_file)
else
print ('Quotes loaded: '..quotes_file)
f:close()
end
return loadfile (quotes_file)()
end
function save_quote(msg)
local to_id = tostring(msg.to.id)
if msg.text:sub(11):isempty() then
return "Usage: !addquote quote"
end
if quotes_table == nil then
quotes_table = {}
end
if quotes_table[to_id] == nil then
print ('New quote key to_id: '..to_id)
quotes_table[to_id] = {}
end
local quotes = quotes_table[to_id]
quotes[#quotes+1] = msg.text:sub(11)
serialize_to_file(quotes_table, quotes_file)
return "done!"
end
function get_quote(msg)
local to_id = tostring(msg.to.id)
local quotes_phrases
quotes_table = read_quotes_file()
quotes_phrases = quotes_table[to_id]
return quotes_phrases[math.random(1,#quotes_phrases)]
end
function run(msg, matches)
if string.match(msg.text, "!quote$") then
return get_quote(msg)
elseif string.match(msg.text, "!addquote (.+)$") then
quotes_table = read_quotes_file()
return save_quote(msg)
end
end
return {
description = "Save quote",
description = "Quote plugin, you can create and retrieve random quotes",
usage = {
"!addquote [msg]",
"!quote",
},
patterns = {
"^!addquote (.+)$",
"^!quote$",
},
run = run
}
| gpl-2.0 |
actboy168/MoeHero | scripts/maps/hero/魔理沙/黑魔[黑洞边缘].lua | 1 | 2011 | local math = math
local mt = ac.skill['黑魔[黑洞边缘]']
mt{
--初始等级
level = 0,
--技能图标
art = [[replaceabletextures\commandbuttons\BTNmarisaQ.blp]],
--技能说明
title = '黑魔[黑洞边缘]',
tip = [[
魔理沙释放很多星弹,向目标地点飞去,每颗星弹造成%damage%(+%damage_plus%)伤害。
|cffffff11可充能%charge_max_stack%次|r
]],
--施法距离
range = {600, 800},
--耗蓝
cost = {60, 80},
--冷却
cool = 1,
charge_cool = {12, 8},
--动画
cast_animation = 'attack',
--施法前摇
cast_start_time = 0.2,
--目标类型
target_type = ac.skill.TARGET_TYPE_POINT,
--范围
area = 500,
--弹幕数量
count = 9,
--伤害
damage = {60, 100},
--伤害加成
damage_plus = function(self, hero)
return hero:get_ad() * 1.0
end,
--弹道速度
speed = 500,
cooldown_mode = 1,
charge_max_stack = 3,
instant = 1,
}
local star = {
[[marisastarm_1b.mdx]],
[[marisastarm_1g.mdx]],
[[marisastarm_1y.mdx]],
}
function mt:on_cast_channel()
local hero = self.owner
local target = self.target
local damage = self.damage + self.damage_plus
local mark = {}
for i = 1, self.count do
local angle = i * (360.0 / self.count)
local mvr = ac.mover.line
{
source = hero,
start = target - {angle, self.area},
model = star[i % 3 + 1],
angle = angle - 180 + 50,
distance = self.area * 2,
speed = self.speed,
high = 60,
size = 1.5,
skill = self,
damage = damage,
hit_type = ac.mover.HIT_TYPE_ENEMY,
hit_area = 100,
}
if mvr then
function mvr:on_move()
self.angle = self.angle - 4
end
function mvr:on_hit(target)
if mark[target] then
target:damage
{
source = hero,
damage = damage * 0.30,
skill = self.skill,
attack = true,
}
return
end
mark[target] = true
target:damage
{
source = hero,
damage = damage,
skill = self.skill,
attack = true,
}
return true
end
end
end
end
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Stellar_Fulcrum/npcs/_4z3.lua | 27 | 1030 | -----------------------------------
-- Area: Stellar Fulcrum
-- NPC: Qe'Lov Gate
-------------------------------------
require("scripts/globals/status");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
player:startEvent(32003);
return 1;
end;
function onEventUpdate(player,csid,option)
-- printf("onUpdate CSID: %u",csid);
-- printf("onUpdate RESULT: %u",option);
end;
function onEventFinish(player,csid,option)
-- printf("onFinish CSID: %u",csid);
-- printf("onFinish RESULT: %u",option);
local pZone = player:getZoneID();
if (csid == 32003 and option == 4) then
if (player:getCharVar(tostring(pZone) .. "_Fight") == 100) then
player:setCharVar("BCNM_Killed",0);
player:setCharVar("BCNM_Timer",0);
end
player:setCharVar(tostring(pZone) .. "_Runaway",1);
player:delStatusEffect(dsp.effect.BATTLEFIELD);
player:setCharVar(tostring(pZone) .. "_Runaway",0)
end
end;
| gpl-3.0 |
lcf8858/Sample_Lua | frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/PhysicsBody.lua | 10 | 16743 |
--------------------------------
-- @module PhysicsBody
-- @extend Ref
-- @parent_module cc
--------------------------------
-- whether this physics body is affected by the physics world’s gravitational force.
-- @function [parent=#PhysicsBody] isGravityEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- reset all the force applied to body.
-- @function [parent=#PhysicsBody] resetForces
-- @param self
--------------------------------
-- get the max of velocity
-- @function [parent=#PhysicsBody] getVelocityLimit
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- set the group of body<br>
-- Collision groups let you specify an integral group index. You can have all fixtures with the same group index always collide (positive index) or never collide (negative index)<br>
-- it have high priority than bit masks
-- @function [parent=#PhysicsBody] setGroup
-- @param self
-- @param #int group
--------------------------------
-- get the body mass.
-- @function [parent=#PhysicsBody] getMass
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- Return bitmask of first shape, if there is no shape in body, return default value.(0xFFFFFFFF)
-- @function [parent=#PhysicsBody] getCollisionBitmask
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- set the body rotation offset
-- @function [parent=#PhysicsBody] getRotationOffset
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- get the body rotation.
-- @function [parent=#PhysicsBody] getRotation
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- get the body moment of inertia.
-- @function [parent=#PhysicsBody] getMoment
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @overload self, vec2_table, vec2_table
-- @overload self, vec2_table
-- @function [parent=#PhysicsBody] applyImpulse
-- @param self
-- @param #vec2_table impulse
-- @param #vec2_table offset
--------------------------------
-- set body rotation offset, it's the rotation witch relative to node
-- @function [parent=#PhysicsBody] setRotationOffset
-- @param self
-- @param #float rotation
--------------------------------
-- @overload self, vec2_table, vec2_table
-- @overload self, vec2_table
-- @function [parent=#PhysicsBody] applyForce
-- @param self
-- @param #vec2_table force
-- @param #vec2_table offset
--------------------------------
--
-- @function [parent=#PhysicsBody] addShape
-- @param self
-- @param #cc.PhysicsShape shape
-- @param #bool addMassAndMoment
-- @return PhysicsShape#PhysicsShape ret (return value: cc.PhysicsShape)
--------------------------------
-- Applies a torque force to body.
-- @function [parent=#PhysicsBody] applyTorque
-- @param self
-- @param #float torque
--------------------------------
-- get the max of angular velocity
-- @function [parent=#PhysicsBody] getAngularVelocityLimit
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- set the max of angular velocity
-- @function [parent=#PhysicsBody] setAngularVelocityLimit
-- @param self
-- @param #float limit
--------------------------------
-- get the velocity of a body
-- @function [parent=#PhysicsBody] getVelocity
-- @param self
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- get linear damping.
-- @function [parent=#PhysicsBody] getLinearDamping
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
--
-- @function [parent=#PhysicsBody] removeAllShapes
-- @param self
--------------------------------
-- set angular damping.<br>
-- it is used to simulate fluid or air friction forces on the body.<br>
-- the value is 0.0f to 1.0f.
-- @function [parent=#PhysicsBody] setAngularDamping
-- @param self
-- @param #float damping
--------------------------------
-- set the max of velocity
-- @function [parent=#PhysicsBody] setVelocityLimit
-- @param self
-- @param #float limit
--------------------------------
-- set body to rest
-- @function [parent=#PhysicsBody] setResting
-- @param self
-- @param #bool rest
--------------------------------
-- get body position offset.
-- @function [parent=#PhysicsBody] getPositionOffset
-- @param self
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- A mask that defines which categories this physics body belongs to.<br>
-- Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and contactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions.<br>
-- The default value is 0xFFFFFFFF (all bits set).
-- @function [parent=#PhysicsBody] setCategoryBitmask
-- @param self
-- @param #int bitmask
--------------------------------
-- get the world body added to.
-- @function [parent=#PhysicsBody] getWorld
-- @param self
-- @return PhysicsWorld#PhysicsWorld ret (return value: cc.PhysicsWorld)
--------------------------------
-- get the angular velocity of a body
-- @function [parent=#PhysicsBody] getAngularVelocity
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- get the body position.
-- @function [parent=#PhysicsBody] getPosition
-- @param self
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- set the enable value.<br>
-- if the body it isn't enabled, it will not has simulation by world
-- @function [parent=#PhysicsBody] setEnable
-- @param self
-- @param #bool enable
--------------------------------
-- set the body is affected by the physics world's gravitational force or not.
-- @function [parent=#PhysicsBody] setGravityEnable
-- @param self
-- @param #bool enable
--------------------------------
-- Return group of first shape, if there is no shape in body, return default value.(0)
-- @function [parent=#PhysicsBody] getGroup
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- brief set the body moment of inertia.<br>
-- note if you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead.
-- @function [parent=#PhysicsBody] setMoment
-- @param self
-- @param #float moment
--------------------------------
-- get the body's tag
-- @function [parent=#PhysicsBody] getTag
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- convert the local point to world
-- @function [parent=#PhysicsBody] local2World
-- @param self
-- @param #vec2_table point
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- Return bitmask of first shape, if there is no shape in body, return default value.(0xFFFFFFFF)
-- @function [parent=#PhysicsBody] getCategoryBitmask
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- brief set dynamic to body.<br>
-- a dynamic body will effect with gravity.
-- @function [parent=#PhysicsBody] setDynamic
-- @param self
-- @param #bool dynamic
--------------------------------
--
-- @function [parent=#PhysicsBody] getFirstShape
-- @param self
-- @return PhysicsShape#PhysicsShape ret (return value: cc.PhysicsShape)
--------------------------------
--
-- @function [parent=#PhysicsBody] getShapes
-- @param self
-- @return array_table#array_table ret (return value: array_table)
--------------------------------
-- Return bitmask of first shape, if there is no shape in body, return default value.(0x00000000)
-- @function [parent=#PhysicsBody] getContactTestBitmask
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- set the angular velocity of a body
-- @function [parent=#PhysicsBody] setAngularVelocity
-- @param self
-- @param #float velocity
--------------------------------
-- convert the world point to local
-- @function [parent=#PhysicsBody] world2Local
-- @param self
-- @param #vec2_table point
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- whether the body is enabled<br>
-- if the body it isn't enabled, it will not has simulation by world
-- @function [parent=#PhysicsBody] isEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @overload self, int, bool
-- @overload self, cc.PhysicsShape, bool
-- @function [parent=#PhysicsBody] removeShape
-- @param self
-- @param #cc.PhysicsShape shape
-- @param #bool reduceMassAndMoment
--------------------------------
-- brief set the body mass.<br>
-- note if you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead.
-- @function [parent=#PhysicsBody] setMass
-- @param self
-- @param #float mass
--------------------------------
-- brief add moment of inertia to body.<br>
-- if _moment(moment of the body) == PHYSICS_INFINITY, it remains.<br>
-- if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY.<br>
-- if moment == -PHYSICS_INFINITY, _moment will not change.<br>
-- if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0)<br>
-- other wise, moment = moment + _moment;
-- @function [parent=#PhysicsBody] addMoment
-- @param self
-- @param #float moment
--------------------------------
-- set the velocity of a body
-- @function [parent=#PhysicsBody] setVelocity
-- @param self
-- @param #vec2_table velocity
--------------------------------
-- set linear damping.<br>
-- it is used to simulate fluid or air friction forces on the body. <br>
-- the value is 0.0f to 1.0f.
-- @function [parent=#PhysicsBody] setLinearDamping
-- @param self
-- @param #float damping
--------------------------------
-- A mask that defines which categories of physics bodies can collide with this physics body.<br>
-- When two physics bodies contact each other, a collision may occur. This body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a non-zero value, then this body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example, you might use this to avoid collision calculations that would make negligible changes to a body’s velocity.<br>
-- The default value is 0xFFFFFFFF (all bits set).
-- @function [parent=#PhysicsBody] setCollisionBitmask
-- @param self
-- @param #int bitmask
--------------------------------
-- set body position offset, it's the position witch relative to node
-- @function [parent=#PhysicsBody] setPositionOffset
-- @param self
-- @param #vec2_table position
--------------------------------
-- set the body is allow rotation or not
-- @function [parent=#PhysicsBody] setRotationEnable
-- @param self
-- @param #bool enable
--------------------------------
-- whether the body can rotation
-- @function [parent=#PhysicsBody] isRotationEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- get angular damping.
-- @function [parent=#PhysicsBody] getAngularDamping
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- get the angular velocity of a body at a local point
-- @function [parent=#PhysicsBody] getVelocityAtLocalPoint
-- @param self
-- @param #vec2_table point
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- whether the body is at rest
-- @function [parent=#PhysicsBody] isResting
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- brief add mass to body.<br>
-- if _mass(mass of the body) == PHYSICS_INFINITY, it remains.<br>
-- if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY.<br>
-- if mass == -PHYSICS_INFINITY, _mass will not change.<br>
-- if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0)<br>
-- other wise, mass = mass + _mass;
-- @function [parent=#PhysicsBody] addMass
-- @param self
-- @param #float mass
--------------------------------
--
-- @function [parent=#PhysicsBody] getShape
-- @param self
-- @param #int tag
-- @return PhysicsShape#PhysicsShape ret (return value: cc.PhysicsShape)
--------------------------------
-- set the body's tag
-- @function [parent=#PhysicsBody] setTag
-- @param self
-- @param #int tag
--------------------------------
-- get the angular velocity of a body at a world point
-- @function [parent=#PhysicsBody] getVelocityAtWorldPoint
-- @param self
-- @param #vec2_table point
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- A mask that defines which categories of bodies cause intersection notifications with this physics body.<br>
-- When two bodies share the same space, each body’s category mask is tested against the other body’s contact mask by performing a logical AND operation. If either comparison results in a non-zero value, an PhysicsContact object is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask for interactions you are interested in.<br>
-- The default value is 0x00000000 (all bits cleared).
-- @function [parent=#PhysicsBody] setContactTestBitmask
-- @param self
-- @param #int bitmask
--------------------------------
-- remove the body from the world it added to
-- @function [parent=#PhysicsBody] removeFromWorld
-- @param self
--------------------------------
-- brief test the body is dynamic or not.<br>
-- a dynamic body will effect with gravity.
-- @function [parent=#PhysicsBody] isDynamic
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- get the sprite the body set to.
-- @function [parent=#PhysicsBody] getNode
-- @param self
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- Create a body contains a box shape.
-- @function [parent=#PhysicsBody] createBox
-- @param self
-- @param #size_table size
-- @param #cc.PhysicsMaterial material
-- @param #vec2_table offset
-- @return PhysicsBody#PhysicsBody ret (return value: cc.PhysicsBody)
--------------------------------
-- Create a body contains a EdgeSegment shape.
-- @function [parent=#PhysicsBody] createEdgeSegment
-- @param self
-- @param #vec2_table a
-- @param #vec2_table b
-- @param #cc.PhysicsMaterial material
-- @param #float border
-- @return PhysicsBody#PhysicsBody ret (return value: cc.PhysicsBody)
--------------------------------
-- @overload self, float
-- @overload self
-- @overload self, float, float
-- @function [parent=#PhysicsBody] create
-- @param self
-- @param #float mass
-- @param #float moment
-- @return PhysicsBody#PhysicsBody ret (return value: cc.PhysicsBody)
--------------------------------
-- Create a body contains a EdgeBox shape.
-- @function [parent=#PhysicsBody] createEdgeBox
-- @param self
-- @param #size_table size
-- @param #cc.PhysicsMaterial material
-- @param #float border
-- @param #vec2_table offset
-- @return PhysicsBody#PhysicsBody ret (return value: cc.PhysicsBody)
--------------------------------
-- Create a body contains a circle shape.
-- @function [parent=#PhysicsBody] createCircle
-- @param self
-- @param #float radius
-- @param #cc.PhysicsMaterial material
-- @param #vec2_table offset
-- @return PhysicsBody#PhysicsBody ret (return value: cc.PhysicsBody)
return nil
| mit |
tsdfsetatata/xserver | config/server/P20018Table.lua | 1 | 1317 | local P20018Table = {
[350401001] = {
['ID'] = 350401001, --索引
['TypeID'] = 4, --脚本ID
['Parameter1'] = {154000011}, --参数1
['Parameter2'] = {''} --参数2
},
[350401002] = {
['ID'] = 350401002,
['TypeID'] = 2,
['Parameter1'] = {151005019},
['Parameter2'] = {''}
},
[350401003] = {
['ID'] = 350401003,
['TypeID'] = 2,
['Parameter1'] = {151005020},
['Parameter2'] = {''}
},
[350401004] = {
['ID'] = 350401004,
['TypeID'] = 12,
['Parameter1'] = {154000011,5},
['Parameter2'] = {''}
},
[350401005] = {
['ID'] = 350401005,
['TypeID'] = 2,
['Parameter1'] = {151005021},
['Parameter2'] = {''}
},
[350401006] = {
['ID'] = 350401006,
['TypeID'] = 2,
['Parameter1'] = {151005046},
['Parameter2'] = {''}
},
[350401007] = {
['ID'] = 350401007,
['TypeID'] = 2,
['Parameter1'] = {151005047},
['Parameter2'] = {''}
},
[350401008] = {
['ID'] = 350401008,
['TypeID'] = 12,
['Parameter1'] = {154000011,30},
['Parameter2'] = {''}
},
[350401009] = {
['ID'] = 350401009,
['TypeID'] = 9,
['Parameter1'] = {2},
['Parameter2'] = {''}
},
[350401010] = {
['ID'] = 350401010,
['TypeID'] = 27,
['Parameter1'] = {},
['Parameter2'] = {''}
}
}
return P20018Table
| gpl-3.0 |
hedgewars/hw | share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua | 1 | 50989 | --[[
A Classic Fairytale: Backstab
= SUMMARY =
It is revealed that there's a traitor among the natives.
Player decides whether to kill him or not.
After this, the natives must defeat 3 waves of cannibals.
= FLOW CHART =
== Linear events ==
- Cut scene: startScene (traitor is revealed)
- Player is instructed to decide what to do with the traitor
| Player kills traitor
- Cut scene: afterChoiceAnim
| Player spares traitor (skips turn or moves too far away)
- Cut scene: afterChoiceAnim (different)
| Player kills any other hog or own hog
> Game over
- First turn of cannibals
- TBS
- First wave of cannibals dead
- Cut scene: wave2Anim
- Spawn 2nd cannibal wave
- TBS
- 2nd wave dead
- Cut scene: wave2DeadAnim
- All natives but one are encaged
- 7 turns till arrival of 3rd wave
- Arrival points are marked with circles
- One hero is deployed near the circles
- Player now only controls the hero, switch hog is removed
- TBS
- 3rd wave appears at end of 7th turn
- TBS
- 3rd wave dead
- Final cut scene
> Victory
=== The traitor ===
The traitor is chosen based on the past player decisions in the campaign.
== Non-linear events ==
| Any native hog dies after traitor decision:
- Another hog (if alive) mourns the loss
]]
HedgewarsScriptLoad("/Scripts/Locale.lua")
HedgewarsScriptLoad("/Scripts/Animate.lua")
HedgewarsScriptLoad("/Scripts/Utils.lua")
-----------------------------Constants---------------------------------
choiceAccepted = 1
choiceRefused = 2
choiceAttacked = 3
choiceEliminate = 1
choiceSpare = 2
leaksNum = 1
denseNum = 2
waterNum = 3
buffaloNum = 4
chiefNum = 5
girlNum = 6
wiseNum = 7
spyKillStage = 1
platformStage = 2
wave3Stage = 3
tmpVar = 0
nativeNames = {loc("Leaks A Lot"), loc("Dense Cloud"), loc("Fiery Water"),
loc("Raging Buffalo"), loc("Righteous Beard"), loc("Fell From Grace"),
loc("Wise Oak"), loc("Eagle Eye"), loc("Flaming Worm")}
nativeHats = {"Rambo", "RobinHood", "pirate_jack", "zoo_Bunny", "IndianChief",
"tiara", "AkuAku", "None", "None"}
nativePos = {{887, 329}, {1050, 288}, {1731, 707},
{830, 342}, {1001, 290}, {773, 340},
{953, 314}, {347, 648}, {314, 647}}
nativeDir = {"Right", "Left", "Left",
"Right", "Left", "Right",
"Left", "Right", "Right"}
cannibalNames = {loc("Brain Teaser"), loc("Bone Jackson"), loc("Gimme Bones"),
loc("Hedgibal Lecter"), loc("Bloodpie"), loc("Scalp Muncher"),
loc("Back Breaker"), loc("Dahmer"), loc("Meiwes"),
loc("Ear Sniffer"), loc("Regurgitator"), loc("Muriel")}
cannibalPos = {{3607, 1472}, {3612, 1487}, {3646, 1502},
{3507, 195}, {3612, 1487}, {840, 1757},
{3056, 1231}, {2981, 1222}, {2785, 1258}}
cannibalDir = {"Left", "Left", "Left",
"Left", "Right", "Right",
"Left", "Left", "Left"}
cyborgPos = {1369, 574}
cyborgPos2 = {1308, 148}
deployedPos = {2522, 1372}
-----------------------------Variables---------------------------------
natives = {}
nativeDead = {}
nativeHidden = {}
nativeRevived = {}
nativesNum = 0
cannibals = {}
cannibalDead = {}
cannibalHidden = {}
speakerHog = nil
spyHog = nil
deployedHog = nil
deployedDead = false
nativesTeleported = false
nativesIsolated = false
hogDeployed = false
cyborgHidden = false
needToAct = 0
m2Choice = 0
m4DenseDead = 0
m4BuffaloDead = 0
m4WaterDead = 0
m4ChiefDead = 0
m4LeaksDead = 0
needRevival = false
gearr = nil
startElimination = 0
stage = 0
choice = 0
highJumped = false
wave3TurnsLeft = nil
startNativesNum = 0
nativesTeamName = nil
tribeTeamName = nil
cyborgTeamName = nil
cannibalsTeamName1 = nil
cannibalsTeamName2 = nil
runawayX, runawayY = 1932, 829
startAnim = {}
afterChoiceAnim = {}
wave2Anim = {}
wave2DeadAnim = {}
wave3DeadAnim = {}
vCircs = {}
trackedNonCyborgGears = {}
-----------------------------Animations--------------------------------
function Wave2Reaction()
local i = 1
local gearr = nil
while nativeDead[i] == true do
i = i + 1
end
gearr = natives[i]
if nativeDead[denseNum] ~= true and band(GetState(natives[denseNum]), gstDrowning) == 0 then
AnimInsertStepNext({func = AnimCustomFunction, args = {dense, EmitDenseClouds, {"Left"}}})
AnimInsertStepNext({func = AnimTurn, args = {dense, "Left"}})
end
if nativeDead[buffaloNum] ~= true and band(GetState(natives[buffaloNum]), gstDrowning) == 0 then
AnimInsertStepNext({func = AnimSay, args = {natives[buffaloNum], loc("Let them have a taste of my fury!"), SAY_SHOUT, 6000}})
end
AnimInsertStepNext({func = AnimSay, args = {gearr, loc("There's more of them? When did they become so hungry?"), SAY_SHOUT, 8000}})
end
function EmitDenseClouds(dir)
local dif
if dir == "Left" then
dif = 10
else
dif = -10
end
AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false})
AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false})
AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false})
AnimInsertStepNext({func = AnimWait, args = {natives[denseNum], 800}})
AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false})
AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false})
AnimInsertStepNext({func = AnimWait, args = {natives[denseNum], 800}})
AnimInsertStepNext({func = AnimVisualGear, args = {natives[denseNum], GetX(natives[denseNum]) + dif, GetY(natives[denseNum]) + dif, vgtSteam, 0, true}, swh = false})
end
function SaySafe()
local i = 1
while gearr == nil do
if nativeDead[i] ~= true and nativeHidden[i] ~= true then
gearr = natives[i]
end
i = i + 1
end
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("We are indeed."), SAY_SAY, 2500}})
AnimInsertStepNext({func = AnimSay, args = {gearr, loc("I think we are safe here."), SAY_SAY, 4000}})
end
function ReviveNatives()
for i = 1, 7 do
if nativeHidden[i] == true and nativeDead[i] ~= true then
RestoreHog(natives[i])
nativeHidden[i] = false
nativeRevived[i] = true
AnimInsertStepNext({func = AnimOutOfNowhere, args = {natives[i], unpack(nativePos[i])}})
end
end
end
function WonderAlive()
if nativeRevived[waterNum] == true then
AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("I'm...alive? How? Why?"), SAY_THINK, 3500}})
AnimInsertStepNext({func = AnimWait, args = {natives[waterNum], 800}})
AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Left"}})
AnimInsertStepNext({func = AnimWait, args = {natives[waterNum], 800}})
AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Right"}})
end
if nativeRevived[leaksNum] == true and nativeRevived[denseNum] == true then
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("But why would they help us?"), SAY_SAY, 4000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("It must be the aliens!"), SAY_SAY, 3500}})
AnimInsertStepNext({func = AnimSay, args = {natives[girlNum], loc("You just appeared out of thin air!"), SAY_SAY, 5000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("But...we died!"), SAY_SAY, 2500}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("This must be the caves!"), SAY_SAY, 3500}})
AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Dude, where are we?"), SAY_SAY, 3000}})
AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}})
AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Right"}})
AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Left"}})
AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}})
AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Left"}})
AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Right"}})
AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}})
AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Right"}})
AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Left"}})
AnimInsertStepNext({func = AnimWait, args = {natives[leaksNum], 800}})
AnimInsertStepNext({func = AnimTurn, args = {natives[leaksNum], "Left"}})
AnimInsertStepNext({func = AnimTurn, args = {natives[denseNum], "Right"}})
AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {natives[leaksNum], natives[girlNum]}}})
if nativeDead[chiefNum] ~= true then
AnimInsertStepNext({func = AnimTurn, args = {natives[chiefNum], "Right"}})
end
elseif nativeRevived[leaksNum] == true then
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Why would they do this?"), SAY_SAY, 6000}})
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("It must be the aliens' deed."), SAY_SAY, 5000}})
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("Do not laugh, inexperienced one, for he speaks the truth!"), SAY_SAY, 10000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Yeah, sure! I died. Hilarious!"), SAY_SAY, 6000}})
AnimInsertStepNext({func = AnimSay, args = {gearr, loc("You're...alive!? But we saw you die!"), SAY_SAY, 6000}})
AnimInsertStepNext({func = AnimSay, args = {gearr, loc("Huh?"), SAY_SAY, 2000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Wow, what a dream!"), SAY_SAY, 3000}})
if nativeDead[chiefNum] ~= true then
AnimInsertStepNext({func = AnimTurn, args = {natives[chiefNum], "Right"}})
end
AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {natives[leaksNum], natives[wiseNum]}}})
AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {natives[leaksNum], gearr}}})
elseif nativeRevived[denseNum] == true then
AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Dude, that's so cool!"), SAY_SAY, 3000}})
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("It must be the aliens' deed."), SAY_SAY, 5000}})
AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("But that's impossible!"), SAY_SAY, 3000}})
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("It was not a dream, unwise one!"), SAY_SAY, 5000}})
AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Exactly, man! That was my dream."), SAY_SAY, 5000}})
AnimInsertStepNext({func = AnimSay, args = {gearr, loc("You're...alive!? But we saw you die!"), SAY_SAY, 6000}})
AnimInsertStepNext({func = AnimSay, args = {gearr, loc("Huh?"), SAY_SAY, 2000}})
AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Dude, wow! I just had the weirdest high!"), SAY_SAY, 6000}})
if nativeDead[chiefNum] ~= true then
AnimInsertStepNext({func = AnimTurn, args = {natives[chiefNum], "Right"}})
end
AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[denseNum], CondNeedToTurn, {natives[denseNum], natives[wiseNum]}}})
AnimInsertStepNext({func = AnimCustomFunction, swh = false, args = {natives[denseNum], CondNeedToTurn, {natives[denseNum], gearr}}})
end
end
function ExplainAlive()
if needRevival == true and m4WaterDead == 1 then
RestoreCyborg()
AnimSetGearPosition(cyborg, unpack(cyborgPos))
AnimInsertStepNext({func = AnimCustomFunction, args = {water, HideCyborg, {}}})
AnimInsertStepNext({func = AnimSwitchHog, args = {water}})
AnimInsertStepNext({func = AnimSay, args = {cyborg, loc("The answer is ... entertainment. You'll see what I mean."), SAY_SAY, 8000}})
AnimInsertStepNext({func = AnimSay, args = {cyborg, loc("You're probably wondering why I brought you back ..."), SAY_SAY, 8000}})
end
end
function SpyDebate()
if m2Choice == choiceAccepted then
spyHog = natives[denseNum]
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("What shall we do with the traitor?"), SAY_SAY, 6000}})
AnimInsertStepNext({func = SetHealth, swh = false, args = {natives[denseNum], 26}})
AnimInsertStepNext({func = AnimVisualGear, args = {natives[wiseNum], GetGearPosition(natives[denseNum]), vgtExplosion, 0, true}})
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("Here, let me help you!"), SAY_SAY, 3000}})
if nativeDead[chiefNum] == true then
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("I forgot that she's the daughter of the chief, too..."), SAY_THINK, 7000}})
AnimInsertStepNext({func = AnimSay, args = {natives[girlNum], loc("You killed my father, you monster!"), SAY_SAY, 5000}})
end
AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("Look, I had no choice!"), SAY_SAY, 3000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("You have been giving us out to the enemy, haven't you!"), SAY_SAY, 7000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("You're a pathetic liar!"), SAY_SAY, 3000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Interesting! Last time you said you killed a cannibal!"), SAY_SAY, 7000}})
AnimInsertStepNext({func = AnimSay, args = {natives[denseNum], loc("I told you, I just found them."), SAY_SAY, 4500}})
AnimInsertStepNext({func = AnimCustomFunction, args = {natives[denseNum], EmitDenseClouds, {"Left"}}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Where did you get the weapons in the forest, Dense Cloud?"), SAY_SAY, 8000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Not now, Fiery Water!"), SAY_SAY, 3000}})
else
spyHog = natives[waterNum]
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("What shall we do with the traitor?"), SAY_SAY, 5000}})
AnimInsertStepNext({func = SetHealth, swh = false, args = {natives[waterNum], 26}})
AnimInsertStepNext({func = AnimVisualGear, args = {natives[wiseNum], nativePos[denseNum][1] + 50, nativePos[denseNum][2], vgtExplosion, 0, true}})
AnimInsertStepNext({func = AnimSay, args = {natives[girlNum], loc("I can't believe what I'm hearing!"), SAY_SAY, 5500}})
AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("You know what? I don't even regret anything!"), SAY_SAY, 7000}})
AnimInsertStepNext({func = AnimSay, args = {natives[girlNum], loc("In fact, you are the only one that's been acting strangely."), SAY_SAY, 8000}})
AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("Are you accusing me of something?"), SAY_SAY, 3500}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Seems like every time you take a \"walk\", the enemy finds us!"), SAY_SAY, 8000}})
AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("You know...taking a stroll."), SAY_SAY, 3500}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("Where have you been?!"), SAY_SAY, 3000}})
end
if nativeRevived[waterNum] == true then
AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("You won't believe what happened to me!"), SAY_SAY, 5500}})
end
AnimInsertStepNext({func = AnimSay, args = {natives[waterNum], loc("Hey, guys!"), SAY_SAY, 2000}})
AnimInsertStepNext({func = AnimMove, args = {natives[waterNum], "Left", nativePos[denseNum][1] + 50, nativePos[denseNum][2]}})
AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "back"}})
AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Right"}})
AnimInsertStepNext({func = AnimMove, args = {natives[waterNum], "Left", 1228, 412}})
AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "long"}})
AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "long"}})
AnimInsertStepNext({func = AnimJump, args = {natives[waterNum], "long"}})
AnimInsertStepNext({func = AnimTurn, args = {natives[waterNum], "Left"}})
AnimInsertStepNext({func = AnimSay, args = {natives[wiseNum], loc("There must be a spy among us!"), SAY_SAY, 4000}})
AnimInsertStepNext({func = AnimSay, args = {natives[girlNum], loc("We made sure noone followed us!"), SAY_SAY, 4000}})
AnimInsertStepNext({func = AnimSay, args = {natives[leaksNum], loc("What? Here? How did they find us?!"), SAY_SAY, 5000}})
end
function AnimationSetup()
table.insert(startAnim, {func = AnimWait, swh = false, args = {natives[leaksNum], 3000}})
table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], SaySafe, {}}})
if needRevival == true then
table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, ReviveNatives, {}}})
table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], WonderAlive, {}}})
table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, ExplainAlive, {}}})
end
table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], RestoreWave, {1}}})
table.insert(startAnim, {func = AnimOutOfNowhere, args = {cannibals[1], unpack(cannibalPos[1])}})
table.insert(startAnim, {func = AnimOutOfNowhere, args = {cannibals[2], unpack(cannibalPos[2])}})
table.insert(startAnim, {func = AnimOutOfNowhere, args = {cannibals[3], unpack(cannibalPos[3])}})
table.insert(startAnim, {func = AnimWait, args = {natives[leaksNum], 1000}})
table.insert(startAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], SpyDebate, {}}})
AddSkipFunction(startAnim, SkipStartAnim, {})
end
function SetupWave2Anim()
for i = 7, 1, -1 do
if nativeDead[i] ~= true then
speakerHog = natives[i]
end
end
table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[4], unpack(cannibalPos[4])}})
table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[5], unpack(cannibalPos[5])}})
table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[6], unpack(cannibalPos[6])}})
table.insert(wave2Anim, {func = AnimSay, args = {speakerHog, loc("Look out! There's more of them!"), SAY_SHOUT, 5000}})
AddSkipFunction(wave2Anim, SkipWave2Anim, {})
end
function PutCircles()
if circlesPut then
return
end
vCircs[1] = AddVisualGear(0,0,vgtCircle,0,true)
vCircs[2] = AddVisualGear(0,0,vgtCircle,0,true)
vCircs[3] = AddVisualGear(0,0,vgtCircle,0,true)
SetVisualGearValues(vCircs[1], cannibalPos[7][1], cannibalPos[7][2], 100, 255, 1, 10, 0, 120, 3, 0xff00ffff)
SetVisualGearValues(vCircs[2], cannibalPos[8][1], cannibalPos[8][2], 100, 255, 1, 10, 0, 120, 3, 0xff00ffff)
SetVisualGearValues(vCircs[3], cannibalPos[9][1], cannibalPos[9][2], 100, 255, 1, 10, 0, 120, 3, 0xff00ffff)
circlesPut = true
end
function DeleteCircles()
for i=1, #vCircs do
DeleteVisualGear(vCircs[i])
end
end
function SetupWave2DeadAnim()
for i = 7, 1, -1 do
if nativeDead[i] ~= true then
deployedHog = natives[i]
end
end
if nativeDead[wiseNum] ~= true and band(GetState(natives[wiseNum]), gstDrowning) == 0 then
if nativesNum > 1 then
table.insert(wave2DeadAnim, {func = AnimWait, args = {natives[wiseNum], 1500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("What a strange feeling!"), SAY_THINK, 3000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I need to warn the others."), SAY_THINK, 3000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("If only I had a way..."), SAY_THINK, 3000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Oh, silly me! I forgot that I'm the shaman."), SAY_THINK, 6000}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], TeleportNatives, {}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], TurnNatives, {natives[wiseNum]}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], CondNeedToTurn, {natives[wiseNum], deployedHog}}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I sense another wave of cannibals heading our way!"), SAY_SAY, 6500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I feel something...a place! They will arrive near the circles!"), SAY_SAY, 7500}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], PutCircles, {}}})
table.insert(wave2DeadAnim, {func = AnimWait, args = {natives[wiseNum], 1500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("We need to prevent their arrival!"), SAY_SAY, 4500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Go, quick!"), SAY_SAY, 2500}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], DeployHog, {}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], RestoreCyborg, {}}})
table.insert(wave2DeadAnim, {func = AnimOutOfNowhere, swh = false, args = {cyborg, cyborgPos2[1], cyborgPos2[2]}})
table.insert(wave2DeadAnim, {func = AnimTurn, args = {cyborg, "Left"}})
if nativesNum > 1 then
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, IsolateNatives, {}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, PutCGI, {}}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I want to see how it handles this!"), SAY_SAY, 6000}})
end
table.insert(wave2DeadAnim, {func = AnimSwitchHog, args = {deployedHog}})
table.insert(wave2DeadAnim, {func = AnimDisappear, args = {cyborg, 0, 0}})
-- table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, DeployHog, {}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborg, {}}})
else
table.insert(wave2DeadAnim, {func = AnimWait, args = {natives[wiseNum], 1500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("What a strange feeling!"), SAY_THINK, 3000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I sense another wave of cannibals heading my way!"), SAY_THINK, 6500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I feel something...a place! They will arrive near the circles!"), SAY_SAY, 7500}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], PutCircles, {}}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I need to prevent their arrival!"), SAY_THINK, 4500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("If only I had a way..."), SAY_THINK, 3000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Oh, silly me! I forgot that I'm the shaman."), SAY_THINK, 6000}})
end
else
table.insert(wave2DeadAnim, {func = AnimWait, args = {cyborg, 1500}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, RestoreCyborg, {}}})
table.insert(wave2DeadAnim, {func = AnimOutOfNowhere, args = {cyborg, cyborgPos2[1], cyborgPos2[2]}})
table.insert(wave2DeadAnim, {func = AnimTurn, args = {cyborg, "Left"}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, TeleportNatives, {}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, TurnNatives, {cyborg}}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("Oh, my! This is even more entertaining than I've expected!"), SAY_SAY, 7500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("You might want to find a way to instantly kill arriving cannibals!"), SAY_SAY, 8000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I believe there's more of them."), SAY_SAY, 4000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I marked the place of their arrival. You're welcome!"), SAY_SAY, 6000}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], PutCircles, {}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {deployedHog, DeployHog, {}}})
if nativesNum > 1 then
-- table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], RestoreCyborg, {}}})
-- table.insert(wave2DeadAnim, {func = AnimOutOfNowhere, swh = false, args = {cyborg, cyborgPos2[1], cyborgPos2[2]}})
-- table.insert(wave2DeadAnim, {func = AnimTurn, args = {cyborg, "Left"}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, IsolateNatives, {}}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, PutCGI, {}}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I want to see how it handles this!"), SAY_SAY, 6000}})
end
table.insert(wave2DeadAnim, {func = AnimSwitchHog, args = {deployedHog}})
table.insert(wave2DeadAnim, {func = AnimDisappear, swh = false, args = {cyborg, 0, 0}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborg, {}}})
end
AddSkipFunction(wave2DeadAnim, SkipWave2DeadAnim, {})
end
function IsolateNatives()
if not nativesIsolated then
PlaceGirder(710, 299, 6)
PlaceGirder(690, 299, 6)
PlaceGirder(761, 209, 4)
PlaceGirder(921, 209, 4)
PlaceGirder(1081, 209, 4)
PlaceGirder(761, 189, 4)
PlaceGirder(921, 189, 4)
PlaceGirder(1081, 189, 4)
PlaceGirder(761, 169, 4)
PlaceGirder(921, 169, 4)
PlaceGirder(1081, 169, 4)
PlaceGirder(761, 149, 4)
PlaceGirder(921, 149, 4)
PlaceGirder(1081, 149, 4)
PlaceGirder(761, 129, 4)
PlaceGirder(921, 129, 4)
PlaceGirder(1081, 129, 4)
PlaceGirder(1120, 261, 2)
PlaceGirder(1140, 261, 2)
PlaceGirder(1160, 261, 2)
AddAmmo(deployedHog, amDEagle, 0)
AddAmmo(deployedHog, amFirePunch, 0)
nativesIsolated = true
end
end
-- Move camera to (x, y)
function MoveCameraCustom(x, y)
-- We use a dummy gear to feed FollowGear
local cameraGear = AddGear(x, y, gtGenericFaller, 0, 0, 0, 5000)
SetState(cameraGear, bor(GetState(cameraGear), gstNoGravity+gstInvisible))
FollowGear(cameraGear)
end
function PutCGI()
AddVisualGear(710, 299, vgtExplosion, 0, false)
AddVisualGear(690, 299, vgtExplosion, 0, false)
AddVisualGear(761, 209, vgtExplosion, 0, false)
AddVisualGear(921, 209, vgtExplosion, 0, false)
AddVisualGear(1081, 209, vgtExplosion, 0, false)
AddVisualGear(761, 189, vgtExplosion, 0, false)
AddVisualGear(921, 189, vgtExplosion, 0, false)
AddVisualGear(1081, 189, vgtExplosion, 0, false)
AddVisualGear(761, 169, vgtExplosion, 0, false)
AddVisualGear(921, 169, vgtExplosion, 0, false)
AddVisualGear(1081, 169, vgtExplosion, 0, false)
AddVisualGear(761, 149, vgtExplosion, 0, false)
AddVisualGear(921, 149, vgtExplosion, 0, false)
AddVisualGear(1081, 149, vgtExplosion, 0, false)
AddVisualGear(761, 129, vgtExplosion, 0, false)
AddVisualGear(921, 129, vgtExplosion, 0, false)
AddVisualGear(1081, 129, vgtExplosion, 0, false)
AddVisualGear(1120, 261, vgtExplosion, 0, false)
AddVisualGear(1140, 261, vgtExplosion, 0, false)
AddVisualGear(1160, 261, vgtExplosion, 0, false)
end
function TeleportNatives()
if not nativesTeleported then
nativePos[waterNum] = {1100, 288}
for i = 1, 7 do
if nativeDead[i] ~= true then
AnimTeleportGear(natives[i], unpack(nativePos[i]))
end
end
nativesTeleported = true
end
end
function TurnNatives(hog)
for i = 1, 7 do
if nativeDead[i] == false then
if GetX(natives[i]) < GetX(hog) then
AnimTurn(natives[i], "Right")
else
AnimTurn(natives[i], "Left")
end
end
end
end
function DeployHog()
if not hogDeployed then
-- Steal switch to force the deployed hog to be on its own
AddAmmo(deployedHog, amSwitch, 0)
AnimSwitchHog(deployedHog)
AnimTeleportGear(deployedHog, unpack(deployedPos))
if deployedHog ~= natives[wiseNum] then
AnimSay(deployedHog, loc("Why me?!"), SAY_THINK, 2000)
end
hogDeployed = true
end
end
function SetupAfterChoiceAnim()
for i = 7, 1, -1 do
if nativeDead[i] ~= true then
if natives[i] ~= spyHog then
speakerHog = natives[i]
end
end
end
if choice == choiceEliminate then
table.insert(afterChoiceAnim, {func = AnimWait, args = {speakerHog, 1500}})
table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("He won't be selling us out anymore!"), SAY_SAY, 6000}})
if nativeDead[girlNum] ~= true and m4ChiefDead == 1 then
table.insert(afterChoiceAnim, {func = AnimSay, args = {natives[girlNum], loc("That's for my father!"), SAY_SAY, 3500}})
end
table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("Let's show those cannibals what we're made of!"), SAY_SAY, 7000}})
else
table.insert(afterChoiceAnim, {func = AnimCustomFunction, swh = false, args = {natives[leaksNum], CondNeedToTurn, {speakerHog, spyHog}}})
table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("We'll spare your life for now!"), SAY_SAY, 4500}})
table.insert(afterChoiceAnim, {func = AnimSay, args = {spyHog, loc("May the spirits aid you in all your quests!"), SAY_SAY, 7000}})
table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("I just don't want to sink to your level."), SAY_SAY, 6000}})
table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("Let's show those cannibals what we're made of!"), SAY_SAY, 7000}})
end
table.insert(afterChoiceAnim, {func = AnimSay, args = {natives[8], loc("Let us help, too!"), SAY_SAY, 3000}})
table.insert(afterChoiceAnim, {func = AnimTurn, args = {speakerHog, "Left", SAY_SAY, 7000}})
table.insert(afterChoiceAnim, {func = AnimSay, args = {speakerHog, loc("No. You and the rest of the tribe are safer there!"), SAY_SAY, 7000}})
AddSkipFunction(afterChoiceAnim, SkipAfterChoiceAnim, {})
end
function SetupHogDeadAnim(gear)
hogDeadAnim = {}
if nativesNum == 0 then
return
end
local hogDeadStrings = {string.format(loc("They killed %s! You bastards!"), gear),
string.format(loc("%s! Why?!"), gear),
loc("That was just mean!"),
string.format(loc("Oh no, not %s!"), gear),
string.format(loc("Why %s? Why?"), gear),
string.format(loc("What has %s ever done to you?"), gear)}
table.insert(hogDeadAnim, {func = AnimSay, args = {CurrentHedgehog, hogDeadStrings[7 - nativesNum], SAY_SHOUT, 4000}})
end
function AfterHogDeadAnim()
freshDead = nil
SetTurnTimeLeft(TurnTime)
end
--------------------------Anim skip functions--------------------------
function AfterAfterChoiceAnim()
stage = 0
AddEvent(CheckWaveDead, {1}, DoWaveDead, {1}, 0)
AddAmmo(speakerHog, amSwitch, 100)
SetGearMessage(speakerHog, 0)
SetState(speakerHog, 0)
SetTurnTimeLeft(MAX_TURN_TIME)
ShowMission(loc("Backstab"), loc("The food bites back"), loc("Defeat the cannibals!"), 1, 4000)
SetAmmoDelay(amBlowTorch, 0)
SetAmmoDelay(amGirder, 0)
SetAmmoDelay(amLandGun, 0)
SetAmmoDelay(amRope, 0)
SetAmmoDelay(amParachute, 0)
SpawnCrates()
end
function SkipAfterChoiceAnim()
SetGearMessage(CurrentHedgehog, 0)
AnimSwitchHog(speakerHog)
end
function AfterWave2Anim()
AddEvent(CheckWaveDead, {2}, DoWaveDead, {2}, 0)
SetGearMessage(CurrentHedgehog, 0)
SetState(CurrentHedgehog, 0)
SpawnCrates()
SetTurnTimeLeft(TurnTime)
end
function SkipWave2DeadAnim()
TeleportNatives()
TurnNatives()
PutCircles()
DeployHog()
EndTurn(true)
if nativesNum > 1 then
IsolateNatives()
end
end
function SpawnPlatformCrates()
SpawnSupplyCrate(2494, 1262, amMine)
SpawnSupplyCrate(2574, 1279, amSMine)
SpawnSupplyCrate(2575, 1267, amMine)
SpawnSupplyCrate(2617, 1259, amSMine)
SpawnSupplyCrate(2579, 1254, amMine)
SpawnSupplyCrate(2478, 1243, amMine)
end
function AfterWave2DeadAnim()
stage = platformStage
SpawnPlatformCrates()
SetGearMessage(CurrentHedgehog, 0)
AddEvent(CheckWaveDead, {3}, DoWaveDead, {3}, 0)
AddEvent(CheckDeployedDead, {}, DoDeployedDead, {}, 0)
HideCyborg()
ShowMission(loc("Backstab"), loc("Drills"), loc("You have 7 turns until the next wave arrives.|Make sure the arriving cannibals are greeted appropriately!|If the hog dies, the cause is lost.|Hint: You might want to use some mines ..."), 1, 12000)
end
function DoTurnsOver()
stage = wave3Stage
RestoreWave(3, true)
DeleteCircles()
end
function SkipWave2Anim()
AnimSwitchHog(speakerHog)
end
function SkipStartAnim()
ReviveNatives()
AnimSetGearPosition(natives[waterNum], nativePos[denseNum][1] + 50, nativePos[denseNum][2])
RestoreWave(1)
SetGearMessage(CurrentHedgehog, 0)
SetState(CurrentHedgehog, 0)
if m2Choice == choiceAccepted then
spyHog = natives[denseNum]
else
spyHog = natives[waterNum]
end
SetHealth(spyHog, 26)
end
function AfterStartAnim()
AnimSwitchHog(natives[leaksNum])
stage = spyKillStage
AddEvent(CheckChoice, {}, DoChoice, {}, 0)
AddEvent(CheckKilledOther, {}, DoKilledOther, {}, 0)
AddEvent(CheckChoiceRefuse, {}, DoChoiceRefuse, {}, 0)
AddEvent(CheckChoiceRunaway, {}, DoChoiceRefuse, {}, 0)
ShowMission(loc("Backstab"), loc("Judas"),
string.format(loc("Kill the traitor, %s, or spare his life!"), GetHogName(spyHog)) .. "|" ..
loc("Kill him or skip your turn."),
3, 8000)
end
-----------------------------Events------------------------------------
function CheckDeployedDead()
return deployedDead
end
function DoDeployedDead()
ShowMission(loc("Backstab"), loc("Brutus"), loc("You have failed to save the tribe!"), -amSkip, 6000)
DismissTeam(nativesTeamName)
DismissTeam(tribeTeamName)
DismissTeam(cyborgTeamName)
EndTurn(true)
end
function CheckChoice()
return choice ~= 0 and tmpVar == 0
end
function CheckDeaths()
for i = 1, 7 do
if natives[i] ~= spyHog and band(GetState(natives[i]), gstAttacked) ~= 0 then
return true
end
end
return false
end
function DoChoice()
RemoveEventFunc(CheckChoiceRefuse)
RemoveEventFunc(CheckChoiceRunaway)
SetGearMessage(CurrentHedgehog, 0)
SetupAfterChoiceAnim()
AddAnim(afterChoiceAnim)
AddFunction({func = AfterAfterChoiceAnim, args = {}})
end
function CheckChoiceRefuse()
return GetHealth(CurrentHedgehog) and highJumped == true and StoppedGear(CurrentHedgehog)
end
function CheckChoiceRunaway()
return GetHealth(CurrentHedgehog) and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetHogTeamName(CurrentHedgehog) == nativesTeamName and GetX(CurrentHedgehog) >= runawayX and GetY(CurrentHedgehog) >= runawayY and StoppedGear(CurrentHedgehog)
end
function CheckChoiceRunawayAll()
for i= 1, 7 do
local hog = natives[i]
if hog ~= nil and GetHealth(hog) and hog ~= spyHog and GetX(hog) >= runawayX and GetY(hog) >= runawayY and StoppedGear(hog) then
return true
end
end
return false
end
function DoChoiceRefuse()
choice = choiceSpare
end
function CheckKilledOther()
if stage ~= spyKillStage then
return false
end
return (nativesNum < startNativesNum and choice ~= choiceEliminate) or
(nativesNum < startNativesNum - 1 and choice == choiceEliminate)
end
function DoKilledOther()
ShowMission(loc("Backstab"), loc("Brutus"), loc("You have killed an innocent hedgehog!"), -amSkip, 6000)
DismissTeam(nativesTeamName)
DismissTeam(tribeTeamName)
EndTurn(true)
end
function CheckWaveDead(index)
for i = (index - 1) * 3 + 1, index * 3 do
if cannibalDead[i] ~= true or CurrentHedgehog == cannibals[i] then
return false
end
end
return true
end
function DoWaveDead(index)
EndTurn(true)
needToAct = index
end
function AddWave3DeadAnim()
SetSoundMask(sndBoring, true)
AnimSwitchHog(deployedHog)
AnimWait(deployedHog, 1)
AddFunction({func = HideNatives, args = {}})
AddFunction({func = SetupWave3DeadAnim, args = {}})
AddFunction({func = AddAnim, args = {wave3DeadAnim}})
AddFunction({func = AddFunction, args = {{func = AfterWave3DeadAnim, args = {}}}})
end
function HideNatives()
for i = 1, 9 do
if nativeDead[i] ~= true and natives[i] ~= deployedHog then
if nativeHidden[i] ~= true then
HideHog(natives[i])
nativeHidden[i] = true
end
end
end
end
function SetupWave3DeadAnim()
table.insert(wave3DeadAnim, {func = AnimTurn, args = {deployedHog, "Left"}})
table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("That ought to show them!"), SAY_SAY, 4000}})
table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("Guys, do you think there's more of them?"), SAY_SHOUT, 5000}})
table.insert(wave3DeadAnim, {func = AnimCustomFunction, args = {deployedHog, MoveCameraCustom, {unpack(nativePos[wiseNum])}}})
table.insert(wave3DeadAnim, {func = AnimVisualGear, args = {deployedHog, unpack(nativePos[wiseNum]), vgtFeather, 0, true, true}})
table.insert(wave3DeadAnim, {func = AnimWait, args = {deployedHog, 1750}})
table.insert(wave3DeadAnim, {func = AnimCustomFunction, args = {deployedHog, FollowGear, {deployedHog}}})
table.insert(wave3DeadAnim, {func = AnimWait, args = {deployedHog, 100}})
table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("Where are they?!"), SAY_THINK, 3000}})
table.insert(wave3DeadAnim, {func = AnimCustomFunction, args = {deployedHog, RestoreCyborg, {}}})
table.insert(wave3DeadAnim, {func = AnimOutOfNowhere, args = {cyborg, 4040, 790}})
table.insert(wave3DeadAnim, {func = AnimSay, args = {cyborg, loc("These primitive people are so funny!"), SAY_THINK, 6500}})
table.insert(wave3DeadAnim, {func = AnimMove, args = {cyborg, "Right", 4060, 0, 7000}})
table.insert(wave3DeadAnim, {func = AnimSwitchHog, args = {deployedHog}})
table.insert(wave3DeadAnim, {func = AnimWait, args = {deployedHog, 1}})
table.insert(wave3DeadAnim, {func = AnimCustomFunction, args = {deployedHog, HideCyborg, {}}})
table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("I need to find the others!"), SAY_THINK, 4500}})
table.insert(wave3DeadAnim, {func = AnimSay, args = {deployedHog, loc("I have to follow that alien."), SAY_THINK, 4500}})
end
function SkipWave3DeadAnim()
AnimSwitchHog(deployedHog)
end
function AfterWave3DeadAnim()
if nativeDead[leaksNum] == true then
SaveCampaignVar("M5LeaksDead", "1")
else
SaveCampaignVar("M5LeaksDead", "0")
end
if nativeDead[denseNum] == true then
SaveCampaignVar("M5DenseDead", "1")
else
SaveCampaignVar("M5DenseDead", "0")
end
if nativeDead[waterNum] == true then
SaveCampaignVar("M5WaterDead", "1")
else
SaveCampaignVar("M5WaterDead", "0")
end
if nativeDead[buffaloNum] == true then
SaveCampaignVar("M5BuffaloDead", "1")
else
SaveCampaignVar("M5BuffaloDead", "0")
end
if nativeDead[girlNum] == true then
SaveCampaignVar("M5GirlDead", "1")
else
SaveCampaignVar("M5GirlDead", "0")
end
if nativeDead[wiseNum] == true then
SaveCampaignVar("M5WiseDead", "1")
else
SaveCampaignVar("M5WiseDead", "0")
end
if nativeDead[chiefNum] == true then
SaveCampaignVar("M5ChiefDead", "1")
else
SaveCampaignVar("M5ChiefDead", "0")
end
SaveCampaignVar("M5Choice", "" .. choice)
if progress and progress<5 then
SaveCampaignVar("Progress", "5")
end
for i = 1, 7 do
if natives[i] == deployedHog then
SaveCampaignVar("M5DeployedNum", "" .. i)
end
end
DismissTeam(tribeTeamName)
DismissTeam(cannibalsTeamName1)
DismissTeam(cannibalsTeamName2)
DismissTeam(cyborgTeamName)
EndTurn(true)
end
-----------------------------Misc--------------------------------------
function SpawnCrates()
SpawnSupplyCrate(0, 0, amDrill)
SpawnSupplyCrate(0, 0, amGrenade)
SpawnSupplyCrate(0, 0, amBazooka)
SpawnSupplyCrate(0, 0, amDynamite)
SpawnSupplyCrate(0, 0, amGrenade)
SpawnSupplyCrate(0, 0, amMine)
SpawnSupplyCrate(0, 0, amShotgun)
SpawnSupplyCrate(0, 0, amFlamethrower)
SpawnSupplyCrate(0, 0, amMolotov)
SpawnSupplyCrate(0, 0, amSMine)
SpawnSupplyCrate(0, 0, amMortar)
SpawnSupplyCrate(0, 0, amRope)
SpawnSupplyCrate(0, 0, amRope)
SpawnSupplyCrate(0, 0, amParachute)
SpawnSupplyCrate(0, 0, amParachute)
SetHealth(SpawnHealthCrate(0, 0), 25)
SetHealth(SpawnHealthCrate(0, 0), 25)
SetHealth(SpawnHealthCrate(0, 0), 25)
SetHealth(SpawnHealthCrate(0, 0), 25)
SetHealth(SpawnHealthCrate(0, 0), 25)
SetHealth(SpawnHealthCrate(0, 0), 25)
end
function RestoreWave(index, animate)
for i = (index - 1) * 3 + 1, index * 3 do
if cannibalHidden[i] == true then
RestoreHog(cannibals[i])
if animate then
AnimOutOfNowhere(cannibals[i], unpack(cannibalPos[i]))
else
AnimSetGearPosition(cannibals[i], unpack(cannibalPos[i]))
FollowGear(cannibals[i])
end
cannibalHidden[i] = false
end
end
end
function GetVariables()
progress = tonumber(GetCampaignVar("Progress"))
m2Choice = tonumber(GetCampaignVar("M2Choice")) or choiceRefused
m4DenseDead = tonumber(GetCampaignVar("M4DenseDead")) or 0
m4LeaksDead = tonumber(GetCampaignVar("M4LeaksDead")) or 0
m4ChiefDead = tonumber(GetCampaignVar("M4ChiefDead")) or 0
m4WaterDead = tonumber(GetCampaignVar("M4WaterDead")) or 0
m4BuffaloDead = tonumber(GetCampaignVar("M4BuffaloDead")) or 0
end
function HideCyborg()
if cyborgHidden == false then
HideHog(cyborg)
cyborgHidden = true
end
end
function RestoreCyborg()
if cyborgHidden == true then
RestoreHog(cyborg)
cyborgHidden = false
-- Clear mines and crates around cyborg
local vaporized = 0
for gear, _ in pairs(trackedNonCyborgGears) do
if GetHealth(gear) and GetHealth(cyborg) and gearIsInBox(gear, GetX(cyborg) - 50, GetY(cyborg) - 50, 100, 100) == true then
AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
DeleteGear(gear)
vaporized = vaporized + 1
end
end
if vaporized > 0 then
PlaySound(sndVaporize)
end
end
end
function SetupPlace()
startNativesNum = nativesNum
HideCyborg()
for i = 1, 9 do
HideHog(cannibals[i])
cannibalHidden[i] = true
end
if m4LeaksDead == 1 then
HideHog(natives[leaksNum])
nativeHidden[leaksNum] = true
needRevival = true
end
if m4DenseDead == 1 then
if m2Choice ~= choiceAccepted then
DeleteGear(natives[denseNum])
startNativesNum = startNativesNum - 1
nativeDead[denseNum] = true
else
HideHog(natives[denseNum])
nativeHidden[denseNum] = true
needRevival = true
end
end
if m4WaterDead == 1 then
HideHog(natives[waterNum])
nativeHidden[waterNum] = true
needRevival = true
end
if m4ChiefDead == 1 then
DeleteGear(natives[chiefNum])
startNativesNum = startNativesNum - 1
nativeDead[chiefNum] = true
AnimSetGearPosition(natives[girlNum], unpack(nativePos[buffaloNum]))
nativePos[girlNum] = nativePos[buffaloNum]
end
if m4BuffaloDead == 1 then
startNativesNum = startNativesNum - 1
nativeDead[buffaloNum] = true
DeleteGear(natives[buffaloNum])
end
PlaceGirder(3568, 1461, 1)
PlaceGirder(440, 523, 5)
PlaceGirder(350, 441, 1)
PlaceGirder(405, 553, 5)
PlaceGirder(316, 468, 1)
PlaceGirder(1319, 168, 0)
end
function SetupAmmo()
AddAmmo(natives[girlNum], amSwitch, 0)
end
function AddHogs()
tribeTeamName = AddTeam(loc("Tribe"), -2, "Bone", "Island", "HillBilly_qau", "cm_birdy")
SetTeamPassive(tribeTeamName, true)
for i = 8, 9 do
natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
end
nativesTeamName = AddMissionTeam(-2)
for i = 1, 7 do
natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
end
nativesNum = 7
cannibalsTeamName1 = AddTeam(loc("Assault Team"), -1, "skull", "Island", "Pirate_qau", "cm_vampire")
for i = 1, 6 do
cannibals[i] = AddHog(cannibalNames[i], 3, 50, "vampirichog")
end
cannibalsTeamName2 = AddTeam(loc("Reinforcements"), -1, "skull", "Island", "Pirate_qau", "cm_vampire")
for i = 7, 9 do
cannibals[i] = AddHog(cannibalNames[i], 2, 50, "vampirichog")
end
cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot_qau", "cm_binary")
cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
for i = 1, 9 do
AnimSetGearPosition(natives[i], unpack(nativePos[i]))
AnimTurn(natives[i], nativeDir[i])
end
AnimSetGearPosition(cyborg, 0, 0)
for i = 1, 9 do
AnimSetGearPosition(cannibals[i], cannibalPos[i][1], cannibalPos[i][2] + 40)
AnimTurn(cannibals[i], cannibalDir[i])
end
end
function CondNeedToTurn(hog1, hog2)
xl, xd = GetX(hog1), GetX(hog2)
if xl > xd then
AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}})
AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}})
elseif xl < xd then
AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}})
AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}})
end
end
-----------------------------Main Functions----------------------------
function onGameInit()
Seed = 2
GameFlags = gfSolidLand
TurnTime = 60000
CaseFreq = 0
MinesNum = 0
MinesTime = 3000
Explosives = 0
Map = "Cave"
Theme = "Nature"
WaterRise = 0
HealthDecrease = 0
AddHogs()
AnimInit()
end
function onGameStart()
GetVariables()
SetupAmmo()
SetupPlace()
AnimationSetup()
AddAnim(startAnim)
AddFunction({func = AfterStartAnim, args = {}})
SetAmmoDelay(amBlowTorch, 9999)
SetAmmoDelay(amGirder, 9999)
SetAmmoDelay(amLandGun, 9999)
SetAmmoDelay(amRope, 9999)
SetAmmoDelay(amParachute, 9999)
end
function onGameTick()
AnimUnWait()
if ShowAnimation() == false then
return
end
ExecuteAfterAnimations()
CheckEvents()
end
function onGearAdd(gear)
local gt = GetGearType(gear)
if gt == gtMine or gt == gtSMine or gt == gtAirMine or gt == gtCase then
trackedNonCyborgGears[gear] = true
end
end
function onGearDelete(gear)
local gt = GetGearType(gear)
if gt == gtMine or gt == gtSMine or gt == gtAirMine or gt == gtCase then
trackedNonCyborgGears[gear] = nil
end
for i = 1, 7 do
if gear == natives[i] then
if nativeDead[i] ~= true then
freshDead = nativeNames[i]
end
nativeDead[i] = true
nativesNum = nativesNum - 1
end
end
for i = 1, 9 do
if gear == cannibals[i] then
cannibalDead[i] = true
end
end
if gear == spyHog and stage == spyKillStage then
freshDead = nil
choice = choiceEliminate
tmpVar = 1
end
if gear == deployedHog then
deployedDead = true
end
end
function onAmmoStoreInit()
SetAmmo(amDEagle, 9, 0, 0, 0)
SetAmmo(amSniperRifle, 4, 0, 0, 0)
SetAmmo(amFirePunch, 9, 0, 0, 0)
SetAmmo(amWhip, 9, 0, 0, 0)
SetAmmo(amBaseballBat, 9, 0, 0, 0)
SetAmmo(amHammer, 9, 0, 0, 0)
SetAmmo(amLandGun, 9, 0, 0, 0)
SetAmmo(amSnowball, 8, 0, 0, 0)
SetAmmo(amGirder, 4, 0, 0, 2)
SetAmmo(amParachute, 4, 0, 0, 2)
SetAmmo(amSwitch, 8, 0, 0, 2)
SetAmmo(amSkip, 9, 0, 0, 0)
SetAmmo(amRope, 5, 0, 0, 3)
SetAmmo(amBlowTorch, 3, 0, 0, 3)
SetAmmo(amPickHammer, 0, 0, 0, 3)
SetAmmo(amLowGravity, 0, 0, 0, 2)
SetAmmo(amDynamite, 0, 0, 0, 3)
SetAmmo(amBazooka, 4, 0, 0, 4)
SetAmmo(amGrenade, 4, 0, 0, 4)
SetAmmo(amMine, 2, 0, 0, 2)
SetAmmo(amSMine, 2, 0, 0, 2)
SetAmmo(amMolotov, 2, 0, 0, 3)
SetAmmo(amFlamethrower, 2, 0, 0, 3)
SetAmmo(amShotgun, 4, 0, 0, 4)
SetAmmo(amTeleport, 0, 0, 0, 2)
SetAmmo(amDrill, 0, 0, 0, 4)
SetAmmo(amMortar, 0, 0, 0, 4)
end
j = 0
function onNewTurn()
tmpVar = 0
if AnimInProgress() then
SetTurnTimeLeft(MAX_TURN_TIME)
return
end
if stage == platformStage then
if wave3TurnsLeft == nil then
wave3TurnsLeft = 7
end
if wave3TurnsLeft > 0 then
-- Workaround for the FIXME below: Use capgrpAmmoinfo to overwrite the incorrect ammo display
AddCaption(string.format(loc("Turns until arrival: %d"), wave3TurnsLeft), capcolDefault, capgrpAmmoinfo)
end
end
if deployedHog then
if GetHogTeamName(CurrentHedgehog) == nativesTeamName then
-- FIXME: This screws up the selected weapon caption, as
-- this function does not update the selected display caption (workaround above)
AnimSwitchHog(deployedHog)
end
end
if stage == spyKillStage then
if GetHogTeamName(CurrentHedgehog) ~= nativesTeamName then
EndTurn(true)
else
if CurrentHedgehog == spyHog then
AnimSwitchHog(natives[leaksNum])
end
SetGearMessage(CurrentHedgehog, 0)
SetTurnTimeLeft(MAX_TURN_TIME)
if CheckChoiceRunawayAll() then
highJumped = true
end
end
else
if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
SetupHogDeadAnim(freshDead)
AddAnim(hogDeadAnim)
AddFunction({func = AfterHogDeadAnim, args = {}})
end
end
if needToAct > 0 then
if needToAct == 1 then
RestoreWave(2)
SetupWave2Anim()
AddAnim(wave2Anim)
AddFunction({func = AfterWave2Anim, args = {}})
elseif needToAct == 2 then
SetupWave2DeadAnim()
AddAnim(wave2DeadAnim)
AddFunction({func = AfterWave2DeadAnim, args = {}})
elseif needToAct == 3 then
AnimSwitchHog(deployedHog)
AddFunction({func = AddWave3DeadAnim, args = {}})
end
needToAct = 0
end
end
function onEndTurn()
if stage == platformStage and wave3TurnsLeft ~= nil then
wave3TurnsLeft = wave3TurnsLeft - 1
if wave3TurnsLeft == 0 then
DoTurnsOver()
end
end
end
function onPrecise()
if GameTime > 2500 and AnimInProgress() then
SetAnimSkip(true)
return
end
end
function onSkipTurn()
if stage == spyKillStage then
highJumped = true
end
end
function onGameResult(winner)
if winner == GetTeamClan(nativesTeamName) then
SendStat(siGameResult, loc("Mission succeeded!"))
else
SendStat(siGameResult, loc("Mission failed!"))
end
end
| gpl-2.0 |
Colettechan/darkstar | scripts/zones/Al_Zahbi/npcs/Famatar.lua | 27 | 3042 | -----------------------------------
-- Area: Al Zahbi
-- NPC: Famatar
-- Type: Imperial Gate Guard
-- @pos -105.538 0.999 75.456 48
-----------------------------------
package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/besieged");
require("scripts/zones/Al_Zahbi/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local merc_rank = getMercenaryRank(player);
if (merc_rank == 0) then
player:startEvent(0x00DB,npc);
else
maps = getMapBitmask(player);
if (getAstralCandescence() == 1) then
maps = maps + 0x80000000;
end
x,y,z,w = getImperialDefenseStats();
player:startEvent(0x00DA,player:getCurrency("imperial_standing"),maps,merc_rank,0,x,y,z,w);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x00DA and option >= 1 and option <= 2049) then
itemid = getISPItem(option);
player:updateEvent(0,0,0,canEquip(player,itemid));
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x00DA) then
if (option == 0 or option == 16 or option == 32 or option == 48) then -- player chose sanction.
if (option ~= 0) then
player:delCurrency("imperial_standing", 100);
end
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
local duration = getSanctionDuration(player);
local subPower = 0; -- getImperialDefenseStats()
player:addStatusEffect(EFFECT_SANCTION,option / 16,0,duration,subPower); -- effect size 1 = regen, 2 = refresh, 3 = food.
player:messageSpecial(SANCTION);
elseif (option % 256 == 17) then -- player bought one of the maps
id = 1862 + (option - 17) / 256;
player:addKeyItem(id);
player:messageSpecial(KEYITEM_OBTAINED,id);
player:delCurrency("imperial_standing", 1000);
elseif (option <= 2049) then -- player bought item
item, price = getISPItem(option)
if (player:getFreeSlotsCount() > 0) then
player:delCurrency("imperial_standing", price);
player:addItem(item);
player:messageSpecial(ITEM_OBTAINED,item);
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,item);
end
end
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Port_San_dOria/npcs/Maunadolace.lua | 13 | 1058 | -----------------------------------
-- Area: Port San d'Oria
-- NPC: Maunadolace
-- Type: Standard NPC
-- @zone: 232
-- @pos -22.800 -9.3 -148.645
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x02c9);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/serving_of_marbled_steak.lua | 18 | 1763 | -----------------------------------------
-- ID: 5157
-- Item: serving_of_marbled_steak
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Strength 6
-- Agility 1
-- Intelligence -3
-- Attack % 18
-- Attack Cap 95
-- Ranged ATT % 32
-- Ranged ATT Cap 95
-- Lizard Killer 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,5157);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 6);
target:addMod(MOD_AGI, 1);
target:addMod(MOD_INT, -3);
target:addMod(MOD_FOOD_ATTP, 18);
target:addMod(MOD_FOOD_ATT_CAP, 95);
target:addMod(MOD_FOOD_RATTP, 32);
target:addMod(MOD_FOOD_RATT_CAP, 95);
target:addMod(MOD_LIZARD_KILLER, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 6);
target:delMod(MOD_AGI, 1);
target:delMod(MOD_INT, -3);
target:delMod(MOD_FOOD_ATTP, 18);
target:delMod(MOD_FOOD_ATT_CAP, 95);
target:delMod(MOD_FOOD_RATTP, 32);
target:delMod(MOD_FOOD_RATT_CAP, 95);
target:delMod(MOD_LIZARD_KILLER, 5);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/effects/shock.lua | 1 | 1253 | -----------------------------------
--
-- EFFECT_SHOCK
--
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_REGEN_DOWN, effect:getPower());
target:addMod(MOD_MND, -getElementalDebuffStatDownFromDOT(effect:getPower()));
target:addMod(MOD_THUNDERRES, -15);
target:addMod(MOD_THUNDERDEF, -20);
target:addMod(MOD_WATERRES, -15);
target:addMod(MOD_WATERDEF, -20);
target:addMod(MOD_REGAIN_DOWN, 2);
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_REGAIN_DOWN, 2);
target:delMod(MOD_REGEN_DOWN, effect:getPower());
target:delMod(MOD_MND, -getElementalDebuffStatDownFromDOT(effect:getPower()));
target:delMod(MOD_THUNDERRES, -15);
target:delMod(MOD_THUNDERDEF, -20);
target:delMod(MOD_WATERRES, -15);
target:delMod(MOD_WATERDEF, -20);
end; | gpl-3.0 |
aleksijuvani/premake-core | modules/gmake2/tests/test_gmake2_pch.lua | 2 | 3078 | --
-- test_gmake2_pch.lua
-- Validate the setup for precompiled headers in makefiles.
-- (c) 2016-2017 Jason Perkins, Blizzard Entertainment and the Premake project
--
local p = premake
local suite = test.declare("gmake2_pch")
local p = premake
local gmake2 = p.modules.gmake2
local project = p.project
--
-- Setup and teardown
--
local wks, prj
function suite.setup()
os.chdir(_TESTS_DIR)
wks, prj = test.createWorkspace()
end
local function prepareVars()
local cfg = test.getconfig(prj, "Debug")
gmake2.cpp.pch(cfg)
end
local function prepareRules()
local cfg = test.getconfig(prj, "Debug")
gmake2.cpp.pchRules(cfg.project)
end
--
-- If no header has been set, nothing should be output.
--
function suite.noConfig_onNoHeaderSet()
prepareVars()
test.isemptycapture()
end
--
-- If a header is set, but the NoPCH flag is also set, then
-- nothing should be output.
--
function suite.noConfig_onHeaderAndNoPCHFlag()
pchheader "include/myproject.h"
flags "NoPCH"
prepareVars()
test.isemptycapture()
end
--
-- If a header is specified and the NoPCH flag is not set, then
-- the header can be used.
--
function suite.config_onPchEnabled()
pchheader "include/myproject.h"
prepareVars()
test.capture [[
PCH = include/myproject.h
PCH_PLACEHOLDER = $(OBJDIR)/$(notdir $(PCH))
GCH = $(PCH_PLACEHOLDER).gch
]]
end
--
-- The PCH can be specified relative the an includes search path.
--
function suite.pch_searchesIncludeDirs()
pchheader "premake.h"
includedirs { "../../../src/host" }
prepareVars()
test.capture [[
PCH = ../../../src/host/premake.h
]]
end
--
-- Verify the format of the PCH rules block for a C++ file.
--
function suite.buildRules_onCpp()
pchheader "include/myproject.h"
prepareRules()
test.capture [[
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) $(PCH_PLACEHOLDER)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) touch "$@"
else
$(SILENT) echo $null >> "$@"
endif
else
$(OBJECTS): | $(OBJDIR)
endif
]]
end
--
-- Verify the format of the PCH rules block for a C file.
--
function suite.buildRules_onC()
language "C"
pchheader "include/myproject.h"
prepareRules()
test.capture [[
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) $(PCH_PLACEHOLDER)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) touch "$@"
else
$(SILENT) echo $null >> "$@"
endif
else
$(OBJECTS): | $(OBJDIR)
endif
]]
end
--
-- If the header is located on one of the include file
-- search directories, it should get found automatically.
--
function suite.findsPCH_onIncludeDirs()
location "MyProject"
pchheader "premake.h"
includedirs { "../../../src/host" }
prepareVars()
test.capture [[
PCH = ../../../../src/host/premake.h
]]
end
| bsd-3-clause |
Akamaru/Mikubot | plugins/birthday_get.lua | 1 | 1250 | do
local function get_value(msg, var_name)
local hash = 'telegram:birthdays'
if hash then
local value = redis:hget(hash, var_name)
if not value then
return'Geburtstag nicht gefunden, benutze "#getbd", um alle Geburtstage aufzulisten.'
else
return var_name..' hat am '..value..' Geburtstag'
end
end
end
local function list_variables(msg)
local hash = 'telegram:birthdays'
if hash then
print('Suche nach Geburtstag in '..hash)
local names = redis:hkeys(hash)
local text = ''
for i=1, #names do
variables = get_value(msg, names[i])
text = text..variables.."\n"
end
if text == '' or text == nil then
return 'Keine Geburtstage vorhanden!'
else
return text
end
end
end
local function run(msg, matches)
if matches[2] then
return get_value(msg, matches[2])
else
return 'Geburtstagsliste:\n\n'..list_variables(msg)
end
end
return {
description = "Zeigt Geburtstage, die mit #setbd gesetzt wurden",
usage = {
"#getbd: Gibt alle Geburtstage aus",
"#getbd (Name): Gibt ein spezifischen Geburtstag aus."
},
patterns = {
"^(#[Gg][Ee][Tt][Bb][Dd]) (.+)$",
"^#[Gg][Ee][Tt][Bb][Dd]$"
},
run = run
}
--by Akamaru [https://ponywave.de]
end | gpl-2.0 |
Colettechan/darkstar | scripts/globals/mobskills/Turbofan.lua | 33 | 1281 | ---------------------------------------------------
-- Turbofan
-- Description:
-- Type: Magical
-- additional effect : Silence.
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
-- skillList 54 = Omega
-- skillList 727 = Proto-Omega
-- skillList 728 = Ultima
-- skillList 729 = Proto-Ultima
local skillList = mob:getMobMod(MOBMOD_SKILL_LIST);
local mobhp = mob:getHPP();
local phase = mob:getLocalVar("battlePhase");
if ((skillList == 729 and phase >= 1 and phase <= 2) or (skillList == 728 and mobhp < 70 and mobhp >= 40)) then
return 0;
end
return 1;
end;
function onMobWeaponSkill(target, mob, skill)
local typeEffect = EFFECT_SILENCE;
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, 1, 3, 30);
local dmgmod = 2;
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3,ELE_LIGHT,dmgmod,TP_MAB_BONUS,1);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_LIGHT,MOBPARAM_IGNORE_SHADOWS);
target:delHP(dmg);
return dmg;
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Halvung/npcs/qm3.lua | 30 | 1312 | -----------------------------------
-- Area: Halvung
-- NPC: ??? (Spawn Reacton(ZNM T2))
-- @pos 18 -9 213 62
-----------------------------------
package.loaded["scripts/zones/Halvung/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Halvung/TextIDs");
require("scripts/globals/status");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local mobID = 17031599;
if (trade:hasItemQty(2588,1) and trade:getItemCount() == 1) then -- Trade Bone Charcoal
if (GetMobAction(mobID) == ACTION_NONE) then
player:tradeComplete();
SpawnMob(mobID):updateClaim(player);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(NOTHING_HAPPENS);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
Colettechan/darkstar | scripts/globals/spells/knights_minne_iii.lua | 27 | 1498 | -----------------------------------------
-- Spell: Knight's Minne III
-- Grants Defense bonus to all allies.
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local sLvl = caster:getSkillLevel(SKILL_SNG); -- Gets skill level of Singing
local iLvl = caster:getWeaponSkillLevel(SLOT_RANGED);
local power = 18 + math.floor((sLvl + iLvl)/10);
if (power >= 64) then
power = 64;
end
local iBoost = caster:getMod(MOD_MINNE_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT);
if (iBoost > 0) then
power = power + 1 + (iBoost-1)*4;
end
power = power + caster:getMerit(MERIT_MINNE_EFFECT);
if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then
power = power * 2;
elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then
power = power * 1.5;
end
caster:delStatusEffect(EFFECT_MARCATO);
local duration = 120;
duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1);
if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then
duration = duration * 2;
end
if not (target:addBardSong(caster,EFFECT_MINNE,power,0,duration,caster:getID(), 0, 3)) then
spell:setMsg(75);
end
return EFFECT_MINNE;
end; | gpl-3.0 |
iamelectron/WPN-XM | bin/innosetup-download-plugin/source/misc/utf8toansi.lua | 5 | 1381 | --Converts UTF-8 file to ANSI
--Usage: luajit utf8toansi.lua inputfile.iss [encoding] > outputfile.iss
--Default encoding is 1252
local ffi = require("ffi")
ffi.cdef[[
int MultiByteToWideChar(unsigned int CodePage, unsigned int dwFlags, const char* lpMultiByteStr, int cbMultiByte, wchar_t* lpWideCharStr, int cchWideChar);
int WideCharToMultiByte(unsigned int CodePage, unsigned int dwFlags, wchar_t* lpWideCharStr, int cchWideChar, char* lpMultiByteStr, int cbMultiByte, char* lpDefaultChar, int* lpUsedDefaultChar);
]]
CP_UTF8 = 65001
function utf8toansi(str, codepage)
local widestr = ffi.new("wchar_t[?]", 1024)
local ansistr = ffi.new("char[?]", 1024)
local useddc = ffi.new("int[?]", 1)
ffi.C.MultiByteToWideChar(CP_UTF8, 0, str, #str, widestr, 1024)
ffi.C.WideCharToMultiByte(codepage, 0, widestr, -1, ansistr, 1024, nil, useddc)
return ffi.string(ansistr)
end
function removeBOM(s)
if s:sub(1, 3) == string.char(0xEF, 0xBB, 0xBF) then
return s:sub(4)
else
return s
end
end
args = {...}
filename = args[1]
encoding = tonumber(args[2]) or 1252
if filename == nil then
print "Usage: luajit utf8toansi.lua filename [encoding]"
os.exit()
end
f = io.open(filename, "r")
for l in f:lines() do
io.write(utf8toansi(removeBOM(l), encoding), "\n")
end
| mit |
zynjec/darkstar | scripts/globals/weaponskills/cross_reaper.lua | 10 | 1806 | -----------------------------------
-- Cross Reaper
-- Scythe weapon skill
-- Skill level: 225
-- Delivers a two-hit attack. Damage varies with TP.
-- Modifiers: STR:30% MND:30%
-- 100%TP 200%TP 300%TP
-- 2.0 2.25 2.5
-----------------------------------
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/weaponskills")
------------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.numHits = 2
-- ftp damage mods (for Damage Varies with TP lines are calculated in the function
params.ftp100 = 2.0 params.ftp200 = 2.25 params.ftp300 = 2.5
-- wscs are in % so 0.2=20%
params.str_wsc = 0.3 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.0 params.mnd_wsc = 0.3 params.chr_wsc = 0.0
-- critical mods, again in % (ONLY USE FOR CRITICAL HIT VARIES WITH TP)
params.crit100 = 0.0 params.crit200=0.0 params.crit300=0.0
params.canCrit = false
-- params.accuracy mods (ONLY USE FOR ACCURACY VARIES WITH TP) , should be the acc at those %s NOT the penalty values. Leave 0 if acc doesnt vary with tp.
params.acc100 = 0 params.acc200=0 params.acc300=0
-- attack multiplier (only some WSes use this, this varies the actual ratio value, see Tachi: Kasha) 1 is default.
params.atk100 = 1; params.atk200 = 1; params.atk300 = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 2.0 params.ftp200 = 4.0 params.ftp300 = 7.0
params.str_wsc = 0.6 params.mnd_wsc = 0.6
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, action, primary, taChar)
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Bastok_Markets/npcs/Harmodios.lua | 14 | 2447 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Harmodios
-- Standard Merchant NPC
-- @pos -79.928 -4.824 -135.114 235
-----------------------------------
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Bastok_Markets/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local WildcatBastok = player:getVar("WildcatBastok");
if (player:getQuestStatus(BASTOK,LURE_OF_THE_WILDCAT_BASTOK) == QUEST_ACCEPTED and player:getMaskBit(WildcatBastok,10) == false) then
player:startEvent(0x01ae);
elseif (player:getVar("comebackQueenCS") == 1) then
player:startEvent(0x01EA);
else
player:showText(npc,HARMODIOS_SHOP_DIALOG);
stock = {
0x43C3, 990,1, --Piccolo
0x43C0, 219,2, --Cornette
0x43C9, 43,2, --Maple Harp
0x13B1, 69120,2, --Scroll of Vital Etude
0x13B2, 66240,2, --Scroll of Swift Etude
0x13B3, 63360,2, --Scroll of Sage Etude
0x13B4, 56700,2, --Scroll of Logical Etude
0x13AF, 79560,2, --Scroll of Herculean Etude
0x13B0, 76500,2, --Scroll of Uncanny Etude
0x43C7, 4644,3, --Gemshorn
0x43C1, 43,3, --Flute
0x13B5, 54000,3 --Scroll of Bewitching Etude
}
showNationShop(player, NATION_BASTOK, stock);
end;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x01ae) then
player:setMaskBit(player:getVar("WildcatBastok"),"WildcatBastok",10,true);
elseif (csid == 0x01EA) then
player:startEvent(0x01EB);
elseif (csid == 0x01EB) then
player:setVar("comebackQueenCS", 2);
end;
end;
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Castle_Oztroja/npcs/_47b.lua | 9 | 1646 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: _47b (Handle)
-- Notes: Opens Trap Door (_47a) or Brass Door (_470)
-- !pos 22.310 -1.087 -14.320 151
-----------------------------------
local ID = require("scripts/zones/Castle_Oztroja/IDs")
require("scripts/globals/missions")
require("scripts/globals/status")
-----------------------------------
function onTrigger(player,npc)
local X = player:getXPos()
local Z = player:getZPos()
local trapDoor = GetNPCByID(npc:getID() - 1)
local brassDoor = GetNPCByID(npc:getID() - 2)
if X < 21.6 and X > 18 and Z > -15.6 and Z < -12.4 then
if VanadielDayOfTheYear() % 2 == 1 then
if brassDoor:getAnimation() == dsp.anim.CLOSE_DOOR and npc:getAnimation() == dsp.anim.CLOSE_DOOR then
npc:openDoor(8)
-- wait 1 second delay goes here
brassDoor:openDoor(6)
end
else
if trapDoor:getAnimation() == dsp.anim.CLOSE_DOOR and npc:getAnimation() == dsp.anim.CLOSE_DOOR then
npc:openDoor(8)
-- wait 1 second delay goes here
trapDoor:openDoor(6)
end
if player:getCurrentMission(WINDURST) == dsp.mission.id.windurst.TO_EACH_HIS_OWN_RIGHT and player:getCharVar("MissionStatus") == 3 then
player:startEvent(43)
end
end
else
player:messageSpecial(ID.text.CANNOT_REACH_TARGET)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 43 then
player:setCharVar("MissionStatus", 4)
end
end | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/abilities/eagle_eye_shot.lua | 1 | 2124 | -----------------------------------
-- Ability: Eagle Eye Shot
-- Delivers a powerful and accurate ranged attack.
-- Obtained: Ranger Level 1
-- Recast Time: 1:00:00
-- Duration: Instant
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/weaponskills");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
local ranged = player:getStorageItem(0, 0, SLOT_RANGED);
local ammo = player:getStorageItem(0, 0, SLOT_AMMO);
if ranged and ranged:isType(ITEM_WEAPON) then
local skilltype = ranged:getSkillType();
if skilltype == SKILL_ARC or skilltype == SKILL_MRK or skilltype == SKILL_THR then
if ammo and (ammo:isType(ITEM_WEAPON) or skilltype == SKILL_THR) then
return 0, 0;
end;
end;
end;
return MSGBASIC_NO_RANGED_WEAPON, 0;
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability,action)
if (player:getWeaponSkillType(SLOT_RANGED) == SKILL_MRK) then
action:animation(target:getID(), action:animation(target:getID()) + 1);
end
local params = {};
params.numHits = 1;
local ftp = 4 + player:getMainLvl() / 10;
params.ftp100 = ftp; params.ftp200 = ftp; params.ftp300 = ftp;
params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 1.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = true;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1
params.enmityMult = 0.0
params.bonusAcc = 100;
local damage, criticalHit, tpHits, extraHits = doRangedWeaponskill(player, target, 0, params, 100, true)
if not (tpHits + extraHits > 0) then
ability:setMsg(MSGBASIC_USES_BUT_MISSES)
action:speceffect(target:getID(), 0)
end
return damage;
end;
| gpl-3.0 |
actboy168/MoeHero | scripts/maps/rule/units.lua | 1 | 1838 | local player = require 'ac.player'
local hero = require 'types.hero'
--补兵数
player.__index.farm_count = 0
--小兵死亡加钱
ac.game:event '单位-杀死单位' (function(trg, source, target)
if target:is_type('建筑') then
return
end
local from_p = source and source:get_owner()
--找到附近的英雄
local heros = hero.getAllHeros()
local group = {}
for u in pairs(heros) do
if u:is_alive() and (from_p == u:get_owner() or u:is_in_range(target, 1200)) and target:is_enemy(u) then
table.insert(group, u)
end
end
if #group == 0 then
return
end
local len = #group
local exp, gold = target.reward_exp, target.reward_gold
--根据人数提高金钱和经验总量
if exp and len > 1 then
exp = exp * (1+0.15*(len -1))
end
if gold and len > 1 then
gold = gold * (1+0.15*(len -1))
end
--附近英雄平分金钱和经验
for _, hero in ipairs(group) do
if exp then
hero:addXp(exp / len)
end
if gold then
hero:addGold(gold / len, target)
end
local p = hero:get_owner()
p.farm_count = p.farm_count + 1 / len
end
end)
--建筑死亡爆炸
ac.game:event '单位-死亡' (function(trg, target, source)
if not target:is_type('建筑') then
return
end
target:set_class '马甲'
target:add_buff '淡化'
{
time = 1,
}
local team = target:get_owner():get_team()
local killer_team
if team == 1 then
killer_team = 2
elseif team == 2 then
killer_team = 1
end
if not killer_team then
return
end
local p = player.com[killer_team]
player.self:sendMsg(('%s%s|r |cffff1111摧毁了一座建筑物|r'):format(p:getColorWord(), p:get_name()))
--敌方全队加钱加经验
if not killer_team then
return
end
for i = 1, 5 do
local p = player.force[killer_team][i]
local hero = p.hero
if hero then
hero:addXp(500)
hero:addGold(250)
end
end
end)
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/stick_of_pepperoni.lua | 18 | 1588 | -----------------------------------------
-- ID: 5660
-- Item: stick_of_pepperoni
-- Food Effect: 30Min, All Races
-----------------------------------------
-- HP % 3 (assuming 3% from testing, no known cap)
-- Strength 3
-- Intelligence -1
-- Attack % 60 (assuming 60%, cap 30)
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5660);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_FOOD_HPP, 3);
target:addMod(MOD_FOOD_HP_CAP, 999);
target:addMod(MOD_STR, 3);
target:addMod(MOD_INT, -1);
target:addMod(MOD_FOOD_ATTP, 60);
target:addMod(MOD_FOOD_ATT_CAP, 30);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_FOOD_HPP, 3);
target:delMod(MOD_FOOD_HP_CAP, 999);
target:delMod(MOD_STR, 3);
target:delMod(MOD_INT, -1);
target:delMod(MOD_FOOD_ATTP, 60);
target:delMod(MOD_FOOD_ATT_CAP, 30);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Temenos/bcnms/Temenos_Eastern_Tower.lua | 35 | 1553 | -----------------------------------
-- Area: Temenos
-- Name:
-----------------------------------
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
if (GetMobAction(16928844) > 0) then DespawnMob(16928844);end
if (GetMobAction(16928853) > 0) then DespawnMob(16928853);end
if (GetMobAction(16928862) > 0) then DespawnMob(16928862);end
if (GetMobAction(16928871) > 0) then DespawnMob(16928871);end
if (GetMobAction(16928880) > 0) then DespawnMob(16928880);end
if (GetMobAction(16928889) > 0) then DespawnMob(16928889);end
if (GetMobAction(16928894) > 0) then DespawnMob(16928894);end
SetServerVariable("[Temenos_E_Tower]UniqueID",GenerateLimbusKey());
HideArmouryCrates(GetInstanceRegion(1300),TEMENOS);
HideTemenosDoor(GetInstanceRegion(1300));
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
player:setVar("limbusbitmap",0);
player:setVar("characterLimbusKey",GetServerVariable("[Temenos_E_Tower]UniqueID"));
player:setVar("LimbusID",1300);
player:delKeyItem(COSMOCLEANSE);
player:delKeyItem(WHITE_CARD);
end;
-- Leaving the Dynamis by every mean possible, given by the LeaveCode
-- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3)
-- 4=Finish he dynamis
function onBcnmLeave(player,instance,leavecode)
--print("leave code "..leavecode);
if (leavecode == 4) then
player:setPos(580,-1.5,4.452,192);
ResetPlayerLimbusVariable(player)
end
end; | gpl-3.0 |
syntafin/prosody-modules | mod_onhold/mod_onhold.lua | 32 | 2253 | -- Prosody IM
-- Copyright (C) 2008-2009 Matthew Wild
-- Copyright (C) 2008-2009 Waqas Hussain
-- Copyright (C) 2009 Jeff Mitchell
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--
local datamanager = require "util.datamanager";
local jid_bare = require "util.jid".bare;
local jid_split = require "util.jid".split;
local st = require "util.stanza";
local datetime = require "util.datetime";
local ipairs = ipairs;
local onhold_jids = module:get_option("onhold_jids") or {};
for _, jid in ipairs(onhold_jids) do onhold_jids[jid] = true; end
function process_message(event)
local session, stanza = event.origin, event.stanza;
local to = stanza.attr.to;
local from = jid_bare(stanza.attr.from);
local node, host;
local onhold_node, onhold_host;
if to then
node, host = jid_split(to)
else
node, host = session.username, session.host;
end
if onhold_jids[from] then
stanza.attr.stamp, stanza.attr.stamp_legacy = datetime.datetime(), datetime.legacy();
local result = datamanager.list_append(node, host, "onhold", st.preserialize(stanza));
stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
return true;
end
return nil;
end
module:hook("message/bare", process_message, 5);
module:hook("message/full", process_message, 5);
module:hook("presence/bare", function(event)
if event.origin.presence then return nil; end
local session = event.origin;
local node, host = session.username, session.host;
local from;
local de_stanza;
local data = datamanager.list_load(node, host, "onhold");
local newdata = {};
if not data then return nil; end
for _, stanza in ipairs(data) do
de_stanza = st.deserialize(stanza);
from = jid_bare(de_stanza.attr.from);
if not onhold_jids[from] then
de_stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = de_stanza.attr.stamp}):up(); -- XEP-0203
de_stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = de_stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated)
de_stanza.attr.stamp, de_stanza.attr.stamp_legacy = nil, nil;
session.send(de_stanza);
else
table.insert(newdata, stanza);
end
end
datamanager.list_store(node, host, "onhold", newdata);
return nil;
end, 5);
| mit |
IsCoolEntertainment/debpkg_redis | deps/lua/test/sort.lua | 889 | 1494 | -- two implementations of a sort function
-- this is an example only. Lua has now a built-in function "sort"
-- extracted from Programming Pearls, page 110
function qsort(x,l,u,f)
if l<u then
local m=math.random(u-(l-1))+l-1 -- choose a random pivot in range l..u
x[l],x[m]=x[m],x[l] -- swap pivot to first position
local t=x[l] -- pivot value
m=l
local i=l+1
while i<=u do
-- invariant: x[l+1..m] < t <= x[m+1..i-1]
if f(x[i],t) then
m=m+1
x[m],x[i]=x[i],x[m] -- swap x[i] and x[m]
end
i=i+1
end
x[l],x[m]=x[m],x[l] -- swap pivot to a valid place
-- x[l+1..m-1] < x[m] <= x[m+1..u]
qsort(x,l,m-1,f)
qsort(x,m+1,u,f)
end
end
function selectionsort(x,n,f)
local i=1
while i<=n do
local m,j=i,i+1
while j<=n do
if f(x[j],x[m]) then m=j end
j=j+1
end
x[i],x[m]=x[m],x[i] -- swap x[i] and x[m]
i=i+1
end
end
function show(m,x)
io.write(m,"\n\t")
local i=1
while x[i] do
io.write(x[i])
i=i+1
if x[i] then io.write(",") end
end
io.write("\n")
end
function testsorts(x)
local n=1
while x[n] do n=n+1 end; n=n-1 -- count elements
show("original",x)
qsort(x,1,n,function (x,y) return x<y end)
show("after quicksort",x)
selectionsort(x,n,function (x,y) return x>y end)
show("after reverse selection sort",x)
qsort(x,1,n,function (x,y) return x<y end)
show("after quicksort again",x)
end
-- array to be sorted
x={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
testsorts(x)
| bsd-3-clause |
Murii/CLove | src/3rdparty/lua/test/sort.lua | 889 | 1494 | -- two implementations of a sort function
-- this is an example only. Lua has now a built-in function "sort"
-- extracted from Programming Pearls, page 110
function qsort(x,l,u,f)
if l<u then
local m=math.random(u-(l-1))+l-1 -- choose a random pivot in range l..u
x[l],x[m]=x[m],x[l] -- swap pivot to first position
local t=x[l] -- pivot value
m=l
local i=l+1
while i<=u do
-- invariant: x[l+1..m] < t <= x[m+1..i-1]
if f(x[i],t) then
m=m+1
x[m],x[i]=x[i],x[m] -- swap x[i] and x[m]
end
i=i+1
end
x[l],x[m]=x[m],x[l] -- swap pivot to a valid place
-- x[l+1..m-1] < x[m] <= x[m+1..u]
qsort(x,l,m-1,f)
qsort(x,m+1,u,f)
end
end
function selectionsort(x,n,f)
local i=1
while i<=n do
local m,j=i,i+1
while j<=n do
if f(x[j],x[m]) then m=j end
j=j+1
end
x[i],x[m]=x[m],x[i] -- swap x[i] and x[m]
i=i+1
end
end
function show(m,x)
io.write(m,"\n\t")
local i=1
while x[i] do
io.write(x[i])
i=i+1
if x[i] then io.write(",") end
end
io.write("\n")
end
function testsorts(x)
local n=1
while x[n] do n=n+1 end; n=n-1 -- count elements
show("original",x)
qsort(x,1,n,function (x,y) return x<y end)
show("after quicksort",x)
selectionsort(x,n,function (x,y) return x>y end)
show("after reverse selection sort",x)
qsort(x,1,n,function (x,y) return x<y end)
show("after quicksort again",x)
end
-- array to be sorted
x={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
testsorts(x)
| mit |
Colettechan/darkstar | scripts/zones/Windurst_Waters/npcs/Orez-Ebrez.lua | 17 | 1793 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Orez-Ebrez
-- Standard Merchant NPC
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,OREZEBREZ_SHOP_DIALOG);
stock = {
0x30B2, 20000,1, --Red Cap
0x30AA, 8972,1, --Soil Hachimaki
0x30A7, 7026,1, --Beetle Mask
0x30B8, 144,2, --Circlet
0x30B1, 8024,2, --Cotton Headgear
0x3098, 396,2, --Leather Bandana
0x30B9, 1863,2, --Poet's Circlet
0x30D3, 14400,2, --Flax Headband
0x30A9, 3272,2, --Cotton Hachimaki
0x30A6, 3520,2, --Bone Mask
0x30BA, 10924,2, --Wool Hat
0x30B0, 1742,3, --Headgear
0x30A8, 552,3, --Hachimaki
0x30D2, 1800,3, --Cotton Headband
0x30A0, 151,3, --Bronze Cap
0x30A1, 1471,3 --Brass Cap
}
showNationShop(player, WINDURST, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Chamber_of_Oracles/npcs/Pedestal_of_Water.lua | 13 | 2386 | -----------------------------------
-- Area: Chamber of Oracles
-- NPC: Pedestal of Water
-- Involved in Zilart Mission 7
-- @pos 199 -2 36 168
-------------------------------------
package.loaded["scripts/zones/Chamber_of_Oracles/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Chamber_of_Oracles/TextIDs");
-------------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local ZilartStatus = player:getVar("ZilartStatus");
if (player:getCurrentMission(ZILART) == THE_CHAMBER_OF_ORACLES) then
if (player:hasKeyItem(WATER_FRAGMENT)) then
player:delKeyItem(WATER_FRAGMENT);
player:setVar("ZilartStatus",ZilartStatus + 64);
player:messageSpecial(YOU_PLACE_THE,WATER_FRAGMENT);
if (ZilartStatus == 255) then
player:startEvent(0x0001);
end
elseif (ZilartStatus == 255) then -- Execute cutscene if the player is interrupted.
player:startEvent(0x0001);
else
player:messageSpecial(IS_SET_IN_THE_PEDESTAL,WATER_FRAGMENT);
end
elseif (player:hasCompletedMission(ZILART,THE_CHAMBER_OF_ORACLES)) then
player:messageSpecial(HAS_LOST_ITS_POWER,WATER_FRAGMENT);
else
player:messageSpecial(PLACED_INTO_THE_PEDESTAL);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("onUpdate CSID: %u",csid);
--printf("onUpdate RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
if (csid == 0x0001) then
player:addTitle(LIGHTWEAVER);
player:setVar("ZilartStatus",0);
player:addKeyItem(PRISMATIC_FRAGMENT);
player:messageSpecial(KEYITEM_OBTAINED,PRISMATIC_FRAGMENT);
player:completeMission(ZILART,THE_CHAMBER_OF_ORACLES);
player:addMission(ZILART,RETURN_TO_DELKFUTTS_TOWER);
end
end;
| gpl-3.0 |
zynjec/darkstar | scripts/globals/weaponskills/rudras_storm.lua | 10 | 1927 | -----------------------------------
-- Rudra's Storm
-- Dagger weapon skill
-- Skill level: N/A
-- Deals triple damage and weighs target down (duration: 60s). Damage varies with TP.
-- Aligned with the Aqua Gorget, Snow Gorget & Shadow Gorget.
-- Aligned with the Aqua Belt, Snow Belt & Shadow Belt.
-- Element: None
-- Modifiers: DEX:80%
-- 100%TP 200%TP 300%TP
-- 6 15 19.5
-----------------------------------
require("scripts/globals/aftermath")
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/weaponskills")
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.numHits = 1
params.ftp100 = 3.25 params.ftp200 = 4.25 params.ftp300 = 5.25
params.str_wsc = 0.0 params.dex_wsc = 0.6 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.0 params.mnd_wsc = 0.0 params.chr_wsc = 0.0
params.crit100 = 0.0 params.crit200 = 0.0 params.crit300 = 0.0
params.canCrit = false
params.acc100 = 0.0 params.acc200 = 0.0 params.acc300 = 0.0
params.atk100 = 1; params.atk200 = 1; params.atk300 = 1;
if USE_ADOULIN_WEAPON_SKILL_CHANGES then
params.ftp100 = 5 params.ftp200 = 10.19 params.ftp300 = 13
params.dex_wsc = 0.8
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, action, primary, taChar)
-- dsp.effect.WEIGHT power value is equal to lead breath as per bg-wiki: http://www.bg-wiki.com/bg/Rudra%27s_Storm
if damage > 0 then
if not target:hasStatusEffect(dsp.effect.WEIGHT) then
target:addStatusEffect(dsp.effect.WEIGHT, 50, 0, 60)
end
-- Apply aftermath
dsp.aftermath.addStatusEffect(player, tp, dsp.slot.MAIN, dsp.aftermath.type.EMPYREAN)
end
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
RJRetro/mame | 3rdparty/genie/tests/actions/xcode/test_xcode_dependencies.lua | 20 | 9645 | --
-- tests/actions/xcode/test_xcode_dependencies.lua
-- Automated test suite for Xcode project dependencies.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.xcode3_deps = { }
local suite = T.xcode3_deps
local xcode = premake.xcode
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local sln, prj, prj2, tr
function suite.setup()
premake.action.set("xcode3")
xcode.used_ids = { } -- reset the list of generated IDs
sln, prj = test.createsolution()
links { "MyProject2" }
prj2 = test.createproject(sln)
kind "StaticLib"
configuration "Debug"
targetsuffix "-d"
end
local function prepare()
premake.bake.buildconfigs()
xcode.preparesolution(sln)
tr = xcode.buildprjtree(premake.solution.getproject(sln, 1))
end
---------------------------------------------------------------------------
-- PBXBuildFile tests
---------------------------------------------------------------------------
function suite.PBXBuildFile_ListsDependencyTargets_OnStaticLib()
prepare()
xcode.PBXBuildFile(tr)
test.capture [[
/* Begin PBXBuildFile section */
[libMyProject2-d.a:build] /* libMyProject2-d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = [libMyProject2-d.a] /* libMyProject2-d.a */; };
/* End PBXBuildFile section */
]]
end
function suite.PBXBuildFile_ListsDependencyTargets_OnSharedLib()
kind "SharedLib"
prepare()
xcode.PBXBuildFile(tr)
test.capture [[
/* Begin PBXBuildFile section */
[libMyProject2-d.dylib:build] /* libMyProject2-d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = [libMyProject2-d.dylib] /* libMyProject2-d.dylib */; };
/* End PBXBuildFile section */
]]
end
---------------------------------------------------------------------------
-- PBXContainerItemProxy tests
---------------------------------------------------------------------------
function suite.PBXContainerItemProxy_ListsProjectConfigs()
prepare()
xcode.PBXContainerItemProxy(tr)
test.capture [[
/* Begin PBXContainerItemProxy section */
[MyProject2.xcodeproj:prodprox] /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = [MyProject2.xcodeproj] /* MyProject2.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = [libMyProject2-d.a:product];
remoteInfo = "libMyProject2-d.a";
};
[MyProject2.xcodeproj:targprox] /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = [MyProject2.xcodeproj] /* MyProject2.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = [libMyProject2-d.a:target];
remoteInfo = "libMyProject2-d.a";
};
/* End PBXContainerItemProxy section */
]]
end
---------------------------------------------------------------------------
-- PBXFileReference tests
---------------------------------------------------------------------------
function suite.PBXFileReference_ListsDependencies()
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = "MyProject"; path = "MyProject"; sourceTree = BUILT_PRODUCTS_DIR; };
[MyProject2.xcodeproj] /* MyProject2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject2.xcodeproj"; path = "MyProject2.xcodeproj"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_UsesRelativePaths()
prj.location = "MyProject"
prj2.location = "MyProject2"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = "MyProject"; path = "MyProject"; sourceTree = BUILT_PRODUCTS_DIR; };
[MyProject2.xcodeproj] /* MyProject2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject2.xcodeproj"; path = "../MyProject2/MyProject2.xcodeproj"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
]]
end
---------------------------------------------------------------------------
-- PBXFrameworksBuildPhase tests
---------------------------------------------------------------------------
function suite.PBXFrameworksBuildPhase_ListsDependencies_OnStaticLib()
prepare()
xcode.PBXFrameworksBuildPhase(tr)
test.capture [[
/* Begin PBXFrameworksBuildPhase section */
[MyProject:fxs] /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
[libMyProject2-d.a:build] /* libMyProject2-d.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
]]
end
function suite.PBXFrameworksBuildPhase_ListsDependencies_OnSharedLib()
kind "SharedLib"
prepare()
xcode.PBXFrameworksBuildPhase(tr)
test.capture [[
/* Begin PBXFrameworksBuildPhase section */
[MyProject:fxs] /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
[libMyProject2-d.dylib:build] /* libMyProject2-d.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
]]
end
---------------------------------------------------------------------------
-- PBXGroup tests
---------------------------------------------------------------------------
function suite.PBXGroup_ListsDependencies()
prepare()
xcode.PBXGroup(tr)
test.capture [[
/* Begin PBXGroup section */
[MyProject] /* MyProject */ = {
isa = PBXGroup;
children = (
[Products] /* Products */,
[Projects] /* Projects */,
);
name = "MyProject";
sourceTree = "<group>";
};
[Products] /* Products */ = {
isa = PBXGroup;
children = (
[MyProject:product] /* MyProject */,
);
name = "Products";
sourceTree = "<group>";
};
[Projects] /* Projects */ = {
isa = PBXGroup;
children = (
[MyProject2.xcodeproj] /* MyProject2.xcodeproj */,
);
name = "Projects";
sourceTree = "<group>";
};
[MyProject2.xcodeproj:prodgrp] /* Products */ = {
isa = PBXGroup;
children = (
[libMyProject2-d.a] /* libMyProject2-d.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
]]
end
---------------------------------------------------------------------------
-- PBXNativeTarget tests
---------------------------------------------------------------------------
function suite.PBXNativeTarget_ListsDependencies()
prepare()
xcode.PBXNativeTarget(tr)
test.capture [[
/* Begin PBXNativeTarget section */
[MyProject:target] /* MyProject */ = {
isa = PBXNativeTarget;
buildConfigurationList = [MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */;
buildPhases = (
[MyProject:rez] /* Resources */,
[MyProject:src] /* Sources */,
[MyProject:fxs] /* Frameworks */,
);
buildRules = (
);
dependencies = (
[MyProject2.xcodeproj:targdep] /* PBXTargetDependency */,
);
name = "MyProject";
productInstallPath = "$(HOME)/bin";
productName = "MyProject";
productReference = [MyProject:product] /* MyProject */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
]]
end
---------------------------------------------------------------------------
-- PBXProject tests
---------------------------------------------------------------------------
function suite.PBXProject_ListsDependencies()
prepare()
xcode.PBXProject(tr)
test.capture [[
/* Begin PBXProject section */
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */;
compatibilityVersion = "Xcode 3.2";
hasScannedForEncodings = 1;
mainGroup = [MyProject] /* MyProject */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = [MyProject2.xcodeproj:prodgrp] /* Products */;
ProjectRef = [MyProject2.xcodeproj] /* MyProject2.xcodeproj */;
},
);
projectRoot = "";
targets = (
[MyProject:target] /* MyProject */,
);
};
/* End PBXProject section */
]]
end
---------------------------------------------------------------------------
-- PBXReferenceProxy tests
---------------------------------------------------------------------------
function suite.PBXReferenceProxy_ListsDependencies()
prepare()
xcode.PBXReferenceProxy(tr)
test.capture [[
/* Begin PBXReferenceProxy section */
[libMyProject2-d.a] /* libMyProject2-d.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libMyProject2-d.a";
remoteRef = [MyProject2.xcodeproj:prodprox] /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
]]
end
---------------------------------------------------------------------------
-- PBXTargetDependency tests
---------------------------------------------------------------------------
function suite.PBXTargetDependency_ListsDependencies()
prepare()
xcode.PBXTargetDependency(tr)
test.capture [[
/* Begin PBXTargetDependency section */
[MyProject2.xcodeproj:targdep] /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "libMyProject2-d.a";
targetProxy = [MyProject2.xcodeproj:targprox] /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
]]
end
| gpl-2.0 |
lcf8858/Sample_Lua | frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/SkeletonRenderer.lua | 10 | 2646 |
--------------------------------
-- @module SkeletonRenderer
-- @extend Node,BlendProtocol
-- @parent_module sp
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setTimeScale
-- @param self
-- @param #float scale
--------------------------------
--
-- @function [parent=#SkeletonRenderer] isOpacityModifyRGB
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setDebugSlotsEnabled
-- @param self
-- @param #bool enabled
--------------------------------
--
-- @function [parent=#SkeletonRenderer] getDebugSlotsEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setBonesToSetupPose
-- @param self
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setSlotsToSetupPose
-- @param self
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setSkin
-- @param self
-- @param #string skinName
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setToSetupPose
-- @param self
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setOpacityModifyRGB
-- @param self
-- @param #bool value
--------------------------------
--
-- @function [parent=#SkeletonRenderer] setDebugBonesEnabled
-- @param self
-- @param #bool enabled
--------------------------------
--
-- @function [parent=#SkeletonRenderer] getSkeleton
-- @param self
-- @return spSkeleton#spSkeleton ret (return value: spSkeleton)
--------------------------------
--
-- @function [parent=#SkeletonRenderer] getDebugBonesEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#SkeletonRenderer] getTimeScale
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @overload self, string, string, float
-- @overload self, string, spAtlas, float
-- @function [parent=#SkeletonRenderer] createWithFile
-- @param self
-- @param #string skeletonDataFile
-- @param #spAtlas atlas
-- @param #float scale
-- @return SkeletonRenderer#SkeletonRenderer ret (return value: sp.SkeletonRenderer)
--------------------------------
--
-- @function [parent=#SkeletonRenderer] getBoundingBox
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
return nil
| mit |
syntafin/prosody-modules | mod_munin/mod_munin.lua | 20 | 3500 | module:set_global();
local s_format = string.format;
local array = require"util.array";
local it = require"util.iterators";
local mt = require"util.multitable";
local meta = mt.new(); meta.data = module:shared"meta";
local data = mt.new(); data.data = module:shared"data";
local munin_listener = {};
local munin_commands = {};
local node_name = module:get_option_string("munin_node_name", "localhost");
local ignore_stats = module:get_option_set("munin_ignored_stats", { });
local function clean_fieldname(name)
return (name:gsub("[^A-Za-z0-9_]", "_"):gsub("^[^A-Za-z_]", "_%1"));
end
function munin_listener.onconnect(conn)
-- require"core.statsmanager".collect();
conn:write("# munin node at "..node_name.."\n");
end
function munin_listener.onincoming(conn, line)
line = line and line:match("^[^\r\n]+");
if type(line) ~= "string" then return end
-- module:log("debug", "incoming: %q", line);
local command = line:match"^%w+";
command = munin_commands[command];
if not command then
conn:write("# Unknown command.\n");
return;
end
local ok, err = pcall(command, conn, line);
if not ok then
module:log("error", "Error running %q: %s", line, err);
conn:close();
end
end
function munin_listener.ondisconnect() end
function munin_commands.cap(conn)
conn:write("cap\n");
end
function munin_commands.list(conn)
conn:write(array(it.keys(data.data)):concat(" ") .. "\n");
end
function munin_commands.config(conn, line)
-- TODO what exactly?
local stat = line:match("%s(%S+)");
if not stat then conn:write("# Unknown service\n.\n"); return end
for _, _, k, value in meta:iter(stat, "", nil) do
conn:write(s_format("%s %s\n", k, value));
end
for _, name, k, value in meta:iter(stat, nil, nil) do
if name ~= "" and not ignore_stats:contains(name) then
conn:write(s_format("%s.%s %s\n", name, k, value));
end
end
conn:write(".\n");
end
function munin_commands.fetch(conn, line)
local stat = line:match("%s(%S+)");
if not stat then conn:write("# Unknown service\n.\n"); return end
for _, name, value in data:iter(stat, nil) do
if not ignore_stats:contains(name) then
conn:write(s_format("%s.value %.12f\n", name, value));
end
end
conn:write(".\n");
end
function munin_commands.quit(conn)
conn:close();
end
module:hook("stats-updated", function (event)
local all_stats, this = event.stats_extra;
local host, sect, name, typ, key;
for stat, value in pairs(event.changed_stats) do
if not ignore_stats:contains(stat) then
this = all_stats[stat];
-- module:log("debug", "changed_stats[%q] = %s", stat, tostring(value));
host, sect, name, typ = stat:match("^/([^/]+)/([^/]+)/(.+):(%a+)$");
if host == nil then
sect, name, typ, host = stat:match("^([^.]+)%.([^:]+):(%a+)$");
elseif host == "*" then
host = nil;
end
key = clean_fieldname(s_format("%s_%s_%s", host or "global", sect, typ));
if not meta:get(key) then
if host then
meta:set(key, "", "graph_title", s_format("%s %s on %s", sect, typ, host));
else
meta:set(key, "", "graph_title", s_format("Global %s %s", sect, typ, host));
end
meta:set(key, "", "graph_vlabel", this and this.units or typ);
meta:set(key, "", "graph_category", sect);
meta:set(key, name, "label", name);
elseif not meta:get(key, name, "label") then
meta:set(key, name, "label", name);
end
data:set(key, name, value);
end
end
end);
module:provides("net", {
listener = munin_listener;
default_mode = "*l";
default_port = 4949;
});
| mit |
Vadavim/jsr-darkstar | scripts/zones/Lower_Jeuno/npcs/_l03.lua | 7 | 1574 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Streetlamp
-- Involved in Quests: Community Service
-- @zone 245
-- @pos -81.310 0 -109.947
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local hour = VanadielHour();
if (hour >= 18 and hour < 21) then
if (player:getQuestStatus(JEUNO,COMMUNITY_SERVICE) == QUEST_ACCEPTED) then
if (player:getVar("cService") == 8) then
player:setVar("cService",9);
end
elseif (hour >= 18 and hour < 21) then
if (player:getQuestStatus(JEUNO,COMMUNITY_SERVICE) == QUEST_COMPLETED) then
if (player:getVar("cService") == 21) then
player:setVar("cService",22);
end
end
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
reaperrr/OpenRA | mods/cnc/maps/gdi09/gdi09.lua | 6 | 6830 | --[[
Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version. For more
information, see COPYING.
]]
InsertionHelicopterType = "tran.insertion"
GDIHeliReinfUnits = { "e2", "e2", "e2", "e3", "e3" }
SamSites = { sam1, sam2, sam3, sam4 }
NodBunkersNorth = { gun3, gun4 }
NodBunkersSouth = { gun1, gun2 }
BoatEscapeTrigger = { CPos.New(2,37) }
WaypointGroup1 = { waypoint1, waypoint2, waypoint8 }
WaypointGroup2 = { waypoint1, waypoint2, waypoint3, waypoint9 }
WaypointGroup3 = { waypoint1, waypoint2, waypoint3, waypoint10, waypoint11, waypoint12, waypoint6, waypoint13 }
WaypointGroup4 = { waypoint1, waypoint2, waypoint3, waypoint4 }
Patrol1Waypoints = { waypoint11.Location, waypoint10.Location }
Patrol2Waypoints = { waypoint1.Location, waypoint2.Location, waypoint3.Location, waypoint4.Location, waypoint5.Location, waypoint4.Location, waypoint3.Location, waypoint2.Location, waypoint1.Location, waypoint6.Location }
Nod1 = { units = { ['e1'] = 2, ['e3'] = 2 }, waypoints = WaypointGroup1, delay = 40 }
Nod2 = { units = { ['e3'] = 2, ['e4'] = 2 }, waypoints = WaypointGroup2, delay = 50 }
Nod3 = { units = { ['e1'] = 2, ['e3'] = 3, ['e4'] = 2 }, waypoints = WaypointGroup1, delay = 50 }
Nod4 = { units = { ['bggy'] = 2 }, waypoints = WaypointGroup2, delay = 50 }
Nod5 = { units = { ['e4'] = 2, ['ltnk'] = 1 }, waypoints = WaypointGroup1, delay = 50 }
Auto1 = { units = { ['e4'] = 2, ['arty'] = 1 }, waypoints = WaypointGroup1, delay = 50 }
Auto2 = { units = { ['e1'] = 2, ['e3'] = 2 }, waypoints = WaypointGroup2, delay = 50 }
Auto3 = { units = { ['e3'] = 2, ['e4'] = 2 }, waypoints = WaypointGroup1, delay = 50 }
Auto4 = { units = { ['e1'] = 3, ['e4'] = 1 }, waypoints = WaypointGroup1, delay = 50 }
Auto5 = { units = { ['ltnk'] = 1, ['bggy'] = 1 }, waypoints = WaypointGroup1, delay = 60 }
Auto6 = { units = { ['bggy'] = 1 }, waypoints = WaypointGroup2, delay = 50 }
Auto7 = { units = { ['ltnk'] = 1 }, waypoints = WaypointGroup2, delay = 50 }
Auto8 = { units = { ['e4'] = 2, ['bggy'] = 1 }, waypoints = WaypointGroup4, delay = 0 }
Patrols = {
grd1 = { units = { ['e3'] = 3 }, waypoints = Patrol1Waypoints, wait = 40, initialWaypointPlacement = { 1 } },
grd2 = { units = { ['e1'] = 2, ['e3'] = 2, ['e4'] = 2 }, waypoints = Patrol2Waypoints, wait = 20, initialWaypointPlacement = { 4, 10, 1 } }
}
AutoAttackWaves = { Nod1, Nod2, Nod3, Nod4, Nod5, Auto1, Auto2, Auto3, Auto4, Auto5, Auto6, Auto7, Auto8 }
StationaryGuards = { Actor174, Actor173, Actor182, Actor183, Actor184, Actor185, Actor186, Actor187 , Actor199, Actor200, Actor201, Actor202, Actor203, Actor204 }
StartStationaryGuards = function()
Utils.Do(StationaryGuards, function(unit)
if not unit.IsDead then
unit.Patrol( { unit.Location } , true, 20)
end
end)
end
SendWaves = function(counter, Waves)
if counter <= #Waves then
local team = Waves[counter]
for type, amount in pairs(team.units) do
MoveAndHunt(Utils.Take(amount, Nod.GetActorsByType(type)), team.waypoints)
end
Trigger.AfterDelay(DateTime.Seconds(team.delay), function() SendWaves(counter + 1, Waves) end)
end
end
StartPatrols = function()
for k, team in pairs(Patrols) do
local group = 1
for type, amount in pairs(team.units) do
for i = 1, amount do
Reinforcements.Reinforce(Nod, { type }, { team.waypoints[team.initialWaypointPlacement[group]] }, 0, function(unit)
ReplenishPatrolUnit(unit, handofnod, team.waypoints, team.wait)
end)
end
group = group + 1
end
end
Patrols = nil
end
ReplenishPatrolUnit = function(unit, building, waypoints, waitatwaypoint)
unit.Patrol(waypoints, true, waitatwaypoint)
Trigger.OnKilled(unit, function()
local queueUnit = { unit = { unit.Type }, atbuilding = { building }, waypoints = waypoints }
PatrolProductionQueue[#PatrolProductionQueue + 1] = queueUnit
end)
end
SendGDIReinforcements = function()
Media.PlaySpeechNotification(GDI, "Reinforce")
Reinforcements.ReinforceWithTransport(GDI, InsertionHelicopterType, GDIHeliReinfUnits, { GDIHeliEntryNorth.Location, GDIHeliLZ.Location }, { GDIHeliLZ.Location + CVec.New(20, 0) })
end
SendGDIReinforcementChinook = function()
Reinforcements.ReinforceWithTransport(GDI, 'tran', nil, { GDIHeliEntryNorth.Location, GDIHeliLZ.Location })
end
SpawnGunboat = function()
Media.PlaySpeechNotification(GDI, "Reinforce")
Actor.Create("boat", true, { Owner = GDI, Facing = Angle.North, Location = CPos.New(62,37) })
end
WorldLoaded = function()
GDI = Player.GetPlayer("GDI")
Nod = Player.GetPlayer("Nod")
Camera.Position = DefaultCameraPosition.CenterPosition
DestroyBunkers = GDI.AddObjective("Destroy the Nod bunkers to allow Carter's\nconvoy to pass through safely.")
Trigger.OnAllKilled(NodBunkersNorth, function()
GDI.MarkCompletedObjective(DestroyBunkers)
Trigger.AfterDelay(DateTime.Seconds(1), SpawnGunboat)
end)
Trigger.OnAllKilled(NodBunkersSouth, function()
GDI.MarkCompletedObjective(DestroyBunkers)
SendGDIReinforcementChinook()
Trigger.AfterDelay(DateTime.Seconds(1), SpawnGunboat)
end)
Trigger.OnEnteredFootprint(BoatEscapeTrigger, function(a, id)
if a.Type == "boat" then
a.Stop()
a.Destroy()
Media.DisplayMessage("Part of Carter's convoy passed through!")
Media.PlaySoundNotification(GDI, "Beepy6")
end
end)
SecureArea = GDI.AddObjective("Destroy the Nod strike force.")
KillGDI = Nod.AddObjective("Kill all enemies!")
Trigger.AfterDelay(DateTime.Seconds(5), SendGDIReinforcements)
AirSupport = GDI.AddObjective("Destroy the SAM sites to receive air support.", "Secondary", false)
Trigger.OnAllKilled(SamSites, function()
GDI.MarkCompletedObjective(AirSupport)
Actor.Create("airstrike.proxy", true, { Owner = GDI })
end)
Actor.Create("flare", true, { Owner = GDI, Location = DefaultFlareLocation.Location })
StartStationaryGuards()
StartAI()
StartPatrols()
InitObjectives(GDI)
Trigger.AfterDelay(DateTime.Minutes(1), function() SendWaves(1, AutoAttackWaves) end)
Trigger.AfterDelay(DateTime.Minutes(3), function() ProduceInfantry(handofnod) end)
Trigger.AfterDelay(DateTime.Minutes(3), function() ProduceVehicle(nodairfield) end)
local initialArrivingUnits = { Actor175, Actor191, Actor192, Actor193, Actor194, Actor195, Actor196, Actor197, Actor198 }
Utils.Do(initialArrivingUnits, function(unit)
unit.Move(unit.Location + CVec.New(0, 1), 0)
end)
end
Tick = function()
if DateTime.GameTime > DateTime.Seconds(5) then
if GDI.HasNoRequiredUnits() then
Nod.MarkCompletedObjective(KillGDI)
end
if Nod.HasNoRequiredUnits() then
GDI.MarkCompletedObjective(SecureArea)
end
end
end
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Bastok_Markets/npcs/Matthias.lua | 9 | 6995 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Matthias
-- Standard Info NPC
-- Involved in Quest:
-----------------------------------
local ID = require("scripts/zones/Bastok_Markets/IDs");
require("scripts/globals/quests");
-----------------------------------
--local variables for item IDs to make things clearer;
local imperialSilk = 2340;
local wolfFelt = 2010;
local silverBrocade = 1991;
local karakulCloth = 2288;
local rainbowCloth = 830;
local rainbowVelvet = 1996;
local wamouraCloth = 2289;
local moblinWeave = 1636;
local goldBrocade = 1999;
function onTrade(player,npc,trade)
if (player:getCharVar("dancerTailorCS") == 4) then
local playersAFChoice = player:getCharVar("dancerAFChoice");
if (playersAFChoice == 1 and
trade:hasItemQty(imperialSilk, 1) == true and
trade:hasItemQty(wolfFelt, 1) == true and
trade:hasItemQty(silverBrocade, 1) == true and
trade:getItemCount() == 3 and
trade:getGil() == 0) then
rewardThePlayer(player);
elseif (playersAFChoice == 2 and
trade:hasItemQty(karakulCloth, 1) == true and
trade:hasItemQty(rainbowCloth, 1) == true and
trade:hasItemQty(rainbowVelvet, 1) == true and
trade:getItemCount() == 3 and
trade:getGil() == 0) then
rewardThePlayer(player);
elseif (playersAFChoice == 3 and
trade:hasItemQty(wamouraCloth, 1) == true and
trade:hasItemQty(moblinWeave, 1) == true and
trade:hasItemQty(goldBrocade, 1) == true and
trade:getItemCount() == 3 and
trade:getGil() == 0) then
rewardThePlayer(player);
end;
end;
end;
function rewardThePlayer(player)
local playersAFChoice = player:getCharVar("dancerAFChoice");
local currentVanaDay = VanadielDayOfTheYear();
player:setCharVar("dancerTailorWorkDay", currentVanaDay);
player:setCharVar("dancerTailorCS", 5);
player:tradeComplete();
player:startEvent(495, playersAFChoice-1);
end;
-- local variables for item IDs to make things clearer
local dancersTiara = 16139;
local dancersBangles = 15003;
local dancersToeshoes = 15747;
function onTrigger(player,npc)
local playersAFChoice = player:getCharVar("dancerAFChoice");
local tailorStartedWorkDay = player:getCharVar("dancerTailorWorkDay");
if (player:getCharVar("dancerTailorCS") == 2) then
player:startEvent(492);
elseif (player:getCharVar("dancerTailorCS") == 3) then
local completedPieces = player:getCharVar("dancerCompletedAF");
local playerCompletedTiara = 0;
if (bit.band(completedPieces,1) > 0) then
playerCompletedTiara = 1;
end;
local playerCompletedBangles = 0;
if (bit.band(completedPieces,2) > 0) then
playerCompletedBangles = 1;
end;
local playerCompletedShoes = 0;
if (bit.band(completedPieces,4) > 0) then
playerCompletedShoes = 1;
end;
local completedPieces = playerCompletedShoes + playerCompletedBangles + playerCompletedTiara;
if (completedPieces == 3) then
player:setCharVar("dancerTailorCS", 6);
player:startEvent(498);
else
player:startEvent(493, playerCompletedTiara, playerCompletedBangles, playerCompletedShoes);
end;
elseif (player:getCharVar("dancerTailorCS") == 4) then
player:startEvent(494, playersAFChoice -1); -- event params indexed from 0
elseif (player:getCharVar("dancerTailorCS") == 5 )then
local currentVanaDay = VanadielDayOfTheYear();
if (currentVanaDay > tailorStartedWorkDay) then
local dancerAFID = 1; -- variable used to convert player's choice into an Item ID.
local playerGender = player:getGender(); --gender is actually important here because it displays the item on screen for you.
if (playersAFChoice == 1) then
dancerAFID = dancersTiara - playerGender;
elseif (playersAFChoice == 2) then
dancerAFID = dancersBangles - playerGender;
elseif (playersAFChoice == 3) then
dancerAFID = dancersToeshoes - playerGender;
end;
player:startEvent(497, dancerAFID);
else
player:startEvent(496); -- not enough time has passed
end;
elseif (player:getCharVar("dancerTailorCS") == 6) then
player:startEvent(498);
else
player:startEvent(499);
end;
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
local completedPieces = player:getCharVar("dancerCompletedAF");
if (csid == 492) then
if (option > 0) then -- option 1 - tiara 2 - bangles 3 - shoes
player:setCharVar("dancerAFChoice", option);
player:setCharVar("dancerTailorCS", 4);
else
player:setCharVar("dancerTailorCS", 3);
end;
elseif (csid == 493) then
if (option > 0) then -- option 1 - tiara 2 - bangles 3 - shoes
local choiceBit = bit.lshift(1, option - 1) --check to see if the player already did this piece
if (bit.band(choiceBit, completedPieces) == choiceBit) then
player:startEvent(498);
else
player:setCharVar("dancerAFChoice", option);
player:setCharVar("dancerTailorCS", 4);
end;
end;
elseif (csid == 497) then -- reward player the appropriate AF
local dancerAFID = 1; -- variable used to convert player's choice into an Item ID.
local playersAFChoice = player:getCharVar("dancerAFChoice");
if (playersAFChoice == 1) then
dancerAFID = dancersTiara;
elseif (playersAFChoice == 2) then
dancerAFID = dancersBangles;
elseif (playersAFChoice == 3) then
dancerAFID = dancersToeshoes;
end;
if (player:getFreeSlotsCount() == 0) then --check to see if the player has enough inventory space before rewarding them.
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED, dancerAFID);
else
local playerGender = player:getGender();
player:addItem(dancerAFID - playerGender);
player:messageSpecial(ID.text.ITEM_OBTAINED, dancerAFID);
local allPiecesCompleted = 7;
if (bit.band(completedPieces, allPiecesCompleted) == allPiecesCompleted) then
player:setCharVar("dancerTailorCS",6); -- final cs flag
else
local playersReward = bit.lshift(1, playersAFChoice - 1)
completedPieces = bit.bor(completedPieces, playersReward);
player:setCharVar("dancerCompletedAF", completedPieces);
player:setCharVar("dancerTailorCS", 3);
end;
end;
else
-- do nothing
end;
end; | gpl-3.0 |
jugglerchris/textadept-vi | vi_quickfix.lua | 1 | 3692 | -- Implement quickfix-like functionality.
local M = {}
local lpeg = require('lpeg')
local P = lpeg.P
local S = lpeg.S
local C = lpeg.C
local R = lpeg.R
local Ct = lpeg.Ct
local Cg = lpeg.Cg
local Cc = lpeg.Cc
local ws = S" \t"
local to_nl = (P(1) - P"\n") ^ 0
local errpat_newdir = Ct(P"make: Entering directory " * S("'`") * Cg((P(1) - P"'")^0, 'newdir')* P"'")
local errpat_leavedir = Ct(P"make: Leaving directory " * S("'`") * Cg((P(1) - P"'")^0, 'leavedir')* P"'")
local errpat_error = Ct((P"In file included from " ^-1) * Cg((P(1) - S":\n") ^ 0, 'path') * P":" * Cg(R"09" ^ 0, 'lineno') * P":" * ((Cg(R"09" ^ 0, 'colno') * P":")^-1) * (S(" \t") ^ 0) * Cg(to_nl, "message"))
local errpat_error_nofile = Ct((P"error" + P"Error" + P"ERROR") * P":" * ws * Cg(to_nl, "message")) +
Ct(Cg(P"make: ***" * to_nl, "message"))
local errpat_ignore = (P(1) - "\n") ^ 0
local errpat_line = (errpat_newdir + errpat_error + errpat_error_nofile)-- + errpat_ignore)
local function pretty(x)
if type(x) == 'table' then
local bits = {'{\n'}
for k,v in pairs(x) do
bits[#bits+1] = " "
bits[#bits+1] = pretty(k)
bits[#bits+1] = " = "
bits[#bits+1] = pretty(v)
bits[#bits+1] = "\n"
end
bits[#bits+1] = '}\n'
return table.concat(bits)
elseif type(x) == 'string' then
return "'" .. x .. "'"
else
return tostring(x)
end
end
local function ts(...)
local args = {...}
local bits = {}
for i,v in ipairs(args) do
bits[#bits + 1] = pretty(v)
bits[#bits + 1] = ","
end
return table.concat(bits)
end
function M.quickfix_from_buffer(buffer)
local dirs = {}
local results = {}
for i=1,buffer.line_count do
local line = buffer:get_line(i)
line = line:match("([^\n]*)")
local match = errpat_line:match(line)
if match then
if match.newdir then
dirs[#dirs+1] = match.newdir
elseif match.leavedir then
if dirs[#dirs] ~= match.leavedir then
error("Non-matching leave directory")
else
dirs[#dirs] = nil
end
elseif match.path or match.message then
local path = match.path
local lineno = match.lineno and tonumber(match.lineno) or nil
local colno = match.colno and tonumber(match.colno) or nil
local message = match.message
-- Get any extra lines of a multi-line message
local errline = i + 1
while errline <= buffer.line_count do
local contline = buffer:get_line(errline)
local matchlen = contline:match("^[ %d]* | ()")
if matchlen then
message = message .. "\n" .. contline:sub(matchlen)
contline = contline:match("([^\n]*)")
line = line .. "\n" .. contline
i = i + 1
else
break
end
errline = errline + 1
end
if path and #dirs > 0 then
path = dirs[#dirs] .. "/" .. path
end
local idx = #results + 1
results[idx] = { line, path=path, lineno=lineno, colno=colno, idx=idx, message=message }
end
end
--cme_log("<"..buffer:get_line(i)..">")
--cme_log("{"..ts(errpat_newdir:match((buffer:get_line(i)))).."}")
--cme_log(ts(errpat_line:match((buffer:get_line(i)))))
end
return results
end
return M
| mit |
JarnoVgr/InfectedWars | entities/effects/refract_ring/init.lua | 1 | 1986 | --[[-----------------------------------------------------------------------------
* Infected Wars, an open source Garry's Mod game-mode.
*
* Infected Wars is the work of multiple authors,
* a full list can be found in CONTRIBUTORS.md.
* For more information, visit https://github.com/JarnoVgr/InfectedWars
*
* Infected Wars is free software: you can redistribute it and/or modify
* it under the terms of the MIT License.
*
* A full copy of the MIT License can be found in LICENSE.txt.
-----------------------------------------------------------------------------]]
local matRefraction = Material( "refract_ring" )
/*---------------------------------------------------------
Initializes the effect. The data is a table of data
which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
self.Refract = 0
self.Size = 32
self.Entity:SetRenderBounds( Vector()*-512, Vector()*512 )
end
/*---------------------------------------------------------
THINK
Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )
self.Refract = self.Refract + 3.0 * FrameTime()
self.Size = 512 * self.Refract^(0.4)
if ( self.Refract >= 2 ) then return false end
return true
end
/*---------------------------------------------------------
Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()
local MySelf = LocalPlayer()
if ( self.Entity:GetPos():Distance( MySelf:GetPos() ) > 1200 ) then
return
end
local Distance = EyePos():Distance( self.Entity:GetPos() )
local Pos = self.Entity:GetPos() + (EyePos()-self.Entity:GetPos()):GetNormal() * Distance * (self.Refract^(0.3)) * 0.8
matRefraction:SetMaterialFloat( "$refractamount", self.Refract * 0.1 )
render.SetMaterial( matRefraction )
render.UpdateRefractTexture()
render.DrawSprite( Pos, self.Size, self.Size )
end
| mit |
Colettechan/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Saluhwa.lua | 13 | 1480 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Saluhwa
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,SALUHWA_SHOP_DIALOG);
stock = {0x3002,605, -- Mapple Shield (Available when AC is in the city)
0x3003,1815, -- Elm Shield (Available when AC is in the city)
0x3004,4980, -- Mahogany Shield (Available when AC is in the city)
0x3005,15600, -- Oak Shield (Available when AC is in the city)
0x3007,64791} -- Round Shield (Available when AC is in the city)
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/spells/barthunder.lua | 1 | 1425 | -----------------------------------------
-- Spell: BARTHUNDER
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local enhanceSkill = caster:getSkillLevel(ENHANCING_MAGIC_SKILL);
local power = calculateBarspellPower(caster,enhanceSkill);
local mdefBonus = caster:getMerit(MERIT_BAR_SPELL_EFFECT) + caster:getMod(MOD_BARSPELL_MDEF_BONUS);
local duration = 150;
if (enhanceSkill > 180) then
duration = 150 + 0.8 * (enhanceSkill - 180);
end
if (caster:hasStatusEffect(EFFECT_COMPOSURE) == true and caster:getID() == target:getID()) then
duration = duration * 3;
end
if (caster:hasStatusEffect(EFFECT_PERPETUANCE)) then
duration = duration * 2;
end
if (caster:hasStatusEffect(EFFECT_RAPTURE)) then
power = power * 1.5;
end
if ((caster:getID() == target:getID()) and target:getEffectsCount(EFFECT_TELLUS) >= 1) then
power = power * 1.25;
mdefBonus = mdefBonus + 10;
end
power, duration = applyEmbolden(caster, power, duration);
target:addStatusEffect(EFFECT_BARTHUNDER,power,0,duration,0,mdefBonus);
return EFFECT_BARTHUNDER;
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/effects/magic_shield.lua | 33 | 1698 | -----------------------------------
--
-- Magic Shield BLOCKS all magic attacks
--
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
if (effect:getPower() == 3) then -- arcane stomp
target:addMod(MOD_FIRE_ABSORB, 100);
target:addMod(MOD_EARTH_ABSORB, 100);
target:addMod(MOD_WATER_ABSORB, 100);
target:addMod(MOD_WIND_ABSORB, 100);
target:addMod(MOD_ICE_ABSORB, 100);
target:addMod(MOD_LTNG_ABSORB, 100);
target:addMod(MOD_LIGHT_ABSORB, 100);
target:addMod(MOD_DARK_ABSORB, 100);
elseif (effect:getPower() < 2) then
target:addMod(MOD_UDMGMAGIC, -101);
else
target:addMod(MOD_MAGIC_ABSORB, 100);
end;
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
if (effect:getPower() == 3) then -- arcane stomp
target:delMod(MOD_FIRE_ABSORB, 100);
target:delMod(MOD_EARTH_ABSORB, 100);
target:delMod(MOD_WATER_ABSORB, 100);
target:delMod(MOD_WIND_ABSORB, 100);
target:delMod(MOD_ICE_ABSORB, 100);
target:delMod(MOD_LTNG_ABSORB, 100);
target:delMod(MOD_LIGHT_ABSORB, 100);
target:delMod(MOD_DARK_ABSORB, 100);
elseif (effect:getPower() < 2) then
target:delMod(MOD_UDMGMAGIC, -101);
else
target:delMod(MOD_MAGIC_ABSORB, 100);
end;
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Xarcabard/npcs/Luck_Rune.lua | 14 | 1042 | -----------------------------------
-- Area: Xarcabard
-- NPC: Luck Rune
-- Involved in Quest: Mhaura Fortune
-- @pos 576.117 -0.164 -16.935 112
-----------------------------------
package.loaded["scripts/zones/Xarcabard/TextIDs"] = nil;
-------------------------------------
require("scripts/zones/Xarcabard/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(NOTHING_OUT_OF_THE_ORDINARY);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
scholzd/libmoon | examples/reflector.lua | 4 | 1855 | --- Layer 2 reflector, swaps src and dst MACs and echoes the packet
local lm = require "libmoon"
local memory = require "memory"
local device = require "device"
local stats = require "stats"
local lacp = require "proto.lacp"
function configure(parser)
parser:argument("dev", "Devices to use."):args("+"):convert(tonumber)
parser:option("-t --threads", "Number of threads per device."):args(1):convert(tonumber):default(1)
parser:flag("-l --lacp", "Try to setup an LACP channel.")
parser:option("-o --output", "File to output statistics to")
return parser:parse()
end
function master(args)
local lacpQueues = {}
for i, dev in ipairs(args.dev) do
local dev = device.config{
port = dev,
rxQueues = args.threads + (args.lacp and 1 or 0),
txQueues = args.threads + (args.lacp and 1 or 0),
rssQueues = args.threads
}
-- last queue for lacp
if args.lacp then
table.insert(lacpQueues, {rxQueue = dev:getRxQueue(args.threads), txQueue = dev:getTxQueue(args.threads)})
end
args.dev[i] = dev
end
device.waitForLinks()
-- setup lacp if requested
if args.lacp then
lacp.startLacpTask("bond0", lacpQueues)
lacp.waitForLink("bond0")
end
-- print statistics
stats.startStatsTask{devices = args.dev, file = args.output}
for i, dev in ipairs(args.dev) do
for i = 1, args.threads do
lm.startTask("reflector", dev:getRxQueue(i - 1), dev:getTxQueue(i - 1))
end
end
lm.waitForTasks()
end
function reflector(rxQ, txQ)
local bufs = memory.bufArray()
while lm.running() do
local rx = rxQ:tryRecv(bufs, 1000)
for i = 1, rx do
-- swap MAC addresses
local pkt = bufs[i]:getEthernetPacket()
local tmp = pkt.eth:getDst()
pkt.eth:setDst(pkt.eth:getSrc())
pkt.eth:setSrc(tmp)
local vlan = bufs[i]:getVlan()
if vlan then
bufs[i]:setVlan(vlan)
end
end
txQ:sendN(bufs, rx)
end
end
| mit |
Colettechan/darkstar | scripts/zones/Dynamis-Bastok/npcs/qm1.lua | 13 | 1302 | -----------------------------------
-- Area: Dynamis Bastok
-- NPC: qm1 (???)
-- Notes: Spawns when Megaboss is defeated
-----------------------------------
package.loaded["scripts/zones/Dynamis-Bastok/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/zones/Dynamis-Bastok/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(HYDRA_CORPS_EYEGLASS) == false) then
player:setVar("DynaBastok_Win",1);
player:addKeyItem(HYDRA_CORPS_EYEGLASS);
player:messageSpecial(KEYITEM_OBTAINED,HYDRA_CORPS_EYEGLASS);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Kazham/npcs/Cobbi_Malgharam.lua | 17 | 1073 | -----------------------------------
-- Area: Kazham
-- NPC: Cobbi Malgharam
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/zones/Kazham/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("BathedInScent") == 1) then
player:startEvent(0x00A1); -- scent from Blue Rafflesias
else
player:startEvent(0x0029);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Waughroon_Shrine/npcs/Burning_Circle.lua | 14 | 2281 | -----------------------------------
-- Area: Waughroon Shrine
-- NPC: Burning Circle
-- Waughroon Shrine Burning Circle
-- @pos -345 104 -260 144
-------------------------------------
package.loaded["scripts/zones/Waughroon_Shrine/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/bcnm");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/globals/missions");
require("scripts/zones/Waughroon_Shrine/TextIDs");
---- 0: Rank 2 Final Mission for Bastok "The Emissary" and Sandy "Journey Abroad"
---- 1: Worms Turn
---- 2: Grimshell Shocktroopers
---- 3: On my Way
---- 4: Thief in Norg
---- 5: 3, 2, 1
---- 6: Shattering Stars (RDM)
---- 7: Shattering Stars (THF)
---- 8: Shattering Stars (BST)
---- 9: Birds of the feather
---- 10: Crustacean Conundrum
---- 11: Grove Gardians
---- 12: The Hills are alive
---- 13: Royal Jelly
---- 14: The Final Bout
---- 15: Up in arms
---- 16: Copy Cat
---- 17: Operation Desert Swarm
---- 18: Prehistoric Pigeons
---- 19: The Palborough Project
---- 20: Shell Shocked
---- 21: Beyond infinity
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (TradeBCNM(player,player:getZoneID(),trade,npc)) then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (EventTriggerBCNM(player,npc)) then
return;
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("onUpdate CSID: %u",csid);
-- printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option)) then
return;
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("onFinish CSID: %u",csid);
-- printf("onFinish RESULT: %u",option);
if (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Al_Zahbi/npcs/Banjanu.lua | 14 | 1038 | -----------------------------------
-- Area: Al Zahbi
-- NPC: Banjanu
-- Type: Standard NPC
-- @zone 48
-- @pos -75.954 0.999 105.367
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0106);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Beadeaux/npcs/Haggleblix.lua | 12 | 6781 | -----------------------------------
-- Area: Beadeaux
-- NPC: Haggleblix
-- Type: Dynamis NPC
-- !pos -255.847 0.595 106.485 147
-----------------------------------
local ID = require("scripts/zones/Beadeaux/IDs");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
require("scripts/globals/dynamis");
local TIMELESS_HOURGLASS = 4236;
local currency = {1455,1456,1457};
local shop = {
7, 1313, -- Siren's Hair
8, 1521, -- Slime Juice
9, 1469, -- Wootz Ore
12, 4246, -- Cantarella
20, 1468, -- Marksman's Oil
25, 1461, -- Wootz Ingot
33, 1460, -- Koh-I-Noor
}
local maps = {
[dsp.ki.MAP_OF_DYNAMIS_SANDORIA] = 10000,
[dsp.ki.MAP_OF_DYNAMIS_BASTOK] = 10000,
[dsp.ki.MAP_OF_DYNAMIS_WINDURST] = 10000,
[dsp.ki.MAP_OF_DYNAMIS_JEUNO] = 10000,
[dsp.ki.MAP_OF_DYNAMIS_BEAUCEDINE] = 15000,
[dsp.ki.MAP_OF_DYNAMIS_XARCABARD] = 20000,
[dsp.ki.MAP_OF_DYNAMIS_VALKURM] = 10000,
[dsp.ki.MAP_OF_DYNAMIS_BUBURIMU] = 10000,
[dsp.ki.MAP_OF_DYNAMIS_QUFIM] = 10000,
[dsp.ki.MAP_OF_DYNAMIS_TAVNAZIA] = 20000,
}
-----------------------------------
function onTrade(player,npc,trade)
local gil = trade:getGil();
local count = trade:getItemCount();
if (player:hasKeyItem(dsp.ki.VIAL_OF_SHROUDED_SAND)) then
-- buy prismatic hourglass
if (gil == PRISMATIC_HOURGLASS_COST and count == 1 and not player:hasKeyItem(dsp.ki.PRISMATIC_HOURGLASS)) then
player:startEvent(134);
-- return timeless hourglass for refund
elseif (count == 1 and trade:hasItemQty(TIMELESS_HOURGLASS,1)) then
player:startEvent(153);
-- currency exchanges
elseif (count == CURRENCY_EXCHANGE_RATE and trade:hasItemQty(currency[1],CURRENCY_EXCHANGE_RATE)) then
player:startEvent(135,CURRENCY_EXCHANGE_RATE);
elseif (count == CURRENCY_EXCHANGE_RATE and trade:hasItemQty(currency[2],CURRENCY_EXCHANGE_RATE)) then
player:startEvent(136,CURRENCY_EXCHANGE_RATE);
elseif (count == 1 and trade:hasItemQty(currency[3],1)) then
player:startEvent(138,currency[3],currency[2],CURRENCY_EXCHANGE_RATE);
-- shop
else
local item;
local price;
for i=1,13,2 do
price = shop[i];
item = shop[i+1];
if (count == price and trade:hasItemQty(currency[2],price)) then
player:setLocalVar("hundoItemBought", item);
player:startEvent(137,currency[2],price,item);
break;
end
end
end
end
end;
function onTrigger(player,npc)
if (player:hasKeyItem(dsp.ki.VIAL_OF_SHROUDED_SAND)) then
player:startEvent(133, currency[1], CURRENCY_EXCHANGE_RATE, currency[2], CURRENCY_EXCHANGE_RATE, currency[3], PRISMATIC_HOURGLASS_COST, TIMELESS_HOURGLASS, TIMELESS_HOURGLASS_COST);
else
player:startEvent(130);
end
end;
function onEventUpdate(player,csid,option)
if (csid == 133) then
-- asking about hourglasses
if (option == 1) then
if (not player:hasItem(TIMELESS_HOURGLASS)) then
-- must figure out what changes here to prevent the additional dialog
-- player:updateEvent(?);
end
-- shop
elseif (option == 2) then
player:updateEvent(unpack(shop,1,8));
elseif (option == 3) then
player:updateEvent(unpack(shop,9,14));
-- offer to trade down from a 10k
elseif (option == 10) then
player:updateEvent(currency[3], currency[2], CURRENCY_EXCHANGE_RATE);
-- main menu (param1 = dynamis map bitmask, param2 = gil)
elseif (option == 11) then
player:updateEvent(getDynamisMapList(player), player:getGil());
-- maps
elseif (maps[option] ~= nil) then
local price = maps[option];
if (price > player:getGil()) then
player:messageSpecial(ID.text.NOT_ENOUGH_GIL);
else
player:delGil(price);
player:addKeyItem(option);
player:messageSpecial(ID.text.KEYITEM_OBTAINED, option);
end
player:updateEvent(getDynamisMapList(player),player:getGil());
end
end
end;
function onEventFinish(player,csid,option)
-- bought prismatic hourglass
if (csid == 134) then
player:tradeComplete();
player:addKeyItem(dsp.ki.PRISMATIC_HOURGLASS);
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.PRISMATIC_HOURGLASS);
-- refund timeless hourglass
elseif (csid == 153) then
player:tradeComplete();
player:addGil(TIMELESS_HOURGLASS_COST);
player:messageSpecial(ID.text.GIL_OBTAINED,TIMELESS_HOURGLASS_COST);
-- singles to hundos
elseif (csid == 135) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,currency[2]);
else
player:tradeComplete();
player:addItem(currency[2]);
player:messageSpecial(ID.text.ITEM_OBTAINED,currency[2]);
end
-- hundos to 10k pieces
elseif (csid == 136) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,currency[3]);
else
player:tradeComplete();
player:addItem(currency[3]);
player:messageSpecial(ID.text.ITEM_OBTAINED,currency[3]);
end
-- 10k pieces to hundos
elseif (csid == 138) then
local slotsReq = math.ceil(CURRENCY_EXCHANGE_RATE / 99);
if (player:getFreeSlotsCount() < slotsReq) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,currency[2]);
else
player:tradeComplete();
for i=1,slotsReq do
if (i < slotsReq or (CURRENCY_EXCHANGE_RATE % 99) == 0) then
player:addItem(currency[2],CURRENCY_EXCHANGE_RATE);
else
player:addItem(currency[2],CURRENCY_EXCHANGE_RATE % 99);
end
end
player:messageSpecial(ID.text.ITEMS_OBTAINED,currency[2],CURRENCY_EXCHANGE_RATE);
end
-- bought item from shop
elseif (csid == 137) then
local item = player:getLocalVar("hundoItemBought");
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,item);
else
player:tradeComplete();
player:addItem(item);
player:messageSpecial(ID.text.ITEM_OBTAINED,item);
end
player:setLocalVar("hundoItemBought", 0);
end
end;
| gpl-3.0 |
benqiu2016/nifi-minifi-cpp | thirdparty/civetweb-1.10/test/filehandler.lua | 11 | 2399 | function send_ok()
mg.write("HTTP/1.0 200 OK\r\n")
mg.write("Connection: close\r\n")
mg.write("Date: " .. os.date("%a, %d %b %Y %H:%M:%S GMT") .. "\r\n")
end
function send_not_found()
mg.write("HTTP/1.0 404 Not Found\r\n")
mg.write("Connection: close\r\n")
mg.write("Date: " .. os.date("%a, %d %b %Y %H:%M:%S GMT") .. "\r\n")
end
handler = "filehandler.lua"
sub_uri = mg.request_info.uri:sub(#handler+2)
filename = "D:\\civetweb\\civetweb" .. sub_uri
attr = lfs.attributes(filename)
--[[
if not attr then
send_not_found()
mg.write("\r\n")
mg.write("File " .. sub_uri .. " not available")
return
end
]]
if mg.request_info.request_method == "GET" then
-- send_file will handle 404 internally
mg.send_file(filename)
return
elseif mg.request_info.request_method == "HEAD" then
-- send_file can handle "GET" and "HEAD"
mg.send_file(filename)
return
elseif mg.request_info.request_method == "PUT" then
local f = io.open(filename, "w")
if (not f) then
mg.write("HTTP/1.0 500 Internal Server Error\r\n")
mg.write("Connection: close\r\n")
mg.write("Date: " .. os.date("%a, %d %b %Y %H:%M:%S GMT") .. "\r\n")
mg.write("\r\n")
return
end
mg.write("HTTP/1.0 201 Created\r\n")
mg.write("Connection: close\r\n")
mg.write("Date: " .. os.date("%a, %d %b %Y %H:%M:%S GMT") .. "\r\n")
mg.write("\r\n")
repeat
local buf = mg.read();
if (buf) then
f:write(buf)
end
until (not buf);
f:close()
mg.write("HTTP/1.0 201 Created\r\n")
mg.write("Connection: close\r\n")
mg.write("Date: " .. os.date("%a, %d %b %Y %H:%M:%S GMT") .. "\r\n")
mg.write("\r\n")
return
elseif mg.request_info.request_method == "DELETE" then
if not attr then
send_not_found()
mg.write("\r\n")
mg.write("File " .. sub_uri .. " not available")
return
end
os.remove(filename)
mg.write("HTTP/1.0 204 No Content\r\n")
mg.write("Connection: close\r\n")
mg.write("Date: " .. os.date("%a, %d %b %Y %H:%M:%S GMT") .. "\r\n")
mg.write("\r\n")
return
elseif mg.request_info.request_method == "OPTIONS" then
send_ok()
mg.write("Allow: GET, HEAD, PUT, DELETE, OPTIONS\r\n")
mg.write("\r\n")
return
else
mg.write("HTTP/1.0 405 Method Not Allowed\r\n")
mg.write("Connection: close\r\n")
mg.write("Date: " .. os.date("%a, %d %b %Y %H:%M:%S GMT") .. "\r\n")
mg.write("\r\n")
return
end
| apache-2.0 |
Colettechan/darkstar | scripts/globals/weaponskills/blast_arrow.lua | 9 | 1362 | -----------------------------------
-- Blast Arrow
-- Archery weapon skill
-- Skill level: 200
-- Delivers a melee-distance ranged attack. params.accuracy varies with TP.
-- Aligned with the Snow Gorget & Light Gorget.
-- Aligned with the Snow Belt & Light Belt.
-- Element: None
-- Modifiers: STR:16% ; AGI:25%
-- 100%TP 200%TP 300%TP
-- 2.00 2.00 2.00
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary)
local params = {};
params.numHits = 1;
params.ftp100 = 2; params.ftp200 = 2; params.ftp300 = 2;
params.str_wsc = 0.16; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.25; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.8; params.acc200= 0.9; params.acc300= 1;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.20; params.agi_wsc = 0.50;
end
local damage, criticalHit, tpHits, extraHits = doRangedWeaponskill(player, target, wsID, params, tp, primary);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Feretory/Zone.lua | 32 | 1164 | -----------------------------------
--
-- Zone: Feretory
--
-----------------------------------
package.loaded["scripts/zones/Marjami_Ravine/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Marjami_Ravine/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
player:setPos(-358.000, -3.400, -440.00, 63);
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/East_Ronfaure/TextIDs.lua | 15 | 1413 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6401; -- You cannot obtain the item <item> come back again after sorting your inventory.
ITEM_OBTAINED = 6406; -- Obtained: <item>.
GIL_OBTAINED = 6407; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6409; -- Obtained key item: <keyitem>.
FISHING_MESSAGE_OFFSET = 7226; -- You can't fish here.
-- Logging
LOGGING_IS_POSSIBLE_HERE = 7477; -- Logging is possible here if you have
-- General Dialog
RAYOCHINDOT_DIALOG = 7401; -- If you are outmatched, run to the city as quickly as you can.
CROTEILLARD_DIALOG = 7402; -- Sorry, no chatting while I'm on duty.
BLESSED_WATERSKIN = 7446; -- To get water, rade the waterskin you hold with the river.
CHEVAL_RIVER_WATER = 7427; -- You fill your waterskin with water from the river. You now have
NOTHING_OUT_OF_ORDINARY = 6420; -- There is nothing out of the ordinary here.
-- Other Dialog
NOTHING_HAPPENS = 7321; -- Nothing happens...
-- conquest Base
CONQUEST_BASE = 7067; -- Tallying conquest results...
-- chocobo digging
DIG_THROW_AWAY = 7239; -- You dig up ?Possible Special Code: 01??Possible Special Code: 01??Possible Special Code: 01? ?Possible Special Code: 01??Possible Special Code: 05?$?BAD CHAR: 8280??BAD CHAR: 80??BAD CHAR: 80?, but your inventory is full.
FIND_NOTHING = 7241; -- You dig and you dig, but find nothing.
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Ordelles_Caves/npcs/qm3.lua | 13 | 1628 | -----------------------------------
-- Area: Ordelle's Caves
-- NPC: ??? (qm3)
-- Involved in Quest: A Squire's Test II
-- @pos -139 0.1 264 193
-------------------------------------
package.loaded["scripts/zones/Ordelles_Caves/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Ordelles_Caves/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (os.time() - player:getVar("SquiresTestII") <= 60 and player:hasKeyItem(STALACTITE_DEW) == false) then
player:messageSpecial(A_SQUIRE_S_TEST_II_DIALOG_II);
player:addKeyItem(STALACTITE_DEW);
player:messageSpecial(KEYITEM_OBTAINED, STALACTITE_DEW);
player:setVar("SquiresTestII",0);
elseif (player:hasKeyItem(STALACTITE_DEW)) then
player:messageSpecial(A_SQUIRE_S_TEST_II_DIALOG_III);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
player:setVar("SquiresTestII",0);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
zynjec/darkstar | scripts/zones/Southern_San_dOria_[S]/npcs/_6eo.lua | 9 | 1121 | -----------------------------------
-- Area: Southern SandOria [S]
-- NPC: Door:House
-- !pos 148 0 27 80
-----------------------------------
local ID = require("scripts/zones/Southern_San_dOria_[S]/IDs")
require("scripts/globals/quests");
require("scripts/globals/settings");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
if (player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.KNOT_QUITE_THERE) == QUEST_ACCEPTED and player:getCharVar("KnotQuiteThere") == 3) then
player:startEvent(63);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 63) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,751);
else
player:completeQuest(CRYSTAL_WAR, dsp.quest.id.crystalWar.KNOT_QUITE_THERE);
player:addItem(751);
player:messageSpecial(ID.text.ITEM_OBTAINED,751); --Platinum Beastcoin
player:setCharVar("KnotQuiteThere",0);
end
end
end;
| gpl-3.0 |
aminba/iramin | plugins/wlc_by_mobin.lua | 8 | 3761 | local add_user_cfg = load_from_file('data/add_user_cfg.lua')
local function template_add_user(base, to_username, from_username, chat_name, chat_id)
base = base or ''
to_username = '@' .. (to_username or '')
from_username = '@' .. (from_username or '')
chat_name = string.gsub(chat_name, '_', ' ') or ''
chat_id = "chat#id" .. (chat_id or '')
if to_username == "@" then
to_username = ''
end
if from_username == "@" then
from_username = ''
end
base = string.gsub(base, "{to_username}", to_username)
base = string.gsub(base, "{from_username}", from_username)
base = string.gsub(base, "{chat_name}", chat_name)
base = string.gsub(base, "{chat_id}", chat_id)
return base
end
function chat_new_user_link(msg)
local pattern = add_user_cfg.initial_chat_msg
local to_username = msg.from.username
local from_username = 'link (@' .. (msg.action.link_issuer.username or '') .. ')'
local chat_name = msg.to.print_name
local chat_id = msg.to.id
pattern = template_add_user(pattern, to_username, from_username, chat_name, chat_id)
if pattern ~= '' then
local receiver = get_receiver(msg)
send_msg(receiver, pattern, ok_cb, false)
end
end
function chat_new_user(msg)
local pattern = add_user_cfg.initial_chat_msg
local to_username = msg.action.user.username
local from_username = msg.from.username
local chat_name = msg.to.print_name
local chat_id = msg.to.id
pattern = template_add_user(pattern, to_username, from_username, chat_name, chat_id)
if pattern ~= '' then
local receiver = get_receiver(msg)
send_msg(receiver, pattern, ok_cb, false)
end
end
local function description_rules(msg, nama)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
local about = ""
local rules = ""
if data[tostring(msg.to.id)]["description"] then
about = data[tostring(msg.to.id)]["description"]
about = "\nدرباره گروه :\n"..درباره گروه.."\n"
end
if data[tostring(msg.to.id)]["rules"] then
rules = data[tostring(msg.to.id)]["rules"]
rules = "\nقوانین گروه :\n"..قوانین.."\n"
end
local sambutan = "سلام "..نام.."\nخوش امدی to '"..string.gsub(msg.to.print_name, "_", " ").."'\nYou can use /help for see bot commands\n"
local text = sambutan..about..rules.."\n"
local receiver = get_receiver(msg)
send_large_msg(receiver, text, ok_cb, false)
end
end
local function run(msg, matches)
if not msg.service then
return "Are you trying to troll me?"
end
--vardump(msg)
if matches[1] == "chat_add_user" then
if not msg.action.user.username then
nama = string.gsub(msg.action.user.print_name, "_", " ")
else
nama = "@"..msg.action.user.username
end
chat_new_user(msg)
description_rules(msg, nama)
elseif matches[1] == "chat_add_user_link" then
if not msg.from.username then
nama = string.gsub(msg.from.print_name, "_", " ")
else
nama = "@"..msg.from.username
end
chat_new_user_link(msg)
description_rules(msg, nama)
elseif matches[1] == "chat_del_user" then
local bye_name = msg.action.user.first_name
return 'بای بای '..bye_name
end
end
return {
description = "Welcoming Message",
usage = "Welcome: If Added User Or Delete User Bot Send A Welcome Or GoodBye Message.",
patterns = {
"^!!tgservice (chat_add_user)$",
"^!!tgservice (chat_add_user_link)$",
"^!!tgservice (chat_del_user)$",
},
run = run
}
| gpl-2.0 |
zynjec/darkstar | scripts/zones/RoMaeve/mobs/Shikigami_Weapon.lua | 11 | 1556 | -----------------------------------
-- Area: RoMaeve
-- NM: Shikigami Weapon
-----------------------------------
require("scripts/globals/pathfind")
require("scripts/globals/regimes")
require("scripts/globals/status")
-----------------------------------
local path =
{
-47, -4, -37,
-49, -4, -37,
-54, -4, -37,
-59, -4, -43,
-67, -3.7, -50.6,
-76, -1.4, -60,
-87, -1, -69,
-104, -3, -58,
-118, -3, -46,
-112, -3.5, -28,
-98, -6, -16,
-84, -6, -9,
-64, -6, 1.1,
-40, -6, 9.6,
-20, -6, 12,
-10, -6.2, 11,
31, -6, 11,
52, -6, 5,
75, -6, -4,
94, -6, -14,
110, -4.2, -25,
118, -3, -34,
109, -3.25, -55,
87, -1, -70,
68, -3.3, -53,
57, -4, -41,
28, -4, -37,
6, -4, -35,
-15, -4, -36,
-23, -4, -36,
-35, -4, -36,
}
function onMobInitialize(mob)
mob:setMod(dsp.mod.REGEN, 5) -- "Has a minor Auto Regen effect"
end
function onMobSpawn(mob)
mob:setStatus(dsp.status.INVISIBLE)
onMobRoam(mob)
end
function onPath(mob)
dsp.path.patrol(mob, path, dsp.path.flag.RUN)
end
function onMobRoam(mob)
-- move to start position if not moving
if not mob:isFollowingPath() then
mob:pathThrough(dsp.path.first(path), dsp.path.flag.RUN)
end
end
function onMobEngaged(mob,target)
mob:setStatus(dsp.status.UPDATE)
end
function onMobDisengage(mob)
mob:setStatus(dsp.status.INVISIBLE)
end
function onMobDeath(mob, player, isKiller)
dsp.regime.checkRegime(player, mob, 119, 2, dsp.regime.type.FIELDS)
end | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/plate_of_fin_sushi_+1.lua | 18 | 1476 | -----------------------------------------
-- ID: 5666
-- Item: plate_of_fin_sushi_+1
-- Food Effect: 60Min, All Races
-----------------------------------------
-- Intelligence 5
-- Accuracy % 17
-- Ranged Accuracy % 17
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,3600,5666);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_INT, 5);
target:addMod(MOD_FOOD_ACCP, 17);
target:addMod(MOD_FOOD_ACC_CAP, 999);
target:addMod(MOD_FOOD_RACCP, 17);
target:addMod(MOD_FOOD_RACC_CAP, 999);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_INT, 5);
target:delMod(MOD_FOOD_ACCP, 17);
target:delMod(MOD_FOOD_ACC_CAP, 999);
target:delMod(MOD_FOOD_RACCP, 17);
target:delMod(MOD_FOOD_RACC_CAP, 999);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/effects/str_down.lua | 34 | 1111 | -----------------------------------
--
-- EFFECT_STR_DOWN
--
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
if ((target:getStat(MOD_STR) - effect:getPower()) < 0) then
effect:setPower(target:getStat(MOD_STR));
end
target:addMod(MOD_STR,-effect:getPower());
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
-- the effect restore strengh of 1 every 3 ticks.
local downSTR_effect_size = effect:getPower()
if (downSTR_effect_size > 0) then
effect:setPower(downSTR_effect_size - 1)
target:delMod(MOD_STR,-1);
end
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
local downSTR_effect_size = effect:getPower()
if (downSTR_effect_size > 0) then
target:delMod(MOD_STR,-downSTR_effect_size);
end
end;
| gpl-3.0 |
qaisjp/openframe | client/gui/gridlist_class.lua | 1 | 14343 | push([[
-----------------------------------------------------------
--- /client/gui/gridlist_class.lua ---
--- Part of openFrame project ---
--- Written by 50p. Additional changes by Orange. ---
--- Lately edited in revision number 13 by Orange ---
--- Licensed under BSD licence ---
-----------------------------------------------------------
-- Class: GridList Class
-- Class which allows to easily add gridlists to windows/screen.
GridList = { };
GridList.__index = GridList;
-- Function: GridList:Create
-- Creates a gridlist
--
-- Required Arguments:
-- x - (float/integer) Space from left side of screen/window
-- y - (float/integer) Space from top side of screen/window
-- width - (float/integer) Width of the gridlist
-- height - (float/integer) Height of the gridlist
--
-- Optional arguments:
-- content - (table) Content of the gridlist
-- relative - (bool) Are the x/y/width/height values relative?
-- parent - (GUI) Parent of the gridlist
--
-- Returns:
-- The result is a gridlist object
function GridList:Create( x, y, width, height, content, relative, parent )
local gridlist = {
gui = false,
sorting = true,
horizontalBar = false,
verticalBar = false,
selectionmode = 0,
columns = { },
onclick = { },
onmouseenter = { },
onmouseleave = { },
cursorovergui = false
};
for i, f in pairs( GUISharedFuncs ) do
if
(
( i ~= "__index" ) and
( i ~= "Text" ) and
( i ~= "Font" )
)
then
gridlist[ i ] = f;
end
end
if type( content ) ~= "table" then
relative, parent = content, relative;
end
gridlist.gui = guiCreateGridList( x, y, width, height, ( type( relative ) == "boolean" ) and relative or false, parent );
if( gridlist.gui ) then
setmetatable( gridlist, self );
self.__index = self;
if type( content ) == "table" then -- if we create a gridlist with table then...
for i, j in ipairs( content ) do
if i == 1 then -- this is columns table
for k, l in ipairs( j ) do
gridlist:AddColumn( unpack( l ) );
end
elseif i == 2 then -- and this is rows table
for k, l in ipairs( j ) do
gridlist:AddRow( unpack( l ) );
end
end
end
end
addEventHandler( "onClientMouseEnter", gridlist.gui, function( ) GUICollection.guiMouseIsOver = gridlist; end, false );
addEventHandler( "onClientMouseLeave", gridlist.gui, function( ) GUICollection.guiMouseIsOver = false; end, false );
addEventHandler( "onClientGUIClick",
gridlist.gui,
function( mouseBtn, state, x, y )
if type( gridlist.onclick ) == "table" then
for i, f in pairs( gridlist.onclick ) do
f( gridlist, mouseBtn, state, x, y );
end
end
end,
false
);
addEventHandler( "onClientMouseEnter",
gridlist.gui,
function( x, y )
if type( gridlist.onmouseenter ) == "table" then
for _, f in pairs( gridlist.onmouseenter ) do
if type( f ) == "function" then
f( gridlist, x, y );
end
end
end
end,
false
)
addEventHandler( "onClientMouseLeave",
gridlist.gui,
function( x, y )
if type( gridlist.onmouseleave ) == "table" then
for _, f in pairs( gridlist.onmouseleave ) do
if type( f ) == "function" then
f( gridlist, x, y );
end
end
end
end,
false
)
return gridlist;
end
return false
end
-- Function: GridList:AutoSizeColumn
-- Autosizes specified column
--
-- Required Arguments:
-- columnID - (integer) Integer of the column to size
--
-- Returns:
-- The result is true if autosized, false if not
function GridList:AutoSizeColumn( columnID )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( columnID ) == "number" ) then
return guiGridListAutoSizeColumn( self.gui, columnID );
end
return false;
end
-- Function: GridList:AddColumn
-- Adds a column
--
-- Required Arguments:
-- title - (string) Title of the column to add
--
-- Optional Arguments:
-- width - (integer) The width of the column to add
--
-- Returns:
-- The result is true if added, false if not
function GridList:AddColumn( title, width )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( title ) == "string" ) and ( type( width ) == "number" ) then
local temp = guiGridListAddColumn( self.gui, title, width );
if temp then
table.insert( self.columns, temp );
return temp;
end
end
return false;
end
-- Function: GridList:AddRow
-- Adds a row
--
-- Required Arguments:
-- ... - (strings) Values in the row
--
-- Returns:
-- The result is true if added, false if not
function GridList:AddRow( ... )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false;
end
local temp = guiGridListAddRow( self.gui );
if temp then
if ( ( #arg > 0 ) and ( #arg <= self:ColumnCount() ) ) then
for i, txt in ipairs( arg ) do
guiGridListSetItemText( self.gui, temp, i, txt, false, false );
end
return temp;
end
end
return false;
end
-- Function: GridList:Clear
-- Clears the gridlist
--
-- Returns:
-- The result is true if cleared, false if not
function GridList:Clear( )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
self.columns = nil;
self.columns = { };
return guiGridListClear( self.gui );
end
-- Function: GridList:ClearRows
-- Clears the gridlist's rows
--
-- Returns:
-- The result is true if cleared, false if not
function GridList:ClearRows( )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
return guiGridListClear( self.gui );
end
-- Function: GridList:ItemData
-- Gets/sets data of an item
--
-- Required Arguments:
-- rowID - (integer) Number of the row
-- columnID - (integer) Number of the column
--
-- Optional Arguments:
-- data - (string) If set, the row data will be set to it
--
-- Returns:
-- * String if tried to get
-- * If tried to set, true if setted, false if not
function GridList:ItemData( rowID, columnID, data )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( rowID ) == "number" ) and ( type( columnID ) == "number" ) then
if ( type( data ) == "string" ) then
return guiGridListSetItemData( self.gui, rowID, columnID, data );
else
return guiGridListGetItemData( self.gui, rowID, columnID );
end
end
return false
end
-- Function: GridList:ItemText
-- Gets/sets text of an gridlist row's item
--
-- Required Arguments:
-- rowID - (integer) Number of the row
-- columnID - (integer) Number of the column
--
-- Optional Arguments:
-- text - (string) If set, the value of a column in a row will be set to it.
-- section - (string) ?
-- number - (string) ?
--
-- Returns:
-- * String if tried to get
-- * If tried to set, true if setted, false if not
function GridList:ItemText( rowID, columnID, text, section, number )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( rowID ) == "number" ) and ( type( columnID ) == "number" ) then
if ( type( text ) == "string" ) then
return guiGridListSetItemText( self.gui, rowID, columnID, text,
( type( section ) == "boolean" ) and section or false,
( type( number ) == "boolean" ) and number or false );
else
return guiGridListGetItemText( self.gui, rowID, columnID );
end
end
return false;
end
-- Function: GridList:SelectedItem
-- Gets/sets selected item
--
-- Optional Arguments:
-- rowID - (integer) If set, the selected item will be set to it.
-- columnID - (integer) If set, the selected item will be set to it.
--
-- Returns:
-- * Position of selected item if tried to get
-- * If tried to set, true if setted, false if not
function GridList:SelectedItem( rowID, columnID )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( rowID ) == "number" ) and ( type( columnID ) == "number" ) then
return guiGridListSetSelectedItem( self.gui, rowID, columnID )
end
return guiGridListGetSelectedItem( self.gui );
end
-- Function: GridList:SortingEnabled
-- Gets/sets is sorting enabled
--
-- Optional Arguments:
-- enabled - (bool) If set, the sorting state will be set to it.
--
-- Returns:
-- * State of sorting if tried to get
-- * If tried to set, true if setted, false if not
function GridList:SortingEnabled( enabled )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( enabled ) == "boolean" ) then
if( guiGridListSetSortingEnabled( self.gui, enabled ) ) then
self.sorting = enabled;
return true
end
end
return self.sorting;
end
-- Function: GridList:RowCount
-- Returns the count of rows
--
-- Returns:
-- Returns the count of rows
function GridList:RowCount( )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
return guiGridListGetRowCount( self.gui );
end
-- Function: GridList:ColumnCount
-- Returns the count of columns
--
-- Returns:
-- Returns the count of columns
function GridList:ColumnCount( )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
local count = 0;
for _ in pairs( self.columns ) do
count = count + 1;
end
return count;
end
-- Function: GridList:InsertRowAfter
-- Inserts a row after specified row id
--
-- Required Arguments:
-- rowID - (integer) The ID of row to add after
--
-- Returns:
-- Returns true if added, false if not
function GridList:InsertRowAfter( rowID )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( rowID ) == "number" ) then
return guiGridListInsertRowAfter( self.gui, rowID );
end
return false;
end
-- Function: GridList:RemoveColumn
-- Removes column with specified id
--
-- Required Arguments:
-- columnID - (integer) The ID of column to remove
--
-- Returns:
-- Returns true if removed, false if not
function GridList:RemoveColumn( columnID )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( columnID ) == "number" ) then
for i, k in pairs( self.columns ) do
if k == columnID then
local temp = guiGridListRemoveColumn( self.gui, column );
if temp then
table.remove( self.columns, i );
return true;
end
end
end
return false
end
return false
end
-- Function: GridList:RemoveRow
-- Removes row with specified id
--
-- Required Arguments:
-- rowID - (integer) The ID of row to remove
--
-- Returns:
-- Returns true if removed, false if not
function GridList:RemoveRow( rowID )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( rowID ) == "number" ) then
return guiGridListRemoveRow( self.gui, rowID );
end
return false
end
-- Function: GridList:ScrollBars
-- Gets/sets state of scrollbars
--
-- Required Arguments:
-- horizontal - (bool) Is horizontal scrollbar enabled?
-- vertical - (bool) Is vertical scrollbar enabled?
--
-- Returns:
-- Returns true if removed, false if not
function GridList:ScrollBars( horizontal, vertical )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( horizontal ) == "boolean" ) and ( type( vertical ) == "boolean" ) then
if guiGridListSetScrollBars( self.gui, horizontal, vertical ) then
self.horizontalBar = horizontal;
self.verticalBar = vertical;
return true;
end
end
return self.horizontalBar, self.verticalBar;
end
-- Function: GridList:SelectionMode
-- Gets/sets the selection mode
--
-- Required Arguments:
-- mode - (integer) ID of selection mode
--
-- Returns:
-- * Returns state if tried to get
-- * Returns true or false if tried to set
function GridList:SelectionMode( mode )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
if ( type( mode ) == "number" ) then
return guiGridListSetSelectionMode( self.gui, mode );
end
return self.selectiomode;
end
-- Function: GridList:ItemColor
-- Gets/sets the color item
--
-- Required Arguments:
-- rowIndex - (integer) ID of row
-- columnIndex - (integer) ID of column
-- Optional Arguments:
-- If set, the color item will be set to it.
-- red - (integer) ?
-- green - (integer) ?
-- blue - (integer) ?
-- alpha - (integer) ?
-- Returns:
-- * Returns color if tried to get
-- * Returns true or false if tried to set
function GridList:ItemColor( rowIndex, columnIndex, red, green, blue, alpha )
if ( type( self ) ~= "table" ) then
outputDebugString( "calling method incorrectly ( object.method() )! use object:method()", 1 );
return false
end
TableAssert
{
{
value = type( rowIndex );
condition = 'number';
sMsg = '1 argument not is number';
};
{
value = type( columnIndex );
condition = 'number';
sMsg = '2 argument not is number';
};
};
return guiGridListGetItemColor( self.gui, rowIndex, columnIndex, tonumber(red) or 255, tonumber(green) or 255, tonumber(blue) or 255, tonumber(alpha) or 255 );
end
]]) | mit |
Vadavim/jsr-darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Adjutant.lua | 14 | 1061 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Adjutant
-- Type: Standard NPC
-- @zone 94
-- @pos -67.819 -4.499 58.997
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0131);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Rolanberry_Fields/npcs/Field_Manual.lua | 29 | 1061 | -----------------------------------
-- Area: Rolanberry Fields
-- NPC: Field Manual
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/fieldsofvalor");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
startFov(FOV_EVENT_ROLANBERRY,player);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onEventSelection
-----------------------------------
function onEventUpdate(player,csid,menuchoice)
updateFov(player,csid,menuchoice,25,85,86,87,88);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
finishFov(player,csid,option,25,85,86,87,88,FOV_MSG_ROLANBERRY);
end;
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Southern_San_dOria_[S]/npcs/Thierride.lua | 9 | 2808 | -----------------------------------
-- Area: Southern SandOria [S]
-- NPC: Thierride
-- !pos -124 -2 14 80
-----------------------------------
local ID = require("scripts/zones/Southern_San_dOria_[S]/IDs");
require("scripts/globals/quests");
-----------------------------------
-- Item 1019 = Lufet Salt
-- Had to use setCharVar because you have to trade Salts one at a time according to the wiki.
-- Lufet Salt can be obtained by killing Crabs in normal West Ronfaure.
function onTrade(player,npc,trade)
local lufetSalt = trade:hasItemQty(1019,1);
local cnt = trade:getItemCount();
local beansAhoy = player:getQuestStatus(CRYSTAL_WAR,dsp.quest.id.crystalWar.BEANS_AHOY);
if (lufetSalt and cnt == 1 and beansAhoy == QUEST_ACCEPTED) then
if (player:getCharVar("BeansAhoy") == 0 == true) then
player:startEvent(337); -- Traded the Correct Item Dialogue (NOTE: You have to trade the Salts one at according to wiki)
elseif (player:needsToZone() == false) then
player:startEvent(340); -- Quest Complete Dialogue
end
else
player:startEvent(339); -- Wrong Item Traded
end
end;
function onTrigger(player,npc)
local beansAhoy = player:getQuestStatus(CRYSTAL_WAR,dsp.quest.id.crystalWar.BEANS_AHOY);
if (beansAhoy == QUEST_AVAILABLE) then
player:startEvent(334); -- Quest Start
elseif (beansAhoy == QUEST_ACCEPTED) then
player:startEvent(335); -- Quest Active, NPC Repeats what he says but as normal 'text' instead of cutscene.
elseif (beansAhoy == QUEST_COMPLETED and getConquestTally() ~= player:getCharVar("BeansAhoy_ConquestWeek")) then
player:startEvent(342);
elseif (beansAhoy == QUEST_COMPLETED) then
player:startEvent(341);
else
player:startEvent(333); -- Default Dialogue
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 334) then
player:addQuest(CRYSTAL_WAR,dsp.quest.id.crystalWar.BEANS_AHOY);
elseif (csid == 337) then
player:tradeComplete();
player:setCharVar("BeansAhoy",1);
player:needsToZone(true);
elseif (csid == 340 or csid == 342) then
if (player:hasItem(5704,1) or player:getFreeSlotsCount() < 1) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,5704)
else
player:addItem(5704,1);
player:messageSpecial(ID.text.ITEM_OBTAINED,5704);
player:setCharVar("BeansAhoy_ConquestWeek",getConquestTally());
if (csid == 340) then
player:completeQuest(CRYSTAL_WAR,dsp.quest.id.crystalWar.BEANS_AHOY);
player:setCharVar("BeansAhoy",0);
player:tradeComplete();
end
end
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/RuAun_Gardens/npcs/relic.lua | 13 | 1848 | -----------------------------------
-- Area: Ru'Aun Gardens
-- NPC: <this space intentionally left blank>
-- @pos -241 -12 332 130
-----------------------------------
package.loaded["scripts/zones/RuAun_Gardens/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/RuAun_Gardens/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- Working on correct relic, 4 items, Stage 4 item, Shard, Necropsyche, currencypiece
if (player:getVar("RELIC_IN_PROGRESS") == 18299 and trade:getItemCount() == 4 and trade:hasItemQty(18299,1) and
trade:hasItemQty(1578,1) and trade:hasItemQty(1589,1) and trade:hasItemQty(1451,1)) then
player:startEvent(60,18300);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 60) then
if (player:getFreeSlotsCount() < 2) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,18300);
player:messageSpecial(FULL_INVENTORY_AFTER_TRADE,1450);
else
player:tradeComplete();
player:addItem(18300);
player:addItem(1450,30);
player:messageSpecial(ITEM_OBTAINED,18300);
player:messageSpecial(ITEMS_OBTAINED,1450,30);
player:setVar("RELIC_IN_PROGRESS",0);
end
end
end; | gpl-3.0 |
RJRetro/mame | 3rdparty/genie/src/tools/snc.lua | 16 | 3848 | --
-- snc.lua
-- Provides Sony SNC-specific configuration strings.
-- Copyright (c) 2010 Jason Perkins and the Premake project
--
premake.snc = { }
-- TODO: Will cfg.system == "windows" ever be true for SNC? If
-- not, remove the conditional blocks that use this test.
--
-- Set default tools
--
premake.snc.cc = "snc"
premake.snc.cxx = "g++"
premake.snc.ar = "ar"
--
-- Translation of Premake flags into SNC flags
--
local cflags =
{
ExtraWarnings = "-Xdiag=2",
FatalWarnings = "-Xquit=2",
}
local cxxflags =
{
NoExceptions = "", -- No exceptions is the default in the SNC compiler.
NoRTTI = "-Xc-=rtti",
}
--
-- Map platforms to flags
--
premake.snc.platforms =
{
PS3 = {
cc = "ppu-lv2-g++",
cxx = "ppu-lv2-g++",
ar = "ppu-lv2-ar",
cppflags = "-MMD -MP",
}
}
local platforms = premake.snc.platforms
--
-- Returns a list of compiler flags, based on the supplied configuration.
--
function premake.snc.getcppflags(cfg)
local result = { }
table.insert(result, platforms[cfg.platform].cppflags)
return result
end
function premake.snc.getcflags(cfg)
local result = table.translate(cfg.flags, cflags)
table.insert(result, platforms[cfg.platform].flags)
if cfg.kind == "SharedLib" then
table.insert(result, "-fPIC")
end
return result
end
function premake.snc.getcxxflags(cfg)
local result = table.translate(cfg.flags, cxxflags)
return result
end
--
-- Returns a list of linker flags, based on the supplied configuration.
--
function premake.snc.getldflags(cfg)
local result = { }
if not cfg.flags.Symbols then
table.insert(result, "-s")
end
if cfg.kind == "SharedLib" then
table.insert(result, "-shared")
if not cfg.flags.NoImportLib then
table.insert(result, '-Wl,--out-implib="' .. cfg.linktarget.fullpath .. '"')
end
end
local platform = platforms[cfg.platform]
table.insert(result, platform.flags)
table.insert(result, platform.ldflags)
return result
end
--
-- Return a list of library search paths. Technically part of LDFLAGS but need to
-- be separated because of the way Visual Studio calls SNC for the PS3. See bug
-- #1729227 for background on why library paths must be split.
--
function premake.snc.getlibdirflags(cfg)
local result = { }
for _, value in ipairs(premake.getlinks(cfg, "all", "directory")) do
table.insert(result, '-L' .. _MAKE.esc(value))
end
return result
end
--
-- Returns a list of project-relative paths to external library files.
-- This function should examine the linker flags and return any that seem to be
-- a real path to a library file (e.g. "path/to/a/library.a", but not "GL").
-- Useful for adding to targets to trigger a relink when an external static
-- library gets updated.
-- Not currently supported on this toolchain.
--
function premake.snc.getlibfiles(cfg)
local result = {}
return result
end
--
-- This is poorly named: returns a list of linker flags for external
-- (i.e. system, or non-sibling) libraries. See bug #1729227 for
-- background on why the path must be split.
--
function premake.snc.getlinkflags(cfg)
local result = {}
for _, value in ipairs(premake.getlinks(cfg, "system", "name")) do
table.insert(result, '-l' .. _MAKE.esc(value))
end
return result
end
--
-- Decorate defines for the SNC command line.
--
function premake.snc.getdefines(defines)
local result = { }
for _,def in ipairs(defines) do
table.insert(result, '-D' .. def)
end
return result
end
--
-- Decorate include file search paths for the SNC command line.
--
function premake.snc.getincludedirs(includedirs)
local result = { }
for _,dir in ipairs(includedirs) do
table.insert(result, "-I" .. _MAKE.esc(dir))
end
return result
end
| gpl-2.0 |
Colettechan/darkstar | scripts/zones/Grand_Palace_of_HuXzoi/npcs/qm1.lua | 15 | 2751 | -----------------------------------
-- Area: Grand Palace of Hu'Xzoi
-- NPC: ??? (Ix'Aern - MNK)
-- @pos 460 0 540
-- ID: 16916819
-----------------------------------
package.loaded["scripts/zones/Grand_Palace_of_HuXzoi/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Grand_Palace_of_HuXzoi/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local IxAern = 16916815; -- Ix'Aern (MNK). This is the ID base for Ix and his minions.
local chance = 0; -- Rate in percent in which an item will drop.
local validTrade = 0;
-- Trade Organs
if (GetMobAction(IxAern) == 0) then
if (trade:hasItemQty(1900,1) and trade:getItemCount() == 1) then -- 1 HQ Aern Organ (33%)
chance=33;
validTrade=1;
elseif (trade:hasItemQty(1900,2) and trade:getItemCount() == 2) then -- 2 HQ Aern Organ (66%)
chance=66;
validTrade=2;
elseif (trade:hasItemQty(1900,3) and trade:getItemCount() == 3) then -- 3 HQ Aern Organ (100%)
chance=100;
validTrade=3;
end;
end;
if (validTrade > 0) then -- Don't want to take their random shit
player:tradeComplete(); -- Take the items
npc:setLocalVar("[SEA]IxAern_DropRate", chance); -- Used to adjust droprates for IxAern's onMobSpawn.
GetMobByID(IxAern):setSpawn(npc:getXPos(), npc:getYPos(), npc:getZPos());
SpawnMob(IxAern,300):updateClaim(player);
-- Minions
if (validTrade > 1) then
GetMobByID(IxAern+1):setSpawn(npc:getXPos(), npc:getYPos(), npc:getZPos()-4);
SpawnMob(IxAern+1,300):updateClaim(player);
end
if (validTrade > 2) then
GetMobByID(IxAern+2):setSpawn(npc:getXPos(), npc:getYPos(), npc:getZPos()+4);
SpawnMob(IxAern+2,300):updateClaim(player);
end
npc:setStatus(STATUS_DISAPPEAR);
-- Change the location to G-7 or I-7
if (math.random(0,1) ==1) then
npc:setPos(380,0,540,0); -- G-7
else
npc:setPos(460,0,540,0); -- I-7
end;
end;
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
RJRetro/mame | 3rdparty/genie/tests/actions/vstudio/sln2005/dependencies.lua | 47 | 1320 | --
-- tests/actions/vstudio/sln2005/dependencies.lua
-- Validate generation of Visual Studio 2005+ solution project dependencies.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_dependencies = { }
local suite = T.vstudio_sln2005_dependencies
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local sln, prj1, prj2
function suite.setup()
_ACTION = "vs2005"
sln, prj1 = test.createsolution()
uuid "AE61726D-187C-E440-BD07-2556188A6565"
prj2 = test.createproject(sln)
uuid "2151E83B-997F-4A9D-955D-380157E88C31"
links "MyProject"
end
local function prepare(language)
prj1.language = language
prj2.language = language
premake.bake.buildconfigs()
prj1 = premake.solution.getproject(sln, 1)
prj2 = premake.solution.getproject(sln, 2)
sln2005.projectdependencies(prj2)
end
--
-- Tests
--
function suite.On2005_Cpp()
prepare("C++")
test.capture [[
ProjectSection(ProjectDependencies) = postProject
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
EndProjectSection
]]
end
function suite.On2005_Cs()
prepare("C#")
test.capture [[
ProjectSection(ProjectDependencies) = postProject
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
EndProjectSection
]]
end
| gpl-2.0 |
Vadavim/jsr-darkstar | scripts/zones/King_Ranperres_Tomb/Zone.lua | 4 | 2205 | -----------------------------------
--
-- Zone: King_Ranperres_Tomb (190)
--
-----------------------------------
package.loaded["scripts/zones/King_Ranperres_Tomb/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/zone");
require("scripts/zones/King_Ranperres_Tomb/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
local tomes = {17555963,17555964,17555965,17555966};
SetGroundsTome(tomes);
local vwnpc = {17555957,17555958,17555959};
SetVoidwatchNPC(vwnpc);
zone:registerRegion(1,-84.302,6.5,-120.997,-77,7.5,-114); -- Used for stairs teleport -85.1,7,-119.9
-- Vrtra
SetRespawnTime(17555890, 86400, 259200);
UpdateTreasureSpawnPoint(17555951);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(242.012,5.305,340.059,121);
end
return cs;
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
if (region:GetRegionID() == 1) then
player:startEvent(0x0009);
end
end;
-----------------------------------
-- onRegionLeave
-----------------------------------
function onRegionLeave(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/The_Garden_of_RuHmet/npcs/_iz2.lua | 14 | 2003 | -----------------------------------
-- Area: The Garden of RuHmet
-- NPC: _iz2 (Ebon_Panel)
-- @pos 422.351 -5.180 -100.000 35 | Hume Tower
-----------------------------------
package.loaded["scripts/zones/The_Garden_of_RuHmet/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/The_Garden_of_RuHmet/TextIDs");
require("scripts/globals/missions");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local Race = player:getRace();
if (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus") == 1) then
player:startEvent(0x00CA);
elseif (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus") == 2) then
if ( Race==2 or Race==1) then
player:startEvent(0x0078);
else
player:messageSpecial(NO_NEED_INVESTIGATE);
end
else
player:messageSpecial(NO_NEED_INVESTIGATE);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x00CA) then
player:setVar("PromathiaStatus",2);
elseif (0x0078 and option ~=0) then -- Hume
player:addTitle(WARRIOR_OF_THE_CRYSTAL);
player:setVar("PromathiaStatus",3);
player:addKeyItem(LIGHT_OF_VAHZL);
player:messageSpecial(KEYITEM_OBTAINED,LIGHT_OF_VAHZL);
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Northern_San_dOria/npcs/Abeaule.lua | 25 | 4316 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Abeaule
-- Starts and Finishes Quest: The Trader in the Forest, The Medicine Woman
-- @pos -136 -2 56 231
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
theTraderInTheForest = player:getQuestStatus(SANDORIA,THE_TRADER_IN_THE_FOREST);
if (theTraderInTheForest == QUEST_ACCEPTED) then
if (trade:hasItemQty(4367,1) and trade:getItemCount() == 1) then -- Trade Batagreens
player:startEvent(0x020d);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
theTraderInTheForest = player:getQuestStatus(SANDORIA,THE_TRADER_IN_THE_FOREST);
medicineWoman = player:getQuestStatus(SANDORIA,THE_MEDICINE_WOMAN);
if (theTraderInTheForest == QUEST_AVAILABLE) then
if (player:getVar("theTraderInTheForestCS") == 1) then
player:startEvent(0x0250);
else
player:startEvent(0x020c);
player:setVar("theTraderInTheForestCS",1);
end
elseif (theTraderInTheForest == QUEST_ACCEPTED) then
player:startEvent(0x0251);
elseif (theTraderInTheForest == QUEST_COMPLETED and medicineWoman == QUEST_AVAILABLE and player:getFameLevel(SANDORIA) >= 3) then
if (player:getVar("medicineWomanCS") == 1) then
player:startEvent(0x0267);
else
player:startEvent(0x0265);
player:setVar("medicineWomanCS",1);
end
elseif (player:hasKeyItem(COLD_MEDICINE)) then
player:startEvent(0x0266);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
-- "The Trader in the Forest" Quest
if (csid == 0x020c and option == 0 or csid == 0x0250 and option == 0) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,592);
else
player:addQuest(SANDORIA,THE_TRADER_IN_THE_FOREST);
player:setVar("theTraderInTheForestCS",0);
player:addItem(592);
player:messageSpecial(ITEM_OBTAINED,592); -- Supplies Order
end
elseif (csid == 0x0251 and option == 1) then
local SUPPLIES_ORDER = 592;
if (player:getFreeSlotsCount() > 0 and player:hasItem(592) == false) then -- Supplies Order
player:addItem(SUPPLIES_ORDER);
player:messageSpecial(ITEM_OBTAINED, SUPPLIES_ORDER);
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED, SUPPLIES_ORDER);
end
elseif (csid == 0x020d) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,12600); -- Robe
else
player:tradeComplete();
player:addTitle(GREEN_GROCER);
player:addItem(12600);
player:messageSpecial(ITEM_OBTAINED,12600); -- Robe
player:addFame(SANDORIA,30);
player:completeQuest(SANDORIA,THE_TRADER_IN_THE_FOREST);
end
-- "The Medicine Woman" Quest
elseif (csid == 0x0265 and option == 0 or csid == 0x0267 and option == 0) then
player:addQuest(SANDORIA,THE_MEDICINE_WOMAN);
elseif (csid == 0x0266) then
player:addTitle(TRAVELING_MEDICINE_MAN);
player:delKeyItem(COLD_MEDICINE);
player:addGil(GIL_RATE*2100);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*2100);
player:addFame(SANDORIA,30);
player:completeQuest(SANDORIA,THE_MEDICINE_WOMAN);
end
end; | gpl-3.0 |
berinhard/newfies-dialer | lua/libs/tag_replace.lua | 1 | 2630 | --
-- Newfies-Dialer License
-- http://www.newfies-dialer.org
--
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
-- You can obtain one at http://mozilla.org/MPL/2.0/.
--
-- Copyright (C) 2011-2013 Star2Billing S.L.
--
-- The Initial Developer of the Original Code is
-- Arezqui Belaid <info@star2billing.com>
--
local json = require("json")
--
-- Function Replace place holders by tag value.
-- This function will replace all the following tags :
-- {last_name}
-- {first_name}
-- {email}
-- {country}
-- {city}
-- {contact}
-- as well as, get additional_vars, and replace json tags
--
function tag_replace(text, contact)
--decode the json
decdata = decodejson(contact['additional_vars'])
if decdata and type(decdata) == "table" then
-- Merge Table
mcontact = table_merge(contact, decdata)
else
mcontact = contact
end
if not type(mcontact) == "table" then
return text
end
for k, v in pairs(mcontact) do
if k == 'contact' then
newv = ''
for i = 1, string.len(v) do
newv = newv..string.sub(v, i, i)..' '
end
text = string.gsub(text, '{'..k..'}', newv)
elseif string.sub(k, -3) ~= '_id' then
text = string.gsub(text, '{'..k..'}', v)
end
end
-- with .- you match the smallest expression
text = string.gsub(text, '{.-}', '')
return text
end
--
-- Merge table
--
function table_merge(t1, t2)
for k,v in pairs(t2) do
if type(v) == "table" then
if type(t1[k] or false) == "table" then
table_merge(t1[k] or {}, t2[k] or {})
else
t1[k] = v
end
else
t1[k] = v
end
end
return t1
end
--
-- Decode Json and return false if the json have an error
--
function decodejson(jsondata)
cError, res = pcall(json.decode,jsondata)
if not cError then
return false
end
return res
end
--
-- Test
--
if false then
local inspect = require 'inspect'
text = "Hello there {first_name}, your city is {city} and your age is {age}, your number is {contact}"
contact = {
additional_vars = '{"country": "canada", "age": "32", "city":"barcelona"}',
campaign_id = "38",
city = "",
contact = "32132123123",
}
print(inspect(contact))
ntext = tag_replace(text, contact)
print("\nReplaced Text : "..ntext)
print("\nend")
end
| mpl-2.0 |
CosyVerif/library | src/cosy/token/init.lua | 1 | 3263 | if _G.js then
error "Not available"
end
return function (loader)
local Configuration = loader.load "cosy.configuration"
local Digest = loader.load "cosy.digest"
local App = loader.load "cosy.configuration.layers".app
local Jwt = loader.require "jwt"
local Time = loader.require "socket".gettime
math.randomseed (Time ())
Configuration.load {
"cosy.nginx",
"cosy.token",
}
if Configuration.token.secret == nil then
App.token = {
secret = Digest (math.random ())
}
end
local Token = {}
function Token.encode (token)
local options = {
alg = Configuration.token.algorithm,
keys = { private = Configuration.token.secret },
}
local result, err = Jwt.encode (token, options)
if not result then
error (err)
end
return result
end
function Token.decode (s)
local options = {
alg = Configuration.token.algorithm,
keys = { private = Configuration.token.secret },
}
local result, err = Jwt.decode (s, options)
if not result then
error (err)
end
return result
end
function Token.administration ()
local now = Time ()
local result = {
iat = now,
nbf = now - 1,
exp = now + Configuration.expiration.administration,
iss = Configuration.http.hostname,
aud = nil,
sub = "cosy:administration",
jti = Digest (tostring (now + math.random ())),
contents = {
type = "administration",
passphrase = Configuration.server.passphrase,
},
}
return Token.encode (result)
end
function Token.identification (data)
local now = Time ()
local result = {
iat = now,
nbf = now - 1,
exp = now + Configuration.expiration.identification,
iss = Configuration.http.hostname,
aud = nil,
sub = "cosy:identification",
jti = Digest (tostring (now + math.random ())),
contents = {
type = "identification",
data = data,
},
}
return Token.encode (result)
end
function Token.validation (data)
local now = Time ()
local result = {
iat = now,
nbf = now - 1,
exp = now + Configuration.expiration.validation,
iss = Configuration.http.hostname,
aud = nil,
sub = "cosy:validation",
jti = Digest (tostring (now + math.random ())),
contents = {
type = "validation",
identifier = data.identifier,
email = data.email,
},
}
return Token.encode (result)
end
function Token.authentication (data)
local now = Time ()
local result = {
iat = now,
nbf = now - 1,
exp = now + Configuration.expiration.authentication,
iss = Configuration.http.hostname,
aud = nil,
sub = "cosy:authentication",
jti = Digest (tostring (now + math.random ())),
contents = {
type = "authentication",
identifier = data.identifier,
locale = data.locale,
},
}
return Token.encode (result)
end
return Token
end
| mit |
zynjec/darkstar | scripts/globals/items/plate_of_tentacle_sushi.lua | 11 | 1548 | -----------------------------------------
-- ID: 5215
-- Item: plate_of_tentacle_sushi
-- Food Effect: 30Min, All Races
-----------------------------------------
-- HP 20
-- Dexterity 3
-- Agility 3
-- Mind -1
-- Accuracy % 20 (cap 18)
-- Ranged Accuracy % 20 (cap 18)
-- Double Attack 1
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,5215)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.HP, 20)
target:addMod(dsp.mod.DEX, 3)
target:addMod(dsp.mod.AGI, 3)
target:addMod(dsp.mod.MND, -1)
target:addMod(dsp.mod.FOOD_ACCP, 20)
target:addMod(dsp.mod.FOOD_ACC_CAP, 18)
target:addMod(dsp.mod.FOOD_RACCP, 20)
target:addMod(dsp.mod.FOOD_RACC_CAP, 18)
target:addMod(dsp.mod.DOUBLE_ATTACK, 1)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 20)
target:delMod(dsp.mod.DEX, 3)
target:delMod(dsp.mod.AGI, 3)
target:delMod(dsp.mod.MND, -1)
target:delMod(dsp.mod.FOOD_ACCP, 20)
target:delMod(dsp.mod.FOOD_ACC_CAP, 18)
target:delMod(dsp.mod.FOOD_RACCP, 20)
target:delMod(dsp.mod.FOOD_RACC_CAP, 18)
target:delMod(dsp.mod.DOUBLE_ATTACK, 1)
end
| gpl-3.0 |
PhearZero/phear-scanner | bin/nmap-openshift/nselib/tns.lua | 3 | 65400 | ---
-- TNS Library supporting a very limited subset of Oracle operations
--
-- Summary
-- -------
-- The library currently provides functionality to connect and authenticate
-- to the Oracle database server. Some preliminary query support has been
-- added, which only works against a few specific versions. The library has
-- been tested against and known to work with Oracle 10g and 11g. Please check
-- the matrix below for tested versions that are known to work.
--
-- Due to the lack of documentation the library is based mostly on guesswork
-- with a lot of unknowns. Bug reports are therefore both welcome and
-- important in order to further improve this library. In addition, knowing
-- that the library works against versions not in the test matrix is valuable
-- as well.
--
-- Overview
-- --------
-- The library contains the following classes:
--
-- o Packet.*
-- - The Packet classes contain specific packets and function to serialize
-- them to strings that can be sent over the wire. Each class may also
-- contain a function to parse the servers response.
--
-- o Comm
-- - Implements a number of functions to handle communication
--
-- o Crypt
-- - Implements encryption algorithms and functions to support
-- authentication with Oracle 10G and Oracle 11G.
--
-- o Helper
-- - A helper class that provides easy access to the rest of the library
--
--
-- Example
-- -------
-- The following sample code illustrates how scripts can use the Helper class
-- to interface the library:
--
-- <code>
-- tnshelper = tns.Helper:new(host, port)
-- status, err = tnshelper:Connect()
-- status, res = tnshelper:Login("sys", "change_on_install")
-- status, err = tnshelper:Close()
-- </code>
--
-- Additional information
-- ----------------------
-- The implementation is based on the following documentation and through
-- analysis of packet dumps:
--
-- o Oracle 10g TNS AES-128 authentication details (Massimiliano Montoro)
-- x http://www.oxid.it/downloads/oracle_tns_aes128_check.txt
-- o Oracle 11g TNS AES-192 authentication details (Massimiliano Montoro)
-- x http://www.oxid.it/downloads/oracle_tns_aes192_check.txt
-- o Initial analysis of Oracle native authentication version 11g
-- (László Tóth)
-- x http://www.soonerorlater.hu/index.khtml?article_id=512
-- o Oracle native authentication version 9i and 10g (László Tóth)
-- x http://www.soonerorlater.hu/index.khtml?article_id=511
--
-- This implementation is tested and known to work against Oracle 10g and 11g
-- on both Linux and Windows. For details regarding what versions where tested
-- please consult the matrix below.
--
-- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html
-- @author "Patrik Karlsson <patrik@cqure.net>"
--
-- @args tns.sid specifies the Oracle instance to connect to
--
-- Version 0.71
-- Created 07/12/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
-- Revised 07/21/2010 - v0.2 - made minor changes to support 11gR2 on Windows
-- Revised 07/23/2010 - v0.3 - corrected incorrect example code in docs
-- - removed ssl require
-- Revised 02/08/2011 - v0.4 - added basic query support <patrik@cqure.net>
-- Revised 17/08/2011 - v0.5 - fixed bug that would prevent connections from
-- working on 64-bit oracle.
-- Revised 20/08/2011 - v0.6 - fixed a few bugs in connection and query code
-- - changed so that connections against untested
-- databases versions will fail
-- - added some more documentation and fixed some
-- indentation bugs
-- <patrik@cqure.net>
-- Revised 26/08/2011 - v0.7 - applied patch from Chris Woodbury
-- <patrik@cqure.net>
-- Revised 28/08/2011 - v0.71- fixed a bug that would prevent the library from
-- authenticating against Oracle 10.2.0.1.0 XE
-- <patrik@cqure.net>
--
-- The following versions have been tested and are known to work:
-- +--------+---------------+---------+-------+-------------------------------+
-- | OS | DB Version | Edition | Arch | Functionality |
-- +--------+---------------+---------+-------+-------------------------------|
-- | Win | 10.2.0.1.0 | EE | 32bit | Authentication |
-- | Win | 10.2.0.1.0 | XE | 32bit | Authentication, Queries |
-- | Linux | 10.2.0.1.0 | EE | 32bit | Authentication |
-- | Win | 11.1.0.6.0 | EE | 32bit | Authentication, Queries |
-- | Win | 11.1.0.6.0 | EE | 64bit | Authentication |
-- | Win | 11.2.0.1.0 | EE | 64bit | Authentication |
-- | Win | 11.2.0.2.0 | EE | 64bit | Authentication |
-- | Linux | 11.2.0.1.0 | EE | 64bit | Authentication |
-- | Win | 11.2.0.2.0 | XE | 32bit | Authentication, Queries |
-- | Win | 11.2.0.2.0 | EE | 64bit | Authentication, Queries |
-- +--------+---------------+---------+-------+-------------------------------+
--
local bin = require "bin"
local bit = require "bit"
local math = require "math"
local match = require "match"
local nmap = require "nmap"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
local openssl = stdnse.silent_require "openssl"
_ENV = stdnse.module("tns", stdnse.seeall)
-- Oracle version constants
ORACLE_VERSION_10G = 313
ORACLE_VERSION_11G = 314
-- Data type to number conversions
DataTypes = {
NUMBER = 2,
DATE = 12,
}
-- A class containing some basic authentication options
AuthOptions =
{
-- Creates a new AuthOptions instance
-- @return o new instance of AuthOptions
new = function( self )
local o = {
auth_term = "pts/" .. math.random(255),
auth_prog = ("sqlplus@nmap_%d (TNS V1-V3)"):format(math.random(32768)),
auth_machine = "nmap_target",
auth_pid = "" .. math.random(32768),
auth_sid = "nmap_" .. math.random(32768)
}
setmetatable(o, self)
self.__index = self
return o
end,
}
-- Decodes different datatypes from the byte arrays or strings read from the
-- tns data packets
DataTypeDecoders = {
-- Decodes a number
[DataTypes.NUMBER] = function(val)
if ( #val == 0 ) then return "" end
if ( #val == 1 and val == '\128' ) then return 0 end
local bytes = {}
for i=1, #val do bytes[i] = select(2, bin.unpack("C", val, i)) end
local positive = ( bit.band(bytes[1], 0x80) ~= 0 )
local function convert_bytes(bytes, positive)
local ret_bytes = {}
local len = #bytes
if ( positive ) then
ret_bytes[1] = bit.band(bytes[1], 0x7F) - 65
for i=2, len do ret_bytes[i] = bytes[i] - 1 end
else
ret_bytes[1] = bit.band(bit.bxor(bytes[1], 0xFF), 0x7F) - 65
for i=2, len do ret_bytes[i] = 101 - bytes[i] end
end
return ret_bytes
end
bytes = convert_bytes(bytes, positive)
local k = ( #bytes - 1 > bytes[1] +1 ) and ( bytes[1] + 1 ) or #bytes - 1
local l = 0
for m=1, k do l = l * 100 + bytes[m+1] end
for m=bytes[1]-#bytes - 1, 0, -1 do l = l * 100 end
return (positive and l or -l)
end,
-- Decodes a date
[DataTypes.DATE] = function(val)
local bytes = {}
if (#val == 0) then
return ""
elseif( #val ~= 7 ) then
return "ERROR: Failed to decode date"
end
for i=1, 7 do bytes[i] = select(2, bin.unpack("C", val, i)) end
return ("%d-%02d-%02d"):format( (bytes[1] - 100 ) * 100 + bytes[2] - 100, bytes[3], bytes[4] )
end,
}
-- Packet class table
--
-- Each Packet type SHOULD implement:
-- o tns_type - A variable indicating the TNS Type of the Packet
-- o toString - A function that serializes the object to string
--
-- Each Packet MAY also optionally implement:
-- o parseResponse
-- x An optional function that parses the servers response
-- x The function should return status and an undefined second return value
--
Packet = {}
-- Contains the TNS header and basic functions for decoding and reading the
-- TNS packet.
Packet.TNS = {
checksum = 0,
hdr_checksum = 0,
length = 0,
reserved = 0,
Type =
{
CONNECT = 1,
ACCEPT = 2,
REFUSE = 4,
DATA = 6,
RESEND = 11,
MARKER = 12,
},
new = function( self, typ )
local o = {
type = typ
}
setmetatable(o, self)
self.__index = self
return o
end,
--- Read a TNS packet of the socket
--
-- @return true on success, false on failure
-- @return err string containing error message on failure
recv = function( self )
local status, data = self.socket:receive_buf( match.numbytes(2), true )
if ( not(status) ) then
return status, data
end
local _
_, self.length = bin.unpack(">S", data )
status, data = self.socket:receive_buf( match.numbytes(6), true )
if ( not(status) ) then
return status, data
end
_, self.checksum, self.type, self.reserved, self.hdr_checksum = bin.unpack(">SCCS", data)
status, data = self.socket:receive_buf( match.numbytes(self.length - 8), true )
if ( status ) then
self.data = data
end
return true
end,
parse = function(data)
local tns = Packet.TNS:new()
local pos
pos, tns.length, tns.checksum, tns.type, tns.reserved, tns.hdr_checksum = bin.unpack(">SSCCS", data)
pos, tns.data = bin.unpack("A" .. ( tns.length - 8 ), data, pos)
return tns
end,
--- Converts the TNS packet to string suitable to be sent over the socket
--
-- @return string containing the TNS packet
__tostring = function( self )
local data = bin.pack(">SSCCSA", self.length, self.checksum, self.type, self.reserved, self.hdr_checksum, self.data )
return data
end,
}
-- Initiates the connection to the listener
Packet.Connect = {
CONN_STR = [[
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%s)(PORT=%d))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=%s)(CID=
(PROGRAM=sqlplus)(HOST=%s)(USER=nmap))))]],
version = 314,
version_comp = 300,
svc_options = 0x0c41,
sess_dus = 8192,
max_trans_dus = 32767,
nt_proto_char = 0x7f08,
line_turnaround = 0,
value_of_1_in_hw = 0x0100,
conn_data_len = 0,
conn_data_offset = 58,
conn_data_max_recv = 512,
conn_data_flags_0 = 0x41,
conn_data_flags_1 = 0x41,
trace_cross_1 = 0,
trace_cross_2 = 0,
trace_unique_conn = 0,
tns_type = Packet.TNS.Type.CONNECT,
-- Creates a new Connect instance
-- @param rhost string containing host or ip
-- @param rport string containing the port number
-- @param dbinstance string containing the instance name
-- @return o containing new Connect instance
new = function( self, rhost, rport, dbinstance )
local o = {
rhost = rhost,
rport = rport,
conn_data = Packet.Connect.CONN_STR:format( rhost, rport, dbinstance, rhost ),
dbinstance = dbinstance:upper()
}
setmetatable(o, self)
self.__index = self
return o
end,
setCmd = function( self, cmd )
local tmp = [[
(DESCRIPTION=(CONNECT_DATA=(CID=(PROGRAM=)(HOST=%s)(USER=nmap))(COMMAND=%s)(ARGUMENTS=64)(SERVICE=%s:%d)(VERSION=185599488)))
]]
self.conn_data = tmp:format( self.rhost, cmd, self.rhost, self.rport )
end,
--- Parses the server response from the CONNECT
--
-- @param tns Packet.TNS containing the TNS packet received from the
-- server
-- @return true on success, false on failure
-- @return version number containing the version supported by the
-- server or an error message on failure
parseResponse = function( self, tns )
local pos, version
if ( tns.type ~= Packet.TNS.Type.ACCEPT ) then
if ( tns.data:match("ERR=12514") ) then
return false, ("TNS: The listener could not resolve \"%s\""):format(self.dbinstance)
end
return false, tns.data:match("%(ERR=(%d*)%)")
end
pos, version = bin.unpack(">S", tns.data )
return true, version
end,
--- Converts the CONNECT packet to string
--
-- @return string containing the packet
__tostring = function( self )
self.conn_data_len = #self.conn_data
return bin.pack(">SSSSSSSSSSICCIILLA", self.version, self.version_comp, self.svc_options,
self.sess_dus, self.max_trans_dus, self.nt_proto_char,
self.line_turnaround, self.value_of_1_in_hw, self.conn_data_len,
self.conn_data_offset, self.conn_data_max_recv, self.conn_data_flags_0,
self.conn_data_flags_1, self.trace_cross_1, self.trace_cross_2,
self.trace_unique_conn, 0, self.conn_data )
end,
}
-- A TNS data packet, one of the most common packets
Packet.Data = {
flag = 0,
-- Createas a new Data instance
-- @return o new instance of Data
new = function( self, data )
local o = {
TNS = Packet.TNS:new( Packet.TNS.Type.DATA ),
data = data
}
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
local data = bin.pack( ">S", self.flag ) .. self.data
self.TNS.length = #data + 8
return tostring(self.TNS) .. data
end,
}
-- Packet received by the server to indicate errors or end of
-- communication.
Packet.Attention = {
tns_type = Packet.TNS.Type.MARKER,
-- Creates a new instance of the Attention packet
-- @return o new instance of Attention
new = function( self, typ, data )
local o = { data = data, att_type = typ }
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the MARKER packet to string
--
-- @return string containing the packet
__tostring = function( self )
return bin.pack( ">C", self.att_type ) .. self.data
end,
}
-- Packet initializing challenge response authentication
Packet.PreAuth = {
tns_type = Packet.TNS.Type.DATA,
flags = 0,
param_order = {
{ ["AUTH_TERMINAL"] = "auth_term" },
{ ["AUTH_PROGRAM_NM"] = "auth_prog" },
{ ["AUTH_MACHINE"] = "auth_machine" },
{ ["AUTH_PID"] = "auth_pid" },
{ ["AUTH_SID"] = "auth_sid" }
},
--- Creates a new PreAuth packet
--
-- @param user string containing the user name
-- @return a new instance of Packet.PreAuth
new = function(self, user, options, ver)
local o = { auth_user = user, auth_options = options, version = ver }
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
local packet_type = 0x0376
local UNKNOWN_MAP = {
["Linuxi386/Linux-2.0.34-8.1.0"] = bin.pack("HCH","0238be0808", #self.auth_user, "00000001000000a851bfbf05000000504ebfbf7853bfbf"),
["IBMPC/WIN_NT-8.1.0"] = bin.pack("HCH","0238be0808", #self.auth_user, "00000001000000a851bfbf05000000504ebfbf7853bfbf"),
["IBMPC/WIN_NT64-9.1.0"] = bin.pack("H", "0201040000000100000001050000000101"),
["x86_64/Linux 2.4.xx"] = bin.pack("H", "0201040000000100000001050000000101"),
}
local unknown = UNKNOWN_MAP[self.version] or ""
local data = bin.pack(">SSA", self.flags, packet_type, unknown)
data = data .. bin.pack("CA", #self.auth_user, self.auth_user )
for _, v in ipairs( Packet.PreAuth.param_order ) do
for k, v2 in pairs(v) do
data = data .. Marshaller.marshalKvp( k, self.auth_options[v2] )
end
end
return data
end,
--- Parses the PreAuth packet response and extracts data needed to
-- perform authentication
--
-- @param tns Packet.TNS containing the TNS packet received from the server
-- @return table containing the keys and values returned by the server
parseResponse = function( self, tns )
local kvps = {}
local pos, kvp_count = bin.unpack( "C", tns.data, 4 )
pos = 6
for kvp_itr=1, kvp_count do
local key, val, kvp_flags
pos, key, val, kvp_flags = Marshaller.unmarshalKvp( tns.data, pos )
-- we don't actually do anything with the flags currently, but they're there
kvps[key] = val
end
return true, kvps
end,
}
-- Packet containing authentication data
Packet.Auth = {
tns_type = Packet.TNS.Type.DATA,
flags = 0,
param_order = {
{ ['key'] = "AUTH_RTT", ['def'] = "25456" },
{ ['key'] = "AUTH_CLNT_MEM", ['def'] = "4096" },
{ ['key'] = "AUTH_TERMINAL", ['var'] = "auth_term" },
{ ['key'] = "AUTH_PROGRAM_NM", ['var'] = "auth_prog" },
{ ['key'] = "AUTH_MACHINE", ['var'] = "auth_machine" },
{ ['key'] = "AUTH_PID", ['var'] = "auth_pid" },
{ ['key'] = "AUTH_SID", ['var'] = "auth_sid" },
{ ['key'] = "AUTH_ACL", ['def'] = "4400" },
{ ['key'] = "AUTH_ALTER_SESSION", ['def'] = "ALTER SESSION SET TIME_ZONE='+02:00'\0" },
{ ['key'] = "AUTH_LOGICAL_SESSION_ID", ['def'] = select(2, bin.unpack("H16", openssl.rand_pseudo_bytes(16))) },
{ ['key'] = "AUTH_FAILOVER_ID", ['def'] = "" },
},
--- Creates a new Auth packet
--
-- @param auth_sesskey the encrypted session key
-- @param auth_pass the encrypted user password
-- @return a new instance of Packet.Auth
new = function(self, user, options, auth_sesskey, auth_pass, ver)
local o = {
auth_sesskey = auth_sesskey,
auth_pass = auth_pass,
auth_options = options,
user = user,
version = ver
}
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
local UNKNOWN_MAP = {
["Linuxi386/Linux-2.0.34-8.1.0"] = bin.pack("HCH","0338be0808", #self.user, "00000001010000cc7dbfbf0d000000747abfbf608abfbf"),
["IBMPC/WIN_NT-8.1.0"] = bin.pack("HCH","0338be0808", #self.user, "00000001010000cc7dbfbf0d000000747abfbf608abfbf"),
["IBMPC/WIN_NT64-9.1.0"] = bin.pack("H","03010400000001010000010d0000000101"),
["x86_64/Linux 2.4.xx"] = bin.pack("H","03010400000001010000010d0000000101")
}
local sess_id = select(2, bin.unpack("H16", openssl.rand_pseudo_bytes(16)))
local unknown = UNKNOWN_MAP[self.version] or ""
local data = bin.pack(">SSA", self.flags, 0x0373, unknown)
data = data .. bin.pack("CA", #self.user, self.user )
data = data .. Marshaller.marshalKvp( "AUTH_SESSKEY", self.auth_sesskey, 1 )
data = data .. Marshaller.marshalKvp( "AUTH_PASSWORD", self.auth_pass )
for k, v in ipairs( self.param_order ) do
if ( v['def'] ) then
data = data .. Marshaller.marshalKvp( v['key'], v['def'] )
elseif ( self.auth_options[ v['var'] ] ) then
data = data .. Marshaller.marshalKvp( v['key'], self.auth_options[ v['var'] ] )
elseif ( self[ v['var'] ] ) then
data = data .. Marshaller.marshalKvp( v['key'], self[ v['var'] ] )
end
end
return data
end,
-- Parses the response of an Auth packet
--
-- @param tns Packet.TNS containing the TNS packet received from the server
-- @return table containing the key pair values from the Auth packet
parseResponse = function( self, tns )
local kvps = {}
local pos, kvp_count = bin.unpack( "C", tns.data, 4 )
pos = 6
for kvp_itr=1, kvp_count do
local key, val, kvp_flags
pos, key, val, kvp_flags = Marshaller.unmarshalKvp( tns.data, pos )
-- we don't actually do anything with the flags currently, but they're there
kvps[key] = val
end
return true, kvps
end,
}
Packet.SNS = {
tns_type = Packet.TNS.Type.DATA,
flags = 0,
-- Creates a new SNS instance
--
-- @return o new instance of the SNS packet
new = function(self)
local o = {}
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
return bin.pack("SH", self.flags,
[[
deadbeef00920b1006000004000004000300000000000400050b10060000080
001000015cb353abecb00120001deadbeef0003000000040004000100010002
0001000300000000000400050b10060000020003e0e100020006fcff0002000
200000000000400050b100600000c0001001106100c0f0a0b08020103000300
0200000000000400050b10060000030001000301
]] )
end,
}
-- Packet containing protocol negotiation
Packet.ProtoNeg = {
tns_type = Packet.TNS.Type.DATA,
flags = 0,
new = function(self)
local o = {}
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
local pfx = bin.pack(">SH", self.flags, "0106050403020100")
return pfx .. "Linuxi386/Linux-2.0.34-8.1.0\0"
end,
--- Parses and verifies the server response
--
-- @param tns Packet.TNS containing the response from the server
parseResponse = function( self, tns )
local pos, flags, neg, ver, _, srv = bin.unpack(">SCCCz", tns.data)
if ( neg ~= 1 ) then
return false, "Error protocol negotiation failed"
end
if ( ver ~= 6 ) then
return false, ("Error protocol version (%d) not supported"):format(ver)
end
return true, srv
end
}
Packet.Unknown1 = {
tns_type = Packet.TNS.Type.DATA,
flags = 0,
--- Creates a new Packet.Unknown1
--
-- @param version containing the version of the packet to send
-- @return new instance of Packet.Unknown1
new = function(self, os)
local o = { os = os }
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
if ( self.os:match("IBMPC/WIN_NT[64]*[-]%d%.%d%.%d") ) then
return bin.pack(">SH", self.flags, [[
02b200b2004225060101010d010105010101010101017fff0309030301007f0
11fff010301013f01010500010702010000180001800000003c3c3c80000000
d007000100010001000000020002000a00000008000800010000000c000c000
a00000017001700010000001800180001000000190019001800190001000000
1a001a0019001a00010000001b001b000a001b00010000001c001c0016001c0
0010000001d001d0017001d00010000001e001e0017001e00010000001f001f
0019001f0001000000200020000a00200001000000210021000a00210001000
0000a000a00010000000b000b00010000002800280001000000290029000100
000075007500010000007800780001000001220122000100000123012300010
12300010000012401240001000001250125000100000126012600010000012a
012a00010000012b012b00010000012c012c00010000012d012d00010000012
e012e00010000012f012f000100000130013000010000013101310001000001
320132000100000133013300010000013401340001000001350135000100000
136013600010000013701370001000001380138000100000139013900010000
013b013b00010000013c013c00010000013d013d00010000013e013e0001000
0013f013f000100000140014000010000014101410001000001420142000100
000143014300010000014701470001000001480148000100000149014900010
000014b014b00010000014d014d00010000014e014e00010000014f014f0001
000001500150000100000151015100010000015201520001000001530153000
100000154015400010000015501550001000001560156000100000157015700
0101570001000001580158000100000159015900010000015a015a000100000
15c015c00010000015d015d0001000001620162000100000163016300010000
0167016700010000016b016b00010000017c017c0001014200010000017d017
d00010000017e017e00010000017f017f000100000180018000010000018101
810001000001820182000100000183018300010000018401840001000001850
18500010000018601860001000001870187000100000189018900010000018a
018a00010000018b018b00010000018c018c00010000018d018d00010000018
e018e00010000018f018f000100000190019000010000019101910001000001
940194000101250001000001950195000100000196019600010000019701970
0010000019d019d00010000019e019e00010000019f019f0001000001a001a0
0001000001a101a10001000001a201a20001000001a301a30001000001a401a
40001000001a501a50001000001a601a60001000001a701a70001000001a801
a80001000001a901a90001000001aa01aa0001000001ab01ab0001000001ad0
1ad0001000001ae01ae0001000001af01af0001000001b001b00001000001b1
01b10001000001c101c10001000001c201c2000101250001000001c601c6000
1000001c701c70001000001c801c80001000001c901c90001000001ca01ca00
01019f0001000001cb01cb000101a00001000001cc01cc000101a2000100000
1cd01cd000101a30001000001ce01ce000101b10001000001cf01cf00010122
0001000001d201d20001000001d301d3000101ab0001000001d401d40001000
001d501d50001000001d601d60001000001d701d70001000001d801d8000100
0001d901d90001000001da01da0001000001db01db0001000001dc01dc00010
00001dd01dd0001000001de01de0001000001df01df0001000001e001e00001
000001e101e10001000001e201e20001000001e301e30001016b0001000001e
401e40001000001e501e50001000001e601e60001000001ea01ea0001000001
eb01eb0001000001ec01ec0001000001ed01ed0001000001ee01ee000100000
1ef01ef0001000001f001f00001000001f201f20001000001f301f300010000
01f401f40001000001f501f50001000001f601f60001000001fd01fd0001000
001fe01fe000100000201020100010000020202020001000002040204000100
000205020500010000020602060001000002070207000100000208020800010
0000209020900010000020a020a00010000020b020b00010000020c020c0001
0000020d020d00010000020e020e00010000020f020f0001000002100210000
100000211021100010000021202120001000002130213000100000214021400
010000021502150001000002160216000100000217021700010000021802180
00100000219021900010000021a021a00010000021b021b00010000021c021c
00010000021d021d00010000021e021e00010000021f021f000100000220022
000010000022102210001000002220222000100000223022300010000022402
240001000002250225000100000226022600010000022702270001000002280
228000100000229022900010000022a022a00010000022b022b00010000022c
022c00010000022d022d00010000022e022e00010000022f022f00010000023
102310001000002320232000100000233023300010000023402340001000002
3702370001000002380238000100000239023900010000023a023a000100000
23b023b00010000023c023c00010000023d023d00010000023e023e00010000
023f023f0001000002400240000100000241024100010000024202420001000
002430243000100000244024400010000
]])
elseif ( "x86_64/Linux 2.4.xx" == self.os ) then
return bin.pack(">SH", self.flags, [[
02b200b2004221060101010d01010401010101010101ffff0308030001003f0
1073f010101010301050201000018800000003c3c3c80000000d00700010001
0001000000020002000a00000008000800010000000c000c000a00000017001
7000100000018001800010000001900190018001900010000001a001a001900
1a00010000001b001b000a001b00010000001c001c0016001c00010000001d0
01d0017001d00010000001e001e0017001e00010000001f001f0019001f0001
000000200020000a00200001000000210021000a002100010000000a000a000
10000000b000b00010000002800280001000000290029000100000075007500
010000007800780001000001220122000100000123012300010123000100000
12401240001000001250125000100000126012600010000012a012a00010000
012b012b00010000012c012c00010000012d012d00010000012e012e0001000
0012f012f000100000130013000010000013101310001000001320132000100
000133013300010000013401340001000001350135000100000136013600010
000013701370001000001380138000100000139013900010000013b013b0001
0000013c013c00010000013d013d00010000013e013e00010000013f013f000
100000140014000010000014101410001000001420142000100000143014300
010000014701470001000001480148000100000149014900010000014b014b0
0010000014d014d00010000014e014e00010000014f014f0001000001500150
000100000151015100010000015201520001000001530153000100000154015
400010000015501550001000001560156000100000157015700010157000100
0001580158000100000159015900010000015a015a00010000015c015c00010
000015d015d0001000001620162000100000163016300010000016701670001
0000016b016b00010000017c017c0001014200010000017d017d00010000017
e017e00010000017f017f000100000180018000010000018101810001000001
820182000100000183018300010000018401840001000001850185000100000
18601860001000001870187000100000189018900010000018a018a00010000
018b018b00010000018c018c00010000018d018d00010000018e018e0001000
0018f018f000100000190019000010000019101910001000001940194000101
2500010000019501950001000001960196000100000197019700010000019d0
19d00010000019e019e00010000019f019f0001000001a001a00001000001a1
01a10001000001a201a20001000001a301a30001000001a401a40001000001a
501a50001000001a601a60001000001a701a70001000001a801a80001000001
a901a90001000001aa01aa0001000001ab01ab0001000001ad01ad000100000
1ae01ae0001000001af01af0001000001b001b00001000001b101b100010000
01c101c10001000001c201c2000101250001000001c601c60001000001c701c
70001000001c801c80001000001c901c90001000001ca01ca0001019f000100
0001cb01cb000101a00001000001cc01cc000101a20001000001cd01cd00010
1a30001000001ce01ce000101b10001000001cf01cf000101220001000001d2
01d20001000001d301d3000101ab0001000001d401d40001000001d501d5000
1000001d601d60001000001d701d70001000001d801d80001000001d901d900
01000001da01da0001000001db01db0001000001dc01dc0001000001dd01dd0
001000001de01de0001000001df01df0001000001e001e00001000001e101e1
0001000001e201e20001000001e301e30001016b0001000001e401e40001000
001e501e50001000001e601e60001000001ea01ea0001000001eb01eb000100
0001ec01ec0001000001ed01ed0001000001ee01ee0001000001ef01ef00010
00001f001f00001000001f201f20001000001f301f30001000001f401f40001
000001f501f50001000001f601f60001000001fd01fd0001000001fe01fe000
100000201020100010000020202020001000002040204000100000205020500
010000020602060001000002070207000100000208020800010000020902090
0010000020a020a00010000020b020b00010000020c020c00010000020d020d
00010000020e020e00010000020f020f0001000002100210000100000211021
100010000021202120001000002130213000100000214021400010000021502
150001000002160216000100000217021700010000021802180001000002190
21900010000021a021a00010000021b021b0001000000030002000a00000004
0002000a0000000500010001000000060002000a000000070002000a0000000
9000100010000000d0000000e0000000f001700010000001000000011000000
12000000130000001400000015000000160000002700780001015d000101260
0010000003a003a0001000000440002000a00000045000000460000004a006d
00010000004c0000005b0002000a0000005e000100010000005f00170001000
000600060000100000061006000010000006400640001000000650065000100
0000660066000100000068000000690000006a006a00010000006c006d00010
000006d006d00010000006e006f00010000006f006f00010000007000700001
000000710071000100000072007200010000007300730001000000740066000
100000076000000770000007900790001
]])
else
return bin.pack(">SH", self.flags, "02b200b2004225060101010d010105010101010101017fff0309030301007f011" ..
"fff010301013f01010500010702010000180001800000003c3c3c80000000d007")
end
end,
}
--- This packet is only used by Oracle10 and older
Packet.Unknown2 = {
tns_type = Packet.TNS.Type.DATA,
flags = 0,
new = function(self, os)
local o = { os = os }
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
if ( "x86_64/Linux 2.4.xx" == self.os ) then
return bin.pack(">SH", self.flags, [[
0000007a007a00010000007b007b00010000008800000092009200010000009
300930001000000980002000a000000990002000a0000009a0002000a000000
9b000100010000009c000c000a000000ac0002000a000000b200b2000100000
0b300b30001000000b400b40001000000b500b50001000000b600b600010000
00b700b70001000000b8000c000a000000b900b20001000000ba00b30001000
000bb00b40001000000bc00b50001000000bd00b60001000000be00b7000100
0000bf000000c0000000c300700001000000c400710001000000c5007200010
00000d000d00001000000d1000000e700e70001000000e800e70001000000e9
00e90001000000f1006d0001000002030203000100000000]]
)
else
return bin.pack(">SH", self.flags, [[
024502450001000002460246000100000247024700010000024802480001000
0024902490001000000030002000a000000040002000a000000050001000100
0000060002000a000000070002000a00000009000100010000000d0000000e0
000000f00170001000000100000001100000012000000130000001400000015
000000160000002700780001015d0001012600010000003a003a00010000004
40002000a00000045000000460000004a006d00010000004c0000005b000200
0a0000005e000100010000005f0017000100000060006000010000006100600
001000000640064000100000065006500010000006600660001000000680000
00690000006a006a00010000006c006d00010000006d006d00010000006e006
f00010000006f006f0001000000700070000100000071007100010000007200
720001000000730073000100000074006600010000007600000077000000790
07900010000007a007a00010000007b007b0001000000880000009200920001
0000009300930001000000980002000a000000990002000a0000009a0002000
a0000009b000100010000009c000c000a000000ac0002000a000000b200b200
01000000b300b30001000000b400b40001000000b500b50001000000b600b60
001000000b700b70001000000b8000c000a000000b900b20001000000ba00b3
0001000000bb00b40001000000bc00b50001000000bd00b60001000000be00b
70001000000bf000000c0000000c300700001000000c400710001000000c500
720001000000d000d00001000000d1000000e700e70001000000e800e700010
00000e900e90001000000f1006d0001000002030203000100000000
]])
end
end,
}
-- Signals that we're about to close the connection
Packet.EOF = {
tns_type = Packet.TNS.Type.DATA,
flags = 0x0040,
new = function(self)
local o = {}
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
return bin.pack(">S", self.flags )
end
}
Packet.PostLogin = {
tns_type = Packet.TNS.Type.DATA,
flags = 0x0000,
-- Creates a new PostLogin instance
--
-- @param sessid number containing session id
-- @return o a new instance of PostLogin
new = function(self, sessid)
local o = { sessid = sessid }
setmetatable(o, self)
self.__index = self
return o
end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
local unknown1 = "116b04"
local unknown2 = "0000002200000001000000033b05fefffffff4010000fefffffffeffffff"
return bin.pack(">SHCH", self.flags, unknown1, tonumber(self.sessid), unknown2 )
end
}
-- Class responsible for sending queries to the server and handling the first
-- row returned by the server. This class is 100% based on packet captures and
-- guesswork.
Packet.Query = {
tns_type = Packet.TNS.Type.DATA,
flags = 0x0000,
--- Creates a new instance of Query
-- @param query string containing the SQL query
-- @return instance of Query
new = function(self, query)
local o = { query = query, counter = 0 }
setmetatable(o, self)
self.__index = self
return o
end,
--- Gets the current counter value
-- @return counter number containing the current counter value
getCounter = function(self) return self.counter end,
--- Sets the current counter value
-- This function is called from sendTNSPacket
-- @param counter number containing the counter value to set
setCounter = function(self, counter) self.counter = counter end,
--- Converts the DATA packet to string
--
-- @return string containing the packet
__tostring = function( self )
local unknown1 = "035e"
local unknown2 = "6180000000000000feffffff"
local unknown3 = "000000feffffff0d000000fefffffffeffffff000000000100000000000000000000000000000000000000feffffff00000000fefffffffeffffff54d25d020000000000000000fefffffffeffffff0000000000000000000000000000000000000000"
local unknown4 = "01000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000"
return bin.pack(">SHCHCHCAH", self.flags, unknown1, self.counter, unknown2, #self.query, unknown3, #self.query, self.query, unknown4 )
end,
--- Parses the Query response from the server
-- @param tns response as received from the <code>Comm.recvTNSPacket</code>
-- function.
-- @return result table containing:
-- <code>columns</code> - a column indexed table with the column names
-- <code>types</code> - a column indexed table with the data types
-- <code>rows</code> - a table containing a row table for each row
-- the row table is a column indexed table of
-- column values.
parseResponse = function( self, tns )
local data = tns.data
local result = {}
local pos, columns = bin.unpack("C", tns.data, 35)
pos = 40
for i=1, columns do
local sql_type
pos, sql_type = bin.unpack("C", data, pos)
pos = pos + 34
local name, len
pos, len = bin.unpack("C", tns.data, pos)
pos, name= bin.unpack("A" .. len, tns.data, pos)
result.columns = result.columns or {}
result.types = result.types or {}
table.insert(result.columns, name)
table.insert(result.types, sql_type)
pos = pos + 10
end
pos = pos + 55
result.rows = {}
local row = {}
for i=1, columns do
local val, len
pos, len = bin.unpack("C", tns.data, pos)
pos, val = bin.unpack("A" .. len, tns.data, pos)
-- if we're at the first row and first column and the len is 0
-- assume we got an empty resultset
if ( len == 0 and #result.rows == 0 and i == 1 ) then
return true, { data = result, moredata = false }
end
local sql_type = result.types[i]
if ( DataTypeDecoders[sql_type] ) then
val = DataTypeDecoders[sql_type](val)
end
table.insert(row, val)
end
table.insert(result.rows, row)
local moredata = true
-- check if we've got any more data?
if ( #data > pos + 97 ) then
local len, err
pos, len = bin.unpack(">S", data, pos + 97)
pos, err = bin.unpack("A" .. len, data, pos)
if ( err:match("^ORA%-01403") ) then
moredata = false
end
end
return true, { data = result, moredata = moredata }
end,
}
-- Class responsible for acknowledging a query response from the server
-- and handles the next several rows returned by the server. This class
-- is mostly based on packet captures and guesswork.
Packet.QueryResponseAck = {
tns_type = Packet.TNS.Type.DATA,
flags = 0x0000,
--- Creates a new QueryResponseAck instance
-- @param result table containing the results as received from the
-- <code>Query.parseResponse</code> function.
-- @return instance new instance of QueryResponseAck
new = function(self, result)
local o = { result = result }
setmetatable(o, self)
self.__index = self
return o
end,
--- Gets the current counter value
-- @return counter number containing the current counter value
getCounter = function(self) return self.counter end,
--- Sets the current counter value
-- This function is called from sendTNSPacket
-- @param counter number containing the counter value to set
setCounter = function(self, counter) self.counter = counter end,
--- Serializes the packet into a string suitable to be sent to the DB
-- server.
-- @return str string containing the serialized packet
__tostring = function(self)
return bin.pack(">SHCH", self.flags, "0305", self.counter, "030000000f000000")
end,
--
-- This is how I (Patrik Karlsson) think this is supposed to work
-- At this point we have the 2nd row (the query response has the first)
-- Every row looks like this, where the leading mask marker (0x15) and mask
-- is optional.
-- | (mask mark)| (bytes) | sor | byte | len * bytes | ... next_column |
-- | 0x15 | [mask] | 0x07 | [len]| [column_val]| ... next_column |
-- The mask is used in order to achieve "compression" and is essentially
-- at a bit mask that decides what columns should be fetched from the
-- preceding row. The mask is provided in reverse order and a set bit
-- indicates that data is provided while an unset bit indicates that the
-- column data should be fetched from the previous row.
--
-- Once a value is fetched the sql data type is verified against the
-- DataTypeDecoder table. If there's a function registered for the fetched
-- data it is run through a decoder, that decodes the *real* value from
-- the encoded data.
--
parseResponse = function( self, tns )
local data = tns.data
local pos, len = bin.unpack("C", data, 21)
local mask = ""
-- calculate the initial mask
if ( len > 0 ) then
while( len > 0) do
local mask_part
pos, mask_part = bin.unpack("B", data, pos)
mask = mask .. mask_part:reverse()
len = len - 1
end
pos = pos + 4
else
pos = pos +3
end
while(true) do
local row = {}
local result = self.result
local cols = #result.columns
-- check for start of data marker
local marker
pos, marker = bin.unpack("C", data, pos)
if ( marker == 0x15 ) then
mask = ""
local _
-- not sure what this value is
pos, _ = bin.unpack("<S", data, pos)
-- calculate the bitmask for the columns that do contain
-- data.
len = cols
while( len > 0 ) do
local mask_part
pos, mask_part = bin.unpack("B", data, pos)
mask = mask .. mask_part:reverse()
len = len - 8
end
pos, marker = bin.unpack("C", data, pos)
end
if ( marker ~= 0x07 ) then
stdnse.debug2("Encountered unknown marker: %d", marker)
break
end
local val
local rows = self.result.rows
for col=1, cols do
if ( #mask > 0 and mask:sub(col, col) == '0' ) then
val = rows[#rows][col]
else
pos, len = bin.unpack("C", data, pos)
pos, val = bin.unpack("A" .. len, data, pos)
local sql_type = result.types[col]
if ( DataTypeDecoders[sql_type] ) then
val = DataTypeDecoders[sql_type](val)
end
end
table.insert(row, val)
end
-- add row to result
table.insert(rows, row)
end
return true, tns.data
end,
}
Marshaller = {
--- Marshals a TNS key-value pair data structure
--
-- @param key The key
-- @param value The value
-- @param flags The flags
-- @return A binary packed string representing the KVP structure
marshalKvp = function( key, value, flags )
return Marshaller.marshalKvpComponent( key ) ..
Marshaller.marshalKvpComponent( value ) ..
bin.pack( "<I", ( flags or 0 ) )
end,
--- Parses a TNS key-value pair data structure.
--
-- @param data Packed string to parse
-- @param pos Position in the string at which the KVP begins
-- @return table containing the last position read, the key, the value, and the KVP flags
unmarshalKvp = function( data, pos )
local key, value, flags
pos, key = Marshaller.unmarshalKvpComponent( data, pos )
pos, value = Marshaller.unmarshalKvpComponent( data, pos )
pos, flags = bin.unpack("<I", data, pos )
return pos, key, value, flags
end,
--- Marshals a key or value element from a TNS key-value pair data structure
--
-- @param value The key or value
-- @return A binary packed string representing the element
marshalKvpComponent = function( value )
local result = ""
value = value or ""
result = result .. bin.pack( "<I", #value )
if ( #value > 0 ) then
-- 64 bytes seems to be the maximum length before Oracle starts
-- chunking strings
local MAX_CHUNK_LENGTH = 64
local split_into_chunks = ( #value > MAX_CHUNK_LENGTH )
if ( not( split_into_chunks ) ) then
-- It's pretty easy if we don't have to split up the string
result = result .. bin.pack( "p", value )
else
-- Otherwise, it's a bit more involved:
-- First, write the multiple-chunk indicator
result = result .. "\xFE"
-- Loop through the string, chunk by chunk
while ( #value > 0 ) do
-- Figure out how much we're writing in this chunk, the
-- remainder of the string, or the maximum, whichever is less
local write_length = MAX_CHUNK_LENGTH
if (#value < MAX_CHUNK_LENGTH) then
write_length = #value
end
-- get a substring of what we're going to write...
local write_value = value:sub( 1, write_length )
-- ...and remove that piece from the remaining string
value = value:sub( write_length + 1 )
result = result .. bin.pack( "p", write_value )
end
-- put a null byte at the end
result = result .. '\0'
end
end
return result
end,
--- Parses a key or value element from a TNS key-value pair data structure.
--
-- @param data Packed string to parse
-- @param pos Position in the string at which the element begins
-- @return table containing the last position read and the value parsed
unmarshalKvpComponent = function( data, pos )
local value_len, chunk_len
local value, chunk = "", ""
local has_multiple_chunks = false
-- read the 32-bit total length of the value
pos, value_len = bin.unpack("<I", data, pos )
if ( value_len == 0 ) then
value = ""
else
-- Look at the first byte after the total length. If the value is
-- broken up into multiple chunks, this will be indicated by this
-- byte being 0xFE.
local _, first_byte = bin.unpack("C", data, pos )
if ( first_byte == 0xFE ) then
has_multiple_chunks = true
pos = pos + 1 -- move pos past the multiple-chunks indicator
end
-- Loop through the chunks until we read the whole value
while ( value:len() < value_len ) do
pos, chunk = bin.unpack("p", data, pos )
value = value .. chunk
end
if ( has_multiple_chunks ) then
pos = pos + 1 -- there's a null byte after the last chunk
end
end
return pos, value
end,
}
-- The TNS communication class uses the TNSSocket to transmit data
Comm = {
--- Creates a new instance of the Comm class
--
-- @param socket containing a TNSSocket
-- @return new instance of Comm
new = function(self, socket)
local o = {
socket = socket,
data_counter = 06
}
setmetatable(o, self)
self.__index = self
return o
end,
--- Attemts to send a TNS packet over the socket
--
-- @param pkt containing an instance of a Packet.*
-- @return Status (true or false).
-- @return Error code (if status is false).
sendTNSPacket = function( self, pkt )
local tns = Packet.TNS:new( pkt.tns_type )
if ( pkt.setCounter ) then
pkt:setCounter(self.data_counter)
self.data_counter = self.data_counter + 1
end
tns.data = tostring(pkt)
tns.length = #tns.data + 8
-- buffer incase of RESEND
self.pkt = pkt
return self.socket:send( tostring(tns) )
end,
--- Handles communication when a MARKER packet is received and retrieves
-- the following error message
--
-- @return false always to indicate that an error occurred
-- @return msg containing the error message
handleMarker = function( self )
local status, tns = self:recvTNSPacket()
if ( not(status) or tns.type ~= Packet.TNS.Type.MARKER ) then
return false, "ERROR: failed to handle marker sent by server"
end
-- send our marker
status = self:sendTNSPacket( Packet.Attention:new( 1, bin.pack("H", "0002") ) )
if ( not(status) ) then
return false, "ERROR: failed to send marker to server"
end
status, tns = self:recvTNSPacket()
if ( not(status) or tns.type ~= Packet.TNS.Type.DATA ) then
return false, "ERROR: expecting DATA packet"
end
-- check if byte 12 is set or not, this should help us distinguish the offset
-- to the error message in Oracle 10g and 11g
local pos, b1 = bin.unpack("C", tns.data, 10)
pos = (b1 == 1) and 99 or 69
-- fetch the oracle error and return it
local msg
pos, msg = bin.unpack("p", tns.data, pos )
return false, msg
end,
--- Receives a TNS packet and handles TNS-resends
--
-- @return status true on success, false on failure
-- @return tns Packet.TNS containing the received packet or err on failure
recvTNSPacket = function( self )
local tns
local retries = 5
repeat
local function recv()
local status, header = self.socket:receive_buf( match.numbytes(8), true )
if ( not(status) ) then return status, header end
local _, length = bin.unpack(">S", header )
local status, data = self.socket:receive_buf( match.numbytes(length - 8), true )
if ( not(status) ) then
return false, data
else
return status, Packet.TNS.parse(header .. data)
end
end
local status
status, tns = recv()
if ( not(status) ) then
if ( retries == 0 ) then
return false, "ERROR: recvTNSPacket failed to receive TNS headers"
end
retries = retries - 1
elseif ( tns.type == Packet.TNS.Type.RESEND ) then
self:sendTNSPacket( self.pkt )
end
until ( status and tns.type ~= Packet.TNS.Type.RESEND )
return true, tns
end,
--- Sends a TNS packet and receives (and handles) the response
--
-- @param pkt containing the Packet.* to send to the server
-- @return status true on success, false on failure
-- @return the parsed response as return from the respective parseResponse
-- function or error message if status was false
exchTNSPacket = function( self, pkt )
local status = self:sendTNSPacket( pkt )
local tns, response
if ( not(status) ) then
return false, "sendTNSPacket failed"
end
status, tns = self:recvTNSPacket()
if ( not(status) ) then
return false, tns
end
--- handle TNS MARKERS
if ( tns.type == Packet.TNS.Type.MARKER ) then
return self:handleMarker()
end
if ( pkt.parseResponse ) then
status, response = pkt:parseResponse( tns )
end
return status, response
end
}
--- Class that handles all Oracle encryption
Crypt = {
-- Test function, not currently in use
Decrypt11g = function(self, c_sesskey, s_sesskey, auth_password, pass, salt )
local combined_sesskey = ""
local sha1 = openssl.sha1(pass .. salt) .. "\0\0\0\0"
local auth_sesskey = s_sesskey
local auth_sesskey_c = c_sesskey
local server_sesskey = openssl.decrypt( "aes-192-cbc", sha1, nil, auth_sesskey )
local client_sesskey = openssl.decrypt( "aes-192-cbc", sha1, nil, auth_sesskey_c )
combined_sesskey = ""
for i=17, 40 do
combined_sesskey = combined_sesskey .. string.char( bit.bxor( string.byte(server_sesskey, i), string.byte(client_sesskey,i) ) )
end
combined_sesskey = ( openssl.md5( combined_sesskey:sub(1,16) ) .. openssl.md5( combined_sesskey:sub(17) ) ):sub(1, 24)
local p = openssl.decrypt( "aes-192-cbc", combined_sesskey, nil, auth_password, false )
return p:sub(17)
end,
--- Creates an Oracle 10G password hash
--
-- @param username containing the Oracle user name
-- @param password containing the Oracle user password
-- @return hash containing the Oracle hash
HashPassword10g = function( self, username, password )
local uspw = ( username .. password ):gsub("(%w)", "\0%1")
local key = bin.pack("H", "0123456789abcdef")
-- do padding
uspw = uspw .. string.rep('\0', (8 - (#uspw % 8)) % 8)
local iv2 = openssl.encrypt( "DES-CBC", key, nil, uspw, false ):sub(-8)
local enc = openssl.encrypt( "DES-CBC", iv2, nil, uspw, false ):sub(-8)
return enc
end,
-- Test function, not currently in use
Decrypt10g = function(self, user, pass, srv_sesskey_enc )
local pwhash = self:HashPassword10g( user:upper(), pass:upper() ) .. "\0\0\0\0\0\0\0\0"
local cli_sesskey_enc = bin.pack("H", "7B244D7A1DB5ABE553FB9B7325110024911FCBE95EF99E7965A754BC41CF31C0")
local srv_sesskey = openssl.decrypt( "AES-128-CBC", pwhash, nil, srv_sesskey_enc )
local cli_sesskey = openssl.decrypt( "AES-128-CBC", pwhash, nil, cli_sesskey_enc )
local auth_pass = bin.pack("H", "4C5E28E66B6382117F9D41B08957A3B9E363B42760C33B44CA5D53EA90204ABE" )
local combined_sesskey = ""
local pass
for i=17, 32 do
combined_sesskey = combined_sesskey .. string.char( bit.bxor( string.byte(srv_sesskey, i), string.byte(cli_sesskey, i) ) )
end
combined_sesskey = openssl.md5( combined_sesskey )
pass = openssl.decrypt( "AES-128-CBC", combined_sesskey, nil, auth_pass ):sub(17)
print( select(2, bin.unpack("H" .. #srv_sesskey, srv_sesskey )))
print( select(2, bin.unpack("H" .. #cli_sesskey, cli_sesskey )))
print( select(2, bin.unpack("H" .. #combined_sesskey, combined_sesskey )))
print( "pass=" .. pass )
end,
--- Performs the relevant encryption needed for the Oracle 10g response
--
-- @param user containing the Oracle user name
-- @param pass containing the Oracle user password
-- @param srv_sesskey_enc containing the encrypted server session key as
-- received from the PreAuth packet
-- @return cli_sesskey_enc the encrypted client session key
-- @return auth_pass the encrypted Oracle password
Encrypt10g = function( self, user, pass, srv_sesskey_enc )
local pwhash = self:HashPassword10g( user:upper(), pass:upper() ) .. "\0\0\0\0\0\0\0\0"
-- We're currently using a static client session key, this should
-- probably be changed to a random value in the future
local cli_sesskey = bin.pack("H", "FAF5034314546426F329B1DAB1CDC5B8FF94349E0875623160350B0E13A0DA36")
local srv_sesskey = openssl.decrypt( "AES-128-CBC", pwhash, nil, srv_sesskey_enc )
local cli_sesskey_enc = openssl.encrypt( "AES-128-CBC", pwhash, nil, cli_sesskey )
-- This value should really be random, not this static cruft
local rnd = bin.pack("H", "4C31AFE05F3B012C0AE9AB0CDFF0C508")
local combined_sesskey = ""
local auth_pass
for i=17, 32 do
combined_sesskey = combined_sesskey .. string.char( bit.bxor( string.byte(srv_sesskey, i), string.byte(cli_sesskey, i) ) )
end
combined_sesskey = openssl.md5( combined_sesskey )
auth_pass = openssl.encrypt("AES-128-CBC", combined_sesskey, nil, rnd .. pass, true )
auth_pass = select(2, bin.unpack("H" .. #auth_pass, auth_pass))
cli_sesskey_enc = select(2, bin.unpack("H" .. #cli_sesskey_enc, cli_sesskey_enc))
return cli_sesskey_enc, auth_pass
end,
--- Performs the relevant encryption needed for the Oracle 11g response
--
-- @param pass containing the Oracle user password
-- @param srv_sesskey_enc containing the encrypted server session key as
-- received from the PreAuth packet
-- @param auth_vrfy_data containing the password salt as received from the
-- PreAuth packet
-- @return cli_sesskey_enc the encrypted client session key
-- @return auth_pass the encrypted Oracle password
Encrypt11g = function( self, pass, srv_sesskey_enc, auth_vrfy_data )
-- This value should really be random, not this static cruft
local rnd = openssl.rand_pseudo_bytes(16)
local cli_sesskey = openssl.rand_pseudo_bytes(40) .. bin.pack("H", "0808080808080808")
local pw_hash = openssl.sha1(pass .. auth_vrfy_data) .. "\0\0\0\0"
local srv_sesskey = openssl.decrypt( "aes-192-cbc", pw_hash, nil, srv_sesskey_enc )
local auth_password
local cli_sesskey_enc
local combined_sesskey = ""
local data = ""
for i=17, 40 do
combined_sesskey = combined_sesskey .. string.char( bit.bxor( string.byte(srv_sesskey, i), string.byte(cli_sesskey, i) ) )
end
combined_sesskey = ( openssl.md5( combined_sesskey:sub(1,16) ) .. openssl.md5( combined_sesskey:sub(17) ) ):sub(1, 24)
cli_sesskey_enc = openssl.encrypt( "aes-192-cbc", pw_hash, nil, cli_sesskey )
cli_sesskey_enc = select(2,bin.unpack("H" .. #cli_sesskey_enc, cli_sesskey_enc))
auth_password = openssl.encrypt( "aes-192-cbc", combined_sesskey, nil, rnd .. pass, true )
auth_password = select(2, bin.unpack("H" .. #auth_password, auth_password))
return cli_sesskey_enc, auth_password
end,
}
Helper = {
--- Creates a new Helper instance
--
-- @param host table containing the host table as received by action
-- @param port table containing the port table as received by action
-- @param instance string containing the instance name
-- @return o new instance of Helper
new = function(self, host, port, instance )
local o = {
host = host,
port = port,
socket = nmap.new_socket(),
dbinstance = instance or stdnse.get_script_args('tns.sid') or "orcl"
}
o.socket:set_timeout(30000)
setmetatable(o, self)
self.__index = self
return o
end,
--- Connects and performs protocol negotiation with the Oracle server
--
-- @return true on success, false on failure
-- @return err containing error message when status is false
Connect = function( self )
local SUPPORTED_VERSIONS = {
"IBMPC/WIN_NT64-9.1.0",
"IBMPC/WIN_NT-8.1.0",
"Linuxi386/Linux-2.0.34-8.1.0",
"x86_64/Linux 2.4.xx"
}
local status, data = self.socket:connect( self.host.ip, self.port.number, "tcp" )
local conn, packet, tns
if( not(status) ) then return status, data end
self.comm = Comm:new( self.socket )
status, self.version = self.comm:exchTNSPacket( Packet.Connect:new( self.host.ip, self.port.number, self.dbinstance ) )
if ( not(status) ) then return false, self.version end
if ( self.version ~= ORACLE_VERSION_11G and self.version ~= ORACLE_VERSION_10G ) then
return false, ("Unsupported Oracle Version (%d)"):format(self.version)
end
status = self.comm:exchTNSPacket( Packet.SNS:new( self.version ) )
if ( not(status) ) then return false, "ERROR: Helper.Connect failed" end
status, self.os = self.comm:exchTNSPacket( Packet.ProtoNeg:new( self.version ) )
if ( not(status) ) then
return false, data
end
-- used for testing unsupported versions
self.os = stdnse.get_script_args("tns.forceos") or self.os
status = false
for _, ver in pairs(SUPPORTED_VERSIONS) do
if ( self.os == ver ) then
status = true
break
end
end
if ( not(status) ) then
stdnse.debug2("ERROR: Version %s is not yet supported", self.os)
return false, ("ERROR: Connect to version %s is not yet supported"):format(self.os)
end
if ( self.os:match("IBMPC/WIN_NT") ) then
status = self.comm:sendTNSPacket( Packet.Unknown1:new( self.os ) )
if ( not(status) ) then
return false, "ERROR: Helper.Connect failed"
end
status, data = self.comm:sendTNSPacket( Packet.Unknown2:new( self.os ) )
if ( not(status) ) then return false, data end
status, data = self.comm:recvTNSPacket( Packet.Unknown2:new( ) )
if ( not(status) ) then return false, data end
-- Oracle 10g under Windows needs this additional read, there's
-- probably a better way to detect this by analysing the packets
-- further.
if ( self.version == ORACLE_VERSION_10G ) then
status, data = self.comm:recvTNSPacket( Packet.Unknown2:new( ) )
if ( not(status) ) then return false, data end
end
elseif ( "x86_64/Linux 2.4.xx" == self.os ) then
status = self.comm:sendTNSPacket( Packet.Unknown1:new( self.os ) )
if ( not(status) ) then
return false, "ERROR: Helper.Connect failed"
end
status = self.comm:sendTNSPacket( Packet.Unknown2:new( self.os ) )
if ( not(status) ) then
return false, "ERROR: Helper.Connect failed"
end
status, data = self.comm:recvTNSPacket( Packet.Unknown2:new( ) )
if ( not(status) ) then
return false, data
end
else
status = self.comm:exchTNSPacket( Packet.Unknown1:new( self.os ) )
if ( not(status) ) then
return false, "ERROR: Helper.Connect failed"
end
end
return true
end,
--- Sends a command to the TNS lsnr
-- It currently accepts and tries to send all commands received
--
-- @param cmd string containing the command to send to the server
-- @return data string containing the result received from the server
lsnrCtl = function( self, cmd )
local status, data = self.socket:connect( self.host.ip, self.port.number, "tcp" )
local conn, packet, tns, pkt
if( not(status) ) then
return status, data
end
self.comm = Comm:new( self.socket )
pkt = Packet.Connect:new( self.host.ip, self.port.number, self.dbinstance )
pkt:setCmd(cmd)
if ( not(self.comm:exchTNSPacket( pkt )) ) then
return false, self.version
end
data = ""
repeat
status, tns = self.comm:recvTNSPacket()
if ( not(status) ) then
self:Close()
return status, tns
end
local _, flags = bin.unpack(">S", tns.data )
data = data .. tns.data:sub(3)
until ( flags ~= 0 )
self:Close()
return true, data
end,
--- Authenticates to the database
--
-- @param user containing the Oracle user name
-- @param pass containing the Oracle user password
-- @return true on success, false on failure
-- @return err containing error message when status is false
Login = function( self, user, password )
local data, packet, status, tns, parser
local sesskey_enc, auth_pass, auth
local auth_options = AuthOptions:new()
status, auth = self.comm:exchTNSPacket( Packet.PreAuth:new( user, auth_options, self.os ) )
if ( not(status) ) then
return false, auth
end
-- Check what version of the DB to authenticate against AND verify whether
-- case sensitive login is enabled or not. In case-sensitive mode the salt
-- is longer, so we check the length of auth["AUTH_VFR_DATA"]
if ( self.version == ORACLE_VERSION_11G and #auth["AUTH_VFR_DATA"] > 2 ) then
sesskey_enc, auth_pass = Crypt:Encrypt11g( password, bin.pack( "H", auth["AUTH_SESSKEY"] ), bin.pack("H", auth["AUTH_VFR_DATA"] ) )
else
sesskey_enc, auth_pass = Crypt:Encrypt10g( user, password, bin.pack( "H", auth["AUTH_SESSKEY"] ) )
end
status, data = self.comm:exchTNSPacket( Packet.Auth:new( user, auth_options, sesskey_enc, auth_pass, self.os ) )
if ( not(status) ) then return false, data end
self.auth_session = data["AUTH_SESSION_ID"]
return true
end,
--- Steal auth data from database
-- @param user containing the Oracle user name
-- @param pass containing the Oracle user password
-- @return true on success, false on failure
-- @return err containing error message when status is false
StealthLogin = function( self, user, password )
local data, packet, status, tns, parser
local sesskey_enc, auth_pass, auth
local auth_options = AuthOptions:new()
status, auth = self.comm:exchTNSPacket( Packet.PreAuth:new( user, auth_options, self.os ) )
if ( not(status) ) then
return false, auth
elseif ( auth["AUTH_SESSKEY"] ) then
return true, auth
else
return false
end
end,
--- Queries the database
--
-- @param query string containing the SQL query
-- @return true on success, false on failure
-- @return result table containing fields
-- <code>rows</code>
-- <code>columns</code>
-- @return err containing error message when status is false
Query = function(self, query)
local SUPPORTED_VERSIONS = {
"IBMPC/WIN_NT-8.1.0",
}
local status = false
for _, ver in pairs(SUPPORTED_VERSIONS) do
if ( self.os == ver ) then
status = true
break
end
end
if ( not(status) ) then
stdnse.debug2("ERROR: Version %s is not yet supported", self.os)
return false, ("ERROR: Querying version %s is not yet supported"):format(self.os)
end
if ( not(query) ) then return false, "No query was supplied by user" end
local data
status, data = self.comm:exchTNSPacket( Packet.PostLogin:new(self.auth_session) )
if ( not(status) ) then
return false, "ERROR: Postlogin packet failed"
end
local status, result = self.comm:exchTNSPacket( Packet.Query:new(query) )
if ( not(status) ) then return false, result end
if ( not(result.moredata) ) then return true, result.data end
result = result.data
repeat
status, data = self.comm:exchTNSPacket( Packet.QueryResponseAck:new(result) )
until(not(status) or data:match(".*ORA%-01403: no data found\n$"))
return true, result
end,
--- Ends the Oracle communication
Close = function( self )
-- We should probably stick some slick sqlplus termination stuff in here
local status = self.comm:sendTNSPacket( Packet.EOF:new( ) )
self.socket:close()
end,
}
return _ENV;
| mit |
Colettechan/darkstar | scripts/zones/Northern_San_dOria/npcs/Galahad.lua | 13 | 1046 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Galahad
-- Type: Consulate Representative NPC
-- @zone: 231
-- @pos -51.984 -2.000 -15.373
--
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,GALAHAD_DIALOG);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/earth_wand.lua | 41 | 1075 | -----------------------------------------
-- ID: 17076
-- Item: Earth Wand
-- Additional Effect: Earth Damage
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onAdditionalEffect Action
-----------------------------------
function onAdditionalEffect(player,target,damage)
local chance = 10;
if (math.random(0,99) >= chance) then
return 0,0,0;
else
local dmg = math.random(6,20);
local params = {};
params.bonusmab = 0;
params.includemab = false;
dmg = addBonusesAbility(player, ELE_EARTH, target, dmg, params);
dmg = dmg * applyResistanceAddEffect(player,target,ELE_EARTH,0);
dmg = adjustForTarget(target,dmg,ELE_EARTH);
dmg = finalMagicNonSpellAdjustments(player,target,ELE_EARTH,dmg);
local message = MSGBASIC_ADD_EFFECT_DMG;
if (dmg < 0) then
message = MSGBASIC_ADD_EFFECT_HEAL;
end
return SUBEFFECT_EARTH_DAMAGE,message,dmg;
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/globals/fieldsofvalor.lua | 12 | 19354 | -------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/conquest");
-- require("scripts/globals/teleports");
require("scripts/globals/status");
require("scripts/globals/regimereward");
require("scripts/globals/regimeinfo");
require("scripts/globals/common");
-- require("scripts/globals/spell_definitions");
-------------------------------------------------
TABS = 12; -- What is this for? Where is it used?
-- key item IDs
ELITE_TRAINING_INTRODUCTION = 1116;
ELITE_TRAINING_CHAPTER_1 = 1117;
ELITE_TRAINING_CHAPTER_2 = 1118;
ELITE_TRAINING_CHAPTER_3 = 1119;
ELITE_TRAINING_CHAPTER_4 = 1120;
ELITE_TRAINING_CHAPTER_5 = 1121;
ELITE_TRAINING_CHAPTER_6 = 1122;
ELITE_TRAINING_CHAPTER_7 = 1123;
-- EVENT PARAM ID CONSTANTS (change these if even seqs displayed break!)
-- onEventUpdate params
FOV_MENU_PAGE_1 = 18;
FOV_MENU_PAGE_2 = 34;
FOV_MENU_PAGE_3 = 50;
FOV_MENU_PAGE_4 = 66;
FOV_MENU_PAGE_5 = 82;
FOV_MENU_VIEW_REGIME = 1;
FOV_MENU_LEVEL_RANGE = 6;
-- onEventFinish params
FOV_MENU_REGEN = 53;
FOV_MENU_REFRESH = 69;
FOV_MENU_PROTECT = 85;
FOV_MENU_SHELL = 101;
FOV_MENU_DRIED_MEAT = 117;
FOV_MENU_SALTED_FISH = 133;
FOV_MENU_HARD_COOKIE = 149;
FOV_MENU_INSTANT_NOODLES = 165;
FOV_MENU_RERAISE = 37;
FOV_MENU_HOME_NATION = 21;
FOV_MENU_CANCEL_REGIME = 3;
FOV_MENU_REPEAT_REGIME1 = -2147483630; -- 2147483666;
FOV_MENU_REPEAT_REGIME2 = -2147483614; -- 2147483682;
FOV_MENU_REPEAT_REGIME3 = -2147483598; -- 2147483698;
FOV_MENU_REPEAT_REGIME4 = -2147483582; -- 2147483714;
FOV_MENU_REPEAT_REGIME5 = -2147483566; -- 2147483730;
FOV_MENU_ELITE_INTRO = 36;
FOV_MENU_ELITE_CHAP1 = 52;
FOV_MENU_ELITE_CHAP2 = 68;
FOV_MENU_ELITE_CHAP3 = 84;
FOV_MENU_ELITE_CHAP4 = 100;
FOV_MENU_ELITE_CHAP5 = 116;
FOV_MENU_ELITE_CHAP6 = 132;
FOV_MENU_ELITE_CHAP7 = 148;
-- Special Message IDs (these usually don't break)
-- Found in Dialog Tables under "Other>System Messages (4)"
FOV_MSG_KILLED_TARGET = 558;
FOV_MSG_COMPLETED_REGIME = 559;
FOV_MSG_GET_GIL = 565;
FOV_MSG_GET_TABS = 566;
FOV_MSG_BEGINS_ANEW = 643;
-- MESSAGE ID CONSTANTS (msg id of "new training regime registered!": change this if msg ids break!)
FOV_MSG_EAST_RONFAURE = 9767;
FOV_MSG_WEST_RONFAURE = 10346;
FOV_MSG_NORTH_GUSTABERG = 10317;
FOV_MSG_SOUTH_GUSTABERG = 9795;
FOV_MSG_WEST_SARUTA = 10126;
FOV_MSG_EAST_SARUTA = 9840;
FOV_MSG_KONSCHTAT = 9701;
FOV_MSG_TAHRONGI = 9720;
FOV_MSG_LA_THEINE = 10039;
FOV_MSG_PASHHOW = 10611;
FOV_MSG_JUGNER = 10757;
FOV_MSG_MERIPH = 10490;
FOV_MSG_BATALLIA = 9921;
FOV_MSG_SAUROMAGUE = 9711;
FOV_MSG_ROLANBERRY = 9672;
FOV_MSG_VALKURM = 10166;
FOV_MSG_BUBURIMU = 10177;
FOV_MSG_QUFIM = 10252;
FOV_MSG_RUAUN_GARDENS = 9672;
FOV_MSG_BEAUCEDINE = 10649;
FOV_MSG_YUHTUNGA = 9971;
FOV_MSG_YHOATOR = 9920;
FOV_MSG_WEST_ALTEPA = 9731;
FOV_MSG_EAST_ALTEPA = 9868;
FOV_MSG_XARCABARD = 10156;
FOV_MSG_BEHEMOTH = 9362;
FOV_MSG_ZITAH = 10188;
FOV_MSG_ROMAEVE = 9537;
FOV_MSG_TERIGGAN = 10031;
FOV_MSG_SORROWS = 9517;
-- Event IDs
FOV_EVENT_RUAUN_GARDENS = 0x0049;
FOV_EVENT_EAST_RONFAURE = 0x003d;
FOV_EVENT_WEST_RONFAURE = 0x003d;
FOV_EVENT_WEST_SARUTA = 0x0034;
FOV_EVENT_EAST_SARUTA = 0x003d;
FOV_EVENT_NORTH_GUSTABERG = 0x010a;
FOV_EVENT_SOUTH_GUSTABERG = 0x003d;
FOV_EVENT_LA_THEINE = 0x003d;
FOV_EVENT_KONSCHTAT = 0x003d;
FOV_EVENT_TAHRONGI = 0x003d;
FOV_EVENT_PASHHOW = 0x001c;
FOV_EVENT_JUGNER = 0x0020;
FOV_EVENT_MERIPH = 0x002e;
FOV_EVENT_BATALLIA = 0x003d;
FOV_EVENT_SAUROMAGUE = 0x003d;
FOV_EVENT_ROLANBERRY = 0x003d;
FOV_EVENT_VALKURM = 0x002f;
FOV_EVENT_BUBURIMU = 0x0033;
FOV_EVENT_QUFIM = 0x0021;
FOV_EVENT_YUHTUNGA = 0x003d;
FOV_EVENT_YHOATOR = 0x003d;
FOV_EVENT_WEST_ALTEPA = 0x003d;
FOV_EVENT_EAST_ALTEPA = 0x003d; -- test
FOV_EVENT_BEAUCEDINE = 0x00da;
FOV_EVENT_XARCABARD = 0x0030;
FOV_EVENT_BEHEMOTH = 0x003d;
FOV_EVENT_ZITAH = 0x003d;
FOV_EVENT_ROMAEVE = 0x003d;
FOV_EVENT_TERIGGAN = 0x003d; -- test
FOV_EVENT_SORROWS = 0x003d;
----------------------------------
-- Start FoV onTrigger
----------------------------------
function startFov(eventid, player)
if (FIELD_MANUALS == 1) then
local hasRegime = player:getVar("fov_regimeid");
local tabs = player:getCurrency("valor_point");
player:startEvent(eventid, 0, 0, 0, 0, 0, 0, tabs, hasRegime);
end;
end
----------------------------------
-- Update FoV onEventUpdate
----------------------------------
function updateFov(player, csid, menuchoice, r1, r2, r3, r4, r5)
if (menuchoice == FOV_MENU_PAGE_1) then
local info = getRegimeInfo(r1);
player:updateEvent(info[1], info[2], info[3], info[4], 0, info[5], info[6], r1);
elseif (menuchoice == FOV_MENU_PAGE_2) then
local info = getRegimeInfo(r2);
player:updateEvent(info[1], info[2], info[3], info[4], 0, info[5], info[6], r2);
elseif (menuchoice == FOV_MENU_PAGE_3) then
local info = getRegimeInfo(r3);
player:updateEvent(info[1], info[2], info[3], info[4], 0, info[5], info[6], r3);
elseif (menuchoice == FOV_MENU_PAGE_4) then
local info = getRegimeInfo(r4);
player:updateEvent(info[1], info[2], info[3], info[4], 0, info[5], info[6], r4);
elseif (menuchoice == FOV_MENU_PAGE_5) then
local info = getRegimeInfo(r5);
player:updateEvent(info[1], info[2], info[3], info[4], 0, info[5], info[6], r5);
elseif (menuchoice == FOV_MENU_VIEW_REGIME) then -- View Regime (this option is only available if they have a regime active!)
-- get regime id and numbers killed...
local regid = player:getVar("fov_regimeid");
local info = getRegimeInfo(regid);
if (info[1] ~= 0) then n1 = player:getVar("fov_numkilled1"); else n1 = 0; end;
if (info[2] ~= 0) then n2 = player:getVar("fov_numkilled2"); else n2 = 0; end;
if (info[3] ~= 0) then n3 = player:getVar("fov_numkilled3"); else n3 = 0; end;
if (info[4] ~= 0) then n4 = player:getVar("fov_numkilled4"); else n4 = 0; end;
player:updateEvent(info[1], info[2], info[3], info[4], n1, n2, n3, n4);
elseif (menuchoice == FOV_MENU_LEVEL_RANGE) then -- Level range and training area on View Regime...
local regid = player:getVar("fov_regimeid");
local info = getRegimeInfo(regid);
player:updateEvent(0, 0, 0, 0, 0, info[5], info[6], 0);
end
end
------------------------------------------
-- Finish FoV onEventFinish
------------------------------------------
function finishFov(player, csid, option, r1, r2, r3, r4, r5, msg_offset)
local msg_accept = msg_offset;
local msg_jobs = msg_offset + 1;
local msg_cancel = msg_offset +2;
local tabs = player:getCurrency("valor_point");
local HAS_FOOD = player:hasStatusEffect(EFFECT_FOOD);
local HAS_SUPPORT_FOOD = player:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD);
local fov_repeat = bit.band(option, 0x80000000);
if (fov_repeat ~= 0) then
fov_repeat = 1;
end
option = bit.band(option, 0x7FFFFFFF);
-- ================= FIELD SUPPORT ===============================================
if (option == FOV_MENU_REGEN) then -- Chose Regen. Regen from FoV removes all forms of regen.
-- Decrease tabs
if (tabs >= 20) then
player:delCurrency("valor_point", 20);
-- Removes regen if on player
player:delStatusEffect(EFFECT_REGEN);
-- Adds regen
player:addStatusEffect(EFFECT_REGEN, 1, 3, 3600);
end
elseif (option == FOV_MENU_REFRESH) then -- Chose Refresh, removes all other refresh.
-- Decrease tabs
if (tabs >= 20) then
player:delCurrency("valor_point", 20);
-- Removes refresh if on player
player:delStatusEffect(EFFECT_REFRESH);
player:delStatusEffect(EFFECT_SUBLIMATION_COMPLETE);
player:delStatusEffect(EFFECT_SUBLIMATION_ACTIVATED);
-- Add refresh
player:addStatusEffect(EFFECT_REFRESH, 1, 3, 3600, 0, 3);
end
elseif (option == FOV_MENU_PROTECT) then -- Chose Protect, removes all other protect.
-- Decrease tabs
if (tabs >= 15) then
player:delCurrency("valor_point", 15);
-- Removes protect if on player
player:delStatusEffect(EFFECT_PROTECT);
-- Work out how much def to give (highest tier dependant on level)
local def = 0;
if (player:getMainLvl() < 27) then -- before protect 2, give protect 1
def = 15;
elseif (player:getMainLvl() < 47) then -- after p2, before p3
def = 40;
elseif (player:getMainLvl() < 63) then -- after p3, before p4
def = 75;
else -- after p4
def = 120;
end
-- Add protect
player:addStatusEffect(EFFECT_PROTECT, def, 0, 1800);
end
elseif (option == FOV_MENU_SHELL) then -- Chose Shell, removes all other shell.
-- Decrease tabs
if (tabs >= 15) then
player:delCurrency("valor_point", 15);
-- Removes shell if on player
player:delStatusEffect(EFFECT_SHELL);
-- Work out how much mdef to give (highest tier dependant on level)
-- values taken from Shell scripts by Tenjou.
local def = 0;
if (player:getMainLvl() < 37) then -- before shell 2, give shell 1
def = 9;
elseif (player:getMainLvl() < 57) then -- after s2, before s3
def = 14;
elseif (player:getMainLvl() < 68) then -- after s3, before s4
def = 19;
else -- after s4
def = 22;
end
-- Add shell
player:addStatusEffect(EFFECT_SHELL, def, 0, 1800);
end
elseif (option == FOV_MENU_RERAISE) then -- Reraise chosen.
-- Decrease tabs
if (tabs >= 10) then
player:delCurrency("valor_point", 10);
-- Remove any other RR
player:delStatusEffect(EFFECT_RERAISE);
-- apply RR1, 2 hour duration.
player:addStatusEffect(EFFECT_RERAISE, 1, 0, 7200);
end
elseif (option == FOV_MENU_HOME_NATION) then -- Return to home nation.
-- Decrease tabs
if (tabs >= 50) then
player:delCurrency("valor_point", 50);
toHomeNation(player); -- Needs an entry in scripts/globals/teleports.lua?
end
elseif (option == FOV_MENU_DRIED_MEAT) then -- Dried Meat: STR+4, Attack +22% (caps at 63)
if (tabs >= 50) then
if (HAS_FOOD == true or HAS_SUPPORT_FOOD == true) then
player:messageBasic(246);
else
player:delCurrency("valor_point", 50);
player:addStatusEffectEx(EFFECT_FIELD_SUPPORT_FOOD, 251, 1, 0, 1800);
end
end
elseif (option == FOV_MENU_SALTED_FISH) then -- Salted Fish: VIT+2 DEF+30% (Caps at 86)
if (tabs >= 50) then
if (HAS_FOOD == true or HAS_SUPPORT_FOOD == true) then
player:messageBasic(246);
else
player:delCurrency("valor_point", 50);
player:addStatusEffectEx(EFFECT_FIELD_SUPPORT_FOOD, 251, 2, 0, 1800);
end
end
elseif (option == FOV_MENU_HARD_COOKIE) then --- Hard Cookie: INT+4, MaxMP+30
if (tabs >= 50) then
if (HAS_FOOD == true or HAS_SUPPORT_FOOD == true) then
player:messageBasic(246);
else
player:delCurrency("valor_point", 50);
player:addStatusEffectEx(EFFECT_FIELD_SUPPORT_FOOD, 251, 3, 0, 1800);
end
end
elseif (option == FOV_MENU_INSTANT_NOODLES) then -- Instant Noodles: VIT+1, Max HP+27% (caps at 75), StoreTP+5
if (tabs >= 50) then
if (HAS_FOOD == true or HAS_SUPPORT_FOOD == true) then
player:messageBasic(246);
else
player:delCurrency("valor_point", 50);
player:addStatusEffectEx(EFFECT_FIELD_SUPPORT_FOOD, 251, 4, 0, 1800);
end
end
elseif (option == FOV_MENU_CANCEL_REGIME) then -- Cancelled Regime.
player:setVar("fov_regimeid" , 0);
player:setVar("fov_numkilled1", 0);
player:setVar("fov_numkilled2", 0);
player:setVar("fov_numkilled3", 0);
player:setVar("fov_numkilled4", 0);
player:showText(player, msg_cancel);
elseif (option == FOV_MENU_PAGE_1) then -- Page 1
writeRegime(player, r1, msg_accept, msg_jobs, fov_repeat);
elseif (option == FOV_MENU_PAGE_2) then -- Page 2
writeRegime(player, r2, msg_accept, msg_jobs, fov_repeat);
elseif (option == FOV_MENU_PAGE_3) then -- Page 3
writeRegime(player, r3, msg_accept, msg_jobs, fov_repeat);
elseif (option == FOV_MENU_PAGE_4) then -- Page 4
writeRegime(player, r4, msg_accept, msg_jobs, fov_repeat);
elseif (option == FOV_MENU_PAGE_5) then -- Page 5
writeRegime(player, r5, msg_accept, msg_jobs, fov_repeat);
elseif (option == FOV_MENU_ELITE_INTRO) then -- Want elite, 100tabs
-- giveEliteRegime(player, ELITE_TRAINING_CHAPTER_7, 100);
elseif (option == FOV_MENU_ELITE_CHAP1) then -- Want elite, 150tabs
-- local tabs = player:getVar("tabs");
-- local newtabs = tabs-150;
-- player:setVar("tabs", newtabs);
elseif (option == FOV_MENU_ELITE_CHAP2) then -- Want elite, 200tabs
-- local tabs = player:getVar("tabs");
-- local newtabs = tabs-200;
-- player:setVar("tabs", newtabs);
elseif (option == FOV_MENU_ELITE_CHAP3) then -- Want elite, 250tabs
elseif (option == FOV_MENU_ELITE_CHAP4) then -- Want elite, 300tabs
elseif (option == FOV_MENU_ELITE_CHAP5) then -- Want elite, 350tabs
elseif (option == FOV_MENU_ELITE_CHAP6) then -- Want elite, 400tabs
elseif (option == FOV_MENU_ELITE_CHAP7) then -- Want elite, 450tabs
else
-- print("opt is "..option);
end
end
function giveEliteRegime(player, keyitem, cost)
if (player:hasKeyItem(keyitem)) then
-- print("has");
-- player:messageBasic(98, keyitem);
else
player:delCurrency("valor_point", cost);
player:addKeyItem(keyitem);
end
end
-----------------------------------
-- Writes the chosen Regime to the SQL database
-----------------------------------
function writeRegime(player, rid, msg_accept, msg_jobs, regrepeat)
local info = getRegimeInfo(rid);
player:setVar("fov_regimeid", rid);
player:setVar("fov_repeat", regrepeat);
for i = 1, 4 do
player:setVar("fov_numkilled"..i, 0);
player:setVar("fov_numneeded"..i, info[i]);
end;
player:showText(player, msg_accept);
player:showText(player, msg_jobs);
end
-----------------------------------
-- player, mob, regime ID, index in the list of mobs to kill that this mob corresponds to (1-4)
-----------------------------------
function checkRegime(player, mob, rid, index)
-- dead people get no point
if (player == nil or player:getHP() == 0) then
return;
end
local partyType = player:checkSoloPartyAlliance();
if (player:checkFovAllianceAllowed() == 1) then
partyType = 1;
end
if (player:getVar("fov_regimeid") == rid) then -- player is doing this regime
-- Need to add difference because a lvl1 can xp with a level 75 at ro'maeve
local difference = math.abs(mob:getMainLvl() - player:getMainLvl());
if (partyType < 2 and (mob:getBaseExp() > 0 or LOW_LEVEL_REGIME == 1) and difference <= 15 and (player:checkDistance(mob) < 100 or player:checkFovDistancePenalty() == 0)) then
-- get the number of mobs needed/killed
local needed = player:getVar("fov_numneeded"..index);
local killed = player:getVar("fov_numkilled"..index);
if (killed < needed) then -- increment killed number and save.
killed = killed + 1;
player:messageBasic(FOV_MSG_KILLED_TARGET, killed, needed);
player:setVar("fov_numkilled"..index, killed);
if (killed == needed) then
local fov_info = getRegimeInfo(rid);
local k1 = player:getVar("fov_numkilled1");
local k2 = player:getVar("fov_numkilled2");
local k3 = player:getVar("fov_numkilled3");
local k4 = player:getVar("fov_numkilled4");
if (k1 == fov_info[1] and k2 == fov_info[2] and k3 == fov_info[3] and k4 == fov_info[4]) then
-- complete regime
player:messageBasic(FOV_MSG_COMPLETED_REGIME);
local reward = getFoVregimeReward(rid);
local tabs = (math.floor(reward / 10) * TABS_RATE);
local VanadielEpoch = vanaDay();
-- Award gil and tabs once per day.
if (player:getVar("fov_LastReward") < VanadielEpoch) then
player:messageBasic(FOV_MSG_GET_GIL, reward);
player:addGil(reward);
player:addCurrency("valor_point", tabs);
player:messageBasic(FOV_MSG_GET_TABS, tabs, player:getCurrency("valor_point")); -- Careful about order.
if (REGIME_WAIT == 1) then
player:setVar("fov_LastReward", VanadielEpoch);
end
end
-- TODO: display msgs (based on zone annoyingly, so will need player:getZoneID() then a lookup)
player:addExp(reward);
if (k1 ~= 0) then player:setVar("fov_numkilled1", 0); end
if (k2 ~= 0) then player:setVar("fov_numkilled2", 0); end
if (k3 ~= 0) then player:setVar("fov_numkilled3", 0); end
if (k4 ~= 0) then player:setVar("fov_numkilled4", 0); end
if (player:getVar("fov_repeat") ~= 1) then
player:setVar("fov_regimeid", 0);
player:setVar("fov_numneeded1", 0);
player:setVar("fov_numneeded2", 0);
player:setVar("fov_numneeded3", 0);
player:setVar("fov_numneeded4", 0);
else
player:messageBasic(FOV_MSG_BEGINS_ANEW);
end
end
end
end
end
end
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Full_Moon_Fountain/npcs/Moon_Spiral.lua | 27 | 1442 | -----------------------------------
-- Area: Full Moon Fountain
-- NPC: Moon Spiral
-- Involved in Quests: The Moonlit Path
-- @pos -302 9 -260 170
-----------------------------------
package.loaded["scripts/zones/Full_Moon_Fountain/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/bcnm");
require("scripts/globals/quests");
require("scripts/globals/missions");
require("scripts/zones/Full_Moon_Fountain/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (TradeBCNM(player,player:getZoneID(),trade,npc)) then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (EventTriggerBCNM(player,npc)) then
return;
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
printf("onUpdate CSID: %u",csid);
printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option)) then
return;
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
printf("onFinish CSID: %u",csid);
printf("onFinish RESULT: %u",option);
if (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Port_Windurst/npcs/Kuroido-Moido.lua | 1 | 4402 | -----------------------------------
-- Area: Port Windurst
-- NPC: Kuriodo-Moido
-- Involved In Quest: Making Amends, Wonder Wands
-- Starts and Finishes: Making Amens!
-- Working 100%
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
MakingAmends = player:getQuestStatus(WINDURST,MAKING_AMENDS); --First quest in series
MakingAmens = player:getQuestStatus(WINDURST,MAKING_AMENS); --Second quest in series
WonderWands = player:getQuestStatus(WINDURST,WONDER_WANDS); --Third and final quest in series
pfame = player:getFameLevel(WINDURST);
needToZone = player:needToZone();
BrokenWand = player:hasKeyItem(128);
if (MakingAmends == QUEST_ACCEPTED) then -- MAKING AMENDS: During Quest
player:startEvent(0x0114);
elseif (MakingAmends == QUEST_COMPLETED and MakingAmens ~= QUEST_COMPLETED and WonderWands ~= QUEST_COMPLETED and needToZone) then -- MAKING AMENDS: After Quest
player:startEvent(0x0117);
elseif (MakingAmends == QUEST_COMPLETED and MakingAmens == QUEST_AVAILABLE) then
if (pfame >=4 and not needToZone) then
player:startEvent(0x0118); -- Start Making Amens! if prerequisites are met
else
player:startEvent(0x0117); -- MAKING AMENDS: After Quest
end
elseif (MakingAmens == QUEST_ACCEPTED and not BrokenWand) then -- Reminder for Making Amens!
player:startEvent(0x011b);
elseif (MakingAmens == QUEST_ACCEPTED and BrokenWand) then -- Complete Making Amens!
player:startEvent(0x011c,GIL_RATE*6000);
elseif (MakingAmens == QUEST_COMPLETED) then
if (WonderWands == QUEST_ACCEPTED) then -- During Wonder Wands dialogue
player:startEvent(0x0105);
elseif (WonderWands == QUEST_COMPLETED) then -- Post Wonder Wands dialogue
player:startEvent(0x010a);
else
player:startEvent(0x011e,0,937); -- Post Making Amens! dialogue (before Wonder Wands)
end
elseif (player:getCurrentMission(ASA) == THAT_WHICH_CURDLES_BLOOD) then
local item = 0;
local asaStatus = player:getVar("ASA_Status");
-- TODO: Other Enfeebling Kits
if (asaStatus == 0) then
item = 2779;
else
printf("Error: Unknown ASA Status Encountered <%u>", asaStatus);
end
-- The Parameters are Item IDs for the Recipe
player:startEvent(0x035a, item, 1134, 2778, 2778, 4099, 2778);
else
rand = math.random(1,2);
if (rand == 1) then
player:startEvent(0x00e1); -- Standard Conversation
else
player:startEvent(0x00e2); -- Standard Conversation
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
local function amensReward(player)
require("scripts/globals/jsr_utils");
local reward = {
["xp"] = 8000,
["gil"] = 9000,
["beast"] = 5,
["item"] = 3974,
};
jsrReward(player, reward);
end
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0118) then
player:addQuest(WINDURST,MAKING_AMENS);
elseif (csid == 0x011c) then
player:needToZone(true);
player:delKeyItem(BROKEN_WAND);
player:addTitle(HAKKURURINKURUS_BENEFACTOR);
amensReward(player);
player:addGil(GIL_RATE*6000);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*6000);
player:addFame(WINDURST,150);
player:completeQuest(WINDURST,MAKING_AMENS);
end
end;
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Bastok_Markets/npcs/Foss.lua | 11 | 1274 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Foss
-- Starts & Finishes Repeatable Quest: Buckets of Gold
-- !pos -283 -12 -37 235
-----------------------------------
require("scripts/globals/npc_util");
require("scripts/globals/quests");
require("scripts/globals/titles");
function onTrade(player,npc,trade)
if (player:getQuestStatus(BASTOK,dsp.quest.id.bastok.BUCKETS_OF_GOLD) >= QUEST_ACCEPTED and npcUtil.tradeHas(trade, {{90,5}})) then
player:startEvent(272);
end
end;
function onTrigger(player,npc)
if (player:getQuestStatus(BASTOK,dsp.quest.id.bastok.BUCKETS_OF_GOLD) == QUEST_AVAILABLE) then
player:startEvent(271);
else
player:startEvent(270);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 271 and option == 0) then
player:addQuest(BASTOK,dsp.quest.id.bastok.BUCKETS_OF_GOLD);
elseif (csid == 272) then
local fame = player:hasCompletedQuest(BASTOK, dsp.quest.id.bastok.BUCKETS_OF_GOLD) and 8 or 75;
if (npcUtil.completeQuest(player, BASTOK, dsp.quest.id.bastok.BUCKETS_OF_GOLD, {title=dsp.title.BUCKET_FISHER, gil=300, fame=fame})) then
player:confirmTrade();
end
end
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/dried_date_+1.lua | 18 | 1342 | -----------------------------------------
-- ID: 5574
-- Item: dried_date_+1
-- Food Effect: 60Min, All Races
-----------------------------------------
-- Health 12
-- Magic 22
-- Agility -1
-- Intelligence 4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,3600,5574);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 12);
target:addMod(MOD_MP, 22);
target:addMod(MOD_AGI, -1);
target:addMod(MOD_INT, 4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 12);
target:delMod(MOD_MP, 22);
target:delMod(MOD_AGI, -1);
target:delMod(MOD_INT, 4);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Port_Bastok/npcs/Bagnobrok.lua | 17 | 1554 | -----------------------------------
-- Area: Port Bastok
-- NPC: Bagnobrok
-- Only sells when Bastok controls Movalpolos
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil;
require("scripts/zones/Port_Bastok/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
RegionOwner = GetRegionOwner(MOVALPOLOS);
if (RegionOwner ~= NATION_BASTOK) then
player:showText(npc,BAGNOBROK_CLOSED_DIALOG);
else
player:showText(npc,BAGNOBROK_OPEN_DIALOG);
stock = {
0x0280, 11, --Copper Ore
0x1162, 694, --Coral Fungus
0x1117, 4032, --Danceshroom
0x0672, 6500, --Kopparnickel Ore
0x142D, 736 --Movalpolos Water
}
showShop(player,BASTOK,stock);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
haiderqwwwqe/mr.SRBOT | plugins/tools.lua | 1 | 23104 | --Begin Tools.lua :)
local SUDO = 226861861 -- حـط ايـديك<===
local function index_function(user_id)
for k,v in pairs(_config.admins) do
if user_id == v[1] then
print(k)
return k
end
end
-- If not found
return false
end
local function getindex(t,id)
for i,v in pairs(t) do
if v == id then
return i
end
end
return nil
end
local function already_sudo(user_id)
for k,v in pairs(_config.sudo_users) do
if user_id == v then
return k
end
end
-- If not found
return false
end
local function reload_plugins( )
plugins = {}
load_plugins()
end
local function sudolint(msg)
local hash = "gp_lang:"..msg.chat_id_
local lang = redis:get(hash)
local sudo_users = _config.sudo_users
if not lang then
text = "*💡 List of sudo users :*\n"
else
text = "*💡 قائمه المطورين : \n"
end
for i=1,#sudo_users do
text = text..i.." - "..sudo_users[i].."\n"
end
return text
end
local function adminlist(msg)
local hash = "gp_lang:"..msg.chat_id_
local lang = redis:get(hash)
local sudo_users = _config.sudo_users
if not lang then
text = '*List of bot admins :*\n'
else
text = "*💡 قائمه الاداريين : *\n"
end
local compare = text
local i = 1
for v,user in pairs(_config.admins) do
text = text..i..'- '..(user[2] or '')..' ➢ ('..user[1]..')\n'
i = i +1
end
if compare == text then
if not lang then
text = '_No_ *admins* _available_'
else
text = '* 💡 لا يوجد اداريين *'
end
end
return text
end
local function action_by_reply(arg, data)
local cmd = arg.cmd
if not tonumber(data.sender_user_id_) then return false end
if data.sender_user_id_ then
if cmd == "رفع اداري" then
local function adminprom_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if is_admin1(tonumber(data.id_)) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is already an_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n *انه بالتأكيد اداري ☑️", 0, "md")
end
end
table.insert(_config.admins, {tonumber(data.id_), user_name})
save_config()
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _has been promoted as_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n تمت ترقيته ليصبح اداري ☑️", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, adminprom_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
if cmd == "تنزيل اداري" then
local function admindem_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local nameid = index_function(tonumber(data.id_))
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if not is_admin1(data.id_) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is not a_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n *انه بالتأكيد ليس اداري ☑️", 0, "md")
end
end
table.remove(_config.admins, nameid)
save_config()
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _has been demoted from_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n *تم تنزيله من الاداره ☑️", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, admindem_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
if cmd == "رفع مطور" then
local function visudo_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if already_sudo(tonumber(data.id_)) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is already a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _انه بالتأكيد مطور ☑️_", 0, "md")
end
end
table.insert(_config.sudo_users, tonumber(data.id_))
save_config()
reload_plugins(true)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is now_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _تم ترقيته ليصبح مطور ☑️_", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, visudo_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
if cmd == "تنزيل مطور" then
local function desudo_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if not already_sudo(data.id_) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is not a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _انه بالتأكيد ليس مطور ☑️_", 0, "md")
end
end
table.remove(_config.sudo_users, getindex( _config.sudo_users, tonumber(data.id_)))
save_config()
reload_plugins(true)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is no longer a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _تم تنزيله من المطورين ☑️_", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, desudo_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
else
if lang then
return tdcli.sendMessage(data.chat_id_, "", 0, "*💡 لا يوجد", 0, "md")
else
return tdcli.sendMessage(data.chat_id_, "", 0, "*User Not Found*", 0, "md")
end
end
end
local function action_by_username(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local cmd = arg.cmd
if not arg.username then return false end
if data.id_ then
if data.type_.user_.username_ then
user_name = '@'..check_markdown(data.type_.user_.username_)
else
user_name = check_markdown(data.title_)
end
if cmd == "رفع اداري" then
if is_admin1(tonumber(data.id_)) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is already a_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _انه بالتأكيد اداري ☑️_", 0, "md")
end
end
table.remove(_config.admins, nameid)
save_config()
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is Now a_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _تم ترقيته ليصبح اداري ☑️_", 0, "md")
end
end
if cmd == "تنزيل اداري" then
local nameid = index_function(tonumber(data.id_))
if not is_admin1(data.id_) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is not a_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _انه بالتأكيد ليس اداري ☑️_", 0, "md")
end
end
table.remove(_config.admins, nameid)
save_config()
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _has been demoted from_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _تم تنزيله من الاداره ☑️_", 0, "md")
end
end
if cmd == "رفع مطور" then
if already_sudo(tonumber(data.id_)) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is already a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n انه بالتأكيد مطور ☑️", 0, "md")
end
end
table.insert(_config.sudo_users, tonumber(data.id_))
save_config()
reload_plugins(true)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is now_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n تم ترقيته ليصبح مطور ☑️", 0, "md")
end
end
if cmd == "تنزيل مطور" then
if not already_sudo(data.id_) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is not a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n انه بالتأكيد ليس مطور ☑️", 0, "md")
end
end
table.remove(_config.sudo_users, getindex( _config.sudo_users, tonumber(data.id_)))
save_config()
reload_plugins(true)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is no longer a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n تم تنزيله من المطورين ☑️", 0, "md")
end
end
else
if lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_💡 لا يوجد _", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "*User Not Found*", 0, "md")
end
end
end
local function action_by_id(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local cmd = arg.cmd
if not tonumber(arg.user_id) then return false end
if data.id_ then
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if cmd == "رفع اداري" then
if is_admin1(tonumber(data.id_)) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is already a_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n *انه بالتأكيد اداري ☑️", 0, "md")
end
end
table.remove(_config.admins, nameid)
save_config()
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is Now a_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n *تمت ترقيته ليصبح اداري ☑️", 0, "md")
end
end
if cmd == "تنزيل اداري" then
local nameid = index_function(tonumber(data.id_))
if not is_admin1(data.id_) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is not a_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n *انه بالتأكيد ليس اداري ☑️*", 0, "md")
end
end
table.remove(_config.admins, nameid)
save_config()
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _has been demoted from_ *admin*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n *تم تنزيله من الاداره ☑️", 0, "md")
end
end
if cmd == "رفع مطور" then
if already_sudo(tonumber(data.id_)) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is already a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _انه بالتأكيد مطور ☑️_", 0, "md")
end
end
table.insert(_config.sudo_users, tonumber(data.id_))
save_config()
reload_plugins(true)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is now_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _تم ترقيته ليصبح مطور ☑️_", 0, "md")
end
end
if cmd == "تنزيل مطور" then
if not already_sudo(data.id_) then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is not a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _انه بالتأكيد ليس مطور ☑️_", 0, "md")
end
end
table.remove(_config.sudo_users, getindex( _config.sudo_users, tonumber(data.id_)))
save_config()
reload_plugins(true)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _is no longer a_ *sudoer*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "* 💡| User :* "..user_name.."\n *💡| ID : "..data.id_.."*\n _تم تنزيله من المطورين ☑️_", 0, "md")
end
end
else
if lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_💡 لا يوجد _", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "*User Not Found*", 0, "md")
end
end
end
local function th3boss(msg, matches)
local hash = "gp_lang:"..msg.chat_id_
local lang = redis:get(hash)
if tonumber(msg.sender_user_id_) == SUDO then
if matches[1] == "رفع مطور" then
if not matches[2] and tonumber(msg.reply_to_message_id_) ~= 0 then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.chat_id_,
message_id_ = msg.reply_to_message_id_
}, action_by_reply, {chat_id=msg.chat_id_,cmd="رفع مطور"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.chat_id_,user_id=matches[2],cmd="رفع مطور"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.chat_id_,username=matches[2],cmd="رفع مطور"})
end
end
if matches[1] == "تنزيل مطور" then
if not matches[2] and tonumber(msg.reply_to_message_id_) ~= 0 then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.chat_id_,
message_id_ = msg.reply_to_message_id_
}, action_by_reply, {chat_id=msg.chat_id_,cmd="تنزيل مطور"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.chat_id_,user_id=matches[2],cmd="تنزيل مطور"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.chat_id_,username=matches[2],cmd="تنزيل مطور"})
end
end
end
if matches[1] == "رفع اداري" and is_sudo(msg) then
if not matches[2] and tonumber(msg.reply_to_message_id_) ~= 0 then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.chat_id_,
message_id_ = msg.reply_to_message_id_
}, action_by_reply, {chat_id=msg.chat_id_,cmd="رفع اداري"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.chat_id_,user_id=matches[2],cmd="رفع اداري"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.chat_id_,username=matches[2],cmd="رفع اداري"})
end
end
if matches[1] == "تنزيل اداري" and is_sudo(msg) then
if not matches[2] and tonumber(msg.reply_to_message_id_) ~= 0 then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.chat_id_,
message_id_ = msg.reply_to_message_id_
}, action_by_reply, {chat_id=msg.chat_id_,cmd="تنزيل اداري"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.chat_id_,user_id=matches[2],cmd="تنزيل اداري"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.chat_id_,username=matches[2],cmd="تنزيل اداري"})
end
end
if matches[1] == 'انشاء مجموعه' and is_admin(msg) then
local text = matches[2]
tdcli.createNewGroupChat({[0] = msg.sender_user_id_}, text)
if not lang then
return '_Group Has Been Created!_'
else
return '_💡 تـم أنـشـاء الـمـجـوعـه ☑️_'
end
end
if matches[1] == 'ترقيه سوبر' and is_admin(msg) then
local text = matches[2]
tdcli.createNewChannelChat({[0] = msg.sender_user_id_}, text)
if not lang then
return '_SuperGroup Has Been Created!_'
else
return '_💡 تـم تـرقـيـه الـمـجـوعـه ☑️_'
end
end
if matches[1] == 'صنع خارقه' and is_admin(msg) then
local id = msg.chat_id_
tdcli.migrateGroupChatToChannelChat(id)
if not lang then
return '_Group Has Been Changed To SuperGroup!_'
else
return '_💡 تـم أنـشـاء الـمـجـوعـه ☑️_'
end
end
if matches[1] == 'ادخل' and is_admin(msg) then
tdcli.importChatInviteLink(matches[2])
if not lang then
return '*Done!*'
else
return '*تــم!*'
end
end
if matches[1] == 'ضع اسم البوت' and is_sudo(msg) then
tdcli.changeName(matches[2])
if not lang then
return '_Bot Name Changed To:_ *'..matches[2]..'*'
else
return '*💡| تم تغيير اسم البوت \n💡| الاسم الجديد : *'..matches[2]..'*'
end
end
if matches[1] == 'ضع معرف البوت' and is_sudo(msg) then
tdcli.changeUsername(matches[2])
if not lang then
return '*💡| Bot Username Changed To *\n*💡| username :* @'..matches[2]
else
return '*➿| تم تعديل معرف البوت *\n* 💡| المعرف الجديد :* @'..matches[2]..''
end
end
if matches[1] == 'مسح معرف البوت' and is_sudo(msg) then
tdcli.changeUsername('')
if not lang then
return '*Done!*'
else
return '_تم حذف معرف البوت _'
end
end
if matches[1] == 'الماركدوان' then
if matches[2] == 'تفعيل' then
redis:set('markread','on')
if not lang then
return '_Markread >_ *ON*'
else
return '_تم تفعيل الماركدوات 💡_'
end
end
if matches[2] == 'تعطيل' then
redis:set('markread','off')
if not lang then
return '_Markread >_ *OFF*'
else
return '_تم تعطيل الماركدوات 💡_'
end
end
end
if matches[1] == 'bc' and is_admin(msg) then
tdcli.sendMessage(matches[2], 0, 0, matches[3], 0) end
if matches[1] == 'اذاعه' and is_sudo(msg) then
local data = load_data(_config.moderation.data)
local bc = matches[2]
for k,v in pairs(data) do
tdcli.sendMessage(k, 0, 0, bc, 0)
end
end
if matches[1] == 'المطورين' and is_sudo(msg) then
return sudolist(msg)
end
if matches[1] == 'المطور' then
return tdcli.sendMessage(msg.chat_id_, msg.id_, 1, _config.info_text, 1, 'html')
end
if matches[1] == 'الاداريين' and is_admin(msg) then
return adminlist(msg)
end
if matches[1] == 'المغادره' and is_admin(msg) then
tdcli.changeChatMemberStatus(chat, our_id, 'Left', dl_cb, nil)
end
if matches[1] == 'الخروج التلقائي' and is_admin(msg) then
local hash = 'auto_leave_bot'
--Enable Auto Leave
if matches[2] == 'تفعيل' then
redis:del(hash)
return 'Auto leave has been enabled'
--Disable Auto Leave
elseif matches[2] == 'تعطيل' then
redis:set(hash, true)
return 'Auto leave has been disabled'
--Auto Leave Status
elseif matches[2] == 'الحاله' then
if not redis:get(hash) then
return 'Auto leave is enable'
else
return 'Auto leave is disable'
end
end
end
end
return {
patterns = {
"^(رفع مطور)$",
"^(تنزيل مطور)$",
"^(المطوريين)$",
"^(رفع مطور) (.*)$",
"^(تنزيل مطور) (.*)$",
"^(رفع اداري)$",
"^(تنزيل اداري)$",
"^(الاداريين)$",
"^(رفع اداري) (.*)$",
"^(تنزيل اداري) (.*)$",
"^(المغادره)$",
"^(الخروج التلقائي) (.*)$",
"^(المطور)$",
"^(انشاء مجموعه) (.*)$",
"^(ترقيه سوبر) (.*)$",
"^(صنع خارقه)$",
"^(ادخل) (.*)$",
"^(ضع اسم البوت) (.*)$",
"^(ضع معرف البوت) (.*)$",
"^(مسح معرف البوت) (.*)$",
"^(الماركدوان) (.*)$",
"^(bc) (%d+) (.*)$",
"^(تفعيل) (.*)$",
"^(تعطيل) (.*)$",
"^(اذاعه) (.*)$",
},
run = th3boss
}
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Buburimu_Peninsula/npcs/Bonbavour_RK.lua | 13 | 3337 | -----------------------------------
-- Area: Buburimu Peninsula
-- NPC: Bonbavour, R.K.
-- Outpost Conquest Guards
-- @pos -481.164 -32.858 49.188 118
-----------------------------------
package.loaded["scripts/zones/Buburimu_Peninsula/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Buburimu_Peninsula/TextIDs");
local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = KOLSHUSHU;
local csid = 0x7ffb;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/watermelon.lua | 18 | 1176 | -----------------------------------------
-- ID: 4491
-- Item: watermelon
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Agility -6
-- Intelligence 4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,4491);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, -6);
target:addMod(MOD_INT, 4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, -6);
target:delMod(MOD_INT, 4);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Jugner_Forest/npcs/Stone_Monument.lua | 13 | 1274 | -----------------------------------
-- Area: Jugner Forest
-- NPC: Stone Monument
-- Involved in quest "An Explorer's Footsteps"
-- @pos -65.976 -23.829 -661.362 104
-----------------------------------
package.loaded["scripts/zones/Jugner_Forest/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Jugner_Forest/TextIDs");
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0384);
end;
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
if (trade:getItemCount() == 1 and trade:hasItemQty(571,1)) then
player:tradeComplete();
player:addItem(570);
player:messageSpecial(ITEM_OBTAINED,570);
player:setVar("anExplorer-CurrentTablet",0x00010);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Abyssea-Grauberg/npcs/qm6.lua | 14 | 1344 | -----------------------------------
-- Zone: Abyssea-Grauberg
-- NPC: qm6 (???)
-- Spawns Minaruja
-- @pos ? ? ? 254
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
--[[
if (trade:hasItemQty(3267,1) and trade:getItemCount() == 1) then -- Player has all the required items.
if (GetMobAction(17818046) == ACTION_NONE) then -- Mob not already spawned from this
SpawnMob(17818046):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe)
player:tradeComplete();
end
end
]]
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(1010, 3267); -- Inform player what items they need.
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/pestle.lua | 41 | 1123 | -----------------------------------------
-- ID: 18599
-- Item: Pestle
-- Additional effect: MP Drain
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onAdditionalEffect Action
-----------------------------------
function onAdditionalEffect(player,target,damage)
local chance = 10;
if (math.random(0,99) >= chance or target:isUndead()) then
return 0,0,0;
else
local drain = math.random(2,8);
local params = {};
params.bonusmab = 0;
params.includemab = false;
-- drain = addBonusesAbility(player, ELE_DARK, target, drain, params);
drain = drain * applyResistanceAddEffect(player,target,ELE_DARK,0);
drain = adjustForTarget(target,drain,ELE_DARK);
drain = finalMagicNonSpellAdjustments(player,target,ELE_DARK,drain);
if (drain > target:getMP()) then
drain = target:getMP();
end
target:addMP(-drain);
return SUBEFFECT_MP_DRAIN, MSGBASIC_ADD_EFFECT_MP_DRAIN, player:addMP(drain);
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/rabbit_pie.lua | 18 | 1844 | -----------------------------------------
-- ID: 5685
-- Item: rabbit_pie
-- Food Effect: 30minutes, All Races
-----------------------------------------
-- Strength 5
-- Vitality 5
-- Attack 25% (caps @ 100)
-- Ranged Attack 25% (caps @ 100)
-- Defense 25% (caps @ 100)
-- Intelligence -2
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5685);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 5);
target:addMod(MOD_VIT, 5);
target:addMod(MOD_FOOD_ATTP, 25);
target:addMod(MOD_FOOD_ATT_CAP, 100);
target:addMod(MOD_FOOD_RATTP, 25);
target:addMod(MOD_FOOD_RATT_CAP, 100);
target:addMod(MOD_FOOD_DEFP, 25);
target:addMod(MOD_FOOD_DEF_CAP, 100);
target:addMod(MOD_INT, -2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 5);
target:delMod(MOD_VIT, 5);
target:delMod(MOD_FOOD_ATTP, 25);
target:delMod(MOD_FOOD_ATT_CAP, 100);
target:delMod(MOD_FOOD_RATTP, 25);
target:delMod(MOD_FOOD_RATT_CAP, 100);
target:delMod(MOD_FOOD_DEFP, 25);
target:delMod(MOD_FOOD_DEF_CAP, 100);
target:delMod(MOD_INT, -2);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/bowl_of_ulbuconut_milk.lua | 18 | 1192 | -----------------------------------------
-- ID: 5976
-- Item: Bowl of Ulbuconut Milk
-- Food Effect: 3Min, All Races
-----------------------------------------
-- Charisma +3
-- Vitality -2
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,180,5976);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_CHR, 3);
target:addMod(MOD_VIT, -2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_CHR, 3);
target:delMod(MOD_VIT, -2);
end;
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.