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 |
|---|---|---|---|---|---|
Vadavim/jsr-darkstar | scripts/zones/Northern_San_dOria/npcs/Pagisalis.lua | 1 | 3474 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Pagisalis
-- Involved In Quest: Enveloped in Darkness
-- @zone 231
-- @pos
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(SANDORIA,UNDYING_FLAMES) == QUEST_ACCEPTED) then
if (trade:hasItemQty(913,2) and trade:getItemCount() == 2) then -- Trade Lump of Beeswax
player:startEvent(0x0233);
elseif (trade:hasItemQty(4099,12) and trade:getItemCount() == 12) then -- Trade Earth Crystals
player:startEvent(0x0233);
end
end
if (player:hasKeyItem(OLD_POCKET_WATCH) and player:hasKeyItem(OLD_BOOTS) == false) then
if (trade:hasItemQty(828,1) and trade:getItemCount() == 1) then -- Trade Velvet Cloth
player:startEvent(0x0025);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
sanFame = player:getFameLevel(SANDORIA);
undyingFlames = player:getQuestStatus(SANDORIA,UNDYING_FLAMES);
if (player:hasKeyItem(OLD_POCKET_WATCH)) then
player:startEvent(0x0030);
elseif (player:hasKeyItem(OLD_BOOTS)) then
player:startEvent(0x003A);
elseif (sanFame >= 2 and undyingFlames == QUEST_AVAILABLE) then
player:startEvent(0x0232);
elseif (undyingFlames == QUEST_ACCEPTED) then
player:startEvent(0x0235);
elseif (undyingFlames == QUEST_COMPLETED) then
player:startEvent(0x0236);
else
player:startEvent(0x0234)
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function questReward(player)
require("scripts/globals/jsr_utils");
local reward = {
["xp"] = 1250,
["guild"] = {ALCH, 300},
["item"] = 13211
};
jsrReward(player, reward);
end
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0232 and option == 0) then
player:addQuest(SANDORIA,UNDYING_FLAMES);
player:SayToPlayer("You may trade two Silver Beastoins instead of beeswax.")
elseif (csid == 0x0233) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13211); -- Friars Rope
else
player:tradeComplete();
player:addTitle(FAITH_LIKE_A_CANDLE);
questReward(player);
player:addFame(SANDORIA,30);
player:completeQuest(SANDORIA,UNDYING_FLAMES);
end
elseif (csid == 0x0025) then
player:tradeComplete();
player:delKeyItem(OLD_POCKET_WATCH);
player:addKeyItem(OLD_BOOTS);
player:messageSpecial(KEYITEM_OBTAINED,OLD_BOOTS);
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/mobskills/Digest.lua | 1 | 1189 | ---------------------------------------------------
-- Drainkiss
-- Deals dark damage to a single target. Additional effect: Drain
-- Type: Magical
-- Utsusemi/Blink absorb: 1 shadow
-- Range: Melee
-- Notes: If used against undead, it will simply do damage and not drain HP.
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:getFamily() == 290) then -- Claret
if (mob:checkDistance(target) < 3) then -- Don't use it if he is on his target.
return 1;
end;
end;
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local hard = mob:getMobMod(MOBMOD_HARD_MODE);
local dmgmod = 1 + hard / 5;
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*2.6,ELE_DARK,dmgmod,TP_MAB_BONUS,1);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_DARK,MOBPARAM_1_SHADOW);
skill:setMsg(MobPhysicalDrainMove(mob, target, skill, MOBDRAIN_HP, dmg));
return dmg;
end;
| gpl-3.0 |
zynjec/darkstar | scripts/globals/weaponskills/quietus.lua | 10 | 1867 | -----------------------------------
-- Quietus
-- Scythe weapon skill
-- Skill Level: N/A
-- Delivers a triple damage attack that ignores target's defense. Amount ignored varies with TP. Redemption: Aftermath.
-- Available only when equipped with Redemption (85)/(90)/(95)/(99) or Penitence +1/+2/+3/Umiliati.
-- Aligned with the Shadow Gorget, Aqua Gorget & Snow Gorget.
-- Aligned with the Shadow Belt, Aqua Belt & Snow Belt.
-- Element: None
-- Modifiers: STR: 60% MND: 60%
-- 100%TP 200%TP 300%TP
-- 3.00 3.00 3.00
-----------------------------------
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.0 params.ftp200 = 3.0 params.ftp300 = 3.0
params.str_wsc = 0.4 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.0 params.mnd_wsc = 0.4 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;
params.ignoresDef = true
params.ignored100 = 0.1
params.ignored200 = 0.3
params.ignored300 = 0.5
if USE_ADOULIN_WEAPON_SKILL_CHANGES then
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)
-- Apply aftermath
if damage > 0 then
dsp.aftermath.addStatusEffect(player, tp, dsp.slot.MAIN, dsp.aftermath.type.EMPYREAN)
end
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Yuhtunga_Jungle/npcs/Logging_Point.lua | 17 | 1091 | -----------------------------------
-- Area: Yuhtunga Jungle
-- NPC: Logging Point
-----------------------------------
package.loaded["scripts/zones/Yuhtunga_Jungle/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/logging");
require("scripts/zones/Yuhtunga_Jungle/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
startLogging(player,player:getZoneID(),npc,trade,0x00CD);
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(LOGGING_IS_POSSIBLE_HERE,1021);
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 |
vseledkin/torch-toolbox | Dataset-tools/data_augmentation.lua | 2 | 3001 | -- Author: Aysegul Dundar
-- Date: December, 2014
require 'image'
require 'pl'
require 'trepl'
opt = lapp[[
-h,--hflip (default true) horizontal flip
-t,--transImgInt (default 20) stepping of translation, number of images to create (ta/t)^2
--ta (default 40) max translation length
-r, --rotationImg (default 2) number of images to create by rotation
--ra (default 0.1) max angle of rotation
-p,--pathToFolder (default 'images') path to the folder of images
]]
if not paths.dir(opt.pathToFolder) then
error(string.format("the folder %s not exist", opt.pathToFolder))
end
function hflip_img(path_img, tmp_img, aug_path)
local tmp_path = path_img .. "/" .. tmp_img
local img = image.load(tmp_path)
local img_flip = image.hflip(img)
-- assumes .jpg ending for now
tmp_img = string.sub(tmp_img, 1, -5)
local img_path = aug_path .. "/" .. tmp_img .. "flip.jpg"
image.save(img_path, img_flip)
end
function rotate_img(path_img, tmp_img, aug_path, degree)
local tmp_path = path_img .. "/" .. tmp_img
local img = image.load(tmp_path)
local img_rotate = image.rotate(img, degree)
-- assumes .jpg ending for now
tmp_img = string.sub(tmp_img, 1, -5)
local img_path = aug_path .. "/" .. tmp_img .. "rotate" .. degree .. ".jpg"
image.save(img_path, img_rotate)
end
function crop5_img(path_img, tmp_img, aug_path, jitter)
local tmp_path = path_img .. "/" .. tmp_img
local img = image.load(tmp_path)
local w = img:size(2) - jitter
local h = img:size(3) - jitter
-- assumes .jpg ending for now
tmp_img = string.sub(tmp_img, 1, -5)
local number_img = jitter/opt.transImgInt
for i=1, number_img do
for j=1, number_img do
local sample = img[{{}, {1+ (j-1) * opt.transImgInt, (j-1) * opt.transImgInt + w},
{1+ (i-1) * opt.transImgInt, (i-1) * opt.transImgInt + h}}]
local img_path = aug_path .. "/" .. tmp_img .. "crop" .. (j+(i-1)*number_img) .. ".jpg"
image.save(img_path, sample)
if opt.hflip == true then
hflip_img(aug_path, tmp_img .. "crop" .. (j+(i-1)*number_img) .. ".jpg", aug_path)
end
end
end
end
local image_names = paths.dir(opt.pathToFolder, 'r')
os.execute("mkdir -p " .. opt.pathToFolder .. "/augmentations")
local aug_path = opt.pathToFolder .. "/augmentations"
for i=1, #image_names do
local tmp_img = image_names[i]
if (string.sub(tmp_img, 1, 1) ~= '.' and tmp_img ~= 'augmentations') then
if opt.ta > 0 then
crop5_img(opt.pathToFolder, tmp_img, aug_path, opt.ta)
elseif opt.hflip == true then
hflip_img(opt.pathToFolder, tmp_img, aug_path)
end
if opt.ra > 0 then
local angle = opt.ra/opt.rotationImg
for i=1, opt.rotationImg do
rotate_img(opt.pathToFolder, tmp_img, aug_path, angle*i)
end
end
end
end
| bsd-3-clause |
Vadavim/jsr-darkstar | scripts/zones/Port_Bastok/npcs/Mine_Konte.lua | 17 | 1124 | -----------------------------------
-- Area: Port Bastok
-- NPC: Mine Konte
-- Involved in Quest: Out of One's Shell
-----------------------------------
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
OutOfOneShell = player:getQuestStatus(BASTOK,OUT_OF_ONE_S_SHELL);
if (OutOfOneShell == QUEST_ACCEPTED and player:getVar("OutOfTheShellZone") == 0) then
player:startEvent(0x0053);
else
player:startEvent(0x002a);
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/Bastok_Markets/npcs/Zaira.lua | 15 | 1895 | -----------------------------------
-- Area: Batok Markets
-- NPC: Zaira
-- Standard Merchant NPC
--
-- Updated Aug-09-2013 by Zerahn, based on bgwiki and gamerescape
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
require("scripts/zones/Bastok_Markets/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,ZAIRA_SHOP_DIALOG);
stock = {
0x12FE, 111,1, --Scroll of Blind
0x12E6, 360,2, --Scroll of Bio
0x12DC, 82,2, --Scroll of Poison
0x12FD, 2250,2, --Scroll of Sleep
0x129F, 61,3, --Scroll of Stone
0x12A9, 140,3, --Scroll of Water
0x129A, 324,3, --Scroll of Aero
0x1290, 837,3, --Scroll of Fire
0x1295, 1584,3, --Scroll of Blizzard
0x12A4, 3261,3, --Scroll of Thunder
0x12EF, 1363,3, --Scroll of Shock
0x12EE, 1827,3, --Scroll of Rasp
0x12ED, 2250,3, --Scroll of Choke
0x12EC, 3688,3, --Scroll of Frost
0x12EB, 4644,3, --Scroll of Burn
0x12F0, 6366,3, --Scroll of Drown
}
showNationShop(player, NATION_BASTOK, 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 |
darklost/quick-ng | quick/framework/cc/components/behavior/EventProtocol.lua | 10 | 5330 |
local Component = import("..Component")
local EventProtocol = class("EventProtocol", Component)
function EventProtocol:ctor()
EventProtocol.super.ctor(self, "EventProtocol")
self.listeners_ = {}
self.nextListenerHandleIndex_ = 0
end
function EventProtocol:addEventListener(eventName, listener, tag)
assert(type(eventName) == "string" and eventName ~= "",
"EventProtocol:addEventListener() - invalid eventName")
eventName = string.upper(eventName)
if self.listeners_[eventName] == nil then
self.listeners_[eventName] = {}
end
local ttag = type(tag)
if ttag == "table" or ttag == "userdata" then
PRINT_DEPRECATED("EventProtocol:addEventListener(eventName, listener, target) is deprecated, please use EventProtocol:addEventListener(eventName, handler(target, listener), tag)")
listener = handler(tag, listener)
tag = ""
end
self.nextListenerHandleIndex_ = self.nextListenerHandleIndex_ + 1
local handle = tostring(self.nextListenerHandleIndex_)
tag = tag or ""
self.listeners_[eventName][handle] = {listener, tag}
if DEBUG > 1 then
printInfo("%s [EventProtocol] addEventListener() - event: %s, handle: %s, tag: %s", tostring(self.target_), eventName, handle, tostring(tag))
end
return handle
end
function EventProtocol:dispatchEvent(event)
event.name = string.upper(tostring(event.name))
local eventName = event.name
if DEBUG > 1 then
printInfo("%s [EventProtocol] dispatchEvent() - event %s", tostring(self.target_), eventName)
end
if self.listeners_[eventName] == nil then return end
event.target = self.target_
event.stop_ = false
event.stop = function(self)
self.stop_ = true
end
for handle, listener in pairs(self.listeners_[eventName]) do
if DEBUG > 1 then
printInfo("%s [EventProtocol] dispatchEvent() - dispatching event %s to listener %s", tostring(self.target_), eventName, handle)
end
-- listener[1] = listener
-- listener[2] = tag
event.tag = listener[2]
listener[1](event)
if event.stop_ then
if DEBUG > 1 then
printInfo("%s [EventProtocol] dispatchEvent() - break dispatching for event %s", tostring(self.target_), eventName)
end
break
end
end
return self.target_
end
function EventProtocol:removeEventListener(handleToRemove)
for eventName, listenersForEvent in pairs(self.listeners_) do
for handle, _ in pairs(listenersForEvent) do
if handle == handleToRemove then
listenersForEvent[handle] = nil
if DEBUG > 1 then
printInfo("%s [EventProtocol] removeEventListener() - remove listener [%s] for event %s", tostring(self.target_), handle, eventName)
end
return self.target_
end
end
end
return self.target_
end
function EventProtocol:removeEventListenersByTag(tagToRemove)
for eventName, listenersForEvent in pairs(self.listeners_) do
for handle, listener in pairs(listenersForEvent) do
-- listener[1] = listener
-- listener[2] = tag
if listener[2] == tagToRemove then
listenersForEvent[handle] = nil
if DEBUG > 1 then
printInfo("%s [EventProtocol] removeEventListener() - remove listener [%s] for event %s", tostring(self.target_), handle, eventName)
end
end
end
end
return self.target_
end
function EventProtocol:removeEventListenersByEvent(eventName)
self.listeners_[string.upper(eventName)] = nil
if DEBUG > 1 then
printInfo("%s [EventProtocol] removeAllEventListenersForEvent() - remove all listeners for event %s", tostring(self.target_), eventName)
end
return self.target_
end
function EventProtocol:removeAllEventListeners()
self.listeners_ = {}
if DEBUG > 1 then
printInfo("%s [EventProtocol] removeAllEventListeners() - remove all listeners", tostring(self.target_))
end
return self.target_
end
function EventProtocol:hasEventListener(eventName)
eventName = string.upper(tostring(eventName))
local t = self.listeners_[eventName]
if not t then
return false
end
for _, __ in pairs(t) do
return true
end
return false
end
function EventProtocol:dumpAllEventListeners()
print("---- EventProtocol:dumpAllEventListeners() ----")
for name, listeners in pairs(self.listeners_) do
printf("-- event: %s", name)
for handle, listener in pairs(listeners) do
printf("-- listener: %s, handle: %s", tostring(listener[1]), tostring(handle))
end
end
return self.target_
end
function EventProtocol:exportMethods()
self:exportMethods_({
"addEventListener",
"dispatchEvent",
"removeEventListener",
"removeEventListenersByTag",
"removeEventListenersByEvent",
"removeAllEventListenersForEvent",
"removeAllEventListeners",
"hasEventListener",
"dumpAllEventListeners",
})
return self.target_
end
function EventProtocol:onBind_()
end
function EventProtocol:onUnbind_()
end
return EventProtocol
| mit |
kickstandproject/asterisk-testsuite-temporary | asttest/self-tests/astlib_configs2/test.lua | 5 | 1883 | -- test astlib
skip_if(not ast.exists(), "asterisk not found")
-- generate what we expect to see
expected_test_conf = [[
[test]
test = 1
test = test
value = this
allow = true
[section]
value = yes
setting = on
ip = 10.10.10.10
[section]
value = no
#include file
[template](!)
value = default
[inherit](template)
value = default
[inherit](template,test)
value = default
[inherit_template](!,template,test)
value = default
]]
f = io.open("expected_test.conf", "w")
f:write(expected_test_conf)
f:close()
-- generate a config
a = ast.new()
a["test.conf"]["test"]["test"] = 1
a["test.conf"]["test"]["test"] = "test"
a["test.conf"]["test"]["value"] = "this"
a["test.conf"]["test"]["allow"] = true
a["test.conf"]["section"]["value"] = "yes"
a["test.conf"]["section"]["setting"] = "on"
a["test.conf"]["section"]["ip"] = "10.10.10.10"
s = a["test.conf"]:new_section("section")
s["value"] = "no"
a["test.conf"]:verbatim("#include file\n\n")
a["test.conf"]["template"].template = true
a["test.conf"]["template"]["value"] = "default"
a["test.conf"]["inherit"].inherit = {"template"}
a["test.conf"]["inherit"]["value"] = "default"
s = a["test.conf"]:new_section("inherit")
s.inherit = {"template", "test"}
s["value"] = "default"
a["test.conf"]["inherit_template"].template = true
a["test.conf"]["inherit_template"].inherit = {"template", "test"}
a["test.conf"]["inherit_template"]["value"] = "default"
a:spawn()
a:term_or_kill()
f = io.open(a:path("/etc/asterisk/test.conf"))
test_conf = f:read("*a")
f:close()
-- diff the two
os.execute("diff -u expected_test.conf " .. a:path("/etc/asterisk/test.conf") .. " > diff")
f = io.open("diff")
diff = f:read("*a")
f:close()
-- cleanup
os.execute("rm -f test.conf expected_test.conf diff")
-- check if our two configs match
fail_if(test_conf ~= expected_test_conf, "test_conf does not match expected_test_conf\n\n" .. diff)
| gpl-2.0 |
Vadavim/jsr-darkstar | scripts/globals/effects/accuracy_boost_ii.lua | 1 | 1028 | -----------------------------------
--
-- EFFECT_ACCURACY_BOOST
--
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_ACC,effect:getPower());
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
-- the effect loses accuracy of 1 every 3 ticks depending on the source of the acc boost
local boostACC_effect_size = effect:getPower();
if (boostACC_effect_size > 0) then
effect:setPower(boostACC_effect_size - 1)
target:delMod(MOD_ACC,1);
end
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
local boostACC_effect_size = effect:getPower();
if (boostACC_effect_size > 0) then
target:delMod(MOD_ACC,effect:getPower());
end
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Windurst_Waters/npcs/Tonana.lua | 13 | 1113 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Tonana
-- Warps players to Windurst Woods
-----------------------------------
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:startEvent(0x23b);
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 (option == 1) then
player:setPos(108.744,-4.999,-134.094,222,241); -- (Retail packet captured)
end
end;
| gpl-3.0 |
amir0858/telesuper1 | plugins/saveplug.lua | 19 | 1055 | --Created by: @WaderTGTeam
--Powered by: @WaderTGTeam
--âڑ ï¸ڈCopyRight all right reservedâڑ ï¸ڈ
local function saveplug(extra, success, result)
local msg = extra.msg
local name = extra.name
local receiver = get_receiver(msg)
if success then
local file = 'plugins/'..name..'.lua'
print('File saving to:', result)
os.rename(result, file)
print('File moved to:', file)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
local function run(msg,matches)
local receiver = get_receiver(msg)
local group = msg.to.id
if msg.reply_id then
local name = matches[2]
if matches[1] == "save" and matches[2] and is_sudo(msg) then
load_document(msg.reply_id, saveplug, {msg=msg,name=name})
return 'Plugin '..name..' has been saved.'
end
end
end
return {
patterns = {
"^[!/#](save) (.*)$",
},
run = run,
}
--Created by: @WaderTGTeam
--Powered by: @WaderTGTeam
--âڑ ï¸ڈCopyRight all right reservedâڑ ï¸ڈ
| agpl-3.0 |
runswithd6s/awesome-configs | battery.lua | 1 | 1955 | -- Source: http://awesome.naquadah.org/wiki/Closured_Battery_Widget
local io = io
local math = math
local naughty = naughty
local beautiful = beautiful
local tonumber = tonumber
local tostring = tostring
local print = print
local pairs = pairs
module("battery")
local limits = {{25, 5},
{12, 3},
{ 7, 1},
{0}}
function get_bat_state (adapter)
local fcur = io.open("/sys/class/power_supply/"..adapter.."/charge_now")
local fcap = io.open("/sys/class/power_supply/"..adapter.."/charge_full")
local fsta = io.open("/sys/class/power_supply/"..adapter.."/status")
local cur = fcur:read()
local cap = fcap:read()
local sta = fsta:read()
fcur:close()
fcap:close()
fsta:close()
local battery = math.floor(cur * 100 / cap)
if sta:match("Charging") then
dir = 1
elseif sta:match("Discharging") then
dir = -1
else
dir = 0
battery = ""
end
return battery, dir
end
function getnextlim (num)
for ind, pair in pairs(limits) do
lim = pair[1]; step = pair[2]; nextlim = limits[ind+1][1] or 0
if num > nextlim then
repeat
lim = lim - step
until num > lim
if lim < nextlim then
lim = nextlim
end
return lim
end
end
end
function batclosure (adapter)
local nextlim = limits[1][1]
return function ()
local prefix = "⚡"
local battery, dir = get_bat_state(adapter)
if dir == -1 then
dirsign = "↓"
prefix = "Bat:"
if battery <= nextlim then
naughty.notify({title = "⚡ Beware! ⚡",
text = "Battery charge is low ( ⚡ "..battery.."%)!",
timeout = 7,
position = "bottom_right",
fg = beautiful.fg_focus,
bg = beautiful.bg_focus
})
nextlim = getnextlim(battery)
end
elseif dir == 1 then
dirsign = "↑"
nextlim = limits[1][1]
else
dirsign = ""
end
if dir ~= 0 then battery = battery.."%" end
return " "..prefix.." "..dirsign..battery..dirsign.." "
end
end | gpl-3.0 |
anthrotype/sile | packages/converters.lua | 4 | 2468 | local lfs = require('lfs')
SILE.scratch.converters = {}
local register = function(sourceExt, targetExt, command)
table.insert(SILE.scratch.converters, {
sourceExt = sourceExt,
targetExt = targetExt,
command = command
})
end
local applyConverter = function(source, converter)
local extLen = string.len(converter.sourceExt)
local targetFile = string.sub(source, 1, -extLen-1) .. converter.targetExt
local sourceTime = lfs.attributes(source, "modification")
if (sourceTime==nil) then
SU.debug("converters", "Source file not found "..source)
return nil -- source not found
end
local targetTime = lfs.attributes(targetFile, "modification")
if((targetTime~=nil) and (targetTime>sourceTime)) then
SU.debug("converters", "Source file already converted "..source)
return targetFile -- already converted
end
command = string.gsub(converter.command, "%$(%w+)", {
SOURCE = source,
TARGET = targetFile
})
local result = os.execute(command)
if type(result) ~= "boolean" then result = (result == 0) end
if result then
SU.debug("converters", "Converted "..source.." to "..targetFile)
return targetFile
else
return nil
end
end
local checkConverters = function(source)
for _, converter in ipairs(SILE.scratch.converters) do
local extLen = string.len(converter.sourceExt)
if ((string.len(source) > extLen) and
(string.sub(source, -extLen) == converter.sourceExt)) then
return applyConverter(source, converter)
end
end
return source -- No conversion needed.
end
SILE.registerCommand("converters:register", function(o, c)
register(o.from, o.to, o.command)
end)
SILE.registerCommand("converters:check", function(o, c)
checkConverters(o.source)
end)
local function extendCommand(name, f)
-- Wrap an existing command
local original = SILE.Commands[name]
if(original) then
SILE.Commands[name] = function(options, content)
f(options, content, original)
end
else
SU.debug("converters", "Can not extend command "..name)
end
end
extendCommand("include", function(o, c, original)
local result = checkConverters(o.src)
if(result~=nil) then
o["src"] = result
original(o, c)
end
end)
extendCommand("img", function(o, c, original)
local result = checkConverters(o.src)
if(result~=nil) then
o["src"] = result
original(o, c)
end
end)
return {
exports = {
register= register,
check= checkConverters
}
}
| mit |
actboy168/MoeHero | scripts/maps/map_item/武器/星云苍斧.lua | 1 | 1297 |
--物品名称
local mt = ac.skill['星云苍斧']
--图标
mt.art = [[BTNattack6.blp]]
--说明
mt.tip = [[
%chance%%概率对%area%码范围的敌人释放幻雷。
这个效果每%cool%秒只能触发一次。
]]
--物品类型
mt.item_type = '武器'
--物品等级
mt.level = 4
--附魔价格
mt.gold = 1800
--物品唯一
mt.unique = true
mt.chance = 25
mt.area = 600
mt.cool = 3
mt.damage = 1.2
function mt:on_add()
local hero = self.owner
local area = self.area
local chance = self.chance
if hero:is_illusion() then
return
end
self.trg = hero:event '造成伤害效果' (function(trg, damage)
if self:is_cooling() then
return
end
if not damage:is_attack() then
return
end
if math.random(1, 100) > chance then
return
end
self:active_cd()
local g = ac.selector()
: in_range(damage.target, area)
: is_enemy(hero)
: get()
local count = #g
local damage = hero:get_ad() * self.damage * (0.9 + count / 10)
for _, u in ipairs(g) do
u:add_effect('chest', [[Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl]]):remove()
u:damage
{
source = hero,
damage = damage / count,
skill = self,
aoe = true,
attack = true,
}
end
end)
end
function mt:on_remove()
if self.trg then self.trg:remove() end
end
| gpl-3.0 |
CosyVerif/library | src/cosy/webclient/dashboard/init.lua | 1 | 2891 | return function (loader)
local I18n = loader.load "cosy.i18n"
local Webclient = loader.load "cosy.webclient"
local i18n = I18n.load {
"cosy.webclient.dashboard",
}
i18n._locale = Webclient.window.navigator.language
local Dashboard = {
template = {},
}
Dashboard.__index = Dashboard
Dashboard.template.anonymous = Webclient.template "cosy.webclient.dashboard.anonymous"
Dashboard.template.user = Webclient.template "cosy.webclient.dashboard.user"
local function show_map ()
Dashboard.map = Webclient.js.new (
Webclient.window.google.maps.Map,
Webclient.document:getElementById "map",
Webclient.tojs {
zoom = 1,
center = {
lat = 0,
lng = 0,
},
mapTypeId = Webclient.window.google.maps.MapTypeId.SATELLITE,
streetViewControl = false,
})
local iterator = Webclient.client.server.filter {
iterator = [[
return function (coroutine, store)
for user in store / "data" * ".*" do
coroutine.yield (user)
end
end
]],
}
for user in iterator do
Webclient.js.new (Webclient.window.google.maps.Marker, Webclient.tojs {
position = {
lat = user.position and user.position.latitude or 44.7328221,
lng = user.position and user.position.longitude or 4.5917742,
},
map = Dashboard.map,
draggable = false,
animation = Webclient.window.google.maps.Animation.DROP,
icon = user.avatar and "data:image/png;base64," .. user.avatar.icon or nil,
title = user.identifier,
})
end
end
function Dashboard.anonymous ()
Dashboard.map = nil
while true do
local info = Webclient.client.server.information {}
local data = {}
for k, v in pairs (info) do
local key = k:match "^#(.*)$"
if key then
data ["count-" .. key] = i18n ["dashboard:count-" .. key] % { count = v }
else
data [k] = v
end
end
Webclient.show {
where = "main",
template = Dashboard.template.anonymous,
data = data,
i18n = i18n,
}
if not Dashboard.map then
show_map ()
end
loader.scheduler.sleep (-math.huge)
end
end
function Dashboard.user ()
while true do
Webclient.show {
where = "main",
template = Dashboard.template.user,
data = {},
i18n = i18n,
}
loader.scheduler.sleep (-math.huge)
end
end
function Dashboard.__call ()
Webclient (function ()
local user = Webclient.client.user.authentified_as {}
if user.identifier then
Dashboard.user ()
else
Dashboard.anonymous ()
end
end)
end
return setmetatable ({}, Dashboard)
end
| mit |
amyvmiwei/skynet | lualib/mqueue.lua | 115 | 1798 | -- This is a deprecated module, use skynet.queue instead.
local skynet = require "skynet"
local c = require "skynet.core"
local mqueue = {}
local init_once
local thread_id
local message_queue = {}
skynet.register_protocol {
name = "queue",
-- please read skynet.h for magic number 8
id = 8,
pack = skynet.pack,
unpack = skynet.unpack,
dispatch = function(session, from, ...)
table.insert(message_queue, {session = session, addr = from, ... })
if thread_id then
skynet.wakeup(thread_id)
thread_id = nil
end
end
}
local function do_func(f, msg)
return pcall(f, table.unpack(msg))
end
local function message_dispatch(f)
while true do
if #message_queue==0 then
thread_id = coroutine.running()
skynet.wait()
else
local msg = table.remove(message_queue,1)
local session = msg.session
if session == 0 then
local ok, msg = do_func(f, msg)
if ok then
if msg then
skynet.fork(message_dispatch,f)
error(string.format("[:%x] send a message to [:%x] return something", msg.addr, skynet.self()))
end
else
skynet.fork(message_dispatch,f)
error(string.format("[:%x] send a message to [:%x] throw an error : %s", msg.addr, skynet.self(),msg))
end
else
local data, size = skynet.pack(do_func(f,msg))
-- 1 means response
c.send(msg.addr, 1, session, data, size)
end
end
end
end
function mqueue.register(f)
assert(init_once == nil)
init_once = true
skynet.fork(message_dispatch,f)
end
local function catch(succ, ...)
if succ then
return ...
else
error(...)
end
end
function mqueue.call(addr, ...)
return catch(skynet.call(addr, "queue", ...))
end
function mqueue.send(addr, ...)
return skynet.send(addr, "queue", ...)
end
function mqueue.size()
return #message_queue
end
return mqueue
| mit |
xiaq/luarocks | src/luarocks/fetch/hg.lua | 14 | 2144 |
--- Fetch back-end for retrieving sources from HG.
--module("luarocks.fetch.hg", package.seeall)
local hg = {}
local unpack = unpack or table.unpack
local fs = require("luarocks.fs")
local dir = require("luarocks.dir")
local util = require("luarocks.util")
--- Download sources for building a rock, using hg.
-- @param rockspec table: The rockspec table
-- @param extract boolean: Unused in this module (required for API purposes.)
-- @param dest_dir string or nil: If set, will extract to the given directory.
-- @return (string, string) or (nil, string): The absolute pathname of
-- the fetched source tarball and the temporary directory created to
-- store it; or nil and an error message.
function hg.get_sources(rockspec, extract, dest_dir)
assert(type(rockspec) == "table")
assert(type(dest_dir) == "string" or not dest_dir)
local hg_cmd = rockspec.variables.HG
local ok, err_msg = fs.is_tool_available(hg_cmd, "Mercurial")
if not ok then
return nil, err_msg
end
local name_version = rockspec.name .. "-" .. rockspec.version
-- Strip off special hg:// protocol type
local url = rockspec.source.url:gsub("^hg://", "")
local module = dir.base_name(url)
local command = {hg_cmd, "clone", url, module}
local tag_or_branch = rockspec.source.tag or rockspec.source.branch
if tag_or_branch then
command = {hg_cmd, "clone", "--rev", tag_or_branch, url, module}
end
local store_dir
if not dest_dir then
store_dir = fs.make_temp_dir(name_version)
if not store_dir then
return nil, "Failed creating temporary directory."
end
util.schedule_function(fs.delete, store_dir)
else
store_dir = dest_dir
end
local ok, err = fs.change_dir(store_dir)
if not ok then return nil, err end
if not fs.execute(unpack(command)) then
return nil, "Failed cloning hg repository."
end
ok, err = fs.change_dir(module)
if not ok then return nil, err end
fs.delete(dir.path(store_dir, module, ".hg"))
fs.delete(dir.path(store_dir, module, ".hgignore"))
fs.pop_dir()
fs.pop_dir()
return module, store_dir
end
return hg
| mit |
zynjec/darkstar | scripts/zones/Quicksand_Caves/npcs/Fountain_of_Kings.lua | 9 | 1187 | -----------------------------------
-- Area: Quicksand Caves
-- NPC: Fountain of Kings
-- !pos 567 18 -939 208
-----------------------------------
local ID = require("scripts/zones/Quicksand_Caves/IDs");
require("scripts/globals/missions");
require("scripts/globals/keyitems");
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
if (player:getCurrentMission(SANDORIA) == dsp.mission.id.sandoria.COMING_OF_AGE and player:getCharVar("MissionStatus") == 2
and not GetMobByID(ID.mob.VALOR):isSpawned() and not GetMobByID(ID.mob.HONOR):isSpawned()) then
SpawnMob(ID.mob.VALOR);
SpawnMob(ID.mob.HONOR);
elseif (player:getCurrentMission(SANDORIA) == dsp.mission.id.sandoria.COMING_OF_AGE and player:getCharVar("MissionStatus") == 3
and not GetMobByID(ID.mob.VALOR):isSpawned() and not GetMobByID(ID.mob.HONOR):isSpawned()) then
player:addKeyItem(dsp.ki.DROPS_OF_AMNIO);
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.DROPS_OF_AMNIO);
else
player:messageSpecial(ID.text.POOL_OF_WATER);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
end;
| gpl-3.0 |
pando85/telegram-bot | plugins/rae.lua | 616 | 1312 | do
function getDulcinea( text )
-- Powered by https://github.com/javierhonduco/dulcinea
local api = "http://dulcinea.herokuapp.com/api/?query="
local query_url = api..text
local b, code = http.request(query_url)
if code ~= 200 then
return "Error: HTTP Connection"
end
dulcinea = json:decode(b)
if dulcinea.status == "error" then
return "Error: " .. dulcinea.message
end
while dulcinea.type == "multiple" do
text = dulcinea.response[1].id
b = http.request(api..text)
dulcinea = json:decode(b)
end
local text = ""
local responses = #dulcinea.response
if responses == 0 then
return "Error: 404 word not found"
end
if (responses > 5) then
responses = 5
end
for i = 1, responses, 1 do
text = text .. dulcinea.response[i].word .. "\n"
local meanings = #dulcinea.response[i].meanings
if (meanings > 5) then
meanings = 5
end
for j = 1, meanings, 1 do
local meaning = dulcinea.response[i].meanings[j].meaning
text = text .. meaning .. "\n\n"
end
end
return text
end
function run(msg, matches)
return getDulcinea(matches[1])
end
return {
description = "Spanish dictionary",
usage = "!rae [word]: Search that word in Spanish dictionary.",
patterns = {"^!rae (.*)$"},
run = run
}
end | gpl-2.0 |
hossein5251/hossein5251bot | plugins/rae.lua | 616 | 1312 | do
function getDulcinea( text )
-- Powered by https://github.com/javierhonduco/dulcinea
local api = "http://dulcinea.herokuapp.com/api/?query="
local query_url = api..text
local b, code = http.request(query_url)
if code ~= 200 then
return "Error: HTTP Connection"
end
dulcinea = json:decode(b)
if dulcinea.status == "error" then
return "Error: " .. dulcinea.message
end
while dulcinea.type == "multiple" do
text = dulcinea.response[1].id
b = http.request(api..text)
dulcinea = json:decode(b)
end
local text = ""
local responses = #dulcinea.response
if responses == 0 then
return "Error: 404 word not found"
end
if (responses > 5) then
responses = 5
end
for i = 1, responses, 1 do
text = text .. dulcinea.response[i].word .. "\n"
local meanings = #dulcinea.response[i].meanings
if (meanings > 5) then
meanings = 5
end
for j = 1, meanings, 1 do
local meaning = dulcinea.response[i].meanings[j].meaning
text = text .. meaning .. "\n\n"
end
end
return text
end
function run(msg, matches)
return getDulcinea(matches[1])
end
return {
description = "Spanish dictionary",
usage = "!rae [word]: Search that word in Spanish dictionary.",
patterns = {"^!rae (.*)$"},
run = run
}
end | gpl-2.0 |
darklost/quick-ng | cocos/scripting/lua-bindings/auto/api/FiniteTimeAction.lua | 18 | 1071 |
--------------------------------
-- @module FiniteTimeAction
-- @extend Action
-- @parent_module cc
--------------------------------
-- Set duration in seconds of the action. <br>
-- param duration In seconds of the action.
-- @function [parent=#FiniteTimeAction] setDuration
-- @param self
-- @param #float duration
-- @return FiniteTimeAction#FiniteTimeAction self (return value: cc.FiniteTimeAction)
--------------------------------
-- Get duration in seconds of the action. <br>
-- return The duration in seconds of the action.
-- @function [parent=#FiniteTimeAction] getDuration
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
--
-- @function [parent=#FiniteTimeAction] clone
-- @param self
-- @return FiniteTimeAction#FiniteTimeAction ret (return value: cc.FiniteTimeAction)
--------------------------------
--
-- @function [parent=#FiniteTimeAction] reverse
-- @param self
-- @return FiniteTimeAction#FiniteTimeAction ret (return value: cc.FiniteTimeAction)
return nil
| mit |
Vadavim/jsr-darkstar | scripts/zones/AlTaieu/npcs/_0x0.lua | 14 | 2215 | -----------------------------------
-- Area: Al'Taieu
-- NPC: Crystalline Field
-- @pos .1 -10 -464 33
-----------------------------------
package.loaded["scripts/zones/AlTaieu/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/AlTaieu/TextIDs");
require("scripts/globals/missions");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
-- Set the PromathiaStatus to 3 if they did all 3 towers for GARDEN_OF_ANTIQUITY
if (player:getVar("[SEA][AlTieu]SouthTowerCS") == 1 and player:getVar("[SEA][AlTieu]WestTowerCS") == 1 and player:getVar("[SEA][AlTieu]EastTowerCS") == 1 and player:getVar("PromathiaStatus") == 2) then
player:setVar("[SEA][AlTieu]SouthTowerCS", 0);
player:setVar("[SEA][AlTieu]WestTowerCS", 0);
player:setVar("[SEA][AlTieu]EastTowerCS", 0);
player:setVar("PromathiaStatus", 3);
end
if (player:getCurrentMission(COP) == GARDEN_OF_ANTIQUITY and player:getVar("PromathiaStatus") == 1) then
player:startEvent(0x00A4);
elseif (player:getCurrentMission(COP) > GARDEN_OF_ANTIQUITY or (player:getCurrentMission(COP) == GARDEN_OF_ANTIQUITY and player:getVar("PromathiaStatus") == 3)) then
player:startEvent(0x0064); -- Teleport inside
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY); -- Access should be restricted if below requirements. Message is probably wrong, though.
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 == 0x0064 and option == 1) then
player:setPos(-20,0.624,-355,191,34); -- {R}
elseif (csid == 0x00A4) then
player:setVar("PromathiaStatus", 2);
end
end; | gpl-3.0 |
dkogan/notion-scripts | scripts/named_scratchpad.lua | 2 | 1398 | --[[
Author: Etan Reisner
Email: deryni@gmail.com
Summary: Toggle (and create) scratchpads by name.
Version: 0.2
Last Updated: 2007-01-23
Copyright (c) Etan Reisner 2007
This software is released under the terms of the MIT license. For more
information, see http://opensource.org/licenses/mit-license.php .
--]]
-- Usage: This will create a scratchpad named example_sp
-- kpress(MOD4.."space", "named_scratchpad(_, 'example_sp')")
function named_scratchpad(reg, name)
local named_sp
local default_w, default_h = 640, 480
local scr = reg:screen_of()
local geom_scr = scr:geom()
local geom_loc = {
w = math.min(geom_scr.w, default_w),
h = math.min(geom_scr.h, default_h),
}
geom_loc.x = (geom_scr.w - geom_loc.w) / 2
geom_loc.y = (geom_scr.h - geom_loc.h) / 2
named_sp = ioncore.lookup_region(name, "WFrame")
if not named_sp then
named_sp = scr:attach_new({
type="WFrame",
name=name,
unnumbered=true,
modal=true,
hidden=true,
sizepolicy=5,
geom=geom_loc,
})
end
mod_sp.set_shown(named_sp, "toggle")
end
-- vim: set expandtab sw=4:
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Wajaom_Woodlands/npcs/Watisa.lua | 32 | 1643 | -----------------------------------
-- Area: Wajaom Woodlands
-- NPC: Watisa
-- Type: Chocobo Renter
-- @pos -201 -11 93 51
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/keyitems");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local level = player:getMainLvl();
local gil = player:getGil();
if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 20) then
local price = getChocoboPrice(player);
player:setLocalVar("chocoboPriceOffer",price);
player:startEvent(0x0009,price,gil);
else
player:startEvent(0x000a);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
local price = player:getLocalVar("chocoboPriceOffer");
if (csid == 0x0009 and option == 0) then
if (player:delGil(price)) then
updateChocoboPrice(player, price);
local duration = 1800 + (player:getMod(MOD_CHOCOBO_RIDING_TIME) * 60)
player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,duration,true);
end
end
end; | gpl-3.0 |
zynjec/darkstar | scripts/zones/The_Garden_of_RuHmet/npcs/_0z0.lua | 9 | 1306 | -----------------------------------
-- Area: The_Garden_of_RuHmet
-- NPC: _0z0
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/missions");
require("scripts/globals/keyitems");
require("scripts/globals/bcnm");
function onTrade(player,npc,trade)
if (TradeBCNM(player,npc,trade)) then
return;
end
end;
function onTrigger(player,npc)
--player:addMission(COP, dsp.mission.id.cop.WHEN_ANGELS_FALL);
--player:setCharVar("PromathiaStatus",3);
if (player:getCurrentMission(COP) == dsp.mission.id.cop.WHEN_ANGELS_FALL and player:getCharVar("PromathiaStatus")==3) then
player:startEvent(203);
elseif (EventTriggerBCNM(player,npc)) then
elseif (player:getCurrentMission(COP) == dsp.mission.id.cop.WHEN_ANGELS_FALL and player:getCharVar("PromathiaStatus")==5) then
player:startEvent(205);
end
return 1;
end;
function onEventUpdate(player,csid,option,extras)
EventUpdateBCNM(player,csid,option,extras);
end;
function onEventFinish(player,csid,option)
-- printf("onFinish CSID: %u",csid);
-- printf("onFinish RESULT: %u",option);
if ( csid == 203) then
player:setCharVar("PromathiaStatus",4);
elseif (EventFinishBCNM(player,csid,option)) then
return;
end
end
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/The_Eldieme_Necropolis/npcs/_5fk.lua | 13 | 1076 | -----------------------------------
-- Area: The Eldieme Necropolis
-- NPC: Titan's Gate
-- @pos 100 -34 88 195
-----------------------------------
package.loaded["scripts/zones/The_Eldieme_Necropolis/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/The_Eldieme_Necropolis/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (npc:getAnimation() == 9) then
player:messageSpecial(SOLID_STONE);
end
return 0;
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/Bastok_Markets/npcs/Ciqala.lua | 12 | 1058 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Ciqala
-- Type: Merchant
-- !pos -283.147 -11.319 -143.680 235
-----------------------------------
local ID = require("scripts/zones/Bastok_Markets/IDs")
require("scripts/globals/shop")
function onTrigger(player,npc)
local stock =
{
16392, 4818, 1, -- Metal Knuckles
17044, 6033, 1, -- Warhammer
16390, 224, 3, -- Bronze Knuckles
16391, 828, 3, -- Brass Knuckles
16385, 129, 3, -- Cesti
16407, 1521, 3, -- Brass Baghnakhs
16405, 104, 3, -- Cat Baghnakhs
17042, 312, 3, -- Bronze Hammer
17043, 2083, 3, -- Brass Hammer
17049, 47, 3, -- Maple Wand
17024, 66, 3, -- Ash Club
17059, 90, 3, -- Bronze Rod
17081, 621, 3, -- Brass Rod
17088, 57, 3, -- Ash Staff
17095, 386, 3, -- Ash Pole
}
player:showText(npc, ID.text.CIQALA_SHOP_DIALOG)
dsp.shop.nation(player, stock, dsp.nation.BASTOK)
end
| gpl-3.0 |
hfjgjfg/core2000 | plugins/stats.lua | 866 | 4001 | do
-- Returns a table with `name` and `msgs`
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..chat_id,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false)
return --text
end
local function chat_stats2(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == 'teleseed' then -- Put everything you like :)
local about = _config.about_text
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /teleseed ")
return about
end
if matches[1]:lower() == "statslist" then
if not is_momod(msg) then
return "For mods only !"
end
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats2(chat_id)
end
if matches[1]:lower() == "stats" then
if not matches[2] then
if not is_momod(msg) then
return "For mods only !"
end
if msg.to.type == 'chat' then
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats(chat_id)
else
return
end
end
if matches[2] == "teleseed" then -- Put everything you like :)
if not is_admin(msg) then
return "For admins only !"
else
return bot_stats()
end
end
if matches[2] == "group" then
if not is_admin(msg) then
return "For admins only !"
else
return chat_stats(matches[3])
end
end
end
end
return {
patterns = {
"^[!/]([Ss]tats)$",
"^[!/]([Ss]tatslist)$",
"^[!/]([Ss]tats) (group) (%d+)",
"^[!/]([Ss]tats) (teleseed)",-- Put everything you like :)
"^[!/]([Tt]eleseed)"-- Put everything you like :)
},
run = run
}
end
| gpl-2.0 |
mahdimohbi/xyxy | plugins/stats.lua | 866 | 4001 | do
-- Returns a table with `name` and `msgs`
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..chat_id,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false)
return --text
end
local function chat_stats2(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == 'teleseed' then -- Put everything you like :)
local about = _config.about_text
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /teleseed ")
return about
end
if matches[1]:lower() == "statslist" then
if not is_momod(msg) then
return "For mods only !"
end
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats2(chat_id)
end
if matches[1]:lower() == "stats" then
if not matches[2] then
if not is_momod(msg) then
return "For mods only !"
end
if msg.to.type == 'chat' then
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats(chat_id)
else
return
end
end
if matches[2] == "teleseed" then -- Put everything you like :)
if not is_admin(msg) then
return "For admins only !"
else
return bot_stats()
end
end
if matches[2] == "group" then
if not is_admin(msg) then
return "For admins only !"
else
return chat_stats(matches[3])
end
end
end
end
return {
patterns = {
"^[!/]([Ss]tats)$",
"^[!/]([Ss]tatslist)$",
"^[!/]([Ss]tats) (group) (%d+)",
"^[!/]([Ss]tats) (teleseed)",-- Put everything you like :)
"^[!/]([Tt]eleseed)"-- Put everything you like :)
},
run = run
}
end
| gpl-2.0 |
mahdibagheri/TeleSeed | plugins/stats.lua | 866 | 4001 | do
-- Returns a table with `name` and `msgs`
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..chat_id,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false)
return --text
end
local function chat_stats2(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == 'teleseed' then -- Put everything you like :)
local about = _config.about_text
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /teleseed ")
return about
end
if matches[1]:lower() == "statslist" then
if not is_momod(msg) then
return "For mods only !"
end
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats2(chat_id)
end
if matches[1]:lower() == "stats" then
if not matches[2] then
if not is_momod(msg) then
return "For mods only !"
end
if msg.to.type == 'chat' then
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats(chat_id)
else
return
end
end
if matches[2] == "teleseed" then -- Put everything you like :)
if not is_admin(msg) then
return "For admins only !"
else
return bot_stats()
end
end
if matches[2] == "group" then
if not is_admin(msg) then
return "For admins only !"
else
return chat_stats(matches[3])
end
end
end
end
return {
patterns = {
"^[!/]([Ss]tats)$",
"^[!/]([Ss]tatslist)$",
"^[!/]([Ss]tats) (group) (%d+)",
"^[!/]([Ss]tats) (teleseed)",-- Put everything you like :)
"^[!/]([Tt]eleseed)"-- Put everything you like :)
},
run = run
}
end
| gpl-2.0 |
Vadavim/jsr-darkstar | scripts/zones/South_Gustaberg/npcs/qm2.lua | 27 | 2839 | -----------------------------------
-- Area: South Gustaberg
-- NPC: ???
-- Involved in Quest: Smoke on the Mountain
-- @pos 461 -21 -580 107
-----------------------------------
package.loaded["scripts/zones/South_Gustaberg/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/South_Gustaberg/TextIDs");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:needToZone() == false) then
player:setVar("SGusta_Sausage_Timer", 0);
end
local SmokeOnTheMountain = player:getQuestStatus(BASTOK,SMOKE_ON_THE_MOUNTAIN);
if (SmokeOnTheMountain == QUEST_ACCEPTED) then
if (trade:hasItemQty(4372,1) and trade:getItemCount() == 1) then
if (player:getVar("SGusta_Sausage_Timer") == 0) then
-- player puts sheep meat on the fire
player:messageSpecial(FIRE_PUT, 4372);
player:tradeComplete();
player:setVar("SGusta_Sausage_Timer", os.time() + 3456); -- 57 minutes 36 seconds, 1 Vana'diel Day
player:needToZone(true);
else
-- message given if sheep meat is already on the fire
player:messageSpecial(MEAT_ALREADY_PUT, 4372)
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:needToZone() == false) then
player:setVar("SGusta_Sausage_Timer", 0);
end
local SmokeOnTheMountain = player:getQuestStatus(BASTOK,SMOKE_ON_THE_MOUNTAIN);
local sausageTimer = player:getVar("SGusta_Sausage_Timer");
if (SmokeOnTheMountain ~= QUEST_AVAILABLE and sausageTimer ~= 0) then
if (sausageTimer >= os.time()) then
player:messageSpecial(FIRE_LONGER, 4372);
elseif (player:getFreeSlotsCount() < 1) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED, 4395);
elseif (sausageTimer < os.time()) then
player:setVar("SGusta_Sausage_Timer", 0);
player:messageSpecial(FIRE_TAKE, 4395);
player:addItem(4395);
end
elseif (SmokeOnTheMountain ~= QUEST_AVAILABLE and sausageTimer == 0) then
player:messageSpecial(FIRE_GOOD);
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 |
jrgdiz/NewtonsRevenge | advtiledloader/Tile.lua | 3 | 2502 | ---------------------------------------------------------------------------------------------------
-- -= Tile =-
---------------------------------------------------------------------------------------------------
-- Setup
local assert = assert
local Tile = {}
Tile.__index = Tile
-- Creates a new tile and returns it.
function Tile:new(id, tileset, quad, width, height, prop)
assert( id and tileset and quad, "Tile:new - Needs at least 3 parameters for id, tileset and quad.")
local tmp = {}
tmp.id = id -- The id of the tile
tmp.tileset = tileset -- The tileset this tile belongs to
tmp.quad = quad -- The of the tileset that defines the tile
tmp.width = width or 0 -- The width of the tile in pixels
tmp.height = height or 0 -- The height of the tile in pixels
tmp.properties = prop or {} -- The properties of the tile set in Tiled
return setmetatable(tmp, Tile)
end
-- Draws the tile at the given location
function Tile:draw(x, y, rotation, scaleX, scaleY, offsetX, offsetY)
love.graphics.drawq(self.tileset.image, self.quad, self.tileset.tileoffset.x + x,
self.tileset.tileoffset.y + y, rotation, scaleX, scaleY, offsetX, offsetY)
end
-- Return the Tile class
return Tile
--[[Copyright (c) 2011 Casey Baxter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.--]] | mit |
anthrotype/sile | lua-libraries/repl/plugins/autoreturn.lua | 7 | 1364 | -- Copyright (c) 2011-2014 Rob Hoelz <rob@hoelz.ro>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
-- this software and associated documentation files (the "Software"), to deal in
-- the Software without restriction, including without limitation the rights to
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-- the Software, and to permit persons to whom the Software is furnished to do so,
-- subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-- A plugin that causes the REPL to automatically return evaluation results
function around:compilechunk(orig, chunk)
local f, err = orig(self, 'return ' .. chunk)
if not f then
f, err = orig(self, chunk)
end
return f, err
end
| mit |
Colettechan/darkstar | scripts/zones/West_Sarutabaruta/npcs/Darumomo_WW.lua | 13 | 3341 | -----------------------------------
-- Area: West Sarutabaruta
-- NPC: Darumomo, W.W.
-- Type: Border Conquest Guards
-- @pos 399.450 -25.858 727.545 115
-----------------------------------
package.loaded["scripts/zones/West_Sarutabaruta/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/West_Sarutabaruta/TextIDs");
local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = SARUTABARUTA;
local csid = 0x7ff6;
-----------------------------------
-- 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 |
sumory/lor | lib/lor/lib/router/group.lua | 2 | 4055 | local setmetatable = setmetatable
local pairs = pairs
local type = type
local error = error
local next = next
local string_format = string.format
local string_lower = string.lower
local table_insert = table.insert
local unpack = table.unpack or unpack
local supported_http_methods = require("lor.lib.methods")
local debug = require("lor.lib.debug")
local utils = require("lor.lib.utils.utils")
local random = utils.random
local clone = utils.clone
local handler_error_tip = "handler must be `function` that matches `function(req, res, next) ... end`"
local Group = {}
function Group:new()
local group = {}
group.id = random()
group.name = "group-" .. group.id
group.is_group = true
group.apis = {}
self:build_method()
setmetatable(group, {
__index = self,
__call = self._call,
__tostring = function(s)
return s.name
end
})
return group
end
--- a magick for usage like `lor:Router()`
-- generate a new group for different routes group
function Group:_call()
local cloned = clone(self)
cloned.id = random()
cloned.name = cloned.name .. ":clone-" .. cloned.id
return cloned
end
function Group:get_apis()
return self.apis
end
function Group:set_api(path, method, ...)
if not path or not method then
return error("`path` & `method` should not be nil.")
end
local handlers = {...}
if not next(handlers) then
return error("handler should not be nil or empty")
end
if type(path) ~= "string" or type(method) ~= "string" or type(handlers) ~= "table" then
return error("params type error.")
end
local extended_handlers = {}
for _, h in ipairs(handlers) do
if type(h) == "function" then
table_insert(extended_handlers, h)
elseif type(h) == "table" then
for _, hh in ipairs(h) do
if type(hh) == "function" then
table_insert(extended_handlers, hh)
else
error(handler_error_tip)
end
end
else
error(handler_error_tip)
end
end
method = string_lower(method)
if not supported_http_methods[method] then
return error(string_format("[%s] method is not supported yet.", method))
end
self.apis[path] = self.apis[path] or {}
self.apis[path][method] = extended_handlers
end
function Group:build_method()
for m, _ in pairs(supported_http_methods) do
m = string_lower(m)
-- 1. group_router:get(func1)
-- 2. group_router:get(func1, func2)
-- 3. group_router:get({func1, func2})
-- 4. group_router:get(path, func1)
-- 5. group_router:get(path, func1, func2)
-- 6. group_router:get(path, {func1, func2})
Group[m] = function(myself, ...)
local params = {...}
if not next(params) then return error("params should not be nil or empty") end
-- case 1 or 3
if #params == 1 then
if type(params[1]) ~= "function" and type(params[1]) ~= "table" then
return error("it must be an function if there's only one param")
end
if type(params[1]) == "table" and #(params[1]) == 0 then
return error("params should not be nil or empty")
end
return Group.set_api(myself, "", m, ...)
end
-- case 2,4,5,6
if #params > 1 then
if type(params[1]) == "string" then -- case 4,5,6
return Group.set_api(myself, params[1], m, unpack(params, 2))
else -- case 2
return Group.set_api(myself, "", m, ...)
end
end
error("error params for group route define")
end
end
end
function Group:clone()
local cloned = clone(self)
cloned.id = random()
cloned.name = cloned.name .. ":clone-" .. cloned.id
return cloned
end
return Group
| mit |
zynjec/darkstar | scripts/globals/items/shrimp_cracker_+1.lua | 11 | 1189 | -----------------------------------------
-- ID: 5636
-- Item: shrimp_cracker_+1
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Vitality 2
-- Defense +10
-- Amorph Killer 12
-- Resist Virus 12
-- HP Recovered While Healing 9
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,300,5636)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.VIT, 2)
target:addMod(dsp.mod.DEF, 10)
target:addMod(dsp.mod.AMORPH_KILLER, 12)
target:addMod(dsp.mod.VIRUSRES, 12)
target:addMod(dsp.mod.HPHEAL, 9)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.VIT, 2)
target:delMod(dsp.mod.DEF, 10)
target:delMod(dsp.mod.AMORPH_KILLER, 12)
target:delMod(dsp.mod.VIRUSRES, 12)
target:delMod(dsp.mod.HPHEAL, 9)
end
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Port_Bastok/npcs/Sawyer.lua | 17 | 1551 | -----------------------------------
-- Area: Port Bastok
-- NPC: Sawyer
-- Standard Merchant NPC
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
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)
player:showText(npc,SAWYER_SHOP_DIALOG);
stock = {
0x11EF, 147,1, --Pumpernickel
0x1141, 3036,1, --Egg Soup
0x115A, 368,1, --Pineapple Juice
0x1127, 22,2, --Bretzel
0x11E2, 143,2, --Sausage
0x1148, 1012,2, --Melon Juice
0x1155, 662,2, --Roast Mutton
0x1193, 92,3, --Iron Bread
0x1154, 294,3, --Baked Popoto
0x1167, 184,3, --Pebble Soup
0x119D, 10,3 --Distilled Water
}
showNationShop(player, BASTOK, 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/zones/Abyssea-Altepa/Zone.lua | 33 | 1470 | -----------------------------------
--
-- Zone: Abyssea - Altepa
--
-----------------------------------
package.loaded["scripts/zones/Abyssea-Altepa/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Abyssea-Altepa/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(435 ,0 ,320 ,136)
end
if (player:getQuestStatus(ABYSSEA, THE_TRUTH_BECKONS) == QUEST_ACCEPTED
and player:getVar("1stTimeAyssea") == 0) then
player:setVar("1stTimeAyssea",1);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
actboy168/MoeHero | scripts/maps/hero/夜刀神十香/init.lua | 1 | 1149 | require 'maps.hero.夜刀神十香.暴虐斩'
require 'maps.hero.夜刀神十香.暴虐舞'
require 'maps.hero.夜刀神十香.空间震'
require 'maps.hero.夜刀神十香.终焉之剑'
return ac.hero.create '夜刀神十香'
{
--物编中的id
id = 'H011',
production = '约会大作战',
model_source = 'U9模型区',
hero_designer = 'actboy168',
hero_scripter = 'actboy168',
show_animation = { 'spell one', 'spell two', 'spell three' },
--技能数量
skill_count = 4,
skill_names = '暴虐斩 暴虐舞 空间震 终焉之剑',
attribute = {
['生命上限'] = 1040,
['魔法上限'] = 200,
['生命恢复'] = 4,
['魔法恢复'] = -1,
['魔法脱战恢复'] = -9,
['攻击'] = 35,
['护甲'] = 13,
['移动速度'] = 300,
['攻击间隔'] = 1.1,
['攻击范围'] = 128,
},
upgrade = {
['生命上限'] = 130,
['魔法上限'] = 0,
['生命恢复'] = 0.25,
['魔法恢复'] = 0,
['攻击'] = 3.1,
['护甲'] = 1.3,
},
weapon = {
},
resource_type = '怒气',
--触发系数
proc = 1,
difficulty = 2,
--选取半径
selected_radius = 32,
--妹子
yuri = true,
}
| gpl-3.0 |
lcf8858/Sample_Lua | frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/Label.lua | 10 | 12761 |
--------------------------------
-- @module Label
-- @extend SpriteBatchNode,LabelProtocol
-- @parent_module cc
--------------------------------
--
-- @function [parent=#Label] isClipMarginEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Enable shadow for the label<br>
-- todo support blur for shadow effect
-- @function [parent=#Label] enableShadow
-- @param self
--------------------------------
-- Sets the untransformed size of the label in a more efficient way.
-- @function [parent=#Label] setDimensions
-- @param self
-- @param #unsigned int width
-- @param #unsigned int height
--------------------------------
--
-- @function [parent=#Label] getString
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#Label] getHeight
-- @param self
-- @return unsigned int#unsigned int ret (return value: unsigned int)
--------------------------------
-- disable shadow/outline/glow rendering
-- @function [parent=#Label] disableEffect
-- @param self
--------------------------------
-- set TTF configuration for Label
-- @function [parent=#Label] setTTFConfig
-- @param self
-- @param #cc._ttfConfig ttfConfig
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Returns the text color of this label<br>
-- Only support for TTF and system font<br>
-- warning Different from the color of Node.
-- @function [parent=#Label] getTextColor
-- @param self
-- @return color4b_table#color4b_table ret (return value: color4b_table)
--------------------------------
-- Sets the untransformed size of the label.<br>
-- The label's width be used for text align if the set value not equal zero.<br>
-- The label's max line width will be equal to the same value.
-- @function [parent=#Label] setWidth
-- @param self
-- @param #unsigned int width
--------------------------------
--
-- @function [parent=#Label] getMaxLineWidth
-- @param self
-- @return unsigned int#unsigned int ret (return value: unsigned int)
--------------------------------
--
-- @function [parent=#Label] getHorizontalAlignment
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- clip upper and lower margin for reduce height of label.
-- @function [parent=#Label] setClipMarginEnabled
-- @param self
-- @param #bool clipEnabled
--------------------------------
-- changes the string to render<br>
-- warning It is as expensive as changing the string if you haven't set up TTF/BMFont/CharMap for the label.
-- @function [parent=#Label] setString
-- @param self
-- @param #string text
--------------------------------
--
-- @function [parent=#Label] setSystemFontName
-- @param self
-- @param #string systemFont
--------------------------------
--
-- @function [parent=#Label] setBMFontFilePath
-- @param self
-- @param #string bmfontFilePath
-- @param #vec2_table imageOffset
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#Label] getFontAtlas
-- @param self
-- @return FontAtlas#FontAtlas ret (return value: cc.FontAtlas)
--------------------------------
-- Sets the line height of the label<br>
-- warning Not support system font<br>
-- since v3.2.0
-- @function [parent=#Label] setLineHeight
-- @param self
-- @param #float height
--------------------------------
--
-- @function [parent=#Label] setSystemFontSize
-- @param self
-- @param #float fontSize
--------------------------------
-- update content immediately.
-- @function [parent=#Label] updateContent
-- @param self
--------------------------------
--
-- @function [parent=#Label] getStringLength
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
--
-- @function [parent=#Label] setLineBreakWithoutSpace
-- @param self
-- @param #bool breakWithoutSpace
--------------------------------
--
-- @function [parent=#Label] getStringNumLines
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- only support for TTF
-- @function [parent=#Label] enableOutline
-- @param self
-- @param #color4b_table outlineColor
-- @param #int outlineSize
--------------------------------
-- Returns the additional kerning of this label<br>
-- warning Not support system font<br>
-- since v3.2.0
-- @function [parent=#Label] getAdditionalKerning
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @overload self, cc.Texture2D, int, int, int
-- @overload self, string, int, int, int
-- @overload self, string
-- @function [parent=#Label] setCharMap
-- @param self
-- @param #string charMapFile
-- @param #int itemWidth
-- @param #int itemHeight
-- @param #int startCharMap
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#Label] getDimensions
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- Sets the max line width of the label.<br>
-- The label's max line width be used for force line breaks if the set value not equal zero.<br>
-- The label's width and max line width has not always to be equal.
-- @function [parent=#Label] setMaxLineWidth
-- @param self
-- @param #unsigned int maxLineWidth
--------------------------------
--
-- @function [parent=#Label] getSystemFontName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#Label] setVerticalAlignment
-- @param self
-- @param #int vAlignment
--------------------------------
-- Returns the line height of this label<br>
-- warning Not support system font
-- @function [parent=#Label] getLineHeight
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
--
-- @function [parent=#Label] getTTFConfig
-- @param self
-- @return _ttfConfig#_ttfConfig ret (return value: cc._ttfConfig)
--------------------------------
--
-- @function [parent=#Label] getVerticalAlignment
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Sets the text color of the label<br>
-- Only support for TTF and system font<br>
-- warning Different from the color of Node.
-- @function [parent=#Label] setTextColor
-- @param self
-- @param #color4b_table color
--------------------------------
-- Sets the untransformed size of the label.<br>
-- The label's height be used for text align if the set value not equal zero.<br>
-- The text will display of incomplete when the size of label not enough to support display all text.
-- @function [parent=#Label] setHeight
-- @param self
-- @param #unsigned int height
--------------------------------
--
-- @function [parent=#Label] getWidth
-- @param self
-- @return unsigned int#unsigned int ret (return value: unsigned int)
--------------------------------
-- only support for TTF
-- @function [parent=#Label] enableGlow
-- @param self
-- @param #color4b_table glowColor
--------------------------------
--
-- @function [parent=#Label] getLetter
-- @param self
-- @param #int lettetIndex
-- @return Sprite#Sprite ret (return value: cc.Sprite)
--------------------------------
-- Sets the additional kerning of the label<br>
-- warning Not support system font<br>
-- since v3.2.0
-- @function [parent=#Label] setAdditionalKerning
-- @param self
-- @param #float space
--------------------------------
--
-- @function [parent=#Label] getSystemFontSize
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
--
-- @function [parent=#Label] getTextAlignment
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
--
-- @function [parent=#Label] getBMFontFilePath
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#Label] setHorizontalAlignment
-- @param self
-- @param #int hAlignment
--------------------------------
-- @overload self, int, int
-- @overload self, int
-- @function [parent=#Label] setAlignment
-- @param self
-- @param #int hAlignment
-- @param #int vAlignment
--------------------------------
--
-- @function [parent=#Label] requestSystemFontRefresh
-- @param self
--------------------------------
--
-- @function [parent=#Label] createWithBMFont
-- @param self
-- @param #string bmfontFilePath
-- @param #string text
-- @param #int alignment
-- @param #int maxLineWidth
-- @param #vec2_table imageOffset
-- @return Label#Label ret (return value: cc.Label)
--------------------------------
--
-- @function [parent=#Label] create
-- @param self
-- @return Label#Label ret (return value: cc.Label)
--------------------------------
-- @overload self, cc.Texture2D, int, int, int
-- @overload self, string, int, int, int
-- @overload self, string
-- @function [parent=#Label] createWithCharMap
-- @param self
-- @param #string charMapFile
-- @param #int itemWidth
-- @param #int itemHeight
-- @param #int startCharMap
-- @return Label#Label ret (return value: cc.Label)
--------------------------------
-- Creates a label with an initial string,font[font name or font file],font size, dimension in points, horizontal alignment and vertical alignment.<br>
-- warning It will generate texture by the platform-dependent code
-- @function [parent=#Label] createWithSystemFont
-- @param self
-- @param #string text
-- @param #string font
-- @param #float fontSize
-- @param #size_table dimensions
-- @param #int hAlignment
-- @param #int vAlignment
-- @return Label#Label ret (return value: cc.Label)
--------------------------------
--
-- @function [parent=#Label] draw
-- @param self
-- @param #cc.Renderer renderer
-- @param #mat4_table transform
-- @param #unsigned int flags
--------------------------------
--
-- @function [parent=#Label] addChild
-- @param self
-- @param #cc.Node child
-- @param #int zOrder
-- @param #int tag
--------------------------------
--
-- @function [parent=#Label] setScaleY
-- @param self
-- @param #float scaleY
--------------------------------
--
-- @function [parent=#Label] setScaleX
-- @param self
-- @param #float scaleX
--------------------------------
--
-- @function [parent=#Label] isOpacityModifyRGB
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#Label] getScaleY
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
--
-- @function [parent=#Label] setBlendFunc
-- @param self
-- @param #cc.BlendFunc blendFunc
--------------------------------
--
-- @function [parent=#Label] visit
-- @param self
-- @param #cc.Renderer renderer
-- @param #mat4_table parentTransform
-- @param #unsigned int parentFlags
--------------------------------
--
-- @function [parent=#Label] getScaleX
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
--
-- @function [parent=#Label] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#Label] setOpacityModifyRGB
-- @param self
-- @param #bool isOpacityModifyRGB
--------------------------------
--
-- @function [parent=#Label] setScale
-- @param self
-- @param #float scale
--------------------------------
--
-- @function [parent=#Label] sortAllChildren
-- @param self
--------------------------------
--
-- @function [parent=#Label] updateDisplayedOpacity
-- @param self
-- @param #unsigned char parentOpacity
--------------------------------
--
-- @function [parent=#Label] getContentSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
--
-- @function [parent=#Label] getBoundingBox
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
--
-- @function [parent=#Label] updateDisplayedColor
-- @param self
-- @param #color3b_table parentColor
return nil
| mit |
Colettechan/darkstar | scripts/zones/Phomiuna_Aqueducts/npcs/_0rr.lua | 13 | 1451 | -----------------------------------
-- Area: Phomiuna_Aqueducts
-- NPC: Oil lamp
-- @pos -60 -23 60 27
-----------------------------------
package.loaded["scripts/zones/Phomiuna_Aqueducts/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/zones/Phomiuna_Aqueducts/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local DoorOffset = npc:getID();
player:messageSpecial(LAMP_OFFSET+7); -- dark lamp
npc:openDoor(7); -- lamp animation
local element = VanadielDayElement();
--printf("element: %u",element);
if (element == 6 or element == 7) then -- lightday or darkday
if (GetNPCByID(DoorOffset-1):getAnimation() == 8) then -- lamp light open ?
GetNPCByID(DoorOffset-6):openDoor(15); -- Open Door _0rk
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 |
Vadavim/jsr-darkstar | scripts/globals/items/cone_of_seraphs_kiss.lua | 18 | 1385 | -----------------------------------------
-- ID: 5556
-- Item: cone_of_seraphs_kiss
-- Food Effect: 1Hr, All Races
-----------------------------------------
-- HP 15
-- MP % 16 (cap 85)
-- MP Recovered While Healing 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,3600,5556);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 15);
target:addMod(MOD_FOOD_MPP, 16);
target:addMod(MOD_FOOD_MP_CAP, 85);
target:addMod(MOD_MPHEAL, 2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 15);
target:delMod(MOD_FOOD_MPP, 16);
target:delMod(MOD_FOOD_MP_CAP, 85);
target:delMod(MOD_MPHEAL, 2);
end;
| gpl-3.0 |
ignacio/StackTracePlus | src/StackTracePlus.lua | 1 | 12581 | -- tables
local _G = _G
local string, io, debug, coroutine = string, io, debug, coroutine
-- functions
local tostring, print, require = tostring, print, require
local next, assert = next, assert
local pcall, type, pairs, ipairs = pcall, type, pairs, ipairs
local error = error
assert(debug, "debug table must be available at this point")
local io_open = io.open
local string_gmatch = string.gmatch
local string_sub = string.sub
local table_concat = table.concat
local _M = {
max_tb_output_len = 70 -- controls the maximum length of the 'stringified' table before cutting with ' (more...)'
}
-- this tables should be weak so the elements in them won't become uncollectable
local m_known_tables = { [_G] = "_G (global table)" }
local function add_known_module(name, desc)
local ok, mod = pcall(require, name)
if ok then
m_known_tables[mod] = desc
end
end
add_known_module("string", "string module")
add_known_module("io", "io module")
add_known_module("os", "os module")
add_known_module("table", "table module")
add_known_module("math", "math module")
add_known_module("package", "package module")
add_known_module("debug", "debug module")
add_known_module("coroutine", "coroutine module")
-- lua5.2
add_known_module("bit32", "bit32 module")
-- luajit
add_known_module("bit", "bit module")
add_known_module("jit", "jit module")
-- lua5.3
if _VERSION >= "Lua 5.3" then
add_known_module("utf8", "utf8 module")
end
local m_user_known_tables = {}
local m_known_functions = {}
for _, name in ipairs{
-- Lua 5.2, 5.1
"assert",
"collectgarbage",
"dofile",
"error",
"getmetatable",
"ipairs",
"load",
"loadfile",
"next",
"pairs",
"pcall",
"print",
"rawequal",
"rawget",
"rawlen",
"rawset",
"require",
"select",
"setmetatable",
"tonumber",
"tostring",
"type",
"xpcall",
-- Lua 5.1
"gcinfo",
"getfenv",
"loadstring",
"module",
"newproxy",
"setfenv",
"unpack",
-- TODO: add table.* etc functions
} do
if _G[name] then
m_known_functions[_G[name]] = name
end
end
local m_user_known_functions = {}
local function safe_tostring (value)
local ok, err = pcall(tostring, value)
if ok then return err else return ("<failed to get printable value>: '%s'"):format(err) end
end
-- Private:
-- Parses a line, looking for possible function definitions (in a very naïve way)
-- Returns '(anonymous)' if no function name was found in the line
local function ParseLine(line)
assert(type(line) == "string")
--print(line)
local match = line:match("^%s*function%s+(%w+)")
if match then
--print("+++++++++++++function", match)
return match
end
match = line:match("^%s*local%s+function%s+(%w+)")
if match then
--print("++++++++++++local", match)
return match
end
match = line:match("^%s*local%s+(%w+)%s+=%s+function")
if match then
--print("++++++++++++local func", match)
return match
end
match = line:match("%s*function%s*%(") -- this is an anonymous function
if match then
--print("+++++++++++++function2", match)
return "(anonymous)"
end
return "(anonymous)"
end
-- Private:
-- Tries to guess a function's name when the debug info structure does not have it.
-- It parses either the file or the string where the function is defined.
-- Returns '?' if the line where the function is defined is not found
local function GuessFunctionName(info)
--print("guessing function name")
if type(info.source) == "string" and info.source:sub(1,1) == "@" then
local file, err = io_open(info.source:sub(2), "r")
if not file then
print("file not found: "..tostring(err)) -- whoops!
return "?"
end
local line
for _ = 1, info.linedefined do
line = file:read("*l")
end
if not line then
print("line not found") -- whoops!
return "?"
end
return ParseLine(line)
else
local line
local lineNumber = 0
for l in string_gmatch(info.source, "([^\n]+)\n-") do
lineNumber = lineNumber + 1
if lineNumber == info.linedefined then
line = l
break
end
end
if not line then
print("line not found") -- whoops!
return "?"
end
return ParseLine(line)
end
end
---
-- Dumper instances are used to analyze stacks and collect its information.
--
local Dumper = {}
Dumper.new = function(thread)
local t = { lines = {} }
for k,v in pairs(Dumper) do t[k] = v end
t.dumping_same_thread = (thread == coroutine.running())
-- if a thread was supplied, bind it to debug.info and debug.get
-- we also need to skip this additional level we are introducing in the callstack (only if we are running
-- in the same thread we're inspecting)
if type(thread) == "thread" then
t.getinfo = function(level, what)
if t.dumping_same_thread and type(level) == "number" then
level = level + 1
end
return debug.getinfo(thread, level, what)
end
t.getlocal = function(level, loc)
if t.dumping_same_thread then
level = level + 1
end
return debug.getlocal(thread, level, loc)
end
else
t.getinfo = debug.getinfo
t.getlocal = debug.getlocal
end
return t
end
-- helpers for collecting strings to be used when assembling the final trace
function Dumper:add (text)
self.lines[#self.lines + 1] = text
end
function Dumper:add_f (fmt, ...)
self:add(fmt:format(...))
end
function Dumper:concat_lines ()
return table_concat(self.lines)
end
---
-- Private:
-- Iterates over the local variables of a given function.
--
-- @param level The stack level where the function is.
--
function Dumper:DumpLocals (level)
local prefix = "\t "
local i = 1
if self.dumping_same_thread then
level = level + 1
end
local name, value = self.getlocal(level, i)
if not name then
return
end
self:add("\tLocal variables:\r\n")
while name do
if type(value) == "number" then
self:add_f("%s%s = number: %g\r\n", prefix, name, value)
elseif type(value) == "boolean" then
self:add_f("%s%s = boolean: %s\r\n", prefix, name, tostring(value))
elseif type(value) == "string" then
self:add_f("%s%s = string: %q\r\n", prefix, name, value)
elseif type(value) == "userdata" then
self:add_f("%s%s = %s\r\n", prefix, name, safe_tostring(value))
elseif type(value) == "nil" then
self:add_f("%s%s = nil\r\n", prefix, name)
elseif type(value) == "table" then
if m_known_tables[value] then
self:add_f("%s%s = %s\r\n", prefix, name, m_known_tables[value])
elseif m_user_known_tables[value] then
self:add_f("%s%s = %s\r\n", prefix, name, m_user_known_tables[value])
else
local txt = "{"
for k,v in pairs(value) do
txt = txt..safe_tostring(k)..":"..safe_tostring(v)
if #txt > _M.max_tb_output_len then
txt = txt.." (more...)"
break
end
if next(value, k) then txt = txt..", " end
end
self:add_f("%s%s = %s %s\r\n", prefix, name, safe_tostring(value), txt.."}")
end
elseif type(value) == "function" then
local info = self.getinfo(value, "nS")
local fun_name = info.name or m_known_functions[value] or m_user_known_functions[value]
if info.what == "C" then
self:add_f("%s%s = C %s\r\n", prefix, name, (fun_name and ("function: " .. fun_name) or tostring(value)))
else
local source = info.short_src
if source:sub(2,7) == "string" then
source = source:sub(9) -- uno más, por el espacio que viene (string "Baragent.Main", por ejemplo)
end
--for k,v in pairs(info) do print(k,v) end
fun_name = fun_name or GuessFunctionName(info)
self:add_f("%s%s = Lua function '%s' (defined at line %d of chunk %s)\r\n", prefix, name, fun_name, info.linedefined, source)
end
elseif type(value) == "thread" then
self:add_f("%sthread %q = %s\r\n", prefix, name, tostring(value))
end
i = i + 1
name, value = self.getlocal(level, i)
end
end
---
-- Public:
-- Collects a detailed stack trace, dumping locals, resolving function names when they're not available, etc.
-- This function is suitable to be used as an error handler with pcall or xpcall
--
-- @param thread An optional thread whose stack is to be inspected (defaul is the current thread)
-- @param message An optional error string or object.
-- @param level An optional number telling at which level to start the traceback (default is 1)
--
-- Returns a string with the stack trace and a string with the original error.
--
function _M.stacktrace(thread, message, level)
if type(thread) ~= "thread" then
-- shift parameters left
thread, message, level = nil, thread, message
end
thread = thread or coroutine.running()
level = level or 1
local dumper = Dumper.new(thread)
local original_error
if type(message) == "table" then
dumper:add("an error object {\r\n")
local first = true
for k,v in pairs(message) do
if first then
dumper:add(" ")
first = false
else
dumper:add(",\r\n ")
end
dumper:add(safe_tostring(k))
dumper:add(": ")
dumper:add(safe_tostring(v))
end
dumper:add("\r\n}")
original_error = dumper:concat_lines()
elseif type(message) == "string" then
dumper:add(message)
original_error = message
end
dumper:add("\r\n")
dumper:add[[
Stack Traceback
===============
]]
--print(error_message)
local level_to_show = level
if dumper.dumping_same_thread then level = level + 1 end
local info = dumper.getinfo(level, "nSlf")
while info do
if info.what == "main" then
if string_sub(info.source, 1, 1) == "@" then
dumper:add_f("(%d) main chunk of file '%s' at line %d\r\n", level_to_show, string_sub(info.source, 2), info.currentline)
else
dumper:add_f("(%d) main chunk of %s at line %d\r\n", level_to_show, info.short_src, info.currentline)
end
elseif info.what == "C" then
--print(info.namewhat, info.name)
--for k,v in pairs(info) do print(k,v, type(v)) end
local function_name = m_user_known_functions[info.func] or m_known_functions[info.func] or info.name or tostring(info.func)
dumper:add_f("(%d) %s C function '%s'\r\n", level_to_show, info.namewhat, function_name)
--dumper:add_f("%s%s = C %s\r\n", prefix, name, (m_known_functions[value] and ("function: " .. m_known_functions[value]) or tostring(value)))
elseif info.what == "tail" then
--print("tail")
--for k,v in pairs(info) do print(k,v, type(v)) end--print(info.namewhat, info.name)
dumper:add_f("(%d) tail call\r\n", level_to_show)
dumper:DumpLocals(level)
elseif info.what == "Lua" then
local source = info.short_src
local function_name = m_user_known_functions[info.func] or m_known_functions[info.func] or info.name
if source:sub(2, 7) == "string" then
source = source:sub(9)
end
local was_guessed = false
if not function_name or function_name == "?" then
--for k,v in pairs(info) do print(k,v, type(v)) end
function_name = GuessFunctionName(info)
was_guessed = true
end
-- test if we have a file name
local function_type = (info.namewhat == "") and "function" or info.namewhat
if info.source and info.source:sub(1, 1) == "@" then
dumper:add_f("(%d) Lua %s '%s' at file '%s:%d'%s\r\n", level_to_show, function_type, function_name, info.source:sub(2), info.currentline, was_guessed and " (best guess)" or "")
elseif info.source and info.source:sub(1,1) == '#' then
dumper:add_f("(%d) Lua %s '%s' at template '%s:%d'%s\r\n", level_to_show, function_type, function_name, info.source:sub(2), info.currentline, was_guessed and " (best guess)" or "")
else
dumper:add_f("(%d) Lua %s '%s' at line %d of chunk '%s'\r\n", level_to_show, function_type, function_name, info.currentline, source)
end
dumper:DumpLocals(level)
else
dumper:add_f("(%d) unknown frame %s\r\n", level_to_show, info.what)
end
level = level + 1
level_to_show = level_to_show + 1
info = dumper.getinfo(level, "nSlf")
end
return dumper:concat_lines(), original_error
end
--
-- Adds a table to the list of known tables
function _M.add_known_table(tab, description)
if m_known_tables[tab] then
error("Cannot override an already known table")
end
m_user_known_tables[tab] = description
end
--
-- Adds a function to the list of known functions
function _M.add_known_function(fun, description)
if m_known_functions[fun] then
error("Cannot override an already known function")
end
m_user_known_functions[fun] = description
end
return _M
| mit |
zynjec/darkstar | scripts/zones/Riverne-Site_B01/npcs/Unstable_Displacement.lua | 9 | 1230 | -----------------------------------
-- Area: Riverne Site #B01
-- NPC: Unstable Displacement
-----------------------------------
local ID = require("scripts/zones/Riverne-Site_B01/IDs");
require("scripts/globals/settings")
require("scripts/globals/quests")
require("scripts/globals/status")
require("scripts/globals/bcnm")
function onTrade(player,npc,trade)
local offset = npc:getID() - ID.npc.DISPLACEMENT_OFFSET;
if (offset == 5 and TradeBCNM(player,npc,trade)) then -- The Wyrmking Descends
return;
end
end
function onTrigger(player,npc)
local offset = npc:getID() - ID.npc.DISPLACEMENT_OFFSET;
-- STORMS OF FATE
if offset == 5 and player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.STORMS_OF_FATE) == QUEST_ACCEPTED and player:getCharVar('StormsOfFate') == 1 then
player:startEvent(1)
elseif offset == 5 and EventTriggerBCNM(player,npc) then
return
elseif offset == 5 then
player:messageSpecial(ID.text.SPACE_SEEMS_DISTORTED)
end
end
function onEventUpdate(player,csid,option,extras)
EventUpdateBCNM(player,csid,option,extras)
end
function onEventFinish(player,csid,option)
if csid == 1 then
player:setCharVar('StormsOfFate',2)
end
end
| gpl-3.0 |
syntafin/prosody-modules | mod_firewall/conditions.lib.lua | 31 | 6103 | local condition_handlers = {};
local jid = require "util.jid";
-- Return a code string for a condition that checks whether the contents
-- of variable with the name 'name' matches any of the values in the
-- comma/space/pipe delimited list 'values'.
local function compile_comparison_list(name, values)
local conditions = {};
for value in values:gmatch("[^%s,|]+") do
table.insert(conditions, ("%s == %q"):format(name, value));
end
return table.concat(conditions, " or ");
end
function condition_handlers.KIND(kind)
return compile_comparison_list("name", kind), { "name" };
end
local wildcard_equivs = { ["*"] = ".*", ["?"] = "." };
local function compile_jid_match_part(part, match)
if not match then
return part.." == nil"
end
local pattern = match:match("<(.*)>");
if pattern then
if pattern == "*" then
return part;
end
if pattern:match("^<.*>$") then
pattern = pattern:match("^<(.*)>$");
else
pattern = pattern:gsub("%p", "%%%0"):gsub("%%(%p)", wildcard_equivs);
end
return ("%s:match(%q)"):format(part, "^"..pattern.."$");
else
return ("%s == %q"):format(part, match);
end
end
local function compile_jid_match(which, match_jid)
local match_node, match_host, match_resource = jid.split(match_jid);
local conditions = {};
conditions[#conditions+1] = compile_jid_match_part(which.."_node", match_node);
conditions[#conditions+1] = compile_jid_match_part(which.."_host", match_host);
if match_resource then
conditions[#conditions+1] = compile_jid_match_part(which.."_resource", match_resource);
end
return table.concat(conditions, " and ");
end
function condition_handlers.TO(to)
return compile_jid_match("to", to), { "split_to" };
end
function condition_handlers.FROM(from)
return compile_jid_match("from", from), { "split_from" };
end
function condition_handlers.TYPE(type)
return compile_comparison_list("(type or (name == 'message' and 'normal') or (name == 'presence' and 'available'))", type), { "type", "name" };
end
local function zone_check(zone, which)
local which_not = which == "from" and "to" or "from";
return ("(zone_%s[%s_host] or zone_%s[%s] or zone_%s[bare_%s]) "
.."and not(zone_%s[%s_host] or zone_%s[%s] or zone_%s[%s])"
)
:format(zone, which, zone, which, zone, which,
zone, which_not, zone, which_not, zone, which_not), {
"split_to", "split_from", "bare_to", "bare_from", "zone:"..zone
};
end
function condition_handlers.ENTERING(zone)
return zone_check(zone, "to");
end
function condition_handlers.LEAVING(zone)
return zone_check(zone, "from");
end
function condition_handlers.PAYLOAD(payload_ns)
return ("stanza:get_child(nil, %q)"):format(payload_ns);
end
function condition_handlers.INSPECT(path)
if path:find("=") then
local path, match = path:match("(.-)=(.*)");
return ("stanza:find(%q) == %q"):format(path, match);
end
return ("stanza:find(%q)"):format(path);
end
function condition_handlers.FROM_GROUP(group_name)
return ("group_contains(%q, bare_from)"):format(group_name), { "group_contains", "bare_from" };
end
function condition_handlers.TO_GROUP(group_name)
return ("group_contains(%q, bare_to)"):format(group_name), { "group_contains", "bare_to" };
end
function condition_handlers.FROM_ADMIN_OF(host)
return ("is_admin(bare_from, %s)"):format(host ~= "*" and host or nil), { "is_admin", "bare_from" };
end
function condition_handlers.TO_ADMIN_OF(host)
return ("is_admin(bare_to, %s)"):format(host ~= "*" and host or nil), { "is_admin", "bare_to" };
end
local day_numbers = { sun = 0, mon = 2, tue = 3, wed = 4, thu = 5, fri = 6, sat = 7 };
local function current_time_check(op, hour, minute)
hour, minute = tonumber(hour), tonumber(minute);
local adj_op = op == "<" and "<" or ">="; -- Start time inclusive, end time exclusive
if minute == 0 then
return "(current_hour"..adj_op..hour..")";
else
return "((current_hour"..op..hour..") or (current_hour == "..hour.." and current_minute"..adj_op..minute.."))";
end
end
local function resolve_day_number(day_name)
return assert(day_numbers[day_name:sub(1,3):lower()], "Unknown day name: "..day_name);
end
function condition_handlers.DAY(days)
local conditions = {};
for day_range in days:gmatch("[^,]+") do
local day_start, day_end = day_range:match("(%a+)%s*%-%s*(%a+)");
if day_start and day_end then
local day_start_num, day_end_num = resolve_day_number(day_start), resolve_day_number(day_end);
local op = "and";
if day_end_num < day_start_num then
op = "or";
end
table.insert(conditions, ("current_day >= %d %s current_day <= %d"):format(day_start_num, op, day_end_num));
elseif day_range:match("%a") then
local day = resolve_day_number(day_range:match("%a+"));
table.insert(conditions, "current_day == "..day);
else
error("Unable to parse day/day range: "..day_range);
end
end
assert(#conditions>0, "Expected a list of days or day ranges");
return "("..table.concat(conditions, ") or (")..")", { "time:day" };
end
function condition_handlers.TIME(ranges)
local conditions = {};
for range in ranges:gmatch("([^,]+)") do
local clause = {};
range = range:lower()
:gsub("(%d+):?(%d*) *am", function (h, m) return tostring(tonumber(h)%12)..":"..(tonumber(m) or "00"); end)
:gsub("(%d+):?(%d*) *pm", function (h, m) return tostring(tonumber(h)%12+12)..":"..(tonumber(m) or "00"); end);
local start_hour, start_minute = range:match("(%d+):(%d+) *%-");
local end_hour, end_minute = range:match("%- *(%d+):(%d+)");
local op = tonumber(start_hour) > tonumber(end_hour) and " or " or " and ";
if start_hour and end_hour then
table.insert(clause, current_time_check(">", start_hour, start_minute));
table.insert(clause, current_time_check("<", end_hour, end_minute));
end
if #clause == 0 then
error("Unable to parse time range: "..range);
end
table.insert(conditions, "("..table.concat(clause, " "..op.." ")..")");
end
return table.concat(conditions, " or "), { "time:hour,min" };
end
function condition_handlers.LIMIT(name)
return ("not throttle_%s:poll(1)"):format(name), { "throttle:"..name };
end
return condition_handlers;
| mit |
dhlab-basel/Sipi | scripts/upload.lua | 1 | 4781 | --
-- Copyright © 2016 Lukas Rosenthaler, Andrea Bianco, Benjamin Geer,
-- Ivan Subotic, Tobias Schweizer, André Kilchenmann, and André Fatton.
-- This file is part of Sipi.
-- Sipi is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as published
-- by the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- Sipi 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.
-- Additional permission under GNU AGPL version 3 section 7:
-- If you modify this Program, or any covered work, by linking or combining
-- it with Kakadu (or a modified version of that library), containing parts
-- covered by the terms of the Kakadu Software Licence, the licensors of this
-- Program grant you additional permission to convey the resulting work.
-- See the GNU Affero General Public License for more details.
-- You should have received a copy of the GNU Affero General Public
-- License along with Sipi. If not, see <http://www.gnu.org/licenses/>.
-- upload script for binary files (currently only images) from Knora
--
require "send_response"
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
myimg = {}
newfilename = {}
iiifurls = {}
if server.secure then
protocol = 'https://'
else
protocol = 'http://'
end
for imgindex,imgparam in pairs(server.uploads) do
--
-- first we check the mimetype consistency
--
success, mime_ok = server.file_mimeconsistency(imgindex)
if not success then
server.log(newfilepath, server.loglevel.error)
send_error(500, mime_ok)
return false
end
if not mime_ok then
success, mimetypeobj = server.file_mimetype(imgindex)
if not success then
server.log("Couldn't determine mimetype!", server.loglevel.error)
send_error(500, mime_ok)
return false
end
mimetype = mimetypeobj.mimetype
else
mimetype = imgparam["mimetype"]
end
--
-- generate a UUID
--
local success, uuid62 = server.uuid62()
if not success then
server.log(uuid62, server.loglevel.error)
send_error(500, uuid62)
return false
end
if mimetype == "image/tiff" or
mimetype == "image/jpeg" or
mimetype == "image/png" or
mimetype == "image/jpx" or
mimetype == "image/jp2" then
--
-- create a new Lua image object. This reads the image into an
-- internal in-memory representation independent of the original
-- image format.
--
success, myimg[imgindex] = SipiImage.new(imgindex)
if not success then
server.log(myimg[imgindex], server.loglevel.error)
send_error(500, myimg[imgindex])
return false
end
filename = imgparam["origname"]
filebody = filename:match("(.+)%..+")
newfilename[imgindex] = "_" .. filebody .. '.jp2'
iiifurls[uuid62 .. ".jp2"] = protocol .. server.host .. '/images/' .. newfilename[imgindex]
iiifurls["filename"] = newfilename[imgindex]
--
-- here we add the subdirs that are necessary if Sipi is configured to use subdirs
--
success, newfilepath = helper.filename_hash(newfilename[imgindex]);
if not success then
server.log(newfilepath, server.loglevel.error)
server.send_error(500, newfilepath)
return false
end
--
-- Create the destination path
--
fullfilepath = config.imgroot .. '/' .. newfilepath
--
-- write the file to the destination
--
local status, errmsg = myimg[imgindex]:write(fullfilepath)
if not status then
server.print('Error converting image to j2k: ', filename, ' ** ', errmsg)
end
else
filename = imgparam["origname"]
--
-- here we add the subdirs that are necessary if Sipi is configured to use subdirs
--
success, newfilepath = helper.filename_hash(filename)
if not success then
server.log(newfilepath, server.loglevel.error)
server.send_error(500, newfilepath)
return false
end
fullfilepath = config.imgroot .. '/' .. newfilepath
server.copyTmpfile(index, fullfilepath)
iiifurls[filename] = protocol .. server.host .. '/images/' .. newfilepath
iiifurls["filename"] = filename
end
end
send_success(iiifurls)
| agpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/mobskills/Antiphase.lua | 1 | 1061 | ---------------------------------------------
-- Antiphase
--
-- Description: Silence Area of Effect (15.0')
-- Type: Enfeebling
-- Utsusemi/Blink absorb: Ignores shadows
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local typeEffect = EFFECT_SILENCE;
local hard = mob:getMobMod(MOBMOD_HARD_MODE);
local tp = skill:getTP();
mob:lowerEnmity(target, 15 + hard * 5);
skill:setMsg(MobStatusEffectMove(mob, target, typeEffect, 1, 0, duration, MOD_MND));
enmityStatusCheck(target, mob, skill, 15 + hard * 5);
if (hard > 0) then
local success = MobRoarMove(mob, target, EFFECT_AMNESIA, 1, 0, duration, MOD_MND);
if (success == 242) then
target:setPendingMessage(277, EFFECT_AMNESIA);
end
end
return typeEffect;
end;
| gpl-3.0 |
JarnoVgr/InfectedWars | gamemode/debug/cl_debug.lua | 1 | 1625 | --[[-----------------------------------------------------------------------------
* 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.
-----------------------------------------------------------------------------]]
DEBUG_DRAWVECS = true
local debugvecs = {}
local function DebugPaint()
if DEBUG_DRAWVECS then
for k, v in pairs(debugvecs) do
local cross = v.vector:GetNormal():Cross(Vector(0,0,1))
local arr1 = (v.start + (v.vector - (v.vector:GetNormal()*2) + (cross*2))):ToScreen()
local arr2 = (v.start + (v.vector - (v.vector:GetNormal()*2) - (cross*2))):ToScreen()
local stpos = v.start:ToScreen()
local endpos = (v.start+v.vector):ToScreen()
surface.SetDrawColor( v.color )
surface.DrawLine( stpos.x, stpos.y, endpos.x, endpos.y )
if (v.vector:Length() > 3) then
surface.DrawLine( arr1.x, arr1.y, endpos.x, endpos.y )
surface.DrawLine( arr2.x, arr2.y, endpos.x, endpos.y )
end
end
end
end
hook.Add("HUDPaint", "DrawDebug", DebugPaint)
local function DebugVecs(um)
local start = um:ReadVector()
local vec = um:ReadVector()
local col = um:ReadVector()
table.insert( debugvecs, { start = start, vector = vec, color = Color(col.x, col.y, col.z, 255) } )
end
usermessage.Hook("Debug_Vector", DebugVecs) | mit |
zynjec/darkstar | scripts/globals/items/serving_of_bass_meuniere.lua | 11 | 1364 | -----------------------------------------
-- ID: 4582
-- Item: serving_of_bass_meuniere
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Health % 3 (cap 130)
-- Dexterity 3
-- Agility 3
-- Mind -3
-- Ranged ACC % 6
-- Ranged ACC Cap 15
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,10800,4582)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.FOOD_HPP, 3)
target:addMod(dsp.mod.FOOD_HP_CAP, 130)
target:addMod(dsp.mod.DEX, 3)
target:addMod(dsp.mod.AGI, 3)
target:addMod(dsp.mod.MND, -3)
target:addMod(dsp.mod.FOOD_RACCP, 6)
target:addMod(dsp.mod.FOOD_RACC_CAP, 15)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 3)
target:delMod(dsp.mod.FOOD_HP_CAP, 130)
target:delMod(dsp.mod.DEX, 3)
target:delMod(dsp.mod.AGI, 3)
target:delMod(dsp.mod.MND, -3)
target:delMod(dsp.mod.FOOD_RACCP, 6)
target:delMod(dsp.mod.FOOD_RACC_CAP, 15)
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Western_Adoulin/npcs/HomePoint#1.lua | 27 | 1255 | -----------------------------------
-- Area: Western_Adoulin
-- NPC: HomePoint#1
-- @pos
-----------------------------------
package.loaded["scripts/zones/Western_Adoulin/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Western_Adoulin/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 44);
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 == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/The_Sanctuary_of_ZiTah/npcs/Kasim.lua | 13 | 1889 | -----------------------------------
-- Area: The Sanctuary of Zitah
-- NPC: Kasim
-- @pos -46 0 -148 121
-----------------------------------
package.loaded["scripts/zones/The_Sanctuary_of_Zitah/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
require("scripts/zones/The_Sanctuary_of_ZiTah/TextIDs");
local region = LITELOR;
local csid = 0x7ff4;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local owner = GetRegionOwner(region);
local arg1 = getArg1(owner,player);
if (owner == player:getNation()) then
nation = 1;
elseif (arg1 < 1792) then
nation = 2;
else
nation = 0;
end
player:startEvent(csid,nation,OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP(),0,0,0);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
player:updateEvent(player:getGil(),OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP());
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
if (option == 1) then
ShowOPVendorShop(player);
elseif (option == 2) then
if (player:delGil(OP_TeleFee(player,region))) then
toHomeNation(player);
end
elseif (option == 6) then
player:delCP(OP_TeleFee(player,region));
toHomeNation(player);
end
end; | gpl-3.0 |
zevv/lgi | tools/dump-typelib.lua | 6 | 5603 | #! /usr/bin/env lua
------------------------------------------------------------------------------
--
-- LGI tools for dumping typelib fragments into readable text format.
--
-- Copyright (c) 2010, 2011 Pavel Holejsovsky
-- Licensed under the MIT license:
-- http://www.opensource.org/licenses/mit-license.php
--
------------------------------------------------------------------------------
local lgi_core = require 'lgi.core'
local gi = lgi_core.gi
require 'debugger'
-- Implements BaseInfo object, capable of dump itself.
local infos = {}
infos.base = { attrs = { 'name', 'namespace', 'type', 'deprecated' },
cats = {}, }
infos.base.__index = infos.base
-- Creates new info wrapper according to info type.
function infos.new(info)
if info then
return setmetatable({ info = info }, infos[info.type] or infos.base)
end
end
-- Derives new baseinfo subtype.
function infos.base:derive(attrs, cats)
local new_attrs = {}
for _, val in ipairs(self.attrs) do new_attrs[#new_attrs + 1] = val end
for _, val in ipairs(attrs or {}) do new_attrs[#new_attrs + 1] = val end
local new_cats = {}
for _, val in ipairs(self.cats) do new_cats[#new_cats + 1] = val end
for _, val in ipairs(cats or {}) do new_cats[#new_cats + 1] = val end
local new = setmetatable({ attrs = new_attrs, cats = new_cats }, self)
new.__index = new
return new
end
-- Gets given attribute or category.
function infos.base:get(name, depth)
local item = self.info[name]
if gi.isinfo(item) then
item = infos.new(item)
if depth then item = item:dump(depth) end
else
for _, cat in pairs(self.cats) do
if cat == name then item = infos.category.new(item) end
end
end
return item
end
-- Dumps all attributes into the target table.
function infos.base:dump_attrs(target, depth)
for _, attr in ipairs(self.attrs) do
target[attr] = self:get(attr, depth - 1)
end
return attrs
end
-- Dumps all categories into the target table.
function infos.base:dump_cats(target, depth)
local cats = {}
for _, cat in ipairs(self.cats) do
target[cat] = self:get(cat):dump(depth - 1)
end
return cats
end
function infos.base:dump(depth)
if depth <= 0 then return '...' end
local t = {}
self:dump_attrs(t, depth)
local cats = {}
self:dump_cats(cats, depth)
if next(cats) then t.cats = cats end
return t
end
-- Implementation of 'subcategory' pseudoinfo.
infos.category = infos.base:derive()
function infos.category.new(category)
return setmetatable({ info = category }, infos.category)
end
function infos.category:dump(depth)
local t = {}
for i = 1, #self.info do
t[i] = infos.new(self.info[i]):dump(depth)
end
return t
end
infos.type = infos.base:derive(
{ 'tag', 'is_basic', 'interface', 'array_type',
'is_zero_terminated', 'array_length', 'fixed_size', 'is_pointer' },
{ 'params' })
function infos.type:dump_cats(target, depth)
local params = {}
for i, param in ipairs(self.info.params or {}) do
params[i] = infos.new(param):dump(depth - 1)
end
if next(params) then target.params = params end
end
infos.registered = infos.base:derive({ 'gtype' }, {})
infos.object = infos.registered:derive(
{ 'parent', 'type_struct', },
{ 'interfaces', 'fields', 'vfuncs', 'methods', 'constants', 'properties',
'signals' })
infos.interface = infos.registered:derive(
{ 'type_struct', },
{ 'prerequisites', 'vfuncs', 'methods', 'constants', 'properties',
'signals' })
infos.property = infos.base:derive({ 'typeinfo', 'flags', 'transfer' })
infos.callable = infos.base:derive(
{ 'return_type', 'return_transfer' },
{ 'args' })
infos['function'] = infos.callable:derive({ 'flags' })
infos.signal = infos.callable:derive({ 'flags' })
infos.callback = infos.callable:derive()
infos.vfunc = infos.callable:derive()
infos.arg = infos.base:derive(
{ 'typeinfo', 'direction', 'transfer', 'optional', 'typeinfo' }
)
infos.struct = infos.registered:derive({ 'is_gtype_struct', 'size' },
{ 'fields', 'methods' })
infos.union = infos.registered:derive({ 'size' }, { 'fields', 'methods' })
infos.field = infos.base:derive({ 'typeinfo', 'flags', 'size', 'offset' })
infos.enum = infos.registered:derive({ 'storage' }, { 'values' })
infos.value = infos.base:derive({ 'value' })
infos.constant = infos.base:derive({ 'typeinfo', 'value' })
-- Implementation of info wrapper for namespace pseudoinfo.
infos.namespace = infos.base:derive({ 'name', 'version', 'dependencies' })
function infos.namespace:get(name)
local item = self.info[name]
return item and infos.new(item)
end
function infos.namespace:dump_cats(target, depth)
if depth <= 0 then return '...' end
for i = 1, #self.info do
local info = self.info[i]
target[info.name] = infos.new(info):dump(depth - 1)
end
end
function infos.namespace.new(info)
return setmetatable({ info = info }, infos.namespace)
end
-- Implementation of root element pseudoinfo.
infos.root = infos.base:derive()
function infos.root:get(name)
return infos.namespace.new(gi.require(name))
end
-- Commandline processing
arg = arg or {}
paths = {}
depth = 3
for i = 1, #arg do
if tonumber(arg[i]) then depth = tonumber(arg[i])
else paths[#paths + 1] = arg[i] end
end
-- Go through all paths and dump them.
for _, path in ipairs(paths) do
local info = infos.root
for name in path:gmatch('([^%.]+)%.?') do
info = info:get(name)
if not info then break end
end
if not info then error(('%s not found'):format(path)) end
dump(info:dump(depth), depth * 2)
end
| mit |
Vadavim/jsr-darkstar | scripts/zones/Kazham/npcs/Lulupp.lua | 14 | 6017 | -----------------------------------
-- Area: Kazham
-- NPC: Lulupp
-- Type: Standard NPC
-- @zone 250
-- @pos -26.567 -3.5 -3.544
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/globals/pathfind");
local path = {
-27.457125, -3.043032, -22.057966,
-27.373426, -2.772481, -20.974442,
-27.103289, -2.500000, -17.846378,
-26.864126, -2.500000, -15.667570,
-26.532335, -2.500000, -16.636086,
-26.505196, -2.500000, -15.471632,
-26.509424, -2.500000, -14.359641,
-26.564587, -2.500000, -4.499783,
-26.574417, -2.500000, -5.523735,
-26.580530, -2.500000, -6.591716,
-26.583765, -2.500000, -8.555706,
-26.501217, -2.500000, -16.563267,
-26.504532, -2.500000, -15.427269,
-26.509769, -2.500000, -14.327281,
-26.565643, -2.500000, -4.247434,
-26.573967, -2.500000, -5.299402,
-26.579763, -2.500000, -6.379386,
-26.580465, -2.500000, -8.155381
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(pathfind.first(path));
onPath(npc);
end;
function onPath(npc)
pathfind.patrol(npc, path);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
-- item IDs
-- 483 Broken Mithran Fishing Rod
-- 22 Workbench
-- 1008 Ten of Coins
-- 1157 Sands of Silence
-- 1158 Wandering Bulb
-- 904 Giant Fish Bones
-- 4599 Blackened Toad
-- 905 Wyvern Skull
-- 1147 Ancient Salt
-- 4600 Lucky Egg
function onTrade(player,npc,trade)
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I);
local progress = player:getVar("OPO_OPO_PROGRESS");
local failed = player:getVar("OPO_OPO_FAILED");
local goodtrade = trade:hasItemQty(483,1);
local badtrade = (trade:hasItemQty(22,1) or trade:hasItemQty(1008,1) or trade:hasItemQty(1157,1) or trade:hasItemQty(1158,1) or trade:hasItemQty(904,1) or trade:hasItemQty(4599,1) or trade:hasItemQty(905,1) or trade:hasItemQty(1147,1) or trade:hasItemQty(4600,1));
if (OpoOpoAndIStatus == QUEST_ACCEPTED) then
if progress == 0 or failed == 1 then
if goodtrade then -- first or second time trading correctly
player:startEvent(0x00DB);
elseif badtrade then
player:startEvent(0x00E5);
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I);
local progress = player:getVar("OPO_OPO_PROGRESS");
local failed = player:getVar("OPO_OPO_FAILED");
local retry = player:getVar("OPO_OPO_RETRY");
if (player:getVar("BathedInScent") == 1 and OpoOpoAndIStatus == QUEST_AVAILABLE) then
player:startEvent(0x00D9, 0, 483) -- 483 broken mithran fishing rod
npc:wait(-1);
elseif (OpoOpoAndIStatus == QUEST_ACCEPTED) then
if retry == 1 then
player:startEvent(0x00EF); -- gave 1st NPC wrong item instead of "Broken Mithran Fishing Rod"
elseif retry == 2 then
player:startEvent(0x00EF, 0, 0, 1); -- gave 2nd NPC wrong item instead of "Workbench"
elseif retry == 3 then
player:startEvent(0x00EF, 0, 0, 2); -- gave 3rd NPC wrong item instead of "Ten of Coins"
elseif retry == 4 then
player:startEvent(0x00EF, 0, 0, 3); -- gave 4th NPC wrong item instead of "Sands of silence"
elseif retry == 5 then
player:startEvent(0x00EF, 0, 0, 4); -- gave 5th NPC wrong item instead of "Wandering Bulb"
elseif retry == 6 then
player:startEvent(0x00EF, 0, 0, 5); -- gave 6th NPC wrong item instead of "Giant Fish Bones"
elseif retry == 7 then
player:startEvent(0x00EF, 0, 0, 6); -- gave 7th NPC wrong item instead of "Blackened Toad"
elseif retry == 8 then
player:startEvent(0x00EF, 0, 0, 7); -- gave 8th NPC wrong item instead of "Wyvern Skull"
elseif retry == 9 then
player:startEvent(0x00EF, 0, 0, 8); -- gave 9th NPC wrong item instead of "Ancient Salt"
elseif retry == 10 then
player:startEvent(0x00EF, 0, 0, 9); -- gave 10th NPC wrong item instead of "Lucky Egg" ... uwot
elseif (progress == 0 or failed == 1) then
player:startEvent(0x00CF); -- asking for rod with Opoppo
elseif (progress >= 1 or failed >= 2) then
player:startEvent(0x00F2); -- happy with rod
end
else
player:startEvent(0x00c5); -- not sure why but this cs has no text
npc:wait(-1);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,npc)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x00D9 and option == 1) then -- Opo Opo and I quest start CS
player:addQuest(OUTLANDS, THE_OPO_OPO_AND_I);
elseif (csid == 0x00DB) then
if (player:getVar("OPO_OPO_PROGRESS") == 0) then
player:tradeComplete();
player:setVar("OPO_OPO_PROGRESS",1);
else
player:setVar("OPO_OPO_FAILED",2);
end
elseif (csid == 0x00E5) then -- Traded wrong item, saving current progress to not take item up to this point
player:setVar("OPO_OPO_RETRY",1);
elseif (csid == 0x00EF and option == 1) then -- Traded wrong to another NPC, give a clue
player:setVar("OPO_OPO_RETRY",0);
player:setVar("OPO_OPO_FAILED",1);
else
npc:wait(0);
end
end;
| gpl-3.0 |
JarnoVgr/InfectedWars | entities/weapons/iw_und_locustcannon/shared.lua | 1 | 8692 | --[[-----------------------------------------------------------------------------
* 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 = "shotgun"
if CLIENT then
SWEP.PrintName = "Locust Cannon"
SWEP.Author = "ClavusElite"
SWEP.Slot = 2
SWEP.SlotPos = 1
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.ShowViewModel = false
SWEP.IgnoreBonemerge = false
SWEP.UseHL2Bonemerge = true
SWEP.ScaleDownLeftHand = true
SWEP.ShowWorldModel = false
SWEP.IconLetter = "0"
SWEP.SelectFont = "HL2MPTypeDeath"
killicon.AddFont("iw_und_locustcannon", "HL2MPTypeDeath", SWEP.IconLetter, Color(255, 80, 0, 255 ))
end
function SWEP:InitializeClientsideModels()
self.VElements = {
["bone+++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(-0.638, -1.063, 0.874), angle = Angle(180, 78.324, 180), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(-0.638, -0.995, 3.93), angle = Angle(180, 78.324, 180), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(0.75, -1, 1.618), angle = Angle(180, 105.186, 0), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone+"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(0.75, -1.007, -1.232), angle = Angle(180, 105.186, 0), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone++++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(-0.638, -1.063, -1.982), angle = Angle(180, 78.324, 180), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone1"] = { type = "Model", model = "models/Gibs/Antlion_gib_Large_3.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(-0.119, -2.757, 0), angle = Angle(23.011, -88.175, 180), size = Vector(0.209, 0.179, 0.354), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone+++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(0.75, -1, -3.5), angle = Angle(180, 105.186, 0), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(0.75, -1, 4.605), angle = Angle(180, 105.186, 0), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone+++++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Gun", rel = "", pos = Vector(-0.638, -1.063, -4.308), angle = Angle(180, 78.324, 180), size = Vector(0.467, 0.467, 0.467), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
self.WElements = {
["locust"] = { type = "Model", model = "models/Weapons/w_shotgun.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(16.562, 0.524, -3.537), angle = Angle(167.143, -1.331, 0), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "models/flesh", skin = 0, bodygroup = {} },
["bone+++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(19.781, 0.832, -6.525), angle = Angle(97.25, -132.431, -51.113), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(21.051, 0.832, -6.525), angle = Angle(97.25, -132.431, -51.113), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone1"] = { type = "Model", model = "models/Gibs/Antlion_gib_Large_3.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(20.163, 1.055, -8.124), angle = Angle(72.337, 0, 0), size = Vector(0.135, 0.109, 0.216), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone+"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(21.819, 1.544, -6.525), angle = Angle(90, -4.088, 0), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone++++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(18.475, 0.832, -6.525), angle = Angle(97.25, -132.431, -51.113), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(18.995, 1.544, -6.525), angle = Angle(90, -4.088, 0), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone+++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(17.357, 1.544, -6.525), angle = Angle(90, -4.088, 0), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(20.37, 1.549, -6.525), angle = Angle(90, -4.088, 0), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["bone+++++++"] = { type = "Model", model = "models/Gibs/HGIBS_rib.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(16.806, 0.832, -6.525), angle = Angle(97.25, -132.431, -51.113), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
end
SWEP.Base = "iw_base"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/Weapons/v_shotgun.mdl"
SWEP.WorldModel = "models/Weapons/w_shotgun.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Sound = Sound("BULLSHOT.Single2")//Sound("npc/antlion/land1.wav")
SWEP.Primary.Recoil = 8
SWEP.Primary.Unrecoil = 7
SWEP.Primary.Damage = 2
SWEP.Primary.NumShots = 8
SWEP.Primary.ClipSize = 10
SWEP.Primary.Delay = 0.4
SWEP.Primary.DefaultClip = SWEP.Primary.ClipSize * 6
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "SMG1"
SWEP.Primary.Cone = 0.12
SWEP.Primary.ConeMoving = 0.19
SWEP.Primary.ConeCrouching = 0.08
SWEP.MuzzleEffect = "rg_muzzle_rifle"
--SWEP.IronSightsPos = Vector(-5.6, -6, 3.6)
--SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.NextReload = 0
function SWEP:Reload()
--self:SetIronsights(false)
if CurTime() < self.NextReload then return end
self.NextReload = CurTime() + self.Primary.Delay * 2
if self.Weapon:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
self.Weapon:SetNetworkedBool( "reloading", true )
self.Weapon:DefaultReload( ACT_VM_RELOAD )
timer.Simple(0.4, self.Weapon.SendWeaponAnim, self.Weapon, ACT_SHOTGUN_RELOAD_FINISH)
self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
end
end
| mit |
Vadavim/jsr-darkstar | scripts/zones/Jugner_Forest_[S]/Zone.lua | 4 | 1772 | -----------------------------------
--
-- Zone: Jugner_Forest_[S] (82)
--
-----------------------------------
package.loaded["scripts/zones/Jugner_Forest_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Jugner_Forest_[S]/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
local vwnpc = {17114036,17114037,17114038};
SetVoidwatchNPC(vwnpc);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(621.865,-6.665,300.264,149);
end
if (player:getQuestStatus(CRYSTAL_WAR,CLAWS_OF_THE_GRIFFON) == QUEST_ACCEPTED and player:getVar("ClawsOfGriffonProg") == 0) then
cs = 0x00C8;
elseif (player:getVar("roadToDivadomCS") == 1) then
cs = 0x0069;
end;
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x00C8) then
player:setVar("ClawsOfGriffonProg",1);
elseif (csid == 0x0069 ) then
player:setVar("roadToDivadomCS", 2);
end;
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/spells/bluemagic/frightful_roar.lua | 1 | 1419 | -----------------------------------------
-- Spell: Frightful Roar
-- Weakens defense of enemies within range
-- Spell cost: 32 MP
-- Monster Type: Demon
-- Spell Type: Magical (Wind)
-- Blue Magic Points: 3
-- Stat Bonus: AGI+2
-- Level: 50
-- Casting Time: 2 seconds
-- Recast Time: 20 seconds
-- Magic Bursts on: Detonation, Fragmentation, and Light
-- Combos: Auto Refresh
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local typeEffect = EFFECT_DEFENSE_DOWN;
local dINT = caster:getStat(MOD_MND) - target:getStat(MOD_MND);
local resist = applyResistance(caster,spell,target,dINT,BLUE_SKILL, 20);
local duration = 180 * resist;
local power = 15 + getSystemBonus(caster,target,spell) * 4;
if (resist >= 0.25) then -- Do it!
if (target:addStatusEffect(typeEffect,power,0,duration * resist)) then
spell:setMsg(236);
else
spell:setMsg(75);
end
else
spell:setMsg(85);
end;
return typeEffect;
end;
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Northern_San_dOria/npcs/Heruze-Moruze.lua | 9 | 1417 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Heruze-Moruze
-- Involved in Mission: 2-3 Windurst
-- !pos -56 -3 36 231
-----------------------------------
local ID = require("scripts/zones/Northern_San_dOria/IDs");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(SANDORIA,dsp.quest.id.sandoria.FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then
if (trade:hasItemQty(532,1) and trade:getItemCount() == 1) then -- Trade Magicmart_flyer
player:messageSpecial(ID.text.FLYER_REFUSED);
end
end
end;
function onTrigger(player,npc)
pNation = player:getNation();
currentMission = player:getCurrentMission(pNation);
if (pNation == dsp.nation.WINDURST) then
if (currentMission == dsp.mission.id.windurst.THE_THREE_KINGDOMS and player:getCharVar("MissionStatus") == 1) then
player:startEvent(582);
else
player:startEvent(554);
end
elseif (pNation == dsp.nation.BASTOK) then
player:startEvent(578);
elseif (pNation == dsp.nation.SANDORIA) then
player:startEvent(577);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 582) then
player:setCharVar("MissionStatus",2);
end
end; | gpl-3.0 |
KTXSoftware/angleproject | kake.lua | 1 | 6982 | project = Project.new("angle")
project:addExclude(".git/**")
project:addExclude("extensions/**")
project:addExclude("samples/**")
project:addExclude("tests/**")
project:addDefine("ANGLE_DISABLE_PERF")
project:addDefine("ANGLE_DISABLE_TRACE")
project:addIncludeDir("src")
project:addIncludeDir("include")
--preprocessor
project:addFile("src/compiler/preprocessor/DiagnosticsBase.cpp")
project:addFile("src/compiler/preprocessor/DirectiveHandlerBase.cpp")
project:addFile("src/compiler/preprocessor/DirectiveParser.cpp")
project:addFile("src/compiler/preprocessor/ExpressionParser.cpp")
project:addFile("src/compiler/preprocessor/Input.cpp")
project:addFile("src/compiler/preprocessor/Lexer.cpp")
project:addFile("src/compiler/preprocessor/Macro.cpp")
project:addFile("src/compiler/preprocessor/MacroExpander.cpp")
project:addFile("src/compiler/preprocessor/Preprocessor.cpp")
project:addFile("src/compiler/preprocessor/Token.cpp")
project:addFile("src/compiler/preprocessor/Tokenizer.cpp")
project:addFile("src/compiler/preprocessor/Diagnostics.h")
project:addFile("src/compiler/preprocessor/DirectiveHandler.h")
project:addFile("src/compiler/preprocessor/DirectiveParser.h")
project:addFile("src/compiler/preprocessor/ExpressionParser.h")
project:addFile("src/compiler/preprocessor/Input.h")
project:addFile("src/compiler/preprocessor/Lexer.h")
project:addFile("src/compiler/preprocessor/Macro.h")
project:addFile("src/compiler/preprocessor/MacroExpander.h")
project:addFile("src/compiler/preprocessor/numeric_lex.h")
project:addFile("src/compiler/preprocessor/pp_utils.h")
project:addFile("src/compiler/preprocessor/Preprocessor.h")
project:addFile("src/compiler/preprocessor/SourceLocation.h")
project:addFile("src/compiler/preprocessor/Token.h")
project:addFile("src/compiler/preprocessor/Tokenizer.h")
project:addFile("src/compiler/preprocessor/length_limits.h")
project:addFile("src/third_party/compiler/ArrayBoundsClamper.cpp")
project:addFile("src/compiler/BuiltInFunctionEmulator.cpp")
project:addFile("src/compiler/Compiler.cpp")
project:addFile("src/compiler/debug.cpp")
project:addFile("src/compiler/DetectCallDepth.cpp")
project:addFile("src/compiler/DetectRecursion.cpp")
project:addFile("src/compiler/Diagnostics.cpp")
project:addFile("src/compiler/DirectiveHandler.cpp")
project:addFile("src/compiler/ForLoopUnroll.cpp")
project:addFile("src/compiler/InfoSink.cpp")
project:addFile("src/compiler/Initialize.cpp")
project:addFile("src/compiler/InitializeDll.cpp")
project:addFile("src/compiler/InitializeParseContext.cpp")
project:addFile("src/compiler/Intermediate.cpp")
project:addFile("src/compiler/intermOut.cpp")
project:addFile("src/compiler/IntermTraverse.cpp")
project:addFile("src/compiler/MapLongVariableNames.cpp")
if platform == Platform.Windows then
project:addFile("src/compiler/ossource_win.cpp")
else
project:addFile("src/compiler/ossource_posix.cpp")
end
project:addFile("src/compiler/parseConst.cpp")
project:addFile("src/compiler/ParseHelper.cpp")
project:addFile("src/compiler/PoolAlloc.cpp")
project:addFile("src/compiler/QualifierAlive.cpp")
project:addFile("src/compiler/RemoveTree.cpp")
project:addFile("src/compiler/ShaderLang.cpp")
project:addFile("src/compiler/SymbolTable.cpp")
project:addFile("src/compiler/Uniform.cpp")
project:addFile("src/compiler/util.cpp")
project:addFile("src/compiler/ValidateLimitations.cpp")
project:addFile("src/compiler/VariableInfo.cpp")
project:addFile("src/compiler/VariablePacker.cpp")
project:addFile("src/compiler/glslang_lex.cpp")
project:addFile("src/compiler/glslang_tab.cpp")
project:addFile("src/compiler/depgraph/DependencyGraph.cpp")
project:addFile("src/compiler/depgraph/DependencyGraphBuilder.cpp")
project:addFile("src/compiler/depgraph/DependencyGraphOutput.cpp")
project:addFile("src/compiler/depgraph/DependencyGraphTraverse.cpp")
project:addFile("src/compiler/timing/RestrictFragmentShaderTiming.cpp")
project:addFile("src/compiler/timing/RestrictVertexShaderTiming.cpp")
project:addFile("src/compiler/BaseTypes.h")
project:addFile("src/compiler/BuiltInFunctionEmulator.h")
project:addFile("src/compiler/Common.h")
project:addFile("src/compiler/ConstantUnion.h")
project:addFile("src/compiler/debug.h")
project:addFile("src/compiler/DetectRecursion.h")
project:addFile("src/compiler/Diagnostics.h")
project:addFile("src/compiler/DirectiveHandler.h")
project:addFile("src/compiler/ForLoopUnroll.h")
project:addFile("src/compiler/InfoSink.h")
project:addFile("src/compiler/Initialize.h")
project:addFile("src/compiler/InitializeDll.h")
project:addFile("src/compiler/InitializeGlobals.h")
project:addFile("src/compiler/InitializeParseContext.h")
project:addFile("src/compiler/intermediate.h")
project:addFile("src/compiler/localintermediate.h")
project:addFile("src/compiler/MapLongVariableNames.h")
project:addFile("src/compiler/MMap.h")
project:addFile("src/compiler/osinclude.h")
project:addFile("src/compiler/ParseHelper.h")
project:addFile("src/compiler/PoolAlloc.h")
project:addFile("src/compiler/QualifierAlive.h")
project:addFile("src/compiler/RemoveTree.h")
project:addFile("src/compiler/RenameFunction.h")
project:addFile("include/GLSLANG/ResourceLimits.h")
project:addFile("include/GLSLANG/ShaderLang.h")
project:addFile("src/compiler/ShHandle.h")
project:addFile("src/compiler/SymbolTable.h")
project:addFile("src/compiler/Types.h")
project:addFile("src/compiler/util.h")
project:addFile("src/compiler/ValidateLimitations.h")
project:addFile("src/compiler/VariableInfo.h")
project:addFile("src/compiler/VariablePacker.h")
project:addFile("src/compiler/glslang_tab.h")
project:addFile("src/compiler/timing/RestrictFragmentShaderTiming.h")
project:addFile("src/compiler/timing/RestrictVertexShaderTiming.h")
project:addFile("src/compiler/depgraph/DependencyGraph.h")
project:addFile("src/compiler/depgraph/DependencyGraphBuilder.h")
project:addFile("src/compiler/depgraph/DependencyGraphOutput.h")
project:addFile("src/compiler/HashNames.h")
--project:addFile("src/compiler/CodeGenHLSL.cpp")
project:addFile("src/compiler/DetectDiscontinuity.cpp")
project:addFile("src/compiler/OutputHLSL.cpp")
project:addFile("src/compiler/SearchSymbol.cpp")
project:addFile("src/compiler/TranslatorHLSL.cpp")
project:addFile("src/compiler/UnfoldShortCircuit.cpp")
project:addFile("src/compiler/DetectDiscontinuity.h")
project:addFile("src/compiler/OutputHLSL.h")
project:addFile("src/compiler/SearchSymbol.h")
project:addFile("src/compiler/TranslatorHLSL.h")
project:addFile("src/compiler/UnfoldShortCircuit.h")
project:addFile("src/compiler/OutputGLSLBase.cpp")
project:addFile("src/compiler/OutputGLSL.cpp")
project:addFile("src/compiler/OutputESSL.cpp")
project:addFile("src/compiler/TranslatorGLSL.cpp")
project:addFile("src/compiler/TranslatorESSL.cpp")
project:addFile("src/compiler/VersionGLSL.cpp")
project:addFile("src/common/debug.cpp") | bsd-3-clause |
Colettechan/darkstar | scripts/zones/Ceizak_Battlegrounds/Zone.lua | 16 | 1206 | -----------------------------------
--
-- Zone: Ceizak Battlegrounds
--
-----------------------------------
require("scripts/globals/settings");
package.loaded["scripts/zones/Ceizak_Battlegrounds/TextIDs"] = nil;
require("scripts/zones/Ceizak_Battlegrounds/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(431,0,178,110);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/serving_of_emperor_roe.lua | 18 | 1339 | -----------------------------------------
-- ID: 4275
-- Item: serving_of_emperor_roe
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Health 8
-- Magic 8
-- Dexterity 4
-- Mind -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,1800,4275);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 8);
target:addMod(MOD_MP, 8);
target:addMod(MOD_DEX, 4);
target:addMod(MOD_MND, -4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 8);
target:delMod(MOD_MP, 8);
target:delMod(MOD_DEX, 4);
target:delMod(MOD_MND, -4);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Temenos/mobs/Enhanced_Dragon.lua | 26 | 1283 | -----------------------------------
-- Area: Temenos Central 1floor
-- NPC: Enhanced_Dragon
-----------------------------------
package.loaded["scripts/zones/Temenos/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Temenos/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
if (IsMobDead(16929051)==true) then
mob:addStatusEffect(EFFECT_REGAIN,7,3,0);
mob:addStatusEffect(EFFECT_REGEN,50,3,0);
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
if (IsMobDead(16929046)==true and IsMobDead(16929047)==true and IsMobDead(16929048)==true and IsMobDead(16929049)==true and IsMobDead(16929050)==true and IsMobDead(16929051)==true) then
GetNPCByID(16928768+71):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+71):setStatus(STATUS_NORMAL);
GetNPCByID(16928770+471):setStatus(STATUS_NORMAL);
end
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/spells/bio.lua | 1 | 2549 | -----------------------------------------
-- Spell: Bio
-- Deals dark damage that weakens an enemy's attacks and gradually reduces its HP.
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/magic");
require("scripts/globals/status");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
--calculate raw damage
local basedmg = caster:getSkillLevel(DARK_MAGIC_SKILL) / 4;
local dmg = calculateMagicDamage(basedmg,1,caster,spell,target,DARK_MAGIC_SKILL,MOD_INT,false);
-- Softcaps at 30, should always do at least 1
if (dmg > 30) then
dmg = 30;
end
if (dmg < 1) then
dmg = 1;
end
--get resist multiplier (1x if no resist)
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),DARK_MAGIC_SKILL,1.0);
--get the resisted damage
dmg = dmg*resist;
--add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
dmg = addBonuses(caster,spell,target,dmg);
--add in target adjustment
dmg = adjustForTarget(target,dmg,spell:getElement());
--add in final adjustments including the actual damage dealt
local final = finalMagicAdjustments(caster,target,spell,dmg);
-- Calculate duration.
local duration = 60;
-- Check for Dia & bio.
local dia = target:getStatusEffect(EFFECT_DIA);
-- Calculate DoT (rough, though fairly accurate)
local dotdmg = 2 + math.floor(caster:getSkillLevel(DARK_MAGIC_SKILL) / 20);
if (dotdmg > 12) then
dotdmg = 12;
end
if (caster:hasStatusEffect(EFFECT_DARK_ARTS) and caster:getMainJob() == JOBS.SCH) then
dotdmg = dotdmg * 1.5;
duration = duration * 2;
end
if (caster:hasStatusEffect(EFFECT_EBULLIENCE)) then
dotdmg = dotdmg * 1.5;
end
local params = {}; params.bonusmab = 0; params.includemab = true;
dotdmg = addBonusesAbility(caster, ELE_DARK, target, dotdmg, params, 1.0);
-- Do it!
if (BIO_OVERWRITE == 0 or (BIO_OVERWRITE == 1 and dia == nil)) then
target:addStatusEffect(EFFECT_BIO,dotdmg,3,duration,FLAG_ERASABLE, 5);
end
--Try to kill same tier Dia (default behavior)
if (DIA_OVERWRITE == 1 and dia ~= nil) then
if (dia:getPower() == 1) then
target:delStatusEffect(EFFECT_DIA);
end
end
return final;
end;
| gpl-3.0 |
JarnoVgr/InfectedWars | gamemode/cl_init.lua | 1 | 30217 | --[[-----------------------------------------------------------------------------
* 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.
-----------------------------------------------------------------------------]]
-- gm13 workaround
surface.OldCreateFont = surface.CreateFont
function surface.CreateFont(arg1,arg2,arg3,arg4,arg5,arg6)
--Call new style if there are only 2 arguments
if arg3 == nil then
surface.OldCreateFont(arg1,arg2)
return
end
local name = arg6-- [6]-- or "None"
local fontdata = {
font = arg1,-- [1],-- or "Arial",
size = arg2,-- [2],-- or 5,
weight = arg3,-- [3],-- or 500,
antialias = arg4,-- [4],-- or false,
additive = arg5,-- [5],-- or true,
}
surface.OldCreateFont(name,fontdata)
end
h = ScrH()
w = ScrW()
PlayerIsAdmin = false
HUD_ON = true
COLOR_RED = Color(180, 0, 0, 255)
COLOR_BLUE = Color(0, 0, 180, 255)
COLOR_GREEN = Color(0, 180, 0, 255)
COLOR_LIMEGREEN = Color(30, 180, 30, 255)
COLOR_YELLOW = Color(180, 180, 0, 255)
COLOR_WHITE = Color(255, 255, 255, 255)
COLOR_BLACK = Color(0, 0, 0, 255)
COLOR_ARMOR = Color(0,0,200,165)
COLOR_DARKBLUE = Color(10, 80, 180, 255)
COLOR_DARKGREEN = Color(0, 190, 0, 255)
COLOR_GRAY = Color(170, 170, 170, 255)
COLOR_DARKGRAY = Color(40, 40, 40, 255)
COLOR_HURT1 = Color( 0, 255, 255, 255 )
COLOR_HURT2 = Color( 128, 255, 142, 255 )
COLOR_HURT3 = Color( 255, 233, 127, 255 )
COLOR_HURT4 = Color( 255, 127, 127, 255 )
COLOR_HUMAN_LIGHT = Color( 85, 150, 200, 255 )
SOUND_POWERACTIVATE = Sound("items/battery_pickup.wav")
SOUND_WARNING = Sound("common/warning.wav")
TOTALGIBS = 0
surface.CreateFont("Tahoma", 16, 1000, true, false, "ScoreboardText" )
surface.CreateFont("DooM", 14, 500, true, false, "DoomSmaller")
surface.CreateFont("DooM", 18, 500, true, false, "DoomSmall")
surface.CreateFont("DooM", 24, 500, true, false, "DoomMedium")
surface.CreateFont("DooM", 40, 500, true, false, "DoomLarge")
surface.CreateFont("Arial", 14, 500, true, false, "InfoSmaller")
surface.CreateFont("Arial", 16, 500, true, false, "InfoSmall")
surface.CreateFont("Arial", 26, 500, true, false, "InfoMedium")
surface.CreateFont("Arial", 15, 700, true, false, "ArialB_15")
surface.CreateFont("Arial", 16, 700, true, false, "ArialB_16")
surface.CreateFont("Arial", 18, 700, true, false, "ArialB_18")
surface.CreateFont("Arial", 18, 500, true, false, "Arial1_18",false,false,1)
surface.CreateFont("Arial", 23, 500, true, false, "ArialBlur_23",false,false,1)
surface.CreateFont("Arial", 20, 700, true, false, "ArialB_20")
surface.CreateFont("Arial", 23, 700, true, false, "ArialB1_23")
surface.CreateFont("Arial", 22, 700, true, false, "ArialB_22")
surface.CreateFont("Arial", 26, 700, true, false, "ArialB_26")
surface.CreateFont("Birdman", 19, 700, true, false, "BrdB_19")
surface.CreateFont("Birdman", 18, 700, true, false, "BrdB_18")
surface.CreateFont("Arial", 65, 700, true, false, "ArialB_65")
surface.CreateFont("Arial", 50, 700, true, false, "ArialB_50")
surface.CreateFont("Arial", 40, 700, true, false, "ArialB_40")
surface.CreateFont("Arial", 36, 700, true, false, "ArialB_36")
surface.CreateFont("Courier New", 20, 500, true, false, "EndRoundStats")
include( 'sh_init.lua' )
include( 'cl_scoreboard.lua' )
include( 'cl_targetid.lua' )
include( 'cl_hudpickup.lua' )
include( 'cl_deathnotice.lua' )
include( 'cl_xrayvision.lua' )
include( 'cl_screeneffects.lua' )
include( 'cl_menu.lua' )
include( 'cl_radialmenu.lua' )
include( 'cl_hud.lua' )
include( 'greencoins/cl_greencoins.lua' )
include( 'debug/cl_debug.lua' )
CreateClientConVar("_iw_crosshair", 1, true, false)
CreateClientConVar("_iw_crosshaircolor", "Default", true, false)
CreateClientConVar("_iw_crosshairalpha", 200, true, false)
CreateClientConVar("_iw_clhands", 1, true, false)
CL_HANDS = util.tobool(GetConVarNumber("_iw_clhands"))
function ToggleHands( pl,commandName,args )
local MySelf = LocalPlayer()
CL_HANDS = util.tobool(args[1])
if CL_HANDS then
RunConsoleCommand("_iw_clhands","1")
MySelf:PrintMessage( HUD_PRINTTALK, "Custom hands enabled")
else
RunConsoleCommand("_iw_clhands","0")
MySelf:PrintMessage( HUD_PRINTTALK, "Custom hands disabled")
end
end
concommand.Add("iw_clhands",ToggleHands)
--[[---------------------------------------------------------
Name: gamemode:Initialize( )
Desc: Called immediately after starting the gamemode
---------------------------------------------------------]]
function GM:Initialize( )
timer.Create("adjusthud",1,0,function()
h = ScrH()
w = ScrW()
end) -- adjust HUD screen dimensions in case the user changes them
CrossInit()
CurCrosshair = GetConVarNumber("_iw_crosshair")
if not CROSSHAIR[CurCrosshair] then
CurCrosshair = 1
end
CurCrosshairColor = GetConVarString("_iw_crosshaircolor")
if not CROSSHAIRCOLORS[CurCrosshairColor] then
CurCrosshairColor = "Default"
end
RunConsoleCommand("_iw_crosshair",CurCrosshair)
RunConsoleCommand("_iw_crosshaircolor",CurCrosshairColor)
--Get changelog info
http.Fetch(CHANGELOG_HTTP,ApplyChangeLog)
self:InitializeVars()
end
function GM:InitializeVars()
self:InitializeMenuVars()
self.Reinforcements = 0
self.MaxReinforcements = 300 --keep it bigger to be sure that everything is fine :o
self.Voted = false
self.EquipedSuit = nil
ROUNDTIME = 0
ROUNDLENGTH = 0
ENDROUND = false
LASTHUMAN = false
--resync between server and client
if IsValid(MySelf) then
MySelf.Class, MySelf.MaxHP, MySelf.SP, MySelf.MaxSP, MySelf.CurPower = nil
end
GAMEMODE.LastHumanStart = 0
GAMEMODE.ShowScoreboard = false
statsreceived = false
stattimer = 0
MapList = {}
MapVotes = { curMap = 0, nextMap = 0, secondNextMap = 0 }
gui.EnableScreenClicker(false)
-- call PlayerEntitityStart when LocalPlayer is valid
timer.Create("playervalid",0.01,0,function()
if (LocalPlayer():IsValid()) then
GAMEMODE:PlayerEntityStart()
timer.Destroy("playervalid")
end
end)
end
function ApplyChangeLog(contents, size)
--HELP_TEXT[7].Text = contents
end
function RestartRound()
if DoXRay then
XRayToggle()
end
hook.Remove("RenderScreenspaceEffects", "DrawEnding")
GAMEMODE:InitializeVars()
end
usermessage.Hook("RestartRound", RestartRound)
function CapReinforcements(um)
local num = um:ReadShort()
if num then
GAMEMODE.MaxReinforcements = num
end
end
usermessage.Hook("SendMaxReinforcements", CapReinforcements)
function LastHuman()
if LASTHUMAN then return end
LASTHUMAN = true
GAMEMODE.LastHumanStart = CurTime()
-- deactivate radio
RunConsoleCommand("stopsound")
timer.Destroy("playtimer")
timer.Destroy("nextplaytimer")
if MUSIC_ENABLED then
timer.Simple(0.1,function() surface.PlaySound(LASTSTANDMUSIC) end)
end
hook.Add("HUDPaint","LastHumanP",LastHumanPaint)
end
usermessage.Hook("lasthuman", LastHuman)
/*--------------------------------------------------
-- This function is called when localplayer() is valid
--------------------------------------------------*/
MySelf = nil
function GM:PlayerEntityStart( )
-- recieve the maplist
if (PlayerIsAdmin) then
RunConsoleCommand("get_maplist")
end
-- set up defaults for current players
for k, v in pairs(player.GetAll()) do
v.TitleText = v.TitleText or "Guest"
v.Class = v.Class or 0
v.Detectable = v.Detectable or false
end
-- Since the player is now valid, receive data
RunConsoleCommand("data_synchronize")
timer.Create("datachecktimer",4,0,CheckData)
MySelf = LocalPlayer()
MySelf.Class = MySelf.Class or 0
MySelf.MaxHP = MySelf.MaxHP or 100
MySelf.SP = MySelf.SP or 100
MySelf.MaxSP = MySelf.MaxSP or 100
MySelf.CurPower = MySelf.CurPower or 0
MySelf.TitleText = MySelf.TitleText or "Guest"
MySelf.PreferBehemoth = true
MySelf.TurretStatus = TurretStatus.inactive
if RadioOn then
RadioPlay(math.random(1,#Radio))
MySelf:PrintMessage(HUD_PRINTTALK,"Radio can be turned off in the Options panel (F3)")
end
end
function CheckData()
-- Double check if all data has been received
local check = false
for k, pl in pairs(player.GetAll()) do
if (pl.TitleText == nil or pl.Class == 0 or pl.Detectable == nil) and (pl:Team() == TEAM_HUMAN or pl:Team() == TEAM_UNDEAD) then
check = true
end
end
if check then
RunConsoleCommand("data_synchronize")
end
end
--Force artistic Derma skin
function GM:ForceDermaSkin()
return "iw_skin"
end
--[[---------------------------------------------------------
Name: gamemode:InitPostEntity( )
Desc: Called as soon as all map entities have been spawned
---------------------------------------------------------]]
function GM:InitPostEntity( )
end
--[[---------------------
Calling late deploy
----------------------]]
function CallLateDeploy()
-- Call the deploy function (to apply the materials)
-- Needed because deploy isn't called when player spawn for the first time
--[[timer.Simple(0.01,function()
if LocalPlayer():GetActiveWeapon().Deploy then
LocalPlayer():GetActiveWeapon():Deploy()
end
end)]]
end
--[[---------------------------------------------------------
Name: gamemode:Think( )
Desc: Called every frame
---------------------------------------------------------]]
local WaterDraintimer = 0
function GM:Think()
if WaterDraintimer < CurTime() then
WaterDraintimer = CurTime()+1
local MySelf = LocalPlayer() -- Decrement suit power when under water
if MySelf:WaterLevel() > 1 then
RunConsoleCommand("decrement_suit",math.Clamp(math.ceil(MySelf:WaterLevel())*2,1,6))
if MySelf:SuitPower() <= 0 and MySelf:Team() == TEAM_HUMAN then
RunConsoleCommand("drown_me",3)
end
end
end
end
--[[---------------------------------------------------------
Name: gamemode:PlayerDeath( )
Desc: Called when a player dies. If the attacker was
a player then attacker will become a Player instead
of an Entity.
---------------------------------------------------------]]
function GM:PlayerDeath( ply, attacker )
end
--------- Radio functions -----------------
CreateClientConVar("_iw_enableradio", 1, true, false)
RadioOn = util.tobool(GetConVarNumber("_iw_enableradio"))
for k=1, #Radio do
util.PrecacheSound(Radio[k][1])
end
CurPlaying = 1
function RadioPlay_old( nr )
RunConsoleCommand("stopsound")
timer.Destroy("playtimer")
timer.Destroy("nextplaytimer")
if (nr > #Radio) then
nr = 1
end
print("Switching to song "..nr)
RadioOn = true
--seems the timers fail to create when they're also destroyed earlier in the same function :/
timer.Simple(0.1,function()
timer.Create("playtimer",0.1, 1, function( the_nr )
print("Playing song "..the_nr)
surface.PlaySound( the_nr ) end,
Radio[nr][1])
timer.Create("nextplaytimer",tonumber(Radio[nr][2])+3, 1, function(nextnr)
if RadioOn then
--RadioPlay( nextnr )
end
end, nr+1)
end)
CurPlaying = nr
end
CurSong = 1
--NextSong = 0
function HandleRadio()
if LASTHUMAN then
return
end
if RadioOn then
if NextSong and NextSong < CurTime() then
RunConsoleCommand("stopsound")
if CurSong > #Radio then
CurSong = 1
end
local toplay = CurSong
timer.Simple(0.1,function()
print("Switching to song "..Radio[toplay][1])
surface.PlaySound(Radio[toplay][1])
end)
NextSong = CurTime() + tonumber(Radio[toplay][2]) + 2
CurSong = CurSong + 1
end
end
end
hook.Add("Think", "Radio", HandleRadio)
NextDelay = 0
function RadioPlay( nr )
if NextDelay > CurTime() then
return
end
NextDelay = CurTime() + 0.3
RunConsoleCommand("stopsound")
RadioOn = true
if (nr > #Radio) then
nr = 1
end
CurSong = nr
NextSong = 0 --CurTime() + tonumber(Radio[CurSong][2]) + 2
--[[timer.Simple(0.1,function()
print("Playing song "..Radio[CurSong][1])
surface.PlaySound(Radio[CurSong][1])
end)]]
end
function ToggleRadio( pl,commandName,args )
local MySelf = LocalPlayer()
local org = RadioOn
RadioOn = util.tobool(args[1])
RunConsoleCommand("stopsound")
if RadioOn then
RunConsoleCommand("_iw_enableradio","1")
if not Org then
MySelf:PrintMessage( HUD_PRINTTALK, "Radio on")
end
RadioPlay(tonumber(args[2]))
else
RunConsoleCommand("_iw_enableradio","0")
if Org then
MySelf:PrintMessage( HUD_PRINTTALK, "Radio off")
end
--timer.Destroy("playtimer")
--timer.Destroy("nextplaytimer")
end
end
concommand.Add("iw_enableradio",ToggleRadio)
--[[---------------------------------------------------------
Name: gamemode:KeyPress( )
Desc: Player pressed a key (see IN enums)
---------------------------------------------------------]]
function GM:KeyPress( player, key )
end
---- XRay timer works similiar, see xrayvision.lua -----
local Stimer = 0
local Sstep = SPEED_TIMER
local function SpeedThink()
local MySelf = LocalPlayer()
-- If your suit power is 0, turn of Xray
if (MySelf:GetPower() == 1) then
if (MySelf:SuitPower() <= 0) then
surface.PlaySound( SOUND_WARNING )
MySelf:SetPower( 3 ) -- turn off the power
else
-- Else, keep draining suit power (if we're truly running fast enough that is)
if (Stimer <= CurTime()) then
Stimer = CurTime()+Sstep
if (MySelf:GetVelocity():Length() > 100) then
local cost = HumanPowers[1].Cost
if MySelf:HasBought("duracell2") then
cost = cost * 0.75
end
if MySelf.EquipedSuit == "scoutsspeedpack" then
cost = cost * 0.5
end
RunConsoleCommand("decrement_suit",tostring(cost))
end
end
end
end
end
hook.Add("Think", "SpeedCheck", SpeedThink)
--[[---------------------------------------------------------
Name: gamemode:KeyRelease( )
Desc: Player released a key (see IN enums)
---------------------------------------------------------]]
function GM:KeyRelease( player, key )
end
local nextjump = 0
function GM:PlayerBindPress( pl, bind, pressed )
if (bind == "+use" and pl:Alive() and pl:Team() == TEAM_UNDEAD and not pl:IsOnGround() and pl:GetPlayerClass() == CLASS_Z_BONES
and pl:HasBought("deathpursuit") and nextjump < CurTime()) then
local trace = pl:GetEyeTrace()
if trace.Entity and trace.Entity:IsPlayer() and trace.Entity:Team() == TEAM_HUMAN then
RunConsoleCommand("_iw_forceboost",trace.Entity:EntIndex())
nextjump = CurTime()+2
end
end
if string.find( bind, "zoom" ) then return true end
end
--[[---------------------------------------------------------
Unlock achievement
---------------------------------------------------------]]
local unlockSound = Sound("weapons/physcannon/energy_disintegrate5.wav")
local achvStack = 0
local achievTime = 0
function DrawAchievement()
endX = w/2-200
endY = h/2-150
textEndX = w/2-90
textEndY = h/2-150
achievAlpha = achievAlpha or 255
achievX = achievX or {}
achievY = achievY or {}
achievX[1] = achievX[1] or endX-w -- four text location
achievY[1] = achievY[1] or endY
achievX[2] = achievX[2] or endX+w
achievY[2] = achievY[2] or endY
achievX[3] = achievX[3] or endX
achievY[3] = achievY[3] or endY-h
achievX[4] = achievX[4] or endX
achievY[4] = achievY[4] or endY+h
achievX[5] = achievX[5] or endX-w -- image location
achievY[5] = achievY[5] or endY
col = Color(255,255,255,achievAlpha)
col2 = Color(0,0,0,achievAlpha)
local rand = 0
local rand2 = 0
for k=1, 4 do
rand = -2+math.Rand(0,4)
rand2 = -2+math.Rand(0,4)
if k == 4 then
rand = 0
rand2 = 0
end
draw.SimpleTextOutlined("Achievement Unlocked!","DoomSmall",achievX[k]+rand,achievY[k]+rand2,col, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, col2)
draw.SimpleTextOutlined(achievName,"DoomMedium",achievX[k]+rand,achievY[k]+20+rand2,col, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, col2)
if achievLoadout ~= "" then
draw.SimpleTextOutlined(achievLoadout,"DoomSmall",achievX[k]+rand,achievY[k]+50+rand2,col, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, col2)
end
end
surface.SetTexture( achievImage )
surface.SetDrawColor( col )
surface.DrawTexturedRect( achievX[5], achievY[5],100,100 )
for k=1,4 do
achievX[k] = math.Approach(achievX[k], textEndX, w*3*FrameTime())
achievY[k] = math.Approach(achievY[k], textEndY, h*3*FrameTime())
end
achievX[5] = math.Approach(achievX[5], endX, w*3*FrameTime())
achievY[5] = math.Approach(achievY[5], endY, h*3*FrameTime())
if (achievTime < CurTime()+1) then
achievAlpha = math.Approach(achievAlpha, 0, 255*FrameTime())
end
if (achievTime < CurTime()) then
hook.Remove("HUDPaint","DrawAchievement")
for k=1, 5 do
achievX[k] = nil
achievY[k] = nil
achievAlpha = nil
end
end
end
function IdentifyUnlock( stat )
local display = false
local code = {}
local disp = {}
local retstr = ""
for k, v in pairs(unlockData) do
if table.HasValue(v,stat) then
display = true
for i, j in pairs(v) do
if not LocalPlayer().DataTable["achievements"][j] then
display = false
break
end
end
if display == true then
table.insert(code,k)
display = false
end
end
end
local tab = {}
table.Add(tab,HumanClass)
table.Add(tab,UndeadClass)
if #code > 0 then
for k, v in pairs(tab) do
for i, j in pairs(v.SwepLoadout) do
if table.HasValue(code,j.UnlockCode) then
table.insert(disp,j.Name)
end
end
end
retstr = "Unlocked loadout: "
if #disp > 0 then
for y=1, #disp do
retstr = retstr..disp[y]
if y < #disp then
retstr = retstr..", "
end
end
end
return retstr
end
return ""
end
function UnlockEffect( achv )
achvStack = achvStack+1
if achievTime < CurTime() then
LocalPlayer().DataTable["achievements"][achv] = true
achvStack = achvStack-1
achievName = achievementDesc[achv].Name
achievImage = surface.GetTextureID(achievementDesc[achv].Image)
achievTime = CurTime()+5
surface.PlaySound(unlockSound)
achievLoadout = IdentifyUnlock( achv )
hook.Add("HUDPaint","DrawAchievement",DrawAchievement)
else
timer.Simple((achievTime-CurTime()+0.2)+5*(achvStack-1),function( str )
UnlockEffect(str)
achvStack = achvStack-1
end,achv) -- Achievement display delays
end
end
-- Receive max health status
local function SetMaxHealth(um)
local ent = um:ReadEntity()
ent.MaxHP = um:ReadShort()
end
usermessage.Hook("SetMaxHP", SetMaxHealth)
-- Receive suit power status
local function SetSuitPower(um)
local MySelf = LocalPlayer()
MySelf.SP = um:ReadShort()
end
usermessage.Hook("SetSP", SetSuitPower)
-- Receive max suit power status
local function SetMaxSuitPower(um)
local MySelf = LocalPlayer()
MySelf.MaxSP = um:ReadShort()
end
usermessage.Hook("SetMaxSP", SetMaxSuitPower)
-- Receive class status
local function RecClass(um)
local ent = um:ReadEntity()
if ent:IsValid() then
ent.Class = um:ReadShort()
end
end
usermessage.Hook("SetClass", RecClass)
-- Receive power status
local function RecPower(um)
local MySelf = LocalPlayer()
MySelf.CurPower = um:ReadShort()
local pf = {
[0] = { 0, 150, 150 },
[1] = { 150, 0, 0 },
[2] = { 0, 0, 150 },
[3] = { 150, 150, 0 }
}
local pf2 = {
[0] = { 255, 255, 255 },
[1] = { 150, 0, 0 },
[2] = { 0, 0, 250 },
[3] = { 255, 255, 255 }
}
CreatePowerFlash( pf[MySelf.CurPower][1], pf[MySelf.CurPower][2], pf[MySelf.CurPower][3] )
SuitBar.col = pf2[MySelf.CurPower]
if MySelf.CurPower == 0 then
PlugSuitBar(false)
PlugHealthBar(false)
else
PlugSuitBar(true)
if MySelf.CurPower == 3 then
PlugHealthBar(true)
else
PlugHealthBar(false)
end
end
-- Toggle XRay (it will only activate if player has Vision power)
RunConsoleCommand("toggle_xrayvision")
end
usermessage.Hook("SetPower", RecPower)
-- Receive detectability
local function RecDetect(um)
local ent = um:ReadEntity()
if ent:IsValid() then
ent.Detectable = um:ReadBool()
end
end
usermessage.Hook("SetDetectable", RecDetect)
-- Receive title
local function RecTitle(um)
local ent = um:ReadEntity()
if ent:IsValid() then
ent.TitleText = um:ReadString()
end
end
usermessage.Hook("SetTitle", RecTitle)
-- Receive player admin status locally
local function SetPlayerIsAdmin(um)
PlayerIsAdmin = um:ReadBool()
end
usermessage.Hook("SetAdmin", SetPlayerIsAdmin)
-- receive data like title text, class, and max hp in one go
local function SetData(um)
local amount = um:ReadShort()
local ent
local pl
for k=1,amount do
pl = um:ReadEntity()
pl.TitleText = um:ReadString()
pl.Class = um:ReadShort()
pl.Detectable = um:ReadBool()
end
end
usermessage.Hook("SetData", SetData)
-- receive all recorded data
local function SetRecordData(um)
local pl = um:ReadEntity()
if not pl.DataTable then
pl.DataTable = {{}}
pl.DataTable["achievements"] = {}
pl.DataTable["shopitems"] = {}
end
for k, v in pairs(recordData) do
pl.DataTable[k] = um:ReadString()
end
for k, v in pairs(achievementDesc) do
pl.DataTable["achievements"][k] = um:ReadBool()
end
pl.StatsReceived = true
end
usermessage.Hook("SetRecordData", SetRecordData)
-- Receive map list
MapList = {}
local function ReceiveMapList(um)
local index = um:ReadShort()
local map = um:ReadString()
map = string.gsub(map,".bsp","")
MapList[index] = map
end
usermessage.Hook("RcMapList", ReceiveMapList)
-- Timer function
function GM:RoundTimeLeft()
return( math.Clamp( ROUNDTIME - CurTime(), 0, ROUNDLENGTH) )
end
local function SynchronizeTime(um)
ROUNDLENGTH = um:ReadShort()
ROUNDTIME = um:ReadLong()
end
usermessage.Hook("SendTime", SynchronizeTime)
local function SynchronizeReinforcements(um)
GAMEMODE.Reinforcements = um:ReadShort()
GAMEMODE.MaxReinforcements = um:ReadShort()
end
usermessage.Hook("SendReinforce", SynchronizeReinforcements)
statsreceived = false
stattimer = 0
local function SetStats(um)
StatsUndKiller = um:ReadString()
StatsHumKiller = um:ReadString()
StatsUndDmg = um:ReadString()
StatsHumDmg = um:ReadString()
StatsMostSocial = um:ReadString()
StatsMostScary = um:ReadString()
StatsMostUnlucky = um:ReadString()
StatsRoundKills = um:ReadString()
StatsRoundDamage = um:ReadString()
statsreceived = true
stattimer = CurTime() + 7
end
usermessage.Hook("SendTopStats", SetStats)
function PrintWeapons()
for k, v in pairs(LocalPlayer():GetWeapons()) do
Msg(v:GetPrintName().."\n")
end
end
/*--------------------------------------------------------
Called when the round ends
--------------------------------------------------------*/
local function EndRound( um )
GAMEMODE.TeamThatWon = um:ReadShort()
GAMEMODE.ShowVoting = um:ReadBool()
if GAMEMODE.ShowVoting then
GAMEMODE.CanRestart = um:ReadBool()
GAMEMODE.CurMap = um:ReadString()
GAMEMODE.NextMap = um:ReadString()
GAMEMODE.SecondNextMap = um:ReadString()
end
ENDROUND = true
gui.EnableScreenClicker(true)
LocalPlayer().Voted = 0
VoteBox = nil
NextSong = nil
RunConsoleCommand("stopsound")
if MUSIC_ENABLED then
--stop radio
timer.Destroy("playtimer")
timer.Destroy("nextplaytimer")
local song = HUMANWINMUSIC
if GAMEMODE.TeamThatWon == TEAM_UNDEAD then
song = UNDEADWINMUSIC
end
timer.Simple(0.1,function( ms ) surface.PlaySound(ms) end,song)
end
hook.Add("RenderScreenspaceEffects", "DrawEnding", DrawEnding)
-- Close all derma frames
CloseFrames()
end
usermessage.Hook("GameEndRound", EndRound)
function SyncVotes( um )
if not GAMEMODE.ShowVoting then return end
MapVotes = { curMap = 0, nextMap = 0, secondNextMap = 0 }
MapVotes.curMap = um:ReadShort()
MapVotes.nextMap = um:ReadShort()
MapVotes.secondNextMap = um:ReadShort()
end
usermessage.Hook("SynchronizeVotes", SyncVotes)
GM.MapExploits = {}
-- receive map exploit locations
function RecMapExploits( um )
local tab = {}
local reset = um:ReadBool()
if reset == true then
GAMEMODE.MapExploits = {}
end
local number = um:ReadShort()
local start = um:ReadShort()
for k=1, number do
tab = {}
tab.origin = um:ReadVector()
tab.bsize = um:ReadShort()
tab.type = um:ReadString()
GAMEMODE.MapExploits[start+k-1] = tab
number = number + 1
end
end
usermessage.Hook("mapexploits",RecMapExploits)
function RecMapExploitsSingle( um )
local tab = {}
tab.origin = um:ReadVector()
tab.bsize = um:ReadShort()
tab.type = um:ReadString()
table.insert(GAMEMODE.MapExploits,tab)
end
usermessage.Hook("mapexploitssingle",RecMapExploitsSingle)
// Receive shop data
local function SetShopData(um)
MySelf = LocalPlayer()
if not MySelf.DataTable then
MySelf.DataTable = {{}}
MySelf.DataTable["achievements"] = {}
MySelf.DataTable["shopitems"] = {}
end
for k, v in pairs(shopData) do
MySelf.DataTable["shopitems"][k] = um:ReadBool()
end
end
usermessage.Hook("SetShopData", SetShopData)
/*---------------------------------------------------------
Name: gamemode:CreateMove( command )
Desc: Allows the client to change the move commands
before it's send to the server
---------------------------------------------------------*/
function GM:CreateMove( cmd )
end
/*---------------------------------------------------------
Name: gamemode:GUIMouseReleased( mousecode )
Desc: The mouse has been released on the game screen
---------------------------------------------------------*/
function GM:GUIMouseReleased( mousecode, AimVector )
hook.Call( "CallScreenClickHook", GAMEMODE, false, mousecode, AimVector )
end
/*---------------------------------------------------------
Name: gamemode:ShutDown( )
Desc: Called when the Lua system is about to shut down
---------------------------------------------------------*/
function GM:ShutDown( )
end
/*---------------------------------------------------------
Name: gamemode:RenderScreenspaceEffects( )
Desc: Bloom etc should be drawn here (or using this hook)
---------------------------------------------------------*/
function GM:RenderScreenspaceEffects()
end
/*---------------------------------------------------------
Name: gamemode:GetTeamColor( ent )
Desc: Return the color for this ent's team
This is for chat and deathnotice text
---------------------------------------------------------*/
function GM:GetTeamColor( ent )
local team = TEAM_UNASSIGNED
if (ent.Team) then team = ent:Team() end
return GAMEMODE:GetTeamNumColor( team )
end
function RestoreViewmodel(pl)
timer.Simple ( 0.1, function()
local MySelf = LocalPlayer()
if MySelf:IsValid() then
if MySelf ~= pl then return end
local wep = MySelf:GetActiveWeapon()
if wep then
if !wep.Base or (wep.Base and not string.find(wep.Base,"iw_")) then
local vm = MySelf:GetViewModel()
if vm and vm:IsValid() then
vm:SetColor(255, 255, 255, 255)
end
end
end
end
end )
end
/*---------------------------------------------------------
Name: ChatText
Allows override of the chat text
---------------------------------------------------------*/
function GM:ChatText( playerindex, playername, text, filter )
if ( filter == "chat" ) then
Msg( playername, ": ", text, "\n" )
else
Msg( text, "\n" )
end
return false
end
/*---------------------------------------------------------
Name: gamemode:PostProcessPermitted( str )
Desc: return true/false depending on whether this post process should be allowed
---------------------------------------------------------*/
function GM:PostProcessPermitted( str )
return true
end
/*---------------------------------------------------------
Name: gamemode:PostRenderVGUI( )
Desc: Called after VGUI has been rendered
---------------------------------------------------------*/
function GM:PostRenderVGUI()
end
/*---------------------------------------------------------
Name: gamemode:RenderScene( )
Desc: Render the scene
---------------------------------------------------------*/
function GM:RenderScene()
end
/*---------------------------------------------------------
Name: CalcView
Allows override of the default view
---------------------------------------------------------*/
function GM:CalcView( ply, origin, angles, fov )
local MySelf = LocalPlayer()
local wep = ply:GetActiveWeapon()
-- Places eyes in ragdoll entity
if MySelf:GetRagdollEntity() then
local phys = MySelf:GetRagdollEntity():GetPhysicsObjectNum(12)
local ragdoll = MySelf:GetRagdollEntity()
if ragdoll then
local lookup = MySelf:LookupAttachment("eyes")
if lookup then
local attach = ragdoll:GetAttachment(lookup)
if attach then
return {origin=attach.Pos, angles=attach.Ang}
end
end
end
end
local view = {}
view.origin = origin
view.angles = angles
view.fov = fov
// Give the active weapon a go at changing the viewmodel position
if ( IsValid( wep ) ) then
local func = wep.GetViewModelPosition
if ( func ) then
view.vm_origin, view.vm_angles = func( wep, origin*1, angles*1 ) // Note: *1 to copy the object so the child function can't edit it.
end
local func = wep.CalcView
if ( func ) then
view.origin, view.angles, view.fov = func( wep, ply, origin*1, angles*1, fov ) // Note: *1 to copy the object so the child function can't edit it.
end
end
return view
end
/*---------------------------------------------------------
Name: gamemode:PreDrawTranslucent( )
Desc: Called before drawing translucent entities
---------------------------------------------------------*/
function GM:PreDrawTranslucent()
end
/*---------------------------------------------------------
Name: gamemode:PostDrawTranslucent( )
Desc: Called after drawing translucent entities
---------------------------------------------------------*/
function GM:PostDrawTranslucent()
end
/*---------------------------------------------------------
Name: gamemode:PreDrawOpaque( )
Desc: Called before drawing opaque entities
---------------------------------------------------------*/
function GM:PreDrawOpaque()
end
/*---------------------------------------------------------
Name: gamemode:PostDrawOpaque( )
Desc: Called after drawing opaque entities
---------------------------------------------------------*/
function GM:PostDrawOpaque()
end
| mit |
Vadavim/jsr-darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Renten-Tonten.lua | 14 | 1066 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Renten-Tonten
-- Type: Standard NPC
-- @zone 94
-- @pos 133.840 -6.75 173.305
--
-- 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(0x01a5);
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/piece_of_cascade_candy.lua | 18 | 1175 | -----------------------------------------
-- ID: 5942
-- Item: Piece of Cascade Candy
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Mind +4
-- Charisma +4
-----------------------------------------
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,1800,5942);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_MND, 4);
target:addMod(MOD_CHR, 4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_MND, 4);
target:delMod(MOD_CHR, 4);
end;
| gpl-3.0 |
Ali-2h/iranibot | plugins/minecraft.lua | 624 | 2605 | local usage = {
"!mine [ip]: Searches Minecraft server on specified ip and sends info. Default port: 25565",
"!mine [ip] [port]: Searches Minecraft server on specified ip and port and sends info.",
}
local ltn12 = require "ltn12"
local function mineSearch(ip, port, receiver) --25565
local responseText = ""
local api = "https://api.syfaro.net/server/status"
local parameters = "?ip="..(URL.escape(ip) or "").."&port="..(URL.escape(port) or "").."&players=true&favicon=true"
local http = require("socket.http")
local respbody = {}
local body, code, headers, status = http.request{
url = api..parameters,
method = "GET",
redirect = true,
sink = ltn12.sink.table(respbody)
}
local body = table.concat(respbody)
if (status == nil) then return "ERROR: status = nil" end
if code ~=200 then return "ERROR: "..code..". Status: "..status end
local jsonData = json:decode(body)
responseText = responseText..ip..":"..port.." ->\n"
if (jsonData.motd ~= nil) then
local tempMotd = ""
tempMotd = jsonData.motd:gsub('%§.', '')
if (jsonData.motd ~= nil) then responseText = responseText.." Motd: "..tempMotd.."\n" end
end
if (jsonData.online ~= nil) then
responseText = responseText.." Online: "..tostring(jsonData.online).."\n"
end
if (jsonData.players ~= nil) then
if (jsonData.players.max ~= nil) then
responseText = responseText.." Max Players: "..jsonData.players.max.."\n"
end
if (jsonData.players.now ~= nil) then
responseText = responseText.." Players online: "..jsonData.players.now.."\n"
end
if (jsonData.players.sample ~= nil and jsonData.players.sample ~= false) then
responseText = responseText.." Players: "..table.concat(jsonData.players.sample, ", ").."\n"
end
end
if (jsonData.favicon ~= nil and false) then
--send_photo(receiver, jsonData.favicon) --(decode base64 and send)
end
return responseText
end
local function parseText(chat, text)
if (text == nil or text == "!mine") then
return usage
end
ip, port = string.match(text, "^!mine (.-) (.*)$")
if (ip ~= nil and port ~= nil) then
return mineSearch(ip, port, chat)
end
local ip = string.match(text, "^!mine (.*)$")
if (ip ~= nil) then
return mineSearch(ip, "25565", chat)
end
return "ERROR: no input ip?"
end
local function run(msg, matches)
local chat_id = tostring(msg.to.id)
local result = parseText(chat_id, msg.text)
return result
end
return {
description = "Searches Minecraft server and sends info",
usage = usage,
patterns = {
"^!mine (.*)$"
},
run = run
} | gpl-2.0 |
pando85/telegram-bot | plugins/minecraft.lua | 624 | 2605 | local usage = {
"!mine [ip]: Searches Minecraft server on specified ip and sends info. Default port: 25565",
"!mine [ip] [port]: Searches Minecraft server on specified ip and port and sends info.",
}
local ltn12 = require "ltn12"
local function mineSearch(ip, port, receiver) --25565
local responseText = ""
local api = "https://api.syfaro.net/server/status"
local parameters = "?ip="..(URL.escape(ip) or "").."&port="..(URL.escape(port) or "").."&players=true&favicon=true"
local http = require("socket.http")
local respbody = {}
local body, code, headers, status = http.request{
url = api..parameters,
method = "GET",
redirect = true,
sink = ltn12.sink.table(respbody)
}
local body = table.concat(respbody)
if (status == nil) then return "ERROR: status = nil" end
if code ~=200 then return "ERROR: "..code..". Status: "..status end
local jsonData = json:decode(body)
responseText = responseText..ip..":"..port.." ->\n"
if (jsonData.motd ~= nil) then
local tempMotd = ""
tempMotd = jsonData.motd:gsub('%§.', '')
if (jsonData.motd ~= nil) then responseText = responseText.." Motd: "..tempMotd.."\n" end
end
if (jsonData.online ~= nil) then
responseText = responseText.." Online: "..tostring(jsonData.online).."\n"
end
if (jsonData.players ~= nil) then
if (jsonData.players.max ~= nil) then
responseText = responseText.." Max Players: "..jsonData.players.max.."\n"
end
if (jsonData.players.now ~= nil) then
responseText = responseText.." Players online: "..jsonData.players.now.."\n"
end
if (jsonData.players.sample ~= nil and jsonData.players.sample ~= false) then
responseText = responseText.." Players: "..table.concat(jsonData.players.sample, ", ").."\n"
end
end
if (jsonData.favicon ~= nil and false) then
--send_photo(receiver, jsonData.favicon) --(decode base64 and send)
end
return responseText
end
local function parseText(chat, text)
if (text == nil or text == "!mine") then
return usage
end
ip, port = string.match(text, "^!mine (.-) (.*)$")
if (ip ~= nil and port ~= nil) then
return mineSearch(ip, port, chat)
end
local ip = string.match(text, "^!mine (.*)$")
if (ip ~= nil) then
return mineSearch(ip, "25565", chat)
end
return "ERROR: no input ip?"
end
local function run(msg, matches)
local chat_id = tostring(msg.to.id)
local result = parseText(chat_id, msg.text)
return result
end
return {
description = "Searches Minecraft server and sends info",
usage = usage,
patterns = {
"^!mine (.*)$"
},
run = run
} | gpl-2.0 |
Vadavim/jsr-darkstar | scripts/globals/mobskills/Water_Shield.lua | 1 | 1308 | ---------------------------------------------
-- Water Shield
--
-- Description: Enhances evasion.
-- Type: Enhancing
-- Utsusemi/Blink absorb: N/A
-- Range: Self
-- Notes: Very sharp evasion increase.
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:hasStatusEffect(EFFECT_EVASION_BOOST) or mob:hasStatusEffect(EFFECT_DEFENSE_BOOST)) then
return 1;
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local hard = mob:getMobMod(MOBMOD_HARD_MODE);
local typeEffect = EFFECT_EVASION_BOOST;
skill:setMsg(MobBuffMove(mob, typeEffect, 40, 0, 30));
local effect = mob:getStatusEffect(EFFECT_EVASION_BOOST);
if (effect ~= nil) then
effect:addMod(MOD_FIREDEF, 60);
target:addMod(MOD_FIREDEF, 60);
effect:addMod(MOD_THUNDERDEF, -60);
target:addMod(MOD_THUNDERDEF, -60);
end
if (hard > 0) then
if (effect ~= nil) then
local power = 20 + hard * 10;
effect:addMod(MOD_MEVA, power);
target:addMod(MOD_MEVA, power);
end
end
return typeEffect;
end;
| gpl-3.0 |
lcf8858/Sample_Lua | src/anysdkConst.lua | 2 | 7269 | Plugin_type = {
kPluginAds = 16,
kPluginAnalytics = 1,
kPluginIAP = 8,
kPluginShare = 4,
kPluginUser = 32,
kPluginSocial = 2,
kPluginPush = 64
}
-- for ads
AdsResultCode = {
kAdsReceived = 0, --enum value is callback of ad is received at center.
kAdsShown = 1, --enum value is callback of advertisement shown.
kAdsDismissed = 2, --enum value is callback of advertisement dismissed.
kPointsSpendSucceed = 3, --enum value is callback of points spend succeed.
kPointsSpendFailed = 4, --enum value is callback of points spend failed.
kNetworkError = 5, --enum value is callback of network error at center.
kUnknownError = 6, --enum value is callback of unknown error.
kOfferWallOnPointsChanged = 7, --enum value is callback of changing the point of offerwall.
kAdsExtension = 40000 --enum value is extension code.
} --ads result code
AdsPos = {
kPosCenter = 0, --enum the toolbar is at center.
kPosTop = 1, --enum the toolbar is at top.
kPosTopLeft = 2, --enum the toolbar is at topleft.
kPosTopRight = 3, --enum the toolbar is at topright.
kPosBottom = 4, --enum the toolbar is at bottom.
kPosBottomLeft = 5, --enum the toolbar is at bottomleft.
kPosBottomRight = 6 --enum the toolbar is at bottomright.
} --ads pos
AdsType = {
AD_TYPE_BANNER = 0, --enum value is banner ads.
AD_TYPE_FULLSCREEN = 1, --enum value is fullscreen ads.
AD_TYPE_MOREAPP = 2, --enum value is moreapp ads.
AD_TYPE_OFFERWALL = 3 --enum value is offerwall ads.
} --ads type
--for pay result code
PayResultCode = {
kPaySuccess = 0, --enum value is callback of succeeding in paying.
kPayFail = 1, --enum value is callback of failing to pay.
kPayCancel = 2, --enum value is callback of canceling to pay.
kPayNetworkError = 3, --enum value is callback of network error.
kPayProductionInforIncomplete = 4, --enum value is callback of incomplete info.
kPayInitSuccess = 5, --enum value is callback of succeeding in initing sdk.
kPayInitFail = 6, --enum value is callback of failing to init sdk.
kPayNowPaying = 7, --enum value is callback of paying now.
kPayRechargeSuccess = 8, --enum value is callback of succeeding in recharging.
kPayExtension = 30000 --enum value is extension code.
}
-- for push action result code
PushActionResultCode = {
kPushReceiveMessage = 0, --enum value is callback of receiving message.
kPushExtensionCode = 60000 --enum value is extension code.
}
-- for share result code
ShareResultCode = {
kShareSuccess = 0, --enum value is callback of succeeding in sharing.
kShareFail = 1, --enum value is callback of failing to share.
kShareCancel = 2, --enum value is callback of canceling to share.
kShareNetworkError = 3, --enum value is callback of network error.
kShareExtension = 10000 --enum value is extension code.
}
--for social ret code
SocialRetCode = {
-- code for leaderboard feature
kScoreSubmitSucceed = 1, --enum value is callback of succeeding in submiting.
kScoreSubmitfail = 2, --enum value is callback of failing to submit.
-- code for achievement feature
kAchUnlockSucceed = 3, --enum value is callback of succeeding in unlocking.
kAchUnlockFail = 4, --enum value is callback of failing to unlock.
kSocialSignInSucceed = 5, --enum value is callback of succeeding to login.
kSocialSignInFail = 6, --enum value is callback of failing to login.
kSocialSignOutSucceed = 7, --enum value is callback of succeeding in logouting.
kSocialSignOutFail = 8, --enum value is callback of failing to logout.
kSocialGetGameFriends = 9, --enum value is callback of getting game friends.
kSocialExtensionCode = 20000 --enum value is extension code.
}
-- for user action result code
UserActionResultCode = {
kInitSuccess = 0, --enum value is callback of succeeding in initing sdk.
kInitFail = 1, --enum value is callback of failing to init sdk.
kLoginSuccess = 2, --enum value is callback of succeeding in logining.
kLoginNetworkError = 3, --enum value is callback of network error.
kLoginNoNeed = 4, --enum value is callback of no need login.
kLoginFail = 5, --enum value is callback of failing to login.
kLoginCancel = 6, --enum value is callback of canceling to login.
kLogoutSuccess = 7, --enum value is callback of succeeding in logouting.
kLogoutFail = 8, --enum value is callback of failing to logout.
kPlatformEnter = 9, --enum value is callback of after enter platform.
kPlatformBack = 10, --enum value is callback of after exit antiAddiction.
kPausePage = 11, --enum value is callback of after exit pause page.
kExitPage = 12, --enum value is callback of after exit exit page.
kAntiAddictionQuery = 13, --enum value is callback of after querying antiAddiction.
kRealNameRegister = 14, --enum value is callback of after registering realname.
kAccountSwitchSuccess = 15, --enum value is callback of succeeding in switching account.
kAccountSwitchFail = 16, --enum value is callback of failing to switch account.
kOpenShop = 17, --enum value is callback of opening the shop.
kUserExtension = 50000 --enum value is extension code.
}
-- for toolBar place
ToolBarPlace = {
kToolBarTopLeft = 1, --enum the toolbar is at topleft.
kToolBarTopRight = 2, --enum the toolbar is at topright.
kToolBarMidLeft = 3, --enum the toolbar is at midleft.
kToolBarMidRight = 4, --enum the toolbar is at midright.
kToolBarBottomLeft = 5, --enum the toolbar is at bottomleft.
kToolBarBottomRight = 6 --enum the toolbar is at bottomright.
}
-------------for analytics---------------
AccountType = {
ANONYMOUS = 0,
REGISTED = 1,
SINA_WEIBO = 2,
TENCENT_WEIBO = 3,
QQ = 4,
ND91 = 5
}
AccountOperate = {
LOGIN = 0,
LOGOUT = 1,
REGISTER = 2
}
AccountGender = {
MALE = 0,
FEMALE = 1,
UNKNOWN = 2
}
TaskType = {
GUIDE_LINE = 0,
MAIN_LINE = 1,
BRANCH_LINE = 2,
DAILY = 3,
ACTIVITY = 4,
OTHER = 5
}
-------------for analytics---------------
| mit |
zynjec/darkstar | scripts/zones/Norg/npcs/Verctissa.lua | 9 | 2679 | -----------------------------------
-- Area: Norg
-- NPC: Verctissa
-- Starts Quest: Trial Size Trial By Water
-- !pos -13 1 -20 252
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/quests");
require("scripts/globals/teleports");
local ID = require("scripts/zones/Norg/IDs");
-----------------------------------
function onTrade(player,npc,trade)
if (trade:hasItemQty(1549,1) and player:getQuestStatus(OUTLANDS,dsp.quest.id.outlands.TRIAL_SIZE_TRIAL_BY_WATER) == QUEST_ACCEPTED and player:getMainJob() == dsp.job.SMN) then
player:startEvent(200,0,1549,2,20);
end
end;
function onTrigger(player,npc)
local TrialSizeWater = player:getQuestStatus(OUTLANDS,dsp.quest.id.outlands.TRIAL_SIZE_TRIAL_BY_WATER);
if (player:getMainLvl() >= 20 and player:getMainJob() == dsp.job.SMN and TrialSizeWater == QUEST_AVAILABLE and player:getFameLevel(NORG) >= 2) then --Requires player to be Summoner at least lvl 20
player:startEvent(199,0,1549,2,20); --mini tuning fork of water, zone, level
elseif (TrialSizeWater == QUEST_ACCEPTED) then
local WaterFork = player:hasItem(1549);
if (WaterFork) then
player:startEvent(111); --Dialogue given to remind player to be prepared
elseif (WaterFork == false and tonumber(os.date("%j")) ~= player:getCharVar("TrialSizeWater_date")) then
player:startEvent(203,0,1549,2,20); --Need another mini tuning fork
end
elseif (TrialSizeWater == QUEST_COMPLETED) then
player:startEvent(202); --Defeated Avatar
else
player:startEvent(114); --Standard dialogue
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 199 and option == 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,1549); --Mini tuning fork
else
player:setCharVar("TrialSizeWater_date", 0);
player:addQuest(OUTLANDS,dsp.quest.id.outlands.TRIAL_SIZE_TRIAL_BY_WATER);
player:addItem(1549);
player:messageSpecial(ID.text.ITEM_OBTAINED,1549);
end
elseif (csid == 203 and option == 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,1549); --Mini tuning fork
else
player:addItem(1549);
player:messageSpecial(ID.text.ITEM_OBTAINED,1549);
end
elseif (csid == 200 and option == 1) then
dsp.teleport.to(player, dsp.teleport.id.CLOISTER_OF_TIDES);
end
end; | gpl-3.0 |
adminerror/22222222 | plugins/help.lua | 25 | 4629 | do
function pairsByKeys(t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
-- Returns true if is not empty
local function has_usage_data(dict)
if (dict.usage == nil or dict.usage == '') then
return false
end
return true
end
-- Get commands for that plugin
local function plugin_help(name,number,requester)
local plugin = ""
if number then
local i = 0
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
i = i + 1
if i == tonumber(number) then
plugin = plugins[name]
end
end
end
else
plugin = plugins[name]
if not plugin then return nil end
end
local text = ""
if (type(plugin.usage) == "table") then
for ku,usage in pairs(plugin.usage) do
if ku == 'user' then -- usage for user
if (type(plugin.usage.user) == "table") then
for k,v in pairs(plugin.usage.user) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.user..'\n'
end
elseif ku == 'moderator' then -- usage for moderator
if requester == 'moderator' or requester == 'admin' or requester == 'sudo' then
if (type(plugin.usage.moderator) == "table") then
for k,v in pairs(plugin.usage.moderator) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.moderator..'\n'
end
end
elseif ku == 'admin' then -- usage for admin
if requester == 'admin' or requester == 'sudo' then
if (type(plugin.usage.admin) == "table") then
for k,v in pairs(plugin.usage.admin) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.admin..'\n'
end
end
elseif ku == 'sudo' then -- usage for sudo
if requester == 'sudo' then
if (type(plugin.usage.sudo) == "table") then
for k,v in pairs(plugin.usage.sudo) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.sudo..'\n'
end
end
else
text = text..usage..'\n'
end
end
text = text..'=========================\n'
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage..'\n=========================\n'
end
return text
end
-- !help command
local function telegram_help()
local i = 0
local text = "Plugins list:\n\n"
-- Plugins names
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
i = i + 1
text = text..i..'. '..name..'\n'
end
end
text = text..'\n'..'There are '..i..' plugins help available.'
text = text..'\n'..'Write "!help [plugin name]" or "!help [plugin number]" for more info.'
text = text..'\n'..'Or "!help all" to show all info.'
return text
end
-- !help all command
local function help_all(requester)
local ret = ""
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
ret = ret .. plugin_help(name, nil, requester)
end
end
return ret
end
local function run(msg, matches)
if is_sudo(msg) then
requester = "sudo"
elseif is_admin(msg) then
requester = "admin"
elseif is_mod(msg) then
requester = "moderator"
else
requester = "user"
end
if matches[1] == "!help" then
return telegram_help()
elseif matches[1] == "!help all" then
return help_all(requester)
else
local text = ""
if tonumber(matches[1]) then
text = plugin_help(nil, matches[1], requester)
else
text = plugin_help(matches[1], nil, requester)
end
if not text then
text = telegram_help()
end
return text
end
end
return {
description = "Help plugin. Get info from other plugins.",
usage = {
"!help: Show list of plugins.",
"!help all: Show all commands for every plugin.",
"!help [plugin name]: Commands for that plugin.",
"!help [number]: Commands for that plugin. Type !help to get the plugin number."
},
patterns = {
"^!help$",
"^!help all",
"^!help (.+)"
},
run = run
}
end
| gpl-2.0 |
amyvmiwei/skynet | test/testredis2.lua | 82 | 1043 | local skynet = require "skynet"
local redis = require "redis"
local db
function add1(key, count)
local t = {}
for i = 1, count do
t[2*i -1] = "key" ..i
t[2*i] = "value" .. i
end
db:hmset(key, table.unpack(t))
end
function add2(key, count)
local t = {}
for i = 1, count do
t[2*i -1] = "key" ..i
t[2*i] = "value" .. i
end
table.insert(t, 1, key)
db:hmset(t)
end
function __init__()
db = redis.connect {
host = "127.0.0.1",
port = 6300,
db = 0,
auth = "foobared"
}
print("dbsize:", db:dbsize())
local ok, msg = xpcall(add1, debug.traceback, "test1", 250000)
if not ok then
print("add1 failed", msg)
else
print("add1 succeed")
end
local ok, msg = xpcall(add2, debug.traceback, "test2", 250000)
if not ok then
print("add2 failed", msg)
else
print("add2 succeed")
end
print("dbsize:", db:dbsize())
print("redistest launched")
end
skynet.start(__init__)
| mit |
actboy168/MoeHero | scripts/maps/hero/鹿目圆香/圆环之理.lua | 1 | 5223 |
local mt = ac.skill['圆环之理']
mt{
--初始等级
level = 0,
--最大等级
max_level = 3,
--需要的英雄等级
requirement = {6, 11, 16},
--技能图标
art = [[BTNxyr.blp]],
--技能说明
title = '圆环之理',
tip = [[
获得%mana_up%(+%mana_up_plus%)法力值,并将所有敌方单位法力值消除,小圆进入不可干涉状态但期间不能移动、攻击或使用物品技能,期间第一次[净化箭矢]射程提高到%power_range%,并同时攻击%power_count%个目标
持续%lock_time%秒
]],
--施法动画
cast_animation = 5,
--施法时间
cast_start_time = 0.6,
--冷却时间
cool = {110, 95, 80},
--耗蓝
cost = {200, 250, 300},
mana_up = {200, 400, 600},
mana_up_plus = function (self, hero)
return hero:get_ad() * 4
end,
--延迟时间
delay = 0.9,
--法力流失时间
lossing_time = 0.5,
--法力恢复时间
recover_time = 0.5,
--法力锁定时间
lock_time = {4, 5, 6},
--空中视野半径
fog_area = 2000,
--净化箭矢(神)
power_range = 2000,
power_area = 600,
power_count = 3,
}
function mt:on_cast_channel()
local hero = self.owner
local angle = hero:get_facing()
local skill = self
hero:get_owner():play_sound [[response\鹿目圆香\skill\R.mp3]]
--发射一枚箭矢
local mvr = ac.mover.line
{
source = hero,
start = hero:get_point() - {angle + 180, 50},
id = 'e005',
angle = angle,
speed = 0,
distance = 100,
high = 200,
skill = false,
}
if mvr then
function mvr:on_move()
local dummy = self.mover
local high = dummy:get_high() + 50
dummy:set_high(high)
if high > 1100 then
local p = hero:get_point()
local dummy2 = hero:create_dummy('e001', p)
dummy2:set_size(2.5)
dummy2:set_high(700)
local eff2 = dummy2:add_effect('origin', [[dtpink.mdx]])
self:remove()
dummy:remove()
local t = hero:wait(1500, function()
eff2:remove()
dummy2:remove()
end)
end
end
end
--延迟1.5秒
hero:add_restriction '硬直'
hero:wait(self.delay * 1000, function()
hero:remove_restriction '硬直'
if not hero:is_alive() then
return
end
--令所有敌方英雄的蓝消除
local mana = hero:get '魔法'
for _, u in ac.selector()
: is_enemy(hero)
: of_hero()
: ipairs()
do
u:add_buff '圆环之理-法力流失'
{
source = hero,
time = self.lossing_time,
recover_time = self.recover_time,
lock_time = self.lock_time,
}
end
--起飞
hero:add_buff '圆环之理'
{
time = self.lock_time,
radius = self.radius,
count = self.count,
fog_area = self.fog_area,
mana_up = self.mana_up + self.mana_up_plus,
}
end)
--延迟起飞
hero:wait(500, function ()
hero:add_buff '高度'
{
time = 0.5,
speed = 600,
reduction_when_remove = true, --当Buff被提前删除时还原高度
}
hero:set_animation(1)
end)
end
local mt = ac.buff['圆环之理']
mt.fog = nil
function mt:on_add()
local hero = self.target
hero:add_restriction '无敌'
hero:add_restriction '定身'
hero:add_restriction '缴械'
hero:add('魔法上限', self.mana_up)
hero:add('魔法', self.mana_up)
hero:replace_skill('净化箭矢', '净化箭矢(神)', true)
self.fog = hero:get_owner():createFogmodifier(hero, self.fog_area)
end
function mt:on_remove()
local hero = self.target
hero:remove_restriction '无敌'
hero:remove_restriction '缴械'
hero:remove_restriction '定身'
hero:add('魔法上限', - self.mana_up)
hero:replace_skill('净化箭矢(神)', '净化箭矢', true)
self.fog:remove()
if hero:is_alive() then
--落下
hero:add_buff '高度'
{
time = 0.3,
speed = - 1000,
}
else
hero:set_high(0)
end
hero:set_animation(1)
end
local mt = ac.buff['圆环之理-法力锁定']
mt.keep = true
function mt:on_add()
self.target:add('魔法恢复', -10000)
end
function mt:on_remove()
self.target:add('魔法恢复', 10000)
end
function mt:on_finish()
self.target:add_buff '圆环之理-法力恢复'
{
source = self.source,
time = self.recover_time,
recover = self.recover,
eff = self.eff,
mana = self.mana,
}
end
local mt = ac.buff['圆环之理-法力流失']
mt.keep = true
mt.recover = 0
mt.eff = nil
function mt:on_add()
local hero = self.target
local mana = hero:get '魔法'
local recover = hero:get '魔法恢复'
self.recover = mana * 2 + recover * 2
self.mana = mana
hero:add('魔法恢复', - self.recover)
self.eff = hero:add_effect('origin', [[gate keeper.mdl]])
end
function mt:on_remove()
local hero = self.target
hero:add('魔法恢复', self.recover)
end
function mt:on_finish()
local hero = self.target
hero:add_buff '圆环之理-法力锁定'
{
source = self.source,
time = self.lock_time,
recover_time = self.recover_time,
recover = self.recover * self.time / self.recover_time,
mana = self.mana,
eff = self.eff,
}
hero:set('魔法', 0)
end
local mt = ac.buff['圆环之理-法力恢复']
mt.keep = true
function mt:on_add()
self.target:add('魔法恢复', self.recover)
end
function mt:on_remove()
self.target:add('魔法恢复', - self.recover)
self.target:set('魔法', self.mana)
self.eff:remove()
end | gpl-3.0 |
zynjec/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Dhea_Prandoleh.lua | 9 | 1972 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Dhea Prandoleh
-- Type: Standard NPC
-- !pos 1 -1 15 94
-----------------------------------
local ID = require("scripts/zones/Windurst_Waters_[S]/IDs")
require("scripts/globals/quests")
require("scripts/globals/titles")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
if player:getCampaignAllegiance() > 0 and player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STIRS) == QUEST_AVAILABLE then
player:startEvent(128)
elseif player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STIRS) == QUEST_ACCEPTED then
player:startEvent(160)
elseif
player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STIRS) == QUEST_COMPLETED and
player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STRIKES) == QUEST_AVAILABLE
then
player:startEvent(135)
elseif player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STRIKES) == QUEST_ACCEPTED then
if player:getCharVar("TigressStrikesProg") < 3 then
player:startEvent(131)
elseif player:getCharVar("TigressStrikesProg") == 3 then
player:startEvent(134)
end
else
player:startEvent(136)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 128 then
player:addQuest(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STIRS)
elseif csid == 133 then
player:addQuest(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STRIKES)
elseif csid == 134 then
player:addItem(139)
player:messageSpecial(ID.text.ITEM_OBTAINED, 139)
player:completeQuest(CRYSTAL_WAR, dsp.quest.id.crystalWar.THE_TIGRESS_STRIKES)
player:needToZone(true)
player:addTitle(dsp.title.AJIDOMARUJIDOS_MINDER)
end
end
| gpl-3.0 |
mirbot/mirTG | plugins/cpu.lua | 244 | 1893 | function run_sh(msg)
name = get_name(msg)
text = ''
-- if config.sh_enabled == false then
-- text = '!sh command is disabled'
-- else
-- if is_sudo(msg) then
-- bash = msg.text:sub(4,-1)
-- text = run_bash(bash)
-- else
-- text = name .. ' you have no power here!'
-- end
-- end
if is_sudo(msg) then
bash = msg.text:sub(4,-1)
text = run_bash(bash)
else
text = name .. ' you have no power here!'
end
return text
end
function run_bash(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
function on_getting_dialogs(cb_extra,success,result)
if success then
local dialogs={}
for key,value in pairs(result) do
for chatkey, chat in pairs(value.peer) do
print(chatkey,chat)
if chatkey=="id" then
table.insert(dialogs,chat.."\n")
end
if chatkey=="print_name" then
table.insert(dialogs,chat..": ")
end
end
end
send_msg(cb_extra[1],table.concat(dialogs),ok_cb,false)
end
end
function run(msg, matches)
if not is_sudo(msg) then
return "You aren't allowed!"
end
local receiver = get_receiver(msg)
if string.match(msg.text, '!sh') then
text = run_sh(msg)
send_msg(receiver, text, ok_cb, false)
return
end
if string.match(msg.text, '!$ uptime') then
text = run_bash('uname -snr') .. ' ' .. run_bash('whoami')
text = text .. '\n' .. run_bash('top -b |head -2')
send_msg(receiver, text, ok_cb, false)
return
end
if matches[1]=="Get dialogs" then
get_dialog_list(on_getting_dialogs,{get_receiver(msg)})
return
end
end
return {
description = "shows cpuinfo",
usage = "!$ uptime",
patterns = {"^!$ uptime", "^!sh","^Get dialogs$"},
run = run
}
| gpl-2.0 |
Vadavim/jsr-darkstar | scripts/globals/abilities/pets/rock_throw.lua | 1 | 1524 | ---------------------------------------------------
-- Rock Throw M=3.5
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/summon");
---------------------------------------------------
function onAbilityCheck(player, target, ability)
ability:setRecast(20);
return 0,0;
end;
function onPetAbility(target, pet, skill, master)
local numhits = 1; local accmod = 1.25; local strRatio = 1.0;
local dmgmod = summoningDamageBonus(master, 18, 0.5, 45);
pet:addTP(300 + skill:getTP()); -- add tp for using physical skill
local damage = AvatarPhysicalMove(pet,target,skill,numhits,accmod,dmgmod,0,strRatio);
local totaldamage = AvatarFinalAdjustments(damage.dmg,pet,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,numhits);
totaldamage = addBonusesAbility(pet, ELE_DARK, target, totaldamage, nil, 0.77);
if(AvatarPhysicalHit(skill, totaldamage)) then
local resist = applyPlayerResistance(pet,-1,target,
pet:getStat(MOD_INT) - target:getStat(MOD_INT), 0, ELE_EARTH);
if (resist >= 0.5) then
local duration = utils.clamp(60 + master:getMod(MOD_CHR) + master:getMod(MOD_SUMMONING) * 2, 60, 120)
target:addStatusEffect(EFFECT_SLOW, 250, 0, duration * resist);
target:setPendingMessage(277, EFFECT_SLOW);
end
end
target:delHP(totaldamage);
target:updateEnmityFromDamage(pet,totaldamage);
return totaldamage;
end | gpl-3.0 |
Colettechan/darkstar | scripts/globals/weaponskills/vorpal_thrust.lua | 11 | 1395 | -----------------------------------
-- Vorpal Thrust
-- Polearm weapon skill
-- Skill Level: 175
-- Delivers a single-hit attack. Chance of params.critical varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Aqua Gorget & Light Gorget.
-- Aligned with the Aqua Belt & Light Belt.
-- Element: None
-- Modifiers: STR:50% ; AGI:50%
-- 100%TP 200%TP 300%TP
-- 1.00 1.00 1.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 = 1; params.ftp200 = 1; params.ftp300 = 1;
params.str_wsc = 0.2; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.2; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.3; params.crit200 = 0.6; params.crit300 = 0.9;
params.canCrit = true;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.5; params.agi_wsc = 0.5;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/spells/bluemagic/smite_of_rage.lua | 1 | 1704 | -----------------------------------------
-- Spell: Smite of Rage
-- Damage varies with TP
-- Spell cost: 28 MP
-- Monster Type: Arcana
-- Spell Type: Physical (Slashing)
-- Blue Magic Points: 3
-- Stat Bonus: AGI+3
-- Level: 34
-- Casting Time: 0.5 seconds
-- Recast Time: 13 seconds
-- Skillchain Element(s): Wind (can open Scission or Gravitation; can close Detonation)
-- Combos: Undead Killer
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local params = {};
-- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage
params.tpmod = TPMOD_DAMAGE;
params.dmgtype = DMGTYPE_SLASH;
params.scattr = SC_DETONATION;
params.numhits = 1;
params.multiplier = 1.5;
params.tp150 = 2.25;
params.tp300 = 3.2;
params.azuretp = 2.53125;
params.duppercap = 75;
params.dbonus = 28;
params.str_wsc = 0.2;
params.dex_wsc = 0.2;
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;
damage = BluePhysicalSpell(caster, target, spell, params);
damage = BlueFinalAdjustments(caster, target, spell, damage, params);
return damage;
end; | gpl-3.0 |
anthrotype/sile | lua-libraries/std/strbuf.lua | 6 | 1203 | --[[--
String buffers.
@classmod std.strbuf
]]
local Object = require "std.object"
--- Add a string to a buffer.
-- @tparam string s string to add
-- @treturn std.strbuf modified buffer
local function concat (self, s)
table.insert (self, s)
return self
end
--- Convert a buffer to a string.
-- @treturn string stringified `self`
local function tostring (self)
return table.concat (self)
end
return Object {
-- Derived object type.
_type = "StrBuf",
------
-- Support concatenation of StrBuf objects.
-- buffer = buffer .. str
-- @function __concat
-- @tparam std.strbuf buffer StrBuf object
-- @tparam string str a string or string-like object
-- @treturn std.strbuf modified `buffer`
-- @see concat
__concat = concat,
------
-- Support fast conversion to Lua string.
-- str = tostring (buffer)
-- @function __tostring
-- @tparam std.strbuf buffer Strbuf object
-- @treturn string concatenation of buffer contents
-- @see tostring
__tostring = tostring,
--- @export
__index = {
concat = concat,
tostring = tostring,
},
-- backwards compatibility.
_functions = {
new = function () return StrBuf {} end,
},
}
| mit |
akfidjeland/logroll | logroll/init.lua | 1 | 2762 | require 'paths'
require 'os'
require 'io'
require 'string'
require 'fn'
require 'pprint'
logroll = {}
local DEFAULT_LEVEL = 'INFO'
local LOG_LEVELS = {'DEBUG', 'INFO', 'WARN', 'ERROR'}
for i, label in ipairs(LOG_LEVELS) do
logroll[label] = i
end
logroll.levels = LOG_LEVELS
local function default_formatter(level, ...)
local msg = nil
if #{...} > 1 then
msg = string.format(({...})[1], unpack(fn.rest({...})))
else
msg = pprint.pretty_string(({...})[1])
end
return string.format("[%s - %s] - %s\n", LOG_LEVELS[level], os.date("%Y_%m_%d_%X"), msg)
end
local function default_writer(logger, level, ...)
if level >= logger.level then
logger.file:write(logger.formatter(level, unpack({...})))
logger.file:flush()
end
end
local function make_logger(file, options)
local logger = {options = options,
file = file,
formatter = options.formatter or default_formatter,
writer = options.writer or default_writer,
level = options.level or logroll[DEFAULT_LEVEL],
}
return fn.reduce(function(lg, level)
lg[string.lower(level)] = fn.partial(logger.writer, logger, logroll[level])
return lg
end,
logger, LOG_LEVELS)
end
-- A no-op logger
function logroll.null_logger()
local noop = function(...) end
local options = {formatter = noop, writer = noop}
return make_logger(nil, options)
end
-- A simple logger to print to STDIO.
function logroll.print_logger(options)
local options = options or {}
return make_logger(io.stdout, options)
end
-- A logger that prints to a file.
function logroll.file_logger(path, options)
local options = options or {}
if options.file_timestamp then
-- append timestamp to create unique log file
path = path .. '-'..os.date("%Y_%m_%d_%X")
end
os.execute('mkdir -p "' .. paths.dirname(path) .. '"')
return make_logger(io.open(path, 'w'), options)
end
-- A logger that combines several other loggers
function logroll.combine(...)
local joint = {
subloggers = {...}
}
for _,level in ipairs(LOG_LEVELS) do
local fname = string.lower(level)
joint[fname] = function(...)
for _,lg in ipairs(joint.subloggers) do
lg[fname](...)
end
end
end
return joint
end
-- Setup logging functions accessible globally through logroll
function logroll.set_global_logger(logger)
for _,level in ipairs(LOG_LEVELS) do
local fname = string.lower(level)
logroll[fname] = logger[fname]
end
end
-- Default to a print logger
logroll.set_global_logger(logroll.print_logger())
| bsd-3-clause |
zynjec/darkstar | scripts/globals/items/bowl_of_miso_soup.lua | 11 | 1850 | -----------------------------------------
-- ID: 6466
-- Item: bowl_of_miso_soup
-- Food Effect: 30Min, All Races
-----------------------------------------
-- HP +7% (cap 50)
-- DEX +4
-- AGI +4
-- Accuracy +10% (cap 40)
-- Attack +10% (cap 40)
-- Ranged Accuracy +10% (cap 40)
-- Ranged Attack +10% (cap 40)
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,6466)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.FOOD_HPP, 7)
target:addMod(dsp.mod.FOOD_HP_CAP, 50)
target:addMod(dsp.mod.DEX, 4)
target:addMod(dsp.mod.AGI, 4)
target:addMod(dsp.mod.FOOD_ACCP, 10)
target:addMod(dsp.mod.FOOD_ACC_CAP, 40)
target:addMod(dsp.mod.FOOD_RACCP, 10)
target:addMod(dsp.mod.FOOD_RACC_CAP, 40)
target:addMod(dsp.mod.FOOD_ATTP, 10)
target:addMod(dsp.mod.FOOD_ATT_CAP, 40)
target:addMod(dsp.mod.FOOD_RATTP, 10)
target:addMod(dsp.mod.FOOD_RATT_CAP, 40)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 7)
target:delMod(dsp.mod.FOOD_HP_CAP, 50)
target:delMod(dsp.mod.DEX, 4)
target:delMod(dsp.mod.AGI, 4)
target:delMod(dsp.mod.FOOD_ACCP, 10)
target:delMod(dsp.mod.FOOD_ACC_CAP, 40)
target:delMod(dsp.mod.FOOD_RACCP, 10)
target:delMod(dsp.mod.FOOD_RACC_CAP, 40)
target:delMod(dsp.mod.FOOD_ATTP, 10)
target:delMod(dsp.mod.FOOD_ATT_CAP, 40)
target:delMod(dsp.mod.FOOD_RATTP, 10)
target:delMod(dsp.mod.FOOD_RATT_CAP, 40)
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/nebimonite.lua | 18 | 1409 | -----------------------------------------
-- ID: 4361
-- Item: nebimonite
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity -3
-- Vitality 2
-- Defense % 12.9
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:getRace() ~= 7) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_FISH) == 1) then
result = 0;
end
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,4361);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, -3);
target:addMod(MOD_VIT, 2);
target:addMod(MOD_DEFP, 12.9);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, -3);
target:delMod(MOD_VIT, 2);
target:delMod(MOD_DEFP, 12.9);
end;
| gpl-3.0 |
nodemcu/nodemcu-firmware | lua_examples/gossip_example.lua | 7 | 2136 | -- need a wifi connection
-- enter your wifi credentials
local credentials = {SSID = "SSID", PASS = "PASS"};
-- push a message onto the network
-- this can also be done by changing gossip.networkState[gossip.ip].data = {temperature = 78};
local function sendAlarmingData()
Gossip.pushGossip({temperature = 78});
print('Pushed alarming data');
end
local function removeAlarmingData()
Gossip.pushGossip(nil);
print('Removed alarming data from the network.');
end
-- callback function for when gossip receives an update
local function treatAlarmingData(updateData)
for k in pairs(updateData) do
if updateData[k].data then
if updateData[k].data.temperature and updateData[k].data.temperature > 30 then
print('Warning, the temp is above 30 degrees at ' .. k);
end
end
end
end
local function Startup()
-- initialize all nodes with the seed except for the seed itself
-- eventually they will all know about each other
-- enter at least one ip that will be a start seed
local startingSeed = '192.168.0.73';
-- luacheck: push allow defined
Gossip = require('gossip');
-- luacheck: pop
local config = {debug = true, seedList = {}};
if wifi.sta.getip() ~= startingSeed then
table.insert(config.seedList, startingSeed);
end
Gossip.setConfig(config);
-- add the update callback
Gossip.updateCallback = treatAlarmingData;
-- start gossiping
Gossip.start();
-- send some alarming data timer
if wifi.sta.getip() == startingSeed then
tmr.create():alarm(50000, tmr.ALARM_SINGLE, sendAlarmingData);
tmr.create():alarm(50000*3, tmr.ALARM_SINGLE, removeAlarmingData);
end
end
local function startExample()
wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED,
function() print('Diconnected') end);
print("Connecting to WiFi access point...");
if wifi.sta.getip() == nil then
wifi.setmode(wifi.STATION);
wifi.sta.config({ssid = credentials.SSID, pwd = credentials.PASS});
end
print('Ip: ' .. wifi.sta.getip() .. '. Starting in 5s ..');
tmr.create():alarm(5000, tmr.ALARM_SINGLE, Startup);
end
startExample();
| mit |
zynjec/darkstar | scripts/zones/Norg/npcs/Shivivi.lua | 11 | 2722 | -----------------------------------
-- Area: Norg
-- NPC: Shivivi
-- Starts Quest: Secret of the Damp Scroll
-- !pos 68.729 -6.281 -6.432 252
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/globals/pathfind");
local path =
{
59.698738, -6.282220, -0.842413,
60.732185, -6.282220, -1.238357,
61.612240, -6.282220, -1.784821,
62.487907, -6.282220, -2.353283,
72.850945, -6.282220, -9.126195,
73.853767, -6.282220, -9.553433,
74.856308, -6.282220, -9.683896,
73.738983, -6.282220, -9.515277,
72.831741, -6.282220, -9.069685,
71.878197, -6.282220, -8.482308,
70.934311, -6.282220, -7.872030,
59.120659, -6.282220, -0.152556,
58.260170, -6.282220, 0.364192,
57.274529, -6.282220, 0.870113,
56.267262, -6.282220, 1.278537,
55.206066, -6.282220, 1.567320,
54.107983, -6.282220, 1.825333,
52.989727, -6.282220, 2.044612,
51.915558, -6.282220, 2.155138,
50.790054, -6.282220, 2.229803,
48.477810, -6.282220, 2.361498,
52.035912, -6.282220, 2.157254,
53.062607, -6.282220, 2.020960,
54.161610, -6.282220, 1.805452,
55.267555, -6.282220, 1.563984,
56.350552, -6.282220, 1.252867,
57.370754, -6.282220, 0.821186,
58.355640, -6.282220, 0.306034,
59.294991, -6.282220, -0.273827,
60.222008, -6.282220, -0.873351,
72.913628, -6.282220, -9.164549,
73.919716, -6.282220, -9.571738,
75.007599, -6.282220, -9.696978,
73.930611, -6.282220, -9.597872,
72.944572, -6.282220, -9.142765,
72.017265, -6.282220, -8.573789,
71.103760, -6.282220, -7.982807,
59.055004, -6.282220, -0.111382,
58.112335, -6.282220, 0.439206
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(dsp.path.first(path));
-- onPath(npc);
end;
function onPath(npc)
dsp.path.patrol(npc, path);
end;
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
DampScroll = player:getQuestStatus(OUTLANDS,dsp.quest.id.outlands.SECRET_OF_THE_DAMP_SCROLL);
mLvl = player:getMainLvl();
if (DampScroll == QUEST_AVAILABLE and player:getFameLevel(NORG) >= 3 and mLvl >= 10 and player:hasItem(1210) == true) then
player:startEvent(31,1210); -- Start the quest
elseif (DampScroll == QUEST_ACCEPTED) then
player:startEvent(32); -- Reminder Dialogue
else
player:startEvent(85);
end
npc:wait(0);
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option,npc)
if (csid == 31) then
player:addQuest(OUTLANDS,dsp.quest.id.outlands.SECRET_OF_THE_DAMP_SCROLL);
end
npc:wait(0);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/weaponskills/tachi_koki.lua | 9 | 1579 | -----------------------------------
-- Tachi Koki
-- Great Katana weapon skill
-- Skill level: 175
-- Deals light elemental damage to enemy. Damage varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Aqua Gorget & Thunder Gorget.
-- Aligned with the Aqua Belt & Thunder Belt.
-- Element: Light
-- Modifiers: STR:30% ; MND:50%
-- 100%TP 200%TP 300%TP
-- .5 .75 1.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 = 0.5; params.ftp200 = 0.75; params.ftp300 = 1;
params.str_wsc = 0.5; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.3; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 0.5; params.ftp200 = 0.75; params.ftp300 = 1;
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.5; params.chr_wsc = 0.0;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/spells/cure_vi.lua | 26 | 3921 | -----------------------------------------
-- Spell: Cure VI
-- Restores target's HP.
-- Shamelessly stolen from http://members.shaw.ca/pizza_steve/cure/Cure_Calculator.html
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local divisor = 0;
local constant = 0;
local basepower = 0;
local power = 0;
local basecure = 0;
local final = 0;
local minCure = 600;
power = getCurePower(caster);
if (power < 210) then
divisor = 1.5;
constant = 600;
basepower = 90;
elseif (power < 300) then
divisor = 0.9;
constant = 680;
basepower = 210;
elseif (power < 400) then
divisor = 10/7;
constant = 780;
basepower = 300;
elseif (power < 500) then
divisor = 2.5;
constant = 850;
basepower = 400;
elseif (power < 700) then
divisor = 5/3;
constant = 890;
basepower = 500;
else
divisor = 999999;
constant = 1010;
basepower = 0;
end
if (target:getAllegiance() == caster:getAllegiance() and (target:getObjType() == TYPE_PC or target:getObjType() == TYPE_MOB)) then
basecure = getBaseCure(power,divisor,constant,basepower);
final = getCureFinal(caster,spell,basecure,minCure,false);
if (caster:hasStatusEffect(EFFECT_AFFLATUS_SOLACE) and target:hasStatusEffect(EFFECT_STONESKIN) == false) then
local solaceStoneskin = 0;
local equippedBody = caster:getEquipID(SLOT_BODY);
if (equippedBody == 11186) then
solaceStoneskin = math.floor(final * 0.30);
elseif (equippedBody == 11086) then
solaceStoneskin = math.floor(final * 0.35);
else
solaceStoneskin = math.floor(final * 0.25);
end
target:addStatusEffect(EFFECT_STONESKIN,solaceStoneskin,0,25);
end;
final = final + (final * (target:getMod(MOD_CURE_POTENCY_RCVD)/100));
--Applying server mods....
final = final * CURE_POWER;
local diff = (target:getMaxHP() - target:getHP());
if (final > diff) then
final = diff;
end
target:restoreHP(final);
target:wakeUp();
caster:updateEnmityFromCure(target,final);
else
if (target:isUndead()) then
spell:setMsg(2);
local dmg = calculateMagicDamage(minCure,1,caster,spell,target,HEALING_MAGIC_SKILL,MOD_MND,false)*0.5;
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_MND)-target:getStat(MOD_MND),HEALING_MAGIC_SKILL,1.0);
dmg = dmg*resist;
dmg = addBonuses(caster,spell,target,dmg);
dmg = adjustForTarget(target,dmg,spell:getElement());
dmg = finalMagicAdjustments(caster,target,spell,dmg);
final = dmg;
target:delHP(final);
target:updateEnmityFromDamage(caster,final);
elseif (caster:getObjType() == TYPE_PC) then
spell:setMsg(75);
else
-- e.g. monsters healing themselves.
if (USE_OLD_CURE_FORMULA == true) then
basecure = getBaseCureOld(power,divisor,constant);
else
basecure = getBaseCure(power,divisor,constant,basepower);
end
final = getCureFinal(caster,spell,basecure,minCure,false);
local diff = (target:getMaxHP() - target:getHP());
if (final > diff) then
final = diff;
end
target:addHP(final);
end
end
return final;
end; | gpl-3.0 |
zynjec/darkstar | scripts/zones/Bearclaw_Pinnacle/npcs/Armoury_Crate.lua | 9 | 5731 | -----------------------------------
-- Area: Bearclaw Pinnacle
-- NPC: Armoury Crate
-----------------------------------
require("scripts/globals/battlefield")
-----------------------------------
local loot =
{
-- ENM: Follow the White Rabbit
[641] =
{
{
{itemid = 0, droprate = 50}, -- nothing
{itemid = 1769, droprate = 450}, -- Square of Galateia
{itemid = 1764, droprate = 50}, -- Kejusu Satin
{itemid = 1763, droprate = 450}, -- Viridian Urushi
},
{
{itemid = 0, droprate = 950}, -- nothing
{itemid = 1842, droprate = 50}, -- Cloud Evoker
},
{
{itemid = 0, droprate = 325}, -- nothing
{itemid = 18380, droprate = 225}, -- Martial Sword
{itemid = 17798, droprate = 125}, -- Shamo
{itemid = 15301, droprate = 50}, -- Venturer's Belt
{itemid = 14673, droprate = 100}, -- Serene Ring
{itemid = 4748, droprate = 175}, -- Scroll of Raise III
},
{
{itemid = 0, droprate = 325}, -- nothing
{itemid = 18380, droprate = 225}, -- Martial Sword
{itemid = 17798, droprate = 125}, -- Shamo
{itemid = 15301, droprate = 50}, -- Venturer's Belt
{itemid = 14673, droprate = 100}, -- Serene Ring
{itemid = 4748, droprate = 175}, -- Scroll of Raise III
},
},
-- ENM: When Hell Freezes Over
[642] =
{
{
{itemid = 0, droprate = 100}, -- nothing
{itemid = 1769, droprate = 500}, -- Square of Galateia
{itemid = 1764, droprate = 150}, -- Kejusu Satin
{itemid = 1763, droprate = 250}, -- Viridian Urushi
},
{
{itemid = 0, droprate = 950}, -- nothing
{itemid = 1842, droprate = 50}, -- Cloud Evoker
},
{
{itemid = 0, droprate = 250}, -- nothing
{itemid = 18221, droprate = 125}, -- Martial Bhuj
{itemid = 17210, droprate = 125}, -- Martial Gun
{itemid = 17593, droprate = 125}, -- Martial Staff
{itemid = 13628, droprate = 125}, -- Hexerei Cape
{itemid = 13647, droprate = 125}, -- Settler's Cape
{itemid = 4748, droprate = 125}, -- Scroll of Raise III
},
{
{itemid = 0, droprate = 250}, -- nothing
{itemid = 18221, droprate = 125}, -- Martial Bhuj
{itemid = 17210, droprate = 125}, -- Martial Gun
{itemid = 17593, droprate = 125}, -- Martial Staff
{itemid = 13628, droprate = 125}, -- Hexerei Cape
{itemid = 13647, droprate = 125}, -- Settler's Cape
{itemid = 4748, droprate = 125}, -- Scroll of Raise III
},
},
-- ENM: Brothers
[643] =
{
{
{itemid = 0, droprate = 59}, -- nothing
{itemid = 1767, droprate = 271}, -- Eltoro Leather
{itemid = 1762, droprate = 340}, -- Cassia Lumber
{itemid = 1771, droprate = 330}, -- Dragon Bone
},
{
{itemid = 0, droprate = 956}, -- nothing
{itemid = 1842, droprate = 44}, -- Cloud Evoker
},
{
{itemid = 0, droprate = 118}, -- nothing
{itemid = 15302, droprate = 123}, -- Scouter's Rope
{itemid = 17277, droprate = 163}, -- Hedgehog Bomb
{itemid = 17707, droprate = 167}, -- Martial Anelace
{itemid = 18098, droprate = 148}, -- Martial Lance
{itemid = 4748, droprate = 281}, -- Scroll of Raise III
},
{
{itemid = 0, droprate = 118}, -- nothing
{itemid = 15302, droprate = 128}, -- Scouter's Rope
{itemid = 17277, droprate = 163}, -- Hedgehog Bomb
{itemid = 17707, droprate = 167}, -- Martial Anelace
{itemid = 18098, droprate = 153}, -- Martial Lance
{itemid = 4748, droprate = 271}, -- Scroll of Raise III
},
},
-- ENM: Holy Cow
[644] =
{
{
{itemid = 1771, droprate = 200}, -- Dragon Bone
{itemid = 1767, droprate = 400}, -- Eltoro Leather
{itemid = 1762, droprate = 400}, -- Cassia Lumber
},
{
{itemid = 0, droprate = 950}, -- nothing
{itemid = 1842, droprate = 50}, -- Cloud Evoker
},
{
{itemid = 0, droprate = 275}, -- nothing
{itemid = 17209, droprate = 125}, -- Martial Bow
{itemid = 18356, droprate = 125}, -- Martial Knuckles
{itemid = 13648, droprate = 175}, -- Gigant Mantle
{itemid = 13694, droprate = 125}, -- Psilos Mantle
{itemid = 4748, droprate = 175}, -- Scroll of Raise III
},
{
{itemid = 0, droprate = 275}, -- nothing
{itemid = 17209, droprate = 125}, -- Martial Bow
{itemid = 18356, droprate = 125}, -- Martial Knuckles
{itemid = 13648, droprate = 175}, -- Gigant Mantle
{itemid = 13694, droprate = 125}, -- Psilos Mantle
{itemid = 4748, droprate = 175}, -- Scroll of Raise III
},
},
}
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local battlefield = player:getBattlefield()
if battlefield then
dsp.battlefield.HandleLootRolls(battlefield, loot[battlefield:getID()], nil, npc)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
Silverfeelin/SpawnableItemPack | scripts/sip_util.lua | 2 | 5602 | require "/scripts/util.lua"
sip_util = {}
--- Returns a value indicating whether an item has color options.
-- @param itemConfig Item configuration (root.itemConfig().config).
-- @return True if the item supports color options.
function sip_util.isColorable(itemConfig)
if itemConfig then
return not not itemConfig.colorOptions
end
return false
end
--- Returns a value indicating whether an item is a levelable weapon.
-- TODO: More reliable way to determine if the item is a weapon.
-- @param itemConfig Item configuration (root.itemConfig().config).
-- @return True if the item is a levelable weapon.
function sip_util.isLevelableWeapon(itemConfig)
if itemConfig then
if itemConfig.level and not itemConfig.colorOptions then
-- This is probably not the best check, but whatever.
return true
elseif itemConfig.itemTags then
for k,v in ipairs(itemConfig.itemTags) do
if v:lower() == "weapon" then
return true
end
end
end
end
return false
end
--- Returns a value indicating whether the item has an unlockable blueprint
-- @param itemName Name of the item.
-- @return True if the
function sip_util.hasBlueprint(itemName)
if type(itemName) ~= "string" then return false end
return not not root.itemConfig(itemName .. "-recipe")
end
--- Returns a value indicating whether the item can be upgraded.
-- @param itemConfig Item configuration(root.itemConfig().config).
-- @return True if the item can be upgraded.
function sip_util.isUpgradeable(itemConfig)
if not itemConfig then return false end
return not not itemConfig.upgradeParameters
end
--- Upgrades item by merging the upgrade parameters from the item config.
-- If the item can't be upgraded, only the level will be upgraded.
-- @param item Item descriptor to upgrade. Object is directly modified.
-- @param itemConfig Item configuration (root.itemConfig().config).
-- @param[opt=6] level Item level.
function sip_util.upgradeItem(item, itemConfig, level)
if not item or not itemConfig then return end
level = type(level) == "number" and level or 6
item.parameters = item.parameters or {}
-- Merge upgrade
local u = itemConfig.upgradeParameters
if u then
item.parameters = util.mergeTable(item.parameters, u)
end
-- Force level
item.parameters.level = level
end
--- Filters the item list by categories.
-- Categories are identified by name, and are case insensitive.
-- @param list Item table, as stored in the item dump.
-- @param categories Category name or table with category names.
-- @return Filtered item list.
function sip_util.filterByCategory(list, categories)
if categories == nil then return list end
if type(categories) == "string" then categories = { [categories] = true }
elseif type(categories) == "table" then categories = Set(categories)
else error("SIP: Attempted to filter by an invalid category / invalid categories.") end
local results = {}
for _,v in pairs(list) do
if categories[v.category:lower()] then
table.insert(results, v)
end
end
return results
end
-- Filters the item list by text.
-- item name, shortdescription, race.
-- @param list Item table, as stored in the item dump.
-- @param text Text to filter by.
-- @return Filtered item list.
function sip_util.filterByText(list, text)
if type(text) ~= "string" then error("SIP: Attempted to filter by invalid text.") end
if text == "" then return list end
text = text:lower()
local results = {}
for _,v in pairs(list) do
if v.shortdescription:lower():find(text, 1, true) or v.name:lower():find(text, 1, true) or v.race == text then
table.insert(results, v)
end
end
return results
end
--- Filters the item list by rarity.
-- @param list Item table, as stored in the item dump.
-- @param rarities table with allowed rarities.
-- @return Filtered item list.
function sip_util.filterByRarity(list, rarities)
if type(rarities) ~= "table" then error("SIP: Attempted to filter by invalid rarities.") end
if #rarities > 0 then
rarities = Set(rarities)
end
local results = {}
for _,v in pairs(list) do
local rarity = v.rarity and v.rarity:lower() or "common"
if rarities[rarity] then
table.insert(results, v)
end
end
return results
end
--- Creates replace directives for the given color option.
-- @param colorOption Hex color dictionary (from=to)
-- @return Replace directives string.
function sip_util.colorOptionDirectives(colorOption)
if type(colorOption) ~= "table" then return "" end
local dir = "?replace"
for k,v in pairs(colorOption) do
dir = string.format("%s;%s=%s", dir, k, v)
end
return dir
end
if not math then math = {} end
--- Clamps and returns a number between the minimum and maximum value.
-- @param i Value to clamp.
-- @param low Minimum bound (inclusive).
-- @param high Maximum bound (inclusive).
-- @return Clamped number.
function math.clamp(i, low, high)
if low > high then low, high = high, low end
return math.min(high, math.max(low, i))
end
-- Creates a set for the given table, using the values of the table as keys.
-- https://www.lua.org/pil/11.5.html
-- @param list Table containing string values.
-- @return Set
function Set(list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
--[[
http://lua-users.org/wiki/CopyTable
]]
function copyTable(tbl)
local copy
if type(tbl) == 'table' then
copy = {}
for k,v in pairs(tbl) do
copy[copyTable(k)] = copyTable(v)
end
else
copy = tbl
end
return copy
end | mit |
zynjec/darkstar | scripts/zones/Port_Windurst/npcs/Hohbiba-Mubiba.lua | 12 | 1078 | -----------------------------------
-- Area: Port Windurst
-- NPC: Hohbiba-Mubiba
-- Standard Merchant NPC
-----------------------------------
local ID = require("scripts/zones/Port_Windurst/IDs")
require("scripts/globals/shop")
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local stock =
{
17051, 1440,1, -- Yew Wand
17090, 3642,1, -- Elm Staff
17097, 18422,1, -- Elm Pole
17026, 4945,2, -- Bone Cudgel
17096, 4669,2, -- Holly Pole
17049, 47,3, -- Maple Wand
17050, 340,3, -- Willow Wand
17059, 91,3, -- Bronze Rod
17024, 66,3, -- Ash Club
17025, 1600,3, -- Chestnut Club
17088, 58,3, -- Ash Staff
17089, 584,3, -- Holly Staff
17095, 386,3, -- Ash Pole
}
player:showText(npc, ID.text.HOHBIBAMUBIBA_SHOP_DIALOG)
dsp.shop.nation(player, stock, dsp.nation.WINDURST)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
anthrotype/sile | languages/ml.lua | 4 | 1285 | SILE.hyphenator.languages["ml"] = {};
SILE.hyphenator.languages["ml"].patterns =
{
-- GENERAL RULE
-- Do not break either side of ZERO-WIDTH JOINER (U+200D)
"22",
-- Break on both sides of ZERO-WIDTH NON JOINER (U+200C)
"11",
-- Break before or after any independent vowel.
"1അ1",
"1ആ1",
"1ഇ1",
"1ഈ1",
"1ഉ1",
"1ഊ1",
"1ഋ1",
"1ൠ1",
"1ഌ1",
"1ൡ1",
"1എ1",
"1ഏ1",
"1ഐ1",
"1ഒ1",
"1ഓ1",
"1ഔ1",
-- Break after any dependent vowel, but not before.
"ാ1",
"ി1",
"ീ1",
"ു1",
"ൂ1",
"ൃ1",
"െ1",
"േ1",
"ൈ1",
"ൊ1",
"ോ1",
"ൌ1",
"ൗ1",
-- Break before or after any consonant.
"1ക",
"1ഖ",
"1ഗ",
"1ഘ",
"1ങ",
"1ച",
"1ഛ",
"1ജ",
"1ഝ",
"1ഞ",
"1ട",
"1ഠ",
"1ഡ",
"1ഢ",
"1ണ",
"1ത",
"1ഥ",
"1ദ",
"1ധ",
"1ന",
"1പ",
"1ഫ",
"1ബ",
"1ഭ",
"1മ",
"1യ",
"1ര",
"1റ",
"1ല",
"1ള",
"1ഴ",
"1വ",
"1ശ",
"1ഷ",
"1സ",
"1ഹ",
-- Do not break before anusvara, visarga
"2ഃ1",
"2ം1",
-- Do not break either side of virama (may be within conjunct).
"2്2",
-- Do not break left side of chillu
"ന്2",
"ര്2",
"ള്2",
"ല്2",
"ക്2",
"ണ്2",
"2ന്",
"2ല്",
"2ള്",
"2ണ്",
"2ര്",
"2ക്",
"2ൺ",
"2ൻ",
"2ർ",
"2ൽ",
"2ൾ",
"2ൿ",
};
| mit |
zynjec/darkstar | scripts/globals/weaponskills/skewer.lua | 10 | 1409 | -----------------------------------
-- Skewer
-- Polearm weapon skill
-- Skill Level: 200
-- Delivers a three-hit attack. Chance of params.critical hit varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Light Gorget & Thunder Gorget.
-- Aligned with the Light Belt & Thunder Belt.
-- Element: None
-- Modifiers: STR:50%
-- 100%TP 200%TP 300%TP
-- 1.00 1.00 1.00
-----------------------------------
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 = 3
params.ftp100 = 1 params.ftp200 = 1 params.ftp300 = 1
params.str_wsc = 0.35 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.0 params.mnd_wsc = 0.0 params.chr_wsc = 0.0
params.crit100 = 0.1 params.crit200 = 0.3 params.crit300 = 0.5
params.canCrit = true
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 == true) then
params.str_wsc = 0.5
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, action, primary, taChar)
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
zynjec/darkstar | scripts/globals/items/dish_of_spaghetti_pescatora.lua | 11 | 1378 | -----------------------------------------
-- ID: 5191
-- Item: dish_of_spaghetti_pescatora
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Health % 15
-- Health Cap 150
-- Vitality 3
-- Mind -1
-- Defense % 22
-- Defense Cap 65
-- Store TP 6
-----------------------------------------
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,5191)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.FOOD_HPP, 15)
target:addMod(dsp.mod.FOOD_HP_CAP, 150)
target:addMod(dsp.mod.VIT, 3)
target:addMod(dsp.mod.MND, -1)
target:addMod(dsp.mod.FOOD_DEFP, 22)
target:addMod(dsp.mod.FOOD_DEF_CAP, 65)
target:addMod(dsp.mod.STORETP, 6)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 15)
target:delMod(dsp.mod.FOOD_HP_CAP, 150)
target:delMod(dsp.mod.VIT, 3)
target:delMod(dsp.mod.MND, -1)
target:delMod(dsp.mod.FOOD_DEFP, 22)
target:delMod(dsp.mod.FOOD_DEF_CAP, 65)
target:delMod(dsp.mod.STORETP, 6)
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/serving_of_beaugreen_sautee.lua | 18 | 1404 | -----------------------------------------
-- ID: 4572
-- Item: serving_of_beaugreen_sautee
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Agility 1
-- Vitality -1
-- Ranged ATT % 7
-- Ranged ATT Cap 15
-----------------------------------------
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,4572);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, 1);
target:addMod(MOD_VIT, -1);
target:addMod(MOD_FOOD_RATTP, 7);
target:addMod(MOD_FOOD_RATT_CAP, 15);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, 1);
target:delMod(MOD_VIT, -1);
target:delMod(MOD_FOOD_RATTP, 7);
target:delMod(MOD_FOOD_RATT_CAP, 15);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/istiridye.lua | 18 | 1404 | -----------------------------------------
-- ID: 5456
-- Item: Istiridye
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity -5
-- Vitality 4
-- Defense +17.07%
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0
if (target:getRace() ~= 7) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_FISH) == 1) then
result = 0;
end
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5456);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, -5);
target:addMod(MOD_VIT, 4);
target:addMod(MOD_DEFP, 17.07);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, -5);
target:delMod(MOD_VIT, 4);
target:delMod(MOD_DEFP, 17.07);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Southern_San_dOria/npcs/Gizel.lua | 14 | 1503 | -----------------------------------
-- Area: Southern San dOria
-- NPC: Gizel
-- Type: Event Scene Replayer NPC
-- @zone 230
-- @pos -34.412 0.000 33.362
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Southern_San_dOria/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
local FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
local count = trade:getItemCount();
local MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x02a4);
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/barblizzara.lua | 1 | 1426 | -----------------------------------------
-- Spell: BARBLIZZARA
-----------------------------------------
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_PERPETUANCE)) then
duration = duration * 2;
end
if (caster:hasStatusEffect(EFFECT_RAPTURE)) then
power = power * 1.5;
end
if (caster:hasStatusEffect(EFFECT_COMPOSURE) == true and caster:getID() == target:getID()) then
duration = duration * 3;
end
if ((caster:getID() == target:getID()) and target:getEffectsCount(EFFECT_IGNIS) >= 1) then
power = power * 1.25;
mdefBonus = mdefBonus + 10;
end
power, duration = applyEmbolden(caster, power, duration);
target:addStatusEffect(EFFECT_BARBLIZZARD,power,0,duration,0,mdefBonus);
return EFFECT_BARBLIZZARD;
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Southern_San_dOria/npcs/Thadiene.lua | 17 | 2118 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Thadiene
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
local FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
local count = trade:getItemCount();
local MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,ASH_THADI_ENE_SHOP_DIALOG);
local stock = {0x4380,1575,1, --Boomerang
0x430a,19630,1, --Great Bow
--0x43a9,16,1, --Silver Arrow
0x4302,7128,1, --Wrapped Bow
0x43b8,5,2, --Crossbow Bolt
0x43aa,126,2, --Fire Arrow
0x43a8,7,2, --Iron Arrow
0x4301,482,2, --Self Bow
0x4308,442,3, --Longbow
0x4300,38,3, --Shortbow
0x43a6,3,3, --Wooden Arrow
0x13a5,4320,3} --Scroll of Battlefield Elegy
showNationShop(player, NATION_SANDORIA, 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 |
syntafin/prosody-modules | mod_muc_log/mod_muc_log.lua | 32 | 4843 | -- Copyright (C) 2009 Thilo Cestonaro
-- Copyright (C) 2009 Waqas Hussain
-- Copyright (C) 2009-2013 Matthew Wild
-- Copyright (C) 2013 Kim Alvefur
-- Copyright (C) 2013 Marco Cirillo
local hosts = prosody.hosts;
local tostring = tostring;
local split_jid = require "util.jid".split;
local datamanager = require"core.storagemanager".olddm;
local data_load, data_store = datamanager.load, datamanager.store;
local datastore = "muc_log";
local muc_form_config_option = "muc#roomconfig_enablelogging"
local log_by_default = module:get_option_boolean("muc_log_by_default", false);
local log_presences = module:get_option_boolean("muc_log_presences", true);
-- Module Definitions
local function get_room_from_jid(jid)
local node, host = split_jid(jid);
local component = hosts[host];
if component then
local muc = component.modules.muc
if muc and rawget(muc,"rooms") then
-- We're running 0.9.x or 0.10 (old MUC API)
return muc.rooms[jid];
elseif muc and rawget(muc,"get_room_from_jid") then
-- We're running >0.10 (new MUC API)
return muc.get_room_from_jid(jid);
else
return
end
end
end
local function logging_enabled(room)
local enabled = room._data.logging;
if enabled == nil then
return log_by_default;
end
return enabled;
end
function log_if_needed(event)
local stanza = event.stanza;
if (stanza.name == "presence") or
(stanza.name == "iq") or
(stanza.name == "message" and tostring(stanza.attr.type) == "groupchat")
then
local node, host = split_jid(stanza.attr.to);
if node and host then
local bare = node .. "@" .. host;
if get_room_from_jid(bare) then
local room = get_room_from_jid(bare)
local today = os.date("!%y%m%d");
local now = os.date("!%H:%M:%S");
local muc_to = nil
local muc_from = nil;
local already_joined = false;
if room._data.hidden then -- do not log any data of private rooms
return;
end
if not logging_enabled(room) then -- do not log where logging is not enabled
return;
end
if stanza.name == "presence" and stanza.attr.type == nil then
muc_from = stanza.attr.to;
if room._occupants and room._occupants[stanza.attr.to] then
already_joined = true;
stanza:tag("alreadyJoined"):text("true");
end
elseif stanza.name == "iq" and stanza.attr.type == "set" then -- kick, to is the room, from is the admin, nick who is kicked is attr of iq->query->item
if stanza.tags[1] and stanza.tags[1].name == "query" then
local tmp = stanza.tags[1];
if tmp.tags[1] ~= nil and tmp.tags[1].name == "item" and tmp.tags[1].attr.nick then
tmp = tmp.tags[1];
for jid, nick in pairs(room._jid_nick) do
if nick == stanza.attr.to .. "/" .. tmp.attr.nick then
muc_to = nick;
break;
end
end
end
end
else
for jid, nick in pairs(room._jid_nick) do
if jid == stanza.attr.from then
muc_from = nick;
break;
end
end
end
if (muc_from or muc_to) then
local data = data_load(node, host, datastore .. "/" .. today);
local realFrom = stanza.attr.from;
local realTo = stanza.attr.to;
if data == nil then
data = {};
end
stanza.attr.from = muc_from;
stanza.attr.to = muc_to;
data[#data + 1] = "<stanza time=\"".. now .. "\">" .. tostring(stanza) .. "</stanza>\n";
stanza.attr.from = realFrom;
stanza.attr.to = realTo;
if already_joined == true then
if stanza[#stanza].name == "alreadyJoined" then -- normaly the faked element should be the last, remove it when it is the last
stanza[#stanza] = nil;
else
for i = 1, #stanza, 1 do
if stanza[i].name == "alreadyJoined" then -- remove the faked element
stanza[i] = nil;
break;
end
end
end
end
datamanager.getpath(node, host, datastore, nil, true); -- create the datastore dir
data_store(node, host, datastore .. "/" .. today, data);
end
end
end
end
end
module:hook("muc-config-form", function(event)
local room, form = event.room, event.form;
table.insert(form,
{
name = muc_form_config_option,
type = "boolean",
label = "Enable Logging?",
value = logging_enabled(room),
}
);
end);
module:hook("muc-config-submitted", function(event)
local room, fields, changed = event.room, event.fields, event.changed;
local new = fields[muc_form_config_option];
if new ~= room._data.logging then
room._data.logging = new;
if type(changed) == "table" then
changed[muc_form_config_option] = true;
else
event.changed = true;
end
end
end);
module:hook("message/bare", log_if_needed, 1);
if log_presences then
module:hook("iq/bare", log_if_needed, 1);
module:hook("presence/full", log_if_needed, 1);
end
module:log("debug", "module mod_muc_log loaded!");
| mit |
Colettechan/darkstar | scripts/globals/items/plate_of_octopus_sushi_+1.lua | 18 | 1324 | -----------------------------------------
-- ID: 5694
-- Item: plate_of_octopus_sushi_+1
-- Food Effect: 60Min, All Races
-----------------------------------------
-- Strength 2
-- Accuracy % 17 (Unknown, assuming 1% more than NQ)
-----------------------------------------
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,5693);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 2);
target:addMod(MOD_FOOD_ACCP, 17);
target:addMod(MOD_FOOD_ACC_CAP, 999);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 2);
target:delMod(MOD_FOOD_ACCP, 17);
target:delMod(MOD_FOOD_ACC_CAP, 999);
end;
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.